RE: [PATCH v8 01/13] ACPI: CPPC: Add AMD pstate energy performance preference cppc control
From: Yuan, Perry
Date: Sun Dec 25 2022 - 11:42:05 EST
[AMD Official Use Only - General]
> -----Original Message-----
> From: Huang, Ray <Ray.Huang@xxxxxxx>
> Sent: Friday, December 23, 2022 5:06 PM
> To: Yuan, Perry <Perry.Yuan@xxxxxxx>
> Cc: rafael.j.wysocki@xxxxxxxxx; Limonciello, Mario
> <Mario.Limonciello@xxxxxxx>; viresh.kumar@xxxxxxxxxx; Sharma, Deepak
> <Deepak.Sharma@xxxxxxx>; Fontenot, Nathan
> <Nathan.Fontenot@xxxxxxx>; Deucher, Alexander
> <Alexander.Deucher@xxxxxxx>; Huang, Shimmer
> <Shimmer.Huang@xxxxxxx>; Du, Xiaojian <Xiaojian.Du@xxxxxxx>; Meng,
> Li (Jassmine) <Li.Meng@xxxxxxx>; Karny, Wyes <Wyes.Karny@xxxxxxx>;
> linux-pm@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v8 01/13] ACPI: CPPC: Add AMD pstate energy
> performance preference cppc control
>
> On Fri, Dec 23, 2022 at 11:19:57AM +0800, Yuan, Perry wrote:
> > [AMD Official Use Only - General]
> >
> >
> >
> > > -----Original Message-----
> > > From: Huang, Ray <Ray.Huang@xxxxxxx>
> > > Sent: Friday, December 23, 2022 10:16 AM
> > > To: Yuan, Perry <Perry.Yuan@xxxxxxx>
> > > Cc: rafael.j.wysocki@xxxxxxxxx; Limonciello, Mario
> > > <Mario.Limonciello@xxxxxxx>; viresh.kumar@xxxxxxxxxx; Sharma,
> Deepak
> > > <Deepak.Sharma@xxxxxxx>; Fontenot, Nathan
> <Nathan.Fontenot@xxxxxxx>;
> > > Deucher, Alexander <Alexander.Deucher@xxxxxxx>; Huang, Shimmer
> > > <Shimmer.Huang@xxxxxxx>; Du, Xiaojian <Xiaojian.Du@xxxxxxx>;
> Meng,
> > > Li (Jassmine) <Li.Meng@xxxxxxx>; Karny, Wyes
> <Wyes.Karny@xxxxxxx>;
> > > linux-pm@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> > > Subject: Re: [PATCH v8 01/13] ACPI: CPPC: Add AMD pstate energy
> > > performance preference cppc control
> > >
> > > On Mon, Dec 19, 2022 at 02:40:30PM +0800, Yuan, Perry wrote:
> > > > From: Perry Yuan <Perry.Yuan@xxxxxxx>
> > > >
> > > > Add support for setting and querying EPP preferences to the
> > > > generic CPPC driver. This enables downstream drivers such as
> > > > amd-pstate to discover and use these values
> > > >
> > > > Downstream drivers that want to use the new symbols
> > > > cppc_get_epp_caps and cppc_set_epp_perf for querying and setting
> > > > EPP preferences will need to call cppc_set_epp_perf to enable the EPP
> function firstly.
> > > >
> > > > Signed-off-by: Perry Yuan <Perry.Yuan@xxxxxxx>
> > > > ---
> > > > drivers/acpi/cppc_acpi.c | 76
> > > > +++++++++++++++++++++++++++++++++++++---
> > > > include/acpi/cppc_acpi.h | 12 +++++++
> > > > 2 files changed, 83 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> > > > index 093675b1a1ff..81081eb899ea 100644
> > > > --- a/drivers/acpi/cppc_acpi.c
> > > > +++ b/drivers/acpi/cppc_acpi.c
> > > > @@ -1093,6 +1093,9 @@ static int cppc_get_perf(int cpunum, enum
> > > > cppc_regs reg_idx, u64 *perf) {
> > > > struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
> > > > struct cpc_register_resource *reg;
> > > > + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
> > > > + struct cppc_pcc_data *pcc_ss_data = NULL;
> > > > + int ret = -EINVAL;
> > > >
> > > > if (!cpc_desc) {
> > > > pr_debug("No CPC descriptor for CPU:%d\n", cpunum); @@
> > > -1102,10
> > > > +1105,6 @@ static int cppc_get_perf(int cpunum, enum cppc_regs
> > > > +reg_idx,
> > > u64 *perf)
> > > > reg = &cpc_desc->cpc_regs[reg_idx];
> > > >
> > > > if (CPC_IN_PCC(reg)) {
> > > > - int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
> > > > - struct cppc_pcc_data *pcc_ss_data = NULL;
> > > > - int ret = 0;
> > > > -
> > >
> > > Do you have any specific reason to move this piece out of if-condition?
> >
> > Move the declaration ahead of the If conditions like other functions did.
> > It looks more reasonable and no functions impact.
> >
>
> If one platform doesn't have any CPC registers, it even won't need define
> these variables like pcc_ss_id, pcc_ss_data, and it will save more time.
>
> Thanks,
> Ray
Make sense , get it fixed in V9