]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dmaengine: xilinx_dma: Add support for residue on direct AXIDMA S2MM
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Thu, 18 Dec 2025 08:39:37 +0000 (10:39 +0200)
committerVinod Koul <vkoul@kernel.org>
Tue, 23 Dec 2025 10:43:13 +0000 (16:13 +0530)
AXIDMA IP supports reporting the amount of bytes transferred on the S2MM
channel in direct mode (i.e. non-SG), but the driver does not. Thus the
driver always reports that all of the buffer was filled.

Add xilinx_dma_get_residue_axidma_direct_s2mm() which gets the residue
amount for direct AXIDMA for S2MM direction.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Suraj Gupta <suraj.gupta2@amd.com>
Link: https://patch.msgid.link/20251218-xilinx-dma-residue-fix-v1-1-7cd221d69d6b@ideasonboard.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/xilinx/xilinx_dma.c

index fabff602065f6cba23cff7bb4f305a3504230a02..64b3fba4e44fcbd4cc1c4ddb28fcbd71296e4258 100644 (file)
@@ -1021,6 +1021,24 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan,
        return residue;
 }
 
+static u32
+xilinx_dma_get_residue_axidma_direct_s2mm(struct xilinx_dma_chan *chan,
+                                         struct xilinx_dma_tx_descriptor *desc)
+{
+       struct xilinx_axidma_tx_segment *seg;
+       struct xilinx_axidma_desc_hw *hw;
+       u32 finished_len;
+
+       finished_len = dma_ctrl_read(chan, XILINX_DMA_REG_BTT);
+
+       seg = list_first_entry(&desc->segments, struct xilinx_axidma_tx_segment,
+                              node);
+
+       hw = &seg->hw;
+
+       return hw->control - finished_len;
+}
+
 /**
  * xilinx_dma_chan_handle_cyclic - Cyclic dma callback
  * @chan: Driver specific dma channel
@@ -1732,6 +1750,9 @@ static void xilinx_dma_complete_descriptor(struct xilinx_dma_chan *chan)
                if (chan->has_sg && chan->xdev->dma_config->dmatype !=
                    XDMA_TYPE_VDMA)
                        desc->residue = xilinx_dma_get_residue(chan, desc);
+               else if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA &&
+                        chan->direction == DMA_DEV_TO_MEM && !chan->has_sg)
+                       desc->residue = xilinx_dma_get_residue_axidma_direct_s2mm(chan, desc);
                else
                        desc->residue = 0;
                desc->err = chan->err;