@@ -921,6 +921,7 @@ static void async_resume(void *data, async_cookie_t cookie)
void dpm_resume(pm_message_t state)
{
struct device *dev;
+ bool suspended = (pm_transition.event != PM_EVENT_ON);
ktime_t starttime = ktime_get();
trace_suspend_resume(TPS("dpm_resume"), state.event, true);
@@ -964,7 +965,8 @@ void dpm_resume(pm_message_t state)
async_synchronize_full();
dpm_show_time(starttime, state, 0, NULL);
- cpufreq_resume();
+ if (likely(suspended))
+ cpufreq_resume();
trace_suspend_resume(TPS("dpm_resume"), state.event, false);
}
cpufreq_resume can be called even without preceding cpufreq_suspend. This can happen in following scenario: suspend_devices_and_enter --> dpm_suspend_start --> dpm_prepare --> device_prepare : this function errors out --> dpm_suspend: this is skipped due to dpm_prepare failure this means cpufreq_suspend is skipped over --> goto Recover_platform, due to previous error --> goto Resume_devices --> dpm_resume_end --> dpm_resume --> cpufreq_resume In case schedutil is used as frequency governor, cpufreq_resume will eventually call sugov_start, which does following: memset(sg_cpu, 0, sizeof(*sg_cpu)); .... This effectively erases function pointer for frequency update, causing crash later on. The function pointer would have been set correctly if subsequent cpufreq_add_update_util_hook runs successfully, but that function returns earlier because cpufreq_suspend was not called: if (WARN_ON(per_cpu(cpufreq_update_util_data, cpu))) return; Ideally, suspend should succeed, then things will be fine. But even in case of suspend failure, system should not crash. The fix is to check the pm_transition status in dpm_resume. if pm_transition.event == PMSG_ON, we know for sure dpm_suspend has not been called, so do not call cpufreq_resume. Signed-off-by: Bo Yan <byan@nvidia.com> --- drivers/base/power/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)