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

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

commit 823a183c177a8c417024cef1a0431367f01e7df9
Author: Tiago Medicci Serrano <tiago.medi...@espressif.com>
AuthorDate: Fri Dec 22 16:22:34 2023 -0300

    esp32s3/rt_timer: Fix deadlock on RT-Timer thread.
    
    The RT-Timer thread may call the `start_rt_timer` function. This
    function gets the spinlock with interrupts disabled to ensure
    exclusive access. However, this was already being performed in the
    RT-Timer thread, causing a deadlock.
---
 arch/xtensa/src/esp32s3/esp32s3_rt_timer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c 
b/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c
index 33c47926b0..46199135b0 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c
@@ -572,10 +572,6 @@ static int rt_timer_thread(int argc, char *argv[])
               kmm_free(timer);
             }
 
-          /* Enter critical section for next scanning list */
-
-          flags = spin_lock_irqsave(&priv->lock);
-
           if (raw_state == RT_TIMER_TIMEOUT)
             {
               /* Check if the timer is in "repeat" mode */
@@ -585,6 +581,10 @@ static int rt_timer_thread(int argc, char *argv[])
                   start_rt_timer(timer, timer->timeout, true);
                 }
             }
+
+          /* Enter critical section for next scanning list */
+
+          flags = spin_lock_irqsave(&priv->lock);
         }
 
       spin_unlock_irqrestore(&priv->lock, flags);

Reply via email to