Skip to content

Commit 96e3212

Browse files
rafaeljwgregkh
authored andcommitted
cpufreq: intel_pstate: Avoid missing HWP max updates in passive mode
commit e0be38e upstream. If the cpufreq policy max limit is changed when intel_pstate operates in the passive mode with HWP enabled and the "powersave" governor is used on top of it, the HWP max limit is not updated as appropriate. Namely, in the "powersave" governor case, the target P-state is always equal to the policy min limit, so if the latter does not change, intel_cpufreq_adjust_hwp() is not invoked to update the HWP Request MSR due to the "target_pstate != old_pstate" check in intel_cpufreq_update_pstate(), so the HWP max limit is not updated as a result. Also, if the CPUFREQ_NEED_UPDATE_LIMITS flag is not set for the driver and the target frequency does not change along with the policy max limit, the "target_freq == policy->cur" check in __cpufreq_driver_target() prevents the driver's ->target() callback from being invoked at all, so the HWP max limit is not updated. To prevent that occurring, set the CPUFREQ_NEED_UPDATE_LIMITS flag in the intel_cpufreq driver structure if HWP is enabled and modify intel_cpufreq_update_pstate() to do the "target_pstate != old_pstate" check only in the non-HWP case and let intel_cpufreq_adjust_hwp() always run in the HWP case (it will update HWP Request only if the cached value of the register is different from the new one including the limits, so if neither the target P-state value nor the max limit changes, the register write will still be avoided). Fixes: f6ebbcf ("cpufreq: intel_pstate: Implement passive mode with HWP enabled") Reported-by: Zhang Rui <rui.zhang@intel.com> Cc: 5.9+ <stable@vger.kernel.org> # 5.9+: 1c53435 cpufreq: Introduce CPUFREQ_NEED_UPDATE_LIMITS ... Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Tested-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent db6e432 commit 96e3212

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

drivers/cpufreq/intel_pstate.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,14 +2550,12 @@ static int intel_cpufreq_update_pstate(struct cpudata *cpu, int target_pstate,
25502550
int old_pstate = cpu->pstate.current_pstate;
25512551

25522552
target_pstate = intel_pstate_prepare_request(cpu, target_pstate);
2553-
if (target_pstate != old_pstate) {
2553+
if (hwp_active) {
2554+
intel_cpufreq_adjust_hwp(cpu, target_pstate, fast_switch);
2555+
cpu->pstate.current_pstate = target_pstate;
2556+
} else if (target_pstate != old_pstate) {
2557+
intel_cpufreq_adjust_perf_ctl(cpu, target_pstate, fast_switch);
25542558
cpu->pstate.current_pstate = target_pstate;
2555-
if (hwp_active)
2556-
intel_cpufreq_adjust_hwp(cpu, target_pstate,
2557-
fast_switch);
2558-
else
2559-
intel_cpufreq_adjust_perf_ctl(cpu, target_pstate,
2560-
fast_switch);
25612559
}
25622560

25632561
intel_cpufreq_trace(cpu, fast_switch ? INTEL_PSTATE_TRACE_FAST_SWITCH :
@@ -3014,6 +3012,7 @@ static int __init intel_pstate_init(void)
30143012
hwp_mode_bdw = id->driver_data;
30153013
intel_pstate.attr = hwp_cpufreq_attrs;
30163014
intel_cpufreq.attr = hwp_cpufreq_attrs;
3015+
intel_cpufreq.flags |= CPUFREQ_NEED_UPDATE_LIMITS;
30173016
if (!default_driver)
30183017
default_driver = &intel_pstate;
30193018

0 commit comments

Comments
 (0)