[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221221155203.11347-2-ptyadav@amazon.de>
Date: Wed, 21 Dec 2022 16:52:02 +0100
From: Pratyush Yadav <ptyadav@...zon.de>
To: <linux-pm@...r.kernel.org>
CC: Pratyush Yadav <ptyadav@...zon.de>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Len Brown <lenb@...nel.org>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
Viresh Kumar <viresh.kumar@...aro.org>,
Robert Moore <robert.moore@...el.com>,
<linux-acpi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<devel@...ica.org>
Subject: [PATCH 1/2] acpi: processor: allow fixing up the frequency for a performance state
In some cases the ACPI table can have an incorrect frequency populated
for a performance state. For example, in Intel platforms, the Turbo
frequency is just listed as +1 MHz above the max non-turbo frequency.
The frequency can actually go much higher based on various factors like
temperature, voltage, etc.
Allow drivers like intel_pstate to fix up performance state frequencies
with the actual maximum value. While at it, also update the QoS
constraints if needed to match the new frequency values.
Signed-off-by: Pratyush Yadav <ptyadav@...zon.de>
---
drivers/acpi/processor_perflib.c | 40 ++++++++++++++++++++++++++++++++
include/acpi/processor.h | 2 ++
2 files changed, 42 insertions(+)
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 970f04a958cd..4958aee4c024 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -766,3 +766,43 @@ void acpi_processor_unregister_performance(unsigned int cpu)
mutex_unlock(&performance_mutex);
}
EXPORT_SYMBOL(acpi_processor_unregister_performance);
+
+int acpi_processor_fixup_perf_state(unsigned int cpu, unsigned int state,
+ unsigned int frequency)
+{
+ struct acpi_processor *pr;
+ int ret;
+
+ mutex_lock(&performance_mutex);
+
+ pr = per_cpu(processors, cpu);
+ if (!pr) {
+ mutex_unlock(&performance_mutex);
+ return -ENODEV;
+ }
+
+ if (!pr->performance) {
+ mutex_unlock(&performance_mutex);
+ return -EINVAL;
+ }
+
+ if (state >= pr->performance->state_count) {
+ mutex_unlock(&performance_mutex);
+ return -EINVAL;
+ }
+
+ pr->performance->states[state].core_frequency = frequency;
+
+ if (ignore_ppc != 1 && state == pr->performance_platform_limit &&
+ freq_qos_request_active(&pr->perflib_req)) {
+ ret = freq_qos_update_request(&pr->perflib_req,
+ frequency * 1000);
+ if (ret < 0)
+ pr_warn("Failed to update perflib freq constraint: CPU%d (%d)\n",
+ pr->id, ret);
+ }
+
+ mutex_unlock(&performance_mutex);
+ return 0;
+}
+EXPORT_SYMBOL(acpi_processor_fixup_perf_state);
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 94181fe9780a..daff978cfa7d 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -258,6 +258,8 @@ extern int acpi_processor_preregister_performance(struct
extern int acpi_processor_register_performance(struct acpi_processor_performance
*performance, unsigned int cpu);
extern void acpi_processor_unregister_performance(unsigned int cpu);
+extern int acpi_processor_fixup_perf_state(unsigned int cpu, unsigned int state,
+ unsigned int frequency);
int acpi_processor_pstate_control(void);
/* note: this locks both the calling module and the processor module
--
2.38.1
Powered by blists - more mailing lists