[PATCH 1/1] Xilinx uartlite serial driver: Add lock in isr to avoid SMP race condition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Trasmitted characters could be lost or written twice due to a missing lock
in the critical section of the isr. The missing lock causes a race condition
on SMP systems between ulite_transmit when called from the isr and
ulite_start_tx as they can execute simultaneously on separate cores. The call
from ulite_start_tx is made from serial_core.c with the lock taken.

Signed-off-by: Kris Modrak <krismodrak@xxxxxxxxxxx>
---
 drivers/tty/serial/uartlite.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 9fc22f4..ee151a2 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -196,9 +196,13 @@ static irqreturn_t ulite_isr(int irq, void *dev_id)
 	int busy, n = 0;
 
 	do {
-		int stat = uart_in32(ULITE_STATUS, port);
+		int stat;
+
+		spin_lock(&port->lock);
+		stat = uart_in32(ULITE_STATUS, port);
 		busy  = ulite_receive(port, stat);
 		busy |= ulite_transmit(port, stat);
+		spin_unlock(&port->lock);
 		n++;
 	} while (busy);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux