[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220712131523.1874428-1-vamshigajjela@google.com>
Date: Tue, 12 Jul 2022 18:45:23 +0530
From: Vamshi Gajjela <vamshigajjela@...gle.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>
Cc: Miquel Raynal <miquel.raynal@...tlin.com>,
Phil Edworthy <phil.edworthy@...esas.com>,
Emil Renner Berthing <kernel@...il.dk>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Johan Hovold <johan@...nel.org>, linux-serial@...r.kernel.org,
linux-kernel@...r.kernel.org,
VAMSHI GAJJELA <vamshigajjela@...gle.com>
Subject: [PATCH] serial: 8250_dw: Avoid pslverr on reading empty receiver fifo
From: VAMSHI GAJJELA <vamshigajjela@...gle.com>
With PSLVERR_RESP_EN parameter set to 1, device generates an error
response when an attempt to read empty RBR with FIFO enabled.
This happens when LCR writes are ignored when UART is busy.
dw8250_check_lcr() in retries to updateLCR, invokes dw8250_force_idle()
to clear and reset fifo and eventually reads UART_RX causing pslverr.
Avoid this by not reading RBR/UART_RX when no data is available.
Signed-off-by: VAMSHI GAJJELA <vamshigajjela@...gle.com>
---
drivers/tty/serial/8250/8250_dw.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index f57bbd32ef11..a83222839884 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -81,9 +81,19 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)
static void dw8250_force_idle(struct uart_port *p)
{
+ unsigned int lsr;
struct uart_8250_port *up = up_to_u8250p(p);
serial8250_clear_and_reinit_fifos(up);
+
+ /*
+ * With PSLVERR_RESP_EN parameter set to 1, device generates pslverr
+ * error response when an attempt to read empty RBR with FIFO enabled
+ */
+ lsr = p->serial_in(p, UART_LSR);
+ if ((up->fcr & UART_FCR_ENABLE_FIFO) && !(lsr & UART_LSR_DR))
+ return;
+
(void)p->serial_in(p, UART_RX);
}
--
2.37.0.144.g8ac04bfd2-goog
Powered by blists - more mailing lists