mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
sleep: fix deadlock in esp_timer_impl_advance after light sleep
When light sleep is started, the other CPU gets halted using DPORT stall mechanism. This can happen while it is inside an esp_timer critical section, which may lead to a deadlock. This change adds functions to take and release esp_timer lock before entering DPORT critical section, preventing the deadlock.
This commit is contained in:
@@ -165,6 +165,16 @@ static inline void IRAM_ATTR timer_count_reload(void)
|
||||
REG_WRITE(FRC_TIMER_LOAD_REG(1), REG_READ(FRC_TIMER_COUNT_REG(1)) - ALARM_OVERFLOW_VAL);
|
||||
}
|
||||
|
||||
void esp_timer_impl_lock()
|
||||
{
|
||||
portENTER_CRITICAL(&s_time_update_lock);
|
||||
}
|
||||
|
||||
void esp_timer_impl_unlock()
|
||||
{
|
||||
portEXIT_CRITICAL(&s_time_update_lock);
|
||||
}
|
||||
|
||||
uint64_t IRAM_ATTR esp_timer_impl_get_time()
|
||||
{
|
||||
uint32_t timer_val;
|
||||
|
Reference in New Issue
Block a user