linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq/amd-pstate: Fix setting scaling max/min freq values
@ 2024-01-19 11:33 Mario Limonciello
  2024-01-22 14:57 ` Wyes Karny
  2024-01-22 23:52 ` Dan Martins
  0 siblings, 2 replies; 4+ messages in thread
From: Mario Limonciello @ 2024-01-19 11:33 UTC (permalink / raw)
  To: ray.huang, rafael
  Cc: viresh.kumar, linux-pm, linux-kernel, Mario Limonciello, stable, wkarny

Scaling min/max freq values were being cached and lagging a setting
each time.  Fix the ordering of the clamp call to ensure they work.

Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931
Cc: stable@vger.kernel.org
Cc: wkarny@gmail.com
Fixes: febab20caeba ("cpufreq/amd-pstate: Fix scaling_min_freq and scaling_max_freq update")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 1f6186475715..1791d37fbc53 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -1232,14 +1232,13 @@ static void amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
 	max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
 	min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
 
+	WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
+	WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
+
 	max_perf = clamp_t(unsigned long, max_perf, cpudata->min_limit_perf,
 			cpudata->max_limit_perf);
 	min_perf = clamp_t(unsigned long, min_perf, cpudata->min_limit_perf,
 			cpudata->max_limit_perf);
-
-	WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
-	WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
-
 	value = READ_ONCE(cpudata->cppc_req_cached);
 
 	if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq/amd-pstate: Fix setting scaling max/min freq values
  2024-01-19 11:33 [PATCH] cpufreq/amd-pstate: Fix setting scaling max/min freq values Mario Limonciello
@ 2024-01-22 14:57 ` Wyes Karny
  2024-01-22 19:37   ` Rafael J. Wysocki
  2024-01-22 23:52 ` Dan Martins
  1 sibling, 1 reply; 4+ messages in thread
From: Wyes Karny @ 2024-01-22 14:57 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: ray.huang, rafael, viresh.kumar, linux-pm, linux-kernel, stable

On Sat, Jan 20, 2024 at 5:49 AM Mario Limonciello
<mario.limonciello@amd.com> wrote:
>
> Scaling min/max freq values were being cached and lagging a setting
> each time.  Fix the ordering of the clamp call to ensure they work.
>
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931
> Cc: stable@vger.kernel.org
> Cc: wkarny@gmail.com
> Fixes: febab20caeba ("cpufreq/amd-pstate: Fix scaling_min_freq and scaling_max_freq update")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Reviewed-by: Wyes Karny <wkarny@gmail.com>

> ---
>  drivers/cpufreq/amd-pstate.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 1f6186475715..1791d37fbc53 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -1232,14 +1232,13 @@ static void amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
>         max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
>         min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
>
> +       WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
> +       WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
> +
>         max_perf = clamp_t(unsigned long, max_perf, cpudata->min_limit_perf,
>                         cpudata->max_limit_perf);
>         min_perf = clamp_t(unsigned long, min_perf, cpudata->min_limit_perf,
>                         cpudata->max_limit_perf);
> -
> -       WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
> -       WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
> -
>         value = READ_ONCE(cpudata->cppc_req_cached);
>
>         if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)
> --
> 2.34.1
>


-- 
Thanks & Regards
Wyes

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq/amd-pstate: Fix setting scaling max/min freq values
  2024-01-22 14:57 ` Wyes Karny
@ 2024-01-22 19:37   ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2024-01-22 19:37 UTC (permalink / raw)
  To: Wyes Karny, Mario Limonciello
  Cc: ray.huang, rafael, viresh.kumar, linux-pm, linux-kernel, stable

On Mon, Jan 22, 2024 at 3:57 PM Wyes Karny <wkarny@gmail.com> wrote:
>
> On Sat, Jan 20, 2024 at 5:49 AM Mario Limonciello
> <mario.limonciello@amd.com> wrote:
> >
> > Scaling min/max freq values were being cached and lagging a setting
> > each time.  Fix the ordering of the clamp call to ensure they work.
> >
> > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931
> > Cc: stable@vger.kernel.org
> > Cc: wkarny@gmail.com
> > Fixes: febab20caeba ("cpufreq/amd-pstate: Fix scaling_min_freq and scaling_max_freq update")
> > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>
> Reviewed-by: Wyes Karny <wkarny@gmail.com>
>
> > ---
> >  drivers/cpufreq/amd-pstate.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> > index 1f6186475715..1791d37fbc53 100644
> > --- a/drivers/cpufreq/amd-pstate.c
> > +++ b/drivers/cpufreq/amd-pstate.c
> > @@ -1232,14 +1232,13 @@ static void amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
> >         max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
> >         min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
> >
> > +       WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
> > +       WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
> > +
> >         max_perf = clamp_t(unsigned long, max_perf, cpudata->min_limit_perf,
> >                         cpudata->max_limit_perf);
> >         min_perf = clamp_t(unsigned long, min_perf, cpudata->min_limit_perf,
> >                         cpudata->max_limit_perf);
> > -
> > -       WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
> > -       WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
> > -
> >         value = READ_ONCE(cpudata->cppc_req_cached);
> >
> >         if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)
> > --

Applied as 6.8-rc material, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq/amd-pstate: Fix setting scaling max/min freq values
  2024-01-19 11:33 [PATCH] cpufreq/amd-pstate: Fix setting scaling max/min freq values Mario Limonciello
  2024-01-22 14:57 ` Wyes Karny
@ 2024-01-22 23:52 ` Dan Martins
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Martins @ 2024-01-22 23:52 UTC (permalink / raw)
  To: ray.huang, rafael, Mario Limonciello
  Cc: viresh.kumar, linux-pm, linux-kernel, Mario Limonciello, stable, wkarny

On Friday, January 19, 2024 6:33:19 A.M. EST Mario Limonciello wrote:
> Scaling min/max freq values were being cached and lagging a setting
> each time.  Fix the ordering of the clamp call to ensure they work.
> 
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931
> Cc: stable@vger.kernel.org
> Cc: wkarny@gmail.com
> Fixes: febab20caeba ("cpufreq/amd-pstate: Fix scaling_min_freq and
> scaling_max_freq update") Signed-off-by: Mario Limonciello
> <mario.limonciello@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 1f6186475715..1791d37fbc53 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -1232,14 +1232,13 @@ static void amd_pstate_epp_update_limit(struct
> cpufreq_policy *policy) max_limit_perf = div_u64(policy->max *
> cpudata->highest_perf, cpudata->max_freq); min_limit_perf =
> div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
> 
> +	WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
> +	WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
> +
>  	max_perf = clamp_t(unsigned long, max_perf, cpudata-
>min_limit_perf,
>  			cpudata->max_limit_perf);
>  	min_perf = clamp_t(unsigned long, min_perf, cpudata-
>min_limit_perf,
>  			cpudata->max_limit_perf);
> -
> -	WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
> -	WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
> -
>  	value = READ_ONCE(cpudata->cppc_req_cached);
> 
>  	if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)

Tested-by: Dan Martins <dan.martins@zoho.com>




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-22 23:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-19 11:33 [PATCH] cpufreq/amd-pstate: Fix setting scaling max/min freq values Mario Limonciello
2024-01-22 14:57 ` Wyes Karny
2024-01-22 19:37   ` Rafael J. Wysocki
2024-01-22 23:52 ` Dan Martins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).