mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
esp32s3/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
78fbc2fc64
commit
007dd34ce8
@@ -285,22 +285,26 @@ static void spiflash_resume_cache(void)
|
|||||||
static void spiflash_start(void)
|
static void spiflash_start(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
|
||||||
|
|
||||||
nxrmutex_lock(&g_flash_op_mutex);
|
nxrmutex_lock(&g_flash_op_mutex);
|
||||||
|
|
||||||
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
|
#ifdef CONFIG_SMP
|
||||||
|
other_cpu = cpu == 1 ? 0 : 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DEBUGASSERT(cpu == 0 || cpu == 1);
|
||||||
|
|
||||||
|
#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);
|
||||||
if (OSINIT_OS_READY())
|
if (OSINIT_OS_READY())
|
||||||
|
|||||||
Reference in New Issue
Block a user