RE: [PATCH] ACPI: CPPC: Don't require _OSC if X86_FEATURE_CPPC is supported

From: Limonciello, Mario
Date: Wed Jun 29 2022 - 14:49:07 EST


[Public]



> -----Original Message-----
> From: Rafael J. Wysocki <rafael@xxxxxxxxxx>
> Sent: Wednesday, June 29, 2022 13:42
> To: Limonciello, Mario <Mario.Limonciello@xxxxxxx>
> Cc: Rafael J. Wysocki <rafael@xxxxxxxxxx>; Len Brown <lenb@xxxxxxxxxx>;
> Pierre Gondois <pierre.gondois@xxxxxxx>; Sudeep Holla
> <sudeep.holla@xxxxxxx>; Yuan, Perry <Perry.Yuan@xxxxxxx>; ACPI Devel
> Maling List <linux-acpi@xxxxxxxxxxxxxxx>; Linux Kernel Mailing List <linux-
> kernel@xxxxxxxxxxxxxxx>
> Subject: Re: [PATCH] ACPI: CPPC: Don't require _OSC if X86_FEATURE_CPPC is
> supported
>
> On Mon, Jun 27, 2022 at 6:58 PM Mario Limonciello
> <mario.limonciello@xxxxxxx> wrote:
> >
> > commit 72f2ecb7ece7 ("ACPI: bus: Set CPPC _OSC bits for all and
> > when CPPC_LIB is supported") added support for claiming to
> > support CPPC in _OSC on non-Intel platforms.
> >
> > This unfortunately caused a regression on a vartiety of AMD
> > platforms in the field because a number of AMD platforms don't set
> > the `_OSC` bit 5 or 6 to indicate CPPC or CPPC v2 support.
> >
> > As these AMD platforms already claim CPPC support via `X86_FEATURE_CPPC`,
> > use this enable this feature rather than requiring the `_OSC`.
> >
> > Fixes: 72f2ecb7ece7 ("Set CPPC _OSC bits for all and when CPPC_LIB is
> supported")
> > Reported-by: Perry Yuan <perry.yuan@xxxxxxx>
> > Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
> > ---
> > drivers/acpi/cppc_acpi.c | 12 +++++++++---
> > 1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> > index 903528f7e187..5463e6309b9a 100644
> > --- a/drivers/acpi/cppc_acpi.c
> > +++ b/drivers/acpi/cppc_acpi.c
> > @@ -629,6 +629,15 @@ static bool is_cppc_supported(int revision, int
> num_ent)
> > return false;
> > }
> >
> > + if (osc_sb_cppc_not_supported) {
> > + pr_debug("Firmware missing _OSC support\n");
> > +#ifdef CONFIG_X86
> > + return boot_cpu_has(X86_FEATURE_CPPC);
> > +#else
> > + return false;
> > +#endif
>
> What about doing
>
> if (osc_sb_cppc_not_supported) {
> pr_debug("Firmware missing _OSC support\n");
> return IS_ENABLED(CONFIG_X86) && boot_cpu_has(X86_FEATURE_CPPC);
> }
>
> instead for the sake of reducing #ifdeffery?

I don't think that would compile on non-X86. X86_FEATURE_CPPC comes as part of
arch/x86/include/asm/cpufeatures.h, which I wouldn't expect is included on !x86.

>
> Also, this is somewhat risky, because even if the given processor has
> X86_FEATURE_CPPC set, the platform may still not want to expose CPPC
> through ACPI. How's that going to work after this change?
>

Well actually doing that through _OSC wouldn't have worked before 72f2ecb7ece7 either.
If desirable - a platform could avoid populating _CPC objects in ACPI tables in this case.

I do know of OEM platforms that the underlying APU supports CPPC but the OEM doesn't
populate _CPC. Presumably for this exact reason.

>
> > + }
> > +
> > return true;
> > }
> >
> > @@ -684,9 +693,6 @@ int acpi_cppc_processor_probe(struct acpi_processor
> *pr)
> > acpi_status status;
> > int ret = -ENODATA;
> >
> > - if (osc_sb_cppc_not_supported)
> > - return -ENODEV;
> > -
> > /* Parse the ACPI _CPC table for this CPU. */
> > status = acpi_evaluate_object_typed(handle, "_CPC", NULL, &output,
> > ACPI_TYPE_PACKAGE);
> > --
> > 2.34.1
> >