Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Call cpu_initclocks() before registering the defaul...



details:   https://anonhg.NetBSD.org/src/rev/4ccbd1643215
branches:  trunk
changeset: 944797:4ccbd1643215
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Oct 11 18:39:09 2020 +0000

description:
Call cpu_initclocks() before registering the default timecounter,
in case it updates hz.  If hz changes, recalculate tick and tickadj.

diffstat:

 sys/kern/kern_clock.c |  17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diffs (44 lines):

diff -r 1157502e9f68 -r 4ccbd1643215 sys/kern/kern_clock.c
--- a/sys/kern/kern_clock.c     Sun Oct 11 17:49:07 2020 +0000
+++ b/sys/kern/kern_clock.c     Sun Oct 11 18:39:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_clock.c,v 1.141 2020/05/08 22:10:09 ad Exp $      */
+/*     $NetBSD: kern_clock.c,v 1.142 2020/10/11 18:39:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.141 2020/05/08 22:10:09 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.142 2020/10/11 18:39:09 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
@@ -178,13 +178,24 @@
         * code do its bit.
         */
        psdiv = 1;
+
+       /*
+        * Call cpu_initclocks() before registering the default
+        * timecounter, in case it needs to adjust hz.
+        */
+       const int old_hz = hz;
+       cpu_initclocks();
+       if (old_hz != hz) {
+               tick = 1000000 / hz;
+               tickadj = (240000 / (60 * hz)) ? (240000 / (60 * hz)) : 1;
+       }
+
        /*
         * provide minimum default time counter
         * will only run at interrupt resolution
         */
        intr_timecounter.tc_frequency = hz;
        tc_init(&intr_timecounter);
-       cpu_initclocks();
 
        /*
         * Compute profhz and stathz, fix profhz if needed.



Home | Main Index | Thread Index | Old Index