You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/10/16 16:46:28 UTC

[incubator-nuttx] branch master updated: arch/xtensa/xtensa_cpupause.c: Allow a spin before taking the g_cpu_wait spinlock.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new d2bc011  arch/xtensa/xtensa_cpupause.c: Allow a spin before taking the g_cpu_wait spinlock.
d2bc011 is described below

commit d2bc01171960847a0b7f308e5907ba1baa23387b
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Fri Oct 15 18:53:05 2021 +0200

    arch/xtensa/xtensa_cpupause.c: Allow a spin before taking the g_cpu_wait
    spinlock.
    
    If we repeatedly call up_cpu_pause and up_cpu_resume, there would be
    cases where the next call to up_cpu_pause happens while the other CPU is
    still responding to the previous resume request.  In this case the
    DEBUGASSERT will trigger.  We should allow the first CPU to wait until the
    other CPU has finished responding to the resume request.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 arch/xtensa/src/common/xtensa_cpupause.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/xtensa/src/common/xtensa_cpupause.c b/arch/xtensa/src/common/xtensa_cpupause.c
index db16c96..b6fbead 100644
--- a/arch/xtensa/src/common/xtensa_cpupause.c
+++ b/arch/xtensa/src/common/xtensa_cpupause.c
@@ -231,10 +231,12 @@ int up_cpu_pause(int cpu)
    * handler from returning until up_cpu_resume() is called; g_cpu_paused
    * is a handshake that will prevent this function from returning until
    * the CPU is actually paused.
+   * Note that we might spin before getting g_cpu_wait, this just means that
+   * the other CPU still hasn't finished responding to the previous resume
+   * request.
    */
 
-  DEBUGASSERT(!spin_islocked(&g_cpu_wait[cpu]) &&
-              !spin_islocked(&g_cpu_paused[cpu]));
+  DEBUGASSERT(!spin_islocked(&g_cpu_paused[cpu]));
 
   spin_lock(&g_cpu_wait[cpu]);
   spin_lock(&g_cpu_paused[cpu]);