diff mbox

[2/2] cpufreq: don't call cpufreq_update_policy() on CPU addition

Message ID 8f2fc4d6240b567fdb69a0b47f073d174b7ef9b2.1392375504.git.viresh.kumar@linaro.org
State New
Headers show

Commit Message

Viresh Kumar Feb. 14, 2014, 11 a.m. UTC
cpufreq_update_policy() is called from two places currently. From a workqueue
handled queued from cpufreq_bp_resume() for boot CPU and from
cpufreq_cpu_callback() whenever a CPU is added.

The first one makes sure that boot CPU is running on the frequency present in
policy->cpu. But we don't really need a call from cpufreq_cpu_callback(),
because we always call cpufreq_driver->init() (which will set policy->cur
correctly) whenever first CPU of any policy is added back. And so every policy
structure is guaranteed to have the right frequency in policy->cur.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Viresh Kumar Feb. 17, 2014, 5:15 a.m. UTC | #1
On 17 February 2014 05:51, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Friday, February 14, 2014 04:30:41 PM Viresh Kumar wrote:
>> cpufreq_update_policy() is called from two places currently. From a workqueue
>> handled queued from cpufreq_bp_resume() for boot CPU and from
>> cpufreq_cpu_callback() whenever a CPU is added.
>>
>> The first one makes sure that boot CPU is running on the frequency present in
>> policy->cpu. But we don't really need a call from cpufreq_cpu_callback(),
>> because we always call cpufreq_driver->init() (which will set policy->cur
>> correctly) whenever first CPU of any policy is added back. And so every policy
>> structure is guaranteed to have the right frequency in policy->cur.
>
> That sounds good, but doing the extra cpufreq_update_policy() shouldn't actually
> hurt, should it?

Yeah, it shouldn't hurt badly..

> So, that would be a cleanup rather than a fix, right?

Hmm, yeah..
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Viresh Kumar Feb. 17, 2014, 8:54 a.m. UTC | #2
On 17 February 2014 14:13, Srivatsa S. Bhat
<srivatsa.bhat@linux.vnet.ibm.com> wrote:
> On 02/14/2014 04:30 PM, Viresh Kumar wrote:
>> cpufreq_update_policy() is called from two places currently. From a workqueue
>> handled queued from cpufreq_bp_resume() for boot CPU and from
>> cpufreq_cpu_callback() whenever a CPU is added.
>>
>> The first one makes sure that boot CPU is running on the frequency present in
>> policy->cpu. But we don't really need a call from cpufreq_cpu_callback(),
>> because we always call cpufreq_driver->init() (which will set policy->cur
>> correctly) whenever first CPU of any policy is added back. And so every policy
>> structure is guaranteed to have the right frequency in policy->cur.
>>
>
> This wording is slightly inaccurate. ->init() may or may not set policy->cur
> (for example, powernowk8 driver doesn't set it in the init routine)..

Its not the wording that is wrong but this particular driver then :)
This is what Documentation/cpu-drivers.txt says:

1.2 Per-CPU Initialization
Then, the driver must fill in the following values:

policy->cur The current operating frequency of
this CPU (if appropriate)

And so it is supposed to do it.

> But we set it for sure in __cpufreq_add_dev():
>
> 1117         if (cpufreq_driver->get) {
> 1118                 policy->cur = cpufreq_driver->get(policy->cpu);
> 1119                 if (!policy->cur) {
> 1120                         pr_err("%s: ->get() failed\n", __func__);
> 1121                         goto err_get_freq;
> 1122                 }
> 1123         }

Its just about removing that from drivers and doing it once in core :)

>> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> The reasoning and the code looks good to me.
>
> Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 383362b..b6eb4ed 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2194,7 +2194,6 @@  static int cpufreq_cpu_callback(struct notifier_block *nfb,
 		switch (action & ~CPU_TASKS_FROZEN) {
 		case CPU_ONLINE:
 			__cpufreq_add_dev(dev, NULL, frozen);
-			cpufreq_update_policy(cpu);
 			break;
 
 		case CPU_DOWN_PREPARE: