From a68022f5be63bceef4c46042bae965df9e0806f8 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Tue, 8 Jul 2025 10:56:55 +0800 Subject: [PATCH] fix(system): fixed cpu_stall function stuck issue on H4 cpu_utility_ll_stall_cpu() used to busy-wait check stalled status after stalling the core. On H4 it turns out that this status will not be set if the core happens to be in WFI state when stalled. If this happened the stall function would just wait forever for the status. --- components/hal/esp32h4/include/hal/cpu_utility_ll.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/hal/esp32h4/include/hal/cpu_utility_ll.h b/components/hal/esp32h4/include/hal/cpu_utility_ll.h index 6f4f0b5d2f..10a2fed2e8 100644 --- a/components/hal/esp32h4/include/hal/cpu_utility_ll.h +++ b/components/hal/esp32h4/include/hal/cpu_utility_ll.h @@ -32,11 +32,12 @@ FORCE_INLINE_ATTR void cpu_utility_ll_stall_cpu(uint32_t cpu_no) { if (cpu_no == 0) { HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.cpucore_cfg, aon_cpu_core0_sw_stall, 0x86); - while(!REG_GET_BIT(HP_SYSTEM_CORE_DEBUG_RUNSTALL_CONF_REG, HP_SYSTEM_CORE0_RUNSTALLED)); } else { HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.cpucore_cfg, aon_cpu_core1_sw_stall, 0x86); - while(!REG_GET_BIT(HP_SYSTEM_CORE_DEBUG_RUNSTALL_CONF_REG, HP_SYSTEM_CORE1_RUNSTALLED)); } + // We do not check stalled status in HP_SYSTEM_CORE_DEBUG_RUNSTALL_CONF_REG here because + // it will not be set if the stalled core was in WFI when the stall happens, thus any check + // is unreliable } FORCE_INLINE_ATTR void cpu_utility_ll_unstall_cpu(uint32_t cpu_no)