Module Name:    src
Committed By:   thorpej
Date:           Wed Oct  7 14:07:42 UTC 2020

Modified Files:
        src/sys/arch/alpha/alpha: qemu.c

Log Message:
- qemu_hardclock(): fix check for spurious hardclock call.
- qemu_clock_init(): Initialize qemu_nsec_per_tick *after* adjusting hz.
  Error pointed out by Jonathan Kollasch.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/alpha/alpha/qemu.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/arch/alpha/alpha/qemu.c
diff -u src/sys/arch/alpha/alpha/qemu.c:1.3 src/sys/arch/alpha/alpha/qemu.c:1.4
--- src/sys/arch/alpha/alpha/qemu.c:1.3	Sat Oct  3 17:32:49 2020
+++ src/sys/arch/alpha/alpha/qemu.c	Wed Oct  7 14:07:42 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: qemu.c,v 1.3 2020/10/03 17:32:49 thorpej Exp $ */
+/* $NetBSD: qemu.c,v 1.4 2020/10/07 14:07:42 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -121,7 +121,7 @@ qemu_set_alarm_relative(unsigned long ns
 static void
 qemu_hardclock(struct clockframe * const framep)
 {
-	if (__predict_false(qemu_nsec_per_tick == 0)) {
+	if (__predict_false(qemu_nsec_per_tick == (unsigned long)-1)) {
 		/* Spurious; qemu_clock_init() hasn't been called yet. */
 		return;
 	}
@@ -138,7 +138,6 @@ qemu_clock_init(void * const v __unused)
 	/* First-time initialization... */
 	if (qemu_nsec_per_tick == (unsigned long)-1) {
 		KASSERT(CPU_IS_PRIMARY(curcpu()));
-		qemu_nsec_per_tick = 1000000000UL / hz;
 
 		/*
 		 * Override the clockintr routine; the Qemu alarm is
@@ -157,6 +156,8 @@ qemu_clock_init(void * const v __unused)
 		tickadj = (240000 / (60 * hz)) ? (240000 / (60 * hz)) : 1;
 		schedhz = 0;
 
+		qemu_nsec_per_tick = 1000000000UL / hz;
+
 		printf("Using the Qemu CPU alarm for %d Hz hardclock.\n", hz);
 	}
 

Reply via email to