Skip to content

Commit 9f9e3e0

Browse files
Esben HaabendalWolfram Sang
authored andcommitted
i2c: imx: Fix reinit_completion() use
Make sure to call reinit_completion() before dma is started to avoid race condition where reinit_completion() is called after complete() and before wait_for_completion_timeout(). Signed-off-by: Esben Haabendal <[email protected]> Fixes: ce1a788 ("i2c: imx: add DMA support for freescale i2c driver") Reviewed-by: Uwe Kleine-König <[email protected]> Signed-off-by: Wolfram Sang <[email protected]> Cc: [email protected]
1 parent cc8de9a commit 9f9e3e0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/i2c/busses/i2c-imx.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct *i2c_imx,
368368
goto err_desc;
369369
}
370370

371+
reinit_completion(&dma->cmd_complete);
371372
txdesc->callback = i2c_imx_dma_callback;
372373
txdesc->callback_param = i2c_imx;
373374
if (dma_submit_error(dmaengine_submit(txdesc))) {
@@ -622,7 +623,6 @@ static int i2c_imx_dma_write(struct imx_i2c_struct *i2c_imx,
622623
* The first byte must be transmitted by the CPU.
623624
*/
624625
imx_i2c_write_reg(i2c_8bit_addr_from_msg(msgs), i2c_imx, IMX_I2C_I2DR);
625-
reinit_completion(&i2c_imx->dma->cmd_complete);
626626
time_left = wait_for_completion_timeout(
627627
&i2c_imx->dma->cmd_complete,
628628
msecs_to_jiffies(DMA_TIMEOUT));
@@ -681,7 +681,6 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx,
681681
if (result)
682682
return result;
683683

684-
reinit_completion(&i2c_imx->dma->cmd_complete);
685684
time_left = wait_for_completion_timeout(
686685
&i2c_imx->dma->cmd_complete,
687686
msecs_to_jiffies(DMA_TIMEOUT));

0 commit comments

Comments
 (0)