[lkml]   [2019]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.4 103/132] cpufreq: Skip cpufreq resume if its not suspended
From: Bo Yan <>

commit 703cbaa601ff3fb554d1246c336ba727cc083ea0 upstream.

cpufreq_resume can be called even without preceding cpufreq_suspend.
This can happen in following scenario:

--> 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)))

The fix is to check cpufreq_suspended first, if it's false, that means
cpufreq_suspend was not called in the first place, so do not resume

Signed-off-by: Bo Yan <>
Acked-by: Viresh Kumar <>
[ rjw: Dropped printing a message ]
Signed-off-by: Rafael J. Wysocki <>
Signed-off-by: Lee Jones <>
Signed-off-by: Greg Kroah-Hartman <>

drivers/cpufreq/cpufreq.c | 3 +++
1 file changed, 3 insertions(+)

--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1627,6 +1627,9 @@ void cpufreq_resume(void)
if (!cpufreq_driver)

+ if (unlikely(!cpufreq_suspended))
+ return;
cpufreq_suspended = false;

if (!has_target())

 \ /
  Last update: 2019-11-27 21:38    [W:0.513 / U:3.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site