MLK-13794: BACKPORT: dmaengine: imx-sdma - correct the dma transfer residue calculation
authorNandor Han <nandor.han@ge.com>
Tue, 11 Oct 2016 11:13:41 +0000 (14:13 +0300)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:58:08 +0000 (14:58 -0500)
This patch fixes crackling sound reported when running autorun-asrc.sh
and it is a backport of 85f57752b3 ("dmaengine: imx-sdma - correct
the dma transfer residue calculation") from v10-rc6.

Original commit message:

From: Nandor Han <nandor.han@ge.com>
Date: Tue, 11 Oct 2016 14:13:41 +0300
Subject: [PATCH] dmaengine: imx-sdma - correct the dma transfer residue
 calculation

The residue calculation was taking in consideration that dma
transaction status will be always retrieved in the dma callback
used to inform that dma transfer is complete. However this is not
the case for all subsystems that use dma. Some subsystems use a
timer to check the dma status periodically.

Therefore the calculation was updated and residue is calculated
accordingly by a) update the residue calculation taking in
consideration the last used buffer index by using *buf_ptail* variable
and b) chn_real_count (number of bytes transferred) is initialized to
zero, when dma channel is created, to avoid using an uninitialized
value in residue calculation when dma status is checked without
waiting dma complete event.

Signed-off-by: Nandor Han <nandor.han@ge.com>
Acked-by: Peter Senna Tschudin <peter.senna@collabora.com>
Tested-by: Peter Senna Tschudin <peter.senna@collabora.com>
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
drivers/dma/imx-sdma.c

index 581df66..5fbe320 100644 (file)
@@ -1312,6 +1312,8 @@ static int sdma_transfer_init(struct sdma_channel *sdmac,
 
        sdmac->status = DMA_IN_PROGRESS;
        sdmac->buf_tail = 0;
+       sdmac->buf_ptail = 0;
+       sdmac->chn_real_count = 0;
        sdmac->flags = 0;
        sdmac->direction = direction;
        sdmac->flags = 0;