Re: [PATCH v9 3/4] serial: 8250: avoid potential PSLVERR issue

From: John Ogness
Date: Fri Jun 20 2025 - 07:21:13 EST


On 2025-06-10, Yunhui Cui <cuiyunhui@xxxxxxxxxxxxx> wrote:
> When the PSLVERR_RESP_EN parameter is set to 1, reading UART_RX while
> the FIFO is enabled and UART_LSR_DR is not set will generate a PSLVERR
> error.
>
> Failure to check the UART_LSR_DR before reading UART_RX, or the non-
> atomic nature of clearing the FIFO and reading UART_RX, poses
> potential risks that could lead to PSLVERR.
>
> PSLVERR is addressed through two methods. One is to introduce
> serial8250_discard_data() to check whether UART_LSR_DR is set before
> reading UART_RX, thus solving the PSLVERR issue when the FIFO is
> enabled. The other is to place FIFO clearing and reading of UART_RX
> under port->lock.
>
> Signed-off-by: Yunhui Cui <cuiyunhui@xxxxxxxxxxxxx>

Reviewed-by: John Ogness <john.ogness@xxxxxxxxxxxxx>