You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/07/10 17:50:38 UTC

[GitHub] [incubator-nuttx] antmerlino commented on a change in pull request #1380: arch/stm32f7: Fixes bug in tickless driver where the compare register…

antmerlino commented on a change in pull request #1380:
URL: https://github.com/apache/incubator-nuttx/pull/1380#discussion_r452987473



##########
File path: arch/arm/src/stm32f7/stm32_tickless.c
##########
@@ -988,22 +988,31 @@ int up_timer_start(FAR const struct timespec *ts)
 }
 #endif
 
+#ifdef CONFIG_SCHED_TICKLESS_ALARM
 int up_alarm_start(FAR const struct timespec *ts)
 {
   uint64_t tm = ((uint64_t)ts->tv_sec * NSEC_PER_SEC + ts->tv_nsec) /
                 NSEC_PER_TICK;
-  uint64_t counter = ((uint64_t)g_tickless.overflow << 32) |
-                     STM32_TIM_GETCOUNTER(g_tickless.tch);
-
-  g_tickless.last_alrm = tm;
+  irqstate_t flags;
 
-  int32_t diff = tm / NSEC_PER_TICK + counter;
+  flags = enter_critical_section();
 
   STM32_TIM_SETCOMPARE(g_tickless.tch, CONFIG_STM32F7_TICKLESS_CHANNEL, tm);
 
   stm32_tickless_ackint(g_tickless.channel);
   stm32_tickless_enableint(CONFIG_STM32F7_TICKLESS_CHANNEL);
 
+  g_tickless.pending = true;
+
+  uint64_t counter = ((uint64_t)g_tickless.overflow << 32) |
+                     STM32_TIM_GETCOUNTER(g_tickless.tch);
+
+  if (counter > tm)
+    {
+      stm32_interval_handler();

Review comment:
       Okay, my report was wrong. There was never a race condition at the sig_timedwait level - Greg's answer cleared that up for me. I just didn't protect for the race condition completely at the STM32 level, there was still a very specific timing sequence that would cause it to lock up.
   
   I've now been running stable with the latest branch.
   
   I can't get the nxstyle line 800 error to go away. Otherwise I fixed all other formatting issues.
   
   This is ready for final review and then merging.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org