dmaengine: tegra186: Fix residual calculation
Subsystems (3)
PATCH RESEND v2 1/1 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.
---v1->v2:
* corrected typo - s/exisiting/existing/
drivers/dma/tegra186-gpc-dma.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/dma/tegra186-gpc-dma.c +3 -0
@@ -746,6 +746,9 @@ static int tegra_dma_get_residual(struct tegra_dma_channel *tdc) bytes_xfer = dma_desc->bytes_xfer + sg_req[dma_desc->sg_idx].len - (wcount *4 ); +if (dma_desc->bytes_req == bytes_xfer) +return 0 ; + residual = dma_desc->bytes_req - (bytes_xfer % dma_desc->bytes_req);return residual;
Signature · 1 line
2.43.2
Quoted 11 lines · Akhil R
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 thetx_statuswhile 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 ee17028009d4 ("dmaengine: tegra: Add tegra gpcdma driver")Signed-off-by Akhil R <[email protected]>Reviewed-by Jon Hunter <[email protected]>
Quoted 6 lines
---
v1->v2:
* corrected typo - s/exisiting/existing/drivers/dma/tegra186-gpc-dma.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 9 lines · Akhil R
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 thetx_statuswhile 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.[...]
Applied, thanks!
[1/1] dmaengine: tegra186: Fix residual calculation
commit: 30f0ced9971b2d8c8c24ae75786f9079489a012d
Best regards,
Signature · 1 line
~Vinod