Skip to content

serial: keep the flushed TX buffer mapped until DMA has stopped

Samarth Narang imx linux-arm-kernel linux-serial lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2serial: amba-pl011: keep the flushed TX buffer mapped until DMA stopsdrivers/tty/serial/amba-pl011.c+51 -30 replies
2/2tty: serial: fsl_lpuart: don't unmap TX buffer before DMA has stoppeddrivers/tty/serial/fsl_lpuart.c+47 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] serial: keep the flushed TX buffer mapped until DMA has stopped

This series addresses the DMA buffer lifetime issues in amba-pl011 and fsl_lpuart reported in the parent thread, where flush_buffer() unmaps the TX buffer before the terminated DMA transfer is guaranteed to have stopped accessing it. In fsl_lpuart, the buffer is unmapped even before termination is requested.

Since flush_buffer() runs under the port lock and cannot wait for DMA termination, both patches request termination while holding the lock and defer unmapping to a work item that first calls dmaengine_synchronize(). The TX completion callback leaves the cleanup of flushed transfers to this work item, while shutdown, and suspend in the case of fsl_lpuart, waits for the work to finish before releasing the TX DMA state.

Both patches have only been compile-tested with arm64 defconfig, the relevant drivers enabled, and W=1, with no new warnings. I do not have access to PL011 or LPUART hardware with DMA support, so testing by someone with suitable hardware would be appreciated.

The imx driver also needs a fix for the issue reported in the same thread, but requires a different approach because its TX completion callback unmaps the scatterlist unconditionally. I will send that patch separately.

Samarth Narang (2):
serial: amba-pl011: keep the flushed TX buffer mapped until DMA stops
tty: serial: fsl_lpuart: don't unmap TX buffer before DMA has stopped

 drivers/tty/serial/amba-pl011.c | 54 +++++++++++++++++++++++++++++++--
 drivers/tty/serial/fsl_lpuart.c | 53 ++++++++++++++++++++++++++++----
 2 files changed, 98 insertions(+), 9 deletions(-)

base-commit: 36aad21d50d1af3f6954bb0c988257a908202477

Signature · 1 line
2.34.1