Re: [PATCH v2 1/2] ACPI: CPPC: add paired FFH feedback-counter read hook
"Rafael J. Wysocki (Intel)" <[email protected]> Tue, 21 Jul 2026 14:17:40 +0200
| Newsgroups | dev.linux.lists.acpica-devel,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAJZ5v0gK6Eyt79NNUwiKhjTKyqGFyV+xd0qbXh=H9LKq-KPwCQ@mail.gmail.com> |
On Wed, Jul 8, 2026 at 10:28=E2=80=AFAM Pengjie Zhang <zhangpengjie2@huawei= .com> wrote: > > cppc_get_perf_ctrs() reads the delivered and reference performance > counters one at a time. > > Allow architectures to provide both FFH feedback counters in one > operation when that either narrows the sampling window or avoids extra > cross-CPU reads. Add a small FFH-specific hook for that case and fall > back to the existing per-register reads when unsupported. > > Tested-by: Sumit Gupta <[email protected]> > Reviewed-by: Sumit Gupta <[email protected]> > Tested-by: Vanshidhar Konda <[email protected]> > Reviewed-by: Vanshidhar Konda <[email protected]> > Signed-off-by: Pengjie Zhang <[email protected]> This is fine with me, so Acked-by: Rafael J. Wysocki (Intel) <[email protected]> and please route it along with the second patch in the series. Thanks! > --- > drivers/acpi/cppc_acpi.c | 50 ++++++++++++++++++++++++++++++++++++---- > include/acpi/cppc_acpi.h | 7 ++++++ > 2 files changed, 52 insertions(+), 5 deletions(-) > > diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c > index 9f572f481241..b6356476a46e 100644 > --- a/drivers/acpi/cppc_acpi.c > +++ b/drivers/acpi/cppc_acpi.c > @@ -1004,6 +1004,22 @@ int __weak cpc_read_ffh(int cpunum, struct cpc_reg= *reg, u64 *val) > return -ENOTSUPP; > } > > +/** > + * cpc_read_ffh_fb_ctrs() - Read FFH feedback counters together > + * @cpunum: Target CPU > + * @reg1: first CPPC register information > + * @val1: place holder for first return value > + * @reg2: second CPPC register information > + * @val2: place holder for second return value > + * > + * Return: 0 on success, error code otherwise > + */ > +int __weak cpc_read_ffh_fb_ctrs(int cpunum, struct cpc_reg *reg1, > + u64 *val1, struct cpc_reg *reg2, u64 *val= 2) > +{ > + return -EOPNOTSUPP; > +} > + > /** > * cpc_write_ffh() - Write FFH register > * @cpunum: CPU number to write > @@ -1496,6 +1512,33 @@ bool cppc_perf_ctrs_in_pcc_cpu(unsigned int cpu) > } > EXPORT_SYMBOL_GPL(cppc_perf_ctrs_in_pcc_cpu); > > +static int cppc_read_fb_ctrs(int cpunum, > + struct cpc_register_resource *delivered_reg, > + struct cpc_register_resource *reference_reg, > + u64 *delivered, u64 *reference) > +{ > + int ret; > + > + /* > + * For FFH feedback counters, try a paired read first to reduce > + * sampling skew between delivered and reference counters. Fall > + * back to the existing per-register reads if unsupported. > + */ > + if (CPC_IN_FFH(delivered_reg) && CPC_IN_FFH(reference_reg)) { > + ret =3D cpc_read_ffh_fb_ctrs(cpunum, > + &delivered_reg->cpc_entry.reg, de= livered, > + &reference_reg->cpc_entry.reg, re= ference); > + if (ret !=3D -EOPNOTSUPP) > + return ret; > + } > + > + ret =3D cpc_read(cpunum, delivered_reg, delivered); > + if (ret) > + return ret; > + > + return cpc_read(cpunum, reference_reg, reference); > +} > + > /** > * cppc_perf_ctrs_in_pcc - Check if any perf counters are in a PCC regio= n. > * > @@ -1561,11 +1604,8 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_per= f_fb_ctrs *perf_fb_ctrs) > } > } > > - ret =3D cpc_read(cpunum, delivered_reg, &delivered); > - if (ret) > - goto out_err; > - > - ret =3D cpc_read(cpunum, reference_reg, &reference); > + ret =3D cppc_read_fb_ctrs(cpunum, delivered_reg, reference_reg, > + &delivered, &reference); > if (ret) > goto out_err; > > diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h > index 8693890a7275..5acebe62feac 100644 > --- a/include/acpi/cppc_acpi.h > +++ b/include/acpi/cppc_acpi.h > @@ -176,6 +176,8 @@ extern int cppc_get_transition_latency(int cpu); > extern bool cpc_ffh_supported(void); > extern bool cpc_supported_by_cpu(void); > extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val); > +extern int cpc_read_ffh_fb_ctrs(int cpu, struct cpc_reg *reg1, u64 *val1= , > + struct cpc_reg *reg2, u64 *val2); > extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val); > extern int cppc_get_epp_perf(int cpunum, u64 *epp_perf); > extern int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls= , bool enable); > @@ -250,6 +252,11 @@ static inline int cpc_read_ffh(int cpunum, struct cp= c_reg *reg, u64 *val) > { > return -EOPNOTSUPP; > } > +static inline int cpc_read_ffh_fb_ctrs(int cpu, struct cpc_reg *reg1, u6= 4 *val1, > + struct cpc_reg *reg2, u64 *val2) > +{ > + return -EOPNOTSUPP; > +} > static inline int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val= ) > { > return -EOPNOTSUPP; > -- > 2.33.0 >