Skip to content

Commit c7d812e

Browse files
Marek Vasutvinodkoul
authored andcommitted
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: a575d0b ("dmaengine: xilinx_dma: Introduce xilinx_dma_get_residue") Signed-off-by: Marek Vasut <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent f61d145 commit c7d812e

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
@@ -997,25 +997,25 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan,
997997
struct xilinx_cdma_tx_segment,
998998
node);
999999
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);
10021002
} else if (chan->xdev->dma_config->dmatype ==
10031003
XDMA_TYPE_AXIDMA) {
10041004
axidma_seg = list_entry(entry,
10051005
struct xilinx_axidma_tx_segment,
10061006
node);
10071007
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);
10101010
} else {
10111011
aximcdma_seg =
10121012
list_entry(entry,
10131013
struct xilinx_aximcdma_tx_segment,
10141014
node);
10151015
aximcdma_hw = &aximcdma_seg->hw;
10161016
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);
10191019
}
10201020
}
10211021

0 commit comments

Comments
 (0)