mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
wifi/bt coexistence: Fix disabled cache access race when writing to flash
Moves the ets_timer_arm() / ets_timer_disarm() code paths to RAM Overhead is 740 bytes of IRAM, 0 bytes DRAM (For comparison: If all of esp_timer.c is moved to RAM, overhead is 1068 bytes IRAM and 480 bytes DRAM.)
This commit is contained in:

committed by
Angus Gratton

parent
b013f5d490
commit
094cf4d79d
@@ -108,7 +108,7 @@ esp_err_t esp_timer_create(const esp_timer_create_args_t* args,
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us)
|
||||
esp_err_t IRAM_ATTR esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us)
|
||||
{
|
||||
if (!is_initialized() || timer_armed(timer)) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@@ -121,7 +121,7 @@ esp_err_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us)
|
||||
return timer_insert(timer);
|
||||
}
|
||||
|
||||
esp_err_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period_us)
|
||||
esp_err_t IRAM_ATTR esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period_us)
|
||||
{
|
||||
if (!is_initialized() || timer_armed(timer)) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@@ -135,7 +135,7 @@ esp_err_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period_us)
|
||||
return timer_insert(timer);
|
||||
}
|
||||
|
||||
esp_err_t esp_timer_stop(esp_timer_handle_t timer)
|
||||
esp_err_t IRAM_ATTR esp_timer_stop(esp_timer_handle_t timer)
|
||||
{
|
||||
if (!is_initialized() || !timer_armed(timer)) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@@ -158,7 +158,7 @@ esp_err_t esp_timer_delete(esp_timer_handle_t timer)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t timer_insert(esp_timer_handle_t timer)
|
||||
static IRAM_ATTR esp_err_t timer_insert(esp_timer_handle_t timer)
|
||||
{
|
||||
timer_list_lock();
|
||||
#if WITH_PROFILING
|
||||
@@ -187,7 +187,7 @@ static esp_err_t timer_insert(esp_timer_handle_t timer)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t timer_remove(esp_timer_handle_t timer)
|
||||
static IRAM_ATTR esp_err_t timer_remove(esp_timer_handle_t timer)
|
||||
{
|
||||
timer_list_lock();
|
||||
LIST_REMOVE(timer, list_entry);
|
||||
@@ -202,7 +202,7 @@ static esp_err_t timer_remove(esp_timer_handle_t timer)
|
||||
|
||||
#if WITH_PROFILING
|
||||
|
||||
static void timer_insert_inactive(esp_timer_handle_t timer)
|
||||
static IRAM_ATTR void timer_insert_inactive(esp_timer_handle_t timer)
|
||||
{
|
||||
/* May be locked or not, depending on where this is called from.
|
||||
* Lock recursively.
|
||||
@@ -220,7 +220,7 @@ static void timer_insert_inactive(esp_timer_handle_t timer)
|
||||
timer_list_unlock();
|
||||
}
|
||||
|
||||
static void timer_remove_inactive(esp_timer_handle_t timer)
|
||||
static IRAM_ATTR void timer_remove_inactive(esp_timer_handle_t timer)
|
||||
{
|
||||
timer_list_lock();
|
||||
LIST_REMOVE(timer, list_entry);
|
||||
@@ -229,17 +229,17 @@ static void timer_remove_inactive(esp_timer_handle_t timer)
|
||||
|
||||
#endif // WITH_PROFILING
|
||||
|
||||
static bool timer_armed(esp_timer_handle_t timer)
|
||||
static IRAM_ATTR bool timer_armed(esp_timer_handle_t timer)
|
||||
{
|
||||
return timer->alarm > 0;
|
||||
}
|
||||
|
||||
static void timer_list_lock()
|
||||
static IRAM_ATTR void timer_list_lock()
|
||||
{
|
||||
portENTER_CRITICAL(&s_timer_lock);
|
||||
}
|
||||
|
||||
static void timer_list_unlock()
|
||||
static IRAM_ATTR void timer_list_unlock()
|
||||
{
|
||||
portEXIT_CRITICAL(&s_timer_lock);
|
||||
}
|
||||
@@ -305,7 +305,7 @@ static void IRAM_ATTR timer_alarm_handler(void* arg)
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_initialized()
|
||||
static IRAM_ATTR bool is_initialized()
|
||||
{
|
||||
return s_timer_task != NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user