* [PATCH] tty: serial: fsl_lpuart: avoid releasing DMA channels twice
@ 2026-11-29 16:30 Yige Jiang
2026-11-29 16:37 ` sashiko-bot
2026-12-01 2:26 ` Sherry Sun
0 siblings, 2 replies; 3+ messages in thread
From: Yige Jiang @ 2026-11-29 16:30 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Yige Jiang, linux-serial, linux-kernel, Michael Walle, stable
lpuart_dma_shutdown() releases the TX and RX DMA channels but leaves
their pointers set. If the device is removed after port shutdown,
lpuart_remove() passes the same channels to dma_release_channel()
again. This can trigger a DMAengine channel reference count warning.
Clear each channel pointer after releasing it so that lpuart_remove()
only releases channels the driver still owns.
A tool-assisted lifetime review found the extra release. Codex helped
draft the fix and this commit message.
Fixes: 159381df1442 ("tty: serial: fsl_lpuart: fix DMA operation when using IOMMU")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Compile-tested on arm64 defconfig with GCC 14.2 and W=1.
drivers/tty/serial/fsl_lpuart.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index e54b4c44db42..17a67805b208 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1934,10 +1934,15 @@ static void lpuart_dma_shutdown(struct lpuart_port *sport)
sport->lpuart_dma_tx_use = false;
}
- if (sport->dma_tx_chan)
+ if (sport->dma_tx_chan) {
dma_release_channel(sport->dma_tx_chan);
- if (sport->dma_rx_chan)
+ sport->dma_tx_chan = NULL;
+ }
+
+ if (sport->dma_rx_chan) {
dma_release_channel(sport->dma_rx_chan);
+ sport->dma_rx_chan = NULL;
+ }
}
static void lpuart_shutdown(struct uart_port *port)
base-commit: eedf2cf3505c1562a2fb24f8b997056f023d242b
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tty: serial: fsl_lpuart: avoid releasing DMA channels twice
2026-11-29 16:30 [PATCH] tty: serial: fsl_lpuart: avoid releasing DMA channels twice Yige Jiang
@ 2026-11-29 16:37 ` sashiko-bot
2026-12-01 2:26 ` Sherry Sun
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-29 16:37 UTC (permalink / raw)
To: Yige Jiang; +Cc: linux-serial
> lpuart_dma_shutdown() releases the TX and RX DMA channels but leaves
> their pointers set. If the device is removed after port shutdown,
> lpuart_remove() passes the same channels to dma_release_channel()
> again. This can trigger a DMAengine channel reference count warning.
>
> Clear each channel pointer after releasing it so that lpuart_remove()
> only releases channels the driver still owns.
>
> A tool-assisted lifetime review found the extra release. Codex helped
> draft the fix and this commit message.
>
> Fixes: 159381df1442 ("tty: serial: fsl_lpuart: fix DMA operation when using IOMMU")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127011317.4d10af6e584b.fsl-lpuart@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] tty: serial: fsl_lpuart: avoid releasing DMA channels twice
2026-11-29 16:30 [PATCH] tty: serial: fsl_lpuart: avoid releasing DMA channels twice Yige Jiang
2026-11-29 16:37 ` sashiko-bot
@ 2026-12-01 2:26 ` Sherry Sun
1 sibling, 0 replies; 3+ messages in thread
From: Sherry Sun @ 2026-12-01 2:26 UTC (permalink / raw)
To: Yige Jiang, Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
Michael Walle, stable@vger.kernel.org
> Subject: [PATCH] tty: serial: fsl_lpuart: avoid releasing DMA channels twice
>
> lpuart_dma_shutdown() releases the TX and RX DMA channels but leaves
> their pointers set. If the device is removed after port shutdown,
> lpuart_remove() passes the same channels to dma_release_channel() again.
> This can trigger a DMAengine channel reference count warning.
>
> Clear each channel pointer after releasing it so that lpuart_remove() only
> releases channels the driver still owns.
>
> A tool-assisted lifetime review found the extra release. Codex helped draft the
> fix and this commit message.
>
> Fixes: 159381df1442 ("tty: serial: fsl_lpuart: fix DMA operation when using
> IOMMU")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
Reviewed-by: Sherry Sun <sherry.sun@nxp.com>
Best Regards
Sherry
> ---
> Compile-tested on arm64 defconfig with GCC 14.2 and W=1.
>
> drivers/tty/serial/fsl_lpuart.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index
> e54b4c44db42..17a67805b208 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -1934,10 +1934,15 @@ static void lpuart_dma_shutdown(struct
> lpuart_port *sport)
> sport->lpuart_dma_tx_use = false;
> }
>
> - if (sport->dma_tx_chan)
> + if (sport->dma_tx_chan) {
> dma_release_channel(sport->dma_tx_chan);
> - if (sport->dma_rx_chan)
> + sport->dma_tx_chan = NULL;
> + }
> +
> + if (sport->dma_rx_chan) {
> dma_release_channel(sport->dma_rx_chan);
> + sport->dma_rx_chan = NULL;
> + }
> }
>
> static void lpuart_shutdown(struct uart_port *port)
>
> base-commit: eedf2cf3505c1562a2fb24f8b997056f023d242b
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-01 2:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 16:30 [PATCH] tty: serial: fsl_lpuart: avoid releasing DMA channels twice Yige Jiang
2026-11-29 16:37 ` sashiko-bot
2026-12-01 2:26 ` Sherry Sun
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.