fix(esp_hw_support): enable THREAD_SAFE_CLAIM with PM_EN to fix auto lslp always be rejected

This commit is contained in:
wuzhenghui
2026-09-15 16:41:26 +08:00
parent 4d7f280139
commit b78696f176
2 changed files with 16 additions and 0 deletions

View File

@@ -1502,7 +1502,16 @@ static SLEEP_FN_ATTR esp_err_t sleep_smp_cpu_sleep_prepare(void)
// which naturally avoids cache livelock, so the 20ms livelock workaround timeout is not needed.
esp_int_wdt_livelock_workaround(false);
#endif
#if CONFIG_FREERTOS_PORT_THREAD_SAFE_CLAIM
esp_err_t ipc_isr_err = ESP_OK;
esp_ipc_isr_stall_other_cpu();
#else
/* Dual-core PM_ENABLE selects THREAD_SAFE_CLAIM, so auto light sleep always takes
* the blocking path above. This safe-stall fallback is for non-PM callers of
* esp_light_sleep_start(): reject and let the upper layer decide whether to retry.
*/
esp_err_t ipc_isr_err = esp_ipc_isr_stall_other_cpu_safe();
#endif
if (ipc_isr_err == ESP_OK) {
#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW
// Run CPU retention in the context of the other safely stalled CPU.

View File

@@ -15,6 +15,9 @@ menu "Power Management"
bool "Support for power management"
# SMP FreeRTOS currently does not support power management IDF-4997
depends on (!FREERTOS_SMP && SOC_PM_SUPPORTED) || __DOXYGEN__
# Without FREERTOS_PORT_THREAD_SAFE_CLAIM, dual-core auto light sleep must use a safe stall that often
# rejects when the peer is in an ISR/critical section, which significantly increases power consumption..
select FREERTOS_PORT_THREAD_SAFE_CLAIM if !FREERTOS_UNICORE
default n
help
If enabled, application is compiled with support for power management.
@@ -23,6 +26,10 @@ menu "Power Management"
RTOS ticks and timers used for timekeeping.
Enable this option if application uses power management APIs.
On dual-core targets this also enables FREERTOS_PORT_THREAD_SAFE_CLAIM.
Without it, automatic light sleep frequently fails to stall the other CPU and
is rejected, which can keep idle power much higher than expected.
config PM_DFS_INIT_AUTO
bool "Enable dynamic frequency scaling (DFS) at startup"
depends on PM_ENABLE