__device_release_driver() drops the runtime PM reference it holds for the device before calling into the driver's remove() callback, so by the time cci_remove() runs the controller may already be runtime suspended with the CCI clocks gated. cci_halt() then does an unclocked write to CCI_HALT_REQ and waits for an acknowledge interrupt that cannot arrive. Resume the device for the teardown and drop the reference once it is done, skipping the halt altogether if the device cannot be resumed. Fixes: e517526195de ("i2c: Add Qualcomm CCI I2C driver") Cc: stable@vger.kernel.org Signed-off-by: Loic Poulain --- drivers/i2c/busses/i2c-qcom-cci.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index 476526b099c3504243fb5c9ee2031a68b8acc02c..9f6d5c3a28e59df6d206d599a71b9c60f678c2a6 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -814,14 +814,20 @@ static int cci_probe(struct platform_device *pdev) static void cci_remove(struct platform_device *pdev) { struct cci *cci = platform_get_drvdata(pdev); - int i; + int i, ret; + + /* Ensure the device is clocked before issuing the halt requests */ + ret = pm_runtime_get_sync(cci->dev); for (i = 0; i < cci->data->num_masters; i++) { if (cci->master[i].cci) { i2c_del_adapter(&cci->master[i].adap); - cci_halt(cci, i); + if (ret >= 0) + cci_halt(cci, i); } } + + pm_runtime_put_sync(cci->dev); } static const struct cci_data cci_v1_data = { -- 2.34.1 From devm_pm_runtime_set_active_enabled() onwards the clocks are owned by runtime PM: the device is marked active while they are on, and the devres cleanup calls pm_runtime_dont_use_autosuspend(), which runtime suspends the device synchronously and so disables the clocks. The error_i2c path therefore has nothing left to undo, so return directly rather than falling through an unbalanced clk disabling. Fixes: f98d49864821 ("i2c: qcom-cci: fix autosuspend cleanup") Cc: stable@vger.kernel.org Signed-off-by: Loic Poulain --- drivers/i2c/busses/i2c-qcom-cci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index 9f6d5c3a28e59df6d206d599a71b9c60f678c2a6..dfe8f6c712369b052f813e2ade1aec9ce5aacedd 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -805,6 +805,10 @@ static int cci_probe(struct platform_device *pdev) if (cci->master[i].cci) i2c_del_adapter(&cci->master[i].adap); } + + /* Runtime PM owns the clocks */ + return ret; + disable_clocks: cci_disable_clocks(cci); -- 2.34.1