Skip to contentSkip to conversation

ACPI: arm64: cpuidle: Tolerate platforms with no deep PSCI idle states

PATCH Applied Breno Leitao 3 participants 5 messages Apr 20 – Apr 27

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

PATCH 1/1 ACPI: arm64: cpuidle: Tolerate platforms with no deep PSCI idle states

Commit cac173bea57d ("ACPI: processor: idle: Rework the handling of acpi_processor_ffh_lpi_probe()") moved the acpi_processor_ffh_lpi_probe() call from acpi_processor_setup_cpuidle_dev(), where its return value was ignored, to acpi_processor_get_power_info(), where it is now treated as a hard failure. As a result, platforms where psci_acpi_cpu_init_idle() returned -ENODEV stopped registering any cpuidle states, forcing CPUs to busy-poll when idle.

On NVIDIA Grace (aarch64) systems with PSCIv1.1, pr->power.count is 1 (only WFI, no deep PSCI states beyond it), so the previous "count = pr->power.count - 1; if (count <= 0) return -ENODEV;" check returned -ENODEV for all 72 CPUs and disabled cpuidle entirely.

The lpi_states count is already validated in acpi_processor_get_lpi_info(), so the check here is redundant. Simplify the loop to iterate over lpi_states[1..power.count). When only WFI is present, the loop body simply does not execute and the function returns 0, which is the correct
outcome: there is nothing to validate for FFH and no error to report.

Fixes cac173bea57d ("ACPI: processor: idle: Rework the handling of acpi_processor_ffh_lpi_probe()")
---
 drivers/acpi/arm64/cpuidle.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/acpi/arm64/cpuidle.c +3 -7
index 801f9c4501425..c68a5db8ebba8 100644
@@ -16,7 +16,7 @@
 
 static int psci_acpi_cpu_init_idle(unsigned int cpu)
 {
-	int i, count;
+	int i;
 	struct acpi_lpi_state *lpi;
 	struct acpi_processor *pr = per_cpu(processors, cpu);
 
@@ -30,14 +30,10 @@ static int psci_acpi_cpu_init_idle(unsigned int cpu)
 	if (!psci_ops.cpu_suspend)
 		return -EOPNOTSUPP;
 
-	count = pr->power.count - 1;
-	if (count <= 0)
-		return -ENODEV;
-
-	for (i = 0; i < count; i++) {
+	for (i = 1; i < pr->power.count; i++) {
 		u32 state;
 
-		lpi = &pr->power.lpi_states[i + 1];
+		lpi = &pr->power.lpi_states[i];
 		/*
 		 * Only bits[31:0] represent a PSCI power_state while
 		 * bits[63:32] must be 0x0 as per ARM ACPI FFH Specification

---
base-commit: 1c7cc4904160c6fc6377564140062d68a3dc93a0
change-id: 20260413-ffh-93f68b2f46a3

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 41 lines · Breno Leitao

Commit cac173bea57d ("ACPI: processor: idle: Rework the handling of acpi_processor_ffh_lpi_probe()") moved the acpi_processor_ffh_lpi_probe() call from acpi_processor_setup_cpuidle_dev(), where its return value was ignored, to acpi_processor_get_power_info(), where it is now treated as a hard failure. As a result, platforms where psci_acpi_cpu_init_idle() returned -ENODEV stopped registering any cpuidle states, forcing CPUs to busy-poll when idle.

On NVIDIA Grace (aarch64) systems with PSCIv1.1, pr->power.count is 1 (only WFI, no deep PSCI states beyond it), so the previous "count = pr->power.count - 1; if (count <= 0) return -ENODEV;" check returned -ENODEV for all 72 CPUs and disabled cpuidle entirely.

The lpi_states count is already validated in acpi_processor_get_lpi_info(), so the check here is redundant. Simplify the loop to iterate over lpi_states[1..power.count). When only WFI is present, the loop body simply does not execute and the function returns 0, which is the correct
outcome: there is nothing to validate for FFH and no error to report.

Fixes cac173bea57d ("ACPI: processor: idle: Rework the handling of acpi_processor_ffh_lpi_probe()")
---
 drivers/acpi/arm64/cpuidle.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/acpi/arm64/cpuidle.c +1 -1
index 801f9c4501425..c68a5db8ebba8 100644
@@ -16,7 +16,7 @@
 
 static int psci_acpi_cpu_init_idle(unsigned int cpu)
 {
-	int i, count;
+	int i;
 	struct acpi_lpi_state *lpi;
 	struct acpi_processor *pr = per_cpu(processors, cpu);
 

drivers/acpi/arm64/cpuidle.c static int psci_acpi_cpu_init_idle(unsigned int cpu) · line 36

Quoted 7 lines
drivers/acpi/arm64/cpuidle.c +0 -4
@@ -30,14 +30,10 @@ static int psci_acpi_cpu_init_idle(unsigned int cpu)
 	if (!psci_ops.cpu_suspend)
 		return -EOPNOTSUPP;
 
-	count = pr->power.count - 1;
-	if (count <= 0)
-		return -ENODEV;
-

Does it make sense to retain this check like
if (pr->power.count < 1)
return -EINVAL;

Though I see the assignment to pr->power.count in drivers/acpi/processor_idle.c is through unsigned int. So I am fine even without the above check.

Signature · 2 lines
Regards,
Sudeep
#2 lore raw
Quoted 10 lines · Sudeep Holla

drivers/acpi/arm64/cpuidle.c static int psci_acpi_cpu_init_idle(unsigned int cpu) · line 36

Quoted 4 lines · Breno Leitao
drivers/acpi/arm64/cpuidle.c +0 -4
-	count = pr->power.count - 1;
-	if (count <= 0)
-		return -ENODEV;
-

Does it make sense to retain this check like
if (pr->power.count < 1)
return -EINVAL;

Quoted 2 lines

Though I see the assignment to pr->power.count in drivers/acpi/processor_idle.c is through unsigned int. So I am fine even without the above check.

I don't think the check is necessary. When count is 0 or 1, the loop for (i = 1; i < pr->power.count; i++) body won't execute, and the function will return 0.

This seems like the correct behavior — if there are no FFH PSCI states to validate, there's nothing that should fail.

Additionally, returning -ENODEV would trigger the "Invalid FFH LPI data" error message, which would be misleading since the LPI data isn't invalid, it's just not present.

That said, please take this with a grain of salt since I'm not deeply familiar with _LPI states and their expected behavior.

Thanks for the review,
--breno

maintainer
#3 lore raw
Quoted 11 lines · Breno Leitao
Quoted 10 lines · Sudeep Holla

drivers/acpi/arm64/cpuidle.c static int psci_acpi_cpu_init_idle(unsigned int cpu) · line 36

Quoted 4 lines · Breno Leitao
drivers/acpi/arm64/cpuidle.c +0 -4
-	count = pr->power.count - 1;
-	if (count <= 0)
-		return -ENODEV;
-

Does it make sense to retain this check like
if (pr->power.count < 1)
return -EINVAL;

Quoted 7 lines
Quoted 2 lines

Though I see the assignment to pr->power.count in drivers/acpi/processor_idle.c is through unsigned int. So I am fine even without the above check.

I don't think the check is necessary. When count is 0 or 1, the loop for (i = 1; i < pr->power.count; i++) body won't execute, and the function will return 0.

Yes but the point is to handle invalid pr->power.count(0 or less) which is not possible here though it is signed it because it is assigned from an unsigned int during initialisation.

Quoted 3 lines

This seems like the correct behavior — if there are no FFH PSCI states to validate, there's nothing that should fail.

Agreed, but I was thinking of error in parsing _LPI being propogated here but again that's not happening here.

Quoted 4 lines

Additionally, returning -ENODEV would trigger the "Invalid FFH LPI data" error message, which would be misleading since the LPI data isn't invalid, it's just not present.

The point was to throw that error if _LPI parsing fails.

Quoted 3 lines

That said, please take this with a grain of salt since I'm not deeply familiar with _LPI states and their expected behavior.

No worries, I agree the check I asked for is not needed.

Signature · 2 lines
Regards,
Sudeep
maintainer Applied
#4 lore raw
In reply to Breno Leitao
Quoted 9 lines · Breno Leitao

Commit cac173bea57d ("ACPI: processor: idle: Rework the handling of acpi_processor_ffh_lpi_probe()") moved the acpi_processor_ffh_lpi_probe() call from acpi_processor_setup_cpuidle_dev(), where its return value was ignored, to acpi_processor_get_power_info(), where it is now treated as a hard failure. As a result, platforms where psci_acpi_cpu_init_idle() returned -ENODEV stopped registering any cpuidle states, forcing CPUs to busy-poll when idle.

[...]

Applied to arm64 (for-next/fixes), thanks!

[1/1] ACPI: arm64: cpuidle: Tolerate platforms with no deep PSCI idle states

      https://git.kernel.org/arm64/c/3ea4415015d6