Skip to content

Commit ba972cf

Browse files
Marek Vasutgregkh
authored andcommitted
dmaengine: xilinx: xilinx_dma: Fix unmasked residue subtraction
[ Upstream commit c7d812e ] 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: a575d0b ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent dc2c68f commit ba972cf

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/dma/xilinx/xilinx_dma.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -996,25 +996,25 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan,
996996
struct xilinx_cdma_tx_segment,
997997
node);
998998
cdma_hw = &cdma_seg->hw;
999-
residue += (cdma_hw->control - cdma_hw->status) &
1000-
chan->xdev->max_buffer_len;
999+
residue += (cdma_hw->control & chan->xdev->max_buffer_len) -
1000+
(cdma_hw->status & chan->xdev->max_buffer_len);
10011001
} else if (chan->xdev->dma_config->dmatype ==
10021002
XDMA_TYPE_AXIDMA) {
10031003
axidma_seg = list_entry(entry,
10041004
struct xilinx_axidma_tx_segment,
10051005
node);
10061006
axidma_hw = &axidma_seg->hw;
1007-
residue += (axidma_hw->control - axidma_hw->status) &
1008-
chan->xdev->max_buffer_len;
1007+
residue += (axidma_hw->control & chan->xdev->max_buffer_len) -
1008+
(axidma_hw->status & chan->xdev->max_buffer_len);
10091009
} else {
10101010
aximcdma_seg =
10111011
list_entry(entry,
10121012
struct xilinx_aximcdma_tx_segment,
10131013
node);
10141014
aximcdma_hw = &aximcdma_seg->hw;
10151015
residue +=
1016-
(aximcdma_hw->control - aximcdma_hw->status) &
1017-
chan->xdev->max_buffer_len;
1016+
(aximcdma_hw->control & chan->xdev->max_buffer_len) -
1017+
(aximcdma_hw->status & chan->xdev->max_buffer_len);
10181018
}
10191019
}
10201020

0 commit comments

Comments
 (0)