* [PATCH v2 RESEND] dmaengine: tegra186: Fix residual calculation
@ 2024-03-15 12:44 Akhil R
2024-03-25 13:30 ` Thierry Reding
2024-03-28 7:39 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Akhil R @ 2024-03-15 12:44 UTC (permalink / raw)
To: ldewangan, jonathanh, vkoul, thierry.reding, dmaengine,
linux-tegra, linux-kernel
Cc: 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 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: ee17028009d4 ("dmaengine: tegra: Add tegra gpcdma driver")
Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
---
v1->v2:
* corrected typo - s/exisiting/existing/
drivers/dma/tegra186-gpc-dma.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/dma/tegra186-gpc-dma.c b/drivers/dma/tegra186-gpc-dma.c
index 88547a23825b..3642508e88bb 100644
--- a/drivers/dma/tegra186-gpc-dma.c
+++ b/drivers/dma/tegra186-gpc-dma.c
@@ -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;
--
2.43.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2 RESEND] dmaengine: tegra186: Fix residual calculation
2024-03-15 12:44 [PATCH v2 RESEND] dmaengine: tegra186: Fix residual calculation Akhil R
@ 2024-03-25 13:30 ` Thierry Reding
2024-03-28 7:39 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Thierry Reding @ 2024-03-25 13:30 UTC (permalink / raw)
To: Akhil R, ldewangan, jonathanh, vkoul, dmaengine, linux-tegra,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 911 bytes --]
On Fri Mar 15, 2024 at 1:44 PM CET, Akhil R wrote:
> 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: ee17028009d4 ("dmaengine: tegra: Add tegra gpcdma driver")
> Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
> Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
> ---
> v1->v2:
> * corrected typo - s/exisiting/existing/
>
> drivers/dma/tegra186-gpc-dma.c | 3 +++
> 1 file changed, 3 insertions(+)
Acked-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2 RESEND] dmaengine: tegra186: Fix residual calculation
2024-03-15 12:44 [PATCH v2 RESEND] dmaengine: tegra186: Fix residual calculation Akhil R
2024-03-25 13:30 ` Thierry Reding
@ 2024-03-28 7:39 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2024-03-28 7:39 UTC (permalink / raw)
To: ldewangan, jonathanh, thierry.reding, dmaengine, linux-tegra,
linux-kernel, Akhil R
On Fri, 15 Mar 2024 18:14:11 +0530, Akhil R wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] dmaengine: tegra186: Fix residual calculation
commit: 30f0ced9971b2d8c8c24ae75786f9079489a012d
Best regards,
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-28 7:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-15 12:44 [PATCH v2 RESEND] dmaengine: tegra186: Fix residual calculation Akhil R
2024-03-25 13:30 ` Thierry Reding
2024-03-28 7:39 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox