@@ -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);
@@ -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
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@amazon.de> --- drivers/acpi/processor_perflib.c | 40 ++++++++++++++++++++++++++++++++ include/acpi/processor.h | 2 ++ 2 files changed, 42 insertions(+)