From fcc78cacca9c9b1272148c1bcfeb01e440b5311d Mon Sep 17 00:00:00 2001 From: Teresa Remmet Date: Mon, 11 Jan 2021 11:34:02 +0100 Subject: [PATCH 1/2] i2c: imx: Fix ABBA deadlock again Like other i2c controllers we see deadlock issues with clock prepare mutex. I our case this came up with a clock output of a rtc connected to i2c bus. This issue has already been fixed upstream by: (d9a22d713acb) i2c: imx: avoid taking clk_prepare mutex in PM callbacks But was reintroduced by a wrongly resolved merge conflict with this commit: (66c0769b6ca8) MLK-11403: I2C: imx: restore pin setting for i2c So again we keep the i2c clock prepared and only enable and disable it for a transfer. Signed-off-by: Teresa Remmet --- drivers/i2c/busses/i2c-imx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index e5da0588fa7ce..7de39df3c2efb 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -1860,7 +1860,7 @@ static int __maybe_unused i2c_imx_runtime_suspend(struct device *dev) { struct imx_i2c_struct *i2c_imx = dev_get_drvdata(dev); - clk_disable_unprepare(i2c_imx->clk); + clk_disable(i2c_imx->clk); pinctrl_pm_select_sleep_state(dev); return 0; @@ -1872,7 +1872,7 @@ static int __maybe_unused i2c_imx_runtime_resume(struct device *dev) int ret; pinctrl_pm_select_default_state(dev); - ret = clk_prepare_enable(i2c_imx->clk); + ret = clk_enable(i2c_imx->clk); if (ret) dev_err(dev, "can't enable I2C clock, ret=%d\n", ret); From b768661fbc71b1d53bb69ef0fbbde262c1ba967a Mon Sep 17 00:00:00 2001 From: Teresa Remmet Date: Mon, 11 Jan 2021 11:34:03 +0100 Subject: [PATCH 2/2] i2c: imx: Remove clk_get_rate for each transfer again As clk_get_rate() also keeps the clk prepare lock which can lead into a deadlock. It was removed upstream with this commit: (90ad2cbe88c2) i2c: imx: use clk notifier for rate changes But it has been readded again with: (0e94d44f4403) MLK-20368 i2c-imx: Coverity: fix divide by zero warning The commit meassage does not explain why it was readded. It is not needed as the clk notifier is used. Removed it again. Signed-off-by: Teresa Remmet --- drivers/i2c/busses/i2c-imx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 7de39df3c2efb..53fac5df9cd7a 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -722,10 +722,6 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx, bool atomic) unsigned int temp = 0; int result; - result = i2c_imx_set_clk(i2c_imx, clk_get_rate(i2c_imx->clk)); - if (result) - return result; - imx_i2c_write_reg(i2c_imx->ifdr, i2c_imx, IMX_I2C_IFDR); /* Enable I2C controller */ imx_i2c_write_reg(i2c_imx->hwdata->i2sr_clr_opcode, i2c_imx, IMX_I2C_I2SR);