i2c: imx: avoid taking clk_prepare mutex in PM callbacks
authorLucas Stach <l.stach@pengutronix.de>
Thu, 8 Mar 2018 13:25:18 +0000 (14:25 +0100)
committerWolfram Sang <wsa@the-dreams.de>
Tue, 3 Apr 2018 13:29:28 +0000 (15:29 +0200)
This is unsafe, as the runtime PM callbacks are called from the PM
workqueue, so this may deadlock when handling an i2c attached clock,
which may already hold the clk_prepare mutex from another context.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-imx.c

index c9632b2f0eaaab753402854064adacc8e0d8af6b..d7267dd9c7bf1da67c4c326ca53fffd6bc0e0c36 100644 (file)
@@ -1226,7 +1226,7 @@ static int 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);
 
        return 0;
 }
@@ -1236,7 +1236,7 @@ static int i2c_imx_runtime_resume(struct device *dev)
        struct imx_i2c_struct *i2c_imx = dev_get_drvdata(dev);
        int ret;
 
-       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);