From 2ec2c2101b1d765f9cfe7bcb13ac3a3a3cc8d165 Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Tue, 2 Apr 2019 16:19:23 +0200 Subject: [PATCH] panic: fix faulty panic handling This commit will change the order of functions in panic_rewind() to fix SOF_IPC_PANIC_STACK in dump_stack(). Thats because arch_dump_regs() function is not able to make a 100% safe return Signed-off-by: Adrian Bonislawski --- src/arch/xtensa/include/arch/sof.h | 5 +---- src/lib/panic.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/arch/xtensa/include/arch/sof.h b/src/arch/xtensa/include/arch/sof.h index b438aecea..8820ea79a 100644 --- a/src/arch/xtensa/include/arch/sof.h +++ b/src/arch/xtensa/include/arch/sof.h @@ -73,16 +73,13 @@ static inline void fill_core_dump(struct sof_ipc_dsp_oops_xtensa *oops, arch_dump_regs_a((void *)&oops->exccause, ps); } -static inline void *arch_dump_regs(uint32_t ps) +static inline void arch_dump_regs(uint32_t ps) { void *buf = (void *)mailbox_get_exception_base(); fill_core_dump(buf, ps); dcache_writeback_region(buf, sizeof(struct sof_ipc_dsp_oops_xtensa)); - - /* tell caller extended data can be placed hereafter */ - return ((uint8_t *)buf + sizeof(struct sof_ipc_dsp_oops_xtensa)); } #endif diff --git a/src/lib/panic.c b/src/lib/panic.c index ebe4a9f9e..8f66f1758 100644 --- a/src/lib/panic.c +++ b/src/lib/panic.c @@ -61,8 +61,8 @@ void panic_rewind(uint32_t p, uint32_t stack_rewind_frames, /* disable all IRQs */ oldps = interrupt_global_disable(); - /* dump DSP core registers */ - ext_offset = arch_dump_regs(oldps); + ext_offset = (void *)mailbox_get_exception_base() + + sizeof(struct sof_ipc_dsp_oops_xtensa); /* dump panic info, filename ane linenum */ dump_panicinfo(ext_offset, panic_info); @@ -73,14 +73,19 @@ void panic_rewind(uint32_t p, uint32_t stack_rewind_frames, /* dump stack frames */ p = dump_stack(p, ext_offset, stack_rewind_frames, count); - /* panic - send IPC oops message to host */ - platform_panic(p); - /* flush last trace messages */ #if CONFIG_TRACE trace_flush(); #endif + /* dump DSP core registers + * after arch_dump_regs() use only inline funcs if needed + */ + arch_dump_regs(oldps); + + /* panic - send IPC oops message to host */ + platform_panic(p); + /* and loop forever */ while (1) ;