Skip to contentSkip to conversation

ACPI: CPPC: Fix acpi_get_psd_map() to iterate only online CPUs

PATCH In review Sean V Kelley 2 participants 3 messages Feb 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: CPPC: Fix acpi_get_psd_map() to iterate only online CPUs

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")
---
 drivers/acpi/cppc_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +1 -1
index a09bdabaa804..e7cfd4cf029a 100644
@@ -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;
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 5 lines · 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().

Quoted 8 lines

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?

Quoted 20 lines
Fixes 80b8286aeec0 ("ACPI / CPPC: support for batching CPPC requests")
---
 drivers/acpi/cppc_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +1 -2
index a09bdabaa804..e7cfd4cf029a 100644
@@ -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 lore raw
Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · 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.

Quoted 8 lines
Quoted 4 lines

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

Quoted 21 lines
Quoted 21 lines
Fixes 80b8286aeec0 ("ACPI / CPPC: support for batching CPPC requests")
---
  drivers/acpi/cppc_acpi.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +1 -2
index a09bdabaa804..e7cfd4cf029a 100644
@@ -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;
 
--