From: sashiko-bot@kernel.org
To: "Moteen Shah" <m-shah@ti.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
linux-serial@vger.kernel.org
Subject: Re: [PATCH v2 2/2] serial: 8250_dw: Add capability to skip empty FIFO read
Date: Wed, 16 Sep 2026 09:05:41 +0000 [thread overview]
Message-ID: <20260916090542.40DFE1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916085520.2259420-3-m-shah@ti.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] tty: serial: 8250: lockless data race on lsr_saved_flags in serial8250_do_shutdown()
--
commit 174d9274c3df70fd0549f2a70fbdf6e13b92b8d2
Author: Moteen Shah <m-shah@ti.com>
serial: 8250_dw: Add capability to skip empty FIFO read
This commit introduces a new UART capability to guard against empty FIFO
reads during startup and shutdown. This prevents data aborts on the TDA54
IP block where reading an empty FIFO is fatal.
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index 38fa45e74a37a..f533310145849 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
[ ... ]
> @@ -2455,7 +2460,8 @@ void serial8250_do_shutdown(struct uart_port *port)
> * Read data port to reset things, and then unlink from
> * the IRQ chain.
> */
> - serial_port_in(port, UART_RX);
> + if (!(up->capabilities & UART_CAP_RXFIFO_EMPTY_READ) || (serial_lsr_in(up) & UART_LSR_DR))
> + serial_port_in(port, UART_RX);
[Severity: Medium]
Does calling serial_lsr_in() here introduce a data race on up->lsr_saved_flags?
In serial8250_do_shutdown(), the uart_port_lock is explicitly released
before reaching this point. Calling serial_lsr_in() locklessly causes a
read-modify-write operation on the shared lsr_saved_flags state:
drivers/tty/serial/8250/8250.h:serial_lsr_in() {
u16 lsr = up->lsr_saved_flags;
lsr |= serial_in(up, UART_LSR);
up->lsr_saved_flags = lsr & up->lsr_save_mask;
return lsr;
}
If a console write occurs concurrently (e.g. an asynchronous printk() from
another CPU), serial8250_console_write() will also invoke serial_lsr_in()
via wait_for_xmitr() while holding the lock. Can this race corrupt the
lsr_saved_flags state?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260916085520.2259420-1-m-shah@ti.com?part=2
next prev parent reply other threads:[~2026-09-16 9:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 8:55 [PATCH v2 0/2] serial: 8250_dw: Add ti,tda54-uart support Moteen Shah
2026-09-16 8:55 ` [PATCH v2 1/2] dt-bindings: serial: snps-dw-apb-uart: Add ti,tda54-uart Moteen Shah
2026-09-16 8:59 ` sashiko-bot
2026-09-16 8:55 ` [PATCH v2 2/2] serial: 8250_dw: Add capability to skip empty FIFO read Moteen Shah
2026-09-16 9:05 ` sashiko-bot [this message]
2026-09-16 10:52 ` Ilpo Järvinen
2026-09-16 12:55 ` Moteen Shah
2026-09-16 14:32 ` Hari Prasath G E
2026-09-16 13:47 ` Kumar, Udit
2026-09-17 9:40 ` Ilpo Järvinen
2026-09-18 4:05 ` Kumar, Udit
2026-09-18 9:23 ` Moteen Shah
2026-09-18 9:56 ` Ilpo Järvinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260916090542.40DFE1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=m-shah@ti.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.