]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/cpufreq/powernv-cpufreq.c
mm, proc: add KReclaimable to /proc/meminfo
[linux.git] / drivers / cpufreq / powernv-cpufreq.c
index 0591874856d3c8ba037537bc863c4bbbfe21e0a5..bf6519cf64bc2e040b6e004f1771e47e5691c7e0 100644 (file)
@@ -679,6 +679,16 @@ void gpstate_timer_handler(struct timer_list *t)
 
        if (!spin_trylock(&gpstates->gpstate_lock))
                return;
+       /*
+        * If the timer has migrated to the different cpu then bring
+        * it back to one of the policy->cpus
+        */
+       if (!cpumask_test_cpu(raw_smp_processor_id(), policy->cpus)) {
+               gpstates->timer.expires = jiffies + msecs_to_jiffies(1);
+               add_timer_on(&gpstates->timer, cpumask_first(policy->cpus));
+               spin_unlock(&gpstates->gpstate_lock);
+               return;
+       }
 
        /*
         * If PMCR was last updated was using fast_swtich then
@@ -718,10 +728,8 @@ void gpstate_timer_handler(struct timer_list *t)
        if (gpstate_idx != gpstates->last_lpstate_idx)
                queue_gpstate_timer(gpstates);
 
+       set_pstate(&freq_data);
        spin_unlock(&gpstates->gpstate_lock);
-
-       /* Timer may get migrated to a different cpu on cpu hot unplug */
-       smp_call_function_any(policy->cpus, set_pstate, &freq_data, 1);
 }
 
 /*
@@ -750,8 +758,13 @@ static int powernv_cpufreq_target_index(struct cpufreq_policy *policy,
 
        cur_msec = jiffies_to_msecs(get_jiffies_64());
 
-       spin_lock(&gpstates->gpstate_lock);
        freq_data.pstate_id = idx_to_pstate(new_index);
+       if (!gpstates) {
+               freq_data.gpstate_id = freq_data.pstate_id;
+               goto no_gpstate;
+       }
+
+       spin_lock(&gpstates->gpstate_lock);
 
        if (!gpstates->last_sampled_time) {
                gpstate_idx = new_index;
@@ -801,6 +814,7 @@ static int powernv_cpufreq_target_index(struct cpufreq_policy *policy,
 
        spin_unlock(&gpstates->gpstate_lock);
 
+no_gpstate:
        /*
         * Use smp_call_function to send IPI and execute the
         * mtspr on target CPU.  We could do that without IPI
@@ -835,6 +849,13 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
                kernfs_put(kn);
        }
 
+       policy->freq_table = powernv_freqs;
+       policy->fast_switch_possible = true;
+
+       if (pvr_version_is(PVR_POWER9))
+               return 0;
+
+       /* Initialise Gpstate ramp-down timer only on POWER8 */
        gpstates =  kzalloc(sizeof(*gpstates), GFP_KERNEL);
        if (!gpstates)
                return -ENOMEM;
@@ -849,8 +870,6 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
                                msecs_to_jiffies(GPSTATE_TIMER_INTERVAL);
        spin_lock_init(&gpstates->gpstate_lock);
 
-       policy->freq_table = powernv_freqs;
-       policy->fast_switch_possible = true;
        return 0;
 }
 
@@ -990,7 +1009,8 @@ static void powernv_cpufreq_stop_cpu(struct cpufreq_policy *policy)
        freq_data.pstate_id = idx_to_pstate(powernv_pstate_info.min);
        freq_data.gpstate_id = idx_to_pstate(powernv_pstate_info.min);
        smp_call_function_single(policy->cpu, set_pstate, &freq_data, 1);
-       del_timer_sync(&gpstates->timer);
+       if (gpstates)
+               del_timer_sync(&gpstates->timer);
 }
 
 static unsigned int powernv_fast_switch(struct cpufreq_policy *policy,