From 614a580bbb5a13f96595ae9ff792ecfd36d42150 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 29 May 2020 22:23:54 +0200 Subject: [PATCH] freertos, soc: don't lower INTLEVEL when entering critical sections This fixes the issue where XTOS_SET_INTLEVEL would lower INTLEVEL from 4 to 3, when eTaskGetState is invoked during the core dump, triggered from the interrupt watchdog. --- components/freertos/xtensa/include/freertos/portmacro.h | 2 +- components/soc/include/soc/spinlock.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/freertos/xtensa/include/freertos/portmacro.h b/components/freertos/xtensa/include/freertos/portmacro.h index 979ffecab..6b824e419 100644 --- a/components/freertos/xtensa/include/freertos/portmacro.h +++ b/components/freertos/xtensa/include/freertos/portmacro.h @@ -144,7 +144,7 @@ static inline uint32_t xPortGetCoreID(void); // They can be called from interrupts too. // WARNING: Only applies to current CPU. See notes above. static inline unsigned portENTER_CRITICAL_NESTED(void) { - unsigned state = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); + unsigned state = XTOS_SET_MIN_INTLEVEL(XCHAL_EXCM_LEVEL); portbenchmarkINTERRUPT_DISABLE(); return state; } diff --git a/components/soc/include/soc/spinlock.h b/components/soc/include/soc/spinlock.h index fd6ec4e33..547fe6240 100644 --- a/components/soc/include/soc/spinlock.h +++ b/components/soc/include/soc/spinlock.h @@ -67,7 +67,7 @@ static inline bool __attribute__((always_inline)) spinlock_acquire(spinlock_t *l uint32_t core_id, other_core_id; assert(lock); - irq_status = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); + irq_status = XTOS_SET_MIN_INTLEVEL(XCHAL_EXCM_LEVEL); if(timeout != SPINLOCK_WAIT_FOREVER){ RSR(CCOUNT, ccount_start); @@ -139,7 +139,7 @@ static inline void __attribute__((always_inline)) spinlock_release(spinlock_t *l uint32_t core_id; assert(lock); - irq_status = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); + irq_status = XTOS_SET_MIN_INTLEVEL(XCHAL_EXCM_LEVEL); RSR(PRID, core_id); assert(core_id == lock->owner); // This is a mutex we didn't lock, or it's corrupt