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:
Ivan Grokhotkov
2018-05-04 12:50:39 +08:00
parent 296b280801
commit 8c307a5720
4 changed files with 60 additions and 0 deletions

View File

@@ -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;