* [PATCH v2] serial: 8250_mid: lock RX DMA timeout flushing
@ 2026-12-04 9:59 James Hilliard
2026-12-04 10:07 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: James Hilliard @ 2026-12-04 9:59 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Ilpo Järvinen,
Chuah, Kim Tatt, Vinod Koul, Andy Shevchenko
Cc: Andy Shevchenko, Heikki Krogerus, Raul E Rangel, linux-serial,
linux-kernel, stable, James Hilliard
The Tangier and Denverton DMA timeout handlers call
serial8250_rx_dma_flush() without holding the UART port lock. The helper
pauses the transfer, copies received data, updates RX state and terminates
the channel. The DMA completion callback accesses the same state under the
port lock, so it can race an unlocked timeout flush. The IRQ-chain lock
held by serial8250_interrupt() does not serialize the completion callback.
Take the port lock around each timeout flush. Release it before handling
the UART interrupt, since serial8250_handle_irq() acquires the port lock
itself.
Fixes: 692aa1905679 ("serial: 8250_mid: Read RX buffer on RX DMA timeout for DNV")
Fixes: 4831e0d9054c ("serial: 8250_mid: handle interrupt correctly in DMA case")
Cc: stable@vger.kernel.org
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Previously included in the DMA cancellation series v4:
https://lore.kernel.org/r/20261023-submit-serial-8250-dma-cancel-v1-v4-0-e759de1839de@gmail.com
---
Changes in v2:
- Rebase on current tty-next for resubmission.
- Link to v1: https://patch.msgid.link/20261024-submit-serial-8250-mid-rx-lock-v1-v1-1-2b9afdf869d7@gmail.com
---
drivers/tty/serial/8250/8250_mid.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c
index df721418e97e..81a1081abfdd 100644
--- a/drivers/tty/serial/8250/8250_mid.c
+++ b/drivers/tty/serial/8250/8250_mid.c
@@ -94,7 +94,8 @@ static int tng_handle_irq(struct uart_port *p)
/* Rx DMA */
err = hsu_dma_get_status(chip, mid->dma_index * 2 + 1, &status);
if (err > 0) {
- serial8250_rx_dma_flush(up);
+ scoped_guard(uart_port_lock_irqsave, p)
+ serial8250_rx_dma_flush(up);
ret |= 1;
} else if (err == 0)
ret |= hsu_dma_do_irq(chip, mid->dma_index * 2 + 1, status);
@@ -148,7 +149,8 @@ static int dnv_handle_irq(struct uart_port *p)
if (fisr & BIT(2)) {
err = hsu_dma_get_status(&mid->dma_chip, 1, &status);
if (err > 0) {
- serial8250_rx_dma_flush(up);
+ scoped_guard(uart_port_lock_irqsave, p)
+ serial8250_rx_dma_flush(up);
ret |= 1;
} else if (err == 0)
ret |= hsu_dma_do_irq(&mid->dma_chip, 1, status);
---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
base-tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-next
change-id: 20261024-submit-serial-8250-mid-rx-lock-v1-21c66e80df80
Best regards,
--
James Hilliard <james.hilliard1@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] serial: 8250_mid: lock RX DMA timeout flushing
2026-12-04 9:59 [PATCH v2] serial: 8250_mid: lock RX DMA timeout flushing James Hilliard
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 20:12 ` James Hilliard
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: James Hilliard
Cc: Jiri Slaby, Ilpo Järvinen, Chuah, Kim Tatt, Vinod Koul,
Andy Shevchenko, Andy Shevchenko, Heikki Krogerus, Raul E Rangel,
linux-serial, linux-kernel, stable
<snip>
Wait, why are you sending multiple patches for 8250 that are NOT in a
series? What order are you expecting me to apply these in?
Here's how they look in my mbox:
1 N T Dec 04 James Hilliard (2.4K) [PATCH v2] serial: 8250_mid: lock RX DMA timeout flushing
6 N T Dec 04 James Hilliard (3.5K) [PATCH v2] serial: 8250: release the transmit PM reference on shutdown
8 N T Dec 04 James Hilliard (2.1K) [PATCH v3] serial: 8250: calculate TX length before preparing DMA flow control
10 N T Dec 04 James Hilliard (1.6K) [PATCH v2] serial: 8250: account for partial receive DMA delivery to TTY
12 N T Dec 04 James Hilliard (2.1K) [PATCH v2] serial: 8250: check DMA channel configuration errors
13 N T Dec 04 James Hilliard (7.2K) [PATCH v2] serial: 8250: prevent DMA callbacks from restarting a closing port
15 N T Dec 04 James Hilliard (2.7K) [PATCH v2] serial: 8250: clear RX trigger callbacks when removing a port
18 N T Dec 04 James Hilliard (6.5K) [PATCH v5] serial: 8250_dw: preserve BUSY-safe fractional divisor programming
What's the odds that's the correct order? (hint, not likely....)
Please send these as patch series. Think about the reciever of your
patches please.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] serial: 8250_mid: lock RX DMA timeout flushing
2026-12-04 10:07 ` Greg Kroah-Hartman
@ 2026-12-04 20:12 ` James Hilliard
0 siblings, 0 replies; 3+ messages in thread
From: James Hilliard @ 2026-12-04 20:12 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Ilpo Järvinen, Chuah, Kim Tatt, Vinod Koul,
Andy Shevchenko, Andy Shevchenko, Heikki Krogerus, Raul E Rangel,
linux-serial, linux-kernel, stable
On Fri, Dec 4, 2026 at 3:07 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> <snip>
>
> Wait, why are you sending multiple patches for 8250 that are NOT in a
> series? What order are you expecting me to apply these in?
I posted them separately because the two series that build on them
need different fixes. These independent patches actually do not
depend on each other and can be applied in any order.
The series that depend on them however do require their listed
dependencies to be applied first.
>
> Here's how they look in my mbox:
>
> 1 N T Dec 04 James Hilliard (2.4K) [PATCH v2] serial: 8250_mid: lock RX DMA timeout flushing
> 6 N T Dec 04 James Hilliard (3.5K) [PATCH v2] serial: 8250: release the transmit PM reference on shutdown
> 8 N T Dec 04 James Hilliard (2.1K) [PATCH v3] serial: 8250: calculate TX length before preparing DMA flow control
> 10 N T Dec 04 James Hilliard (1.6K) [PATCH v2] serial: 8250: account for partial receive DMA delivery to TTY
> 12 N T Dec 04 James Hilliard (2.1K) [PATCH v2] serial: 8250: check DMA channel configuration errors
> 13 N T Dec 04 James Hilliard (7.2K) [PATCH v2] serial: 8250: prevent DMA callbacks from restarting a closing port
> 15 N T Dec 04 James Hilliard (2.7K) [PATCH v2] serial: 8250: clear RX trigger callbacks when removing a port
> 18 N T Dec 04 James Hilliard (6.5K) [PATCH v5] serial: 8250_dw: preserve BUSY-safe fractional divisor programming
>
> What's the odds that's the correct order? (hint, not likely....)
The order in your mbox works. I checked the posted patches against
tty-next, and any order gives the same result. It's the two later
series that need some of these fixes first: DMA cancellation [0] uses
six of them, and H616/A523 [1] uses the DW divisor and RX trigger
callback fixes.
[0] https://lore.kernel.org/r/20261204-submit-serial-8250-dma-cancel-v1-v14-0-b691fec8097d@gmail.com/
[1] https://lore.kernel.org/r/20261204-submit-h616-uart-fifo-v1-v10-0-1a9fb4f79635@gmail.com/
> Please send these as patch series. Think about the reciever of your
> patches please.
I didn't think the individual patches needed an ordering note, since
none of the eight conflicts with or depends on another.
In general when I'm sending patches where there are dependencies
or ordering requirements those will appear in the b4 metadata as
prerequisites and/or in a cover letter or patch notes.
I didn't put the 8 patches in a series because I didn't want to imply
that they depended on each other or imply that they needed to be
reviewed/applied together or in a specific order.
The two series that do depend on the independent patches
explicitly list their requirements.
>
> greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-04 20:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 9:59 [PATCH v2] serial: 8250_mid: lock RX DMA timeout flushing James Hilliard
2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 20:12 ` James Hilliard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox