jlaitine commented on code in PR #15929:
URL: https://github.com/apache/nuttx/pull/15929#discussion_r1984702546


##########
arch/risc-v/src/common/riscv_mtimer.c:
##########
@@ -222,8 +221,11 @@ static int riscv_mtimer_start(struct oneshot_lowerhalf_s 
*lower,
   flags = up_irq_save();
 
   mtime = riscv_mtimer_get_mtime(priv);
-  alarm = mtime + ts->tv_sec * priv->freq +
-          ts->tv_nsec * priv->freq / NSEC_PER_SEC;
+
+  /* Align each tick start to cycle_per_tick boundary to avoid clock drift */
+
+  alarm = mtime / priv->cycle_per_tick * priv->cycle_per_tick +

Review Comment:
   I'd like to see that we keep both  riscv_mtimer_current and 
riscv_mtimer_tick_current . If you need to get the number of the current tick, 
you probably should have an interface for that?
   
   On the other hand, it shouldn't harm to define all the existing interfaces?



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

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

Reply via email to