Re: [PATCH] dmaengine: switchtec-dma: preserve results for out-of-order completions
From: Logan Gunthorpe
Date: Mon Jul 20 2026 - 11:49:37 EST
On 2026-07-18 08:32, Hao-Qun Huang wrote:
> Switchtec completion entries can arrive out of submission order, and the
> driver handles that by marking the descriptor complete and deferring its
> callback until the ring tail catches up. The problem is that the
> per-transfer result (status and residue) is only kept in a stack variable
> while the completion entry is being read. Once the tail gap closes,
> cleanup retires the descriptor at the tail along with any already
> completed descriptors behind it, and hands the same stack result to every
> one of them.
>
> So a transfer that failed out of order can be reported as successful (or
> the other way round) depending on which completion happened to close the
> gap, and the residue can end up coming from the wrong transfer too.
>
> Keep the result in each descriptor instead of on the stack, and pass the
> descriptor's own saved result when it is retired. Cookie ordering, the
> CID-to-descriptor mapping and the completion locking are unchanged; only
> the result handed to each callback is corrected.
>
> Fixes: 30eba9df76ad ("dmaengine: switchtec-dma: Implement hardware initialization and cleanup")
> Assisted-by: Claude:claude-fable-5
> Signed-off-by: Hao-Qun Huang <alvinhuang0603@xxxxxxxxx>
This appears correct to me:
Reviewed-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>
Thanks!
Logan