cpufreq: Set same governor as a first CPU when CPU online
Jinyoung Park [Mon, 2 Sep 2013 05:50:30 +0000 (14:50 +0900)]
Set governor for a newly online CPU with same governor as a first CPU.

Bug 1354391

Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/268954
(cherry picked from commit 57de2dbf25c025834fa7fbcd1d440b9e05179ce1)

Change-Id: I104ff8f61e89667f482f262d4cc3cb5ea1a1875a
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/301039
Reviewed-by: Harry Hong <hhong@nvidia.com>
Tested-by: Harry Hong <hhong@nvidia.com>

drivers/cpufreq/cpufreq.c

index 0c1f3ac..e179bbe 100644 (file)
@@ -797,7 +797,14 @@ static int cpufreq_add_dev_policy(unsigned int cpu,
 
        gov = __find_governor(per_cpu(cpufreq_cpu_governor, cpu));
        if (gov) {
-               policy->governor = gov;
+               struct cpufreq_policy *first_cp = per_cpu(cpufreq_cpu_data,
+                                               cpumask_first(cpu_online_mask));
+               /* Set same governor as a first CPU. */
+               if (first_cp && first_cp->governor &&
+                               strcmp(first_cp->governor->name, gov->name))
+                       policy->governor = first_cp->governor;
+               else
+                       policy->governor = gov;
                pr_debug("Restoring governor %s for cpu %d\n",
                       policy->governor->name, cpu);
        }