fix: add mutex protection for software trigger RegDMA start to avoid data races

This commit is contained in:
sibeibei
2025-12-04 20:10:11 +08:00
parent 5c5d78b639
commit 7d013fb36d
5 changed files with 36 additions and 4 deletions

View File

@@ -276,6 +276,15 @@ void sleep_retention_do_extra_retention(bool backup_or_restore);
void sleep_retention_do_system_retention(bool backup_or_restore);
#endif
#if SOC_PM_SUPPORT_PMU_MODEM_STATE
/**
* @brief Software trigger REGDMA to do phy linked list retention
*
* @param backup_or_restore true for backup register context to memory
* or false for restore to register from memory
*/
void sleep_retention_do_phy_retention(bool backup_or_restore);
#endif /*SOC_PM_SUPPORT_PMU_MODEM_STATE */
#endif // SOC_PAU_SUPPORTED
#ifdef __cplusplus

View File

@@ -173,10 +173,8 @@ __attribute__((unused)) void sleep_modem_wifi_modem_state_deinit(void)
void IRAM_ATTR sleep_modem_wifi_do_phy_retention(bool restore)
{
if (restore) {
pau_regdma_trigger_modem_link_restore();
} else {
pau_regdma_trigger_modem_link_backup();
sleep_retention_do_phy_retention(!restore);
if (!restore) {
s_sleep_modem.wifi.modem_state_phy_done = 1;
}
}

View File

@@ -1005,3 +1005,23 @@ void IRAM_ATTR sleep_retention_do_system_retention(bool backup_or_restore)
}
}
#endif
#if SOC_PM_SUPPORT_PMU_MODEM_STATE
void IRAM_ATTR sleep_retention_do_phy_retention(bool backup_or_restore)
{
/* since the PHY link and other module links are within the sleep-retention entry (4) context
* add mutex protection to avoid data race.
*/
#if SOC_PM_PAU_REGDMA_COMMON_PHY_LINK_ENTRY
_lock_acquire_recursive(&s_retention.lock);
#endif
if (backup_or_restore) {
pau_regdma_trigger_modem_link_backup();
} else {
pau_regdma_trigger_modem_link_restore();
}
#if SOC_PM_PAU_REGDMA_COMMON_PHY_LINK_ENTRY
_lock_release_recursive(&s_retention.lock);
#endif
}
#endif /*SOC_PM_SUPPORT_PMU_MODEM_STATE */

View File

@@ -1559,6 +1559,10 @@ config SOC_PM_PAU_REGDMA_LINK_IDX_WIFIMAC
int
default 4
config SOC_PM_PAU_REGDMA_COMMON_PHY_LINK_ENTRY
bool
default y
config SOC_PM_PMU_MIN_SLP_SLOW_CLK_CYCLE_FIXED
bool
default y

View File

@@ -627,6 +627,7 @@
#define SOC_PM_PAU_LINK_NUM (5)
#define SOC_PM_PAU_REGDMA_LINK_CONFIGURABLE (1)
#define SOC_PM_PAU_REGDMA_LINK_IDX_WIFIMAC (4) // The range of values for the link index is [0, SOC_PM_PAU_LINK_NUM)
#define SOC_PM_PAU_REGDMA_COMMON_PHY_LINK_ENTRY (1)
#define SOC_PM_PMU_MIN_SLP_SLOW_CLK_CYCLE_FIXED (1)