From d9a3e3bb86960c419325b0f051bd5c7fd37e23c1 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Thu, 31 Aug 2023 17:45:17 +0800 Subject: [PATCH] fix(freertos): Corrected xPortCanYield() for esp32p4 This commit updates the xPortCanYield() for esp32p4 by correcting the return condition. Previously, the API would return true if an ISR of priority 1 was received which is incorrect. --- .../portable/riscv/include/freertos/portmacro.h | 6 ++++++ 1 file changed, 6 insertions(+) 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 d004ef87b4c..2e8cada586b 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h @@ -641,6 +641,12 @@ FORCE_INLINE_ATTR bool xPortCanYield(void) uint32_t threshold = REG_READ(INTERRUPT_CORE0_CPU_INT_THRESH_REG); #if SOC_INT_CLIC_SUPPORTED threshold = threshold >> (CLIC_CPU_INT_THRESH_S + (8 - NLBITS)); + + /* When CLIC is supported, the lowest interrupt threshold level is 0. + * Therefore, an interrupt threshold level above 0 would mean that we + * are either in a critical section or in an ISR. + */ + return (threshold == 0); #endif /* SOC_INT_CLIC_SUPPORTED */ /* when enter critical code, FreeRTOS will mask threshold to RVHAL_EXCM_LEVEL * and exit critical code, will recover threshold value (1). so threshold <= 1