* [PATCH] dmaengine: xilinx: xilinx_dma: Fix unmasked residue subtraction
@ 2026-03-16 22:25 Marek Vasut
2026-03-17 11:27 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2026-03-16 22:25 UTC (permalink / raw)
To: dmaengine
Cc: Marek Vasut, Michal Simek, Radhey Shyam Pandey, Rahul Navale,
Sasha Levin, Suraj Gupta, Thomas Gessler, Vinod Koul,
linux-arm-kernel, linux-kernel
The segment .control and .status fields both contain top bits which are
not part of the buffer size, the buffer size is located only in the bottom
max_buffer_len bits. To avoid interference from those top bits, mask out
the size using max_buffer_len first, and only then subtract the values.
Fixes: a575d0b4e663 ("dmaengine: xilinx_dma: Introduce xilinx_dma_get_residue")
Signed-off-by: Marek Vasut <marex@nabladev.com>
---
Cc: Michal Simek <michal.simek@amd.com>
Cc: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Cc: Rahul Navale <rahul.navale@ifm.com>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Suraj Gupta <suraj.gupta2@amd.com>
Cc: Thomas Gessler <thomas.gessler@brueckmann-gmbh.de>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
drivers/dma/xilinx/xilinx_dma.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index 6e8e348973a9e..4f88ba92bd2d8 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -997,16 +997,16 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan,
struct xilinx_cdma_tx_segment,
node);
cdma_hw = &cdma_seg->hw;
- residue += (cdma_hw->control - cdma_hw->status) &
- chan->xdev->max_buffer_len;
+ residue += (cdma_hw->control & chan->xdev->max_buffer_len) -
+ (cdma_hw->status & chan->xdev->max_buffer_len);
} else if (chan->xdev->dma_config->dmatype ==
XDMA_TYPE_AXIDMA) {
axidma_seg = list_entry(entry,
struct xilinx_axidma_tx_segment,
node);
axidma_hw = &axidma_seg->hw;
- residue += (axidma_hw->control - axidma_hw->status) &
- chan->xdev->max_buffer_len;
+ residue += (axidma_hw->control & chan->xdev->max_buffer_len) -
+ (axidma_hw->status & chan->xdev->max_buffer_len);
} else {
aximcdma_seg =
list_entry(entry,
@@ -1014,8 +1014,8 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan,
node);
aximcdma_hw = &aximcdma_seg->hw;
residue +=
- (aximcdma_hw->control - aximcdma_hw->status) &
- chan->xdev->max_buffer_len;
+ (aximcdma_hw->control & chan->xdev->max_buffer_len) -
+ (aximcdma_hw->status & chan->xdev->max_buffer_len);
}
}
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] dmaengine: xilinx: xilinx_dma: Fix unmasked residue subtraction
2026-03-16 22:25 [PATCH] dmaengine: xilinx: xilinx_dma: Fix unmasked residue subtraction Marek Vasut
@ 2026-03-17 11:27 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2026-03-17 11:27 UTC (permalink / raw)
To: dmaengine, Marek Vasut
Cc: Michal Simek, Radhey Shyam Pandey, Rahul Navale, Sasha Levin,
Suraj Gupta, Thomas Gessler, linux-arm-kernel, linux-kernel
On Mon, 16 Mar 2026 23:25:24 +0100, Marek Vasut wrote:
> The segment .control and .status fields both contain top bits which are
> not part of the buffer size, the buffer size is located only in the bottom
> max_buffer_len bits. To avoid interference from those top bits, mask out
> the size using max_buffer_len first, and only then subtract the values.
>
>
Applied, thanks!
[1/1] dmaengine: xilinx: xilinx_dma: Fix unmasked residue subtraction
commit: c7d812e33f3e8ca0fa9eeabf71d1c7bc3acedc09
Best regards,
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-17 11:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 22:25 [PATCH] dmaengine: xilinx: xilinx_dma: Fix unmasked residue subtraction Marek Vasut
2026-03-17 11:27 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox