public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	 Viresh Kumar <viresh.kumar@linaro.org>,
	Mario Limonciello <mario.limonciello@amd.com>,
	Sudeep Holla <sudeep.holla@arm.com>
Subject: Re: [PATCH v1 10/10] cpufreq: Pass policy pointer to ->update_limits()
Date: Mon, 07 Apr 2025 15:27:59 -0700	[thread overview]
Message-ID: <2362a42de1403e99a66551575efd910cc92980bc.camel@linux.intel.com> (raw)
In-Reply-To: <CAJZ5v0iMYSTnX9mkZb8aEmtbKxWOgsshNJ_AqnB9Mn27y8jzeQ@mail.gmail.com>

On Mon, 2025-04-07 at 20:48 +0200, Rafael J. Wysocki wrote:
> On Fri, Mar 28, 2025 at 9:49 PM Rafael J. Wysocki <rjw@rjwysocki.net>
> wrote:
> > 
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > 
> > Since cpufreq_update_limits() obtains a cpufreq policy pointer for
> > the
> > given CPU and reference counts the corresponding policy object, it
> > may
> > as well pass the policy pointer to the cpufreq driver's -
> > >update_limits()
> > callback which allows that callback to avoid invoking
> > cpufreq_cpu_get()
> > for the same CPU.
> > 
> > Accordingly, redefine ->update_limits() to take a policy pointer
> > instead
> > of a CPU number and update both drivers implementing it,
> > intel_pstate
> > and amd-pstate, as needed.
> > 
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
Hi Rafael,

> Hi Srinivas,
> 
> If you have any concerns regarding this patch, please let me know
> (note that it is based on the [05/10]).
> 
Changes looks fine, but wants to test out some update limits from
interrupt path.
Checked your branches at linux-pm, not able to locate in any branch to
apply.
Please point me to a branch.

Thanks,
Srinivas

> > ---
> >  drivers/cpufreq/amd-pstate.c   |    7 ++-----
> >  drivers/cpufreq/cpufreq.c      |    2 +-
> >  drivers/cpufreq/intel_pstate.c |   29 ++++++++++++++++++----------
> > -
> >  include/linux/cpufreq.h        |    2 +-
> >  4 files changed, 22 insertions(+), 18 deletions(-)
> > 
> > --- a/drivers/cpufreq/amd-pstate.c
> > +++ b/drivers/cpufreq/amd-pstate.c
> > @@ -821,19 +821,16 @@
> >         schedule_work(&sched_prefcore_work);
> >  }
> > 
> > -static void amd_pstate_update_limits(unsigned int cpu)
> > +static void amd_pstate_update_limits(struct cpufreq_policy
> > *policy)
> >  {
> > -       struct cpufreq_policy *policy __free(put_cpufreq_policy) =
> > cpufreq_cpu_get(cpu);
> >         struct amd_cpudata *cpudata;
> >         u32 prev_high = 0, cur_high = 0;
> >         bool highest_perf_changed = false;
> > +       unsigned int cpu = policy->cpu;
> > 
> >         if (!amd_pstate_prefcore)
> >                 return;
> > 
> > -       if (!policy)
> > -               return;
> > -
> >         if (amd_get_highest_perf(cpu, &cur_high))
> >                 return;
> > 
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -2741,7 +2741,7 @@
> >                 return;
> > 
> >         if (cpufreq_driver->update_limits)
> > -               cpufreq_driver->update_limits(cpu);
> > +               cpufreq_driver->update_limits(policy);
> >         else
> >                 cpufreq_policy_refresh(policy);
> >  }
> > --- a/drivers/cpufreq/intel_pstate.c
> > +++ b/drivers/cpufreq/intel_pstate.c
> > @@ -1353,14 +1353,9 @@
> >                 cpufreq_update_policy(cpu);
> >  }
> > 
> > -static bool intel_pstate_update_max_freq(struct cpudata *cpudata)
> > +static void __intel_pstate_update_max_freq(struct cpufreq_policy
> > *policy,
> > +                                          struct cpudata *cpudata)
> >  {
> > -       struct cpufreq_policy *policy __free(put_cpufreq_policy);
> > -
> > -       policy = cpufreq_cpu_get(cpudata->cpu);
> > -       if (!policy)
> > -               return false;
> > -
> >         guard(cpufreq_policy_write)(policy);
> > 
> >         if (hwp_active)
> > @@ -1370,16 +1365,28 @@
> >                         cpudata->pstate.max_freq : cpudata-
> > >pstate.turbo_freq;
> > 
> >         refresh_frequency_limits(policy);
> > +}
> > +
> > +static bool intel_pstate_update_max_freq(struct cpudata *cpudata)
> > +{
> > +       struct cpufreq_policy *policy __free(put_cpufreq_policy);
> > +
> > +       policy = cpufreq_cpu_get(cpudata->cpu);
> > +       if (!policy)
> > +               return false;
> > +
> > +       __intel_pstate_update_max_freq(policy, cpudata);
> > 
> >         return true;
> >  }
> > 
> > -static void intel_pstate_update_limits(unsigned int cpu)
> > +static void intel_pstate_update_limits(struct cpufreq_policy
> > *policy)
> >  {
> > -       struct cpudata *cpudata = all_cpu_data[cpu];
> > +       struct cpudata *cpudata = all_cpu_data[policy->cpu];
> > +
> > +       __intel_pstate_update_max_freq(policy, cpudata);
> > 
> > -       if (intel_pstate_update_max_freq(cpudata))
> > -               hybrid_update_capacity(cpudata);
> > +       hybrid_update_capacity(cpudata);
> >  }
> > 
> >  static void intel_pstate_update_limits_for_all(void)
> > --- a/include/linux/cpufreq.h
> > +++ b/include/linux/cpufreq.h
> > @@ -399,7 +399,7 @@
> >         unsigned int    (*get)(unsigned int cpu);
> > 
> >         /* Called to update policy limits on firmware
> > notifications. */
> > -       void            (*update_limits)(unsigned int cpu);
> > +       void            (*update_limits)(struct cpufreq_policy
> > *policy);
> > 
> >         /* optional */
> >         int             (*bios_limit)(int cpu, unsigned int
> > *limit);
> > 
> > 
> > 
> > 
> 


  reply	other threads:[~2025-04-07 22:28 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-28 20:36 [PATCH v1 00/10] cpufreq: cpufreq_update_limits() fix and some cleanups Rafael J. Wysocki
2025-03-28 20:39 ` [PATCH v1 01/10] cpufreq: Reference count policy in cpufreq_update_limits() Rafael J. Wysocki
2025-03-29  2:02   ` Marek Marczykowski-Górecki
2025-03-29 11:48     ` Rafael J. Wysocki
2025-04-01  8:30   ` Viresh Kumar
2025-04-01 16:47     ` Rafael J. Wysocki
2025-04-15 13:08   ` Marek Marczykowski-Górecki
2025-04-15 13:12     ` Rafael J. Wysocki
2025-03-28 20:40 ` [PATCH v1 02/10] cpufreq: Consolidate some code in cpufreq_online() Rafael J. Wysocki
2025-04-01  8:32   ` Viresh Kumar
2025-03-28 20:41 ` [PATCH v1 03/10] cpufreq: Split cpufreq_online() Rafael J. Wysocki
2025-04-01  8:38   ` Viresh Kumar
2025-04-01  8:43     ` Viresh Kumar
2025-03-28 20:42 ` [PATCH v1 04/10] cpufreq: Add and use cpufreq policy locking guards Rafael J. Wysocki
2025-04-01  8:43   ` Viresh Kumar
2025-03-28 20:43 ` [PATCH v1 05/10] cpufreq: intel_pstate: Rearrange max frequency updates handling code Rafael J. Wysocki
2025-04-07 18:46   ` Rafael J. Wysocki
2025-03-28 20:44 ` [PATCH v1 06/10] cpufreq: Use locking guard and __free() in cpufreq_update_policy() Rafael J. Wysocki
2025-04-01  8:46   ` Viresh Kumar
2025-03-28 20:45 ` [PATCH v1 07/10] cpufreq: Drop cpufreq_cpu_acquire() and cpufreq_cpu_release() Rafael J. Wysocki
2025-04-01  8:46   ` Viresh Kumar
2025-03-28 20:46 ` [PATCH v1 08/10] cpufreq: Use __free() for policy reference counting cleanup Rafael J. Wysocki
2025-04-01  8:48   ` Viresh Kumar
2025-03-28 20:47 ` [PATCH v1 09/10] cpufreq: Introduce cpufreq_policy_refresh() Rafael J. Wysocki
2025-04-01  8:51   ` Viresh Kumar
2025-03-28 20:48 ` [PATCH v1 10/10] cpufreq: Pass policy pointer to ->update_limits() Rafael J. Wysocki
2025-04-01  8:51   ` Viresh Kumar
2025-04-07 18:48   ` Rafael J. Wysocki
2025-04-07 22:27     ` srinivas pandruvada [this message]
2025-04-07 23:49       ` Doug Smythies
2025-04-08 14:18         ` srinivas pandruvada
2025-04-08 11:41       ` Rafael J. Wysocki
2025-04-08 13:37         ` Rafael J. Wysocki
2025-04-08 17:47           ` srinivas pandruvada
2025-04-08 18:34             ` Rafael J. Wysocki
2025-04-08 18:48               ` srinivas pandruvada
2025-04-01 16:57 ` [PATCH v1 00/10] cpufreq: cpufreq_update_limits() fix and some cleanups Mario Limonciello
2025-04-09 19:16 ` Sudeep Holla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2362a42de1403e99a66551575efd910cc92980bc.camel@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=sudeep.holla@arm.com \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox