riscv64: cpu_initclocks: install tb_timecounter before cpu_startclock()
authorcheloha <cheloha@openbsd.org>
Thu, 8 Sep 2022 03:09:40 +0000 (03:09 +0000)
committercheloha <cheloha@openbsd.org>
Thu, 8 Sep 2022 03:09:40 +0000 (03:09 +0000)
In the future, the clock interrupt code will need a real timecounter
to work correctly.  Nudge the tc_init(9) call for tb_timecounter up
before cpu_startclock().

sys/arch/riscv64/riscv64/clock.c

index 75643f9..b1ddd38 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: clock.c,v 1.4 2022/08/09 04:49:08 cheloha Exp $       */
+/*     $OpenBSD: clock.c,v 1.5 2022/09/08 03:09:40 cheloha Exp $       */
 
 /*
  * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
@@ -63,6 +63,9 @@ tb_get_timecount(struct timecounter *tc)
 void
 cpu_initclocks(void)
 {
+       tb_timecounter.tc_frequency = tb_freq;
+       tc_init(&tb_timecounter);
+
        tick_increment = tb_freq / hz;
 
        stathz = 100;
@@ -77,9 +80,6 @@ cpu_initclocks(void)
        evcount_attach(&stat_count, "stat", NULL);
 
        cpu_startclock();
-
-       tb_timecounter.tc_frequency = tb_freq;
-       tc_init(&tb_timecounter);
 }
 
 void