[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFivqmLkLn-92rMow+c7iEADCdh3-DEapVmtB_Qwk1a2JrwwWw@mail.gmail.com>
Date: Wed, 30 Jul 2025 15:34:46 -0700
From: Prashant Malani <pmalani@...gle.com>
To: Viresh Kumar <viresh.kumar@...aro.org>
Cc: Bowen Yu <yubowen8@...wei.com>, rafael@...nel.org, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, linuxarm@...wei.com,
jonathan.cameron@...wei.com, zhanjie9@...ilicon.com, lihuisong@...wei.com,
zhenglifeng1@...wei.com, Beata Michalska <beata.michalska@....com>,
Ionela Voinescu <ionela.voinescu@....com>
Subject: Re: [PATCH 2/2] cpufreq: CPPC: Fix error handling in cppc_scale_freq_workfn()
Thanks for adding me, Viresh.
On Tue, 29 Jul 2025 at 23:39, Viresh Kumar <viresh.kumar@...aro.org> wrote:
>
> + Prashant/Beata/Ionela
>
> On 30-07-25, 11:23, Bowen Yu wrote:
> > From: Jie Zhan <zhanjie9@...ilicon.com>
> >
> > Perf counters could be 0 if the cpu is in a low-power idle state. Just try
> > it again next time and update the frequency scale when the cpu is active
> > and perf counters successfully return.
> >
> > Also, remove the FIE source on an actual failure.
> >
> > Signed-off-by: Jie Zhan <zhanjie9@...ilicon.com>
> > ---
> > drivers/cpufreq/cppc_cpufreq.c | 13 ++++++++++++-
> > 1 file changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> > index 904006027df2..e95844d3d366 100644
> > --- a/drivers/cpufreq/cppc_cpufreq.c
> > +++ b/drivers/cpufreq/cppc_cpufreq.c
> > @@ -78,12 +78,23 @@ static void cppc_scale_freq_workfn(struct kthread_work *work)
> > struct cppc_cpudata *cpu_data;
> > unsigned long local_freq_scale;
> > u64 perf;
> > + int ret;
> >
> > cppc_fi = container_of(work, struct cppc_freq_invariance, work);
> > cpu_data = cppc_fi->cpu_data;
> >
> > - if (cppc_get_perf_ctrs(cppc_fi->cpu, &fb_ctrs)) {
> > + ret = cppc_get_perf_ctrs(cppc_fi->cpu, &fb_ctrs);
> > + /*
> > + * Perf counters could be 0 if the cpu is in a low-power idle state.
> > + * Just try it again next time.
> > + */
FWIU the performance counters shouldn't be returning 0 in an idle state.
Per the UEFI spec [1], they increment any time the CPU is active,
so they should just return their last counter value before they went into idle
(of course in the FFH case an IPI is performed on the target CPU, so even
if the CPU was idle, it will get woken up).
As such it is better to either :
- Check for idle_cpu() directly and return (see [2] for the function)
or
- Always clear the source on encountering an error return value.
[1] https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html?highlight=cppc#performance-counters
[2] https://lore.kernel.org/linux-pm/20250619000925.415528-2-pmalani@google.com/
HTH,
-Prashant
Powered by blists - more mailing lists