cpufreq: intel_pstate: Allow enable/disable energy efficiency
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Fri, 26 Jun 2020 18:34:00 +0000 (11:34 -0700)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 2 Jul 2020 11:02:46 +0000 (13:02 +0200)
commited7bde7a6dab521ee9e28fe2264018f83d83c7fa
treebad397fef297f8f82bd56102d2363b3f084a6335
parent9ebcfadb0610322ac537dd7aa5d9cbc2b2894c68
cpufreq: intel_pstate: Allow enable/disable energy efficiency

By default intel_pstate the driver disables energy efficiency by setting
MSR_IA32_POWER_CTL bit 19 for Kaby Lake desktop CPU model in HWP mode.
This CPU model is also shared by Coffee Lake desktop CPUs. This allows
these systems to reach maximum possible frequency. But this adds power
penalty, which some customers don't want. They want some way to enable/
disable dynamically.

So, add an additional attribute "energy_efficiency" under
/sys/devices/system/cpu/intel_pstate/ for these CPU models. This allows
to read and write bit 19 ("Disable Energy Efficiency Optimization") in
the MSR IA32_POWER_CTL.

This attribute is present in both HWP and non-HWP mode as this has an
effect in both modes. Refer to Intel Software Developer's manual for
details.

The scope of this bit is package wide. Also these systems are single
package systems. So read/write MSR on the current CPU is enough.

The energy efficiency (EE) bit setting needs to be preserved during
suspend/resume and CPU offline/online operation. To do this:
- Restoring the EE setting from the cpufreq resume() callback, if there
is change from the system default.
- By default, don't disable EE from cpufreq init() callback for matching
CPU models. Since the scope is package wide and is a single package
system, move the disable EE calls from init() callback to
intel_pstate_init() function, which is called only once.

Suggested-by: Len Brown <lenb@kernel.org>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Documentation/admin-guide/pm/intel_pstate.rst
arch/x86/include/asm/msr-index.h
drivers/cpufreq/intel_pstate.c