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/zcu102 and Ultra96 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 declare
standby is not supported and fallback to wfi.

Signed-off-by: David Cerdeira <[email protected]>
  • Loading branch information
DavidMCerdeira authored and josecm committed Oct 3, 2024
1 parent a5d7602 commit 11b03d5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
10 changes: 10 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,16 @@ 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)) {
/**
* If standby is not supported let's just wait for an interrupt
*/
__asm__ volatile("wfi");
return PSCI_E_SUCCESS;
}
/* only apply request to core level */
uint32_t pwr_state_aux = PSCI_POWER_STATE_LVL_0 | PSCI_STATE_TYPE_STANDBY;

Expand Down
9 changes: 1 addition & 8 deletions src/arch/armv8/psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,7 @@ 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();
}

return ret;
Expand Down
14 changes: 8 additions & 6 deletions src/platform/ultra96/inc/plat/psci.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
#ifndef __PLAT_PSCI_H__
#define __PLAT_PSCI_H__

#define PSCI_POWER_STATE_LVL_0 0x0000000
#define PSCI_POWER_STATE_LVL_1 0x1000000
#define PSCI_POWER_STATE_LVL_2 0x2000000
#define PSCI_STATE_TYPE_STANDBY 0x00000
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
#define PSCI_STATE_TYPE_BIT (1UL << 30)
#define PSCI_POWER_STATE_LVL_0 0x0000000
#define PSCI_POWER_STATE_LVL_1 0x1000000
#define PSCI_POWER_STATE_LVL_2 0x2000000
#define PSCI_STATE_TYPE_STANDBY 0x00000
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
#define PSCI_STATE_TYPE_BIT (1UL << 30)

#define PLAT_PSCI_STANDBY_NOT_SUPPORTED 1

#endif // __PLAT_PSCI_H__
14 changes: 8 additions & 6 deletions src/platform/zcu102/inc/plat/psci.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
#ifndef __PLAT_PSCI_H__
#define __PLAT_PSCI_H__

#define PSCI_POWER_STATE_LVL_0 0x0000000
#define PSCI_POWER_STATE_LVL_1 0x1000000
#define PSCI_POWER_STATE_LVL_2 0x2000000
#define PSCI_STATE_TYPE_STANDBY 0x00000
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
#define PSCI_STATE_TYPE_BIT (1UL << 30)
#define PSCI_POWER_STATE_LVL_0 0x0000000
#define PSCI_POWER_STATE_LVL_1 0x1000000
#define PSCI_POWER_STATE_LVL_2 0x2000000
#define PSCI_STATE_TYPE_STANDBY 0x00000
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
#define PSCI_STATE_TYPE_BIT (1UL << 30)

#define PLAT_PSCI_STANDBY_NOT_SUPPORTED 1

#endif // __PLAT_PSCI_H__
14 changes: 8 additions & 6 deletions src/platform/zcu104/inc/plat/psci.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
#ifndef __PLAT_PSCI_H__
#define __PLAT_PSCI_H__

#define PSCI_POWER_STATE_LVL_0 0x0000000
#define PSCI_POWER_STATE_LVL_1 0x1000000
#define PSCI_POWER_STATE_LVL_2 0x2000000
#define PSCI_STATE_TYPE_STANDBY 0x00000
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
#define PSCI_STATE_TYPE_BIT (1UL << 30)
#define PSCI_POWER_STATE_LVL_0 0x0000000
#define PSCI_POWER_STATE_LVL_1 0x1000000
#define PSCI_POWER_STATE_LVL_2 0x2000000
#define PSCI_STATE_TYPE_STANDBY 0x00000
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
#define PSCI_STATE_TYPE_BIT (1UL << 30)

#define PLAT_PSCI_STANDBY_NOT_SUPPORTED 1

#endif // __PLAT_PSCI_H__

0 comments on commit 11b03d5

Please sign in to comment.