summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/pxa.c
diff options
context:
space:
mode:
authorChao Xie <chao.xie@marvell.com>2012-06-14 12:18:46 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-15 15:04:49 -0700
commitcfe275c2db6932e81ea23288a8a74f0b815c9513 (patch)
tree18fe17fda676d1058eee52c0dec06a82670e1697 /drivers/tty/serial/pxa.c
parent2fc46915ecfbc51afcf995901f6ade7c3d503a25 (diff)
downloadblackbird-op-linux-cfe275c2db6932e81ea23288a8a74f0b815c9513.tar.gz
blackbird-op-linux-cfe275c2db6932e81ea23288a8a74f0b815c9513.zip
serial: pxa: add spin lock for console write
v3: Remove empty line v2: Move local_irq_save() after clk_prepare_enable() v1: At UP mode, when cpu want to print message in kernel, it will invoke peempt_disable and disable irq. So it is safe for UP mode. For SMP mode, it is not safe to protect the HW reigsters. one CPU will run a program which will invoke printf. another CPU will run a program in kernel that invoke printk. So when second CPU is trying to printk, it will do 1. save ier register 2. enable uue bit of ier register 3. push buffer to uart fifo 4 .restore ier register when first CPU want to printf, and it happens between 1 and 4, it will enable thre bit of ier, and waiting for transmit intterupt. while step 4 will make the ier lost thre bit. add spin lock here to protect the ier register for console write. Signed-off-by: Chao Xie <chao.xie@marvell.com> Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/pxa.c')
-rw-r--r--drivers/tty/serial/pxa.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
index 5847a4b855f7..9033fc6e0e4e 100644
--- a/drivers/tty/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
@@ -670,9 +670,19 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
{
struct uart_pxa_port *up = serial_pxa_ports[co->index];
unsigned int ier;
+ unsigned long flags;
+ int locked = 1;
clk_prepare_enable(up->clk);
+ local_irq_save(flags);
+ if (up->port.sysrq)
+ locked = 0;
+ else if (oops_in_progress)
+ locked = spin_trylock(&up->port.lock);
+ else
+ spin_lock(&up->port.lock);
+
/*
* First save the IER then disable the interrupts
*/
@@ -688,6 +698,10 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
wait_for_xmitr(up);
serial_out(up, UART_IER, ier);
+ if (locked)
+ spin_unlock(&up->port.lock);
+ local_irq_restore(flags);
+
clk_disable_unprepare(up->clk);
}
OpenPOWER on IntegriCloud