mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] acpi-cpufreq: Fix nominal_freq units to KHz in get_max_boost_ratio()
@ 2025-05-29  8:51 Gautham R. Shenoy
  2025-05-29 13:23 ` Rafael J. Wysocki
  0 siblings, 1 reply; 5+ messages in thread
From: Gautham R. Shenoy @ 2025-05-29  8:51 UTC (permalink / raw)
  To: Rafael J . Wysocki, Viresh Kumar, Mario Limonciello, Manu Bretelle
  Cc: linux-pm, linux-kernel, Gautham R. Shenoy

commit 083466754596 ("cpufreq: ACPI: Fix max-frequency computation")
modified get_max_boost_ratio() to return the nominal_freq advertised
in the _CPC object. This was for the purposes of computing the maximum
frequency. The frequencies advertised in _CPC objects are in
MHz. However, cpufreq expects the frequency to be in KHz. Since the
nominal_freq returned by get_max_boost_ratio() was not in KHz but
instead in MHz,the cpuinfo_max_frequency that was computed using this
nominal_freq was incorrect and an invalid value which resulted in
cpufreq reporting the P0 frequency as the cpuinfo_max_freq.

Fix this by converting the nominal_freq to KHz before returning the
same from get_max_boost_ratio().

Reported-by: Manu Bretelle <chantr4@gmail.com>
Closes: https://lore.kernel.org/lkml/aDaB63tDvbdcV0cg@HQ-GR2X1W2P57/
Fixes: 083466754596 ("cpufreq: ACPI: Fix max-frequency computation")
Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
---
 drivers/cpufreq/acpi-cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index d26b610e4f24..76768fe213a9 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -660,7 +660,7 @@ static u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq)
 	nominal_perf = perf_caps.nominal_perf;
 
 	if (nominal_freq)
-		*nominal_freq = perf_caps.nominal_freq;
+		*nominal_freq = perf_caps.nominal_freq * 1000;
 
 	if (!highest_perf || !nominal_perf) {
 		pr_debug("CPU%d: highest or nominal performance missing\n", cpu);
-- 
2.34.1


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

* Re: [PATCH] acpi-cpufreq: Fix nominal_freq units to KHz in get_max_boost_ratio()
  2025-05-29  8:51 [PATCH] acpi-cpufreq: Fix nominal_freq units to KHz in get_max_boost_ratio() Gautham R. Shenoy
@ 2025-05-29 13:23 ` Rafael J. Wysocki
  2025-05-29 16:34   ` Manu Bretelle
  0 siblings, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2025-05-29 13:23 UTC (permalink / raw)
  To: Gautham R. Shenoy
  Cc: Rafael J . Wysocki, Viresh Kumar, Mario Limonciello,
	Manu Bretelle, linux-pm, linux-kernel

On Thu, May 29, 2025 at 10:52 AM Gautham R. Shenoy
<gautham.shenoy@amd.com> wrote:
>
> commit 083466754596 ("cpufreq: ACPI: Fix max-frequency computation")
> modified get_max_boost_ratio() to return the nominal_freq advertised
> in the _CPC object. This was for the purposes of computing the maximum
> frequency. The frequencies advertised in _CPC objects are in
> MHz. However, cpufreq expects the frequency to be in KHz. Since the
> nominal_freq returned by get_max_boost_ratio() was not in KHz but
> instead in MHz,the cpuinfo_max_frequency that was computed using this
> nominal_freq was incorrect and an invalid value which resulted in
> cpufreq reporting the P0 frequency as the cpuinfo_max_freq.
>
> Fix this by converting the nominal_freq to KHz before returning the
> same from get_max_boost_ratio().
>
> Reported-by: Manu Bretelle <chantr4@gmail.com>
> Closes: https://lore.kernel.org/lkml/aDaB63tDvbdcV0cg@HQ-GR2X1W2P57/
> Fixes: 083466754596 ("cpufreq: ACPI: Fix max-frequency computation")
> Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
> ---
>  drivers/cpufreq/acpi-cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index d26b610e4f24..76768fe213a9 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -660,7 +660,7 @@ static u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq)
>         nominal_perf = perf_caps.nominal_perf;
>
>         if (nominal_freq)
> -               *nominal_freq = perf_caps.nominal_freq;
> +               *nominal_freq = perf_caps.nominal_freq * 1000;
>
>         if (!highest_perf || !nominal_perf) {
>                 pr_debug("CPU%d: highest or nominal performance missing\n", cpu);
> --

Applied, thanks!

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

* Re: [PATCH] acpi-cpufreq: Fix nominal_freq units to KHz in get_max_boost_ratio()
  2025-05-29 13:23 ` Rafael J. Wysocki
@ 2025-05-29 16:34   ` Manu Bretelle
  2025-05-29 16:44     ` Limonciello, Mario
  0 siblings, 1 reply; 5+ messages in thread
From: Manu Bretelle @ 2025-05-29 16:34 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Gautham R. Shenoy, Viresh Kumar, Mario Limonciello, linux-pm,
	linux-kernel

On Thu, May 29, 2025 at 6:23 AM Rafael J. Wysocki <rafael@kernel.org> wrote:

>
> Applied, thanks!

Thanks Rafael!

I see it was merged into pm/linux-next, will it make it into the next
5.15 LTS release?
I did not find what the process is for LTS backport and would like to
make sure this trickles
down to LTS kernels.
Thanks

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

* Re: [PATCH] acpi-cpufreq: Fix nominal_freq units to KHz in get_max_boost_ratio()
  2025-05-29 16:34   ` Manu Bretelle
@ 2025-05-29 16:44     ` Limonciello, Mario
  2025-05-29 16:51       ` Manu Bretelle
  0 siblings, 1 reply; 5+ messages in thread
From: Limonciello, Mario @ 2025-05-29 16:44 UTC (permalink / raw)
  To: Manu Bretelle, Rafael J. Wysocki
  Cc: Shenoy, Gautham Ranjal, Viresh Kumar, linux-pm, linux-kernel

On 5/29/25 11:34 AM, Manu Bretelle wrote:
> On Thu, May 29, 2025 at 6:23 AM Rafael J. Wysocki <rafael@kernel.org> wrote:
> 
>>
>> Applied, thanks!
> 
> Thanks Rafael!
> 
> I see it was merged into pm/linux-next, will it make it into the next
> 5.15 LTS release?
> I did not find what the process is for LTS backport and would like to
> make sure this trickles
> down to LTS kernels.
> Thanks

Here is the policy for stable:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html

It doesn't explicitly contain a stable tag, but because it has a fixes 
tag it's very likely that it gets backported by AUTOSEL later.



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

* Re: [PATCH] acpi-cpufreq: Fix nominal_freq units to KHz in get_max_boost_ratio()
  2025-05-29 16:44     ` Limonciello, Mario
@ 2025-05-29 16:51       ` Manu Bretelle
  0 siblings, 0 replies; 5+ messages in thread
From: Manu Bretelle @ 2025-05-29 16:51 UTC (permalink / raw)
  To: Limonciello, Mario
  Cc: Rafael J. Wysocki, Shenoy, Gautham Ranjal, Viresh Kumar,
	linux-pm, linux-kernel

> Here is the policy for stable:
> https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
>
> It doesn't explicitly contain a stable tag, but because it has a fixes
> tag it's very likely that it gets backported by AUTOSEL later.
>
>
Thanks Mario!

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

end of thread, other threads:[~2025-05-29 16:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-29  8:51 [PATCH] acpi-cpufreq: Fix nominal_freq units to KHz in get_max_boost_ratio() Gautham R. Shenoy
2025-05-29 13:23 ` Rafael J. Wysocki
2025-05-29 16:34   ` Manu Bretelle
2025-05-29 16:44     ` Limonciello, Mario
2025-05-29 16:51       ` Manu Bretelle

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

all inboxes | Powered by JetHome®