cpufreq: Fix serialization of frequency transitions
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 2 Jul 2013 11:06:28 +0000 (16:36 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 4 Jul 2013 11:12:44 +0000 (13:12 +0200)
Commit 7c30ed ("cpufreq: make sure frequency transitions are serialized")
interacts poorly with systems that have a single core freqency for all
cores.  On such systems we have a single policy for all cores with
several CPUs.  When we do a frequency transition the governor calls the
pre and post change notifiers which causes cpufreq_notify_transition()
per CPU.  Since the policy is the same for all of them all CPUs after
the first and the warnings added are generated by checking a per-policy
flag the warnings will be triggered for all cores after the first.

Fix this by allowing notifier to be called for n times. Where n is the number of
cpus in policy->cpus.

Reported-and-tested-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c
include/linux/cpufreq.h

index 6a015ada5285720389d1191a210d541f41b429fe..0937b8d6c2a4cebe904bbc9c5cdbf24afd2a681f 100644 (file)
@@ -312,11 +312,12 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy,
        switch (state) {
 
        case CPUFREQ_PRECHANGE:
-               if (WARN(policy->transition_ongoing,
+               if (WARN(policy->transition_ongoing ==
+                                       cpumask_weight(policy->cpus),
                                "In middle of another frequency transition\n"))
                        return;
 
-               policy->transition_ongoing = true;
+               policy->transition_ongoing++;
 
                /* detect if the driver reported a value as "old frequency"
                 * which is not equal to what the cpufreq core thinks is
@@ -341,7 +342,7 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy,
                                "No frequency transition in progress\n"))
                        return;
 
-               policy->transition_ongoing = false;
+               policy->transition_ongoing--;
 
                adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
                pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new,
index 4d7390bc172731a88ebbc28d7bd9f76ac3713794..90d5a15120d592eedeff5de22cd33fe61fe98351 100644 (file)
@@ -119,7 +119,7 @@ struct cpufreq_policy {
 
        struct kobject          kobj;
        struct completion       kobj_unregister;
-       bool                    transition_ongoing; /* Tracks transition status */
+       int                     transition_ongoing; /* Tracks transition status */
 };
 
 #define CPUFREQ_ADJUST                 (0)
This page took 0.029538 seconds and 5 git commands to generate.