All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] dma: imx-sdma: add 1ms delay to ensure SDMA channel is stopped
@ 2017-03-17  6:12 jiada_wang
  2017-03-17  6:12 ` jiada_wang
  0 siblings, 1 reply; 3+ messages in thread
From: jiada_wang @ 2017-03-17  6:12 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams; +Cc: dmaengine, linux-kernel, jiada_wang

From: Jiada Wang <jiada_wang@mentor.com>

Changes from v2:
Documented the reasoning about adding 1ms delay after disable of
channel bit in commit changelog and inline comment.

Jiada Wang (1):
  dma: imx-sdma: add 1ms delay to ensure SDMA channel is stopped

 drivers/dma/imx-sdma.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] dma: imx-sdma: add 1ms delay to ensure SDMA channel is stopped
  2017-03-17  6:12 [PATCH v2] dma: imx-sdma: add 1ms delay to ensure SDMA channel is stopped jiada_wang
@ 2017-03-17  6:12 ` jiada_wang
  2017-03-27  5:21   ` Vinod Koul
  0 siblings, 1 reply; 3+ messages in thread
From: jiada_wang @ 2017-03-17  6:12 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams; +Cc: dmaengine, linux-kernel, jiada_wang

From: Jiada Wang <jiada_wang@mentor.com>

sdma_disable_channel() cannot ensure dma is stopped to access
module's FIFOs. There is chance SDMA core is running and accessing
BD when disable of corresponding channel, this may cause sometimes
even after call of .sdma_disable_channel(), SDMA core still be
running and accessing module's FIFOs.

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.

This patch introduces adds a new function sdma_disable_channel_with_delay()
which simply adds 1ms delay after call sdma_disable_channel(),
and set it as .device_terminate_all.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
 drivers/dma/imx-sdma.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index d1651a5..21726a2 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -937,6 +937,21 @@ static int sdma_disable_channel(struct dma_chan *chan)
 	return 0;
 }
 
+static int sdma_disable_channel_with_delay(struct dma_chan *chan)
+{
+	sdma_disable_channel(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.
+	 */
+	mdelay(1);
+
+	return 0;
+}
+
 static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac)
 {
 	struct sdma_engine *sdma = sdmac->sdma;
@@ -1828,7 +1843,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_disable_channel;
+	sdma->dma_device.device_terminate_all = sdma_disable_channel_with_delay;
 	sdma->dma_device.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
 	sdma->dma_device.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
 	sdma->dma_device.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] dma: imx-sdma: add 1ms delay to ensure SDMA channel is stopped
  2017-03-17  6:12 ` jiada_wang
@ 2017-03-27  5:21   ` Vinod Koul
  0 siblings, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2017-03-27  5:21 UTC (permalink / raw)
  To: jiada_wang; +Cc: dan.j.williams, dmaengine, linux-kernel

On Thu, Mar 16, 2017 at 11:12:09PM -0700, jiada_wang@mentor.com wrote:
> From: Jiada Wang <jiada_wang@mentor.com>
> 
> sdma_disable_channel() cannot ensure dma is stopped to access
> module's FIFOs. There is chance SDMA core is running and accessing
> BD when disable of corresponding channel, this may cause sometimes
> even after call of .sdma_disable_channel(), SDMA core still be
> running and accessing module's FIFOs.
> 
> 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.
> 
> This patch introduces adds a new function sdma_disable_channel_with_delay()
> which simply adds 1ms delay after call sdma_disable_channel(),
> and set it as .device_terminate_all.

Applied after fixing the subsystem name.


-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-27  5:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17  6:12 [PATCH v2] dma: imx-sdma: add 1ms delay to ensure SDMA channel is stopped jiada_wang
2017-03-17  6:12 ` jiada_wang
2017-03-27  5:21   ` Vinod Koul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.