Skip to content

Commit 11b03d5

Browse files
DavidMCerdeirajosecm
authored andcommitted
feat(armv8/psci): Handle unexpected standby behavior
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]>
1 parent a5d7602 commit 11b03d5

File tree

5 files changed

+35
-26
lines changed

5 files changed

+35
-26
lines changed

src/arch/armv8/armv8-a/psci.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ void psci_wake(uint32_t handler_id)
8282

8383
int32_t psci_standby()
8484
{
85+
/* We've observed that some platforms behave unexpectedly when performing
86+
* standby. In these cases, after standby, the CPU cores are not awaken
87+
* by interrupts. */
88+
if (DEFINED(PLAT_PSCI_STANDBY_NOT_SUPPORTED)) {
89+
/**
90+
* If standby is not supported let's just wait for an interrupt
91+
*/
92+
__asm__ volatile("wfi");
93+
return PSCI_E_SUCCESS;
94+
}
8595
/* only apply request to core level */
8696
uint32_t pwr_state_aux = PSCI_POWER_STATE_LVL_0 | PSCI_STATE_TYPE_STANDBY;
8797

src/arch/armv8/psci.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,7 @@ static int32_t psci_cpu_suspend_handler(uint32_t power_state, unsigned long entr
6969
ret = psci_power_down(PSCI_WAKEUP_POWERDOWN);
7070
} else {
7171
// PSCI_STATE_TYPE_STANDBY:
72-
/**
73-
* TODO: ideally we would emmit a standby request to PSCI (currently, ATF), but when we
74-
* do, we do not wake up on interrupts on the current development target zcu104. We should
75-
* understand why. To circunvent this, we directly emmit a wfi
76-
*/
77-
// ret = psci_standby();
78-
__asm__ volatile("wfi\n\r");
79-
ret = PSCI_E_SUCCESS;
72+
ret = psci_standby();
8073
}
8174

8275
return ret;

src/platform/ultra96/inc/plat/psci.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
#ifndef __PLAT_PSCI_H__
77
#define __PLAT_PSCI_H__
88

9-
#define PSCI_POWER_STATE_LVL_0 0x0000000
10-
#define PSCI_POWER_STATE_LVL_1 0x1000000
11-
#define PSCI_POWER_STATE_LVL_2 0x2000000
12-
#define PSCI_STATE_TYPE_STANDBY 0x00000
13-
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
14-
#define PSCI_STATE_TYPE_BIT (1UL << 30)
9+
#define PSCI_POWER_STATE_LVL_0 0x0000000
10+
#define PSCI_POWER_STATE_LVL_1 0x1000000
11+
#define PSCI_POWER_STATE_LVL_2 0x2000000
12+
#define PSCI_STATE_TYPE_STANDBY 0x00000
13+
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
14+
#define PSCI_STATE_TYPE_BIT (1UL << 30)
15+
16+
#define PLAT_PSCI_STANDBY_NOT_SUPPORTED 1
1517

1618
#endif // __PLAT_PSCI_H__

src/platform/zcu102/inc/plat/psci.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
#ifndef __PLAT_PSCI_H__
77
#define __PLAT_PSCI_H__
88

9-
#define PSCI_POWER_STATE_LVL_0 0x0000000
10-
#define PSCI_POWER_STATE_LVL_1 0x1000000
11-
#define PSCI_POWER_STATE_LVL_2 0x2000000
12-
#define PSCI_STATE_TYPE_STANDBY 0x00000
13-
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
14-
#define PSCI_STATE_TYPE_BIT (1UL << 30)
9+
#define PSCI_POWER_STATE_LVL_0 0x0000000
10+
#define PSCI_POWER_STATE_LVL_1 0x1000000
11+
#define PSCI_POWER_STATE_LVL_2 0x2000000
12+
#define PSCI_STATE_TYPE_STANDBY 0x00000
13+
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
14+
#define PSCI_STATE_TYPE_BIT (1UL << 30)
15+
16+
#define PLAT_PSCI_STANDBY_NOT_SUPPORTED 1
1517

1618
#endif // __PLAT_PSCI_H__

src/platform/zcu104/inc/plat/psci.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
#ifndef __PLAT_PSCI_H__
77
#define __PLAT_PSCI_H__
88

9-
#define PSCI_POWER_STATE_LVL_0 0x0000000
10-
#define PSCI_POWER_STATE_LVL_1 0x1000000
11-
#define PSCI_POWER_STATE_LVL_2 0x2000000
12-
#define PSCI_STATE_TYPE_STANDBY 0x00000
13-
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
14-
#define PSCI_STATE_TYPE_BIT (1UL << 30)
9+
#define PSCI_POWER_STATE_LVL_0 0x0000000
10+
#define PSCI_POWER_STATE_LVL_1 0x1000000
11+
#define PSCI_POWER_STATE_LVL_2 0x2000000
12+
#define PSCI_STATE_TYPE_STANDBY 0x00000
13+
#define PSCI_STATE_TYPE_POWERDOWN (1UL << 30)
14+
#define PSCI_STATE_TYPE_BIT (1UL << 30)
15+
16+
#define PLAT_PSCI_STANDBY_NOT_SUPPORTED 1
1517

1618
#endif // __PLAT_PSCI_H__

0 commit comments

Comments
 (0)