From: James Hilliard <james.hilliard1@gmail.com>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Raul E Rangel" <rrangel@chromium.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Heikki Krogerus" <heikki.krogerus@linux.intel.com>,
"Tony Lindgren" <tony@atomide.com>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Richard Genoud" <richard.genoud@bootlin.com>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
"Jacky Huang" <ychuang3@nuvoton.com>,
"Shan-Chun Hung" <schung@nuvoton.com>,
"Pali Rohár" <pali@kernel.org>, "Frank Li" <Frank.Li@nxp.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Maciej W. Rozycki" <macro@orcam.me.uk>,
"Timur Tabi" <timur@kernel.org>,
"Peter Ujfalusi" <peter.ujfalusi@ti.com>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Patrice Chotard" <patrice.chotard@foss.st.com>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
linuxppc-dev@lists.ozlabs.org,
James Hilliard <james.hilliard1@gmail.com>
Subject: [PATCH v9 3/8] serial: 8250_omap: serialize RX DMA completion and flushing
Date: Mon, 02 Nov 2026 16:14:30 -0700 [thread overview]
Message-ID: <20261102-submit-serial-8250-dma-cancel-v1-v9-3-9159caade148@gmail.com> (raw)
In-Reply-To: <20261102-submit-serial-8250-dma-cancel-v1-v9-0-9159caade148@gmail.com>
Moving RX DMA locking out of __dma_rx_do_complete() left the DMA
completion callback calling it without rx_dma_lock. Shutdown and runtime
suspend flush RX under rx_dma_lock but without the port lock, allowing
these paths to overlap the callback's buffer accounting and flip-buffer
insertion. RX submission and UART interrupt handling also require the
port lock.
Take rx_dma_lock inside the port lock in the completion callback. Hold
the port lock around the shutdown and runtime-suspend flushes, matching
the existing interrupt-path lock order. Assert both locks in the common
completion helper and the port lock at the flush entry point.
Fixes: 789898416749 ("serial: 8250: 8250_omap: Move locking out from __dma_rx_do_complete()")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/tty/serial/8250/8250_omap.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index b6f108d34854..322403cec2de 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -771,8 +771,10 @@ static void omap_8250_shutdown(struct uart_port *port)
guard(serial8250_rpm)(up);
flush_work(&priv->qos_work);
- if (up->dma)
+ if (up->dma) {
+ guard(uart_port_lock_irq)(port);
omap_8250_rx_dma_flush(up);
+ }
serial_out(up, UART_OMAP_WER, 0);
if (priv->habit & UART_HAS_EFR2)
@@ -898,7 +900,7 @@ static int omap8250_rs485_config(struct uart_port *port,
#ifdef CONFIG_SERIAL_8250_DMA
static int omap_8250_rx_dma(struct uart_8250_port *p);
-/* Must be called while priv->rx_dma_lock is held */
+/* Must be called with the port lock and priv->rx_dma_lock held. */
static void __dma_rx_do_complete(struct uart_8250_port *p)
{
struct uart_8250_dma *dma = p->dma;
@@ -911,6 +913,9 @@ static void __dma_rx_do_complete(struct uart_8250_port *p)
int ret;
u32 reg;
+ lockdep_assert_held_once(&p->port.lock);
+ lockdep_assert_held_once(&priv->rx_dma_lock);
+
if (!dma->rx_running)
goto out;
@@ -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;
@@ -995,6 +1001,8 @@ static void omap_8250_rx_dma_flush(struct uart_8250_port *p)
unsigned long flags;
int ret;
+ lockdep_assert_held_once(&p->port.lock);
+
spin_lock_irqsave(&priv->rx_dma_lock, flags);
if (!dma->rx_running) {
@@ -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);
--
2.53.0
next prev parent reply other threads:[~2026-11-02 23:14 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 23:14 [PATCH v9 0/8] serial: 8250: serialize DMA cancellation with buffer reuse James Hilliard
2026-11-02 23:14 ` [PATCH v9 1/8] serial: 8250_omap: separate locked TX DMA completion processing James Hilliard
2026-11-03 16:10 ` Raul E Rangel
2026-11-02 23:14 ` [PATCH v9 2/8] serial: serialize asynchronous write wakeups with the port lock James Hilliard
2026-11-03 16:10 ` Raul E Rangel
2026-11-03 17:06 ` Andy Shevchenko
2026-11-03 20:25 ` Maciej W. Rozycki
2026-11-02 23:14 ` James Hilliard [this message]
2026-11-03 11:55 ` [PATCH v9 3/8] serial: 8250_omap: serialize RX DMA completion and flushing Ilpo Järvinen
2026-11-03 16:10 ` Raul E Rangel
2026-11-02 23:14 ` [PATCH v9 4/8] serial: 8250_omap: quiesce DMA IRQ handling before shutdown James Hilliard
2026-11-03 16:11 ` Raul E Rangel
2026-11-02 23:14 ` [PATCH v9 5/8] serial: core: allow drivers to reserve flushed transmit storage James Hilliard
2026-11-03 16:11 ` Raul E Rangel
2026-11-03 17:08 ` Andy Shevchenko
2026-11-02 23:14 ` [PATCH v9 6/8] serial: 8250: drain canceled TX DMA before reusing its buffer James Hilliard
2026-11-03 16:11 ` Raul E Rangel
2026-11-03 17:21 ` Andy Shevchenko
2026-11-02 23:14 ` [PATCH v9 7/8] serial: 8250: retire canceled RX DMA before reusing the receive buffer James Hilliard
2026-11-03 16:11 ` Raul E Rangel
2026-11-03 18:05 ` James Hilliard
2026-11-03 17:33 ` Andy Shevchenko
2026-11-03 17:54 ` James Hilliard
2026-11-03 18:06 ` Andy Shevchenko
2026-11-03 18:16 ` James Hilliard
2026-11-03 20:59 ` Andy Shevchenko
2026-11-02 23:14 ` [PATCH v9 8/8] serial: 8250: retain DMA resources when termination fails James Hilliard
2026-11-03 16:11 ` Raul E Rangel
2026-11-03 17:35 ` Andy Shevchenko
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=20261102-submit-serial-8250-dma-cancel-v1-v9-3-9159caade148@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=Frank.Li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bigeasy@linutronix.de \
--cc=claudiu.beznea@tuxon.dev \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=imx@lists.linux.dev \
--cc=jirislaby@kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=macro@orcam.me.uk \
--cc=nicolas.ferre@microchip.com \
--cc=pali@kernel.org \
--cc=patrice.chotard@foss.st.com \
--cc=peter.ujfalusi@ti.com \
--cc=richard.genoud@bootlin.com \
--cc=rrangel@chromium.org \
--cc=s.hauer@pengutronix.de \
--cc=schung@nuvoton.com \
--cc=timur@kernel.org \
--cc=tony@atomide.com \
--cc=vigneshr@ti.com \
--cc=ychuang3@nuvoton.com \
/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
all inboxes | Powered by JetHome®