Re: [PATCH v3 1/3] ACPI: CPPC: Reject desired_perf reads on ACPI 6.6+
"Rafael J. Wysocki (Intel)" <[email protected]> Mon, 3 Aug 2026 16:38:49 +0200
| Newsgroups | org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm |
|---|---|
| Message-ID | <CAJZ5v0iDuOJ2C_P8G9xD9BV7XEpQroyPecqM30ZxfEL=PzROAg@mail.gmail.com> |
On Mon, Aug 3, 2026 at 12:03=E2=80=AFPM Christian Loehle <[email protected]> wrote: > > When CPPC feedback counters cannot provide a usable sample, cppc-cpufreq > calls cppc_get_desired_perf() because some platforms repurpose Desired > Performance to report actual delivered performance. > > The fallback was added for platforms on which Desired Performance reflect= s > delivered performance. ACPI 6.6 defines the register as write-only, so > invoking that workaround on an ACPI 6.6 or later platform would require a= n > invalid register read. > > Make cppc_get_desired_perf() return -EOPNOTSUPP in that case. When checki= ng > the FADT minor revision, mask off its upper errata-generation bits and > compare only the specification minor version. I'm wondering if the _CPC revision can be used for this instead of the spec revision? The _CPC revision changed from 3 to 4 between ACPI 6.5 and ACPI 6.6, so doing that should be straightforward. > The FADT revision may not accurately describe the semantics implemented b= y > _CPC. If a nominally pre-6.6 platform implements Desired Performance as > write-only, a read may return zero and make cppc_cpufreq_get_rate() repor= t > 0 kHz. Treat a zero read as unusable and fall back to the cached OSPM > request, just as for a failed read. > > Fixes: c47195631960 ("cppc_cpufreq: Use desired perf if feedback ctrs are= 0 or unchanged") > Cc: [email protected] > Suggested-by: Sumit Gupta <[email protected]> > Signed-off-by: Christian Loehle <[email protected]> > --- > drivers/acpi/cppc_acpi.c | 15 ++++++++++++++- > drivers/cpufreq/cppc_cpufreq.c | 2 +- > 2 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c > index 53d09ca98f06..6e5381f8de38 100644 > --- a/drivers/acpi/cppc_acpi.c > +++ b/drivers/acpi/cppc_acpi.c > @@ -1316,15 +1316,28 @@ static int cppc_set_reg_val(int cpu, enum cppc_re= gs reg_idx, u64 val) > return cpc_write(cpu, reg, val); > } > > +static bool cppc_desired_perf_readable(void) > +{ > + u8 minor_revision =3D acpi_gbl_FADT.minor_revision & 0x0f; > + > + return acpi_gbl_FADT.header.revision < 6 || > + (acpi_gbl_FADT.header.revision =3D=3D 6 && minor_revision = < 6); > +} > + > /** > * cppc_get_desired_perf - Get the desired performance register value. > * @cpunum: CPU from which to get desired performance. > * @desired_perf: Return address. > * > - * Return: 0 for success, -EIO otherwise. > + * Return: 0 for success, -EOPNOTSUPP for ACPI 6.6 or later, and a negat= ive > + * errno otherwise. > */ > int cppc_get_desired_perf(int cpunum, u64 *desired_perf) > { > + /* ACPI 6.6 no longer specifies Desired Performance as readable. = */ > + if (!cppc_desired_perf_readable()) > + return -EOPNOTSUPP; > + > return cppc_get_reg_val(cpunum, DESIRED_PERF, desired_perf); > } > EXPORT_SYMBOL_GPL(cppc_get_desired_perf); > diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufre= q.c > index 6fe0e972952a..80893844353c 100644 > --- a/drivers/cpufreq/cppc_cpufreq.c > +++ b/drivers/cpufreq/cppc_cpufreq.c > @@ -836,7 +836,7 @@ static unsigned int cppc_cpufreq_get_rate(unsigned in= t cpu) > * value first as some platforms may update the actual delivered = perf > * there; if failed, resort to the cached desired perf. > */ > - if (cppc_get_desired_perf(cpu, &delivered_perf)) > + if (cppc_get_desired_perf(cpu, &delivered_perf) || !delivered_per= f) > delivered_perf =3D cpu_data->perf_ctrls.desired_perf; > > return cppc_perf_to_khz(&cpu_data->perf_caps, delivered_perf); > -- > 2.34.1 >