]> www.infradead.org Git - users/dwmw2/linux.git/commit
cpufreq: intel_pstate: Check turbo_is_disabled() in store_no_turbo()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 11 Jun 2024 14:53:06 +0000 (16:53 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 12 Jun 2024 12:11:50 +0000 (14:11 +0200)
commit350cbb5d2f676bff22c49e5e81764c3b8da342a9
tree62847ea0a3176eee5ab550328d21e1eea0decd2b
parent83a7eefedc9b56fe7bfeff13b6c7356688ffa670
cpufreq: intel_pstate: Check turbo_is_disabled() in store_no_turbo()

After recent changes in intel_pstate, global.turbo_disabled is only set
at the initialization time and never changed.  However, it turns out
that on some systems the "turbo disabled" bit in MSR_IA32_MISC_ENABLE,
the initial state of which is reflected by global.turbo_disabled, can be
flipped later and there should be a way to take that into account (other
than checking that MSR every time the driver runs which is costly and
useless overhead on the vast majority of systems).

For this purpose, notice that before the changes in question,
store_no_turbo() contained a turbo_is_disabled() check that was used
for updating global.turbo_disabled if the "turbo disabled" bit in
MSR_IA32_MISC_ENABLE had been flipped and that functionality can be
restored.  Then, users will be able to reset global.turbo_disabled
by writing 0 to no_turbo which used to work before on systems with
flipping "turbo disabled" bit.

This guarantees the driver state to remain in sync, but READ_ONCE()
annotations need to be added in two places where global.turbo_disabled
is accessed locklessly, so modify the driver to make that happen.

Fixes: 0940f1a8011f ("cpufreq: intel_pstate: Do not update global.turbo_disabled after initialization")
Closes: https://lore.kernel.org/linux-pm/bf3ebf1571a4788e97daf861eb493c12d42639a3.camel@xry111.site
Suggested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reported-by: Xi Ruoyao <xry111@xry111.site>
Tested-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/intel_pstate.c