From 1231d7a2d63abc146e856ecf697d0f2cede92722 Mon Sep 17 00:00:00 2001
From: Robin Gong <yibin.gong@nxp.com>
Date: Fri, 7 Sep 2018 21:57:18 +0800
Subject: [PATCH] MLK-19451: dmaengine: imx-sdma: remove mdelay(1)

commit 7f3ff14b7eb1 ("dmaengine: imx-sdma: add 1ms delay to ensure
SDMA channel is stopped") add 1ms delay to ensure no dma done interrupt
come in after channel disabled. This 1ms may cause SAI underrun issue
between two times playback, because ALSA framework stop SAI module after
dma terminate, thus the 1ms timing window trigger continuous 'underrun'
interrupt. Actually, don't need 1ms delay anymore since virt-dma could
handle the interrupt after channel terminated.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
Signed-off-by: Srikanth Krishnakar <Srikanth_Krishnakar@mentor.com>
---
 drivers/dma/imx-sdma.c | 44 +-----------------------------------------
 1 file changed, 1 insertion(+), 43 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index a20b8e6dc243e1..e2cc29e87de44e 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1145,48 +1145,6 @@ static int sdma_disable_channel(struct dma_chan *chan)
 	return 0;
 }
 
-static int sdma_terminate_all(struct dma_chan *chan);
-
-static int sdma_terminate_all_with_delay(struct dma_chan *chan)
-{
-	sdma_terminate_all(chan);
-
-	/*
-	 * According to NXP R&D team a delay of one BD SDMA cost time
-	 * (maximum is 1ms) should be added after disable of the channel
-	 * bit, to ensure SDMA core has really been stopped after SDMA
-	 * clients call .device_terminate_all.
-	 */
-	usleep_range(1000, 2000);
-
-	spin_lock_irqsave(&sdmac->vc.lock, flags);
-	vchan_get_all_descriptors(&sdmac->vc, &head);
-	sdmac->desc = NULL;
-	spin_unlock_irqrestore(&sdmac->vc.lock, flags);
-	vchan_dma_desc_free_list(&sdmac->vc, &head);
-}
-
-static int sdma_disable_channel_async(struct dma_chan *chan)
-{
-	struct sdma_channel *sdmac = to_sdma_chan(chan);
-
-	sdma_disable_channel(chan);
-
-	if (sdmac->desc)
-		schedule_work(&sdmac->terminate_worker);
-
-	return 0;
-}
-
-static void sdma_channel_synchronize(struct dma_chan *chan)
-{
-	struct sdma_channel *sdmac = to_sdma_chan(chan);
-
-	vchan_synchronize(&sdmac->vc);
-
-	flush_work(&sdmac->terminate_worker);
-}
-
 static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac)
 {
 	struct sdma_engine *sdma = sdmac->sdma;
@@ -2458,7 +2416,7 @@ static int sdma_probe(struct platform_device *pdev)
 	sdma->dma_device.device_prep_slave_sg = sdma_prep_slave_sg;
 	sdma->dma_device.device_prep_dma_cyclic = sdma_prep_dma_cyclic;
 	sdma->dma_device.device_config = sdma_config;
-	sdma->dma_device.device_terminate_all = sdma_terminate_all_with_delay;
+	sdma->dma_device.device_terminate_all = sdma_terminate_all;
 	sdma->dma_device.device_pause = sdma_channel_pause;
 	sdma->dma_device.device_resume = sdma_channel_resume;
 	sdma->dma_device.src_addr_widths = SDMA_DMA_BUSWIDTHS;
-- 
GitLab