i2c: use proper DMAENGINE API for termination
Subsystems (11)
Wolfram Sang
maintainercover i2c: use proper DMAENGINE API for termination
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(-)
Signature · 1 line
2.30.2
Wolfram Sang
maintainerPATCH 1/7 i2c: at91-master: : use proper DMAENGINE API for termination
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.
--- drivers/i2c/busses/i2c-at91-master.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-at91-master.c +2 -2
@@ -138,9 +138,9 @@ static void at91_twi_dma_cleanup(struct at91_twi_dev *dev)if (dma->xfer_in_progress) {if (dma->direction ==DMA_FROM_DEVICE ) -dmaengine_terminate_all (dma->chan_rx); +dmaengine_terminate_sync (dma->chan_rx);else -dmaengine_terminate_all (dma->chan_tx); +dmaengine_terminate_sync (dma->chan_tx); dma->xfer_in_progress = false; }if (dma->buf_mapped) {
Signature · 1 line
2.30.2
Re: [PATCH 1/7] i2c: at91-master: : use proper DMAENGINE API for termination
Quoted 8 lines · Wolfram Sang
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 wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>
Thanks!
Re: [PATCH 1/7] i2c: at91-master: : use proper DMAENGINE API for termination
In reply to Wolfram SangQuoted 6 lines · Wolfram Sang
dmaengine_terminate_all()is deprecated in favor of explicitly saying if it should be sync or async. Here, we wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>
Applied to for-next, thanks!
[email protected]
maintainerRe: [PATCH 1/7] i2c: at91-master: : use proper DMAENGINE API for termination
Quoted 10 lines · Wolfram Sang
Quoted 6 lines · Wolfram Sang
dmaengine_terminate_all()is deprecated in favor of explicitly saying if it should be sync or async. Here, we wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>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
Wolfram Sang
maintainerPATCH 2/7 i2c: imx: : use proper DMAENGINE API for termination
In reply to Wolfram Sangdmaengine_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.
--- drivers/i2c/busses/i2c-imx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-imx.c +3 -3
@@ -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 ; }
Signature · 1 line
2.30.2
Re: [PATCH 2/7] i2c: imx: : use proper DMAENGINE API for termination
Hello Wolfram,
Quoted 6 lines · Wolfram Sang
dmaengine_terminate_all()is deprecated in favor of explicitly saying if it should be sync or async. Here, we wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>
Thank you!
Quoted 39 lines
--- drivers/i2c/busses/i2c-imx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/i2c/busses/i2c-imx.c +3
-3@@ -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 ; }Signature · 1 line
2.30.2
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH 2/7] i2c: imx: : use proper DMAENGINE API for termination
In reply to Wolfram SangQuoted 6 lines · Wolfram Sang
dmaengine_terminate_all()is deprecated in favor of explicitly saying if it should be sync or async. Here, we wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>
Applied to for-next, thanks!
Wolfram Sang
maintainerPATCH 3/7 i2c: mxs: : use proper DMAENGINE API for termination
In reply to Wolfram Sangdmaengine_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.
--- drivers/i2c/busses/i2c-mxs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-mxs.c +2 -2
@@ -290,14 +290,14 @@ static int mxs_i2c_dma_setup_xfer(struct i2c_adapter *adap, select_init_dma_fail:dma_unmap_sg (i2c->dev, &i2c->sg_io[0 ],1 ,DMA_TO_DEVICE ); select_init_pio_fail: -dmaengine_terminate_all (i2c->dmach); +dmaengine_terminate_sync (i2c->dmach);return -EINVAL ;/* Write failpath. */ write_init_dma_fail:dma_unmap_sg (i2c->dev, i2c->sg_io,2 ,DMA_TO_DEVICE ); write_init_pio_fail: -dmaengine_terminate_all (i2c->dmach); +dmaengine_terminate_sync (i2c->dmach);return -EINVAL ; }
Signature · 1 line
2.30.2
Re: [PATCH 3/7] i2c: mxs: : use proper DMAENGINE API for termination
Quoted 6 lines · Wolfram Sang
dmaengine_terminate_all()is deprecated in favor of explicitly saying if it should be sync or async. Here, we wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>
Applied to for-next, thanks!
Wolfram Sang
maintainerPATCH 4/7 i2c: qup: : use proper DMAENGINE API for termination
In reply to Wolfram Sangdmaengine_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.
--- drivers/i2c/busses/i2c-qup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-qup.c +1 -1
@@ -778,7 +778,7 @@ static int qup_i2c_bam_schedule_desc(struct qup_i2c_dev *qup) ret = -EINVAL ;/* abort TX descriptors */ -dmaengine_terminate_all (qup->btx.dma); +dmaengine_terminate_sync (qup->btx.dma); goto desc_err; }
Signature · 1 line
2.30.2
Re: [PATCH 4/7] i2c: qup: : use proper DMAENGINE API for termination
Quoted 6 lines · Wolfram Sang
dmaengine_terminate_all()is deprecated in favor of explicitly saying if it should be sync or async. Here, we wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>
Applied to for-next, thanks!
Wolfram Sang
maintainerPATCH 5/7 i2c: rcar: : use proper DMAENGINE API for termination
In reply to Wolfram Sangdmaengine_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.
--- drivers/i2c/busses/i2c-rcar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-rcar.c +2 -2
@@ -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); }
Signature · 1 line
2.30.2
Re: [PATCH 5/7] i2c: rcar: : use proper DMAENGINE API for termination
Hi Wolfram,
Quoted 6 lines · Wolfram Sang
dmaengine_terminate_all()is deprecated in favor of explicitly saying if it should be sync or async. Here, we wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>
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
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Wolfram Sang
maintainerRe: [PATCH 5/7] i2c: rcar: : use proper DMAENGINE API for termination
Quoted 3 lines
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 :(
Quoted 1 line
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.
Wolfram Sang
maintainerPATCH 6/7 i2c: sh_mobile: : use proper DMAENGINE API for termination
In reply to Wolfram Sangdmaengine_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.
--- drivers/i2c/busses/i2c-sh_mobile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-sh_mobile.c +2 -2
@@ -458,9 +458,9 @@ static void sh_mobile_i2c_cleanup_dma(struct sh_mobile_i2c_data *pd)if (pd->dma_direction ==DMA_NONE )return ;else if (pd->dma_direction ==DMA_FROM_DEVICE ) -dmaengine_terminate_all (pd->dma_rx); +dmaengine_terminate_sync (pd->dma_rx);else if (pd->dma_direction ==DMA_TO_DEVICE ) -dmaengine_terminate_all (pd->dma_tx); +dmaengine_terminate_sync (pd->dma_tx);sh_mobile_i2c_dma_unmap (pd); }
Signature · 1 line
2.30.2
Re: [PATCH 6/7] i2c: sh_mobile: : use proper DMAENGINE API for termination
Quoted 6 lines · Wolfram Sang
dmaengine_terminate_all()is deprecated in favor of explicitly saying if it should be sync or async. Here, we wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>
Applied to for-next, thanks!
Wolfram Sang
maintainerPATCH 7/7 i2c: stm32f7: : use proper DMAENGINE API for termination
In reply to Wolfram Sangdmaengine_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.
--- drivers/i2c/busses/i2c-stm32f7.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-stm32f7.c +4 -4
@@ -1567,7 +1567,7 @@ static irqreturn_t stm32f7_i2c_isr_event_thread(int irq, void *data)if (!ret) {dev_dbg (i2c_dev->dev,"<%s>: Timed out\n" , __func__);stm32f7_i2c_disable_dma_req (i2c_dev); -dmaengine_terminate_all (dma->chan_using); +dmaengine_terminate_sync (dma->chan_using); f7_msg->result = -ETIMEDOUT ; }
@@ -1637,7 +1637,7 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)/* Disable dma */ if (i2c_dev->use_dma) {stm32f7_i2c_disable_dma_req (i2c_dev); -dmaengine_terminate_all (dma->chan_using); +dmaengine_terminate_sync (dma->chan_using); } i2c_dev->master_mode = false;
@@ -1678,7 +1678,7 @@ static int stm32f7_i2c_xfer(struct i2c_adapter *i2c_adap,dev_dbg (i2c_dev->dev,"Access to slave 0x%x timed out\n" , i2c_dev->msg->addr);if (i2c_dev->use_dma) -dmaengine_terminate_all (dma->chan_using); +dmaengine_terminate_sync (dma->chan_using); ret = -ETIMEDOUT ; }
@@ -1727,7 +1727,7 @@ static int stm32f7_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,if (!timeout) {dev_dbg (dev,"Access to slave 0x%x timed out\n" , f7_msg->addr);if (i2c_dev->use_dma) -dmaengine_terminate_all (dma->chan_using); +dmaengine_terminate_sync (dma->chan_using); ret = -ETIMEDOUT ; goto pm_free; }
Signature · 1 line
2.30.2
Wolfram Sang
maintainerRe: [PATCH 7/7] i2c: stm32f7: : use proper DMAENGINE API for termination
Quoted 6 lines · Wolfram Sang
dmaengine_terminate_all()is deprecated in favor of explicitly saying if it should be sync or async. Here, we wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>
Eeks, this is called from irq context as well. Broken patch :(
Alain Volmat
maintainerRe: [PATCH 7/7] i2c: stm32f7: : use proper DMAENGINE API for termination
Hi Wolfram,
thanks for the update. If you are ok with that I modify the patch to partially rely on _async / synchronize whenever needed and push it again separately.
Regards,
Alain
Quoted 10 lines · Wolfram Sang
Quoted 6 lines · Wolfram Sang
dmaengine_terminate_all()is deprecated in favor of explicitly saying if it should be sync or async. Here, we wantdmaengine_terminate_sync()because there is no other synchronization code in the driver to handle an async case.Signed-off-by Wolfram Sang <[email protected]>Eeks, this is called from irq context as well. Broken patch :(
Wolfram Sang
maintainerRe: [PATCH 7/7] i2c: stm32f7: : use proper DMAENGINE API for termination
Hi Alain,
Quoted 3 lines
thanks for the update. If you are ok with that I modify the patch to partially rely on
_async/ synchronize whenever needed and push it again separately.
Perfect, thanks!
All the best,
Wolfram
Wolfram Sang
maintainerQuoted 2 lines · Wolfram Sang
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.