From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: linux-serial@vger.kernel.org, imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v14 6/8] serial: 8250: drain canceled TX DMA before reusing its buffer
Date: Fri, 04 Dec 2026 10:31:01 +0000 [thread overview]
Message-ID: <sashiko-outbox-249601@kernel.org> (raw)
In-Reply-To: <20261204-submit-serial-8250-dma-cancel-v1-v14-6-b691fec8097d@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] serial: 8250: duplicate uart_write_wakeup() on flushed TX DMA
completion
--
commit 51a77130997322f4f64bf1629b8c2f64b1ab9074
Author: James Hilliard <james.hilliard1@gmail.com>
serial: 8250: drain canceled TX DMA before reusing its buffer
This commit reserves the flushed TX FIFO storage and defers clearing
tx_running to a workqueue that synchronizes the terminated DMA channel before
completing the transfer and unblocking writers.
> diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
> index 43c55cb991a52..739a8238e4dec 100644
> --- a/drivers/tty/serial/8250/8250_dma.c
> +++ b/drivers/tty/serial/8250/8250_dma.c
> @@ -11,34 +11,79 @@
>
> #include "8250.h"
>
> -static void __dma_tx_complete(void *param)
> +static void serial8250_tx_dma_complete(struct uart_8250_port *p)
> {
> - struct uart_8250_port *p = param;
> struct uart_8250_dma *dma = p->dma;
> - unsigned long flags;
> int ret;
>
> - uart_port_lock_irqsave(&p->port, &flags);
> - if (dma->shutting_down)
> - goto out;
> -
> dma_sync_single_for_cpu(dmaengine_get_dma_device(dma->txchan), dma->tx_addr,
> UART_XMIT_SIZE, DMA_TO_DEVICE);
>
> dma->tx_running = 0;
>
> - uart_xmit_advance(&p->port, dma->tx_size);
> + if (dma->tx_flushed) {
> + p->port.icount.tx += dma->tx_size;
> + uart_xmit_unblock(&p->port);
> + } else {
> + uart_xmit_advance(&p->port, dma->tx_size);
> + }
>
> uart_write_wakeup_if_needed(&p->port);
[Severity: Medium]
Does this invoke uart_write_wakeup() twice on every flushed TX DMA
completion?
uart_xmit_unblock() already calls uart_write_wakeup(). Because p->port.lock
remains held and the flushed FIFO is empty, the following
uart_write_wakeup_if_needed() always calls uart_write_wakeup() a second time.
On SMP, a writer woken by the first wakeup can re-arm TTY_DO_WRITE_WAKEUP
before spinning on p->port.lock in uart_write(), letting the second wakeup
consume that bit prematurely:
CPU0 CPU1
serial8250_tx_dma_complete()
[holds p->port.lock]
uart_xmit_unblock(&p->port)
uart_write_wakeup()
ttyport_write_buf()
set_bit(TTY_DO_WRITE_WAKEUP, ...)
uart_write()
spin on p->port.lock
uart_write_wakeup_if_needed()
uart_write_wakeup()
ttyport_write_wakeup()
test_and_clear_bit(TTY_DO_WRITE_WAKEUP, ...) <-- spurious wakeup
The same pattern appears in omap_8250_tx_dma_complete(), where
uart_xmit_unblock() also runs before omap8250_restore_regs(), waking writers
to spin on p->port.lock during register restoration and widening the window
between the two wakeups.
Moving uart_write_wakeup_if_needed() into the else branch, and calling
uart_xmit_unblock() after omap8250_restore_regs() on OMAP, would avoid both
issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-submit-serial-8250-dma-cancel-v1-v14-0-b691fec8097d@gmail.com?part=6
next prev parent reply other threads:[~2026-12-04 10:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 10:03 [PATCH v14 0/8] serial: 8250: serialize DMA cancellation with buffer reuse James Hilliard
2026-12-04 10:03 ` [PATCH v14 1/8] serial: 8250_omap: separate locked TX DMA completion processing James Hilliard
2026-12-04 10:18 ` sashiko-bot
2026-12-04 10:03 ` [PATCH v14 2/8] serial: serialize asynchronous write wakeups with the port lock James Hilliard
2026-12-04 10:30 ` sashiko-bot
2026-12-04 10:03 ` [PATCH v14 3/8] serial: 8250_omap: serialize RX DMA completion and flushing James Hilliard
2026-12-04 10:20 ` sashiko-bot
2026-12-04 10:03 ` [PATCH v14 4/8] serial: 8250_omap: quiesce DMA IRQ handling before shutdown James Hilliard
2026-12-04 10:03 ` [PATCH v14 5/8] serial: core: allow drivers to reserve flushed transmit storage James Hilliard
2026-12-04 10:37 ` sashiko-bot
2026-12-04 10:03 ` [PATCH v14 6/8] serial: 8250: drain canceled TX DMA before reusing its buffer James Hilliard
2026-12-04 10:31 ` sashiko-bot [this message]
2026-12-04 10:03 ` [PATCH v14 7/8] serial: 8250: retire canceled RX DMA before reusing the receive buffer James Hilliard
2026-12-04 10:44 ` sashiko-bot
2026-12-04 10:03 ` [PATCH v14 8/8] serial: 8250: retain DMA resources when termination fails James Hilliard
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=sashiko-outbox-249601@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=james.hilliard1@gmail.com \
--cc=linux-serial@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox