Skip to content

Commit 30f0ced

Browse files
Akhil Rvinodkoul
authored andcommitted
dmaengine: tegra186: Fix residual calculation
The existing residual calculation returns an incorrect value when bytes_xfer == bytes_req. This scenario occurs particularly with drivers like UART where DMA is scheduled for maximum number of bytes and is terminated when the bytes inflow stops. At higher baud rates, it could request the tx_status while there is no bytes left to transfer. This will lead to incorrect residual being set. Hence return residual as '0' when bytes transferred equals to the bytes requested. Fixes: ee17028 ("dmaengine: tegra: Add tegra gpcdma driver") Signed-off-by: Akhil R <[email protected]> Reviewed-by: Jon Hunter <[email protected]> Acked-by: Thierry Reding <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 43c633e commit 30f0ced

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/dma/tegra186-gpc-dma.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,9 @@ static int tegra_dma_get_residual(struct tegra_dma_channel *tdc)
746746
bytes_xfer = dma_desc->bytes_xfer +
747747
sg_req[dma_desc->sg_idx].len - (wcount * 4);
748748

749+
if (dma_desc->bytes_req == bytes_xfer)
750+
return 0;
751+
749752
residual = dma_desc->bytes_req - (bytes_xfer % dma_desc->bytes_req);
750753

751754
return residual;

0 commit comments

Comments
 (0)