Skip to content

Commit 63345e8

Browse files
committed
wait: add check for waiti
waiti can only work with interrupt level 0, check if the level is 0 and set SOF_IPC_PANIC_WFI panic. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
1 parent 90b455e commit 63345e8

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/arch/xtensa/include/arch/wait.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,20 @@
2929
*/
3030

3131
#include <xtensa/xtruntime.h>
32+
#include <arch/interrupt.h>
33+
#include <sof/panic.h>
34+
3235

3336
#if defined(PLATFORM_WAITI_DELAY)
3437

3538
static inline void arch_wait_for_interrupt(int level)
3639
{
3740
int i;
3841

42+
/* can only eneter WFI when at runlevel 0 i.e. not IRQ level */
43+
if (arch_interrupt_get_level() > 0)
44+
panic(SOF_IPC_PANIC_WFI);
45+
3946
/* this sequnce must be atomic on LX6 */
4047
XTOS_SET_INTLEVEL(5);
4148

@@ -55,7 +62,11 @@ static inline void arch_wait_for_interrupt(int level)
5562

5663
static inline void arch_wait_for_interrupt(int level)
5764
{
58-
asm volatile("waiti 0");
65+
/* can only eneter WFI when at runlevel 0 i.e. not IRQ level */
66+
if (arch_interrupt_get_level() > 0)
67+
panic(SOF_IPC_PANIC_WFI);
68+
69+
asm volatile("waiti 0");
5970
}
6071

6172
#endif

src/include/uapi/ipc.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,17 @@
137137
#define SOF_IPC_PANIC_MAGIC 0x0dead000
138138
#define SOF_IPC_PANIC_MAGIC_MASK 0x0ffff000
139139
#define SOF_IPC_PANIC_CODE_MASK 0x00000fff
140-
#define SOF_IPC_PANIC_MEM (SOF_IPC_PANIC_MAGIC | 0)
141-
#define SOF_IPC_PANIC_WORK (SOF_IPC_PANIC_MAGIC | 1)
142-
#define SOF_IPC_PANIC_IPC (SOF_IPC_PANIC_MAGIC | 2)
143-
#define SOF_IPC_PANIC_ARCH (SOF_IPC_PANIC_MAGIC | 3)
144-
#define SOF_IPC_PANIC_PLATFORM (SOF_IPC_PANIC_MAGIC | 4)
145-
#define SOF_IPC_PANIC_TASK (SOF_IPC_PANIC_MAGIC | 5)
146-
#define SOF_IPC_PANIC_EXCEPTION (SOF_IPC_PANIC_MAGIC | 6)
147-
#define SOF_IPC_PANIC_DEADLOCK (SOF_IPC_PANIC_MAGIC | 7)
148-
#define SOF_IPC_PANIC_STACK (SOF_IPC_PANIC_MAGIC | 8)
149-
#define SOF_IPC_PANIC_IDLE (SOF_IPC_PANIC_MAGIC | 9)
140+
#define SOF_IPC_PANIC_MEM (SOF_IPC_PANIC_MAGIC | 0x0)
141+
#define SOF_IPC_PANIC_WORK (SOF_IPC_PANIC_MAGIC | 0x1)
142+
#define SOF_IPC_PANIC_IPC (SOF_IPC_PANIC_MAGIC | 0x2)
143+
#define SOF_IPC_PANIC_ARCH (SOF_IPC_PANIC_MAGIC | 0x3)
144+
#define SOF_IPC_PANIC_PLATFORM (SOF_IPC_PANIC_MAGIC | 0x4)
145+
#define SOF_IPC_PANIC_TASK (SOF_IPC_PANIC_MAGIC | 0x5)
146+
#define SOF_IPC_PANIC_EXCEPTION (SOF_IPC_PANIC_MAGIC | 0x6)
147+
#define SOF_IPC_PANIC_DEADLOCK (SOF_IPC_PANIC_MAGIC | 0x7)
148+
#define SOF_IPC_PANIC_STACK (SOF_IPC_PANIC_MAGIC | 0x8)
149+
#define SOF_IPC_PANIC_IDLE (SOF_IPC_PANIC_MAGIC | 0x9)
150+
#define SOF_IPC_PANIC_WFI (SOF_IPC_PANIC_MAGIC | 0xa)
150151

151152
/*
152153
* SOF memory capabilities, add new ones at the end

0 commit comments

Comments
 (0)