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/09/24 02:01:36 UTC

[incubator-nuttx] branch master updated (f2f2040 -> 9c2c5d3)

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

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


    from f2f2040  esp32_spiram/psram/himem: Add and fix the files' sections.
     new d0e7d7b  risc-v/esp32-c3: Remove _s of non static variables from esp32c3_rt_timer.c
     new 9c2c5d3  risc-v/esp32-c3: fix pid initiatialization on esp32c3_rt_timer.c

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/risc-v/src/esp32c3/esp32c3_rt_timer.c | 58 +++++++++++++++---------------
 1 file changed, 30 insertions(+), 28 deletions(-)

[incubator-nuttx] 01/02: risc-v/esp32-c3: Remove _s of non static variables from esp32c3_rt_timer.c

Posted by xi...@apache.org.
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

commit d0e7d7b77fbcd0233904e802e574bf12efd9276a
Author: Sara Souza <sa...@espressif.com>
AuthorDate: Thu Sep 23 11:23:02 2021 -0300

    risc-v/esp32-c3: Remove _s of non static variables from esp32c3_rt_timer.c
---
 arch/risc-v/src/esp32c3/esp32c3_rt_timer.c | 50 +++++++++++++++---------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c b/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
index 661a113..8c3cfdf 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
@@ -69,9 +69,9 @@
 struct esp32c3_rt_priv_s
 {
   int pid;
-  sem_t s_toutsem;
-  struct list_node s_runlist;
-  struct list_node s_toutlist;
+  sem_t toutsem;
+  struct list_node runlist;
+  struct list_node toutlist;
   struct esp32c3_tim_dev_s *timer;
 };
 
@@ -141,7 +141,7 @@ static void start_rt_timer(struct rt_timer_s *timer,
        * node of timer whose alarm value is larger than new one
        */
 
-      list_for_every_entry(&priv->s_runlist, p, struct rt_timer_s, list)
+      list_for_every_entry(&priv->runlist, p, struct rt_timer_s, list)
         {
           if (p->alarm > timer->alarm)
             {
@@ -157,14 +157,14 @@ static void start_rt_timer(struct rt_timer_s *timer,
 
       if (!inserted)
         {
-          list_add_tail(&priv->s_runlist, &timer->list);
+          list_add_tail(&priv->runlist, &timer->list);
         }
 
       timer->state = RT_TIMER_READY;
 
       /* If this timer is at the head of the list */
 
-      if (timer == container_of(priv->s_runlist.next,
+      if (timer == container_of(priv->runlist.next,
                                 struct rt_timer_s, list))
         {
           /* Reset the hardware timer alarm */
@@ -214,7 +214,7 @@ static void stop_rt_timer(struct rt_timer_s *timer)
     {
       /* Check if the timer is at the head of the list */
 
-      if (timer == container_of(priv->s_runlist.next,
+      if (timer == container_of(priv->runlist.next,
                                 struct rt_timer_s, list))
         {
           ishead = true;
@@ -231,13 +231,13 @@ static void stop_rt_timer(struct rt_timer_s *timer)
 
       if (ishead)
         {
-          if (!list_is_empty(&priv->s_runlist))
+          if (!list_is_empty(&priv->runlist))
             {
               /* Set the value from the next timer as the new hardware timer
                * alarm value.
                */
 
-              next_timer = container_of(priv->s_runlist.next,
+              next_timer = container_of(priv->runlist.next,
                                         struct rt_timer_s,
                                         list);
               alarm = next_timer->alarm;
@@ -289,12 +289,12 @@ static void delete_rt_timer(struct rt_timer_s *timer)
       goto exit;
     }
 
-  list_add_after(&priv->s_toutlist, &timer->list);
+  list_add_after(&priv->toutlist, &timer->list);
   timer->state = RT_TIMER_DELETE;
 
   /* Wake up the thread to process deleted timers */
 
-  ret = nxsem_post(&priv->s_toutsem);
+  ret = nxsem_post(&priv->toutsem);
   if (ret < 0)
     {
       tmrerr("ERROR: Failed to post sem ret=%d\n", ret);
@@ -332,10 +332,10 @@ static int rt_timer_thread(int argc, char *argv[])
     {
       /* Waiting for all timers to time out */
 
-      ret = nxsem_wait(&priv->s_toutsem);
+      ret = nxsem_wait(&priv->toutsem);
       if (ret)
         {
-          tmrerr("ERROR: Wait s_toutsem error=%d\n", ret);
+          tmrerr("ERROR: Wait toutsem error=%d\n", ret);
           assert(0);
         }
 
@@ -343,11 +343,11 @@ static int rt_timer_thread(int argc, char *argv[])
 
       /* Process all the timers in list */
 
-      while (!list_is_empty(&priv->s_toutlist))
+      while (!list_is_empty(&priv->toutlist))
         {
           /* Get the first timer in the list */
 
-          timer = container_of(priv->s_toutlist.next,
+          timer = container_of(priv->toutlist.next,
                                struct rt_timer_s, list);
 
           /* Cache the raw state to decide how to deal with this timer */
@@ -428,7 +428,7 @@ static int rt_timer_isr(int irq, void *context, void *arg)
 
   /* Check if there is a timer running */
 
-  if (!list_is_empty(&priv->s_runlist))
+  if (!list_is_empty(&priv->runlist))
     {
       /**
        * When stop/delete timer, in the same time the hardware timer
@@ -436,7 +436,7 @@ static int rt_timer_isr(int irq, void *context, void *arg)
        * from running list, so the 1st timer is not which triggers.
        */
 
-      timer = container_of(priv->s_runlist.next, struct rt_timer_s, list);
+      timer = container_of(priv->runlist.next, struct rt_timer_s, list);
       ESP32C3_TIM_GETCTR(priv->timer, &counter);
       counter = CYCLES_TO_USEC(counter);
       if (timer->alarm <= counter)
@@ -450,16 +450,16 @@ static int rt_timer_isr(int irq, void *context, void *arg)
 
           list_delete(&timer->list);
           timer->state = RT_TIMER_TIMEOUT;
-          list_add_after(&priv->s_toutlist, &timer->list);
+          list_add_after(&priv->toutlist, &timer->list);
           wake = true;
 
           /* Check if there is a timer running */
 
-          if (!list_is_empty(&priv->s_runlist))
+          if (!list_is_empty(&priv->runlist))
             {
               /* Reset hardware timer alarm with next timer's alarm value */
 
-              timer = container_of(priv->s_runlist.next,
+              timer = container_of(priv->runlist.next,
                                    struct rt_timer_s, list);
               alarm = timer->alarm;
 
@@ -476,7 +476,7 @@ static int rt_timer_isr(int irq, void *context, void *arg)
     {
       /* Wake up the thread to process timed-out timers */
 
-      ret = nxsem_post(&priv->s_toutsem);
+      ret = nxsem_post(&priv->toutsem);
       if (ret < 0)
         {
           tmrerr("ERROR: Failed to post sem ret=%d\n", ret);
@@ -716,7 +716,7 @@ int esp32c3_rt_timer_init(void)
       return -EINVAL;
     }
 
-  nxsem_init(&priv->s_toutsem, 0, 0);
+  nxsem_init(&priv->toutsem, 0, 0);
 
   priv->pid = kthread_create(RT_TIMER_TASK_NAME,
                        RT_TIMER_TASK_PRIORITY,
@@ -730,8 +730,8 @@ int esp32c3_rt_timer_init(void)
       return priv->pid;
     }
 
-  list_initialize(&priv->s_runlist);
-  list_initialize(&priv->s_toutlist);
+  list_initialize(&priv->runlist);
+  list_initialize(&priv->toutlist);
 
   flags = enter_critical_section();
 
@@ -790,5 +790,5 @@ void esp32c3_rt_timer_deinit(void)
       priv->pid = -EINVAL;
     }
 
-  nxsem_destroy(&priv->s_toutsem);
+  nxsem_destroy(&priv->toutsem);
 }

[incubator-nuttx] 02/02: risc-v/esp32-c3: fix pid initiatialization on esp32c3_rt_timer.c

Posted by xi...@apache.org.
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

commit 9c2c5d39194cdfa00990a413da00306ba53854fe
Author: Sara Souza <sa...@espressif.com>
AuthorDate: Thu Sep 23 11:27:06 2021 -0300

    risc-v/esp32-c3: fix pid initiatialization on esp32c3_rt_timer.c
    
    pid variable was initialized to -EINVAL to prevent rt_timer_deinit
    from delete an invalid kthread. But priv->pid was being overwritten in the
    rt_timer_init, so in case of failure to create a kthread, it would
    call rt_timer_deinit with a non expected initialization value.
---
 arch/risc-v/src/esp32c3/esp32c3_rt_timer.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c b/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
index 8c3cfdf..c703bab 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
@@ -718,21 +718,23 @@ int esp32c3_rt_timer_init(void)
 
   nxsem_init(&priv->toutsem, 0, 0);
 
-  priv->pid = kthread_create(RT_TIMER_TASK_NAME,
+  pid = kthread_create(RT_TIMER_TASK_NAME,
                        RT_TIMER_TASK_PRIORITY,
                        RT_TIMER_TASK_STACK_SIZE,
                        rt_timer_thread,
                        NULL);
-  if (priv->pid < 0)
+  if (pid < 0)
     {
       tmrerr("ERROR: Failed to create RT timer task error=%d\n", pid);
       esp32c3_tim_deinit(priv->timer);
-      return priv->pid;
+      return pid;
     }
 
   list_initialize(&priv->runlist);
   list_initialize(&priv->toutlist);
 
+  priv->pid = pid;
+
   flags = enter_critical_section();
 
   /* ESP32-C3 hardware timer configuration: