From b9c64236c185161d40ef1ec38e3981de25efde27 Mon Sep 17 00:00:00 2001 From: sibeibei Date: Wed, 15 Apr 2026 13:24:38 +0800 Subject: [PATCH 1/3] feat(ci): add sleep cache safe check for wifi power save --- examples/wifi/power_save/pytest_wifi_power_save.py | 13 +++++++++++++ examples/wifi/power_save/sdkconfig.ci.c2_xtal26m | 1 + .../wifi/power_save/sdkconfig.ci.c2eco4_xtal26m | 1 + examples/wifi/power_save/sdkconfig.ci.c3eco7 | 1 + examples/wifi/power_save/sdkconfig.ci.pd_modem | 4 ++++ examples/wifi/power_save/sdkconfig.ci.pd_top | 1 + 6 files changed, 21 insertions(+) create mode 100644 examples/wifi/power_save/sdkconfig.ci.pd_modem diff --git a/examples/wifi/power_save/pytest_wifi_power_save.py b/examples/wifi/power_save/pytest_wifi_power_save.py index 845b9274615..00735167fec 100644 --- a/examples/wifi/power_save/pytest_wifi_power_save.py +++ b/examples/wifi/power_save/pytest_wifi_power_save.py @@ -60,6 +60,19 @@ def test_wifi_power_save_pd_top(dut: Dut) -> None: _run_test(dut) +@pytest.mark.wifi_ap +@pytest.mark.parametrize( + 'config', + [ + 'pd_modem', + ], + indirect=True, +) +@idf_parametrize('target', ['esp32c6', 'esp32c5', 'esp32c61'], indirect=['target']) +def test_wifi_power_save_pd_modem(dut: Dut) -> None: + _run_test(dut) + + @pytest.mark.wifi_ap @pytest.mark.xtal_26mhz @pytest.mark.parametrize( diff --git a/examples/wifi/power_save/sdkconfig.ci.c2_xtal26m b/examples/wifi/power_save/sdkconfig.ci.c2_xtal26m index 065020b06fb..68a9d5efcdf 100644 --- a/examples/wifi/power_save/sdkconfig.ci.c2_xtal26m +++ b/examples/wifi/power_save/sdkconfig.ci.c2_xtal26m @@ -1,3 +1,4 @@ CONFIG_IDF_TARGET="esp32c2" CONFIG_XTAL_FREQ_26=y CONFIG_EXAMPLE_GET_AP_INFO_FROM_STDIN=y +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y diff --git a/examples/wifi/power_save/sdkconfig.ci.c2eco4_xtal26m b/examples/wifi/power_save/sdkconfig.ci.c2eco4_xtal26m index a302168187a..296928320fd 100644 --- a/examples/wifi/power_save/sdkconfig.ci.c2eco4_xtal26m +++ b/examples/wifi/power_save/sdkconfig.ci.c2eco4_xtal26m @@ -2,3 +2,4 @@ CONFIG_IDF_TARGET="esp32c2" CONFIG_XTAL_FREQ_26=y CONFIG_EXAMPLE_GET_AP_INFO_FROM_STDIN=y CONFIG_ESP32C2_REV_MIN_200=y +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y diff --git a/examples/wifi/power_save/sdkconfig.ci.c3eco7 b/examples/wifi/power_save/sdkconfig.ci.c3eco7 index 6b253290433..05ef4a47428 100644 --- a/examples/wifi/power_save/sdkconfig.ci.c3eco7 +++ b/examples/wifi/power_save/sdkconfig.ci.c3eco7 @@ -1,3 +1,4 @@ CONFIG_IDF_TARGET="esp32c3" CONFIG_ESP32C3_REV_MIN_101=y CONFIG_EXAMPLE_GET_AP_INFO_FROM_STDIN=y +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y diff --git a/examples/wifi/power_save/sdkconfig.ci.pd_modem b/examples/wifi/power_save/sdkconfig.ci.pd_modem new file mode 100644 index 00000000000..604a4ddeb80 --- /dev/null +++ b/examples/wifi/power_save/sdkconfig.ci.pd_modem @@ -0,0 +1,4 @@ +CONFIG_EXAMPLE_GET_AP_INFO_FROM_STDIN=y +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y +CONFIG_ESP_PHY_MAC_BB_PD=y +CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP=y diff --git a/examples/wifi/power_save/sdkconfig.ci.pd_top b/examples/wifi/power_save/sdkconfig.ci.pd_top index 92f20b28e0f..2bb4010036f 100644 --- a/examples/wifi/power_save/sdkconfig.ci.pd_top +++ b/examples/wifi/power_save/sdkconfig.ci.pd_top @@ -1,3 +1,4 @@ CONFIG_EXAMPLE_GET_AP_INFO_FROM_STDIN=y CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y CONFIG_ESP_PHY_MAC_BB_PD=y +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y From d4ee7343654d9be0c254d3a3d5b70d72cec767bf Mon Sep 17 00:00:00 2001 From: sibeibei Date: Wed, 15 Apr 2026 12:22:05 +0800 Subject: [PATCH 2/3] fix(wifi): IRAM for regdma path used in modem pd light sleep --- components/esp_hw_support/linker.lf | 12 ++++++++++++ components/esp_hw_support/port/regdma_link.c | 18 +++++++++--------- components/esp_wifi/esp32c6/esp_adapter.c | 4 ++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/components/esp_hw_support/linker.lf b/components/esp_hw_support/linker.lf index d64577e8101..1a9c00ea1f2 100644 --- a/components/esp_hw_support/linker.lf +++ b/components/esp_hw_support/linker.lf @@ -53,6 +53,18 @@ entries: sar_periph_ctrl (noflash) else: sar_periph_ctrl: sar_periph_ctrl_power_enable (noflash) + if SOC_PM_MODEM_RETENTION_BY_REGDMA = y && ESP_PHY_MAC_BB_PD = y: + sleep_retention:sleep_retention_find_link_by_id (noflash) + regdma_link:regdma_find_link_by_id (noflash) + regdma_link:regdma_link_get_next (noflash) + regdma_link:regdma_link_get_next_continuous_wrapper (noflash) + regdma_link:regdma_link_get_next_addr_map_wrapper (noflash) + regdma_link:regdma_link_get_next_write_wait_wrapper (noflash) + regdma_link:regdma_link_get_next_branch_continuous_wrapper (noflash) + regdma_link:regdma_link_get_next_branch_addr_map_wrapper (noflash) + regdma_link:regdma_link_get_next_branch_write_wait_wrapper (noflash) + regdma_link:regdma_link_set_write_wait_content (noflash) + regdma_link:regdma_link_get_instance (noflash) [mapping:soc_pm] archive: libsoc.a diff --git a/components/esp_hw_support/port/regdma_link.c b/components/esp_hw_support/port/regdma_link.c index 916eee36955..b94f44889db 100644 --- a/components/esp_hw_support/port/regdma_link.c +++ b/components/esp_hw_support/port/regdma_link.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -312,43 +312,43 @@ void * regdma_link_init(const regdma_link_config_t *config, bool branch, int mod return link; } -static void * regdma_link_get_next_continuous_wrapper(void *link) +__attribute__((used, noinline)) static void * regdma_link_get_next_continuous_wrapper(void *link) { regdma_link_continuous_t *continuous = __containerof(link, regdma_link_continuous_t, head); return (void *)(continuous->body.next); } -static void * regdma_link_get_next_addr_map_wrapper(void *link) +__attribute__((used, noinline)) static void * regdma_link_get_next_addr_map_wrapper(void *link) { regdma_link_addr_map_t *addr_map = __containerof(link, regdma_link_addr_map_t, head); return (void *)(addr_map->body.next); } -static void * regdma_link_get_next_write_wait_wrapper(void *link) +__attribute__((used, noinline)) static void * regdma_link_get_next_write_wait_wrapper(void *link) { regdma_link_write_wait_t *write_wait = __containerof(link, regdma_link_write_wait_t, head); return (void *)(write_wait->body.next); } -static regdma_entry_buf_t * regdma_link_get_next_branch_continuous_wrapper(void *link) +__attribute__((used, noinline)) static regdma_entry_buf_t * regdma_link_get_next_branch_continuous_wrapper(void *link) { regdma_link_branch_continuous_t *branch_continuous = __containerof(link, regdma_link_branch_continuous_t, head); return &branch_continuous->body.next; } -static regdma_entry_buf_t * regdma_link_get_next_branch_addr_map_wrapper(void *link) +__attribute__((used, noinline)) static regdma_entry_buf_t * regdma_link_get_next_branch_addr_map_wrapper(void *link) { regdma_link_branch_addr_map_t *branch_addr_map = __containerof(link, regdma_link_branch_addr_map_t, head); return &branch_addr_map->body.next; } -static regdma_entry_buf_t * regdma_link_get_next_branch_write_wait_wrapper(void *link) +__attribute__((used, noinline)) static regdma_entry_buf_t * regdma_link_get_next_branch_write_wait_wrapper(void *link) { regdma_link_branch_write_wait_t *branch_write_wait = __containerof(link, regdma_link_branch_write_wait_t, head); return &branch_write_wait->body.next; } -static void * regdma_link_get_next(void *link, int entry) +__attribute__((used, noinline)) static void * regdma_link_get_next(void *link, int entry) { if (link) { regdma_link_head_t head = REGDMA_LINK_HEAD(link); @@ -401,7 +401,7 @@ void * regdma_link_recursive(void *link, int entry, void (*hook)(void *, int, in return regdma_link_recursive_impl(link, entry, 0, hook); } -static void * regdma_link_get_instance(void *link) +__attribute__((used, noinline)) static void * regdma_link_get_instance(void *link) { void * container_memaddr[] = { (void *)__containerof(link, regdma_link_continuous_t, head), diff --git a/components/esp_wifi/esp32c6/esp_adapter.c b/components/esp_wifi/esp32c6/esp_adapter.c index 4ff4bca9c96..899f424f123 100644 --- a/components/esp_wifi/esp32c6/esp_adapter.c +++ b/components/esp_wifi/esp32c6/esp_adapter.c @@ -568,12 +568,12 @@ static void esp_phy_disable_wrapper(void) } #if SOC_PM_MODEM_RETENTION_BY_REGDMA -static void regdma_link_set_write_wait_content_wrapper(void *addr, uint32_t value, uint32_t mask) +static void IRAM_ATTR regdma_link_set_write_wait_content_wrapper(void *addr, uint32_t value, uint32_t mask) { regdma_link_set_write_wait_content(addr, value, mask); } -static void *sleep_retention_find_link_by_id_wrapper(int id) +static void *IRAM_ATTR sleep_retention_find_link_by_id_wrapper(int id) { return sleep_retention_find_link_by_id(id); } From 3dfdc82bf0075291ab4726a060da51cf8f0a24ca Mon Sep 17 00:00:00 2001 From: liuning Date: Thu, 12 Mar 2026 16:36:43 +0800 Subject: [PATCH 3/3] fix(pm): fix coexist force wake behaviour with offchannel to optimize performance at returning home channel --- components/esp_wifi/Kconfig | 3 ++- components/esp_wifi/lib | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index 2713820427b..a726b8eda41 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -434,7 +434,8 @@ menu "Wi-Fi" config ESP_WIFI_SLP_BEACON_LOST_TIMEOUT int "Beacon loss timeout" range 5 100 - default 10 + default 25 if ESP_COEX_SW_COEXIST_ENABLE + default 10 if (!ESP_COEX_SW_COEXIST_ENABLE) depends on ESP_WIFI_SLP_BEACON_LOST_OPT help Timeout time for close rf phy when beacon loss occurs, Unit: 1024 microsecond. diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index abbdc70d7a0..99985757823 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit abbdc70d7a0456bb402f1be57e573eb727853495 +Subproject commit 999857578236638b31b0149d3d1364a51b750da4