diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2013-04-09 18:38:18 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-04-10 07:42:45 -0400 |
commit | d1b6848590af407c5d2354929ac683052d631830 (patch) | |
tree | 482ffe294513d0c6856a419f1f7cba786ea79c34 | |
parent | 49ded525d4486dc97fc965858bf3ddf245463670 (diff) |
cpufreq / intel_pstate: Optimize intel_pstate_set_policy
This function is called quite often from other subsystems.
Removed unused call to intel_pstate_get_min_max().
Also when "policy->policy == CPUFREQ_POLICY_PERFORMANCE", then
no need to do calculations as the limits will be forced anyway.
Also corrected filename in the header.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index ad72922919ed..fb382427b059 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * cpufreq_snb.c: Native P state management for Intel processors | 2 | * intel_pstate.c: Native P state management for Intel processors |
3 | * | 3 | * |
4 | * (C) Copyright 2012 Intel Corporation | 4 | * (C) Copyright 2012 Intel Corporation |
5 | * Author: Dirk Brandewie <dirk.j.brandewie@intel.com> | 5 | * Author: Dirk Brandewie <dirk.j.brandewie@intel.com> |
@@ -658,30 +658,27 @@ static unsigned int intel_pstate_get(unsigned int cpu_num) | |||
658 | static int intel_pstate_set_policy(struct cpufreq_policy *policy) | 658 | static int intel_pstate_set_policy(struct cpufreq_policy *policy) |
659 | { | 659 | { |
660 | struct cpudata *cpu; | 660 | struct cpudata *cpu; |
661 | int min, max; | ||
662 | 661 | ||
663 | cpu = all_cpu_data[policy->cpu]; | 662 | cpu = all_cpu_data[policy->cpu]; |
664 | 663 | ||
665 | if (!policy->cpuinfo.max_freq) | 664 | if (!policy->cpuinfo.max_freq) |
666 | return -ENODEV; | 665 | return -ENODEV; |
667 | 666 | ||
668 | intel_pstate_get_min_max(cpu, &min, &max); | ||
669 | |||
670 | limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; | ||
671 | limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); | ||
672 | limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); | ||
673 | |||
674 | limits.max_perf_pct = policy->max * 100 / policy->cpuinfo.max_freq; | ||
675 | limits.max_perf_pct = clamp_t(int, limits.max_perf_pct, 0 , 100); | ||
676 | limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); | ||
677 | |||
678 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { | 667 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { |
679 | limits.min_perf_pct = 100; | 668 | limits.min_perf_pct = 100; |
680 | limits.min_perf = int_tofp(1); | 669 | limits.min_perf = int_tofp(1); |
681 | limits.max_perf_pct = 100; | 670 | limits.max_perf_pct = 100; |
682 | limits.max_perf = int_tofp(1); | 671 | limits.max_perf = int_tofp(1); |
683 | limits.no_turbo = 0; | 672 | limits.no_turbo = 0; |
673 | return 0; | ||
684 | } | 674 | } |
675 | limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; | ||
676 | limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); | ||
677 | limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); | ||
678 | |||
679 | limits.max_perf_pct = policy->max * 100 / policy->cpuinfo.max_freq; | ||
680 | limits.max_perf_pct = clamp_t(int, limits.max_perf_pct, 0 , 100); | ||
681 | limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); | ||
685 | 682 | ||
686 | return 0; | 683 | return 0; |
687 | } | 684 | } |