mirror of
https://github.com/espressif/esp-idf.git
synced 2026-07-16 07:53:05 +03:00
Merge branch 'fix-fix_rtc_spinlock_sleep_dead_lock_v5.5' into 'release/v5.5'
fix(esp_hw_support): fix possible dead lock in deepsleep process (v5.5) See merge request espressif/esp-idf!49176
This commit is contained in:
@@ -1228,10 +1228,18 @@ static esp_err_t FORCE_IRAM_ATTR deep_sleep_start(bool allow_sleep_rejection)
|
||||
|
||||
esp_sync_timekeeping_timers();
|
||||
|
||||
// Must acquire all spinlocks which may be acquired during sleep process before stalling other core,
|
||||
// otherwise deadlock may occur.
|
||||
portENTER_CRITICAL(&spinlock_rtc_deep_sleep);
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
extern portMUX_TYPE rtc_spinlock;
|
||||
portENTER_CRITICAL_SAFE(&rtc_spinlock); // Maybe acquired from temp_sensor_get_raw_value by phy_close_rf callback
|
||||
esp_clk_private_lock(); // Maybe acquired from esp_clk_slowclk_cal_set
|
||||
#endif
|
||||
|
||||
/* Disable interrupts and stall another core in case another task writes
|
||||
* to RTC memory while we calculate RTC memory CRC.
|
||||
*/
|
||||
portENTER_CRITICAL(&spinlock_rtc_deep_sleep);
|
||||
esp_ipc_isr_stall_other_cpu();
|
||||
esp_ipc_isr_stall_pause();
|
||||
|
||||
@@ -1302,6 +1310,10 @@ static esp_err_t FORCE_IRAM_ATTR deep_sleep_start(bool allow_sleep_rejection)
|
||||
// Never returns here, except that the sleep is rejected.
|
||||
esp_ipc_isr_stall_resume();
|
||||
esp_ipc_isr_release_other_cpu();
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
esp_clk_private_unlock();
|
||||
portEXIT_CRITICAL_SAFE(&rtc_spinlock);
|
||||
#endif
|
||||
portEXIT_CRITICAL(&spinlock_rtc_deep_sleep);
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user