From 42dea9edf903329d5a4cb285bcbf1fcd68b23637 Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Fri, 20 Nov 2020 13:36:17 +0900 Subject: [PATCH] arch: lc823450: Fix the pause handler for SMP Summary: - Apply the same logic added to cxd56_cpupause.c Impact: - SMP only Testing: - Tested with lc823450-xgevk:rndis - Run smp and ostest Signed-off-by: Masayuki Ishikawa --- arch/arm/src/lc823450/lc823450_cpupause.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/lc823450/lc823450_cpupause.c b/arch/arm/src/lc823450/lc823450_cpupause.c index 2714fc3c2d..b172df1ea4 100644 --- a/arch/arm/src/lc823450/lc823450_cpupause.c +++ b/arch/arm/src/lc823450/lc823450_cpupause.c @@ -190,6 +190,7 @@ int up_cpu_paused(int cpu) int lc823450_pause_handler(int irq, void *c, FAR void *arg) { int cpu = up_cpu_index(); + int ret = OK; /* Clear : Pause IRQ */ @@ -211,10 +212,21 @@ int lc823450_pause_handler(int irq, void *c, FAR void *arg) if (spin_islocked(&g_cpu_paused[cpu])) { - return up_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(); + + ret = up_cpu_paused(cpu); + + leave_critical_section(flags); } - return OK; + return ret; } /****************************************************************************