From a5d7602167597381376ba65da5b71bf0e46b3993 Mon Sep 17 00:00:00 2001 From: David Cerdeira Date: Thu, 26 Sep 2024 17:18:18 +0100 Subject: [PATCH] feat(armv8/psci): Handle unexpected powerdown behavior We've observed that some platforms behave unexpectedly when performing power down. In these cases, after powerdown, the CPU cores are not awaken by interrupts as expected by Bao. This commit solve this, by adding the ability to skip the powerdown firmware call, instead relying on the fallback mechanism of using standby. Signed-off-by: David Cerdeira --- src/arch/armv8/armv8-a/cpu.c | 11 +---------- src/arch/armv8/armv8-a/psci.c | 7 +++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/arch/armv8/armv8-a/cpu.c b/src/arch/armv8/armv8-a/cpu.c index 32710cc2b..227a8f7be 100644 --- a/src/arch/armv8/armv8-a/cpu.c +++ b/src/arch/armv8/armv8-a/cpu.c @@ -31,16 +31,7 @@ void cpu_arch_profile_idle() { int64_t err = psci_power_down(PSCI_WAKEUP_IDLE); if (err) { - switch (err) { - case PSCI_E_NOT_SUPPORTED: - /** - * If power down is not supported let's just wait for an interrupt - */ - __asm__ volatile("wfi"); - break; - default: - ERROR("PSCI cpu%d power down failed with error %ld", cpu()->id, err); - } + ERROR("PSCI cpu%d power down failed with error %ld", cpu()->id, err); } /** diff --git a/src/arch/armv8/armv8-a/psci.c b/src/arch/armv8/armv8-a/psci.c index da8cf0418..1f39af007 100644 --- a/src/arch/armv8/armv8-a/psci.c +++ b/src/arch/armv8/armv8-a/psci.c @@ -90,6 +90,13 @@ int32_t psci_standby() int32_t psci_power_down(enum wakeup_reason reason) { + /* We've observed that some platforms behave unexpectedly when performing + * power down. In these cases, after powerdown, the CPU cores are not awaken + * by interrupts as expected by Bao. */ + if (DEFINED(PLAT_PSCI_POWERDOWN_NOT_SUPPORTED)) { + return psci_standby(); + } + extern void psci_boot_entry(unsigned long x0); uint32_t pwr_state_aux = PSCI_POWER_STATE_LVL_0 | PSCI_STATE_TYPE_POWERDOWN;