From d6ce32f057b2a7f8c7c96b73f3ea9f1adfac755b Mon Sep 17 00:00:00 2001 From: hujun5 Date: Tue, 8 Oct 2024 21:01:08 +0800 Subject: [PATCH] sim: fix sim smp boot regression This commit fixes the regression from https://github.com/apache/nuttx/pull/13716 Signed-off-by: hujun5 --- arch/sim/src/sim/posix/sim_hostsmp.c | 2 ++ arch/sim/src/sim/sim_doirq.c | 10 ++++++++++ arch/sim/src/sim/sim_internal.h | 1 + include/nuttx/irq.h | 5 +---- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/sim/src/sim/posix/sim_hostsmp.c b/arch/sim/src/sim/posix/sim_hostsmp.c index f338c5b38ac75..beed1dd332cd5 100644 --- a/arch/sim/src/sim/posix/sim_hostsmp.c +++ b/arch/sim/src/sim/posix/sim_hostsmp.c @@ -106,6 +106,8 @@ static void *sim_idle_trampoline(void *arg) host_cpu_started(); + sim_unlock(); + /* The idle Loop */ for (; ; ) diff --git a/arch/sim/src/sim/sim_doirq.c b/arch/sim/src/sim/sim_doirq.c index 62fba5aaea44e..5adcf15cdfadc 100644 --- a/arch/sim/src/sim/sim_doirq.c +++ b/arch/sim/src/sim/sim_doirq.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "sim_internal.h" @@ -34,6 +35,15 @@ * Public Functions ****************************************************************************/ +void sim_unlock(void) +{ + /* wait until cpu0 in idle() */ + + while (!OSINIT_IDLELOOP()); + + sched_unlock(); +} + /**************************************************************************** * Name: sim_doirq ****************************************************************************/ diff --git a/arch/sim/src/sim/sim_internal.h b/arch/sim/src/sim/sim_internal.h index 5660d9d129a80..1c35be0d965f7 100644 --- a/arch/sim/src/sim/sim_internal.h +++ b/arch/sim/src/sim/sim_internal.h @@ -206,6 +206,7 @@ extern char **g_argv; void sim_copyfullstate(xcpt_reg_t *dest, xcpt_reg_t *src); void *sim_doirq(int irq, void *regs); +void sim_unlock(void); /* sim_hostmisc.c ***********************************************************/ diff --git a/include/nuttx/irq.h b/include/nuttx/irq.h index 1f38864b5d3cb..0c94f71a3ad6c 100644 --- a/include/nuttx/irq.h +++ b/include/nuttx/irq.h @@ -80,10 +80,7 @@ do \ { \ g_cpu_irqset = 0; \ - SP_DMB(); \ - g_cpu_irqlock = SP_UNLOCKED; \ - SP_DSB(); \ - SP_SEV(); \ + spin_unlock_wo_note(&g_cpu_irqlock); \ } \ while (0) #endif