diff --git a/arch/xtensa/src/esp32/esp32_cpustart.c b/arch/xtensa/src/esp32/esp32_cpustart.c index a1c003d164..172b424b33 100644 --- a/arch/xtensa/src/esp32/esp32_cpustart.c +++ b/arch/xtensa/src/esp32/esp32_cpustart.c @@ -41,13 +41,12 @@ #include #include -#include #include #include #include #include -#include +#include #include #include "sched/sched.h" @@ -65,7 +64,7 @@ ****************************************************************************/ static volatile bool g_appcpu_started; -static sem_t g_appcpu_interlock; +static volatile spinlock_t g_appcpu_interlock SP_SECTION; /**************************************************************************** * ROM function prototypes @@ -169,7 +168,7 @@ void xtensa_appcpu_start(void) /* Handle interlock*/ g_appcpu_started = true; - sem_post(&g_appcpu_interlock); + spin_unlock(&g_appcpu_interlock); /* Reset scheduler parameters */ @@ -271,8 +270,7 @@ int up_cpu_start(int cpu) * have priority inheritance enabled. */ - sem_init(&g_appcpu_interlock, 0, 0); - sem_setprotocol(&g_appcpu_interlock, SEM_PRIO_NONE); + spin_initialize(&g_appcpu_interlock, SP_LOCKED); /* Flush and enable I-cache for APP CPU */ @@ -315,16 +313,8 @@ int up_cpu_start(int cpu) /* And wait for the initial task to run on CPU1 */ - while (!g_appcpu_started) - { - ret = sem_wait(&g_appcpu_interlock); - if (ret < 0) - { - DEBUGASSERT(errno == EINTR); - } - } - - sem_destroy(&g_appcpu_interlock); + spin_lock(&g_appcpu_interlock); + DEBUGASSERT(g_appcpu_started); } return OK; diff --git a/include/nuttx/spinlock.h b/include/nuttx/spinlock.h index 44b907bc61..6f3409ca90 100644 --- a/include/nuttx/spinlock.h +++ b/include/nuttx/spinlock.h @@ -145,15 +145,16 @@ spinlock_t up_testset(volatile FAR spinlock_t *lock); * Initialize a non-reentrant spinlock object to its initial, unlocked state. * * Input Parameters: - * lock - A reference to the spinlock object to be initialized. + * lock - A reference to the spinlock object to be initialized. + * state - Initial state of the spinlock {SP_LOCKED or SP_UNLOCKED) * * Returned Value: * None. * ****************************************************************************/ -/* void spin_initialize(FAR spinlock_t *lock); */ -#define spin_initialize(i) do { (l) = SP_UNLOCKED; } while (0) +/* void spin_initialize(FAR spinlock_t *lock, spinlock_t state); */ +#define spin_initialize(l,s) do { *(l) = (s); } while (0) /**************************************************************************** * Name: spin_initializer