aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2017-03-13 21:30:12 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-03-13 22:56:39 -0400
commit3f8ed54aee491bbb83656592c2d0ad7b78d045ca (patch)
tree68f3a0b4f92f8e740b4d62766f6c6fc0b04132ab
parent6e7408acd04d06c04981c0c0fb5a2462b16fae4f (diff)
cpufreq: intel_pstate: Correct frequency setting in the HWP mode
In the functions intel_pstate_hwp_set(), min/max range from HWP capability MSR along with max_perf_pct and min_perf_pct, is used to set the HWP request MSR. In some cases this doesn't result in the correct HWP max/min in HWP request. For example: In the following case: HWP capabilities from MSR 0x771 0x70a1220 Here cpufreq min/max frequencies from above MSR dump are 700MHz and 3.2GHz respectively. This will result in hwp_min = 0x07 hwp_max = 0x20 To limit max frequency to 2GHz: perf_limits->max_perf_pct = 63 (2GHz as a percent of 3.2GHz rounded up) With the current calculation: adj_range = max_perf_pct * range / 100; adj_range = 63 * (32 - 7) / 100 adj_range = 15 max = hw_min + adj_range; max = 7 + 15 = 22 This will result in HWP request of 0x160f, which will result in a frequency cap of 2.2GHz not 2GHz. The problem with the above calculation is that hwp_min of 7 is treated as 0% in the range. But max_perf_pct is calculated with respect to minimum as 0 and max as 3.2GHz or hwp_max, so adding hwp_min to it will result in more than the desired. Since the min_perf_pct and max_perf_pct is already a percent of max frequency or hwp_max, this min/max HWP request value can be calculated directly applying these percentage to hwp_max. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/cpufreq/intel_pstate.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index f9fe910f3b83..ee12641ee010 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -845,7 +845,7 @@ static struct freq_attr *hwp_cpufreq_attrs[] = {
845 845
846static void intel_pstate_hwp_set(struct cpufreq_policy *policy) 846static void intel_pstate_hwp_set(struct cpufreq_policy *policy)
847{ 847{
848 int min, hw_min, max, hw_max, cpu, range, adj_range; 848 int min, hw_min, max, hw_max, cpu;
849 struct perf_limits *perf_limits = limits; 849 struct perf_limits *perf_limits = limits;
850 u64 value, cap; 850 u64 value, cap;
851 851
@@ -863,20 +863,17 @@ static void intel_pstate_hwp_set(struct cpufreq_policy *policy)
863 hw_max = HWP_GUARANTEED_PERF(cap); 863 hw_max = HWP_GUARANTEED_PERF(cap);
864 else 864 else
865 hw_max = HWP_HIGHEST_PERF(cap); 865 hw_max = HWP_HIGHEST_PERF(cap);
866 range = hw_max - hw_min;
867 866
868 max_perf_pct = perf_limits->max_perf_pct; 867 max_perf_pct = perf_limits->max_perf_pct;
869 min_perf_pct = perf_limits->min_perf_pct; 868 min_perf_pct = perf_limits->min_perf_pct;
869 min = hw_max * min_perf_pct / 100;
870 870
871 rdmsrl_on_cpu(cpu, MSR_HWP_REQUEST, &value); 871 rdmsrl_on_cpu(cpu, MSR_HWP_REQUEST, &value);
872 adj_range = min_perf_pct * range / 100; 872
873 min = hw_min + adj_range;
874 value &= ~HWP_MIN_PERF(~0L); 873 value &= ~HWP_MIN_PERF(~0L);
875 value |= HWP_MIN_PERF(min); 874 value |= HWP_MIN_PERF(min);
876 875
877 adj_range = max_perf_pct * range / 100; 876 max = hw_max * max_perf_pct / 100;
878 max = hw_min + adj_range;
879
880 value &= ~HWP_MAX_PERF(~0L); 877 value &= ~HWP_MAX_PERF(~0L);
881 value |= HWP_MAX_PERF(max); 878 value |= HWP_MAX_PERF(max);
882 879