diff mbox series

[5/7] i2c: rcar: : use proper DMAENGINE API for termination

Message ID 20210623095942.3325-6-wsa+renesas@sang-engineering.com (mailing list archive)
State New, archived
Headers show
Series i2c: use proper DMAENGINE API for termination | expand

Commit Message

Wolfram Sang June 23, 2021, 9:59 a.m. UTC
dmaengine_terminate_all() is deprecated in favor of explicitly saying if
it should be sync or async. Here, we want dmaengine_terminate_sync()
because there is no other synchronization code in the driver to handle
an async case.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/busses/i2c-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Geert Uytterhoeven June 23, 2021, 2:02 p.m. UTC | #1
Hi Wolfram,

On Wed, Jun 23, 2021 at 12:01 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> dmaengine_terminate_all() is deprecated in favor of explicitly saying if
> it should be sync or async. Here, we want dmaengine_terminate_sync()
> because there is no other synchronization code in the driver to handle
> an async case.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Thanks for your patch!

Is this safe? The driver is not using a threaded irq, and DMA termination
may be called from the interrupt handler.

Have you tried triggering DMA termination, with lockdep enabled?

Gr{oetje,eeting}s,

                        Geert
Wolfram Sang June 23, 2021, 2:08 p.m. UTC | #2
> Is this safe? The driver is not using a threaded irq, and DMA termination
> may be called from the interrupt handler.

You are right, this will not work. Not my best day today, I overlooked
it for i2c-rcar and lost the note pointing out the same issue for
stm32f7 :(

> Have you tried triggering DMA termination, with lockdep enabled?

Nope. As the code didn't show signs of async nature, I assumed sync was
desired anyhow.
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 327c092a4130..41ff327882ef 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -391,9 +391,9 @@  static void rcar_i2c_cleanup_dma(struct rcar_i2c_priv *priv)
 	if (priv->dma_direction == DMA_NONE)
 		return;
 	else if (priv->dma_direction == DMA_FROM_DEVICE)
-		dmaengine_terminate_all(priv->dma_rx);
+		dmaengine_terminate_sync(priv->dma_rx);
 	else if (priv->dma_direction == DMA_TO_DEVICE)
-		dmaengine_terminate_all(priv->dma_tx);
+		dmaengine_terminate_sync(priv->dma_tx);
 
 	rcar_i2c_dma_unmap(priv);
 }