On Wed, Dec 21, 2022 at 4:52 PM Pratyush Yadav <ptyadav@xxxxxxxxx> wrote: > > 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. Which is a known convention based on compatibility with some older OSes. > The frequency can actually go much higher based on various factors like > temperature, voltage, etc. It can. > Allow drivers like intel_pstate to fix up performance state frequencies > with the actual maximum value. Why do you want to do that? > While at it, also update the QoS > constraints if needed to match the new frequency values. > > Signed-off-by: Pratyush Yadav <ptyadav@xxxxxxxxx> > --- > 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 >