Module Name:    src
Committed By:   mlelstv
Date:           Fri Jan 12 06:23:20 UTC 2024

Modified Files:
        src/sys/arch/virt68k/dev: gfrtc_mainbus.c

Log Message:
The interrupt handler needs to clear the interrupt condition
before re-arming the timer. Otherwise the timer could expire
again before clearing the interrupt, the interrupt gets lost
and the clock stops.

On real hardware that could only occur if the timer interval
is extremely short or if there is a higher-than-clock interrupt
that delays processing. In the emulated world however, time
can progress non-continously and this happens often under load.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/dev/gfrtc_mainbus.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/virt68k/dev/gfrtc_mainbus.c
diff -u src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.1 src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.2
--- src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.1	Tue Jan  2 07:40:59 2024
+++ src/sys/arch/virt68k/dev/gfrtc_mainbus.c	Fri Jan 12 06:23:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gfrtc_mainbus.c,v 1.1 2024/01/02 07:40:59 thorpej Exp $	*/
+/*	$NetBSD: gfrtc_mainbus.c,v 1.2 2024/01/12 06:23:20 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2023, 2024 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gfrtc_mainbus.c,v 1.1 2024/01/02 07:40:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gfrtc_mainbus.c,v 1.2 2024/01/12 06:23:20 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -65,12 +65,12 @@ struct gfrtc_mainbus_softc {
 
 #define	CLOCK_HANDLER()							\
 do {									\
-	/* Get the next alarm set ASAP. */				\
-	gfrtc_set_alarm(&sc->sc_gfrtc, sc->sc_interval_ns);		\
-									\
 	/* Clear the interrupt condition. */				\
 	gfrtc_clear_interrupt(&sc->sc_gfrtc);				\
 									\
+	/* Get the next alarm set ASAP. */				\
+	gfrtc_set_alarm(&sc->sc_gfrtc, sc->sc_interval_ns);		\
+									\
 	/* Increment the counter and call the handler. */		\
 	sc->sc_evcnt->ev_count++;					\
 	sc->sc_handler((struct clockframe *)v);				\

Reply via email to