* [PATCH v2] serial: 8250_dw: Prefer SRBR in bogus RX timeout workaround if available
@ 2026-09-07 7:40 Yicong Yang
2026-09-07 7:49 ` sashiko-bot
2026-09-08 10:25 ` Andy Shevchenko
0 siblings, 2 replies; 4+ messages in thread
From: Yicong Yang @ 2026-09-07 7:40 UTC (permalink / raw)
To: ilpo.jarvinen, andriy.shevchenko, linux-serial, linux-kernel
Cc: gregkh, jirislaby, geshijian, yangyang.8776, yanligen,
yang.yicong
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@picoheart.com>
---
Change since v2:
- simply the workaround path per Ilpo and Andy
- run ~48k reboot tests and didn't reproduce the issue
Link: https://lore.kernel.org/linux-serial/20260629075510.32854-1-yang.yicong@picoheart.com/
drivers/tty/serial/8250/8250_dw.c | 9 ++++++++-
drivers/tty/serial/8250/8250_dwlib.c | 5 +++++
drivers/tty/serial/8250/8250_dwlib.h | 4 ++++
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 51d026f20825..b8a0bca8b536 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -439,8 +439,15 @@ static int dw8250_handle_irq(struct uart_port *p)
if (!up->dma && rx_timeout) {
status = serial_lsr_in(up);
+ /*
+ * 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 (!(status & (UART_LSR_DR | UART_LSR_BI)))
- serial_port_in(p, UART_RX);
+ serial_port_in(p, d->data.srbr);
}
/* 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..9bb02a4ab11f 100644
--- a/drivers/tty/serial/8250/8250_dwlib.c
+++ b/drivers/tty/serial/8250/8250_dwlib.c
@@ -247,5 +247,10 @@ 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->srbr = DW_UART_SRBR_0;
+ else
+ pd->srbr = UART_RX;
}
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..6cfe2ab2e2a0 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;
+
+ /* Shadow RBR offset, fallback to RBR if no shadow register support */
+ unsigned int srbr;
};
void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, const struct ktermios *old);
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] serial: 8250_dw: Prefer SRBR in bogus RX timeout workaround if available
2026-09-07 7:40 [PATCH v2] serial: 8250_dw: Prefer SRBR in bogus RX timeout workaround if available Yicong Yang
@ 2026-09-07 7:49 ` sashiko-bot
2026-09-08 10:25 ` Andy Shevchenko
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-09-07 7:49 UTC (permalink / raw)
To: Yicong Yang; +Cc: linux-serial
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Runtime PM is enabled after UART port registration, causing circular dependencies and hung threads.
--
commit eaccc720cb53d60702a5d31bbe2439896bdfd1ce
Author: Yicong Yang <yang.yicong@picoheart.com>
serial: 8250_dw: Prefer SRBR in bogus RX timeout workaround if available
The DW uart can get into a state where a bogus RX timeout interrupt is
asserted without available data. The driver currently works around this by
doing a bogus read from the standard RBR, but this can cause hardware errors
on some platforms. This commit changes the driver to prefer reading from the
Shadow RBR (SRBR) if available, avoiding the error.
Link: https://lore.kernel.org/linux-serial/20260629075510.32854-1-yang.yicong@picoheart.com/
> diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
> index 51d026f20825a..b8a0bca8b536f 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
[ ... ]
[Severity: High]
This is a pre-existing issue, but I noticed a potential circular dependency in
the device probe sequence:
drivers/tty/serial/8250/8250_dw.c:dw8250_probe() {
...
data->data.line = serial8250_register_8250_port(up);
if (data->data.line < 0)
return data->data.line;
platform_set_drvdata(pdev, data);
pm_runtime_enable(dev);
...
}
Does this ordering cause hung worker threads during device probe?
Calling serial8250_register_8250_port() invokes uart_add_one_port(), which
synchronously calls the pm() callback (dw8250_do_pm()) via uart_change_pm().
If the callback calls pm_runtime_get_sync() before runtime PM is enabled on
the device, the core will attempt operations on an uninitialized device,
leading to circular wait conditions.
Should pm_runtime_enable() be called before serial8250_register_8250_port()
to prevent this?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260907074035.77796-1-yang.yicong@picoheart.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] serial: 8250_dw: Prefer SRBR in bogus RX timeout workaround if available
2026-09-07 7:40 [PATCH v2] serial: 8250_dw: Prefer SRBR in bogus RX timeout workaround if available Yicong Yang
2026-09-07 7:49 ` sashiko-bot
@ 2026-09-08 10:25 ` Andy Shevchenko
2026-09-08 11:52 ` Yicong Yang
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2026-09-08 10:25 UTC (permalink / raw)
To: Yicong Yang
Cc: ilpo.jarvinen, linux-serial, linux-kernel, gregkh, jirislaby,
geshijian, yangyang.8776, yanligen
On Mon, Sep 07, 2026 at 03:40:35PM +0800, Yicong Yang wrote:
> 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.
...
> struct dw8250_port_data {
>
> /* RS485 variables */
> bool hw_rs485_support;
>
> + /* Shadow RBR offset, fallback to RBR if no shadow register support */
This comment is for "section", so split it to two
/* Register offsets */
/* Shadow RBR (if not defined RBR will be used) */
> + unsigned int srbr;
In APIs this defined as int, I would follow (however I agree that ideally in
all of them it should be unsigned).
int srbr;
> };
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] serial: 8250_dw: Prefer SRBR in bogus RX timeout workaround if available
2026-09-08 10:25 ` Andy Shevchenko
@ 2026-09-08 11:52 ` Yicong Yang
0 siblings, 0 replies; 4+ messages in thread
From: Yicong Yang @ 2026-09-08 11:52 UTC (permalink / raw)
To: Andy Shevchenko
Cc: yang.yicong, ilpo.jarvinen, linux-serial, linux-kernel, gregkh,
jirislaby, geshijian, yangyang.8776, yanligen
On 9/8/26 6:25 PM, Andy Shevchenko wrote:
> On Mon, Sep 07, 2026 at 03:40:35PM +0800, Yicong Yang wrote:
>> 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.
>
> ...
>
>> struct dw8250_port_data {
>
>>
>> /* RS485 variables */
>> bool hw_rs485_support;
>>
>> + /* Shadow RBR offset, fallback to RBR if no shadow register support */
>
> This comment is for "section", so split it to two
>
sure, will split.
> /* Register offsets */
> /* Shadow RBR (if not defined RBR will be used) */
>
>> + unsigned int srbr;
>
> In APIs this defined as int, I would follow (however I agree that ideally in
> all of them it should be unsigned).
>
> int srbr;
will make it int. I remembered that I referred to
uart_port::serial_{in, out}() that use unsigned int
for offset, but yes serial_port_{in, out}() use int.
will update in v3.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-08 11:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-07 7:40 [PATCH v2] serial: 8250_dw: Prefer SRBR in bogus RX timeout workaround if available Yicong Yang
2026-09-07 7:49 ` sashiko-bot
2026-09-08 10:25 ` Andy Shevchenko
2026-09-08 11:52 ` Yicong Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox