PM: sleep: Pause cpuidle later and resume it earlier during system transitions
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 22 Oct 2021 16:07:47 +0000 (18:07 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 26 Oct 2021 13:52:07 +0000 (15:52 +0200)
commit23f62d7ab25bd1a7dbbb89cfcd429df7735855af
tree1a3b952983081d491bd9e5d6fa9f7e8ad52c3eec
parent8d89835b0467b7e618c1c93603c1aff85a0c3c66
PM: sleep: Pause cpuidle later and resume it earlier during system transitions

Commit 8651f97bd951 ("PM / cpuidle: System resume hang fix with
cpuidle") that introduced cpuidle pausing during system suspend
did that to work around a platform firmware issue causing systems
to hang during resume if CPUs were allowed to enter idle states
in the system suspend and resume code paths.

However, pausing cpuidle before the last phase of suspending
devices is the source of an otherwise arbitrary difference between
the suspend-to-idle path and other system suspend variants, so it is
cleaner to do that later, before taking secondary CPUs offline (it
is still safer to take secondary CPUs offline with cpuidle paused,
though).

Modify the code accordingly, but in order to avoid code duplication,
introduce new wrapper functions, pm_sleep_disable_secondary_cpus()
and pm_sleep_enable_secondary_cpus(), to combine cpuidle_pause()
and cpuidle_resume(), respectively, with the handling of secondary
CPUs during system-wide transitions to sleep states.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/base/power/main.c
kernel/power/hibernate.c
kernel/power/power.h
kernel/power/suspend.c