diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-04-02 00:51:33 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-04-03 06:59:47 -0400 |
commit | c75de0ac0756d4b442f460e10461720c7c2412c2 (patch) | |
tree | 33a72a502531652f73fb539816dc4ba7622e6cc1 | |
parent | e42391cd048809d903291d07f86ed3934ce138e9 (diff) |
cpufreq: Schedule work for the first-online CPU on resume
All CPUs leaving the first-online CPU are hotplugged out on suspend and
and cpufreq core stops managing them.
On resume, we need to call cpufreq_update_policy() for this CPU's policy
to make sure its frequency is in sync with cpufreq's cached value, as it
might have got updated by hardware during suspend/resume.
The policies are always added to the top of the policy-list. So, in
normal circumstances, CPU 0's policy will be the last one in the list.
And so the code checks for the last policy.
But there are cases where it will fail. Consider quad-core system, with
policy-per core. If CPU0 is hotplugged out and added back again, the
last policy will be on CPU1 :(
To fix this in a proper way, always look for the policy of the first
online CPU. That way we will be sure that we are calling
cpufreq_update_policy() for the only CPU that wasn't hotplugged out.
Cc: 3.15+ <stable@vger.kernel.org> # 3.15+
Fixes: 2f0aea936360 ("cpufreq: suspend governors on system suspend/hibernate")
Reported-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 28e59a48b35f..8ae655c364f4 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -1698,15 +1698,18 @@ void cpufreq_resume(void) | |||
1698 | || __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS)) | 1698 | || __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS)) |
1699 | pr_err("%s: Failed to start governor for policy: %p\n", | 1699 | pr_err("%s: Failed to start governor for policy: %p\n", |
1700 | __func__, policy); | 1700 | __func__, policy); |
1701 | |||
1702 | /* | ||
1703 | * schedule call cpufreq_update_policy() for boot CPU, i.e. last | ||
1704 | * policy in list. It will verify that the current freq is in | ||
1705 | * sync with what we believe it to be. | ||
1706 | */ | ||
1707 | if (list_is_last(&policy->policy_list, &cpufreq_policy_list)) | ||
1708 | schedule_work(&policy->update); | ||
1709 | } | 1701 | } |
1702 | |||
1703 | /* | ||
1704 | * schedule call cpufreq_update_policy() for first-online CPU, as that | ||
1705 | * wouldn't be hotplugged-out on suspend. It will verify that the | ||
1706 | * current freq is in sync with what we believe it to be. | ||
1707 | */ | ||
1708 | policy = cpufreq_cpu_get_raw(cpumask_first(cpu_online_mask)); | ||
1709 | if (WARN_ON(!policy)) | ||
1710 | return; | ||
1711 | |||
1712 | schedule_work(&policy->update); | ||
1710 | } | 1713 | } |
1711 | 1714 | ||
1712 | /** | 1715 | /** |