summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Bereza <alex@bereza.email>2026-08-17 11:23:55 +0200
committerVinod Koul <vkoul@kernel.org>2026-09-10 17:51:06 +0530
commitcee9c863ee68cb27d66745eb03f60e357f4f8ad2 (patch)
tree79b7ba2336a6ab8fe8738938b46520c3aa62ba42
parentdc750422170a563c7a81f6e49d36bb02c62ae37f (diff)
downloadlinux-next-cee9c863ee68cb27d66745eb03f60e357f4f8ad2.tar.gz
linux-next-cee9c863ee68cb27d66745eb03f60e357f4f8ad2.zip
dmaengine: xilinx_dma: Fix hardware buffer descriptor reuse order
xilinx_dma_alloc_chan_resources() builds a static ring of hardware buffer descriptors once and the driver uses this ring throughout the lifetime of a channel. This requires the allocation order of hardware buffer descriptors from chan->free_seg_list to stay in sync with the hardware buffer descriptor ring built at channel allocation time by returning oldest descriptors to chan->free_seg_list first. When chan->pending_list is not empty e.g. during xilinx_dma_terminate_all() the chan->free_seg_list and the order of the static hardware buffer descriptor ring get out of sync. Descriptors age in this order: pending -> active -> done. So freeing pending_list first returns the newest buffer descriptors to the chan->free_seg_list first and thus breaks the order required by the static hardware buffer descriptor ring. Then when the channel is reused, after a wrap around of the free_seg_list the DMA will find a hardware buffer descriptor with a length field that is still zeroed and stop with something like this: xilinx-vdma 86000000.dma: Channel 000000003a21d7b8 has errors 10, cdr 6de4c000 tdr 6de4c000 After this no more descriptors are completed and a consumer potentially blocks and waits forever. The only way to get out of this error state is to rebuild the static hardware buffer descriptor ring and the free_seg_list by releasing and re-acquiring the channel. Fix the order in which hardware buffer descriptors are returned to free_seg_list to ensure the mentioned requirement holds. Fixes: 23059408b6a3 ("dmaengine: xilinx_dma: Fix race condition in the driver for multiple descriptor scenario") Signed-off-by: Alex Bereza <alex@bereza.email> Reviewed-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Suraj Gupta <suraj.gupta2@amd.com> Link: https://patch.msgid.link/20260817-fix-hw-buf-desc-reuse-v1-1-d79827a844c7@bereza.email Signed-off-by: Vinod Koul <vkoul@kernel.org>
-rw-r--r--drivers/dma/xilinx/xilinx_dma.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index bef2b031dba1..0817b74f7450 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -920,9 +920,9 @@ static void xilinx_dma_free_descriptors(struct xilinx_dma_chan *chan)
spin_lock_irqsave(&chan->lock, flags);
- xilinx_dma_free_desc_list(chan, &chan->pending_list);
xilinx_dma_free_desc_list(chan, &chan->done_list);
xilinx_dma_free_desc_list(chan, &chan->active_list);
+ xilinx_dma_free_desc_list(chan, &chan->pending_list);
spin_unlock_irqrestore(&chan->lock, flags);
}