lkml.org 
[lkml]   [2022]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] cpufreq: Avoid unnecessary frequency updates due to mismatch
On Thu, May 5, 2022 at 3:32 PM Matthias Brugger <matthias.bgg@gmail.com> wrote:
>
>
>
> On 04/05/2022 10:21, Viresh Kumar wrote:
> > For some platforms, the frequency returned by hardware may be slightly
> > different from what is provided in the frequency table. For example,
> > hardware may return 499 MHz instead of 500 MHz. In such cases it is
> > better to avoid getting into unnecessary frequency updates, as we may
> > end up switching policy->cur between the two and sending unnecessary
> > pre/post update notifications, etc.
> >
> > This patch has chosen allows the hardware frequency and table frequency
> > to deviate by 1 MHz for now, we may want to increase it a bit later on
> > if someone still complains.
> >
> > Reported-by: Rex-BC Chen <rex-bc.chen@mediatek.com>
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
>
> > ---
> > drivers/cpufreq/cpufreq.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index 0d58b0f8f3af..233e8af48848 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -28,6 +28,7 @@
> > #include <linux/suspend.h>
> > #include <linux/syscore_ops.h>
> > #include <linux/tick.h>
> > +#include <linux/units.h>
> > #include <trace/events/power.h>
> >
> > static LIST_HEAD(cpufreq_policy_list);
> > @@ -1708,6 +1709,16 @@ static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, b
> > return new_freq;
> >
> > if (policy->cur != new_freq) {
> > + /*
> > + * For some platforms, the frequency returned by hardware may be
> > + * slightly different from what is provided in the frequency
> > + * table, for example hardware may return 499 MHz instead of 500
> > + * MHz. In such cases it is better to avoid getting into
> > + * unnecessary frequency updates.
> > + */
> > + if (abs(policy->cur - new_freq) < HZ_PER_MHZ)
> > + return policy->cur;
> > +
> > cpufreq_out_of_sync(policy, new_freq);
> > if (update)
> > schedule_work(&policy->update);

Applied as 5.19 material, thanks!

\
 
 \ /
  Last update: 2022-05-06 20:58    [W:0.070 / U:1.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site