[2/2] cpufreq: intel_pstate: use acpi perflib to update turbo frequency

Message ID 20221221155203.11347-3-ptyadav@amazon.de
State New
Headers
Series intel_pstate: fix turbo not being used after a processor is rebooted |

Commit Message

Pratyush Yadav Dec. 21, 2022, 3:52 p.m. UTC
  The _PSS table does not contain the whole turbo frequency range, but
only +1 MHz above the max non-turbo frequency. The pstate driver then
updates the ACPI perf data with the actual max frequency. But doing this
here directly would mean that frequency QoS constraints that acpi
perflib imposes do not get updated.

This is a problem when a CPU is brought offline and online again. When
the CPU first comes online, cpufreq is not initialized. So PPC
constraints are not applied (because ignore_ppc == -1). This leads to
the frequency QoS allowing all values from acpi perflib side.

Once everything is initialized and then userspace brings a CPU down and
up again, intel_pstate_init_acpi_perf_limits() calls
acpi_processor_register_performance(), which then eventually calls
acpi_processor_get_platform_limit(). There PPC is state 0, the turbo
state, but the frequency has not been updated yet. So when
acpi_processor_get_platform_limit() sets QoS constraints, it sets them
with the max_non_turbo + 1 value.

Now even though intel_pstate says it can support the full turbo speed,
cpufreq only asks for up to max_non_turbo + 1 MHz since that is what
satisfies all constraints.

Call into acpi perflib's function to update the frequency so it can also
update the QoS constraints with the new value.

Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
---
 drivers/cpufreq/intel_pstate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index fd73d6d2b808..b312f87ff522 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -464,8 +464,9 @@  static void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy)
 	 * Also need to convert to MHz as _PSS freq is in MHz.
 	 */
 	if (!global.turbo_disabled)
-		cpu->acpi_perf_data.states[0].core_frequency =
-					policy->cpuinfo.max_freq / 1000;
+		acpi_processor_fixup_perf_state(policy->cpu, 0,
+						policy->cpuinfo.max_freq / 1000);
+
 	cpu->valid_pss_table = true;
 	pr_debug("_PPC limits will be enforced\n");