mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
esp32/spiflash: Fix error to pause the other CPU during operation
Whenever a SPI flash operation will take place, it's necessary to disable the cache and run no code from the flash. This includes pausing the other CPU (when `CONFIG_SMP=y`). This commit prevents an error to occur when the CPU core is evaluated before the task is increased to the max priority.
This commit is contained in:
committed by
Xiang Xiao
parent
d5c654914e
commit
78fbc2fc64
@@ -463,18 +463,22 @@ static inline void spi_reset_regbits(struct esp32_spiflash_s *priv,
|
|||||||
static void esp32_spiflash_opstart(void)
|
static void esp32_spiflash_opstart(void)
|
||||||
{
|
{
|
||||||
struct tcb_s *tcb = this_task();
|
struct tcb_s *tcb = this_task();
|
||||||
int cpu = up_cpu_index();
|
|
||||||
int saved_priority = tcb->sched_priority;
|
int saved_priority = tcb->sched_priority;
|
||||||
|
int cpu;
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
int other_cpu = cpu ? 0 : 1;
|
int other_cpu;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DEBUGASSERT(cpu == 0 || cpu == 1);
|
|
||||||
|
|
||||||
/* Temporary raise schedule priority */
|
/* Temporary raise schedule priority */
|
||||||
|
|
||||||
nxsched_set_priority(tcb, SCHED_PRIORITY_MAX);
|
nxsched_set_priority(tcb, SCHED_PRIORITY_MAX);
|
||||||
|
|
||||||
|
cpu = up_cpu_index();
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
other_cpu = cpu == 1 ? 0 : 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DEBUGASSERT(cpu == 0 || cpu == 1);
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
DEBUGASSERT(other_cpu == 0 || other_cpu == 1);
|
DEBUGASSERT(other_cpu == 0 || other_cpu == 1);
|
||||||
DEBUGASSERT(other_cpu != cpu);
|
DEBUGASSERT(other_cpu != cpu);
|
||||||
|
|||||||
Reference in New Issue
Block a user