提交 8b766e05 编写于 作者: R Rafael J. Wysocki

Merge branches 'pm-cpufreq-fixes' and 'intel_pstate-fixes'

* pm-cpufreq-fixes:
  cpufreq: Fix and clean up show_cpuinfo_cur_freq()

* intel_pstate-fixes:
  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()
...@@ -84,6 +84,11 @@ static inline u64 div_ext_fp(u64 x, u64 y) ...@@ -84,6 +84,11 @@ static inline u64 div_ext_fp(u64 x, u64 y)
return div64_u64(x << EXT_FRAC_BITS, y); return div64_u64(x << EXT_FRAC_BITS, y);
} }
static inline int32_t percent_ext_fp(int percent)
{
return div_ext_fp(percent, 100);
}
/** /**
* struct sample - Store performance sample * struct sample - Store performance sample
* @core_avg_perf: Ratio of APERF/MPERF which is the actual average * @core_avg_perf: Ratio of APERF/MPERF which is the actual average
...@@ -845,12 +850,11 @@ static struct freq_attr *hwp_cpufreq_attrs[] = { ...@@ -845,12 +850,11 @@ static struct freq_attr *hwp_cpufreq_attrs[] = {
static void intel_pstate_hwp_set(struct cpufreq_policy *policy) static void intel_pstate_hwp_set(struct cpufreq_policy *policy)
{ {
int min, hw_min, max, hw_max, cpu, range, adj_range; int min, hw_min, max, hw_max, cpu;
struct perf_limits *perf_limits = limits; struct perf_limits *perf_limits = limits;
u64 value, cap; u64 value, cap;
for_each_cpu(cpu, policy->cpus) { for_each_cpu(cpu, policy->cpus) {
int max_perf_pct, min_perf_pct;
struct cpudata *cpu_data = all_cpu_data[cpu]; struct cpudata *cpu_data = all_cpu_data[cpu];
s16 epp; s16 epp;
...@@ -863,20 +867,15 @@ static void intel_pstate_hwp_set(struct cpufreq_policy *policy) ...@@ -863,20 +867,15 @@ static void intel_pstate_hwp_set(struct cpufreq_policy *policy)
hw_max = HWP_GUARANTEED_PERF(cap); hw_max = HWP_GUARANTEED_PERF(cap);
else else
hw_max = HWP_HIGHEST_PERF(cap); hw_max = HWP_HIGHEST_PERF(cap);
range = hw_max - hw_min;
max_perf_pct = perf_limits->max_perf_pct; min = fp_ext_toint(hw_max * perf_limits->min_perf);
min_perf_pct = perf_limits->min_perf_pct;
rdmsrl_on_cpu(cpu, MSR_HWP_REQUEST, &value); rdmsrl_on_cpu(cpu, MSR_HWP_REQUEST, &value);
adj_range = min_perf_pct * range / 100;
min = hw_min + adj_range;
value &= ~HWP_MIN_PERF(~0L); value &= ~HWP_MIN_PERF(~0L);
value |= HWP_MIN_PERF(min); value |= HWP_MIN_PERF(min);
adj_range = max_perf_pct * range / 100; max = fp_ext_toint(hw_max * perf_limits->max_perf);
max = hw_min + adj_range;
value &= ~HWP_MAX_PERF(~0L); value &= ~HWP_MAX_PERF(~0L);
value |= HWP_MAX_PERF(max); value |= HWP_MAX_PERF(max);
...@@ -989,6 +988,7 @@ static void intel_pstate_update_policies(void) ...@@ -989,6 +988,7 @@ static void intel_pstate_update_policies(void)
static int pid_param_set(void *data, u64 val) static int pid_param_set(void *data, u64 val)
{ {
*(u32 *)data = val; *(u32 *)data = val;
pid_params.sample_rate_ns = pid_params.sample_rate_ms * NSEC_PER_MSEC;
intel_pstate_reset_all_pid(); intel_pstate_reset_all_pid();
return 0; return 0;
} }
...@@ -1225,7 +1225,7 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b, ...@@ -1225,7 +1225,7 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
limits->max_perf_pct); limits->max_perf_pct);
limits->max_perf_pct = max(limits->min_perf_pct, limits->max_perf_pct = max(limits->min_perf_pct,
limits->max_perf_pct); limits->max_perf_pct);
limits->max_perf = div_ext_fp(limits->max_perf_pct, 100); limits->max_perf = percent_ext_fp(limits->max_perf_pct);
intel_pstate_update_policies(); intel_pstate_update_policies();
...@@ -1262,7 +1262,7 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b, ...@@ -1262,7 +1262,7 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
limits->min_perf_pct); limits->min_perf_pct);
limits->min_perf_pct = min(limits->max_perf_pct, limits->min_perf_pct = min(limits->max_perf_pct,
limits->min_perf_pct); limits->min_perf_pct);
limits->min_perf = div_ext_fp(limits->min_perf_pct, 100); limits->min_perf = percent_ext_fp(limits->min_perf_pct);
intel_pstate_update_policies(); intel_pstate_update_policies();
...@@ -2080,36 +2080,34 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu) ...@@ -2080,36 +2080,34 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu)
static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy, static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy,
struct perf_limits *limits) struct perf_limits *limits)
{ {
int32_t max_policy_perf, min_policy_perf;
limits->max_policy_pct = DIV_ROUND_UP(policy->max * 100, max_policy_perf = div_ext_fp(policy->max, policy->cpuinfo.max_freq);
policy->cpuinfo.max_freq); max_policy_perf = clamp_t(int32_t, max_policy_perf, 0, int_ext_tofp(1));
limits->max_policy_pct = clamp_t(int, limits->max_policy_pct, 0, 100);
if (policy->max == policy->min) { if (policy->max == policy->min) {
limits->min_policy_pct = limits->max_policy_pct; min_policy_perf = max_policy_perf;
} else { } else {
limits->min_policy_pct = DIV_ROUND_UP(policy->min * 100, min_policy_perf = div_ext_fp(policy->min,
policy->cpuinfo.max_freq); policy->cpuinfo.max_freq);
limits->min_policy_pct = clamp_t(int, limits->min_policy_pct, min_policy_perf = clamp_t(int32_t, min_policy_perf,
0, 100); 0, max_policy_perf);
} }
/* Normalize user input to [min_policy_pct, max_policy_pct] */ /* Normalize user input to [min_perf, max_perf] */
limits->min_perf_pct = max(limits->min_policy_pct, limits->min_perf = max(min_policy_perf,
limits->min_sysfs_pct); percent_ext_fp(limits->min_sysfs_pct));
limits->min_perf_pct = min(limits->max_policy_pct, limits->min_perf = min(limits->min_perf, max_policy_perf);
limits->min_perf_pct); limits->max_perf = min(max_policy_perf,
limits->max_perf_pct = min(limits->max_policy_pct, percent_ext_fp(limits->max_sysfs_pct));
limits->max_sysfs_pct); limits->max_perf = max(min_policy_perf, limits->max_perf);
limits->max_perf_pct = max(limits->min_policy_pct,
limits->max_perf_pct);
/* Make sure min_perf_pct <= max_perf_pct */ /* Make sure min_perf <= max_perf */
limits->min_perf_pct = min(limits->max_perf_pct, limits->min_perf_pct); limits->min_perf = min(limits->min_perf, limits->max_perf);
limits->min_perf = div_ext_fp(limits->min_perf_pct, 100);
limits->max_perf = div_ext_fp(limits->max_perf_pct, 100);
limits->max_perf = round_up(limits->max_perf, EXT_FRAC_BITS); limits->max_perf = round_up(limits->max_perf, EXT_FRAC_BITS);
limits->min_perf = round_up(limits->min_perf, EXT_FRAC_BITS); limits->min_perf = round_up(limits->min_perf, EXT_FRAC_BITS);
limits->max_perf_pct = fp_ext_toint(limits->max_perf * 100);
limits->min_perf_pct = fp_ext_toint(limits->min_perf * 100);
pr_debug("cpu:%d max_perf_pct:%d min_perf_pct:%d\n", policy->cpu, pr_debug("cpu:%d max_perf_pct:%d min_perf_pct:%d\n", policy->cpu,
limits->max_perf_pct, limits->min_perf_pct); limits->max_perf_pct, limits->min_perf_pct);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册