dmaengine: pl330: no device_synchronize -- does terminate_sync guarantee the transfer stopped?
Hello,
I'm trying to clarify the termination guarantees provided by the PL330 DMAengine driver.
PL330 does not implement device_synchronize. Consequently, for PL330 channels, dmaengine_terminate_sync() calls pl330_terminate_all() without any additional provider-specific synchronization.
pl330_terminate_all() requests termination through _stop(), which issues DMAKILL using the controller's debug interface. However, I could not establish from the driver code that this operation waits for the channel thread to reach STOPPED or guarantees that all outstanding bus writes have completed before returning.
There is a separate callback concern: PL330 uses a per-channel completion tasklet, but pl330_terminate_all() does not explicitly synchronize or kill that tasklet. The tasklet is killed in pl330_free_chan_resources().
DMAengine clients rely on dmaengine_terminate_sync(), or dmaengine_terminate_async() followed by dmaengine_synchronize(), to establish that the DMA operation and its callbacks have completed before unmapping or freeing buffers, as described in Documentation/driver-api/dmaengine/client.rst.
One relevant client is Samsung UART on Exynos. Its release_dma() path has a proposed change to use dmaengine_terminate_sync() before unmapping and freeing the RX buffer [1]. The safety of that ordering depends on the guarantees provided by PL330.
I have two questions:
Hardware completion: Does DMAKILL guarantee that all outstanding DMA bus transactions have completed before the command finishes, or is an additional wait for the channel to reach STOPPED required?
Callback synchronization: Can a PL330 completion tasklet still be running or become scheduled after pl330_terminate_all() returns? If so, would implementing device_synchronize to wait for the appropriate hardware retirement condition and synchronize the tasklet be the preferred approach?
I'm particularly interested in whether PL330 currently satisfies the DMAengine synchronous-termination contract, or whether an additional synchronization mechanism is needed.
This question arose from a research static analyzer for DMA lifecycle ordering and a subsequent source review.
[1] https://lore.kernel.org/r/[email protected]
Thanks,
Samarth