[next] cpufreq: amd-pstate: Fix min_perf assignment in amd_pstate_adjust_perf()

Message ID 41f82085-8ea9-4ffa-a93a-8e39ce0f4c27@mailbox.org
State New
Headers
Series [next] cpufreq: amd-pstate: Fix min_perf assignment in amd_pstate_adjust_perf() |

Commit Message

Tor Vic Feb. 7, 2024, 1:09 p.m. UTC
  In the function amd_pstate_adjust_perf(), the 'min_perf' variable is set
to 'highest_perf' instead of 'lowest_perf'.

Fixes: 1d215f0319c2 ("cpufreq: amd-pstate: Add fast switch function for 
AMD P-State")
Reported-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Signed-off-by: Tor Vic <torvic9@mailbox.org>
---
IIRC, this was first reported by Oleksandr, hence the 'Reported-by' tag.
---
  drivers/cpufreq/amd-pstate.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Yuan, Perry Feb. 7, 2024, 1:54 p.m. UTC | #1
[AMD Official Use Only - General]

 Hi Tor,

> -----Original Message-----
> From: Tor Vic <torvic9@mailbox.org>
> Sent: Wednesday, February 7, 2024 9:09 PM
> To: Huang, Ray <Ray.Huang@amd.com>; Yuan, Perry
> <Perry.Yuan@amd.com>; rafael@kernel.org
> Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>; linux-
> pm@vger.kernel.org; Oleksandr Natalenko <oleksandr@natalenko.name>
> Subject: [PATCH][next] cpufreq: amd-pstate: Fix min_perf assignment in
> amd_pstate_adjust_perf()
>
> In the function amd_pstate_adjust_perf(), the 'min_perf' variable is set to
> 'highest_perf' instead of 'lowest_perf'.
>
> Fixes: 1d215f0319c2 ("cpufreq: amd-pstate: Add fast switch function for AMD
> P-State")
> Reported-by: Oleksandr Natalenko <oleksandr@natalenko.name>
> Signed-off-by: Tor Vic <torvic9@mailbox.org>
> ---
> IIRC, this was first reported by Oleksandr, hence the 'Reported-by' tag.
> ---
>   drivers/cpufreq/amd-pstate.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 08e112444c27..aa5e57e27d2b 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -577,7 +577,7 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
>       if (target_perf < capacity)
>               des_perf = DIV_ROUND_UP(cap_perf * target_perf,
> capacity);
>
> -     min_perf = READ_ONCE(cpudata->highest_perf);
> +     min_perf = READ_ONCE(cpudata->lowest_perf);
>       if (_min_perf < capacity)
>               min_perf = DIV_ROUND_UP(cap_perf * _min_perf, capacity);
>
> --
> 2.43.0

Thanks for the fix!

Reviewed-by: Perry Yuan <Perry.Yuan@amd.com>
  
Tor Vic Feb. 7, 2024, 2:07 p.m. UTC | #2
On 2/7/24 14:54, Yuan, Perry wrote:
> [AMD Official Use Only - General]
> 
>   Hi Tor,
> 
>> -----Original Message-----
>> From: Tor Vic <torvic9@mailbox.org>
>> Sent: Wednesday, February 7, 2024 9:09 PM
>> To: Huang, Ray <Ray.Huang@amd.com>; Yuan, Perry
>> <Perry.Yuan@amd.com>; rafael@kernel.org
>> Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>; linux-
>> pm@vger.kernel.org; Oleksandr Natalenko <oleksandr@natalenko.name>
>> Subject: [PATCH][next] cpufreq: amd-pstate: Fix min_perf assignment in
>> amd_pstate_adjust_perf()
>>
>> In the function amd_pstate_adjust_perf(), the 'min_perf' variable is set to
>> 'highest_perf' instead of 'lowest_perf'.
>>
>> Fixes: 1d215f0319c2 ("cpufreq: amd-pstate: Add fast switch function for AMD
>> P-State")
>> Reported-by: Oleksandr Natalenko <oleksandr@natalenko.name>
>> Signed-off-by: Tor Vic <torvic9@mailbox.org>
>> ---
>> IIRC, this was first reported by Oleksandr, hence the 'Reported-by' tag.
>> ---
>>    drivers/cpufreq/amd-pstate.c | 2 +-
>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
>> index 08e112444c27..aa5e57e27d2b 100644
>> --- a/drivers/cpufreq/amd-pstate.c
>> +++ b/drivers/cpufreq/amd-pstate.c
>> @@ -577,7 +577,7 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
>>        if (target_perf < capacity)
>>                des_perf = DIV_ROUND_UP(cap_perf * target_perf,
>> capacity);
>>
>> -     min_perf = READ_ONCE(cpudata->highest_perf);
>> +     min_perf = READ_ONCE(cpudata->lowest_perf);
>>        if (_min_perf < capacity)
>>                min_perf = DIV_ROUND_UP(cap_perf * _min_perf, capacity);
>>
>> --
>> 2.43.0
> 
> Thanks for the fix!

I think this is actually for stable and mainline too, not only for -next.
Should I resend with 'Cc: stable' tag and your Reviewed-by?

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

Patch

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 08e112444c27..aa5e57e27d2b 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -577,7 +577,7 @@  static void amd_pstate_adjust_perf(unsigned int cpu,
  	if (target_perf < capacity)
  		des_perf = DIV_ROUND_UP(cap_perf * target_perf, capacity);

-	min_perf = READ_ONCE(cpudata->highest_perf);
+	min_perf = READ_ONCE(cpudata->lowest_perf);
  	if (_min_perf < capacity)
  		min_perf = DIV_ROUND_UP(cap_perf * _min_perf, capacity);