Skip to content

Commit

Permalink
i2c: imx-lpi2c: avoid taking clk_prepare mutex in PM callbacks
Browse files Browse the repository at this point in the history
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: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
  • Loading branch information
Alexander Stein authored and Wolfram Sang committed May 3, 2023
1 parent c770657 commit fa39065
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/i2c/busses/i2c-imx-lpi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ static int __maybe_unused lpi2c_runtime_suspend(struct device *dev)
{
struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev);

clk_bulk_disable_unprepare(lpi2c_imx->num_clks, lpi2c_imx->clks);
clk_bulk_disable(lpi2c_imx->num_clks, lpi2c_imx->clks);
pinctrl_pm_select_sleep_state(dev);

return 0;
Expand All @@ -651,7 +651,7 @@ static int __maybe_unused lpi2c_runtime_resume(struct device *dev)
int ret;

pinctrl_pm_select_default_state(dev);
ret = clk_bulk_prepare_enable(lpi2c_imx->num_clks, lpi2c_imx->clks);
ret = clk_bulk_enable(lpi2c_imx->num_clks, lpi2c_imx->clks);
if (ret) {
dev_err(dev, "failed to enable I2C clock, ret=%d\n", ret);
return ret;
Expand Down

0 comments on commit fa39065

Please sign in to comment.