diff options
author | Bo Yan <byan@nvidia.com> | 2018-01-23 16:57:55 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-02-05 05:03:33 -0500 |
commit | 703cbaa601ff3fb554d1246c336ba727cc083ea0 (patch) | |
tree | 1d6c54f84f12ed6de8b299cb6b5976c504e40550 | |
parent | 7f3fdd40a7dfaa7405185250974b0fabd08c1f8b (diff) |
cpufreq: Skip cpufreq resume if it's not suspended
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;
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
cpufreq.
Signed-off-by: Bo Yan <byan@nvidia.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
[ rjw: Dropped printing a message ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 421f318c0e66..de33ebf008ad 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -1686,6 +1686,9 @@ void cpufreq_resume(void) | |||
1686 | if (!cpufreq_driver) | 1686 | if (!cpufreq_driver) |
1687 | return; | 1687 | return; |
1688 | 1688 | ||
1689 | if (unlikely(!cpufreq_suspended)) | ||
1690 | return; | ||
1691 | |||
1689 | cpufreq_suspended = false; | 1692 | cpufreq_suspended = false; |
1690 | 1693 | ||
1691 | if (!has_target() && !cpufreq_driver->resume) | 1694 | if (!has_target() && !cpufreq_driver->resume) |