xiaoxiang781216 commented on code in PR #15929: URL: https://github.com/apache/nuttx/pull/15929#discussion_r1984689321
########## 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: should we remove? ``` static int riscv_mtimer_max_delay(struct oneshot_lowerhalf_s *lower, struct timespec *ts); static int riscv_mtimer_start(struct oneshot_lowerhalf_s *lower, oneshot_callback_t callback, void *arg, const struct timespec *ts); static int riscv_mtimer_cancel(struct oneshot_lowerhalf_s *lower, struct timespec *ts); ``` and keep: ``` static int riscv_mtimer_current(struct oneshot_lowerhalf_s *lower, struct timespec *ts); ``` keep: ``` static int riscv_mtimer_tick_max_delay(struct oneshot_lowerhalf_s *lower, clock_t *ticks); static int riscv_mtimer_tick_start(struct oneshot_lowerhalf_s *lower, oneshot_callback_t callback, void *arg, clock_t ticks); static int riscv_mtimer_tick_cancel(struct oneshot_lowerhalf_s *lower, clock_t *ticks); ``` remove: ``` static int riscv_mtimer_tick_current(struct oneshot_lowerhalf_s *lower, clock_t *ticks); ``` so, we can make both side happy. -- 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