driver(interrupt): fix the issue that interrupt might be allocated and freed on different cores

closes https://github.com/espressif/esp-idf/issues/2211
This commit is contained in:
kooho
2018-09-20 12:13:43 +08:00
parent 607d899503
commit bbca0e46ed
3 changed files with 50 additions and 8 deletions

View File

@@ -29,6 +29,7 @@
#include "esp_intr.h"
#include "esp_attr.h"
#include "esp_intr_alloc.h"
#include "esp_ipc.h"
#include <limits.h>
#include <assert.h>
@@ -709,9 +710,11 @@ esp_err_t esp_intr_free(intr_handle_t handle)
{
bool free_shared_vector=false;
if (!handle) return ESP_ERR_INVALID_ARG;
//This routine should be called from the interrupt the task is scheduled on.
if (handle->vector_desc->cpu!=xPortGetCoreID()) return ESP_ERR_INVALID_ARG;
//Assign this routine to the core where this interrupt is allocated on.
if (handle->vector_desc->cpu!=xPortGetCoreID()) {
esp_err_t ret = esp_ipc_call_blocking(handle->vector_desc->cpu, (esp_ipc_func_t)&esp_intr_free, (void *)handle);
return ret == ESP_OK ? ESP_OK : ESP_FAIL;
}
portENTER_CRITICAL(&spinlock);
esp_intr_disable(handle);
if (handle->vector_desc->flags&VECDESC_FL_SHARED) {