Module Name:    src
Committed By:   thorpej
Date:           Sun Oct 11 18:39:09 UTC 2020

Modified Files:
        src/sys/kern: kern_clock.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/kern/kern_clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_clock.c
diff -u src/sys/kern/kern_clock.c:1.141 src/sys/kern/kern_clock.c:1.142
--- src/sys/kern/kern_clock.c:1.141	Fri May  8 22:10:09 2020
+++ src/sys/kern/kern_clock.c	Sun Oct 11 18:39:09 2020
@@ -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 @@ initclocks(void)
 	 * 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.

Reply via email to