cpufreq: arm_big_little: Don't destroy/create freq table/clk for every cpu on/off
authorViresh Kumar <viresh.kumar@linaro.org>
Fri, 14 Dec 2012 02:34:07 +0000 (08:04 +0530)
committerJon Medhurst <tixy@linaro.org>
Fri, 19 Jul 2013 12:43:15 +0000 (13:43 +0100)
When a cpu goes down, exit would be called for it. Similarly for every cpu up
init would be called. This would result in same freq table and clk structure to
get freed/allocated again. There is no way for freq table/clk structures to
change between these calls.

Also, when we disable switcher, firstly cpufreq unregister would be called and
hence exit for all cpus and then register would be called, i.e. init would be
called.

For saving time/energy for both cases, lets not free table/clk until module exit
is not done.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/cpufreq/arm_big_little.c

index fe8d0bbc399ae47c8945c4f4f452c1a43bcb56a0..f106106f78ccf9c52690f634f4cde40caa5444ac 100644 (file)
@@ -469,23 +469,6 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy)
        return 0;
 }
 
-static int bL_cpufreq_exit(struct cpufreq_policy *policy)
-{
-       struct device *cpu_dev;
-
-       cpu_dev = get_cpu_device(policy->cpu);
-       if (!cpu_dev) {
-               pr_err("%s: failed to get cpu%d device\n", __func__,
-                               policy->cpu);
-               return -ENODEV;
-       }
-
-       put_cluster_clk_and_freq_table(cpu_dev);
-       dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu);
-
-       return 0;
-}
-
 /* Export freq_table to sysfs */
 static struct freq_attr *bL_cpufreq_attr[] = {
        &cpufreq_freq_attr_scaling_available_freqs,
@@ -499,7 +482,6 @@ static struct cpufreq_driver bL_cpufreq_driver = {
        .target                 = bL_cpufreq_set_target,
        .get                    = bL_cpufreq_get_rate,
        .init                   = bL_cpufreq_init,
-       .exit                   = bL_cpufreq_exit,
        .have_governor_per_policy = true,
        .attr                   = bL_cpufreq_attr,
 };
@@ -594,6 +576,25 @@ void bL_cpufreq_unregister(struct cpufreq_arm_bL_ops *ops)
        bL_switcher_put_enabled();
        pr_info("%s: Un-registered platform driver: %s\n", __func__,
                        arm_bL_ops->name);
+
+       /* For saving table get/put on every cpu in/out */
+       if (is_bL_switching_enabled()) {
+               put_cluster_clk_and_freq_table(get_cpu_device(0));
+       } else {
+               int i;
+
+               for (i = 0; i < MAX_CLUSTERS; i++) {
+                       struct device *cdev = get_cpu_device(i);
+                       if (!cdev) {
+                               pr_err("%s: failed to get cpu%d device\n",
+                                               __func__, i);
+                               return;
+                       }
+
+                       put_cluster_clk_and_freq_table(cdev);
+               }
+       }
+
        arm_bL_ops = NULL;
 }
 EXPORT_SYMBOL_GPL(bL_cpufreq_unregister);