From b562ceb8c153c3a864dded5c66e02c071e75533d Mon Sep 17 00:00:00 2001 From: Andy Lin Date: Sun, 21 Jan 2024 04:08:54 +0800 Subject: [PATCH] fix(freertos): Fix broken portable macro portTRY_ENTER_CRITICAL_SAFE() This commit fixes a bug where the portTRY_ENTER_CRITICAL_SAFE() for the Xtensa and RISC-V FreeRTOS ports were broken as it did not correctly use the timeout parameter. Merges: https://github.com/espressif/esp-idf/pull/13022 --- .../portable/riscv/include/freertos/portmacro.h | 7 ++++++- .../portable/xtensa/include/freertos/portmacro.h | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h index b889f02bba..d309ef8638 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h @@ -340,7 +340,12 @@ FORCE_INLINE_ATTR BaseType_t xPortGetCoreID(void) portEXIT_CRITICAL(mux); \ } \ }) -#define portTRY_ENTER_CRITICAL_SAFE(mux, timeout) portENTER_CRITICAL_SAFE(mux, timeout) +#define portTRY_ENTER_CRITICAL_SAFE(mux, timeout) ({ \ + (void)timeout; \ + portENTER_CRITICAL_SAFE(mux); \ + BaseType_t ret = pdPASS; \ + ret; \ +}) // ---------------------- Yielding ------------------------- diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h index 660c48a950..03d8eba888 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h @@ -197,7 +197,7 @@ BaseType_t xPortInterruptedFromISRContext(void); static inline UBaseType_t xPortSetInterruptMaskFromISR(void); /** - * @brief Reenable interrupts in a nested manner (meant to be called from ISRs) + * @brief Re-enable interrupts in a nested manner (meant to be called from ISRs) * * @warning Only applies to current CPU. * @param prev_level Previous interrupt level @@ -464,7 +464,7 @@ FORCE_INLINE_ATTR BaseType_t xPortGetCoreID(void); #define portENTER_CRITICAL_ISR(mux) vPortEnterCritical(mux) #define portEXIT_CRITICAL_ISR(mux) vPortExitCritical(mux) -#define portTRY_ENTER_CRITICAL_SAFE(mux, timeout) xPortEnterCriticalTimeoutSafe(mux) +#define portTRY_ENTER_CRITICAL_SAFE(mux, timeout) xPortEnterCriticalTimeoutSafe(mux, timeout) #define portENTER_CRITICAL_SAFE(mux) vPortEnterCriticalSafe(mux) #define portEXIT_CRITICAL_SAFE(mux) vPortExitCriticalSafe(mux)