From bbc6571b284eb811893d915f1f8c1085f71c41e3 Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Tue, 29 Sep 2020 08:17:17 +0900 Subject: [PATCH] arch: arm: Fix up_interrupt_context() for SMP Summary: - I found an issue with up_interrupt_context() when testing. - And finally found that up_interrupt_context() is not atomic. - This commit fixes the issue Impact: - Affects SMP only Testing: - Tested with spresense:wifi_smp and sabre-6quad:smp (qemu) Signed-off-by: Masayuki Ishikawa --- arch/arm/src/common/arm_interruptcontext.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/common/arm_interruptcontext.c b/arch/arm/src/common/arm_interruptcontext.c index 07385351269..6ec9d122377 100644 --- a/arch/arm/src/common/arm_interruptcontext.c +++ b/arch/arm/src/common/arm_interruptcontext.c @@ -59,5 +59,15 @@ bool up_interrupt_context(void) { - return CURRENT_REGS != NULL; +#ifdef CONFIG_SMP + irqstate_t flags = up_irq_save(); +#endif + + bool ret = CURRENT_REGS != NULL; + +#ifdef CONFIG_SMP + up_irq_restore(flags); +#endif + + return ret; }