Skip to content

Commit 734a5bf

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 9ebd1bc commit 734a5bf

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

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
@@ -144,16 +144,17 @@
144144
#define SOF_IPC_PANIC_MAGIC 0x0dead000
145145
#define SOF_IPC_PANIC_MAGIC_MASK 0x0ffff000
146146
#define SOF_IPC_PANIC_CODE_MASK 0x00000fff
147-
#define SOF_IPC_PANIC_MEM (SOF_IPC_PANIC_MAGIC | 0)
148-
#define SOF_IPC_PANIC_WORK (SOF_IPC_PANIC_MAGIC | 1)
149-
#define SOF_IPC_PANIC_IPC (SOF_IPC_PANIC_MAGIC | 2)
150-
#define SOF_IPC_PANIC_ARCH (SOF_IPC_PANIC_MAGIC | 3)
151-
#define SOF_IPC_PANIC_PLATFORM (SOF_IPC_PANIC_MAGIC | 4)
152-
#define SOF_IPC_PANIC_TASK (SOF_IPC_PANIC_MAGIC | 5)
153-
#define SOF_IPC_PANIC_EXCEPTION (SOF_IPC_PANIC_MAGIC | 6)
154-
#define SOF_IPC_PANIC_DEADLOCK (SOF_IPC_PANIC_MAGIC | 7)
155-
#define SOF_IPC_PANIC_STACK (SOF_IPC_PANIC_MAGIC | 8)
156-
#define SOF_IPC_PANIC_IDLE (SOF_IPC_PANIC_MAGIC | 9)
147+
#define SOF_IPC_PANIC_MEM (SOF_IPC_PANIC_MAGIC | 0x0)
148+
#define SOF_IPC_PANIC_WORK (SOF_IPC_PANIC_MAGIC | 0x1)
149+
#define SOF_IPC_PANIC_IPC (SOF_IPC_PANIC_MAGIC | 0x2)
150+
#define SOF_IPC_PANIC_ARCH (SOF_IPC_PANIC_MAGIC | 0x3)
151+
#define SOF_IPC_PANIC_PLATFORM (SOF_IPC_PANIC_MAGIC | 0x4)
152+
#define SOF_IPC_PANIC_TASK (SOF_IPC_PANIC_MAGIC | 0x5)
153+
#define SOF_IPC_PANIC_EXCEPTION (SOF_IPC_PANIC_MAGIC | 0x6)
154+
#define SOF_IPC_PANIC_DEADLOCK (SOF_IPC_PANIC_MAGIC | 0x7)
155+
#define SOF_IPC_PANIC_STACK (SOF_IPC_PANIC_MAGIC | 0x8)
156+
#define SOF_IPC_PANIC_IDLE (SOF_IPC_PANIC_MAGIC | 0x9)
157+
#define SOF_IPC_PANIC_WFI (SOF_IPC_PANIC_MAGIC | 0xa)
157158

158159
/*
159160
* SOF memory capabilities, add new ones at the end

0 commit comments

Comments
 (0)