Re: [PATCH v10 4/7] dmaengine: dw: use virt-dma for descriptor and callback ownership
From: Andy Shevchenko
Date: Thu Nov 19 2026 - 05:29:49 EST
On Thu, Nov 19, 2026 at 03:01:38AM -0700, James Hilliard wrote:
> The status getter can invoke a client's completion callback while polling
> the hardware. An 8250 RX timeout calls it with the port lock held, and the
> callback takes that same lock. Termination also lacks a synchronization
> hook to wait for callbacks already detached from the channel's queues.
>
> Use virt-dma for transaction queues, cookie completion and callback
> delivery. Keep the active transaction and hardware state under vc.lock.
> Polling still processes RAW.XFER and advances software-LLP blocks, so
> clients such as catpt can complete transfers with the controller interrupt
> masked. Client callbacks run only from the per-channel virt-dma tasklet.
>
> An 8250 RX timeout consumes the transfer length minus the reported
> residue. On a bus error, source reads do not establish how many bytes
> reached the destination. Credit only whole blocks whose completion the
> driver observed while advancing a software-linked transfer. For a
> hardware-linked transfer, treat the whole buffer as unconfirmed.
>
> Report the abort and the same residue to result callbacks and status
> pollers, even after another transfer completes. Reserve the error record
> during preparation, when clients can still handle allocation failure.
> Use the normal virt-dma submission path; neither submission nor fault
> reporting needs to allocate. Keep only failed cookies after descriptor
> release, until the cookie is reused or the channel is released.
>
> Submit only the first block of each transaction to virt-dma. Its child
> LLIs remain on the driver's hardware-chain list and are freed together
> after the callback returns. Keep the controller tasklet for hardware
> event processing and error recovery.
>
> Complete cookies under vc.lock before handing descriptors to the callback
> tasklet. Complete terminated cookies in submission order without invoking
> their callbacks, so a concurrent termination cannot advance the completed
> cookie past an older completion that later moves it backwards. Newly
> submitted transactions become eligible to start when issue_pending()
> moves them to the issued queue.
>
> Implement device_synchronize with vchan_synchronize(), which drains only
> the selected channel's callbacks. DMAengine calls it before releasing
> channel resources. Exclude the controller tasklet while clearing channel
> configuration and powering down, and let a pending run return without
> register access after the last channel has been released.
>
> This implements the callback deferral proposed by Serge Semin using the
> shared infrastructure suggested by Andy Shevchenko.
...
> Link: https://lore.kernel.org/r/20240911184710.4207-3-fancer.lancer@xxxxxxxxx
> Link: https://lore.kernel.org/r/avrHOJ-fVZOO32bI@ashevche-desk.local
Same issue. And I think I have told you about it a few times before.
--
With Best Regards,
Andy Shevchenko