From 1914aac05f5b29e4fc54b143f3c461154efde96f Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Fri, 20 Nov 2020 13:47:56 +0900 Subject: [PATCH] arch: xtensa: Fix the pause handler for SMP Summary: - Apply the same logic added to cxd56_cpupause.c Impact: - SMP only Testing: - Tested with esp32-core:smp (QEMU) - Run smp and ostest Signed-off-by: Masayuki Ishikawa --- arch/xtensa/src/common/xtensa_cpupause.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/xtensa/src/common/xtensa_cpupause.c b/arch/xtensa/src/common/xtensa_cpupause.c index 5b59200ab2..0d7c4860b6 100644 --- a/arch/xtensa/src/common/xtensa_cpupause.c +++ b/arch/xtensa/src/common/xtensa_cpupause.c @@ -192,7 +192,18 @@ void xtensa_pause_handler(void) if (spin_islocked(&g_cpu_paused[cpu])) { + /* NOTE: up_cpu_paused() needs to be executed in a critical section + * to ensure that this CPU holds g_cpu_irqlock. However, adding + * a critical section in up_cpu_paused() is not a good idea, + * because it is also called in enter_critical_section() to break + * a deadlock + */ + + irqstate_t flags = enter_critical_section(); + up_cpu_paused(cpu); + + leave_critical_section(flags); } }