mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dmaengine: xilinx_dma: Add support for residue on direct AXIDMA S2MM
@ 2025-12-18  8:39 Tomi Valkeinen
  2025-12-18 19:06 ` Gupta, Suraj
  2025-12-23 11:28 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Tomi Valkeinen @ 2025-12-18  8:39 UTC (permalink / raw)
  To: Vinod Koul, Michal Simek, Vishal Sagar
  Cc: dmaengine, linux-arm-kernel, linux-kernel, Laurent Pinchart,
	Tomi Valkeinen

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>
---
 drivers/dma/xilinx/xilinx_dma.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index fabff602065f..64b3fba4e44f 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -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;

---
base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
change-id: 20251218-xilinx-dma-residue-fix-f6e4f97ffe61

Best regards,
-- 
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] dmaengine: xilinx_dma: Add support for residue on direct AXIDMA S2MM
  2025-12-18  8:39 [PATCH] dmaengine: xilinx_dma: Add support for residue on direct AXIDMA S2MM Tomi Valkeinen
@ 2025-12-18 19:06 ` Gupta, Suraj
  2025-12-23 11:28 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Gupta, Suraj @ 2025-12-18 19:06 UTC (permalink / raw)
  To: Tomi Valkeinen, Vinod Koul, Simek, Michal, Sagar, Vishal
  Cc: dmaengine, linux-arm-kernel, linux-kernel, Laurent Pinchart

[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> Sent: Thursday, December 18, 2025 2:10 PM
> To: Vinod Koul <vkoul@kernel.org>; Simek, Michal <michal.simek@amd.com>;
> Sagar, Vishal <vishal.sagar@amd.com>
> Cc: dmaengine@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; Laurent Pinchart
> <laurent.pinchart@ideasonboard.com>; Tomi Valkeinen
> <tomi.valkeinen@ideasonboard.com>
> Subject: [PATCH] dmaengine: xilinx_dma: Add support for residue on direct
> AXIDMA S2MM
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> 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>


Looks fine to me.
Reviewed-by: Suraj Gupta <suraj.gupta2@amd.com>

> ---
>  drivers/dma/xilinx/xilinx_dma.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
> index fabff602065f..64b3fba4e44f 100644
> --- a/drivers/dma/xilinx/xilinx_dma.c
> +++ b/drivers/dma/xilinx/xilinx_dma.c
> @@ -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;
>
> ---
> base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
> change-id: 20251218-xilinx-dma-residue-fix-f6e4f97ffe61
>
> Best regards,
> --
> Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: xilinx_dma: Add support for residue on direct AXIDMA S2MM
  2025-12-18  8:39 [PATCH] dmaengine: xilinx_dma: Add support for residue on direct AXIDMA S2MM Tomi Valkeinen
  2025-12-18 19:06 ` Gupta, Suraj
@ 2025-12-23 11:28 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2025-12-23 11:28 UTC (permalink / raw)
  To: Michal Simek, Vishal Sagar, Tomi Valkeinen
  Cc: dmaengine, linux-arm-kernel, linux-kernel, Laurent Pinchart


On Thu, 18 Dec 2025 10:39:37 +0200, Tomi Valkeinen wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] dmaengine: xilinx_dma: Add support for residue on direct AXIDMA S2MM
      commit: 5c9142a8063f71233b25d94ae0d73e7dcf9d2a1d

Best regards,
-- 
~Vinod



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-23 11:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-18  8:39 [PATCH] dmaengine: xilinx_dma: Add support for residue on direct AXIDMA S2MM Tomi Valkeinen
2025-12-18 19:06 ` Gupta, Suraj
2025-12-23 11:28 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®