From: Raul E Rangel <rrangel@chromium.org>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.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>,
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
Subject: Re: [PATCH v9 8/8] serial: 8250: retain DMA resources when termination fails
Date: Tue, 3 Nov 2026 09:11:04 -0700 [thread overview]
Message-ID: <20261103161104.2449407-8-rrangel@chromium.org> (raw)
In-Reply-To: <20261102-submit-serial-8250-dma-cancel-v1-v9-8-9159caade148@gmail.com>
Hi James,
Thanks for replacing the fixed 100 ms sleep with exponential backoff
(1 ms -> 1 s) and adding the initial/ongoing/recovery diagnostics in v9.
Following up on our v8 discussion regarding blocking in
serial8250_terminate_dma() versus non-blocking resource quarantine:
1. Why non-blocking quarantine cannot be done purely inside 8250_dma:
I agree with your v8 reply and the updated commit message here that
serial8250_release_dma() cannot simply return early while leaving
serial_core to proceed with normal teardown:
a) Immediately after serial8250_release_dma(up) returns in
serial8250_do_shutdown() (8250_port.c:2474-2511, and similarly in
omap_8250_shutdown() at 8250_omap.c:794-803), the 8250 driver itself
clears the hardware FIFOs (serial8250_clear_fifos()), reads UART_RX,
frees the IRQ (up->ops->release_irq(up)), and drops runtime PM
(serial8250_rpm_put_tx(up) / serial8250_rpm_put(up)).
b) In uart_tty_port_shutdown() (serial_core.c:1841-1853), immediately
after uart_port_shutdown(port) returns, serial_core unconditionally
calls uart_free_xmit_buf(port) (line 1850) — freeing the page that
dma->tx_addr is still DMA-mapped to — and powers down the UART via
uart_change_pm(state, UART_PM_STATE_OFF) (line 1852). Likewise,
uart_suspend_port() (serial_core.c:2502-2514) calls ops->shutdown(uport)
(line 2502) and unconditionally sets UART_PM_STATE_OFF (line 2512).
c) Even if startup() returns -EIO on reopen when DMA is still active,
uart_port_startup() (serial_core.c:422-423) has:
if (retval && capable(CAP_SYS_ADMIN))
return 1;
which causes uart_port_activate() (serial_core.c:2060-2062) to set
tty_port_set_active(port, true) with tty_port_initialized(port) == false
and allows root open() (serial_core.c:2040-2042) to succeed (0). From
that state, ioctl(TIOCSSERIAL) -> uart_set_info() (serial_core.c:1068)
-> uart_shutdown() (serial_core.c:466-511, which calls
uart_free_xmit_buf() at line 510 outside if (tty_port_initialized))
or uart_hangup() (serial_core.c:1942-1950) or uart_change_port() ->
release_port() (serial_core.c:932-933, 1072) can free the TX buffer,
power down the UART, and release MMIO mappings while DMA is active.
We modeled these cross-layer paths in Serial8250TxDmaV8.tla
(QuarantineGuardsShutdown, QuarantineGuardsAdminOpen, and
NoDmaOnPoweredOffUart in Serial8250TxDmaV8_UnguardedQuarantineHazard.cfg
and Serial8250TxDmaV8_AdminReopenQuarantineHazard.cfg vs.
Serial8250TxDmaV8_TerminateRetryHang_Fixed.cfg, alongside
Serial8250TxDmaV8_QuarantinePioReopenHazard.cfg at
https://github.com/ismell/linux-8250-dma-tla), and TLC confirms that
quarantine without those serial_core and PM guards violates
NoDmaOnPoweredOffUart / NoConcurrentFifoAccess (in 6 states) and
NoUsersAtFree (in 7 states). Given that enforcing non-blocking quarantine
requires coordinated changes across serial_core.c, runtime PM, and 8250
shutdown, addressing non-blocking quarantine in a separate follow-up
series and documenting the limitation here makes sense.
2. What in-tree DMAengine providers actually return from terminate_all:
For context on when the retry loop in serial8250_terminate_dma() can
trigger, I audited all 78 .device_terminate_all implementations in
drivers/dma/:
- 64 out of 78 unconditionally return 0.
- Among DMA controllers used with 8250 UARTs, synchronous FIFO-draining
drivers (drivers/dma/dw/core.c dwc_chan_pause ~40 us,
drivers/dma/idma64.c idma64_chan_deactivate ~100 us) already poll in
microseconds inside terminate_all and return 0.
- The only 8250-paired DMA controllers that can return non-zero are:
* drivers/dma/tegra186-gpc-dma.c (tegra_dma_terminate_all, lines
714-743), which already polls readl_relaxed_poll_timeout_atomic()
for up to 5000 us (5 ms) in tegra_dma_stop_client() / tegra_dma_pause()
/ tegra_dma_pause_noerr() (lines 389-414, 676-712) before returning
-ETIMEDOUT; and
* drivers/dma/at_xdmac.c (at_xdmac_device_terminate_all, lines
1999-2039), which only returns < 0 if pm_runtime_resume_and_get()
fails.
(Even across all 14 non-zero .device_terminate_all implementations in
drivers/dma/, the only one designed around a caller retry loop is
cppi41_stop_chan() -> cppi41_tear_down_chan() in drivers/dma/ti/cppi41.c:
652-770, which is a USB MUSB controller used only by musb_cppi41.c.)
Thanks,
Raul
next prev parent reply other threads:[~2026-11-03 16:11 UTC|newest]
Thread overview: 41+ 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 ` [PATCH v9 3/8] serial: 8250_omap: serialize RX DMA completion and flushing James Hilliard
2026-11-03 11:55 ` 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-09 16:21 ` [PATCH v10 " Raul E Rangel
2026-11-03 17:33 ` [PATCH v9 " 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 [this message]
2026-11-03 17:35 ` Andy Shevchenko
2026-11-09 3:50 [PATCH v10 0/8] serial: 8250: serialize DMA cancellation with buffer reuse James Hilliard
2026-11-09 3:50 ` [PATCH v10 1/8] serial: 8250_omap: separate locked TX DMA completion processing James Hilliard
2026-11-09 3:50 ` [PATCH v10 2/8] serial: serialize asynchronous write wakeups with the port lock James Hilliard
2026-11-09 22:57 ` Andy Shevchenko
2026-11-09 3:50 ` [PATCH v10 3/8] serial: 8250_omap: serialize RX DMA completion and flushing James Hilliard
2026-11-09 3:50 ` [PATCH v10 4/8] serial: 8250_omap: quiesce DMA IRQ handling before shutdown James Hilliard
2026-11-09 3:50 ` [PATCH v10 5/8] serial: core: allow drivers to reserve flushed transmit storage James Hilliard
2026-11-09 3:50 ` [PATCH v10 6/8] serial: 8250: drain canceled TX DMA before reusing its buffer James Hilliard
2026-11-09 3:50 ` [PATCH v10 7/8] serial: 8250: retire canceled RX DMA before reusing the receive buffer James Hilliard
2026-11-09 3:50 ` [PATCH v10 8/8] serial: 8250: retain DMA resources when termination fails James Hilliard
2026-11-09 16:21 ` Raul E Rangel
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=20261103161104.2449407-8-rrangel@chromium.org \
--to=rrangel@chromium.org \
--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=james.hilliard1@gmail.com \
--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=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®