Skip to content

Commit dfeeedc

Browse files
committed
cpufreq: intel_pstate: Update cpuinfo.max_freq on HWP_CAP changes
With HWP enabled, when the turbo range of performance levels is disabled by the platform firmware, the CPU capacity is given by the "guaranteed performance" field in MSR_HWP_CAPABILITIES which is generally dynamic. When it changes, the kernel receives an HWP notification interrupt handled by notify_hwp_interrupt(). When the "guaranteed performance" value changes in the above configuration, the CPU performance scaling needs to be adjusted so as to use the new CPU capacity in computations, which means that the cpuinfo.max_freq value needs to be updated for that CPU. Accordingly, modify intel_pstate_notify_work() to read MSR_HWP_CAPABILITIES and update cpuinfo.max_freq to reflect the new configuration (this update can be carried out even if the configuration doesn't actually change, because it simply doesn't matter then and it takes less time to update it than to do extra checks to decide whether or not a change has really occurred). Reported-by: Srinivas Pandruvada <[email protected]> Tested-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 521223d commit dfeeedc

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,19 +1134,22 @@ static void intel_pstate_update_policies(void)
11341134
cpufreq_update_policy(cpu);
11351135
}
11361136

1137+
static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
1138+
struct cpufreq_policy *policy)
1139+
{
1140+
policy->cpuinfo.max_freq = global.turbo_disabled_mf ?
1141+
cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
1142+
refresh_frequency_limits(policy);
1143+
}
1144+
11371145
static void intel_pstate_update_max_freq(unsigned int cpu)
11381146
{
11391147
struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);
1140-
struct cpudata *cpudata;
11411148

11421149
if (!policy)
11431150
return;
11441151

1145-
cpudata = all_cpu_data[cpu];
1146-
policy->cpuinfo.max_freq = global.turbo_disabled_mf ?
1147-
cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
1148-
1149-
refresh_frequency_limits(policy);
1152+
__intel_pstate_update_max_freq(all_cpu_data[cpu], policy);
11501153

11511154
cpufreq_cpu_release(policy);
11521155
}
@@ -1594,8 +1597,15 @@ static void intel_pstate_notify_work(struct work_struct *work)
15941597
{
15951598
struct cpudata *cpudata =
15961599
container_of(to_delayed_work(work), struct cpudata, hwp_notify_work);
1600+
struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpudata->cpu);
1601+
1602+
if (policy) {
1603+
intel_pstate_get_hwp_cap(cpudata);
1604+
__intel_pstate_update_max_freq(cpudata, policy);
1605+
1606+
cpufreq_cpu_release(policy);
1607+
}
15971608

1598-
cpufreq_update_policy(cpudata->cpu);
15991609
wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_STATUS, 0);
16001610
}
16011611

0 commit comments

Comments
 (0)