Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: nomadik: Fixup system suspend

For !CONFIG_PM_RUNTIME, the device were never put back into active
state while resuming.

For CONFIG_PM_RUNTIME, we blindly trusted the device to be inactive
while we were about to handle it at suspend late, which is just too
optimistic.

Even if the driver uses pm_runtime_put_sync() after each tranfer to
return it's runtime PM resources, there are no guarantees this will
actually mean the device will inactivated. The reason is that the PM
core will prevent runtime suspend during system suspend, and thus when
a transfer occurs during the early phases of system suspend the device
will be kept active after the transfer.

To handle both issues above, use pm_runtime_force_suspend|resume() from
the system suspend|resume callbacks.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Ulf Hansson and committed by
Wolfram Sang
9219982b 8e8782c7

+7 -7
+7 -7
drivers/i2c/busses/i2c-nomadik.c
··· 879 879 #ifdef CONFIG_PM_SLEEP 880 880 static int nmk_i2c_suspend_late(struct device *dev) 881 881 { 882 - pinctrl_pm_select_sleep_state(dev); 882 + int ret; 883 883 884 + ret = pm_runtime_force_suspend(dev); 885 + if (ret) 886 + return ret; 887 + 888 + pinctrl_pm_select_sleep_state(dev); 884 889 return 0; 885 890 } 886 891 887 892 static int nmk_i2c_resume_early(struct device *dev) 888 893 { 889 - /* First go to the default state */ 890 - pinctrl_pm_select_default_state(dev); 891 - /* Then let's idle the pins until the next transfer happens */ 892 - pinctrl_pm_select_idle_state(dev); 893 - 894 - return 0; 894 + return pm_runtime_force_resume(dev); 895 895 } 896 896 #endif 897 897