mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ACPI: CPPC: Fix acpi_get_psd_map() to iterate only online CPUs
@ 2026-02-11 20:48 Sean V Kelley
  2026-02-11 21:06 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Sean V Kelley @ 2026-02-11 20:48 UTC (permalink / raw)
  To: rafael
  Cc: lenb, pprakash, gautham.shenoy, jamien, mochs, linux-acpi,
	linux-kernel, Sean V Kelley

per_cpu(cpc_desc_ptr, cpu) object is initialized for only the online
CPUs via acpi_soft_cpu_online() -> __acpi_processor_start() ->
acpi_cppc_processor_probe().

However the function acpi_get_psd_map() iterates over all possible CPUs
when building the P-state domain map. When it encounters an offline CPU,
it returns -EFAULT, causing cppc_cpufreq initialization to fail.

This breaks systems booted with "nosmt" or "nosmt=force".

Fix by using for_each_online_cpu() so that only CPUs with valid CPC
descriptors are considered.

Fixes: 80b8286aeec0 ("ACPI / CPPC: support for batching CPPC requests")
Signed-off-by: Sean V Kelley <skelley@nvidia.com>
---
 drivers/acpi/cppc_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index a09bdabaa804..e7cfd4cf029a 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -524,7 +524,7 @@ int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data)
 	else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY)
 		cpu_data->shared_type = CPUFREQ_SHARED_TYPE_ANY;
 
-	for_each_possible_cpu(i) {
+	for_each_online_cpu(i) {
 		if (i == cpu)
 			continue;
 
-- 
2.43.0


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

* Re: [PATCH] ACPI: CPPC: Fix acpi_get_psd_map() to iterate only online CPUs
  2026-02-11 20:48 [PATCH] ACPI: CPPC: Fix acpi_get_psd_map() to iterate only online CPUs Sean V Kelley
@ 2026-02-11 21:06 ` Rafael J. Wysocki
  2026-02-11 21:14   ` Sean Kelley
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2026-02-11 21:06 UTC (permalink / raw)
  To: Sean V Kelley
  Cc: rafael, lenb, pprakash, gautham.shenoy, jamien, mochs,
	linux-acpi, linux-kernel

On Wed, Feb 11, 2026 at 9:49 PM Sean V Kelley <skelley@nvidia.com> wrote:
>
> per_cpu(cpc_desc_ptr, cpu) object is initialized for only the online
> CPUs via acpi_soft_cpu_online() -> __acpi_processor_start() ->
> acpi_cppc_processor_probe().
>
> However the function acpi_get_psd_map() iterates over all possible CPUs
> when building the P-state domain map. When it encounters an offline CPU,
> it returns -EFAULT, causing cppc_cpufreq initialization to fail.
>
> This breaks systems booted with "nosmt" or "nosmt=force".
>
> Fix by using for_each_online_cpu() so that only CPUs with valid CPC
> descriptors are considered.

Thanks for the patch, but there's one more instance of this in send_pcc_cmd().

Maybe fix both in one go while at it?

> Fixes: 80b8286aeec0 ("ACPI / CPPC: support for batching CPPC requests")
> Signed-off-by: Sean V Kelley <skelley@nvidia.com>
> ---
>  drivers/acpi/cppc_acpi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index a09bdabaa804..e7cfd4cf029a 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -524,7 +524,7 @@ int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data)
>         else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY)
>                 cpu_data->shared_type = CPUFREQ_SHARED_TYPE_ANY;
>
> -       for_each_possible_cpu(i) {
> +       for_each_online_cpu(i) {
>                 if (i == cpu)
>                         continue;
>
> --

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

* Re: [PATCH] ACPI: CPPC: Fix acpi_get_psd_map() to iterate only online CPUs
  2026-02-11 21:06 ` Rafael J. Wysocki
@ 2026-02-11 21:14   ` Sean Kelley
  0 siblings, 0 replies; 3+ messages in thread
From: Sean Kelley @ 2026-02-11 21:14 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: lenb, pprakash, gautham.shenoy, jamien, mochs, linux-acpi, linux-kernel

On 2/11/26 1:06 PM, Rafael J. Wysocki wrote:
> On Wed, Feb 11, 2026 at 9:49 PM Sean V Kelley <skelley@nvidia.com> wrote:
>>
>> per_cpu(cpc_desc_ptr, cpu) object is initialized for only the online
>> CPUs via acpi_soft_cpu_online() -> __acpi_processor_start() ->
>> acpi_cppc_processor_probe().
>>
>> However the function acpi_get_psd_map() iterates over all possible CPUs
>> when building the P-state domain map. When it encounters an offline CPU,
>> it returns -EFAULT, causing cppc_cpufreq initialization to fail.
>>
>> This breaks systems booted with "nosmt" or "nosmt=force".
>>
>> Fix by using for_each_online_cpu() so that only CPUs with valid CPC
>> descriptors are considered.
> 
> Thanks for the patch, but there's one more instance of this in send_pcc_cmd().
> 
> Maybe fix both in one go while at it?

Good catch. Will do.

Sean

> 
>> Fixes: 80b8286aeec0 ("ACPI / CPPC: support for batching CPPC requests")
>> Signed-off-by: Sean V Kelley <skelley@nvidia.com>
>> ---
>>   drivers/acpi/cppc_acpi.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
>> index a09bdabaa804..e7cfd4cf029a 100644
>> --- a/drivers/acpi/cppc_acpi.c
>> +++ b/drivers/acpi/cppc_acpi.c
>> @@ -524,7 +524,7 @@ int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data)
>>          else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY)
>>                  cpu_data->shared_type = CPUFREQ_SHARED_TYPE_ANY;
>>
>> -       for_each_possible_cpu(i) {
>> +       for_each_online_cpu(i) {
>>                  if (i == cpu)
>>                          continue;
>>
>> --


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

end of thread, other threads:[~2026-02-11 21:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-11 20:48 [PATCH] ACPI: CPPC: Fix acpi_get_psd_map() to iterate only online CPUs Sean V Kelley
2026-02-11 21:06 ` Rafael J. Wysocki
2026-02-11 21:14   ` Sean Kelley

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®