Skip to content

Commit

Permalink
feat(armv8/psci): Handle unexpected standby behavior
Browse files Browse the repository at this point in the history
The development target zcu104 does not wake up on interrupts after emiting PSCI standby calls to TF-A. We should understand why. To circunvent this, we allow platforms to delcare standby is not supported and fallback to wfi

Signed-off-by: David Cerdeira <[email protected]>
  • Loading branch information
DavidMCerdeira committed Oct 2, 2024
1 parent f35d572 commit 2f33b23
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/arch/armv8/armv8-a/psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ void psci_wake(uint32_t handler_id)

int32_t psci_standby()
{
/* We've observed that some platforms behave unexpectedly when performing
* standby. In these cases, after standby, the CPU cores are not awaken
* by interrupts. */
if (!DEFINED(PLAT_PSCI_STANDBY_NOT_SUPPORTED)) {
return PSCI_E_NOT_SUPPORTED
}
/* only apply request to core level */
uint32_t pwr_state_aux = PSCI_POWER_STATE_LVL_0 | PSCI_STATE_TYPE_STANDBY;

Expand Down
13 changes: 5 additions & 8 deletions src/arch/armv8/psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,11 @@ static int32_t psci_cpu_suspend_handler(uint32_t power_state, unsigned long entr
ret = psci_power_down(PSCI_WAKEUP_POWERDOWN);
} else {
// PSCI_STATE_TYPE_STANDBY:
/**
* TODO: ideally we would emmit a standby request to PSCI (currently, ATF), but when we
* do, we do not wake up on interrupts on the current development target zcu104. We should
* understand why. To circunvent this, we directly emmit a wfi
*/
// ret = psci_standby();
__asm__ volatile("wfi\n\r");
ret = PSCI_E_SUCCESS;
ret = psci_standby();
if(ret == PSCI_E_NOT_SUPPORTED){
__asm__ volatile("wfi\n\r");
ret = PSCI_E_SUCCESS;
}
}

return ret;
Expand Down
2 changes: 2 additions & 0 deletions src/platform/zcu102/inc/plat/psci.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
#define PSCI_STATE_TYPE_BIT (1UL << 30)

#define PLAT_PSCI_STANDBY_NOT_SUPPORTED

#endif // __PLAT_PSCI_H__

0 comments on commit 2f33b23

Please sign in to comment.