Skip to content

Commit ea46458

Browse files
Esben Haabendalgregkh
authored andcommitted
i2c: imx: Fix reinit_completion() use
commit 9f9e3e0 upstream. 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] Signed-off-by: Sudip Mukherjee <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 60baabc commit ea46458

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
@@ -376,6 +376,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct *i2c_imx,
376376
goto err_desc;
377377
}
378378

379+
reinit_completion(&dma->cmd_complete);
379380
txdesc->callback = i2c_imx_dma_callback;
380381
txdesc->callback_param = i2c_imx;
381382
if (dma_submit_error(dmaengine_submit(txdesc))) {
@@ -619,7 +620,6 @@ static int i2c_imx_dma_write(struct imx_i2c_struct *i2c_imx,
619620
* The first byte must be transmitted by the CPU.
620621
*/
621622
imx_i2c_write_reg(msgs->addr << 1, i2c_imx, IMX_I2C_I2DR);
622-
reinit_completion(&i2c_imx->dma->cmd_complete);
623623
time_left = wait_for_completion_timeout(
624624
&i2c_imx->dma->cmd_complete,
625625
msecs_to_jiffies(DMA_TIMEOUT));
@@ -678,7 +678,6 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx,
678678
if (result)
679679
return result;
680680

681-
reinit_completion(&i2c_imx->dma->cmd_complete);
682681
time_left = wait_for_completion_timeout(
683682
&i2c_imx->dma->cmd_complete,
684683
msecs_to_jiffies(DMA_TIMEOUT));

0 commit comments

Comments
 (0)