From 2d016f8d212ea93607d767c80fa62fefc755e291 Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Thu, 17 Jun 2021 13:30:27 +0900 Subject: [PATCH] arch: xtensa: Fix the PS register handling Summary: - I noticed that DEBUGASSERT sometimes happens in nxsem_wait() when testing Wi-Fi with esp32-devkitc:wsifi_smp - The call stack was not from an interrupt handler and actually g_current_regs[] were correct, even though asserted with (up_interrupt_handler() == false) - Finally, I found that we need to call rsync after we set a new value to the PS register which is described in the Xtensa document. - This commit fixes this issue Impact: - All xtensa architectures Testing: - Tested with esp32-devkitc:wifi_smp and esp32-devkitc:wifi Signed-off-by: Masayuki Ishikawa --- arch/xtensa/include/irq.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/include/irq.h b/arch/xtensa/include/irq.h index 9f20eb349f..d4622a8ed9 100644 --- a/arch/xtensa/include/irq.h +++ b/arch/xtensa/include/irq.h @@ -203,7 +203,11 @@ static inline void xtensa_setps(uint32_t ps) { __asm__ __volatile__ ( - "wsr %0, PS" : : "r"(ps) + "wsr %0, PS \n" + "rsync \n" + : + : "r"(ps) + : "memory" ); } @@ -213,7 +217,11 @@ static inline void up_irq_restore(uint32_t ps) { __asm__ __volatile__ ( - "wsr %0, PS" : : "r"(ps) + "wsr %0, PS \n" + "rsync \n" + : + : "r"(ps) + : "memory" ); }