spi_flash: raise priority of the task performing spi_flash operation
Fixes https://github.com/espressif/arduino-esp32/issues/740
This commit is contained in:
parent
f53f40396b
commit
ceafbca0a2
1 changed files with 7 additions and 0 deletions
|
@ -110,6 +110,11 @@ void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu()
|
||||||
assert(other_cpuid == 1);
|
assert(other_cpuid == 1);
|
||||||
spi_flash_disable_cache(other_cpuid, &s_flash_op_cache_state[other_cpuid]);
|
spi_flash_disable_cache(other_cpuid, &s_flash_op_cache_state[other_cpuid]);
|
||||||
} else {
|
} else {
|
||||||
|
// Temporarily raise current task priority to prevent a deadlock while
|
||||||
|
// waiting for IPC task to start on the other CPU
|
||||||
|
TaskHandle_t self = xTaskGetCurrentTaskHandle();
|
||||||
|
int old_prio = uxTaskPriorityGet(self);
|
||||||
|
vTaskPrioritySet(self, configMAX_PRIORITIES - 1);
|
||||||
// Signal to the spi_flash_op_block_task on the other CPU that we need it to
|
// Signal to the spi_flash_op_block_task on the other CPU that we need it to
|
||||||
// disable cache there and block other tasks from executing.
|
// disable cache there and block other tasks from executing.
|
||||||
s_flash_op_can_start = false;
|
s_flash_op_can_start = false;
|
||||||
|
@ -121,6 +126,8 @@ void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu()
|
||||||
}
|
}
|
||||||
// Disable scheduler on the current CPU
|
// Disable scheduler on the current CPU
|
||||||
vTaskSuspendAll();
|
vTaskSuspendAll();
|
||||||
|
// Can now set the priority back to the normal one
|
||||||
|
vTaskPrioritySet(self, old_prio);
|
||||||
// This is guaranteed to run on CPU <cpuid> because the other CPU is now
|
// This is guaranteed to run on CPU <cpuid> because the other CPU is now
|
||||||
// occupied by highest priority task
|
// occupied by highest priority task
|
||||||
assert(xPortGetCoreID() == cpuid);
|
assert(xPortGetCoreID() == cpuid);
|
||||||
|
|
Loading…
Reference in a new issue