This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 8fd797841d32941d5e25e6c98367e0c172b27c4c
Author: Masayuki Ishikawa <masayuki.ishik...@gmail.com>
AuthorDate: Fri Nov 20 13:33:43 2020 +0900

    arch: armv7-a: Fix the pause handler for SMP
    
    Summary:
    - Apply the same logic added to cxd56_cpupause.c
    
    Impact:
    - SMP only
    
    Testing:
    - Tested with sabre-6quad:smp (QEMU and dev board)
    - Run smp and ostest
    
    Signed-off-by: Masayuki Ishikawa <masayuki.ishik...@jp.sony.com>
---
 arch/arm/src/armv7-a/arm_cpupause.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/arm/src/armv7-a/arm_cpupause.c 
b/arch/arm/src/armv7-a/arm_cpupause.c
index 4725418..36d1eb0 100644
--- a/arch/arm/src/armv7-a/arm_cpupause.c
+++ b/arch/arm/src/armv7-a/arm_cpupause.c
@@ -205,6 +205,7 @@ int up_cpu_paused(int cpu)
 int arm_pause_handler(int irq, FAR void *context, FAR void *arg)
 {
   int cpu = this_cpu();
+  int ret = OK;
 
   /* Check for false alarms.  Such false could occur as a consequence of
    * some deadlock breaking logic that might have already serviced the SG2
@@ -214,10 +215,21 @@ int arm_pause_handler(int irq, FAR void *context, 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;
 }
 
 /****************************************************************************

Reply via email to