Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/alpha/alpha - qemu_hardclock(): fix check for spuri...



details:   https://anonhg.NetBSD.org/src/rev/5fd9319b23ee
branches:  trunk
changeset: 944690:5fd9319b23ee
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Oct 07 14:07:42 2020 +0000

description:
- 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.

diffstat:

 sys/arch/alpha/alpha/qemu.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r 9486a587d013 -r 5fd9319b23ee sys/arch/alpha/alpha/qemu.c
--- a/sys/arch/alpha/alpha/qemu.c       Wed Oct 07 07:35:28 2020 +0000
+++ b/sys/arch/alpha/alpha/qemu.c       Wed Oct 07 14:07:42 2020 +0000
@@ -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 @@
 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 @@
        /* 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 @@
                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);
        }
 



Home | Main Index | Thread Index | Old Index