diff mbox

[3/3] dma: zx: fix residue calculation

Message ID 1481810617-7650-3-git-send-email-shawnguo@kernel.org
State New
Headers show

Commit Message

Shawn Guo Dec. 15, 2016, 2:03 p.m. UTC
From: Shawn Guo <shawn.guo@linaro.org>


The dma residue is defined as the free space to end of transfer buffer,
which could be multiple segments chained together.  So the residue
calculation in zx_dma_tx_status() works for both slave_sg and cyclic
case.  But unfortunately, the 'index' is wrong.  It should plus one,
because the current segment is already occupied and shouldn't be counted
into free space.

This fixes the HDMI audio noise issue we see on ZX296718 with SPDIF
interface.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

---
 drivers/dma/zx_dma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
1.9.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Comments

Jun Nie Dec. 22, 2016, 6:22 a.m. UTC | #1
2016-12-15 22:03 GMT+08:00 Shawn Guo <shawnguo@kernel.org>:
> From: Shawn Guo <shawn.guo@linaro.org>

>

> The dma residue is defined as the free space to end of transfer buffer,

> which could be multiple segments chained together.  So the residue

> calculation in zx_dma_tx_status() works for both slave_sg and cyclic

> case.  But unfortunately, the 'index' is wrong.  It should plus one,

> because the current segment is already occupied and shouldn't be counted

> into free space.

>

> This fixes the HDMI audio noise issue we see on ZX296718 with SPDIF

> interface.

>

> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

> ---

>  drivers/dma/zx_dma.c | 3 ++-

>  1 file changed, 2 insertions(+), 1 deletion(-)

>


Reviewed-by:  Jun Nie <jun.nie@linaro.org>


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
diff mbox

Patch

diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c
index 33155c6816cc..42ff3e66c1e1 100644
--- a/drivers/dma/zx_dma.c
+++ b/drivers/dma/zx_dma.c
@@ -365,7 +365,8 @@  static enum dma_status zx_dma_tx_status(struct dma_chan *chan,
 
 		bytes = 0;
 		clli = zx_dma_get_curr_lli(p);
-		index = (clli - ds->desc_hw_lli) / sizeof(struct zx_desc_hw);
+		index = (clli - ds->desc_hw_lli) /
+				sizeof(struct zx_desc_hw) + 1;
 		for (; index < ds->desc_num; index++) {
 			bytes += ds->desc_hw[index].src_x;
 			/* end of lli */