mbox series

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

Message ID 20210623095942.3325-1-wsa+renesas@sang-engineering.com
Headers show
Series i2c: use proper DMAENGINE API for termination | expand

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. Update the drivers I audited.


Wolfram Sang (7):
  i2c: at91-master: : use proper DMAENGINE API for termination
  i2c: imx: : use proper DMAENGINE API for termination
  i2c: mxs: : use proper DMAENGINE API for termination
  i2c: qup: : use proper DMAENGINE API for termination
  i2c: rcar: : use proper DMAENGINE API for termination
  i2c: sh_mobile: : use proper DMAENGINE API for termination
  i2c: stm32f7: : use proper DMAENGINE API for termination

 drivers/i2c/busses/i2c-at91-master.c | 4 ++--
 drivers/i2c/busses/i2c-imx.c         | 6 +++---
 drivers/i2c/busses/i2c-mxs.c         | 4 ++--
 drivers/i2c/busses/i2c-qup.c         | 2 +-
 drivers/i2c/busses/i2c-rcar.c        | 4 ++--
 drivers/i2c/busses/i2c-sh_mobile.c   | 4 ++--
 drivers/i2c/busses/i2c-stm32f7.c     | 8 ++++----
 7 files changed, 16 insertions(+), 16 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.
Oleksij Rempel June 25, 2021, 12:06 p.m. UTC | #3
Hello Wolfram,

On Wed, Jun 23, 2021 at 11:59:36AM +0200, Wolfram Sang 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>

Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de

Thank you!

> ---
>  drivers/i2c/busses/i2c-imx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index dc5ca71906db..b224e82924d2 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -423,7 +423,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct *i2c_imx,
>  	return 0;
>  
>  err_submit:
> -	dmaengine_terminate_all(dma->chan_using);
> +	dmaengine_terminate_sync(dma->chan_using);
>  err_desc:
>  	dma_unmap_single(chan_dev, dma->dma_buf,
>  			dma->dma_len, dma->dma_data_dir);
> @@ -899,7 +899,7 @@ static int i2c_imx_dma_write(struct imx_i2c_struct *i2c_imx,
>  				&i2c_imx->dma->cmd_complete,
>  				msecs_to_jiffies(DMA_TIMEOUT));
>  	if (time_left == 0) {
> -		dmaengine_terminate_all(dma->chan_using);
> +		dmaengine_terminate_sync(dma->chan_using);
>  		return -ETIMEDOUT;
>  	}
>  
> @@ -954,7 +954,7 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx,
>  				&i2c_imx->dma->cmd_complete,
>  				msecs_to_jiffies(DMA_TIMEOUT));
>  	if (time_left == 0) {
> -		dmaengine_terminate_all(dma->chan_using);
> +		dmaengine_terminate_sync(dma->chan_using);
>  		return -ETIMEDOUT;
>  	}
>  
> -- 
> 2.30.2
> 
>
Codrin Ciubotariu July 13, 2021, 9:07 a.m. UTC | #4
On 23.06.2021 12:59, Wolfram Sang wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

> 

> 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>


Reviewed-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>


Thanks!
Wolfram Sang Aug. 11, 2021, 1:24 p.m. UTC | #5
On Wed, Jun 23, 2021 at 11:59:35AM +0200, Wolfram Sang 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>


Applied to for-next, thanks!
Wolfram Sang Aug. 11, 2021, 1:24 p.m. UTC | #6
On Wed, Jun 23, 2021 at 11:59:36AM +0200, Wolfram Sang 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>

Applied to for-next, thanks!
Wolfram Sang Aug. 11, 2021, 1:24 p.m. UTC | #7
On Wed, Jun 23, 2021 at 11:59:40AM +0200, Wolfram Sang 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>

Applied to for-next, thanks!
Wolfram Sang Aug. 11, 2021, 1:26 p.m. UTC | #8
On Wed, Jun 23, 2021 at 11:59:34AM +0200, Wolfram Sang wrote:
> dmaengine_terminate_all() is deprecated in favor of explicitly saying if

> it should be sync or async. Update the drivers I audited.


I applied the patches now, except for i2c-rcar and i2c-stm32f7 where
this approach can't be used because of interrupt context. I will check
for i2c-rcar how to do this properly and Alain for i2c-stm32f7 and we
will resend then.
Codrin Ciubotariu Aug. 11, 2021, 1:34 p.m. UTC | #9
On 11.08.2021 16:24, Wolfram Sang wrote:
> On Wed, Jun 23, 2021 at 11:59:35AM +0200, Wolfram Sang 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>
> 
> Applied to for-next, thanks!
> 

just saw it now, there is a double : :  in the subject. Maybe you could 
fix it if it's not too late...

Thanks and best regards,
Codrin