cpufreq: powernv: Adding fast_switch for schedutil
authorAkshay Adiga <akshay.adiga@linux.vnet.ibm.com>
Tue, 8 Nov 2016 13:33:27 +0000 (19:03 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 11 Nov 2016 00:41:02 +0000 (01:41 +0100)
Adding fast_switch which does light weight operation to set the desired
pstate. Both global and local pstates are set to the same desired pstate.

Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/powernv-cpufreq.c

index d3ffde8066298ff48d64c990eefe1dec0bf34cb6..4a4380d728ad347760e59e4f2007dedc5d5299a4 100644 (file)
@@ -752,9 +752,12 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
        spin_lock_init(&gpstates->gpstate_lock);
        ret = cpufreq_table_validate_and_show(policy, powernv_freqs);
 
-       if (ret < 0)
+       if (ret < 0) {
                kfree(policy->driver_data);
+               return ret;
+       }
 
+       policy->fast_switch_possible = true;
        return ret;
 }
 
@@ -897,6 +900,20 @@ static void powernv_cpufreq_stop_cpu(struct cpufreq_policy *policy)
        del_timer_sync(&gpstates->timer);
 }
 
+static unsigned int powernv_fast_switch(struct cpufreq_policy *policy,
+                                       unsigned int target_freq)
+{
+       int index;
+       struct powernv_smp_call_data freq_data;
+
+       index = cpufreq_table_find_index_dl(policy, target_freq);
+       freq_data.pstate_id = powernv_freqs[index].driver_data;
+       freq_data.gpstate_id = powernv_freqs[index].driver_data;
+       set_pstate(&freq_data);
+
+       return powernv_freqs[index].frequency;
+}
+
 static struct cpufreq_driver powernv_cpufreq_driver = {
        .name           = "powernv-cpufreq",
        .flags          = CPUFREQ_CONST_LOOPS,
@@ -904,6 +921,7 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
        .exit           = powernv_cpufreq_cpu_exit,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = powernv_cpufreq_target_index,
+       .fast_switch    = powernv_fast_switch,
        .get            = powernv_cpufreq_get,
        .stop_cpu       = powernv_cpufreq_stop_cpu,
        .attr           = powernv_cpu_freq_attr,