CVS commit: src/sys/arch/virt68k/dev

2024-03-09 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Mar  9 11:16:31 UTC 2024

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

Log Message:
Fix a null dereference.
free_interrupts may be called even when sc_ih has not been assigned yet.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/dev/virtio_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/virtio_mainbus.c
diff -u src/sys/arch/virt68k/dev/virtio_mainbus.c:1.1 src/sys/arch/virt68k/dev/virtio_mainbus.c:1.2
--- src/sys/arch/virt68k/dev/virtio_mainbus.c:1.1	Tue Jan  2 07:40:59 2024
+++ src/sys/arch/virt68k/dev/virtio_mainbus.c	Sat Mar  9 11:16:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio_mainbus.c,v 1.1 2024/01/02 07:40:59 thorpej Exp $	*/
+/*	$NetBSD: virtio_mainbus.c,v 1.2 2024/03/09 11:16:31 isaki Exp $	*/
 
 /*
  * Copyright (c) 2021, 2024 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_mainbus.c,v 1.1 2024/01/02 07:40:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_mainbus.c,v 1.2 2024/03/09 11:16:31 isaki Exp $");
 
 #include 
 #include 
@@ -170,6 +170,8 @@ virtio_mainbus_alloc_interrupts(struct v
 static void
 virtio_mainbus_free_interrupts(struct virtio_mmio_softc *msc)
 {
-	intr_disestablish(msc->sc_ih);
-	msc->sc_ih = NULL;
+	if (msc->sc_ih) {
+		intr_disestablish(msc->sc_ih);
+		msc->sc_ih = NULL;
+	}
 }



CVS commit: src/sys/arch/virt68k/dev

2024-03-09 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Mar  9 11:16:31 UTC 2024

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

Log Message:
Fix a null dereference.
free_interrupts may be called even when sc_ih has not been assigned yet.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/dev/virtio_mainbus.c

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



CVS commit: src/sys/arch/virt68k/dev

2024-01-11 Thread Michael van Elst
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 
-__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 
 #include 
@@ -65,12 +65,12 @@ struct gfrtc_mainbus_softc {
 
 #define	CLOCK_HANDLER()			\
 do {	\
-	/* Get the next alarm set ASAP. */\
-	gfrtc_set_alarm(>sc_gfrtc, sc->sc_interval_ns);		\
-	\
 	/* Clear the interrupt condition. */\
 	gfrtc_clear_interrupt(>sc_gfrtc);\
 	\
+	/* Get the next alarm set ASAP. */\
+	gfrtc_set_alarm(>sc_gfrtc, sc->sc_interval_ns);		\
+	\
 	/* Increment the counter and call the handler. */		\
 	sc->sc_evcnt->ev_count++;	\
 	sc->sc_handler((struct clockframe *)v);\



CVS commit: src/sys/arch/virt68k/dev

2024-01-11 Thread Michael van Elst
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.



CVS commit: src/sys/arch/virt68k/dev

2024-01-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jan  6 21:49:59 UTC 2024

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

Log Message:
Fix dump paste-o.  Halt works properly.  Reboot does reboot, but the
new kernel instance crashes early.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/dev/virtctrl.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/virtctrl.c
diff -u src/sys/arch/virt68k/dev/virtctrl.c:1.1 src/sys/arch/virt68k/dev/virtctrl.c:1.2
--- src/sys/arch/virt68k/dev/virtctrl.c:1.1	Tue Jan  2 18:11:44 2024
+++ src/sys/arch/virt68k/dev/virtctrl.c	Sat Jan  6 21:49:59 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtctrl.c,v 1.1 2024/01/02 18:11:44 thorpej Exp $	*/
+/*	$NetBSD: virtctrl.c,v 1.2 2024/01/06 21:49:59 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtctrl.c,v 1.1 2024/01/02 18:11:44 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtctrl.c,v 1.2 2024/01/06 21:49:59 thorpej Exp $");
 
 #include 
 #include 
@@ -64,7 +64,7 @@ static const struct device_compatible_en
 #define	REG_READ(sc, r)		\
 	bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (r))
 #define	REG_WRITE(sc, r, v)	\
-	bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (r))
+	bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (r), (v))
 
 static void
 virtctrl_reset_handler(void *v, int howto)



CVS commit: src/sys/arch/virt68k/dev

2024-01-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jan  6 21:49:59 UTC 2024

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

Log Message:
Fix dump paste-o.  Halt works properly.  Reboot does reboot, but the
new kernel instance crashes early.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/dev/virtctrl.c

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