Re: [PATCH v3 2/3] ACPI: CPPC: Skip desired_perf read in cppc_get_perf()

"Rafael J. Wysocki (Intel)" <[email protected]> Mon, 3 Aug 2026 16:43:15 +0200
Newsgroups org.kernel.vger.linux-pm,org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel
Message-ID <CAJZ5v0hiqqHr13GEdTVk3E7KypNe1JEfwCZxMfPrRueOL5hEHg@mail.gmail.com>
On Mon, Aug 3, 2026 at 12:03=E2=80=AFPM Christian Loehle
<[email protected]> wrote:
>
> ACPI 6.6 changed the Optional Attribute of Desired Performance from
> Read/Write to Write. cppc_get_perf() nevertheless reads the register when
> initializing performance controls, even though cppc-cpufreq overwrites th=
e
> value before using it.

IMV it would be better to say that the change from R/W to W happened
between _CPC rev 3 (in ACPI 6.5) and _CPC rev 4 (in ACPI 6.6).

It would also be better to refer to the _CPC revision in the paragraph belo=
w.

> Use the readability check from cppc_get_desired_perf() and leave
> desired_perf zero instead of reading it on ACPI 6.6 or later. Also exclud=
e
> the register from PCC read-command detection so it cannot trigger an
> otherwise unnecessary read command.
>
> Fixes: 658fa7b1c47a ("ACPI: CPPC: Add cppc_get_perf() API to read perform=
ance controls")
> Cc: [email protected]
> Suggested-by: Zhongqiu Han <[email protected]>
> Reviewed-by: Zhongqiu Han <[email protected]>
> Signed-off-by: Christian Loehle <[email protected]>
> ---
>  drivers/acpi/cppc_acpi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index 6e5381f8de38..210988d57b71 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -1843,6 +1843,7 @@ int cppc_get_perf(int cpu, struct cppc_perf_ctrls *=
perf_ctrls)
>         u64 desired_perf =3D 0, min =3D 0, max =3D 0, energy_perf =3D 0, =
auto_sel =3D 0;
>         int pcc_ss_id =3D per_cpu(cpu_pcc_subspace_idx, cpu);
>         struct cppc_pcc_data *pcc_ss_data =3D NULL;
> +       bool read_desired_perf =3D cppc_desired_perf_readable();
>         int ret =3D 0, regs_in_pcc =3D 0;
>
>         if (!cpc_desc) {
> @@ -1862,7 +1863,8 @@ int cppc_get_perf(int cpu, struct cppc_perf_ctrls *=
perf_ctrls)
>         auto_sel_reg =3D &cpc_desc->cpc_regs[AUTO_SEL_ENABLE];
>
>         /* Are any of the regs PCC ?*/
> -       if (CPC_IN_PCC(desired_perf_reg) || CPC_IN_PCC(min_perf_reg) ||
> +       if ((read_desired_perf && CPC_IN_PCC(desired_perf_reg)) ||
> +           CPC_IN_PCC(min_perf_reg) ||
>             CPC_IN_PCC(max_perf_reg) || CPC_IN_PCC(energy_perf_reg) ||
>             CPC_IN_PCC(auto_sel_reg)) {
>                 if (pcc_ss_id < 0) {
> @@ -1894,7 +1896,7 @@ int cppc_get_perf(int cpu, struct cppc_perf_ctrls *=
perf_ctrls)
>         }
>         perf_ctrls->min_perf =3D min;
>
> -       if (CPC_SUPPORTED(desired_perf_reg)) {
> +       if (read_desired_perf && CPC_SUPPORTED(desired_perf_reg)) {
>                 ret =3D cpc_read(cpu, desired_perf_reg, &desired_perf);
>                 if (ret)
>                         goto out_err;
> --
> 2.34.1
>