* [PATCH] cpufreq: intel_pstate: Fix HWP on boot CPU after system resume
@ 2016-05-02 0:27 Rafael J. Wysocki
2016-05-02 2:12 ` Viresh Kumar
0 siblings, 1 reply; 2+ messages in thread
From: Rafael J. Wysocki @ 2016-05-02 0:27 UTC (permalink / raw)
To: Linux PM list
Cc: Srinivas Pandruvada, Viresh Kumar, Linux Kernel Mailing List
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Commit 41cfd64cf49fc "Update frequencies of policy->cpus only from
->set_policy()" changed the way the intel_pstate driver's ->set_policy
callback updates the HWP (hardware-managed P-states) settings.
A side effect of it is that if those settings are modified on the
boot CPU during system suspend and wakeup, they will never be
restored during subsequent system resume.
To address this problem, allow cpufreq drivers that don't provide
->target or ->target_index callbacks to use ->suspend and ->resume
callbacks and add a ->resume callback to intel_pstate to restore
the HWP settings on the CPUs that belong to the given policy.
Fixes: 41cfd64cf49fc "Update frequencies of policy->cpus only from ->set_policy()"
Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
Note: We've tried to address that issue by adding syscore_ops to
intel_pstate and restoring the boot CPU's HWP setting from a
syscore resume, but that turns out to be too early (apparently,
the processor is not ready for that at that point).
---
drivers/cpufreq/cpufreq.c | 28 ++++++++++++++++------------
drivers/cpufreq/intel_pstate.c | 12 ++++++++++--
2 files changed, 26 insertions(+), 14 deletions(-)
Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/intel_pstate.c
+++ linux-pm/drivers/cpufreq/intel_pstate.c
@@ -318,6 +318,14 @@ static void intel_pstate_hwp_set(const s
}
}
+static int intel_pstate_hwp_set_policy(struct cpufreq_policy *policy)
+{
+ if (hwp_active)
+ intel_pstate_hwp_set(policy->cpus);
+
+ return 0;
+}
+
static void intel_pstate_hwp_set_online_cpus(void)
{
get_online_cpus();
@@ -1183,8 +1191,7 @@ static int intel_pstate_set_policy(struc
out:
intel_pstate_set_update_util_hook(policy->cpu);
- if (hwp_active)
- intel_pstate_hwp_set(policy->cpus);
+ intel_pstate_hwp_set_policy(policy);
return 0;
}
@@ -1248,6 +1255,7 @@ static struct cpufreq_driver intel_pstat
.flags = CPUFREQ_CONST_LOOPS,
.verify = intel_pstate_verify_policy,
.setpolicy = intel_pstate_set_policy,
+ .resume = intel_pstate_hwp_set_policy,
.get = intel_pstate_get,
.init = intel_pstate_cpu_init,
.stop_cpu = intel_pstate_stop_cpu,
Index: linux-pm/drivers/cpufreq/cpufreq.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq.c
+++ linux-pm/drivers/cpufreq/cpufreq.c
@@ -1631,21 +1631,25 @@ void cpufreq_suspend(void)
if (!cpufreq_driver)
return;
- if (!has_target())
+ if (!has_target() && !cpufreq_driver->suspend)
goto suspend;
pr_debug("%s: Suspending Governors\n", __func__);
for_each_active_policy(policy) {
- down_write(&policy->rwsem);
- ret = cpufreq_governor(policy, CPUFREQ_GOV_STOP);
- up_write(&policy->rwsem);
-
- if (ret)
- pr_err("%s: Failed to stop governor for policy: %p\n",
- __func__, policy);
- else if (cpufreq_driver->suspend
- && cpufreq_driver->suspend(policy))
+ if (has_target()) {
+ down_write(&policy->rwsem);
+ ret = cpufreq_governor(policy, CPUFREQ_GOV_STOP);
+ up_write(&policy->rwsem);
+
+ if (ret) {
+ pr_err("%s: Failed to stop governor for policy: %p\n",
+ __func__, policy);
+ continue;
+ }
+ }
+
+ if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy))
pr_err("%s: Failed to suspend driver: %p\n", __func__,
policy);
}
@@ -1670,7 +1674,7 @@ void cpufreq_resume(void)
cpufreq_suspended = false;
- if (!has_target())
+ if (!has_target() && !cpufreq_driver->resume)
return;
pr_debug("%s: Resuming Governors\n", __func__);
@@ -1679,7 +1683,7 @@ void cpufreq_resume(void)
if (cpufreq_driver->resume && cpufreq_driver->resume(policy)) {
pr_err("%s: Failed to resume driver: %p\n", __func__,
policy);
- } else {
+ } else if (has_target()) {
down_write(&policy->rwsem);
ret = cpufreq_start_governor(policy);
up_write(&policy->rwsem);
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] cpufreq: intel_pstate: Fix HWP on boot CPU after system resume
2016-05-02 0:27 [PATCH] cpufreq: intel_pstate: Fix HWP on boot CPU after system resume Rafael J. Wysocki
@ 2016-05-02 2:12 ` Viresh Kumar
0 siblings, 0 replies; 2+ messages in thread
From: Viresh Kumar @ 2016-05-02 2:12 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PM list, Srinivas Pandruvada, Linux Kernel Mailing List
On 02-05-16, 02:27, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Commit 41cfd64cf49fc "Update frequencies of policy->cpus only from
> ->set_policy()" changed the way the intel_pstate driver's ->set_policy
> callback updates the HWP (hardware-managed P-states) settings.
> A side effect of it is that if those settings are modified on the
> boot CPU during system suspend and wakeup, they will never be
> restored during subsequent system resume.
>
> To address this problem, allow cpufreq drivers that don't provide
> ->target or ->target_index callbacks to use ->suspend and ->resume
> callbacks and add a ->resume callback to intel_pstate to restore
> the HWP settings on the CPUs that belong to the given policy.
>
> Fixes: 41cfd64cf49fc "Update frequencies of policy->cpus only from ->set_policy()"
> Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>
> Note: We've tried to address that issue by adding syscore_ops to
> intel_pstate and restoring the boot CPU's HWP setting from a
> syscore resume, but that turns out to be too early (apparently,
> the processor is not ready for that at that point).
>
> ---
> drivers/cpufreq/cpufreq.c | 28 ++++++++++++++++------------
> drivers/cpufreq/intel_pstate.c | 12 ++++++++++--
> 2 files changed, 26 insertions(+), 14 deletions(-)
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-02 2:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-02 0:27 [PATCH] cpufreq: intel_pstate: Fix HWP on boot CPU after system resume Rafael J. Wysocki
2016-05-02 2:12 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox