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 3/8] serial: 8250_omap: serialize RX DMA completion and flushing
Date: Fri, 04 Dec 2026 10:20:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-249590@kernel.org> (raw)
In-Reply-To: <20261204-submit-serial-8250-dma-cancel-v1-v14-3-b691fec8097d@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] serial: 8250_omap: AB-BA deadlock on port lock in
omap8250_runtime_suspend()
- [Low] serial: 8250_omap: redundant priv->rx_dma_lock under port lock
in RX DMA
--
commit b087c1c0ef62420632ac4cbef6f88f28c80c857c
Author: James Hilliard <james.hilliard1@gmail.com>
serial: 8250_omap: serialize RX DMA completion and flushing
This commit takes priv->rx_dma_lock under the port lock in
__dma_rx_complete(), acquires the port lock around omap_8250_rx_dma_flush()
during shutdown and runtime suspend, and adds lockdep assertions to the RX
DMA completion and flush helpers.
> diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
> index d18dca27a4c22..5e8a5aafdb6dc 100644
> --- a/drivers/tty/serial/8250/8250_omap.c
> +++ b/drivers/tty/serial/8250/8250_omap.c
[ ... ]
> @@ -977,7 +982,8 @@ static void __dma_rx_complete(void *param)
> if (dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state) != DMA_COMPLETE)
> return;
>
> - __dma_rx_do_complete(p);
> + scoped_guard(spinlock, &priv->rx_dma_lock)
> + __dma_rx_do_complete(p);
> if (priv->throttled)
> return;
[Severity: Low]
Is priv->rx_dma_lock still needed once every RX DMA path holds p->port.lock?
With this change, all three sites that acquire priv->rx_dma_lock
(__dma_rx_complete(), omap_8250_rx_dma_flush(), and omap_8250_rx_dma())
always hold p->port.lock, so priv->rx_dma_lock provides no extra mutual
exclusion.
Taking it here adds an uncontended spinlock acquire/release on every RX DMA
completion, right before omap_8250_rx_dma() takes it again under the same
port lock. If the runtime PM lock-ordering issue below allows keeping RX DMA
serialized by p->port.lock, removing priv->rx_dma_lock would simplify the
locking and avoid the extra overhead.
[ ... ]
> @@ -1811,8 +1819,10 @@ static int omap8250_runtime_suspend(struct device *dev)
> }
> }
>
> - if (up && up->dma && up->dma->rxchan)
> + if (up && up->dma && up->dma->rxchan) {
> + guard(uart_port_lock_irqsave)(&up->port);
> omap_8250_rx_dma_flush(up);
> + }
>
> priv->latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE;
> schedule_work(&priv->qos_work);
[Severity: High]
Can acquiring &up->port.lock in omap8250_runtime_suspend() cause an ABBA
deadlock with runtime PM?
8250_omap sets UART_CAP_RPM without pm_runtime_irq_safe(), and several
serial_core and 8250_port paths call pm_runtime_resume_and_get() or
pm_runtime_get_sync() while holding port->lock with interrupts disabled,
such as uart_update_mctrl() -> omap8250_set_mctrl().
CPU0 CPU1
---- ----
omap8250_runtime_suspend()
[status = RPM_SUSPENDING]
uart_update_mctrl()
guard(uart_port_lock_irqsave)(port)
omap8250_set_mctrl()
pm_runtime_resume_and_get()
rpm_resume()
wait for RPM_SUSPENDING
<-- sleeps holding port->lock
guard(uart_port_lock_irqsave)
<-- spins forever on port->lock
CPU1 sleeps in TASK_UNINTERRUPTIBLE inside rpm_resume() waiting for
RPM_SUSPENDING to finish while holding port->lock, while CPU0 cannot leave
RPM_SUSPENDING until CPU1 releases port->lock, deadlocking both CPUs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-submit-serial-8250-dma-cancel-v1-v14-0-b691fec8097d@gmail.com?part=3
next prev parent reply other threads:[~2026-12-04 10:20 UTC|newest]
Thread overview: 16+ 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 [this message]
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
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
2026-12-04 10:44 ` [PATCH v14 0/8] serial: 8250: serialize DMA cancellation with buffer reuse sashiko-bot
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-249590@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 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.