Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'pm-4.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
"These fix a few more intel_pstate issues and one small issue in the
cpufreq core.

Specifics:

- Fix breakage in the intel_pstate's debugfs interface for PID
controller tuning (Rafael Wysocki)

- Fix computations related to P-state limits in intel_pstate to avoid
excessive rounding errors leading to visible inaccuracies (Srinivas
Pandruvada, Rafael Wysocki)

- Add a missing newline to a message printed by one function in the
cpufreq core and clean up that function (Rafael Wysocki)"

* tag 'pm-4.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
cpufreq: Fix and clean up show_cpuinfo_cur_freq()
cpufreq: intel_pstate: Avoid percentages in limits-related computations
cpufreq: intel_pstate: Correct frequency setting in the HWP mode
cpufreq: intel_pstate: Update pid_params.sample_rate_ns in pid_param_set()

+36 -36
+5 -3
drivers/cpufreq/cpufreq.c
··· 680 680 char *buf) 681 681 { 682 682 unsigned int cur_freq = __cpufreq_get(policy); 683 - if (!cur_freq) 684 - return sprintf(buf, "<unknown>"); 685 - return sprintf(buf, "%u\n", cur_freq); 683 + 684 + if (cur_freq) 685 + return sprintf(buf, "%u\n", cur_freq); 686 + 687 + return sprintf(buf, "<unknown>\n"); 686 688 } 687 689 688 690 /**
+31 -33
drivers/cpufreq/intel_pstate.c
··· 84 84 return div64_u64(x << EXT_FRAC_BITS, y); 85 85 } 86 86 87 + static inline int32_t percent_ext_fp(int percent) 88 + { 89 + return div_ext_fp(percent, 100); 90 + } 91 + 87 92 /** 88 93 * struct sample - Store performance sample 89 94 * @core_avg_perf: Ratio of APERF/MPERF which is the actual average ··· 850 845 851 846 static void intel_pstate_hwp_set(struct cpufreq_policy *policy) 852 847 { 853 - int min, hw_min, max, hw_max, cpu, range, adj_range; 848 + int min, hw_min, max, hw_max, cpu; 854 849 struct perf_limits *perf_limits = limits; 855 850 u64 value, cap; 856 851 857 852 for_each_cpu(cpu, policy->cpus) { 858 - int max_perf_pct, min_perf_pct; 859 853 struct cpudata *cpu_data = all_cpu_data[cpu]; 860 854 s16 epp; 861 855 ··· 867 863 hw_max = HWP_GUARANTEED_PERF(cap); 868 864 else 869 865 hw_max = HWP_HIGHEST_PERF(cap); 870 - range = hw_max - hw_min; 871 866 872 - max_perf_pct = perf_limits->max_perf_pct; 873 - min_perf_pct = perf_limits->min_perf_pct; 867 + min = fp_ext_toint(hw_max * perf_limits->min_perf); 874 868 875 869 rdmsrl_on_cpu(cpu, MSR_HWP_REQUEST, &value); 876 - adj_range = min_perf_pct * range / 100; 877 - min = hw_min + adj_range; 870 + 878 871 value &= ~HWP_MIN_PERF(~0L); 879 872 value |= HWP_MIN_PERF(min); 880 873 881 - adj_range = max_perf_pct * range / 100; 882 - max = hw_min + adj_range; 883 - 874 + max = fp_ext_toint(hw_max * perf_limits->max_perf); 884 875 value &= ~HWP_MAX_PERF(~0L); 885 876 value |= HWP_MAX_PERF(max); 886 877 ··· 988 989 static int pid_param_set(void *data, u64 val) 989 990 { 990 991 *(u32 *)data = val; 992 + pid_params.sample_rate_ns = pid_params.sample_rate_ms * NSEC_PER_MSEC; 991 993 intel_pstate_reset_all_pid(); 992 994 return 0; 993 995 } ··· 1225 1225 limits->max_perf_pct); 1226 1226 limits->max_perf_pct = max(limits->min_perf_pct, 1227 1227 limits->max_perf_pct); 1228 - limits->max_perf = div_ext_fp(limits->max_perf_pct, 100); 1228 + limits->max_perf = percent_ext_fp(limits->max_perf_pct); 1229 1229 1230 1230 intel_pstate_update_policies(); 1231 1231 ··· 1262 1262 limits->min_perf_pct); 1263 1263 limits->min_perf_pct = min(limits->max_perf_pct, 1264 1264 limits->min_perf_pct); 1265 - limits->min_perf = div_ext_fp(limits->min_perf_pct, 100); 1265 + limits->min_perf = percent_ext_fp(limits->min_perf_pct); 1266 1266 1267 1267 intel_pstate_update_policies(); 1268 1268 ··· 2080 2080 static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy, 2081 2081 struct perf_limits *limits) 2082 2082 { 2083 + int32_t max_policy_perf, min_policy_perf; 2083 2084 2084 - limits->max_policy_pct = DIV_ROUND_UP(policy->max * 100, 2085 - policy->cpuinfo.max_freq); 2086 - limits->max_policy_pct = clamp_t(int, limits->max_policy_pct, 0, 100); 2085 + max_policy_perf = div_ext_fp(policy->max, policy->cpuinfo.max_freq); 2086 + max_policy_perf = clamp_t(int32_t, max_policy_perf, 0, int_ext_tofp(1)); 2087 2087 if (policy->max == policy->min) { 2088 - limits->min_policy_pct = limits->max_policy_pct; 2088 + min_policy_perf = max_policy_perf; 2089 2089 } else { 2090 - limits->min_policy_pct = DIV_ROUND_UP(policy->min * 100, 2091 - policy->cpuinfo.max_freq); 2092 - limits->min_policy_pct = clamp_t(int, limits->min_policy_pct, 2093 - 0, 100); 2090 + min_policy_perf = div_ext_fp(policy->min, 2091 + policy->cpuinfo.max_freq); 2092 + min_policy_perf = clamp_t(int32_t, min_policy_perf, 2093 + 0, max_policy_perf); 2094 2094 } 2095 2095 2096 - /* Normalize user input to [min_policy_pct, max_policy_pct] */ 2097 - limits->min_perf_pct = max(limits->min_policy_pct, 2098 - limits->min_sysfs_pct); 2099 - limits->min_perf_pct = min(limits->max_policy_pct, 2100 - limits->min_perf_pct); 2101 - limits->max_perf_pct = min(limits->max_policy_pct, 2102 - limits->max_sysfs_pct); 2103 - limits->max_perf_pct = max(limits->min_policy_pct, 2104 - limits->max_perf_pct); 2096 + /* Normalize user input to [min_perf, max_perf] */ 2097 + limits->min_perf = max(min_policy_perf, 2098 + percent_ext_fp(limits->min_sysfs_pct)); 2099 + limits->min_perf = min(limits->min_perf, max_policy_perf); 2100 + limits->max_perf = min(max_policy_perf, 2101 + percent_ext_fp(limits->max_sysfs_pct)); 2102 + limits->max_perf = max(min_policy_perf, limits->max_perf); 2105 2103 2106 - /* Make sure min_perf_pct <= max_perf_pct */ 2107 - limits->min_perf_pct = min(limits->max_perf_pct, limits->min_perf_pct); 2104 + /* Make sure min_perf <= max_perf */ 2105 + limits->min_perf = min(limits->min_perf, limits->max_perf); 2108 2106 2109 - limits->min_perf = div_ext_fp(limits->min_perf_pct, 100); 2110 - limits->max_perf = div_ext_fp(limits->max_perf_pct, 100); 2111 2107 limits->max_perf = round_up(limits->max_perf, EXT_FRAC_BITS); 2112 2108 limits->min_perf = round_up(limits->min_perf, EXT_FRAC_BITS); 2109 + limits->max_perf_pct = fp_ext_toint(limits->max_perf * 100); 2110 + limits->min_perf_pct = fp_ext_toint(limits->min_perf * 100); 2113 2111 2114 2112 pr_debug("cpu:%d max_perf_pct:%d min_perf_pct:%d\n", policy->cpu, 2115 2113 limits->max_perf_pct, limits->min_perf_pct);