Linux ACPI
 help / color / mirror / Atom feed
* [PATCH v2] ACPI: CPPC: Fix remaining for_each_possible_cpu() to use online CPUs
@ 2026-02-11 21:22 Sean V Kelley
  2026-02-12 11:44 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Sean V Kelley @ 2026-02-11 21:22 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 send_pcc_cmd() and acpi_get_psd_map() still iterate over all
possible CPUs. In acpi_get_psd_map(), encountering an offline CPU
returns -EFAULT, causing cppc_cpufreq initialization to fail.

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

Fix by using for_each_online_cpu() in both functions.

Fixes: 80b8286aeec0 ("ACPI / CPPC: support for batching CPPC requests")
Signed-off-by: Sean V Kelley <skelley@nvidia.com>
---

Notes:
    v2: Also fix for_each_possible_cpu() in send_pcc_cmd() (Rafael)

 drivers/acpi/cppc_acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index a09bdabaa804..0e6ffb188fe7 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -362,7 +362,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd)
 end:
 	if (cmd == CMD_WRITE) {
 		if (unlikely(ret)) {
-			for_each_possible_cpu(i) {
+			for_each_online_cpu(i) {
 				struct cpc_desc *desc = per_cpu(cpc_desc_ptr, i);
 
 				if (!desc)
@@ -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 related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ACPI: CPPC: Fix remaining for_each_possible_cpu() to use online CPUs
  2026-02-11 21:22 [PATCH v2] ACPI: CPPC: Fix remaining for_each_possible_cpu() to use online CPUs Sean V Kelley
@ 2026-02-12 11:44 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2026-02-12 11:44 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 10:23 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 send_pcc_cmd() and acpi_get_psd_map() still iterate over all
> possible CPUs. In acpi_get_psd_map(), encountering an offline CPU
> returns -EFAULT, causing cppc_cpufreq initialization to fail.
>
> This breaks systems booted with "nosmt" or "nosmt=force".
>
> Fix by using for_each_online_cpu() in both functions.
>
> Fixes: 80b8286aeec0 ("ACPI / CPPC: support for batching CPPC requests")
> Signed-off-by: Sean V Kelley <skelley@nvidia.com>
> ---
>
> Notes:
>     v2: Also fix for_each_possible_cpu() in send_pcc_cmd() (Rafael)
>
>  drivers/acpi/cppc_acpi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index a09bdabaa804..0e6ffb188fe7 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -362,7 +362,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd)
>  end:
>         if (cmd == CMD_WRITE) {
>                 if (unlikely(ret)) {
> -                       for_each_possible_cpu(i) {
> +                       for_each_online_cpu(i) {
>                                 struct cpc_desc *desc = per_cpu(cpc_desc_ptr, i);
>
>                                 if (!desc)
> @@ -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;
>
> --

Applied as 7.0-rc material, thanks!

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-11 21:22 [PATCH v2] ACPI: CPPC: Fix remaining for_each_possible_cpu() to use online CPUs Sean V Kelley
2026-02-12 11:44 ` Rafael J. Wysocki

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