diff mbox series

[v2] cpufreq/amd-pstate: Fix the return value of amd_pstate_fast_switch()

Message ID 20231127111121.400-1-gautham.shenoy@amd.com (mailing list archive)
State Mainlined, archived
Headers show
Series [v2] cpufreq/amd-pstate: Fix the return value of amd_pstate_fast_switch() | expand

Commit Message

Gautham R. Shenoy Nov. 27, 2023, 11:11 a.m. UTC
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")
Acked-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Wyes Karny <wyes.karny@amd.com>
Reviewed-by: Perry Yuan <perry.yuan@amd.com>
Cc: stable@vger.kernel.org # v6.4+
Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Rafael J. Wysocki Nov. 28, 2023, 2:09 p.m. UTC | #1
On Mon, Nov 27, 2023 at 12:11 PM Gautham R. Shenoy
<gautham.shenoy@amd.com> 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")
> Acked-by: Huang Rui <ray.huang@amd.com>
> Reviewed-by: Wyes Karny <wyes.karny@amd.com>
> Reviewed-by: Perry Yuan <perry.yuan@amd.com>
> Cc: stable@vger.kernel.org # v6.4+
> 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,
> --

Applied as 6.7-rc material, thanks!

BTW, if you are aware of any pending AMD P-state fixes for 6.7, please
let me know.
diff mbox series

Patch

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,