From 3a7ec8acfa4082e97f2d2777be67ae0c4605d016 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Thu, 27 Jan 2022 20:18:39 +0800 Subject: [PATCH 1/2] freertos: always inline xPortSetInterruptMaskFromISR and vPortClearInterruptMaskFromISR These were called from IRAM context where the caller expect them to be inlined and accessible when cache is disabled. This was not the case when compiled with -O0. Closes https://github.com/espressif/esp-idf/issues/8301 --- components/freertos/port/xtensa/include/freertos/portmacro.h | 4 ++-- tools/unit-test-app/configs/no_optimization_c3 | 3 +++ tools/unit-test-app/configs/no_optimization_esp32 | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tools/unit-test-app/configs/no_optimization_c3 create mode 100644 tools/unit-test-app/configs/no_optimization_esp32 diff --git a/components/freertos/port/xtensa/include/freertos/portmacro.h b/components/freertos/port/xtensa/include/freertos/portmacro.h index 934f056816..2ee4c12c2b 100644 --- a/components/freertos/port/xtensa/include/freertos/portmacro.h +++ b/components/freertos/port/xtensa/include/freertos/portmacro.h @@ -558,14 +558,14 @@ static inline void __attribute__((always_inline)) uxPortCompareSetExtram(volatil // --------------------- Interrupts ------------------------ -static inline UBaseType_t xPortSetInterruptMaskFromISR(void) +static inline UBaseType_t __attribute__((always_inline)) xPortSetInterruptMaskFromISR(void) { UBaseType_t prev_int_level = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); portbenchmarkINTERRUPT_DISABLE(); return prev_int_level; } -static inline void vPortClearInterruptMaskFromISR(UBaseType_t prev_level) +static inline void __attribute__((always_inline)) vPortClearInterruptMaskFromISR(UBaseType_t prev_level) { portbenchmarkINTERRUPT_RESTORE(prev_level); XTOS_RESTORE_JUST_INTLEVEL(prev_level); diff --git a/tools/unit-test-app/configs/no_optimization_c3 b/tools/unit-test-app/configs/no_optimization_c3 new file mode 100644 index 0000000000..00719f8712 --- /dev/null +++ b/tools/unit-test-app/configs/no_optimization_c3 @@ -0,0 +1,3 @@ +CONFIG_IDF_TARGET="esp32c3" +TEST_COMPONENTS=esp_ipc spi_flash +CONFIG_COMPILER_OPTIMIZATION_NONE=y diff --git a/tools/unit-test-app/configs/no_optimization_esp32 b/tools/unit-test-app/configs/no_optimization_esp32 new file mode 100644 index 0000000000..64114b1215 --- /dev/null +++ b/tools/unit-test-app/configs/no_optimization_esp32 @@ -0,0 +1,3 @@ +CONFIG_IDF_TARGET="esp32" +TEST_COMPONENTS=esp_ipc spi_flash +CONFIG_COMPILER_OPTIMIZATION_NONE=y From 1690785432ca0c21532ef2e69ed2797203e7cdb4 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Mon, 7 Feb 2022 11:33:33 +0800 Subject: [PATCH 2/2] spi flash: fix cache accessed while disabled issues at -O0 mask_get_id and gpio_hal_iomux_func_sel were called while cache is disabled, but were not inlined as expected at -0O. Force these functions to always be inlined. --- components/driver/spi_bus_lock.c | 2 +- components/hal/esp32/include/hal/gpio_ll.h | 2 +- components/hal/esp32c3/include/hal/gpio_ll.h | 2 +- components/hal/esp32h2/include/hal/gpio_ll.h | 2 +- components/hal/esp32s2/include/hal/gpio_ll.h | 2 +- components/hal/esp32s3/include/hal/gpio_ll.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/driver/spi_bus_lock.c b/components/driver/spi_bus_lock.c index 353b1693cd..1b0318a90a 100644 --- a/components/driver/spi_bus_lock.c +++ b/components/driver/spi_bus_lock.c @@ -164,7 +164,7 @@ typedef struct spi_bus_lock_t spi_bus_lock_t; #define REQUEST_BIT(mask) ((mask) << REQ_SHIFT) #define PENDING_BIT(mask) ((mask) << PENDING_SHIFT) #define DEV_MASK(id) (LOCK_BIT(1<