Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dmaengine: xilinx: xilinx_dma: Fix unmasked residue subtraction

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>
Link: https://patch.msgid.link/20260316222530.163815-1-marex@nabladev.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Marek Vasut and committed by
Vinod Koul
c7d812e3 f61d1459

+6 -6
+6 -6
drivers/dma/xilinx/xilinx_dma.c
··· 997 997 struct xilinx_cdma_tx_segment, 998 998 node); 999 999 cdma_hw = &cdma_seg->hw; 1000 - residue += (cdma_hw->control - cdma_hw->status) & 1001 - chan->xdev->max_buffer_len; 1000 + residue += (cdma_hw->control & chan->xdev->max_buffer_len) - 1001 + (cdma_hw->status & chan->xdev->max_buffer_len); 1002 1002 } else if (chan->xdev->dma_config->dmatype == 1003 1003 XDMA_TYPE_AXIDMA) { 1004 1004 axidma_seg = list_entry(entry, 1005 1005 struct xilinx_axidma_tx_segment, 1006 1006 node); 1007 1007 axidma_hw = &axidma_seg->hw; 1008 - residue += (axidma_hw->control - axidma_hw->status) & 1009 - chan->xdev->max_buffer_len; 1008 + residue += (axidma_hw->control & chan->xdev->max_buffer_len) - 1009 + (axidma_hw->status & chan->xdev->max_buffer_len); 1010 1010 } else { 1011 1011 aximcdma_seg = 1012 1012 list_entry(entry, ··· 1014 1014 node); 1015 1015 aximcdma_hw = &aximcdma_seg->hw; 1016 1016 residue += 1017 - (aximcdma_hw->control - aximcdma_hw->status) & 1018 - chan->xdev->max_buffer_len; 1017 + (aximcdma_hw->control & chan->xdev->max_buffer_len) - 1018 + (aximcdma_hw->status & chan->xdev->max_buffer_len); 1019 1019 } 1020 1020 } 1021 1021