mirror of
https://github.com/apache/nuttx.git
synced 2026-10-02 11:48:02 +00:00
up_idlepm() (esp32s3_idle.c/esp32_idle.c/esp32s2_idle.c and the
shared risc-v esp_idle.c for esp32c3/esp32c6) has a recovery branch
that forces the domain back to PM_NORMAL when oldstate is not
PM_NORMAL and nothing is currently staying at it:
pm_stay(PM_IDLE_DOMAIN, PM_NORMAL);
pm_changestate(PM_IDLE_DOMAIN, PM_NORMAL);
newstate = PM_NORMAL;
pm_stay() here has no matching pm_relax() anywhere in any of the
four files. The first time this branch runs, the stay count for
PM_NORMAL never returns to 0, and pm_checkstate() (called
unconditionally right after this block) can never recommend
anything deeper than PM_NORMAL again for the rest of uptime -- the
idle loop keeps running, but the governor is permanently pinned at
full power, with no further light or deep sleep.
Confirmed on real ESP32-S3 hardware (XIAO ESP32-S3,
CONFIG_ESPRESSIF_WIFI + CONFIG_PM + CONFIG_SCHED_TICKLESS): reading
g_pmdomains[0] live via JTAG/GDB showed a "system" wakelock stuck at
state=PM_NORMAL, count=1, acquired a few seconds after boot (right
when Wi-Fi coming up briefly moves the domain off PM_NORMAL and this
branch then forces it back). Reproduced 4/4 times before this fix
(never a single PM_STANDBY transition or light-sleep-return log line
across a 40+ minute run), 0/4 after.
The trigger is timing-dependent (whether anything else already
holds PM_NORMAL at the moment this branch runs), which is likely why
it does not reproduce on every single boot.
Fix: release the stay right after the one pm_changestate() call it
exists to force, matching the comment already there ("Keep working
in normal stage") -- a one-shot nudge, not a standing hold.
Touching the switch statement right below the fix in all four files
exposed a pre-existing nxstyle violation (case labels indented level
with the switch's opening brace instead of one level in from it, per
NuttX style); reindented alongside since checkpatch lints the whole
file. esp32s3_idle.c also had two unrelated stray-indented lines
("Perform IDLE mode power management" / up_idlepm()) in up_idle();
fixed those too, same reason.
Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
Assisted-by: Claude:claude-sonnet-5
|
||
|---|---|---|
| .. | ||
| bootloader | ||
| hardware | ||
| rom | ||
| .gitignore | ||
| Bootloader.mk | ||
| chip.h | ||
| chip_macros.h | ||
| chip_memory.h | ||
| esp32_aes.c | ||
| esp32_aes.h | ||
| esp32_allocateheap.c | ||
| esp32_ble.c | ||
| esp32_ble.h | ||
| esp32_ble_adapter.c | ||
| esp32_ble_adapter.h | ||
| esp32_config.h | ||
| esp32_cpuidlestack.c | ||
| esp32_cpustart.c | ||
| esp32_crypto.c | ||
| esp32_dac.c | ||
| esp32_dac.h | ||
| esp32_dma.c | ||
| esp32_dma.h | ||
| esp32_emac.c | ||
| esp32_emac.h | ||
| esp32_extraheaps.c | ||
| esp32_freerun.c | ||
| esp32_freerun.h | ||
| esp32_himem.c | ||
| esp32_himem.h | ||
| esp32_himem_chardev.c | ||
| esp32_i2c.c | ||
| esp32_i2c.h | ||
| esp32_i2s.c | ||
| esp32_idle.c | ||
| esp32_imm.c | ||
| esp32_intercpu_interrupt.c | ||
| esp32_iramheap.c | ||
| esp32_iramheap.h | ||
| esp32_ledc.c | ||
| esp32_ledc.h | ||
| esp32_libc_stubs.c | ||
| esp32_oneshot.c | ||
| esp32_oneshot.h | ||
| esp32_oneshot_lowerhalf.c | ||
| esp32_partition.c | ||
| esp32_partition.h | ||
| esp32_pminitialize.c | ||
| esp32_psram.c | ||
| esp32_psram.h | ||
| esp32_qencoder.c | ||
| esp32_qencoder.h | ||
| esp32_region.c | ||
| esp32_region.h | ||
| esp32_resetcause.c | ||
| esp32_resetcause.h | ||
| esp32_rng.c | ||
| esp32_rtc_gpio.c | ||
| esp32_rtc_gpio.h | ||
| esp32_rtcheap.c | ||
| esp32_rtcheap.h | ||
| esp32_serial.c | ||
| esp32_sha.c | ||
| esp32_sha.h | ||
| esp32_smp.h | ||
| esp32_spi.c | ||
| esp32_spi.h | ||
| esp32_spi_slave.c | ||
| esp32_spicache.c | ||
| esp32_spicache.h | ||
| esp32_spiflash.c | ||
| esp32_spiflash.h | ||
| esp32_spiram.c | ||
| esp32_spiram.h | ||
| esp32_start.c | ||
| esp32_start.h | ||
| esp32_systemreset.c | ||
| esp32_systemreset.h | ||
| esp32_textheap.c | ||
| esp32_tickless.c | ||
| esp32_tickless.h | ||
| esp32_tim.c | ||
| esp32_tim.h | ||
| esp32_tim_lowerhalf.c | ||
| esp32_tim_lowerhalf.h | ||
| esp32_timerisr.c | ||
| esp32_touch.c | ||
| esp32_touch.h | ||
| esp32_touch_lowerhalf.h | ||
| esp32_twai.c | ||
| esp32_twai.h | ||
| esp32_user.c | ||
| esp32_userspace.c | ||
| esp32_userspace.h | ||
| esp32_userspace_pid.c | ||
| esp32_wdt.c | ||
| esp32_wdt.h | ||
| esp32_wdt_lowerhalf.c | ||
| esp32_wdt_lowerhalf.h | ||
| esp32_wifi_adapter.c | ||
| esp32_wifi_adapter.h | ||
| esp32_window_hooks.S | ||
| hal.mk | ||
| Kconfig | ||
| Kconfig.security | ||
| Make.defs | ||