Skip to content

Commit 71ddc5a

Browse files
committed
fix(esp_hw_support): fix mmu retention code cache safety
1 parent 1a5741b commit 71ddc5a

File tree

5 files changed

+22
-59
lines changed

5 files changed

+22
-59
lines changed

components/esp_hw_support/include/esp_private/esp_sleep_internal.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ esp_err_t esp_deep_sleep_register_phy_hook(esp_deep_sleep_cb_t new_dslp_cb);
108108
void esp_deep_sleep_deregister_phy_hook(esp_deep_sleep_cb_t old_dslp_cb);
109109
#endif
110110

111+
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_PM_MMU_TABLE_RETENTION_WHEN_TOP_PD
112+
/**
113+
* @brief Backup or restore the MMU when the top domain is powered down.
114+
* @param backup_or_restore decide to backup mmu or restore mmu
115+
*/
116+
void esp_sleep_mmu_retention(bool backup_or_restore);
117+
118+
/**
119+
* @brief Whether to allow the top domain to be powered off due to mmu domain requiring retention.
120+
*
121+
* In light sleep mode, only when the system can provide enough memory
122+
* for mmu retention, the top power domain can be powered off.
123+
*/
124+
bool mmu_domain_pd_allowed(void);
125+
#endif
126+
111127
#ifdef __cplusplus
112128
}
113129
#endif

components/esp_hw_support/include/esp_sleep.h

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -770,41 +770,6 @@ esp_err_t esp_sleep_cpu_retention_init(void);
770770
esp_err_t esp_sleep_cpu_retention_deinit(void);
771771
#endif // ESP_SLEEP_POWER_DOWN_CPU
772772

773-
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_PM_MMU_TABLE_RETENTION_WHEN_TOP_PD
774-
/**
775-
* @brief Backup or restore the MMU when the top domain is powered down.
776-
* @param backup_or_restore decide to backup mmu or restore mmu
777-
*/
778-
void esp_sleep_mmu_retention(bool backup_or_restore);
779-
780-
/**
781-
* @brief Mmu backup initialize when power down TOP domain
782-
*
783-
* @return
784-
* - ESP_OK on success
785-
* - ESP_ERR_NO_MEM not enough retention memory
786-
*/
787-
esp_err_t esp_sleep_mmu_retention_init(void);
788-
789-
/**
790-
* @brief Mmu backup de-initialize when power down TOP domain
791-
*
792-
* @return
793-
* - ESP_OK on success
794-
*
795-
* Release system retention memory.
796-
*/
797-
esp_err_t esp_sleep_mmu_retention_deinit(void);
798-
799-
/**
800-
* @brief Whether to allow the top domain to be powered off due to mmu domain requiring retention.
801-
*
802-
* In light sleep mode, only when the system can provide enough memory
803-
* for mmu retention, the top power domain can be powered off.
804-
*/
805-
bool mmu_domain_pd_allowed(void);
806-
#endif
807-
808773
/**
809774
* @brief Configure to isolate all GPIO pins in sleep state
810775
*/

components/esp_hw_support/lowpower/port/esp32c5/sleep_mmu.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ IRAM_ATTR void esp_sleep_mmu_retention(bool backup_or_restore)
112112
}
113113
}
114114

115-
static esp_err_t esp_sleep_mmu_retention_deinit_impl(void)
115+
static esp_err_t esp_sleep_mmu_retention_deinit(void)
116116
{
117117
if (s_mmu_retention.retent.mmu_table_frame) {
118118
heap_caps_free((void *)s_mmu_retention.retent.mmu_table_frame);
@@ -121,7 +121,7 @@ static esp_err_t esp_sleep_mmu_retention_deinit_impl(void)
121121
return ESP_OK;
122122
}
123123

124-
static esp_err_t esp_sleep_mmu_retention_init_impl(void)
124+
static esp_err_t esp_sleep_mmu_retention_init(void)
125125
{
126126
if (s_mmu_retention.retent.mmu_table_frame == NULL) {
127127
void *frame = mmu_domain_mmu_table_sleep_frame_alloc_and_init();
@@ -136,16 +136,6 @@ static esp_err_t esp_sleep_mmu_retention_init_impl(void)
136136
return ESP_ERR_NO_MEM;
137137
}
138138

139-
esp_err_t esp_sleep_mmu_retention_init(void)
140-
{
141-
return esp_sleep_mmu_retention_init_impl();
142-
}
143-
144-
esp_err_t esp_sleep_mmu_retention_deinit(void)
145-
{
146-
return esp_sleep_mmu_retention_deinit_impl();
147-
}
148-
149139
bool mmu_domain_pd_allowed(void)
150140
{
151141
return (s_mmu_retention.retent.mmu_table_frame != NULL);

components/esp_hw_support/lowpower/port/esp32c61/sleep_mmu.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ IRAM_ATTR void esp_sleep_mmu_retention(bool backup_or_restore)
112112
}
113113
}
114114

115-
static esp_err_t esp_sleep_mmu_retention_deinit_impl(void)
115+
static esp_err_t esp_sleep_mmu_retention_deinit(void)
116116
{
117117
if (s_mmu_retention.retent.mmu_table_frame) {
118118
heap_caps_free((void *)s_mmu_retention.retent.mmu_table_frame);
@@ -121,7 +121,7 @@ static esp_err_t esp_sleep_mmu_retention_deinit_impl(void)
121121
return ESP_OK;
122122
}
123123

124-
static esp_err_t esp_sleep_mmu_retention_init_impl(void)
124+
static esp_err_t esp_sleep_mmu_retention_init(void)
125125
{
126126
if (s_mmu_retention.retent.mmu_table_frame == NULL) {
127127
void *frame = mmu_domain_mmu_table_sleep_frame_alloc_and_init();
@@ -136,16 +136,6 @@ static esp_err_t esp_sleep_mmu_retention_init_impl(void)
136136
return ESP_ERR_NO_MEM;
137137
}
138138

139-
esp_err_t esp_sleep_mmu_retention_init(void)
140-
{
141-
return esp_sleep_mmu_retention_init_impl();
142-
}
143-
144-
esp_err_t esp_sleep_mmu_retention_deinit(void)
145-
{
146-
return esp_sleep_mmu_retention_deinit_impl();
147-
}
148-
149139
bool mmu_domain_pd_allowed(void)
150140
{
151141
return (s_mmu_retention.retent.mmu_table_frame != NULL);

components/esp_pm/linker.lf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ entries:
3434
if SOC_PM_SUPPORT_TOP_PD = y:
3535
sleep_clock:clock_domain_pd_allowed (noflash)
3636
sleep_system_peripheral:peripheral_domain_pd_allowed (noflash)
37+
if SOC_PM_MMU_TABLE_RETENTION_WHEN_TOP_PD = y && PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP = y:
38+
sleep_mmu:mmu_domain_pd_allowed (noflash)
3739
sleep_modem:modem_domain_pd_allowed (noflash)
3840
sleep_modem:periph_inform_out_light_sleep_overhead (noflash)
3941
if IDF_TARGET_ESP32P4 = n && IDF_TARGET_ESP32C61 = n : # TODO: IDF-6496, IDF-9304

0 commit comments

Comments
 (0)