diff --git a/arch/xtensa/core/xtensa-asm2-util.S b/arch/xtensa/core/xtensa-asm2-util.S index d46ea5ee3a7..0646c338672 100644 --- a/arch/xtensa/core/xtensa-asm2-util.S +++ b/arch/xtensa/core/xtensa-asm2-util.S @@ -248,14 +248,17 @@ xtensa_switch: #ifdef CONFIG_KERNEL_COHERENCE /* Flush the stack. The top of stack was stored for us in - * EXCSAVE3 (FIXME: shouldn't be hardcoded!) by arch_cohere_stacks(). + * EXCSAVE3 (FIXME: shouldn't be hardcoded!) by + * arch_cohere_stacks(). It can be NULL for a dummy thread. */ rsr.EXCSAVE3 a0 + beqz a0, noflush mov a3, a1 flushloop: dhwb a3, 0 addi a3, a3, XCHAL_DCACHE_LINESIZE blt a3, a0, flushloop +noflush: #endif /* Restore the A3 argument we spilled earlier (via the base diff --git a/arch/xtensa/include/kernel_arch_func.h b/arch/xtensa/include/kernel_arch_func.h index 061b6a480eb..b69f951adce 100644 --- a/arch/xtensa/include/kernel_arch_func.h +++ b/arch/xtensa/include/kernel_arch_func.h @@ -111,7 +111,7 @@ static ALWAYS_INLINE void arch_cohere_stacks(struct k_thread *old_thread, /* Dummy threads appear at system initialization, but don't * have stack_info data and will never be saved. Ignore. */ - if (!osz) { + if (old_thread->base.thread_state & _THREAD_DUMMY) { return; }