[PATCH] serial: lpuart32: fix rx stall on FIFO overflow

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

 



When the rx FIFO overruns then no new characters are received, even
when the FIFO is read from and space becomes available again.
Acknowledge the overrun in this case to let the UART continue to work.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/serial/serial_lpuart32.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/serial/serial_lpuart32.c b/drivers/serial/serial_lpuart32.c
index 0f3e7c7a04..09d4b620be 100644
--- a/drivers/serial/serial_lpuart32.c
+++ b/drivers/serial/serial_lpuart32.c
@@ -44,6 +44,17 @@ static void lpuart32_disable(struct lpuart32 *lpuart32)
 	writel(0, lpuart32->base + LPUART32_UARTCTRL);
 }
 
+/* Test whether a character is in the RX buffer */
+static int lpuart32_serial_tstc(struct console_device *cdev)
+{
+	struct lpuart32 *lpuart32 = cdev_to_lpuart32(cdev);
+
+	if (readl(lpuart32->base + LPUART32_UARTSTAT) & LPUART32_UARTSTAT_OR)
+		writel(LPUART32_UARTSTAT_OR, lpuart32->base + LPUART32_UARTSTAT);
+
+	return readl(lpuart32->base + LPUART32_UARTSTAT) & LPUART32_UARTSTAT_RDRF;
+}
+
 static int lpuart32_serial_setbaudrate(struct console_device *cdev,
 				     int baudrate)
 {
@@ -69,7 +80,7 @@ static int lpuart32_serial_getc(struct console_device *cdev)
 {
 	struct lpuart32 *lpuart32 = cdev_to_lpuart32(cdev);
 
-	while (!(readl(lpuart32->base + LPUART32_UARTSTAT) & LPUART32_UARTSTAT_RDRF));
+	while (!lpuart32_serial_tstc(cdev));
 
 	return readl(lpuart32->base + LPUART32_UARTDATA) & 0xff;
 }
@@ -81,14 +92,6 @@ static void lpuart32_serial_putc(struct console_device *cdev, char c)
 	lpuart32_putc(lpuart32->base, c);
 }
 
-/* Test whether a character is in the RX buffer */
-static int lpuart32_serial_tstc(struct console_device *cdev)
-{
-	struct lpuart32 *lpuart32 = cdev_to_lpuart32(cdev);
-
-	return readl(lpuart32->base + LPUART32_UARTSTAT) & LPUART32_UARTSTAT_RDRF;
-}
-
 static void lpuart32_serial_flush(struct console_device *cdev)
 {
 }
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux