[PATCH] serial: 8250_dw: Prefer SRBR in bogus RX timeout workaround if available
From: Yicong Yang
Date: Mon Jun 29 2026 - 04:05:05 EST
The DW uart could get into the cases where a bogus RX timeout
interrupt is asserted but no available data. This could be
workaround by doing a bogus read.
Currently the driver's using the standard RBR (receive buffer
register) for this bogus read. However the reading of RBR
in this case is allowed to raise a hardware error if vendor
choose to implement in this way (our platform). It's also
allowed to do the bogus read using SRBR (shadow RBR) for
workaround which won't raise the hardware error. So change
to use the SRBR to workaround the issue if it's available.
Signed-off-by: Yicong Yang <yang.yicong@xxxxxxxxxxxxx>
---
drivers/tty/serial/8250/8250_dw.c | 15 +++++++++++++--
drivers/tty/serial/8250/8250_dwlib.c | 3 +++
drivers/tty/serial/8250/8250_dwlib.h | 4 ++++
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 84ffba045ffa..fea7dfa30e78 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -440,8 +440,19 @@ static int dw8250_handle_irq(struct uart_port *p)
if (!up->dma && rx_timeout) {
status = serial_lsr_in(up);
- if (!(status & (UART_LSR_DR | UART_LSR_BI)))
- serial_port_in(p, UART_RX);
+ if (!(status & (UART_LSR_DR | UART_LSR_BI))) {
+ /*
+ * Do the bogus read from Shadow RBR (SRBR) if provided.
+ * Both RBR and SRBR are supported ways to workaround
+ * this problem. But read RBR can cause hardware error
+ * (PSLVERR) if hardware choose to implement in this way
+ * (implement REG_TIMEOUT_WIDTH to 0), whereas SRBR won't.
+ */
+ if (d->data.shadow_support)
+ serial_port_in(p, DW_UART_SRBR_0);
+ else
+ serial_port_in(p, UART_RX);
+ }
}
/* Manually stop the Rx DMA transfer when acting as flow controller */
diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
index 8859e66d2d71..19d997a59541 100644
--- a/drivers/tty/serial/8250/8250_dwlib.c
+++ b/drivers/tty/serial/8250/8250_dwlib.c
@@ -247,5 +247,8 @@ void dw8250_setup_port(struct uart_port *p)
if (reg & DW_UART_CPR_SIR_MODE)
up->capabilities |= UART_CAP_IRDA;
+
+ if (reg & DW_UART_CPR_SHADOW)
+ pd->shadow_support = true;
}
EXPORT_SYMBOL_GPL(dw8250_setup_port);
diff --git a/drivers/tty/serial/8250/8250_dwlib.h b/drivers/tty/serial/8250/8250_dwlib.h
index 1fe52332e774..3ad412d984ed 100644
--- a/drivers/tty/serial/8250/8250_dwlib.h
+++ b/drivers/tty/serial/8250/8250_dwlib.h
@@ -13,6 +13,7 @@
#include "8250.h"
/* Offsets for the DesignWare specific registers */
+#define DW_UART_SRBR_0 0x0c /* Shadow Receive Buffer Register */
#define DW_UART_USR 0x1f /* UART Status Register */
#define DW_UART_DMASA 0xa8 /* DMA Software Ack */
#define DW_UART_TCR 0xac /* Transceiver Control Register (RS485) */
@@ -90,6 +91,9 @@ struct dw8250_port_data {
/* RS485 variables */
bool hw_rs485_support;
+
+ /* Support Shadow registers */
+ bool shadow_support;
};
void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, const struct ktermios *old);
--
2.50.1 (Apple Git-155)