From 72acec7275046fab63c2acc9598f0b4d4510af63 Mon Sep 17 00:00:00 2001 From: Tiago Medicci Serrano Date: Fri, 20 Sep 2024 14:28:46 -0300 Subject: [PATCH] esp32s3: Fix faulty `esp32s3-devkit:stack` example This defconfig is an example of the recorded stack and it became faulty recently after the implementation of the `up_current_regs` functions. The `noinstrument_function` directive must be used for preventing it from being looped when instrumentation is enabled. Also, this commit places `sched/instrument/stack_record.c` in IRAM. --- arch/xtensa/include/irq.h | 5 +++-- boards/xtensa/esp32s3/common/scripts/legacy_sections.ld | 1 + boards/xtensa/esp32s3/common/scripts/mcuboot_sections.ld | 1 + boards/xtensa/esp32s3/common/scripts/simple_boot_sections.ld | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/include/irq.h b/arch/xtensa/include/irq.h index 6e5d77bd304de..21ce8f20f437b 100644 --- a/arch/xtensa/include/irq.h +++ b/arch/xtensa/include/irq.h @@ -429,11 +429,12 @@ int up_cpu_index(void); # define up_cpu_index() (0) #endif -static inline_function uint32_t *up_current_regs(void) +noinstrument_function static inline_function uint32_t *up_current_regs(void) { return (uint32_t *)g_current_regs[up_cpu_index()]; } +noinstrument_function static inline_function void up_set_current_regs(uint32_t *regs) { g_current_regs[up_cpu_index()] = regs; @@ -449,7 +450,7 @@ static inline_function void up_set_current_regs(uint32_t *regs) ****************************************************************************/ #ifndef __ASSEMBLY__ -noinstrument_function static inline bool up_interrupt_context(void) +noinstrument_function static inline_function bool up_interrupt_context(void) { #ifdef CONFIG_SMP irqstate_t flags = up_irq_save(); diff --git a/boards/xtensa/esp32s3/common/scripts/legacy_sections.ld b/boards/xtensa/esp32s3/common/scripts/legacy_sections.ld index a09e99aa00a5d..9a00ed91838f2 100644 --- a/boards/xtensa/esp32s3/common/scripts/legacy_sections.ld +++ b/boards/xtensa/esp32s3/common/scripts/legacy_sections.ld @@ -102,6 +102,7 @@ SECTIONS *libsched.a:sched_suspendscheduler.*(.literal .text .literal.* .text.*) *libsched.a:sched_thistask.*(.literal .text .literal.* .text.*) *libsched.a:spinlock.*(.literal .text .literal.* .text.*) + *libsched.a:stack_record.*(.literal .text .literal.* .text.*) *libc.a:*lib_instrument.*(.literal .text .literal.* .text.*) diff --git a/boards/xtensa/esp32s3/common/scripts/mcuboot_sections.ld b/boards/xtensa/esp32s3/common/scripts/mcuboot_sections.ld index 68398759b0310..38daf32cee90a 100644 --- a/boards/xtensa/esp32s3/common/scripts/mcuboot_sections.ld +++ b/boards/xtensa/esp32s3/common/scripts/mcuboot_sections.ld @@ -210,6 +210,7 @@ SECTIONS *libsched.a:sched_suspendscheduler.*(.literal .text .literal.* .text.*) *libsched.a:sched_thistask.*(.literal .text .literal.* .text.*) *libsched.a:spinlock.*(.literal .text .literal.* .text.*) + *libsched.a:stack_record.*(.literal .text .literal.* .text.*) #ifdef CONFIG_ESP32S3_SPEED_UP_ISR *libarch.a:xtensa_switchcontext.*(.literal.up_switch_context .text.up_switch_context) diff --git a/boards/xtensa/esp32s3/common/scripts/simple_boot_sections.ld b/boards/xtensa/esp32s3/common/scripts/simple_boot_sections.ld index fb98660c36f42..cdae1e4e5f2ee 100644 --- a/boards/xtensa/esp32s3/common/scripts/simple_boot_sections.ld +++ b/boards/xtensa/esp32s3/common/scripts/simple_boot_sections.ld @@ -104,6 +104,7 @@ SECTIONS *libsched.a:sched_thistask.*(.literal .text .literal.* .text.*) *libsched.a:spinlock.*(.literal .text .literal.* .text.*) *libsched.a:*sched_get_stackinfo.*(.literal .text .literal.* .text.*) + *libsched.a:stack_record.*(.literal .text .literal.* .text.*) #ifdef CONFIG_ESP32S3_SPEED_UP_ISR *libarch.a:xtensa_switchcontext.*(.literal.up_switch_context .text.up_switch_context)