public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq/amd-pstate: Fix the return value of amd_pstate_fast_switch()
@ 2023-11-23  8:27 Gautham R. Shenoy
  2023-11-23  8:54 ` Yuan, Perry
  2023-11-24  4:23 ` Wyes Karny
  0 siblings, 2 replies; 5+ messages in thread
From: Gautham R. Shenoy @ 2023-11-23  8:27 UTC (permalink / raw)
  To: Wyes Karny, Huang Rui, Mario Limonciello, Perry Yuan,
	Rafael J . Wysocki, Viresh Kumar
  Cc: linux-pm, linux-kernel, Gautham R. Shenoy

cpufreq_driver->fast_switch() callback expects a frequency as a return
value. amd_pstate_fast_switch() was returning the return value of
amd_pstate_update_freq(), which only indicates a success or failure.

Fix this by making amd_pstate_fast_switch() return the target_freq
when the call to amd_pstate_update_freq() is successful, and return
the current frequency from policy->cur when the call to
amd_pstate_update_freq() is unsuccessful.

Fixes: 4badf2eb1e98 ("cpufreq: amd-pstate: Add ->fast_switch() callback")
Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 9a1e194d5cf8..300f81d36291 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -518,7 +518,9 @@ static int amd_pstate_target(struct cpufreq_policy *policy,
 static unsigned int amd_pstate_fast_switch(struct cpufreq_policy *policy,
 				  unsigned int target_freq)
 {
-	return amd_pstate_update_freq(policy, target_freq, true);
+	if (!amd_pstate_update_freq(policy, target_freq, true))
+		return target_freq;
+	return policy->cur;
 }
 
 static void amd_pstate_adjust_perf(unsigned int cpu,
-- 
2.25.1


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

* RE: [PATCH] cpufreq/amd-pstate: Fix the return value of amd_pstate_fast_switch()
  2023-11-23  8:27 [PATCH] cpufreq/amd-pstate: Fix the return value of amd_pstate_fast_switch() Gautham R. Shenoy
@ 2023-11-23  8:54 ` Yuan, Perry
  2023-11-24  4:23 ` Wyes Karny
  1 sibling, 0 replies; 5+ messages in thread
From: Yuan, Perry @ 2023-11-23  8:54 UTC (permalink / raw)
  To: Shenoy, Gautham Ranjal, Karny, Wyes, Huang, Ray,
	Limonciello, Mario, Rafael J . Wysocki, Viresh Kumar
  Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

[AMD Official Use Only - General]

> -----Original Message-----
> From: Shenoy, Gautham Ranjal <gautham.shenoy@amd.com>
> Sent: Thursday, November 23, 2023 4:28 PM
> To: Karny, Wyes <Wyes.Karny@amd.com>; Huang, Ray
> <Ray.Huang@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>;
> Yuan, Perry <Perry.Yuan@amd.com>; Rafael J . Wysocki <rafael@kernel.org>;
> Viresh Kumar <viresh.kumar@linaro.org>
> Cc: linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org; Shenoy, Gautham
> Ranjal <gautham.shenoy@amd.com>
> Subject: [PATCH] cpufreq/amd-pstate: Fix the return value of
> amd_pstate_fast_switch()
>
> cpufreq_driver->fast_switch() callback expects a frequency as a return value.
> amd_pstate_fast_switch() was returning the return value of
> amd_pstate_update_freq(), which only indicates a success or failure.
>
> Fix this by making amd_pstate_fast_switch() return the target_freq when the
> call to amd_pstate_update_freq() is successful, and return the current
> frequency from policy->cur when the call to
> amd_pstate_update_freq() is unsuccessful.
>
> Fixes: 4badf2eb1e98 ("cpufreq: amd-pstate: Add ->fast_switch() callback")
> Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 9a1e194d5cf8..300f81d36291 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -518,7 +518,9 @@ static int amd_pstate_target(struct cpufreq_policy
> *policy,  static unsigned int amd_pstate_fast_switch(struct cpufreq_policy
> *policy,
>                                 unsigned int target_freq)
>  {
> -     return amd_pstate_update_freq(policy, target_freq, true);
> +     if (!amd_pstate_update_freq(policy, target_freq, true))
> +             return target_freq;
> +     return policy->cur;
>  }
>
>  static void amd_pstate_adjust_perf(unsigned int cpu,
> --
> 2.25.1

LGTM
Thank you for the fix.

Reviewed-by: Perry Yuan <perry.yuan@amd.com>

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

* Re: [PATCH] cpufreq/amd-pstate: Fix the return value of amd_pstate_fast_switch()
  2023-11-23  8:27 [PATCH] cpufreq/amd-pstate: Fix the return value of amd_pstate_fast_switch() Gautham R. Shenoy
  2023-11-23  8:54 ` Yuan, Perry
@ 2023-11-24  4:23 ` Wyes Karny
  2023-11-24  7:31   ` Huang Rui
  1 sibling, 1 reply; 5+ messages in thread
From: Wyes Karny @ 2023-11-24  4:23 UTC (permalink / raw)
  To: Gautham R. Shenoy
  Cc: Huang Rui, Mario Limonciello, Perry Yuan, Rafael J . Wysocki,
	Viresh Kumar, linux-pm, linux-kernel

On 23 Nov 13:57, Gautham R. Shenoy wrote:
> cpufreq_driver->fast_switch() callback expects a frequency as a return
> value. amd_pstate_fast_switch() was returning the return value of
> amd_pstate_update_freq(), which only indicates a success or failure.
> 
> Fix this by making amd_pstate_fast_switch() return the target_freq
> when the call to amd_pstate_update_freq() is successful, and return
> the current frequency from policy->cur when the call to
> amd_pstate_update_freq() is unsuccessful.
> 
> Fixes: 4badf2eb1e98 ("cpufreq: amd-pstate: Add ->fast_switch() callback")

Reviewed-by: Wyes Karny <wyes.karny@amd.com>

> Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 9a1e194d5cf8..300f81d36291 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -518,7 +518,9 @@ static int amd_pstate_target(struct cpufreq_policy *policy,
>  static unsigned int amd_pstate_fast_switch(struct cpufreq_policy *policy,
>  				  unsigned int target_freq)
>  {
> -	return amd_pstate_update_freq(policy, target_freq, true);
> +	if (!amd_pstate_update_freq(policy, target_freq, true))
> +		return target_freq;
> +	return policy->cur;
>  }
>  
>  static void amd_pstate_adjust_perf(unsigned int cpu,
> -- 
> 2.25.1
> 

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

* Re: [PATCH] cpufreq/amd-pstate: Fix the return value of amd_pstate_fast_switch()
  2023-11-24  4:23 ` Wyes Karny
@ 2023-11-24  7:31   ` Huang Rui
  2023-11-24 10:25     ` Gautham R. Shenoy
  0 siblings, 1 reply; 5+ messages in thread
From: Huang Rui @ 2023-11-24  7:31 UTC (permalink / raw)
  To: Karny, Wyes, Shenoy, Gautham Ranjal
  Cc: Limonciello, Mario, Yuan, Perry, Rafael J . Wysocki, Viresh Kumar,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

On Fri, Nov 24, 2023 at 12:23:58PM +0800, Karny, Wyes wrote:
> On 23 Nov 13:57, Gautham R. Shenoy wrote:
> > cpufreq_driver->fast_switch() callback expects a frequency as a return
> > value. amd_pstate_fast_switch() was returning the return value of
> > amd_pstate_update_freq(), which only indicates a success or failure.
> > 
> > Fix this by making amd_pstate_fast_switch() return the target_freq
> > when the call to amd_pstate_update_freq() is successful, and return
> > the current frequency from policy->cur when the call to
> > amd_pstate_update_freq() is unsuccessful.
> > 
> > Fixes: 4badf2eb1e98 ("cpufreq: amd-pstate: Add ->fast_switch() callback")
> 
> Reviewed-by: Wyes Karny <wyes.karny@amd.com>
> 

Acked-by: Huang Rui <ray.huang@amd.com>

Do you want to cc stable mailing list to fix it in stable kernels?

Thanks,
Ray

> > Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
> > ---
> >  drivers/cpufreq/amd-pstate.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> > index 9a1e194d5cf8..300f81d36291 100644
> > --- a/drivers/cpufreq/amd-pstate.c
> > +++ b/drivers/cpufreq/amd-pstate.c
> > @@ -518,7 +518,9 @@ static int amd_pstate_target(struct cpufreq_policy *policy,
> >  static unsigned int amd_pstate_fast_switch(struct cpufreq_policy *policy,
> >  				  unsigned int target_freq)
> >  {
> > -	return amd_pstate_update_freq(policy, target_freq, true);
> > +	if (!amd_pstate_update_freq(policy, target_freq, true))
> > +		return target_freq;
> > +	return policy->cur;
> >  }
> >  
> >  static void amd_pstate_adjust_perf(unsigned int cpu,
> > -- 
> > 2.25.1
> > 

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

* Re: [PATCH] cpufreq/amd-pstate: Fix the return value of amd_pstate_fast_switch()
  2023-11-24  7:31   ` Huang Rui
@ 2023-11-24 10:25     ` Gautham R. Shenoy
  0 siblings, 0 replies; 5+ messages in thread
From: Gautham R. Shenoy @ 2023-11-24 10:25 UTC (permalink / raw)
  To: Huang Rui
  Cc: Karny, Wyes, Limonciello, Mario, Yuan, Perry, Rafael J . Wysocki,
	Viresh Kumar, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Fri, Nov 24, 2023 at 03:31:34PM +0800, Huang Rui wrote:
> On Fri, Nov 24, 2023 at 12:23:58PM +0800, Karny, Wyes wrote:
> > On 23 Nov 13:57, Gautham R. Shenoy wrote:
> > > cpufreq_driver->fast_switch() callback expects a frequency as a return
> > > value. amd_pstate_fast_switch() was returning the return value of
> > > amd_pstate_update_freq(), which only indicates a success or failure.
> > > 
> > > Fix this by making amd_pstate_fast_switch() return the target_freq
> > > when the call to amd_pstate_update_freq() is successful, and return
> > > the current frequency from policy->cur when the call to
> > > amd_pstate_update_freq() is unsuccessful.
> > > 
> > > Fixes: 4badf2eb1e98 ("cpufreq: amd-pstate: Add ->fast_switch() callback")
> > 
> > Reviewed-by: Wyes Karny <wyes.karny@amd.com>
> > 
> 
> Acked-by: Huang Rui <ray.huang@amd.com>

Thanks!
> 
> Do you want to cc stable mailing list to fix it in stable kernels?

Yes, I forgot to do that. I will send a v2 having collected your
Acked-by and the Reviewed-by's from Perry and Wyes.

> 
> Thanks,
> Ray

--
Thanks and Regards
gautham.

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

end of thread, other threads:[~2023-11-24 10:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-23  8:27 [PATCH] cpufreq/amd-pstate: Fix the return value of amd_pstate_fast_switch() Gautham R. Shenoy
2023-11-23  8:54 ` Yuan, Perry
2023-11-24  4:23 ` Wyes Karny
2023-11-24  7:31   ` Huang Rui
2023-11-24 10:25     ` Gautham R. Shenoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox