Skip to content

Commit 70e633b

Browse files
khayash1Wolfram Sang
authored andcommitted
i2c: designware: Fix clock issue when PM is disabled
When the driver is removed, the clocks are first enabled by calling pm_runtime_get_sync(), and then disabled with pm_runtime_put_sync(). If CONFIG_PM=y, clocks for this controller are disabled when it's in the idle state. So the clocks are properly disabled when the driver exits. Othewise, the clocks are always enabled and the PM functions have no effect. Therefore, the driver exits without disabling the clocks. # cat /sys/kernel/debug/clk/clk-pclk/clk_enable_count 18 # echo 1214a000.i2c > /sys/bus/platform/drivers/i2c_designware/bind # cat /sys/kernel/debug/clk/clk-pclk/clk_enable_count 20 # echo 1214a000.i2c > /sys/bus/platform/drivers/i2c_designware/unbind # cat /sys/kernel/debug/clk/clk-pclk/clk_enable_count 20 To ensure that the clocks can be disabled correctly even without CONFIG_PM=y, should add the following fixes: - Replace with pm_runtime_put_noidle(), which only decrements the runtime PM usage count. - Call i2c_dw_prepare_clk(false) to explicitly disable the clocks. Fixes: 7272194 ("i2c-designware: add minimal support for runtime PM") Co-developed-by: Kohei Ito <ito.kohei@socionext.com> Signed-off-by: Kohei Ito <ito.kohei@socionext.com> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
1 parent 12aad29 commit 70e633b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/i2c/busses/i2c-designware-platdrv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,11 @@ static void dw_i2c_plat_remove(struct platform_device *pdev)
333333
i2c_dw_disable(dev);
334334

335335
pm_runtime_dont_use_autosuspend(device);
336-
pm_runtime_put_sync(device);
336+
pm_runtime_put_noidle(device);
337337
dw_i2c_plat_pm_cleanup(dev);
338338

339+
i2c_dw_prepare_clk(dev, false);
340+
339341
i2c_dw_remove_lock_support(dev);
340342

341343
reset_control_assert(dev->rst);

0 commit comments

Comments
 (0)