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 <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2021-06-17 13:30:27 +09:00 committed by Xiang Xiao
parent 80157b8782
commit 2d016f8d21

View File

@ -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"
);
}