CVS commit: src/sys/netinet6

2023-03-29 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Wed Mar 29 13:01:44 UTC 2023

Modified Files:
src/sys/netinet6: nd6_nbr.c

Log Message:
use carp mac address when replying to neighbor solicitations referring
to carp interface addresses.
unconfuses commercial routers


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/netinet6/nd6_nbr.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/netinet6/nd6_nbr.c
diff -u src/sys/netinet6/nd6_nbr.c:1.182 src/sys/netinet6/nd6_nbr.c:1.183
--- src/sys/netinet6/nd6_nbr.c:1.182	Mon Aug  2 12:56:25 2021
+++ src/sys/netinet6/nd6_nbr.c	Wed Mar 29 13:01:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6_nbr.c,v 1.182 2021/08/02 12:56:25 andvar Exp $	*/
+/*	$NetBSD: nd6_nbr.c,v 1.183 2023/03/29 13:01:44 kardel Exp $	*/
 /*	$KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.182 2021/08/02 12:56:25 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.183 2023/03/29 13:01:44 kardel Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -100,7 +100,7 @@ static int dad_maxtry = 15;	/* max # of 
 void
 nd6_ns_input(struct mbuf *m, int off, int icmp6len)
 {
-	struct ifnet *ifp;
+	struct ifnet *ifp, *ifpc;
 	struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
 	struct nd_neighbor_solicit *nd_ns;
 	struct in6_addr saddr6 = ip6->ip6_src;
@@ -116,10 +116,11 @@ nd6_ns_input(struct mbuf *m, int off, in
 	union nd_opts ndopts;
 	const struct sockaddr_dl *proxydl = NULL;
 	struct psref psref;
+	struct psref psref_c;
 	struct psref psref_ia;
 	char ip6buf[INET6_ADDRSTRLEN], ip6buf2[INET6_ADDRSTRLEN];
 
-	ifp = m_get_rcvif_psref(m, );
+	ifp = ifpc = m_get_rcvif_psref(m, );
 	if (ifp == NULL)
 		goto freeit;
 
@@ -224,8 +225,15 @@ nd6_ns_input(struct mbuf *m, int off, in
 	if (ifp->if_carp && ifp->if_type != IFT_CARP) {
 		int s = pserialize_read_enter();
 		ifa = carp_iamatch6(ifp->if_carp, );
-		if (ifa != NULL)
+		if (ifa != NULL) {
 			ifa_acquire(ifa, _ia);
+			if (ifa->ifa_ifp && ifa->ifa_ifp != ifp) {
+ifpc = ifa->ifa_ifp;
+if_acquire(ifpc, _c);
+			}
+		}
+		
+		
 		pserialize_read_exit(s);
 	} else
 		ifa = NULL;
@@ -350,14 +358,14 @@ nd6_ns_input(struct mbuf *m, int off, in
 		in6_all = in6addr_linklocal_allnodes;
 		if (in6_setscope(_all, ifp, NULL) != 0)
 			goto bad;
-		nd6_na_output(ifp, _all, ,
+		nd6_na_output(ifpc, _all, ,
 		((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
 		(ip6_forwarding ? ND_NA_FLAG_ROUTER : 0),
 		tlladdr, (const struct sockaddr *)proxydl);
 		goto freeit;
 	}
 
-	nd6_cache_lladdr(ifp, , lladdr, lladdrlen, ND_NEIGHBOR_SOLICIT, 0);
+	nd6_cache_lladdr(ifpc, , lladdr, lladdrlen, ND_NEIGHBOR_SOLICIT, 0);
 
 	nd6_na_output(ifp, , ,
 	((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
@@ -366,6 +374,9 @@ nd6_ns_input(struct mbuf *m, int off, in
  freeit:
 	ifa_release(ifa, _ia);
 	m_put_rcvif_psref(ifp, );
+	if (ifp != ifpc)
+		if_put(ifpc, _c);
+
 	m_freem(m);
 	return;
 



CVS commit: src/sys/netinet6

2023-03-29 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Wed Mar 29 13:01:44 UTC 2023

Modified Files:
src/sys/netinet6: nd6_nbr.c

Log Message:
use carp mac address when replying to neighbor solicitations referring
to carp interface addresses.
unconfuses commercial routers


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/netinet6/nd6_nbr.c

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



CVS commit: src/sys/dev/pci

2023-03-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar 29 09:45:05 UTC 2023

Modified Files:
src/sys/dev/pci: virtioreg.h

Log Message:
virtio(4): Use flexible array members, not zero-length arrays.

This enables the compiler to detect sizeof mistakes like
PR kern/57304.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/virtioreg.h

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

Modified files:

Index: src/sys/dev/pci/virtioreg.h
diff -u src/sys/dev/pci/virtioreg.h:1.11 src/sys/dev/pci/virtioreg.h:1.12
--- src/sys/dev/pci/virtioreg.h:1.11	Sat Oct 15 20:00:35 2022
+++ src/sys/dev/pci/virtioreg.h	Wed Mar 29 09:45:05 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtioreg.h,v 1.11 2022/10/15 20:00:35 riastradh Exp $	*/
+/*	$NetBSD: virtioreg.h,v 1.12 2023/03/29 09:45:05 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -153,7 +153,7 @@ struct vring_desc {
 struct vring_avail {
 uint16_t flags;
 uint16_t idx;
-uint16_t ring[0];
+uint16_t ring[];
 	/* trailed by uint16_t used_event when VIRTIO_F_RING_EVENT_IDX */
 } __packed;
 
@@ -168,7 +168,7 @@ struct vring_used_elem {
 struct vring_used {
 uint16_t flags;
 uint16_t idx;
-struct vring_used_elem ring[0];
+struct vring_used_elem ring[];
 	/* trailed by uint16_t avail_event when VIRTIO_F_RING_EVENT_IDX */
 } __packed;
 



CVS commit: src/sys/dev/pci

2023-03-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar 29 09:45:05 UTC 2023

Modified Files:
src/sys/dev/pci: virtioreg.h

Log Message:
virtio(4): Use flexible array members, not zero-length arrays.

This enables the compiler to detect sizeof mistakes like
PR kern/57304.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/virtioreg.h

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



CVS commit: src/sys/dev/pci

2023-03-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar 29 09:44:26 UTC 2023

Modified Files:
src/sys/dev/pci: virtio.c

Log Message:
virtio(4): Fix sizing of virtqueue allocation.

vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.

Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.

XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.

PR kern/57304

Reported-by: syzbot+7fb1047f5dfa33b26...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/pci/virtio.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/dev/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.71 src/sys/dev/pci/virtio.c:1.72
--- src/sys/dev/pci/virtio.c:1.71	Mon Mar 27 14:56:40 2023
+++ src/sys/dev/pci/virtio.c	Wed Mar 29 09:44:25 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.71 2023/03/27 14:56:40 nakayama Exp $	*/
+/*	$NetBSD: virtio.c,v 1.72 2023/03/29 09:44:25 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.71 2023/03/27 14:56:40 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.72 2023/03/29 09:44:25 riastradh Exp $");
 
 #include 
 #include 
@@ -784,9 +784,9 @@ virtio_alloc_vq(struct virtio_softc *sc,
 
 	size_desc = sizeof(vq->vq_desc[0]) * vq_num;
 	size_avail = sizeof(uint16_t) * hdrlen
-	+ sizeof(vq->vq_avail[0].ring) * vq_num;
+	+ sizeof(vq->vq_avail[0].ring[0]) * vq_num;
 	size_used = sizeof(uint16_t) *hdrlen
-	+ sizeof(vq->vq_used[0].ring) * vq_num;
+	+ sizeof(vq->vq_used[0].ring[0]) * vq_num;
 	size_indirect = (sc->sc_indirect && maxnsegs >= MINSEG_INDIRECT) ?
 	sizeof(struct vring_desc) * maxnsegs * vq_num : 0;
 



CVS commit: src/sys/dev/pci

2023-03-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar 29 09:44:26 UTC 2023

Modified Files:
src/sys/dev/pci: virtio.c

Log Message:
virtio(4): Fix sizing of virtqueue allocation.

vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.

Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.

XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.

PR kern/57304

Reported-by: syzbot+7fb1047f5dfa33b26...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/pci/virtio.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/x68k/x68k

2023-03-28 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Mar 28 20:10:02 UTC 2023

Modified Files:
src/sys/arch/x68k/x68k: kgdb_stub.c

Log Message:
s/ourput/output/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x68k/x68k/kgdb_stub.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/x68k/x68k/kgdb_stub.c
diff -u src/sys/arch/x68k/x68k/kgdb_stub.c:1.19 src/sys/arch/x68k/x68k/kgdb_stub.c:1.20
--- src/sys/arch/x68k/x68k/kgdb_stub.c:1.19	Wed Nov 10 16:40:55 2021
+++ src/sys/arch/x68k/x68k/kgdb_stub.c	Tue Mar 28 20:10:01 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kgdb_stub.c,v 1.19 2021/11/10 16:40:55 msaitoh Exp $	*/
+/*	$NetBSD: kgdb_stub.c,v 1.20 2023/03/28 20:10:01 andvar Exp $	*/
 
 /*
  * Copyright (c) 1990, 1993
@@ -45,13 +45,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kgdb_stub.c,v 1.19 2021/11/10 16:40:55 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kgdb_stub.c,v 1.20 2023/03/28 20:10:01 andvar Exp $");
 
 #include "opt_kgdb.h"
 
 #ifdef KGDB
 #ifndef lint
-static char rcsid[] = "$NetBSD: kgdb_stub.c,v 1.19 2021/11/10 16:40:55 msaitoh Exp $";
+static char rcsid[] = "$NetBSD: kgdb_stub.c,v 1.20 2023/03/28 20:10:01 andvar Exp $";
 #endif
 
 #include 
@@ -415,7 +415,7 @@ kgdb_trap(int type, struct frame *frame)
 			 * knowing if we're in or out of this loop
 			 * when he issues a "remote-signal".  (Note
 			 * that without the length check, we could
-			 * loop here forever if the ourput line is
+			 * loop here forever if the output line is
 			 * looped back or the remote host is echoing.)
 			 */
 			if (inlen == 0) {



CVS commit: src/sys/arch/x68k/x68k

2023-03-28 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Mar 28 20:10:02 UTC 2023

Modified Files:
src/sys/arch/x68k/x68k: kgdb_stub.c

Log Message:
s/ourput/output/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x68k/x68k/kgdb_stub.c

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



CVS commit: src/sys

2023-03-28 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Mar 28 20:01:58 UTC 2023

Modified Files:
src/sys/arch/arm/xscale: pxa2x0_mci.c
src/sys/arch/ibmnws/ibmnws: machdep.c
src/sys/arch/luna68k/dev: sioreg.h
src/sys/arch/luna68k/stand/boot: sioreg.h
src/sys/arch/mvmeppc/mvmeppc: machdep.c
src/sys/arch/sparc/include: cgtworeg.h
src/sys/arch/sun3/include: cg2reg.h
src/sys/arch/x68k/x68k: machdep.c
src/sys/arch/zaurus/dev: zrc.c
src/sys/dev/ic: mb89352.c
src/sys/dev/usb: uhid.c

Log Message:
s/interrput/interrupt/ and s/accesss/access/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/xscale/pxa2x0_mci.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/ibmnws/ibmnws/machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/luna68k/dev/sioreg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/luna68k/stand/boot/sioreg.h
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/mvmeppc/mvmeppc/machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc/include/cgtworeg.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sun3/include/cg2reg.h
cvs rdiff -u -r1.209 -r1.210 src/sys/arch/x68k/x68k/machdep.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/zaurus/dev/zrc.c
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/ic/mb89352.c
cvs rdiff -u -r1.126 -r1.127 src/sys/dev/usb/uhid.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/arm/xscale/pxa2x0_mci.c
diff -u src/sys/arch/arm/xscale/pxa2x0_mci.c:1.13 src/sys/arch/arm/xscale/pxa2x0_mci.c:1.14
--- src/sys/arch/arm/xscale/pxa2x0_mci.c:1.13	Tue Sep 27 06:36:43 2022
+++ src/sys/arch/arm/xscale/pxa2x0_mci.c	Tue Mar 28 20:01:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pxa2x0_mci.c,v 1.13 2022/09/27 06:36:43 skrll Exp $	*/
+/*	$NetBSD: pxa2x0_mci.c,v 1.14 2023/03/28 20:01:57 andvar Exp $	*/
 /*	$OpenBSD: pxa2x0_mmc.c,v 1.5 2009/02/23 18:09:55 miod Exp $	*/
 
 /*
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pxa2x0_mci.c,v 1.13 2022/09/27 06:36:43 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pxa2x0_mci.c,v 1.14 2023/03/28 20:01:57 andvar Exp $");
 
 #include 
 #include 
@@ -742,7 +742,7 @@ pxamci_stop_clock(struct pxamci_softc *s
 }
 
 /*
- * SD/MMC controller interrput handler
+ * SD/MMC controller interrupt handler
  */
 static int
 pxamci_intr(void *arg)

Index: src/sys/arch/ibmnws/ibmnws/machdep.c
diff -u src/sys/arch/ibmnws/ibmnws/machdep.c:1.19 src/sys/arch/ibmnws/ibmnws/machdep.c:1.20
--- src/sys/arch/ibmnws/ibmnws/machdep.c:1.19	Wed Feb 16 23:49:26 2022
+++ src/sys/arch/ibmnws/ibmnws/machdep.c	Tue Mar 28 20:01:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.19 2022/02/16 23:49:26 riastradh Exp $	*/
+/*	$NetBSD: machdep.c,v 1.20 2023/03/28 20:01:57 andvar Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.19 2022/02/16 23:49:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.20 2023/03/28 20:01:57 andvar Exp $");
 
 #include "opt_compat_netbsd.h"
 
@@ -159,7 +159,7 @@ void
 cpu_startup(void)
 {
 	/*
-	 * Mapping PReP interrput vector register.
+	 * Mapping PReP interrupt vector register.
 	 */
 	prep_intr_reg = (vaddr_t) mapiodev(PREP_INTR_REG, PAGE_SIZE, false);
 	if (!prep_intr_reg)

Index: src/sys/arch/luna68k/dev/sioreg.h
diff -u src/sys/arch/luna68k/dev/sioreg.h:1.5 src/sys/arch/luna68k/dev/sioreg.h:1.6
--- src/sys/arch/luna68k/dev/sioreg.h:1.5	Sat Sep 25 15:18:38 2021
+++ src/sys/arch/luna68k/dev/sioreg.h	Tue Mar 28 20:01:57 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sioreg.h,v 1.5 2021/09/25 15:18:38 tsutsui Exp $ */
+/* $NetBSD: sioreg.h,v 1.6 2023/03/28 20:01:57 andvar Exp $ */
 /*
  * Copyright (c) 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -91,7 +91,7 @@
 #define WR0_RSTINT	0x10	/* Reset External/Status Interrupt */
 #define WR0_CHANRST	0x18	/* Channel Reset */
 #define WR0_INTNXT	0x20	/* Enable Interrupt on Next Receive Character */
-#define WR0_RSTPEND	0x28	/* Reset Transmitter Interrput/DMA Pending */
+#define WR0_RSTPEND	0x28	/* Reset Transmitter Interrupt/DMA Pending */
 #define WR0_ERRRST	0x30	/* Error Reset */
 #define WR0_ENDINTR	0x38	/* End of Interrupt */
 

Index: src/sys/arch/luna68k/stand/boot/sioreg.h
diff -u src/sys/arch/luna68k/stand/boot/sioreg.h:1.4 src/sys/arch/luna68k/stand/boot/sioreg.h:1.5
--- src/sys/arch/luna68k/stand/boot/sioreg.h:1.4	Sat Feb 14 05:03:09 2015
+++ src/sys/arch/luna68k/stand/boot/sioreg.h	Tue Mar 28 20:01:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sioreg.h,v 1.4 2015/02/14 05:03:09 tsutsui Exp $	*/
+/*	$NetBSD: sioreg.h,v 1.5 2023/03/28 20:01:57 andvar Exp $	*/
 
 /*
  * Copyright (c) 1992 OMRON Corporation.
@@ -115,7 +115,7 @@ struct siodevice {
 #define WR0_RSTINT	0x10	/* Reset External/Status Interrupt */
 #define WR0_CHANRST	0x18	/* Channel Reset */
 #define WR0_INTNXT	0x20	/* Enable Interrupt on Next Receive 

CVS commit: src/sys

2023-03-28 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Mar 28 20:01:58 UTC 2023

Modified Files:
src/sys/arch/arm/xscale: pxa2x0_mci.c
src/sys/arch/ibmnws/ibmnws: machdep.c
src/sys/arch/luna68k/dev: sioreg.h
src/sys/arch/luna68k/stand/boot: sioreg.h
src/sys/arch/mvmeppc/mvmeppc: machdep.c
src/sys/arch/sparc/include: cgtworeg.h
src/sys/arch/sun3/include: cg2reg.h
src/sys/arch/x68k/x68k: machdep.c
src/sys/arch/zaurus/dev: zrc.c
src/sys/dev/ic: mb89352.c
src/sys/dev/usb: uhid.c

Log Message:
s/interrput/interrupt/ and s/accesss/access/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/xscale/pxa2x0_mci.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/ibmnws/ibmnws/machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/luna68k/dev/sioreg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/luna68k/stand/boot/sioreg.h
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/mvmeppc/mvmeppc/machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc/include/cgtworeg.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sun3/include/cg2reg.h
cvs rdiff -u -r1.209 -r1.210 src/sys/arch/x68k/x68k/machdep.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/zaurus/dev/zrc.c
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/ic/mb89352.c
cvs rdiff -u -r1.126 -r1.127 src/sys/dev/usb/uhid.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/x86/x86

2023-03-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 28 19:55:42 UTC 2023

Modified Files:
src/sys/arch/x86/x86: bus_dma.c

Log Message:
x86/bus_dma.c: Sprinkle KASSERTMSG.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/x86/x86/bus_dma.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/x86/x86/bus_dma.c
diff -u src/sys/arch/x86/x86/bus_dma.c:1.89 src/sys/arch/x86/x86/bus_dma.c:1.90
--- src/sys/arch/x86/x86/bus_dma.c:1.89	Sat Aug 20 23:48:51 2022
+++ src/sys/arch/x86/x86/bus_dma.c	Tue Mar 28 19:55:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.89 2022/08/20 23:48:51 riastradh Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.90 2023/03/28 19:55:42 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2007, 2020 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.89 2022/08/20 23:48:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.90 2023/03/28 19:55:42 riastradh Exp $");
 
 /*
  * The following is included because _bus_dma_uiomove is derived from
@@ -207,7 +207,8 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t,
 	/* Always round the size. */
 	size = round_page(size);
 
-	KASSERT(boundary >= PAGE_SIZE || boundary == 0);
+	KASSERTMSG(boundary >= PAGE_SIZE || boundary == 0,
+	"boundary=0x%"PRIxBUSSIZE, boundary);
 
 	/*
 	 * Allocate pages from the VM system.
@@ -389,7 +390,9 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dm
 	 */
 	map->dm_mapsize = 0;
 	map->dm_nsegs = 0;
-	KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
+	KASSERTMSG(map->dm_maxsegsz <= map->_dm_maxmaxsegsz,
+	"maxsegsz=0x%"PRIxBUSSIZE", maxmaxsegsz=0x%"PRIxBUSSIZE,
+	map->dm_maxsegsz, map->_dm_maxmaxsegsz);
 
 	if (buflen > map->_dm_size)
 		return EINVAL;
@@ -517,9 +520,12 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, b
 	 */
 	map->dm_mapsize = 0;
 	map->dm_nsegs = 0;
-	KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
+	KASSERTMSG(map->dm_maxsegsz <= map->_dm_maxmaxsegsz,
+	"maxsegsz=0x%"PRIxBUSSIZE", maxmaxsegsz=0x%"PRIxBUSSIZE,
+	map->dm_maxsegsz, map->_dm_maxmaxsegsz);
 
-	KASSERT(m0->m_flags & M_PKTHDR);
+	KASSERTMSG(m0->m_flags & M_PKTHDR, "m0=%p m_flags=0x%x", m0,
+	m0->m_flags);
 	if (m0->m_pkthdr.len > map->_dm_size)
 		return (EINVAL);
 
@@ -545,9 +551,15 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, b
 			break;
 
 		case M_EXT|M_EXT_PAGES:
-			KASSERT(m->m_ext.ext_buf <= m->m_data);
-			KASSERT(m->m_data <=
-			m->m_ext.ext_buf + m->m_ext.ext_size);
+			KASSERTMSG(m->m_ext.ext_buf <= m->m_data,
+			"m=%p m_ext.ext_buf=%p m_ext.ext_size=%zu"
+			" m_data=%p",
+			m, m->m_ext.ext_buf, m->m_ext.ext_size, m->m_data);
+			KASSERTMSG((m->m_data <=
+m->m_ext.ext_buf + m->m_ext.ext_size),
+			"m=%p m_ext.ext_buf=%p m_ext.ext_size=%zu"
+			" m_data=%p",
+			m, m->m_ext.ext_buf, m->m_ext.ext_size, m->m_data);
 
 			offset = (vaddr_t)m->m_data -
 			trunc_page((vaddr_t)m->m_ext.ext_buf);
@@ -655,7 +667,9 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bu
 	 */
 	map->dm_mapsize = 0;
 	map->dm_nsegs = 0;
-	KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
+	KASSERTMSG(map->dm_maxsegsz <= map->_dm_maxmaxsegsz,
+	"maxsegsz=0x%"PRIxBUSSIZE", maxmaxsegsz=0x%"PRIxBUSSIZE,
+	map->dm_maxsegsz, map->_dm_maxmaxsegsz);
 
 	resid = uio->uio_resid;
 	iov = uio->uio_iov;
@@ -732,7 +746,9 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bu
 	 */
 	map->dm_mapsize = 0;
 	map->dm_nsegs = 0;
-	KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
+	KASSERTMSG(map->dm_maxsegsz <= map->_dm_maxmaxsegsz,
+	"maxsegsz=0x%"PRIxBUSSIZE", maxmaxsegsz=0x%"PRIxBUSSIZE,
+	map->dm_maxsegsz, map->_dm_maxmaxsegsz);
 
 	if (size0 > map->_dm_size)
 		return EINVAL;
@@ -811,8 +827,8 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 		"bad offset 0x%"PRIxBUSADDR" >= 0x%"PRIxBUSSIZE,
 		offset, map->dm_mapsize);
 		KASSERTMSG(len <= map->dm_mapsize - offset,
-		"bad length 0x%"PRIxBUSADDR" + %"PRIxBUSSIZE
-		" > %"PRIxBUSSIZE,
+		"bad length 0x%"PRIxBUSADDR" + 0x%"PRIxBUSSIZE
+		" > 0x%"PRIxBUSSIZE,
 		offset, len, map->dm_mapsize);
 	}
 



CVS commit: src/sys/arch/x86/x86

2023-03-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 28 19:55:42 UTC 2023

Modified Files:
src/sys/arch/x86/x86: bus_dma.c

Log Message:
x86/bus_dma.c: Sprinkle KASSERTMSG.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/x86/x86/bus_dma.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/mips/include

2023-03-28 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Tue Mar 28 10:54:13 UTC 2023

Modified Files:
src/sys/arch/mips/include: bus_space_defs.h types.h

Log Message:
Add missing PRIuBUSSIZE to mips.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/include/bus_space_defs.h
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/mips/include/types.h

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/mips/include/bus_space_defs.h
diff -u src/sys/arch/mips/include/bus_space_defs.h:1.4 src/sys/arch/mips/include/bus_space_defs.h:1.5
--- src/sys/arch/mips/include/bus_space_defs.h:1.4	Sun Jul 26 08:08:41 2020
+++ src/sys/arch/mips/include/bus_space_defs.h	Tue Mar 28 10:54:13 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_space_defs.h,v 1.4 2020/07/26 08:08:41 simonb Exp $	*/
+/*	$NetBSD: bus_space_defs.h,v 1.5 2023/03/28 10:54:13 nakayama Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -112,11 +112,13 @@ typedef int64_t bus_addr_t;
 typedef uint64_t bus_size_t;
 #define	PRIxBUSADDR	PRIx64
 #define	PRIxBUSSIZE	PRIx64
+#define	PRIuBUSSIZE	PRIu64
 #else
 typedef paddr_t bus_addr_t;
 typedef psize_t bus_size_t;
 #define	PRIxBUSADDR	PRIxPADDR
 #define	PRIxBUSSIZE	PRIxPSIZE
+#define	PRIuBUSSIZE	PRIuPSIZE
 #endif
 
 /*

Index: src/sys/arch/mips/include/types.h
diff -u src/sys/arch/mips/include/types.h:1.77 src/sys/arch/mips/include/types.h:1.78
--- src/sys/arch/mips/include/types.h:1.77	Thu Jul  7 10:06:02 2022
+++ src/sys/arch/mips/include/types.h	Tue Mar 28 10:54:13 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.77 2022/07/07 10:06:02 martin Exp $	*/
+/*	$NetBSD: types.h,v 1.78 2023/03/28 10:54:13 nakayama Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -74,12 +74,14 @@ typedef __uint64_t	psize_t;
 #define	PRIxPADDR	PRIx64
 #define	PRIxPSIZE	PRIx64
 #define	PRIdPSIZE	PRId64
+#define	PRIuPSIZE	PRIu64
 #else
 typedef __uint32_t	paddr_t;
 typedef __uint32_t	psize_t;
 #define	PRIxPADDR	PRIx32
 #define	PRIxPSIZE	PRIx32
 #define	PRIdPSIZE	PRId32
+#define	PRIuPSIZE	PRIu32
 #endif
 #ifdef _LP64
 typedef __uint64_t	vaddr_t;



CVS commit: src/sys/arch/mips/include

2023-03-28 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Tue Mar 28 10:54:13 UTC 2023

Modified Files:
src/sys/arch/mips/include: bus_space_defs.h types.h

Log Message:
Add missing PRIuBUSSIZE to mips.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/include/bus_space_defs.h
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/mips/include/types.h

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



CVS commit: src/sys/dev/pci

2023-03-27 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Mon Mar 27 14:56:40 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c virtio.c

Log Message:
Use PRIuBUSSIZE to print bus_size_t variables.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/pci/if_vioif.c
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/pci/virtio.c

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



CVS commit: src/sys/dev/pci

2023-03-27 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Mon Mar 27 14:56:40 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c virtio.c

Log Message:
Use PRIuBUSSIZE to print bus_size_t variables.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/pci/if_vioif.c
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/pci/virtio.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.106 src/sys/dev/pci/if_vioif.c:1.107
--- src/sys/dev/pci/if_vioif.c:1.106	Fri Mar 24 13:16:15 2023
+++ src/sys/dev/pci/if_vioif.c	Mon Mar 27 14:56:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.106 2023/03/24 13:16:15 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.107 2023/03/27 14:56:40 nakayama Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.106 2023/03/24 13:16:15 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.107 2023/03/27 14:56:40 nakayama Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1185,7 +1185,7 @@ vioif_alloc_mems(struct vioif_softc *sc)
 	>sc_segs[0], 1, , BUS_DMA_NOWAIT);
 	if (r != 0) {
 		aprint_error_dev(sc->sc_dev,
-		"DMA memory allocation failed, size %zu, "
+		"DMA memory allocation failed, size %" PRIuBUSSIZE ", "
 		"error code %d\n", dmamemsize, r);
 		goto err_none;
 	}

Index: src/sys/dev/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.70 src/sys/dev/pci/virtio.c:1.71
--- src/sys/dev/pci/virtio.c:1.70	Mon Mar 27 10:48:46 2023
+++ src/sys/dev/pci/virtio.c	Mon Mar 27 14:56:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.70 2023/03/27 10:48:46 riastradh Exp $	*/
+/*	$NetBSD: virtio.c,v 1.71 2023/03/27 14:56:40 nakayama Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.70 2023/03/27 10:48:46 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.71 2023/03/27 14:56:40 nakayama Exp $");
 
 #include 
 #include 
@@ -866,12 +866,12 @@ virtio_alloc_vq(struct virtio_softc *sc,
 	virtio_reset_vq(sc, vq);
 
 	aprint_verbose_dev(sc->sc_dev,
-	"allocated %zu byte for virtqueue %d for %s, size %d\n",
-	allocsize, vq->vq_index, name, vq_num);
+	"allocated %" PRIuBUSSIZE " byte for virtqueue %d for %s, "
+	"size %d\n", allocsize, vq->vq_index, name, vq_num);
 	if (size_indirect > 0)
 		aprint_verbose_dev(sc->sc_dev,
-		"using %zu byte (%d entries) indirect descriptors\n",
-		size_indirect, maxnsegs * vq_num);
+		"using %" PRIuBUSSIZE " byte (%d entries) indirect "
+		"descriptors\n", size_indirect, maxnsegs * vq_num);
 
 	return 0;
 



CVS commit: src/sys/dev/pci

2023-03-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 27 10:48:46 UTC 2023

Modified Files:
src/sys/dev/pci: virtio.c

Log Message:
virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/pci/virtio.c

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



CVS commit: src/sys/dev/pci

2023-03-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 27 10:48:46 UTC 2023

Modified Files:
src/sys/dev/pci: virtio.c

Log Message:
virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/pci/virtio.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/dev/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.69 src/sys/dev/pci/virtio.c:1.70
--- src/sys/dev/pci/virtio.c:1.69	Sat Mar 25 02:59:23 2023
+++ src/sys/dev/pci/virtio.c	Mon Mar 27 10:48:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.69 2023/03/25 02:59:23 yamaguchi Exp $	*/
+/*	$NetBSD: virtio.c,v 1.70 2023/03/27 10:48:46 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.69 2023/03/25 02:59:23 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.70 2023/03/27 10:48:46 riastradh Exp $");
 
 #include 
 #include 
@@ -746,7 +746,7 @@ virtio_init_vq_vqdone(struct virtio_soft
 
 void
 virtio_init_vq(struct virtio_softc *sc, struct virtqueue *vq, int index,
-   int (*intrhand)(void *), void *arg)
+   int (*func)(void *), void *arg)
 {
 
 	memset(vq, 0, sizeof(*vq));
@@ -754,7 +754,7 @@ virtio_init_vq(struct virtio_softc *sc, 
 	vq->vq_owner = sc;
 	vq->vq_num = sc->sc_ops->read_queue_size(sc, index);
 	vq->vq_index = index;
-	vq->vq_intrhand = intrhand;
+	vq->vq_intrhand = func;
 	vq->vq_intrhand_arg = arg;
 }
 



CVS commit: src/sys/arch

2023-03-26 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 26 15:24:22 UTC 2023

Modified Files:
src/sys/arch/amiga/dev: view.c viewioctl.h viewvar.h
src/sys/arch/atari/dev: view.c viewvar.h

Log Message:
s/dipslay/display/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amiga/dev/view.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amiga/dev/viewioctl.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/amiga/dev/viewvar.h
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/atari/dev/view.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/atari/dev/viewvar.h

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/amiga/dev/view.c
diff -u src/sys/arch/amiga/dev/view.c:1.34 src/sys/arch/amiga/dev/view.c:1.35
--- src/sys/arch/amiga/dev/view.c:1.34	Sun Sep 19 10:34:07 2021
+++ src/sys/arch/amiga/dev/view.c	Sun Mar 26 15:24:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: view.c,v 1.34 2021/09/19 10:34:07 andvar Exp $ */
+/*	$NetBSD: view.c,v 1.35 2023/03/26 15:24:22 andvar Exp $ */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,14 +31,14 @@
  */
 
 /* The view major device is a placeholder device.  It serves
- * simply to map the semantics of a graphics dipslay to
+ * simply to map the semantics of a graphics display to
  * the semantics of a character block device.  In other
  * words the graphics system as currently built does not like to be
  * referred to by open/close/ioctl.  This device serves as
  * a interface to graphics. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: view.c,v 1.34 2021/09/19 10:34:07 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: view.c,v 1.35 2023/03/26 15:24:22 andvar Exp $");
 
 #include 
 #include 

Index: src/sys/arch/amiga/dev/viewioctl.h
diff -u src/sys/arch/amiga/dev/viewioctl.h:1.11 src/sys/arch/amiga/dev/viewioctl.h:1.12
--- src/sys/arch/amiga/dev/viewioctl.h:1.11	Sun Sep 19 10:34:07 2021
+++ src/sys/arch/amiga/dev/viewioctl.h	Sun Mar 26 15:24:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: viewioctl.h,v 1.11 2021/09/19 10:34:07 andvar Exp $	*/
+/*	$NetBSD: viewioctl.h,v 1.12 2023/03/26 15:24:22 andvar Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -32,7 +32,7 @@
 
 /*
  * The view major device is a placeholder device.  It serves
- * simply to map the semantics of a graphics dipslay to
+ * simply to map the semantics of a graphics display to
  * the semantics of a character block device.  In other
  * words the graphics system as currently built does not like to be
  * referred to by open/close/ioctl.  This device serves as

Index: src/sys/arch/amiga/dev/viewvar.h
diff -u src/sys/arch/amiga/dev/viewvar.h:1.5 src/sys/arch/amiga/dev/viewvar.h:1.6
--- src/sys/arch/amiga/dev/viewvar.h:1.5	Sun Sep 19 10:34:07 2021
+++ src/sys/arch/amiga/dev/viewvar.h	Sun Mar 26 15:24:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: viewvar.h,v 1.5 2021/09/19 10:34:07 andvar Exp $	*/
+/*	$NetBSD: viewvar.h,v 1.6 2023/03/26 15:24:22 andvar Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,7 +31,7 @@
  */
 
 /* The view major device is a placeholder device.  It serves
- * simply to map the semantics of a graphics dipslay to
+ * simply to map the semantics of a graphics display to
  * the semantics of a character block device.  In other
  * words the graphics system as currently built does not like to be
  * referred to by open/close/ioctl.  This device serves as

Index: src/sys/arch/atari/dev/view.c
diff -u src/sys/arch/atari/dev/view.c:1.38 src/sys/arch/atari/dev/view.c:1.39
--- src/sys/arch/atari/dev/view.c:1.38	Fri Jan  6 10:28:28 2023
+++ src/sys/arch/atari/dev/view.c	Sun Mar 26 15:24:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: view.c,v 1.38 2023/01/06 10:28:28 tsutsui Exp $	*/
+/*	$NetBSD: view.c,v 1.39 2023/03/26 15:24:21 andvar Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,14 +31,14 @@
  */
 
 /* The view major device is a placeholder device.  It serves
- * simply to map the semantics of a graphics dipslay to
+ * simply to map the semantics of a graphics display to
  * the semantics of a character block device.  In other
  * words the graphics system as currently built does not like to be
  * referred to by open/close/ioctl.  This device serves as
  * a interface to graphics. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: view.c,v 1.38 2023/01/06 10:28:28 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: view.c,v 1.39 2023/03/26 15:24:21 andvar Exp $");
 
 #include 
 #include 

Index: src/sys/arch/atari/dev/viewvar.h
diff -u src/sys/arch/atari/dev/viewvar.h:1.8 src/sys/arch/atari/dev/viewvar.h:1.9
--- src/sys/arch/atari/dev/viewvar.h:1.8	Sun Sep 19 10:34:08 2021
+++ src/sys/arch/atari/dev/viewvar.h	Sun Mar 26 15:24:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: viewvar.h,v 1.8 2021/09/19 10:34:08 andvar Exp $	*/
+/*	$NetBSD: viewvar.h,v 1.9 2023/03/26 15:24:21 andvar Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,7 +31,7 @@
  */
 
 /* The view major device is a 

CVS commit: src/sys/arch

2023-03-26 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 26 15:24:22 UTC 2023

Modified Files:
src/sys/arch/amiga/dev: view.c viewioctl.h viewvar.h
src/sys/arch/atari/dev: view.c viewvar.h

Log Message:
s/dipslay/display/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amiga/dev/view.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amiga/dev/viewioctl.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/amiga/dev/viewvar.h
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/atari/dev/view.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/atari/dev/viewvar.h

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



CVS commit: src/sys/arch

2023-03-26 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 26 15:12:34 UTC 2023

Modified Files:
src/sys/arch/mac68k/dev: ite_compat.c
src/sys/arch/vax/vsa: smg.c

Log Message:
s/diplay/display/ and s/DIPPLAY/DISPLAY/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/mac68k/dev/ite_compat.c
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/vax/vsa/smg.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/mac68k/dev/ite_compat.c
diff -u src/sys/arch/mac68k/dev/ite_compat.c:1.13 src/sys/arch/mac68k/dev/ite_compat.c:1.14
--- src/sys/arch/mac68k/dev/ite_compat.c:1.13	Thu Aug 20 14:40:17 2015
+++ src/sys/arch/mac68k/dev/ite_compat.c	Sun Mar 26 15:12:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ite_compat.c,v 1.13 2015/08/20 14:40:17 christos Exp $	*/
+/*	$NetBSD: ite_compat.c,v 1.14 2023/03/26 15:12:34 andvar Exp $	*/
 
 /*
  * Copyright (C) 2000 Scott Reynolds
@@ -30,13 +30,13 @@
 /*
  * The main thing to realize about this emulator is that the old console
  * emulator was largely compatible with the DEC VT-220.  Since the
- * wsdiplay driver has a more complete emulation of that terminal, it's
+ * wsdisplay driver has a more complete emulation of that terminal, it's
  * reasonable to pass virtually everything up to that driver without
  * modification.
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ite_compat.c,v 1.13 2015/08/20 14:40:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ite_compat.c,v 1.14 2023/03/26 15:12:34 andvar Exp $");
 
 #include "ite.h"
 #include "wsdisplay.h"

Index: src/sys/arch/vax/vsa/smg.c
diff -u src/sys/arch/vax/vsa/smg.c:1.64 src/sys/arch/vax/vsa/smg.c:1.65
--- src/sys/arch/vax/vsa/smg.c:1.64	Sat Feb 11 05:59:39 2023
+++ src/sys/arch/vax/vsa/smg.c	Sun Mar 26 15:12:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: smg.c,v 1.64 2023/02/11 05:59:39 tsutsui Exp $ */
+/*	$NetBSD: smg.c,v 1.65 2023/03/26 15:12:34 andvar Exp $ */
 /*	$OpenBSD: smg.c,v 1.28 2014/12/23 21:39:12 miod Exp $	*/
 /*
  * Copyright (c) 2006, Miodrag Vallat
@@ -117,7 +117,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: smg.c,v 1.64 2023/02/11 05:59:39 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smg.c,v 1.65 2023/03/26 15:12:34 andvar Exp $");
 
 #include "dzkbd.h"
 #include "wsdisplay.h"
@@ -675,7 +675,7 @@ smg_putchar(void *cookie, int row, int s
 			 * WSDISPLAY_FONTORDER_R2L to use proper shift ops.
 			 * On the other hand, VRAM data is stored in
 			 * WSDISPLAY_FONTORDER_R2L bitorder and
-			 * WSDIPPLAY_FONTORDER_L2R byteorder.
+			 * WSDISPLAY_FONTORDER_L2R byteorder.
 			 */
 			glyph = 0;
 			for (i = ri->ri_font->stride; i != 0; i--)



CVS commit: src/sys/arch

2023-03-26 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 26 15:12:34 UTC 2023

Modified Files:
src/sys/arch/mac68k/dev: ite_compat.c
src/sys/arch/vax/vsa: smg.c

Log Message:
s/diplay/display/ and s/DIPPLAY/DISPLAY/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/mac68k/dev/ite_compat.c
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/vax/vsa/smg.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/vax/include

2023-03-26 Thread Anders Magnusson
Module Name:src
Committed By:   ragge
Date:   Sun Mar 26 12:23:42 UTC 2023

Modified Files:
src/sys/arch/vax/include: trap.h

Log Message:
Change CASMAGIC to 0xFEDABABE so that it cannot accidentally end up in
valid kernel memory.  Due to the VARM accesses above S0 should always
give a ptelen trap.
Bug found by Kalvis Duckmanton.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/vax/include/trap.h

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/vax/include/trap.h
diff -u src/sys/arch/vax/include/trap.h:1.24 src/sys/arch/vax/include/trap.h:1.25
--- src/sys/arch/vax/include/trap.h:1.24	Sun Jul  3 02:18:20 2011
+++ src/sys/arch/vax/include/trap.h	Sun Mar 26 12:23:42 2023
@@ -1,4 +1,4 @@
-/*  $NetBSD: trap.h,v 1.24 2011/07/03 02:18:20 matt Exp $ */
+/*  $NetBSD: trap.h,v 1.25 2023/03/26 12:23:42 ragge Exp $ */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -74,7 +74,7 @@
 #define	AFLT_FLTUND	0xa	/* floating underflow */
 
 /* Used by RAS to detect an interrupted CAS */
-#define	CASMAGIC	0xBEDABABE /* high end of S0 space */
+#define	CASMAGIC	0xFEDABABE /* always invalid space */
 
 /* Trap's coming from user mode */
 #define	T_USER	0x100



CVS commit: src/sys/arch/vax/include

2023-03-26 Thread Anders Magnusson
Module Name:src
Committed By:   ragge
Date:   Sun Mar 26 12:23:42 UTC 2023

Modified Files:
src/sys/arch/vax/include: trap.h

Log Message:
Change CASMAGIC to 0xFEDABABE so that it cannot accidentally end up in
valid kernel memory.  Due to the VARM accesses above S0 should always
give a ptelen trap.
Bug found by Kalvis Duckmanton.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/vax/include/trap.h

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



CVS commit: src/sys/arch/vax/vax

2023-03-26 Thread Anders Magnusson
Module Name:src
Committed By:   ragge
Date:   Sun Mar 26 12:21:09 UTC 2023

Modified Files:
src/sys/arch/vax/vax: pmap.c

Log Message:
Ensure that the kernel do not try to allocate a S0 segment larger than 1G,
since the hardware prohibits that.


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/sys/arch/vax/vax/pmap.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/vax/vax/pmap.c
diff -u src/sys/arch/vax/vax/pmap.c:1.195 src/sys/arch/vax/vax/pmap.c:1.196
--- src/sys/arch/vax/vax/pmap.c:1.195	Sun Dec 11 18:02:40 2022
+++ src/sys/arch/vax/vax/pmap.c	Sun Mar 26 12:21:09 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.195 2022/12/11 18:02:40 oster Exp $	   */
+/*	$NetBSD: pmap.c,v 1.196 2023/03/26 12:21:09 ragge Exp $	   */
 /*
  * Copyright (c) 1994, 1998, 1999, 2003 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.195 2022/12/11 18:02:40 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.196 2023/03/26 12:21:09 ragge Exp $");
 
 #include "opt_ddb.h"
 #include "opt_cputype.h"
@@ -276,6 +276,15 @@ pmap_bootstrap(void)
 		usrptsize = (avail_end/(20 * PPTESZ)) * VAX_NBPG;
 		
 	kvmsize = calc_kvmsize(usrptsize);
+	/*
+	 * Ensure that not more than 1G is allocated, since that is 
+	 * max size of S0 space.
+	 * Also note that for full S0 space the SLR should be 0x20,
+	 * since the comparison in the vax microcode is >= SLR.
+	 */
+#define	S0SPACE	(1*1024*1024*1024)
+	if (kvmsize > S0SPACE)
+		kvmsize = S0SPACE;
 	sysptsize = kvmsize >> VAX_PGSHIFT;
 	/*
 	 * Virtual_* and avail_* is used for mapping of system page table.



CVS commit: src/sys/arch/vax/vax

2023-03-26 Thread Anders Magnusson
Module Name:src
Committed By:   ragge
Date:   Sun Mar 26 12:21:09 UTC 2023

Modified Files:
src/sys/arch/vax/vax: pmap.c

Log Message:
Ensure that the kernel do not try to allocate a S0 segment larger than 1G,
since the hardware prohibits that.


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/sys/arch/vax/vax/pmap.c

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



CVS commit: src/sys/netinet

2023-03-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Mar 26 10:32:38 UTC 2023

Modified Files:
src/sys/netinet: ip_carp.c

Log Message:
Use backing device to send advertisements. Otherwise the packets originate
from the virtual MAC address, which confuses switches.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/netinet/ip_carp.c

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



CVS commit: src/sys/netinet

2023-03-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Mar 26 10:32:38 UTC 2023

Modified Files:
src/sys/netinet: ip_carp.c

Log Message:
Use backing device to send advertisements. Otherwise the packets originate
from the virtual MAC address, which confuses switches.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/netinet/ip_carp.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/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.117 src/sys/netinet/ip_carp.c:1.118
--- src/sys/netinet/ip_carp.c:1.117	Fri Sep  2 23:48:11 2022
+++ src/sys/netinet/ip_carp.c	Sun Mar 26 10:32:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_carp.c,v 1.117 2022/09/02 23:48:11 thorpej Exp $	*/
+/*	$NetBSD: ip_carp.c,v 1.118 2023/03/26 10:32:38 mlelstv Exp $	*/
 /*	$OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.117 2022/09/02 23:48:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.118 2023/03/26 10:32:38 mlelstv Exp $");
 
 /*
  * TODO:
@@ -1876,6 +1876,9 @@ carp_join_multicast(struct carp_softc *s
 	struct ip_moptions *imo = >sc_imo, tmpimo;
 	struct in_addr addr;
 
+	if (sc->sc_carpdev == NULL)
+		return (ENETDOWN);
+
 	memset(, 0, sizeof(tmpimo));
 	addr.s_addr = INADDR_CARP_GROUP;
 	if ((tmpimo.imo_membership[0] =
@@ -1885,7 +1888,7 @@ carp_join_multicast(struct carp_softc *s
 
 	imo->imo_membership[0] = tmpimo.imo_membership[0];
 	imo->imo_num_memberships = 1;
-	imo->imo_multicast_if_index = sc->sc_if.if_index;
+	imo->imo_multicast_if_index = sc->sc_carpdev->if_index;
 	imo->imo_multicast_ttl = CARP_DFLTTL;
 	imo->imo_multicast_loop = 0;
 	return (0);
@@ -1970,6 +1973,9 @@ carp_join_multicast6(struct carp_softc *
 	struct sockaddr_in6 addr6;
 	int error;
 
+	if (sc->sc_carpdev == NULL)
+		return (ENETDOWN);
+
 	/* Join IPv6 CARP multicast group */
 	memset(, 0, sizeof(addr6));
 	addr6.sin6_family = AF_INET6;
@@ -1996,7 +2002,7 @@ carp_join_multicast6(struct carp_softc *
 	}
 
 	/* apply v6 multicast membership */
-	im6o->im6o_multicast_if_index = sc->sc_if.if_index;
+	im6o->im6o_multicast_if_index = sc->sc_carpdev->if_index;
 	if (imm)
 		LIST_INSERT_HEAD(>im6o_memberships, imm,
 		i6mm_chain);



CVS commit: src/sys/arch/atari/include

2023-03-25 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Mar 25 21:51:12 UTC 2023

Modified Files:
src/sys/arch/atari/include: video.h

Log Message:
s/resultion/resolution/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/atari/include/video.h

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



CVS commit: src/sys/arch/atari/include

2023-03-25 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Mar 25 21:51:12 UTC 2023

Modified Files:
src/sys/arch/atari/include: video.h

Log Message:
s/resultion/resolution/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/atari/include/video.h

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/atari/include/video.h
diff -u src/sys/arch/atari/include/video.h:1.9 src/sys/arch/atari/include/video.h:1.10
--- src/sys/arch/atari/include/video.h:1.9	Sat Mar 25 21:47:10 2023
+++ src/sys/arch/atari/include/video.h	Sat Mar 25 21:51:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: video.h,v 1.9 2023/03/25 21:47:10 andvar Exp $	*/
+/*	$NetBSD: video.h,v 1.10 2023/03/25 21:51:12 andvar Exp $	*/
 
 /*
  * Copyright (c) 1995 Leo Weppelman.
@@ -41,7 +41,7 @@ struct video {
 volatile	u_short	vd_st_rgb[16];	/* RGB for simultaneous colors	(ST)*/
 volatile	u_char	vd_st_res;	/* ST resolution		*/
 volatile	char	vd_fill1;	/* filler			*/
-volatile	u_short	vd_tt_res;	/* TT-resultion mode		*/
+volatile	u_short	vd_tt_res;	/* TT-resolution mode		*/
 volatile	u_char  vd_ste_hscroll;	/* MEGA STe hor bitwise scroll	*/
 volatile	u_short vd_fal_res;	/* Falcon resolution		*/
 volatile	charvd_fill2[23];



CVS commit: src/sys/arch

2023-03-25 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Mar 25 21:47:10 UTC 2023

Modified Files:
src/sys/arch/atari/include: video.h
src/sys/arch/x86/include: specialreg.h

Log Message:
s/Predective/Predictive/ and s/dedected/detected/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/atari/include/video.h
cvs rdiff -u -r1.203 -r1.204 src/sys/arch/x86/include/specialreg.h

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/atari/include/video.h
diff -u src/sys/arch/atari/include/video.h:1.8 src/sys/arch/atari/include/video.h:1.9
--- src/sys/arch/atari/include/video.h:1.8	Sun Jul  3 11:30:48 2022
+++ src/sys/arch/atari/include/video.h	Sat Mar 25 21:47:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: video.h,v 1.8 2022/07/03 11:30:48 andvar Exp $	*/
+/*	$NetBSD: video.h,v 1.9 2023/03/25 21:47:10 andvar Exp $	*/
 
 /*
  * Copyright (c) 1995 Leo Weppelman.
@@ -117,7 +117,7 @@ struct video {
 #define	TT_SHOLD	0x1000	/* Sample/hold mode			*/
 
 /* The falcon video modes */
-#define RES_FALAUTO	0	/* Falcon resolution dedected at boot	*/
+#define RES_FALAUTO	0	/* Falcon resolution detected at boot	*/
 #define RES_VGA2	1	/* 640x480,   2 colors			*/
 #define RES_VGA4	2	/* 640x480,   4 colors			*/
 #define RES_VGA16	3	/* 640x480,  16 colors			*/

Index: src/sys/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.203 src/sys/arch/x86/include/specialreg.h:1.204
--- src/sys/arch/x86/include/specialreg.h:1.203	Fri Feb 17 09:53:24 2023
+++ src/sys/arch/x86/include/specialreg.h	Sat Mar 25 21:47:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.203 2023/02/17 09:53:24 msaitoh Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.204 2023/03/25 21:47:10 andvar Exp $	*/
 
 /*
  * Copyright (c) 2014-2020 The NetBSD Foundation, Inc.
@@ -1065,7 +1065,7 @@
 #define CPUID_AMDEXT2_FSRC	  __BIT(11) /* Fast Short Rep Cmpsb */
 #define CPUID_AMDEXT2_PREFETCHCTL __BIT(13) /* Prefetch control MSR */
 #define CPUID_AMDEXT2_CPUIDUSRDIS __BIT(17) /* CPUID dis. for non-priv. soft */
-#define CPUID_AMDEXT2_EPSF	  __BIT(18) /* Enhanced Predective Store Fwd */
+#define CPUID_AMDEXT2_EPSF	  __BIT(18) /* Enhanced Predictive Store Fwd */
 
 #define CPUID_AMDEXT2_FLAGS	 "\20"	  \
 	"\1NoNestedDataBp" "\2FsGsKernelGsBaseNonSerializing"		  \



CVS commit: src/sys/arch

2023-03-25 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Mar 25 21:47:10 UTC 2023

Modified Files:
src/sys/arch/atari/include: video.h
src/sys/arch/x86/include: specialreg.h

Log Message:
s/Predective/Predictive/ and s/dedected/detected/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/atari/include/video.h
cvs rdiff -u -r1.203 -r1.204 src/sys/arch/x86/include/specialreg.h

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



CVS commit: src/sys/net

2023-03-25 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Mar 25 21:35:49 UTC 2023

Modified Files:
src/sys/net: if_spppsubr.c

Log Message:
s/deteted/detected/ in log message.


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/sys/net/if_spppsubr.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/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.266 src/sys/net/if_spppsubr.c:1.267
--- src/sys/net/if_spppsubr.c:1.266	Sat Sep  3 02:47:59 2022
+++ src/sys/net/if_spppsubr.c	Sat Mar 25 21:35:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.266 2022/09/03 02:47:59 thorpej Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.267 2023/03/25 21:35:49 andvar Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.266 2022/09/03 02:47:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.267 2023/03/25 21:35:49 andvar Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -3132,7 +3132,7 @@ sppp_lcp_tlu(struct sppp *sp)
 		if ((sp->pp_flags & PP_LOOPBACK) == 0) {
 			SPPP_LOG(sp, LOG_DEBUG,
 			"interface is going up, "
-			"but no loopback packet is deteted\n");
+			"but no loopback packet is detected\n");
 		}
 		sp->pp_flags &= ~PP_LOOPBACK;
 	}



CVS commit: src/sys/net

2023-03-25 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Mar 25 21:35:49 UTC 2023

Modified Files:
src/sys/net: if_spppsubr.c

Log Message:
s/deteted/detected/ in log message.


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/sys/net/if_spppsubr.c

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



CVS commit: src/sys/dev/ic

2023-03-25 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Mar 25 21:33:46 UTC 2023

Modified Files:
src/sys/dev/ic: dm9000reg.h

Log Message:
s/deteced/detected/ and s/couner/counter/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ic/dm9000reg.h

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

Modified files:

Index: src/sys/dev/ic/dm9000reg.h
diff -u src/sys/dev/ic/dm9000reg.h:1.10 src/sys/dev/ic/dm9000reg.h:1.11
--- src/sys/dev/ic/dm9000reg.h:1.10	Tue May 31 12:59:00 2022
+++ src/sys/dev/ic/dm9000reg.h	Sat Mar 25 21:33:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dm9000reg.h,v 1.10 2022/05/31 12:59:00 andvar Exp $	*/
+/*	$NetBSD: dm9000reg.h,v 1.11 2023/03/25 21:33:46 andvar Exp $	*/
 
 /*
  * Copyright (c) 2009 Paul Fleischer
@@ -59,7 +59,7 @@
 #define  DM9000_NCR_WAKEEN	(1<<6)	/* wakeup event enable */
 #define  DM9000_NCR_EXY_PHY	(1<<7)	/* select ext. PHY, immune SW reset */
 #define DM9000_NSR		0x01	/* "network" status */
-#define  DM9000_NSR_RXOV	(1<<1)	/* receive overflow deteced */
+#define  DM9000_NSR_RXOV	(1<<1)	/* receive overflow detected */
 #define  DM9000_NSR_TX1END	(1<<2)	/* transmit 1 completed, W1C */
 #define  DM9000_NSR_TX2END	(1<<3) 	/* transmit 2 completed, W1C */
 #define  DM9000_NSR_WAKEST	(1<<5)	/* wakeup event, W1C */
@@ -99,7 +99,7 @@
 #define  DM9000_RSR_MF		(1<<6)	/* mcast/bcast frame received */
 #define  DM9000_RSR_RF		(1<<7)	/* damaged runt frame received <64 */
 #define DM9000_ROCR		0x07	/* receive overflow counter */
-/* 7: OVF detected, 6:0 statistic couner */
+/* 7: OVF detected, 6:0 statistic counter */
 #define DM9000_BPTR		0x08	/* back pressure threshold */
 /* 7:4 back pressure high watermark (3 def), 3:0 jam pattern time (7 def) */
 #define DM9000_FCTR		0x09	/* flow control threshold */



CVS commit: src/sys/dev/ic

2023-03-25 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Mar 25 21:33:46 UTC 2023

Modified Files:
src/sys/dev/ic: dm9000reg.h

Log Message:
s/deteced/detected/ and s/couner/counter/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ic/dm9000reg.h

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



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2023-03-25 Thread David Brownlee
Module Name:src
Committed By:   abs
Date:   Sat Mar 25 20:14:26 UTC 2023

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: console.c libstubs.h
libstubs.s version

Log Message:
Fix NetBSD/amiga bootblocks for Kickstart 3.2 - from Karoly Balogh

Kickstart 3.2 changed to not initialize console.device before
bootstrap, so the previous NetBSD bootblocks would crash when they
tried to initialise console output.

With this change if the call to the OpenDevice() stub fails, the
code now calls FindResident() and InitResident() before retrying
the OpenDevice().

Many thanks to Karoly Balogh for tracking this down (and also for
knowing just who to poke to get insight into the 3.2 changes :)


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/amiga/stand/bootblock/boot/console.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amiga/stand/bootblock/boot/libstubs.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amiga/stand/bootblock/boot/libstubs.s
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amiga/stand/bootblock/boot/version

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/amiga/stand/bootblock/boot/console.c
diff -u src/sys/arch/amiga/stand/bootblock/boot/console.c:1.15 src/sys/arch/amiga/stand/bootblock/boot/console.c:1.16
--- src/sys/arch/amiga/stand/bootblock/boot/console.c:1.15	Sun Dec 18 12:02:37 2016
+++ src/sys/arch/amiga/stand/bootblock/boot/console.c	Sat Mar 25 20:14:26 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: console.c,v 1.15 2016/12/18 12:02:37 mlelstv Exp $ */
+/* $NetBSD: console.c,v 1.16 2023/03/25 20:14:26 abs Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -138,8 +138,20 @@ consinit(void *consptr) {
 		goto err;
 
 	mc->cnior->buf = (void *)mc->w;
-	if (OpenDevice("console.device", 0, mc->cnior, 0))
-		goto err;
+	mc->cnior->length = 136; /* sizeof(struct Window) */
+	if (OpenDevice("console.device", 0, mc->cnior, 0)) {
+		/* Kickstart 3.2 decided not to initialize console.device
+before bootstrap, so we have to do it ourselves. */
+		void *res = FindResident("console.device");
+		if (!res)
+			goto err;
+
+		if (!InitResident(res, 0))
+			goto err;
+
+		if (OpenDevice("console.device", 0, mc->cnior, 0))
+			goto err;
+	}
 
 	mc->tmior = (struct TimerIO *)CreateIORequest(mc->cnmp, sizeof(struct TimerIO));
 	if (!mc->tmior)

Index: src/sys/arch/amiga/stand/bootblock/boot/libstubs.h
diff -u src/sys/arch/amiga/stand/bootblock/boot/libstubs.h:1.7 src/sys/arch/amiga/stand/bootblock/boot/libstubs.h:1.8
--- src/sys/arch/amiga/stand/bootblock/boot/libstubs.h:1.7	Sat Oct 17 11:18:18 2009
+++ src/sys/arch/amiga/stand/bootblock/boot/libstubs.h	Sat Mar 25 20:14:26 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: libstubs.h,v 1.7 2009/10/17 11:18:18 mlelstv Exp $ */
+/* $NetBSD: libstubs.h,v 1.8 2023/03/25 20:14:26 abs Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -65,6 +65,7 @@ void CloseDevice(struct AmigaIO *);
 #endif
 
 void *FindResident(const char *);
+void *InitResident(const char *, u_int32_t);
 void *OpenResource(const char *);
 
 u_int32_t CachePreDMA(u_int32_t, u_int32_t *, int);

Index: src/sys/arch/amiga/stand/bootblock/boot/libstubs.s
diff -u src/sys/arch/amiga/stand/bootblock/boot/libstubs.s:1.10 src/sys/arch/amiga/stand/bootblock/boot/libstubs.s:1.11
--- src/sys/arch/amiga/stand/bootblock/boot/libstubs.s:1.10	Sat Oct 17 11:18:18 2009
+++ src/sys/arch/amiga/stand/bootblock/boot/libstubs.s	Sat Mar 25 20:14:26 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: libstubs.s,v 1.10 2009/10/17 11:18:18 mlelstv Exp $ */
+/* $NetBSD: libstubs.s,v 1.11 2023/03/25 20:14:26 abs Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -208,6 +208,16 @@ ENTRY_NOPROFILE(FindResident)
 	movl	%d0,%a0			| Comply with ELF ABI
 	rts
 
+ENTRY_NOPROFILE(InitResident)
+	movl	%a6,%sp@-
+	movl	%pc@(_C_LABEL(SysBase):w),%a6
+	movl	%sp@(8),%a1
+	movl	%sp@(12),%d1
+	jsr	%a6@(-0x66)
+	movl	%sp@+,%a6
+	movl	%d0,%a0			| Comply with ELF ABI
+	rts
+
 ENTRY_NOPROFILE(OpenResource)
 	movl	%a6,%sp@-
 	movl	%pc@(_C_LABEL(SysBase):w),%a6

Index: src/sys/arch/amiga/stand/bootblock/boot/version
diff -u src/sys/arch/amiga/stand/bootblock/boot/version:1.2 src/sys/arch/amiga/stand/bootblock/boot/version:1.3
--- src/sys/arch/amiga/stand/bootblock/boot/version:1.2	Thu Feb 25 03:42:14 2021
+++ src/sys/arch/amiga/stand/bootblock/boot/version	Sat Mar 25 20:14:26 2023
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.2 2021/02/25 03:42:14 rin Exp $
+$NetBSD: version,v 1.3 2023/03/25 20:14:26 abs Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -12,3 +12,4 @@ is taken as the current.
 2.4:	Moved default command into fixed location for easy patching
 3.0:	Initial 2 stage amiga bootblocks
 3.1:	Add support for FFSv2
+3.2:	Fix booting with some "modern" Kickstart versions



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2023-03-25 Thread David Brownlee
Module Name:src
Committed By:   abs
Date:   Sat Mar 25 20:14:26 UTC 2023

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: console.c libstubs.h
libstubs.s version

Log Message:
Fix NetBSD/amiga bootblocks for Kickstart 3.2 - from Karoly Balogh

Kickstart 3.2 changed to not initialize console.device before
bootstrap, so the previous NetBSD bootblocks would crash when they
tried to initialise console output.

With this change if the call to the OpenDevice() stub fails, the
code now calls FindResident() and InitResident() before retrying
the OpenDevice().

Many thanks to Karoly Balogh for tracking this down (and also for
knowing just who to poke to get insight into the 3.2 changes :)


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/amiga/stand/bootblock/boot/console.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amiga/stand/bootblock/boot/libstubs.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amiga/stand/bootblock/boot/libstubs.s
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amiga/stand/bootblock/boot/version

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



CVS commit: src/sys/dev/pci

2023-03-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 25 11:04:34 UTC 2023

Modified Files:
src/sys/dev/pci: viomb.c viornd.c vioscsi.c

Log Message:
Mark as MPSAFE.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/viomb.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/viornd.c
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/vioscsi.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/dev/pci/viomb.c
diff -u src/sys/dev/pci/viomb.c:1.16 src/sys/dev/pci/viomb.c:1.17
--- src/sys/dev/pci/viomb.c:1.16	Sat Mar 25 11:00:35 2023
+++ src/sys/dev/pci/viomb.c	Sat Mar 25 11:04:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: viomb.c,v 1.16 2023/03/25 11:00:35 mlelstv Exp $	*/
+/*	$NetBSD: viomb.c,v 1.17 2023/03/25 11:04:34 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.16 2023/03/25 11:00:35 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.17 2023/03/25 11:04:34 mlelstv Exp $");
 
 #include 
 #include 
@@ -192,7 +192,7 @@ viomb_attach(device_t parent, device_t s
 	}
 
 	if (virtio_child_attach_finish(vsc, sc->sc_vq, __arraycount(sc->sc_vq),
-	viomb_config_change, 0) != 0)
+	viomb_config_change, VIRTIO_F_INTR_MPSAFE) != 0)
 		goto err_out;
 
 	if (kthread_create(PRI_IDLE, KTHREAD_MPSAFE, NULL,

Index: src/sys/dev/pci/viornd.c
diff -u src/sys/dev/pci/viornd.c:1.20 src/sys/dev/pci/viornd.c:1.21
--- src/sys/dev/pci/viornd.c:1.20	Thu Mar 23 03:55:11 2023
+++ src/sys/dev/pci/viornd.c	Sat Mar 25 11:04:34 2023
@@ -1,4 +1,4 @@
-/* 	$NetBSD: viornd.c,v 1.20 2023/03/23 03:55:11 yamaguchi Exp $ */
+/* 	$NetBSD: viornd.c,v 1.21 2023/03/25 11:04:34 mlelstv Exp $ */
 /*	$OpenBSD: viornd.c,v 1.1 2014/01/21 21:14:58 sf Exp $	*/
 
 /*
@@ -191,7 +191,7 @@ viornd_attach(device_t parent, device_t 
 	sc->sc_vq.vq_done = viornd_vq_done;
 
 	error = virtio_child_attach_finish(vsc, >sc_vq, 1,
-	NULL, 0);
+	NULL, VIRTIO_F_INTR_MPSAFE);
 	if (error) {
 		virtio_free_vq(vsc, >sc_vq);
 		goto vio_failed;

Index: src/sys/dev/pci/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.35 src/sys/dev/pci/vioscsi.c:1.36
--- src/sys/dev/pci/vioscsi.c:1.35	Sat Mar 25 09:03:47 2023
+++ src/sys/dev/pci/vioscsi.c	Sat Mar 25 11:04:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.35 2023/03/25 09:03:47 mlelstv Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.36 2023/03/25 11:04:34 mlelstv Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.35 2023/03/25 09:03:47 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.36 2023/03/25 11:04:34 mlelstv Exp $");
 
 #include 
 #include 
@@ -173,7 +173,8 @@ vioscsi_attach(device_t parent, device_t
 	cmd_per_lun, qsize, seg_max, max_target, max_lun);
 
 	if (virtio_child_attach_finish(vsc, sc->sc_vqs,
-	__arraycount(sc->sc_vqs), NULL, VIRTIO_F_INTR_MSIX) != 0)
+	__arraycount(sc->sc_vqs), NULL,
+	VIRTIO_F_INTR_MSIX | VIRTIO_F_INTR_MPSAFE) != 0)
 		goto err;
 
 	/*
@@ -186,6 +187,7 @@ vioscsi_attach(device_t parent, device_t
 	adapt->adapt_max_periph = adapt->adapt_openings;
 	adapt->adapt_request = vioscsi_scsipi_request;
 	adapt->adapt_minphys = minphys;
+	adapt->adapt_flags = SCSIPI_ADAPT_MPSAFE;
 
 	/*
 	 * Fill in the scsipi_channel.



CVS commit: src/sys/dev/pci

2023-03-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 25 11:04:34 UTC 2023

Modified Files:
src/sys/dev/pci: viomb.c viornd.c vioscsi.c

Log Message:
Mark as MPSAFE.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/viomb.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/viornd.c
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/vioscsi.c

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



CVS commit: src/sys/dev/pci

2023-03-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 25 11:00:35 UTC 2023

Modified Files:
src/sys/dev/pci: viomb.c

Log Message:
Fix 32bit overflow when calculating balloon size.
Don't make uvm_pglistalloc wait, it will wait forever. Instead rely on
the retries by this driver. This also allows to cancel the request.
Increase inflate speed by factor 10 (same as deflate).


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/viomb.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/dev/pci/viomb.c
diff -u src/sys/dev/pci/viomb.c:1.15 src/sys/dev/pci/viomb.c:1.16
--- src/sys/dev/pci/viomb.c:1.15	Thu Mar 23 03:55:11 2023
+++ src/sys/dev/pci/viomb.c	Sat Mar 25 11:00:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: viomb.c,v 1.15 2023/03/23 03:55:11 yamaguchi Exp $	*/
+/*	$NetBSD: viomb.c,v 1.16 2023/03/25 11:00:35 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.15 2023/03/23 03:55:11 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.16 2023/03/25 11:00:35 mlelstv Exp $");
 
 #include 
 #include 
@@ -286,8 +286,8 @@ inflate(struct viomb_softc *sc)
 	nhpages = nvpages * VIRTIO_PAGE_SIZE / PAGE_SIZE;
 
 	b = >sc_req;
-	if (uvm_pglistalloc(nhpages*PAGE_SIZE, 0, UINT32_MAX*PAGE_SIZE,
-			0, 0, >bl_pglist, nhpages, 1)) {
+	if (uvm_pglistalloc(nhpages*PAGE_SIZE, 0, UINT32_MAX*(paddr_t)PAGE_SIZE,
+			0, 0, >bl_pglist, nhpages, 0)) {
 		printf("%s: %" PRIu64 " pages of physical memory "
 		   "could not be allocated, retrying...\n",
 		   device_xname(sc->sc_dev), nhpages);
@@ -507,9 +507,9 @@ viomb_thread(void *arg)
 if (r != 0)
 	sleeptime = 1;
 else
-	sleeptime = 1000;
+	sleeptime = 100;
 			} else
-sleeptime = 100;
+sleeptime = 20;
 		} else if (sc->sc_npages < sc->sc_actual + sc->sc_inflight) {
 			if (sc->sc_inflight == 0)
 r = deflate(sc);



CVS commit: src/sys/dev/pci

2023-03-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 25 11:00:35 UTC 2023

Modified Files:
src/sys/dev/pci: viomb.c

Log Message:
Fix 32bit overflow when calculating balloon size.
Don't make uvm_pglistalloc wait, it will wait forever. Instead rely on
the retries by this driver. This also allows to cancel the request.
Increase inflate speed by factor 10 (same as deflate).


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/viomb.c

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



CVS commit: src/sys/dev/pci

2023-03-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 25 09:03:47 UTC 2023

Modified Files:
src/sys/dev/pci: vioscsi.c

Log Message:
A single SCSI request may require multiple slots in the virtio queue
but the queue isn't sized for the theoretical maximum. So just use
XS_BUSY to pace the scsipi layer.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/vioscsi.c

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



CVS commit: src/sys/dev/pci

2023-03-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 25 09:03:47 UTC 2023

Modified Files:
src/sys/dev/pci: vioscsi.c

Log Message:
A single SCSI request may require multiple slots in the virtio queue
but the queue isn't sized for the theoretical maximum. So just use
XS_BUSY to pace the scsipi layer.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/vioscsi.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/dev/pci/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.34 src/sys/dev/pci/vioscsi.c:1.35
--- src/sys/dev/pci/vioscsi.c:1.34	Sat Mar 25 08:14:00 2023
+++ src/sys/dev/pci/vioscsi.c	Sat Mar 25 09:03:47 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.34 2023/03/25 08:14:00 mlelstv Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.35 2023/03/25 09:03:47 mlelstv Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.34 2023/03/25 08:14:00 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.35 2023/03/25 09:03:47 mlelstv Exp $");
 
 #include 
 #include 
@@ -300,7 +300,7 @@ vioscsi_scsipi_request(struct scsipi_cha
 	 */
 	vr = vioscsi_req_get(sc);
 	if (vr == NULL) {
-		xs->error = XS_RESOURCE_SHORTAGE;
+		xs->error = XS_BUSY;
 		scsipi_done(xs);
 		return;
 	}
@@ -387,11 +387,9 @@ stuffup:
 
 	error = virtio_enqueue_reserve(vsc, vq, slot, nsegs);
 	if (error) {
-		aprint_error_dev(sc->sc_dev, "error reserving %d (nsegs %d)\n",
-		error, nsegs);
 		bus_dmamap_unload(virtio_dmat(vsc), vr->vr_data);
 		/* slot already freed by virtio_enqueue_reserve() */
-		xs->error = XS_RESOURCE_SHORTAGE;
+		xs->error = XS_BUSY;
 		scsipi_done(xs);
 		return;
 	}



CVS commit: src/sys/dev/pci

2023-03-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 25 08:14:00 UTC 2023

Modified Files:
src/sys/dev/pci: vioscsi.c

Log Message:
restore fetch of qsize.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/vioscsi.c

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



CVS commit: src/sys/dev/pci

2023-03-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 25 08:14:00 UTC 2023

Modified Files:
src/sys/dev/pci: vioscsi.c

Log Message:
restore fetch of qsize.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/vioscsi.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/dev/pci/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.33 src/sys/dev/pci/vioscsi.c:1.34
--- src/sys/dev/pci/vioscsi.c:1.33	Fri Mar 24 13:32:19 2023
+++ src/sys/dev/pci/vioscsi.c	Sat Mar 25 08:14:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.33 2023/03/24 13:32:19 yamaguchi Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.34 2023/03/25 08:14:00 mlelstv Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.33 2023/03/24 13:32:19 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.34 2023/03/25 08:14:00 mlelstv Exp $");
 
 #include 
 #include 
@@ -163,6 +163,7 @@ vioscsi_attach(device_t parent, device_t
 			sc->sc_vqs[i].vq_done = vioscsi_vq_done;
 	}
 
+	qsize = sc->sc_vqs[VIOSCSI_VQ_REQUEST].vq_num;
 	if (vioscsi_alloc_reqs(sc, vsc, qsize))
 		goto err;
 



CVS commit: src/sys/dev/pci

2023-03-24 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Sat Mar 25 02:59:23 UTC 2023

Modified Files:
src/sys/dev/pci: virtio.c

Log Message:
Setup virtqueues after registering them to virtio_softc


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/pci/virtio.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/dev/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.68 src/sys/dev/pci/virtio.c:1.69
--- src/sys/dev/pci/virtio.c:1.68	Fri Mar 24 13:32:19 2023
+++ src/sys/dev/pci/virtio.c	Sat Mar 25 02:59:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.68 2023/03/24 13:32:19 yamaguchi Exp $	*/
+/*	$NetBSD: virtio.c,v 1.69 2023/03/25 02:59:23 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.68 2023/03/24 13:32:19 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.69 2023/03/25 02:59:23 yamaguchi Exp $");
 
 #include 
 #include 
@@ -865,10 +865,6 @@ virtio_alloc_vq(struct virtio_softc *sc,
 
 	virtio_reset_vq(sc, vq);
 
-	/* set the vq address */
-	sc->sc_ops->setup_queue(sc, vq->vq_index,
-	vq->vq_dmamap->dm_segs[0].ds_addr);
-
 	aprint_verbose_dev(sc->sc_dev,
 	"allocated %zu byte for virtqueue %d for %s, size %d\n",
 	allocsize, vq->vq_index, name, vq_num);
@@ -1301,6 +1297,7 @@ virtio_child_attach_finish(struct virtio
 virtio_callback config_change,
 int req_flags)
 {
+	size_t i;
 	int r;
 
 #ifdef DIAGNOSTIC
@@ -1309,11 +1306,11 @@ virtio_child_attach_finish(struct virtio
 	KASSERT((req_flags & VIRTIO_ASSERT_FLAGS) != VIRTIO_ASSERT_FLAGS);
 #undef VIRTIO_ASSERT_FLAGS
 
-	for (size_t _i = 0; _i < nvqs; _i++){
-		KASSERT(vqs[_i].vq_index == _i);
-		KASSERT(vqs[_i].vq_intrhand != NULL);
-		KASSERT(vqs[_i].vq_done == NULL ||
-		vqs[_i].vq_intrhand == virtio_vq_done);
+	for (i = 0; i < nvqs; i++){
+		KASSERT(vqs[i].vq_index == i);
+		KASSERT(vqs[i].vq_intrhand != NULL);
+		KASSERT(vqs[i].vq_done == NULL ||
+		vqs[i].vq_intrhand == virtio_vq_done);
 	}
 #endif
 
@@ -1325,6 +1322,12 @@ virtio_child_attach_finish(struct virtio
 	sc->sc_intrhand = virtio_vq_intr;
 	sc->sc_flags = req_flags;
 
+	/* set the vq address */
+	for (i = 0; i < nvqs; i++) {
+		sc->sc_ops->setup_queue(sc, vqs[i].vq_index,
+		vqs[i].vq_dmamap->dm_segs[0].ds_addr);
+	}
+
 	r = sc->sc_ops->alloc_interrupts(sc);
 	if (r != 0) {
 		aprint_error_dev(sc->sc_dev,



CVS commit: src/sys/dev/pci

2023-03-24 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Sat Mar 25 02:59:23 UTC 2023

Modified Files:
src/sys/dev/pci: virtio.c

Log Message:
Setup virtqueues after registering them to virtio_softc


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/pci/virtio.c

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



CVS commit: src/sys/dev/pci

2023-03-24 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Mar 24 13:32:19 UTC 2023

Modified Files:
src/sys/dev/pci: vioscsi.c virtio.c

Log Message:
Added check of pointer for allocated memory before release of resource


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/pci/vioscsi.c
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/pci/virtio.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/dev/pci/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.32 src/sys/dev/pci/vioscsi.c:1.33
--- src/sys/dev/pci/vioscsi.c:1.32	Thu Mar 23 03:55:11 2023
+++ src/sys/dev/pci/vioscsi.c	Fri Mar 24 13:32:19 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.32 2023/03/23 03:55:11 yamaguchi Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.33 2023/03/24 13:32:19 yamaguchi Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.32 2023/03/23 03:55:11 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.33 2023/03/24 13:32:19 yamaguchi Exp $");
 
 #include 
 #include 
@@ -206,8 +206,7 @@ err:
 		vioscsi_free_reqs(sc, vsc);
 
 	for (i=0; i < __arraycount(sc->sc_vqs); i++) {
-		if (sc->sc_vqs[i].vq_num > 0)
-			virtio_free_vq(vsc, >sc_vqs[i]);
+		virtio_free_vq(vsc, >sc_vqs[i]);
 	}
 
 	virtio_child_attach_failed(vsc);

Index: src/sys/dev/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.67 src/sys/dev/pci/virtio.c:1.68
--- src/sys/dev/pci/virtio.c:1.67	Thu Mar 23 03:55:11 2023
+++ src/sys/dev/pci/virtio.c	Fri Mar 24 13:32:19 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.67 2023/03/23 03:55:11 yamaguchi Exp $	*/
+/*	$NetBSD: virtio.c,v 1.68 2023/03/24 13:32:19 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.67 2023/03/23 03:55:11 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.68 2023/03/24 13:32:19 yamaguchi Exp $");
 
 #include 
 #include 
@@ -898,6 +898,9 @@ virtio_free_vq(struct virtio_softc *sc, 
 	struct vq_entry *qe;
 	int i = 0;
 
+	if (vq->vq_vaddr == NULL)
+		return 0;
+
 	/* device must be already deactivated */
 	/* confirm the vq is empty */
 	SIMPLEQ_FOREACH(qe, >vq_freelist, qe_list) {



CVS commit: src/sys/dev/pci

2023-03-24 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Mar 24 13:32:19 UTC 2023

Modified Files:
src/sys/dev/pci: vioscsi.c virtio.c

Log Message:
Added check of pointer for allocated memory before release of resource


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/pci/vioscsi.c
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/pci/virtio.c

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



CVS commit: src/sys/dev/pci

2023-03-24 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Mar 24 13:16:15 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): fix wrong memory allocation size


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.105 src/sys/dev/pci/if_vioif.c:1.106
--- src/sys/dev/pci/if_vioif.c:1.105	Thu Mar 23 07:26:07 2023
+++ src/sys/dev/pci/if_vioif.c	Fri Mar 24 13:16:15 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.105 2023/03/23 07:26:07 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.106 2023/03/24 13:16:15 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.105 2023/03/23 07:26:07 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.106 2023/03/24 13:16:15 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1401,7 +1401,7 @@ vioif_alloc_queues(struct vioif_softc *s
 		nvqs++;
 
 	sc->sc_vqs = kmem_zalloc(sizeof(sc->sc_vqs[0]) * nvqs, KM_SLEEP);
-	sc->sc_netqs = kmem_zalloc(sizeof(sc->sc_vqs[0]) * netq_num,
+	sc->sc_netqs = kmem_zalloc(sizeof(sc->sc_netqs[0]) * netq_num,
 	KM_SLEEP);
 }
 



CVS commit: src/sys/dev/pci

2023-03-24 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Mar 24 13:16:15 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): fix wrong memory allocation size


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/dev/pci/if_vioif.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

2023-03-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Mar 24 12:28:42 UTC 2023

Modified Files:
src/sys/arch/x86/x86: consinit.c
src/sys/arch/xen/include: xen.h
src/sys/arch/xen/x86: pvh_consinit.c

Log Message:
Allow a PVH dom0 to use VGA as console: make xen_pvh_consinit() return 1 if
it handles the console and 0 otherwise (especially when console=tty0 or
console=pc is present on the command line).
In consinit() fallback to native console selection if xen_pvh_consinit()
returns 0.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x86/x86/consinit.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/xen/include/xen.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/xen/x86/pvh_consinit.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/x86/x86/consinit.c
diff -u src/sys/arch/x86/x86/consinit.c:1.35 src/sys/arch/x86/x86/consinit.c:1.36
--- src/sys/arch/x86/x86/consinit.c:1.35	Mon Sep  5 14:18:51 2022
+++ src/sys/arch/x86/x86/consinit.c	Fri Mar 24 12:28:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: consinit.c,v 1.35 2022/09/05 14:18:51 riastradh Exp $	*/
+/*	$NetBSD: consinit.c,v 1.36 2023/03/24 12:28:42 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1998
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.35 2022/09/05 14:18:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.36 2023/03/24 12:28:42 bouyer Exp $");
 
 #include "opt_kgdb.h"
 #include "opt_puc.h"
@@ -173,8 +173,9 @@ consinit(void)
 
 #ifdef XENPVHVM
 	if (vm_guest == VM_GUEST_XENPVH) {
-		xen_pvh_consinit();
-		return;
+		if (xen_pvh_consinit() != 0)
+			return;
+		/* fallback to native console selection, usefull for dom0 PVH */
 	}
 #endif
 	if (initted)

Index: src/sys/arch/xen/include/xen.h
diff -u src/sys/arch/xen/include/xen.h:1.47 src/sys/arch/xen/include/xen.h:1.48
--- src/sys/arch/xen/include/xen.h:1.47	Sat May  2 16:44:36 2020
+++ src/sys/arch/xen/include/xen.h	Fri Mar 24 12:28:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen.h,v 1.47 2020/05/02 16:44:36 bouyer Exp $	*/
+/*	$NetBSD: xen.h,v 1.48 2023/03/24 12:28:42 bouyer Exp $	*/
 
 /*
  *
@@ -60,7 +60,7 @@ void	xen_parse_cmdline(int, union xen_cm
 
 void	xenconscn_attach(void);
 
-void 	xen_pvh_consinit(void);
+int 	xen_pvh_consinit(void);
 
 void	xenprivcmd_init(void);
 

Index: src/sys/arch/xen/x86/pvh_consinit.c
diff -u src/sys/arch/xen/x86/pvh_consinit.c:1.2 src/sys/arch/xen/x86/pvh_consinit.c:1.3
--- src/sys/arch/xen/x86/pvh_consinit.c:1.2	Sun May  3 17:23:14 2020
+++ src/sys/arch/xen/x86/pvh_consinit.c	Fri Mar 24 12:28:42 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pvh_consinit.c,v 1.2 2020/05/03 17:23:14 bouyer Exp $ */
+/* $NetBSD: pvh_consinit.c,v 1.3 2023/03/24 12:28:42 bouyer Exp $ */
 
 /*
  * Copyright (c) 2020 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pvh_consinit.c,v 1.2 2020/05/03 17:23:14 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pvh_consinit.c,v 1.3 2023/03/24 12:28:42 bouyer Exp $");
 
 #include "xencons.h"
 #include 
@@ -51,7 +51,7 @@ static struct consdev pvh_xencons = {
 };
 
 
-void
+int
 xen_pvh_consinit(void)
 {
 	/*
@@ -59,21 +59,35 @@ xen_pvh_consinit(void)
 	 * boot stage.
 	 */
 	static int initted = 0;
+	if (xendomain_is_dom0()) {
+		union xen_cmdline_parseinfo xcp;
+		xen_parse_cmdline(XEN_PARSE_CONSOLE, );
+#ifdef CONS_OVERRIDE
+if (strcmp(default_consinfo.devname, "tty0") == 0 ||
+		strcmp(default_consinfo.devname, "pc") == 0) {
+#else
+		if (strcmp(xcp.xcp_console, "tty0") == 0 || /* linux name */
+		strcmp(xcp.xcp_console, "pc") == 0) { /* NetBSD name */
+#endif /* CONS_OVERRIDE */
+			return 0; /* native console code will do it */
+		}
+	}
 	if (initted == 0 && !xendomain_is_dom0()) {
 		/* pmap not up yet, fall back to printk() */
 		cn_tab = _xencons;
 		initted++;
-		return;
+		return 1;
 	} else if (initted > 1) {
-		return;
+		return 1;
 	}
 	initted++;
 	if (xendomain_is_dom0()) {
+		/* we know we're using Xen's console at this point */
 		xenconscn_attach(); /* no ring in this case */
 		initted++; /* don't init console twice */
-		return;
+		return 1;
 	}
-		
+
 #if NXENCONS > 0
 	/* we can now map the xencons rings. */
 	struct xen_hvm_param xen_hvm_param;
@@ -98,6 +112,7 @@ xen_pvh_consinit(void)
 	xen_start_info.console.domU.evtchn = xen_hvm_param.value;
 	xenconscn_attach();
 #endif
+	return 1;
 }
 
 static int



CVS commit: src/sys/arch

2023-03-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Mar 24 12:28:42 UTC 2023

Modified Files:
src/sys/arch/x86/x86: consinit.c
src/sys/arch/xen/include: xen.h
src/sys/arch/xen/x86: pvh_consinit.c

Log Message:
Allow a PVH dom0 to use VGA as console: make xen_pvh_consinit() return 1 if
it handles the console and 0 otherwise (especially when console=tty0 or
console=pc is present on the command line).
In consinit() fallback to native console selection if xen_pvh_consinit()
returns 0.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x86/x86/consinit.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/xen/include/xen.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/xen/x86/pvh_consinit.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/x86/x86

2023-03-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Mar 24 12:25:28 UTC 2023

Modified Files:
src/sys/arch/x86/x86: mpacpi.c

Log Message:
mpacpi_config_cpu(): Xen with a PVH dom0 reports x2apic->LocalApicId
below 0xff, which causes a panic later because no CPUs are attached.
Accept the bogus LocalApicId value for VM_GUEST_XENPVH.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/x86/x86/mpacpi.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/x86/x86/mpacpi.c
diff -u src/sys/arch/x86/x86/mpacpi.c:1.109 src/sys/arch/x86/x86/mpacpi.c:1.110
--- src/sys/arch/x86/x86/mpacpi.c:1.109	Sat Jan 22 11:49:17 2022
+++ src/sys/arch/x86/x86/mpacpi.c	Fri Mar 24 12:25:28 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpacpi.c,v 1.109 2022/01/22 11:49:17 thorpej Exp $	*/
+/*	$NetBSD: mpacpi.c,v 1.110 2023/03/24 12:25:28 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.109 2022/01/22 11:49:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.110 2023/03/24 12:25:28 bouyer Exp $");
 
 #include "acpica.h"
 #include "opt_acpi.h"
@@ -396,8 +396,9 @@ mpacpi_config_cpu(ACPI_SUBTABLE_HEADER *
 		/* ACPI spec: "Logical processors with APIC ID values
 		 * less than 255 must use the Processor Local APIC
 		 * structure to convey their APIC information to OSPM."
+		 * But Xen with PVH dom0 breaks this ACPI spec.
 		 */
-		if (x2apic->LocalApicId <= 0xff) {
+		if (x2apic->LocalApicId <= 0xff && vm_guest != VM_GUEST_XENPVH) {
 			printf("bogus MADT X2APIC entry (id = 0x%"PRIx32")\n",
 			x2apic->LocalApicId);
 			break;



CVS commit: src/sys/arch/x86/x86

2023-03-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Mar 24 12:25:28 UTC 2023

Modified Files:
src/sys/arch/x86/x86: mpacpi.c

Log Message:
mpacpi_config_cpu(): Xen with a PVH dom0 reports x2apic->LocalApicId
below 0xff, which causes a panic later because no CPUs are attached.
Accept the bogus LocalApicId value for VM_GUEST_XENPVH.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/x86/x86/mpacpi.c

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



CVS commit: src/sys/kern

2023-03-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Mar 24 12:22:52 UTC 2023

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

Log Message:
extattr_set_vp(): properly handle XATTR_REPLACE flags, FFSv2ea will return
ENOATTR, not ENODATA if the attribute is missing.

Makes glusterfs 10 run on a FFSv2ea file system.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/kern/vfs_xattr.c

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



CVS commit: src/sys/kern

2023-03-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Mar 24 12:22:52 UTC 2023

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

Log Message:
extattr_set_vp(): properly handle XATTR_REPLACE flags, FFSv2ea will return
ENOATTR, not ENODATA if the attribute is missing.

Makes glusterfs 10 run on a FFSv2ea file system.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/kern/vfs_xattr.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/vfs_xattr.c
diff -u src/sys/kern/vfs_xattr.c:1.38 src/sys/kern/vfs_xattr.c:1.39
--- src/sys/kern/vfs_xattr.c:1.38	Tue Oct 25 23:22:36 2022
+++ src/sys/kern/vfs_xattr.c	Fri Mar 24 12:22:52 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_xattr.c,v 1.38 2022/10/25 23:22:36 riastradh Exp $	*/
+/*	$NetBSD: vfs_xattr.c,v 1.39 2023/03/24 12:22:52 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.38 2022/10/25 23:22:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.39 2023/03/24 12:22:52 bouyer Exp $");
 
 #include 
 #include 
@@ -231,6 +231,7 @@ extattr_set_vp(struct vnode *vp, int att
 
 		switch (error) {
 		case ENODATA:
+		case ENOATTR:
 			if (flag & XATTR_REPLACE)
 goto done;
 			break;



CVS commit: src/sys/uvm

2023-03-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Mar 24 07:26:21 UTC 2023

Modified Files:
src/sys/uvm: uvm_map.c

Log Message:
Unwrap. NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.404 -r1.405 src/sys/uvm/uvm_map.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/uvm/uvm_map.c
diff -u src/sys/uvm/uvm_map.c:1.404 src/sys/uvm/uvm_map.c:1.405
--- src/sys/uvm/uvm_map.c:1.404	Mon Feb 27 16:24:45 2023
+++ src/sys/uvm/uvm_map.c	Fri Mar 24 07:26:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_map.c,v 1.404 2023/02/27 16:24:45 riastradh Exp $	*/
+/*	$NetBSD: uvm_map.c,v 1.405 2023/03/24 07:26:21 skrll Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.404 2023/02/27 16:24:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.405 2023/03/24 07:26:21 skrll Exp $");
 
 #include "opt_ddb.h"
 #include "opt_pax.h"
@@ -2384,8 +2384,7 @@ uvm_unmap_remove(struct vm_map *map, vad
 		}
 
 		if (VM_MAP_IS_KERNEL(map) && (flags & UVM_FLAG_NOWAIT) == 0) {
-			uvm_km_check_empty(map, entry->start,
-			entry->end);
+			uvm_km_check_empty(map, entry->start, entry->end);
 		}
 #endif /* defined(UVMDEBUG) */
 



CVS commit: src/sys/uvm

2023-03-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Mar 24 07:26:21 UTC 2023

Modified Files:
src/sys/uvm: uvm_map.c

Log Message:
Unwrap. NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.404 -r1.405 src/sys/uvm/uvm_map.c

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



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:53:02 UTC 2023

Modified Files:
src/sys/nfs: nfs_serv.c

Log Message:
nfs: Avoid free of uninitialized on bad name size in create, mknod.

XXX These error branches are a nightmare and need to be more
systematically cleaned up.  Even if they are correct now, they are
impossible to audit and extremely fragile in case anyone ever needs
to make other changes to them.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/nfs/nfs_serv.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/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.183 src/sys/nfs/nfs_serv.c:1.184
--- src/sys/nfs/nfs_serv.c:1.183	Wed Apr 27 17:38:52 2022
+++ src/sys/nfs/nfs_serv.c	Thu Mar 23 19:53:01 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.184 2023/03/23 19:53:01 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.184 2023/03/23 19:53:01 riastradh Exp $");
 
 #include 
 #include 
@@ -1648,10 +1648,10 @@ nfsmout:
 			vput(nd.ni_dvp);
 		if (nd.ni_vp)
 			vput(nd.ni_vp);
-	}
-	if (nd.ni_pathbuf != NULL) {
-		pathbuf_destroy(nd.ni_pathbuf);
-		nd.ni_pathbuf = NULL;
+		if (nd.ni_pathbuf != NULL) {
+			pathbuf_destroy(nd.ni_pathbuf);
+			nd.ni_pathbuf = NULL;
+		}
 	}
 	return (error);
 }
@@ -1801,10 +1801,10 @@ nfsmout:
 			vput(nd.ni_dvp);
 		if (nd.ni_vp)
 			vput(nd.ni_vp);
-	}
-	if (nd.ni_pathbuf != NULL) {
-		pathbuf_destroy(nd.ni_pathbuf);
-		nd.ni_pathbuf = NULL;
+		if (nd.ni_pathbuf != NULL) {
+			pathbuf_destroy(nd.ni_pathbuf);
+			nd.ni_pathbuf = NULL;
+		}
 	}
 	if (dirp)
 		vrele(dirp);



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:53:02 UTC 2023

Modified Files:
src/sys/nfs: nfs_serv.c

Log Message:
nfs: Avoid free of uninitialized on bad name size in create, mknod.

XXX These error branches are a nightmare and need to be more
systematically cleaned up.  Even if they are correct now, they are
impossible to audit and extremely fragile in case anyone ever needs
to make other changes to them.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/nfs/nfs_serv.c

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



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:52 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned name lengths so we don't trip over negative ones.

- nfsm_strsiz is only used with uint32_t in callers, but let's not
  leave it as a rake to step on.

- nfsm_srvnamesiz is abused with signed s.  The internal conversion
  to unsigned serves to reject both negative and too-large values in
  such callers.

  XXX Should make all callers use unsigned, rather than flipping back
  and forth between signed and unsigned for name lengths.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/nfs/nfsm_subs.h

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



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:52 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned name lengths so we don't trip over negative ones.

- nfsm_strsiz is only used with uint32_t in callers, but let's not
  leave it as a rake to step on.

- nfsm_srvnamesiz is abused with signed s.  The internal conversion
  to unsigned serves to reject both negative and too-large values in
  such callers.

  XXX Should make all callers use unsigned, rather than flipping back
  and forth between signed and unsigned for name lengths.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/nfs/nfsm_subs.h

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

Modified files:

Index: src/sys/nfs/nfsm_subs.h
diff -u src/sys/nfs/nfsm_subs.h:1.56 src/sys/nfs/nfsm_subs.h:1.57
--- src/sys/nfs/nfsm_subs.h:1.56	Thu Mar 23 19:52:33 2023
+++ src/sys/nfs/nfsm_subs.h	Thu Mar 23 19:52:52 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsm_subs.h,v 1.56 2023/03/23 19:52:33 riastradh Exp $	*/
+/*	$NetBSD: nfsm_subs.h,v 1.57 2023/03/23 19:52:52 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -366,7 +366,7 @@
 
 #define	nfsm_strsiz(s,m) \
 		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
-		if (((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
+		if ((uint32_t)((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
 			m_freem(mrep); \
 			error = EBADRPC; \
 			goto nfsmout; \
@@ -374,7 +374,8 @@
 
 #define	nfsm_srvnamesiz(s) \
 		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
-		if (((s) = fxdr_unsigned(uint32_t,*tl)) > NFS_MAXNAMLEN) \
+		if ((uint32_t)((s) = fxdr_unsigned(uint32_t,*tl)) > \
+		NFS_MAXNAMLEN) \
 			error = NFSERR_NAMETOL; \
 		if (error) \
 			nfsm_reply(0); \



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:43 UTC 2023

Modified Files:
src/sys/nfs: nfs_srvsubs.c

Log Message:
nfs: Avoid integer overflow in nfs_namei bounds check.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/nfs/nfs_srvsubs.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/nfs/nfs_srvsubs.c
diff -u src/sys/nfs/nfs_srvsubs.c:1.16 src/sys/nfs/nfs_srvsubs.c:1.17
--- src/sys/nfs/nfs_srvsubs.c:1.16	Wed Apr 27 17:38:52 2022
+++ src/sys/nfs/nfs_srvsubs.c	Thu Mar 23 19:52:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_srvsubs.c,v 1.16 2022/04/27 17:38:52 hannken Exp $	*/
+/*	$NetBSD: nfs_srvsubs.c,v 1.17 2023/03/23 19:52:42 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.16 2022/04/27 17:38:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.17 2023/03/23 19:52:42 riastradh Exp $");
 
 #include 
 #include 
@@ -129,7 +129,7 @@ nfs_namei(struct nameidata *ndp, nfsrvfh
 	*retdirp = NULL;
 	ndp->ni_pathbuf = NULL;
 
-	if ((len + 1) > NFS_MAXPATHLEN)
+	if (len > NFS_MAXPATHLEN - 1)
 		return (ENAMETOOLONG);
 	if (len == 0)
 		return (EACCES);



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:33 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned fhlen so we don't trip over negative values.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/nfs/nfsm_subs.h

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

Modified files:

Index: src/sys/nfs/nfsm_subs.h
diff -u src/sys/nfs/nfsm_subs.h:1.55 src/sys/nfs/nfsm_subs.h:1.56
--- src/sys/nfs/nfsm_subs.h:1.55	Thu Aug 12 20:25:27 2021
+++ src/sys/nfs/nfsm_subs.h	Thu Mar 23 19:52:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsm_subs.h,v 1.55 2021/08/12 20:25:27 andvar Exp $	*/
+/*	$NetBSD: nfsm_subs.h,v 1.56 2023/03/23 19:52:33 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -480,20 +480,24 @@
 		} }
 
 #define nfsm_srvmtofh(nsfh) \
-	{ int fhlen = NFSX_V3FH; \
+	{ uint32_t fhlen = NFSX_V3FH; \
 		if (nfsd->nd_flag & ND_NFSV3) { \
-			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
-			fhlen = fxdr_unsigned(int, *tl); \
+			nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); \
+			fhlen = fxdr_unsigned(uint32_t, *tl); \
+			CTASSERT(NFSX_V3FHMAX <= FHANDLE_SIZE_MAX); \
 			if (fhlen > NFSX_V3FHMAX || \
 			(fhlen < FHANDLE_SIZE_MIN && fhlen > 0)) { \
 error = EBADRPC; \
 nfsm_reply(0); \
 			} \
 		} else { \
+			CTASSERT(NFSX_V2FH >= FHANDLE_SIZE_MIN); \
 			fhlen = NFSX_V2FH; \
 		} \
 		(nsfh)->nsfh_size = fhlen; \
 		if (fhlen != 0) { \
+			KASSERT(fhlen >= FHANDLE_SIZE_MIN); \
+			KASSERT(fhlen <= FHANDLE_SIZE_MAX); \
 			nfsm_dissect(tl, u_int32_t *, fhlen); \
 			memcpy(NFSRVFH_DATA(nsfh), tl, fhlen); \
 		} \



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:33 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned fhlen so we don't trip over negative values.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/nfs/nfsm_subs.h

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



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:43 UTC 2023

Modified Files:
src/sys/nfs: nfs_srvsubs.c

Log Message:
nfs: Avoid integer overflow in nfs_namei bounds check.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/nfs/nfs_srvsubs.c

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



CVS commit: src/sys/dev/pci

2023-03-23 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 07:26:07 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): clear flags when configure is failed


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.104 src/sys/dev/pci/if_vioif.c:1.105
--- src/sys/dev/pci/if_vioif.c:1.104	Thu Mar 23 03:55:11 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 07:26:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.104 2023/03/23 03:55:11 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.105 2023/03/23 07:26:07 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.104 2023/03/23 03:55:11 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.105 2023/03/23 07:26:07 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -924,8 +924,10 @@ vioif_ifflags(struct vioif_softc *sc)
 		log(LOG_WARNING,
 		"%s: couldn't %sable ALLMULTI\n",
 		ifp->if_xname, onoff ? "en" : "dis");
-		if (onoff == false) {
-			ifp->if_flags |= IFF_ALLMULTI;
+		if (onoff) {
+			CLR(ifp->if_flags, IFF_ALLMULTI);
+		} else {
+			SET(ifp->if_flags, IFF_ALLMULTI);
 		}
 	}
 
@@ -935,8 +937,10 @@ vioif_ifflags(struct vioif_softc *sc)
 		log(LOG_WARNING,
 		"%s: couldn't %sable PROMISC\n",
 		ifp->if_xname, onoff ? "en" : "dis");
-		if (onoff == false) {
-			ifp->if_flags |= IFF_PROMISC;
+		if (onoff) {
+			CLR(ifp->if_flags, IFF_PROMISC);
+		} else {
+			SET(ifp->if_flags, IFF_PROMISC);
 		}
 	}
 



CVS commit: src/sys/dev/pci

2023-03-23 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 07:26:07 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): clear flags when configure is failed


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 03:55:11 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c ld_virtio.c vio9p.c viomb.c viornd.c
vioscsi.c virtio.c virtiovar.h
src/sys/dev/virtio: viocon.c

Log Message:
Added functions to set interrupt handler and index into virtqueue


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/pci/if_vioif.c
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/pci/ld_virtio.c \
src/sys/dev/pci/vioscsi.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/vio9p.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/viomb.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/viornd.c
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/pci/virtiovar.h
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/virtio/viocon.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.103 src/sys/dev/pci/if_vioif.c:1.104
--- src/sys/dev/pci/if_vioif.c:1.103	Thu Mar 23 03:27:48 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 03:55:11 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.103 2023/03/23 03:27:48 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.104 2023/03/23 03:55:11 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.103 2023/03/23 03:27:48 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.104 2023/03/23 03:55:11 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -596,8 +596,10 @@ vioif_attach(device_t parent, device_t s
 		 * Allocating a virtqueue for control channel
 		 */
 		sc->sc_ctrlq.ctrlq_vq = >sc_vqs[ctrlq_idx];
-		r = virtio_alloc_vq(vsc, ctrlq->ctrlq_vq, ctrlq_idx,
-		NBPG, 1, "control");
+		virtio_init_vq(vsc, ctrlq->ctrlq_vq, ctrlq_idx,
+		vioif_ctrl_intr, ctrlq);
+
+		r = virtio_alloc_vq(vsc, ctrlq->ctrlq_vq, NBPG, 1, "control");
 		if (r != 0) {
 			aprint_error_dev(self, "failed to allocate "
 			"a virtqueue for control channel, error code %d\n",
@@ -606,9 +608,6 @@ vioif_attach(device_t parent, device_t s
 			sc->sc_has_ctrl = false;
 			cv_destroy(>ctrlq_wait);
 			mutex_destroy(>ctrlq_wait_lock);
-		} else {
-			ctrlq->ctrlq_vq->vq_intrhand = vioif_ctrl_intr;
-			ctrlq->ctrlq_vq->vq_intrhand_arg = (void *) ctrlq;
 		}
 	}
 
@@ -623,7 +622,7 @@ vioif_attach(device_t parent, device_t s
 		goto err;
 
 	r = virtio_child_attach_finish(vsc, sc->sc_vqs, nvqs,
-	vioif_config_change, virtio_vq_intrhand, req_flags);
+	vioif_config_change, req_flags);
 	if (r != 0)
 		goto err;
 
@@ -1470,15 +1469,15 @@ vioif_netqueue_init(struct vioif_softc *
 	"%s-%s", device_xname(sc->sc_dev), qname);
 
 	mutex_init(>netq_lock, MUTEX_DEFAULT, IPL_NET);
-	r = virtio_alloc_vq(vsc, vq, qid,
+	virtio_init_vq(vsc, vq, qid, params[dir].intrhand, netq);
+
+	r = virtio_alloc_vq(vsc, vq,
 	params[dir].segsize + sc->sc_hdr_size,
 	params[dir].nsegs, qname);
 	if (r != 0)
 		goto err;
 	netq->netq_vq = vq;
 
-	netq->netq_vq->vq_intrhand = params[dir].intrhand;
-	netq->netq_vq->vq_intrhand_arg = netq;
 	netq->netq_softint = softint_establish(softint_flags,
 	params[dir].sihand, netq);
 	if (netq->netq_softint == NULL) {
@@ -1534,8 +1533,6 @@ err:
 		softint_disestablish(netq->netq_softint);
 		netq->netq_softint = NULL;
 	}
-	netq->netq_vq->vq_intrhand = NULL;
-	netq->netq_vq->vq_intrhand_arg = NULL;
 
 	virtio_free_vq(vsc, vq);
 	mutex_destroy(>netq_lock);

Index: src/sys/dev/pci/ld_virtio.c
diff -u src/sys/dev/pci/ld_virtio.c:1.31 src/sys/dev/pci/ld_virtio.c:1.32
--- src/sys/dev/pci/ld_virtio.c:1.31	Thu Mar 23 03:27:48 2023
+++ src/sys/dev/pci/ld_virtio.c	Thu Mar 23 03:55:11 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_virtio.c,v 1.31 2023/03/23 03:27:48 yamaguchi Exp $	*/
+/*	$NetBSD: ld_virtio.c,v 1.32 2023/03/23 03:55:11 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.31 2023/03/23 03:27:48 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.32 2023/03/23 03:55:11 yamaguchi Exp $");
 
 #include 
 #include 
@@ -332,15 +332,17 @@ ld_virtio_attach(device_t parent, device
 	/* 2 for the minimum size */
 	maxnsegs += VIRTIO_BLK_MIN_SEGMENTS;
 
-	if (virtio_alloc_vq(vsc, >sc_vq, 0, maxxfersize, maxnsegs,
+	virtio_init_vq_vqdone(vsc, >sc_vq, 0,
+	ld_virtio_vq_done);
+
+	if (virtio_alloc_vq(vsc, >sc_vq, maxxfersize, maxnsegs,
 	"I/O request") != 0) {
 		goto err;
 	}
 	qsize = sc->sc_vq.vq_num;
-	sc->sc_vq.vq_done = ld_virtio_vq_done;
 
 	if (virtio_child_attach_finish(vsc, >sc_vq, 1,
-	NULL, virtio_vq_intr, VIRTIO_F_INTR_MSIX) != 0)
+	NULL, VIRTIO_F_INTR_MSIX) != 0)
 		goto err;
 
 	ld->sc_dv = self;
Index: src/sys/dev/pci/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.31 

CVS commit: src/sys/dev

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 03:55:11 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c ld_virtio.c vio9p.c viomb.c viornd.c
vioscsi.c virtio.c virtiovar.h
src/sys/dev/virtio: viocon.c

Log Message:
Added functions to set interrupt handler and index into virtqueue


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/pci/if_vioif.c
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/pci/ld_virtio.c \
src/sys/dev/pci/vioscsi.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/vio9p.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/viomb.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/viornd.c
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/pci/virtiovar.h
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/virtio/viocon.c

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



CVS commit: src/sys/dev/virtio

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 03:44:28 UTC 2023

Modified Files:
src/sys/dev/virtio: viocon.c

Log Message:
viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/virtio/viocon.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/dev/virtio/viocon.c
diff -u src/sys/dev/virtio/viocon.c:1.6 src/sys/dev/virtio/viocon.c:1.7
--- src/sys/dev/virtio/viocon.c:1.6	Thu Mar 23 03:27:48 2023
+++ src/sys/dev/virtio/viocon.c	Thu Mar 23 03:44:28 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: viocon.c,v 1.6 2023/03/23 03:27:48 yamaguchi Exp $	*/
+/*	$NetBSD: viocon.c,v 1.7 2023/03/23 03:44:28 yamaguchi Exp $	*/
 /*	$OpenBSD: viocon.c,v 1.8 2021/11/05 11:38:29 mpi Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: viocon.c,v 1.6 2023/03/23 03:27:48 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: viocon.c,v 1.7 2023/03/23 03:44:28 yamaguchi Exp $");
 
 #include 
 #include 
@@ -123,6 +123,9 @@ struct viocon_softc {
 	struct device		*sc_dev;
 	struct virtio_softc	*sc_virtio;
 	struct virtqueue	*sc_vqs;
+#define VIOCON_PORT_RX	0
+#define VIOCON_PORT_TX	1
+#define VIOCON_PORT_NQS	2
 
 	struct virtqueue*sc_c_vq_rx;
 	struct virtqueue*sc_c_vq_tx;
@@ -194,6 +197,7 @@ viocon_attach(struct device *parent, str
 	struct viocon_softc *sc = device_private(self);
 	struct virtio_softc *vsc = device_private(parent);
 	int maxports = 1;
+	size_t nvqs;
 
 	sc->sc_dev = self;
 	if (virtio_child(vsc) != NULL) {
@@ -203,8 +207,9 @@ viocon_attach(struct device *parent, str
 	}
 	sc->sc_virtio = vsc;
 	sc->sc_max_ports = maxports;
+	nvqs = VIOCON_PORT_NQS * maxports;
 
-	sc->sc_vqs = kmem_zalloc(2 * (maxports + 1) * sizeof(sc->sc_vqs[0]),
+	sc->sc_vqs = kmem_zalloc(nvqs * sizeof(sc->sc_vqs[0]),
 	KM_SLEEP);
 	sc->sc_ports = kmem_zalloc(maxports * sizeof(sc->sc_ports[0]),
 	KM_SLEEP);
@@ -219,13 +224,13 @@ viocon_attach(struct device *parent, str
 	}
 	viocon_rx_fill(sc->sc_ports[0]);
 
-	if (virtio_child_attach_finish(vsc, sc->sc_vqs, sc->sc_max_ports * 2,
+	if (virtio_child_attach_finish(vsc, sc->sc_vqs, nvqs,
 	/*config_change*/NULL, virtio_vq_intr, /*req_flags*/0) != 0)
 		goto err;
 
 	return;
 err:
-	kmem_free(sc->sc_vqs, 2 * (maxports + 1) * sizeof(sc->sc_vqs[0]));
+	kmem_free(sc->sc_vqs, nvqs * sizeof(sc->sc_vqs[0]));
 	kmem_free(sc->sc_ports, maxports * sizeof(sc->sc_ports[0]));
 	virtio_child_attach_failed(vsc);
 }
@@ -247,11 +252,8 @@ viocon_port_create(struct viocon_softc *
 	vp->vp_sc = sc;
 	DPRINTF("%s: vp: %p\n", __func__, vp);
 
-	if (portidx == 0)
-		rxidx = 0;
-	else
-		rxidx = 2 * (portidx + 1);
-	txidx = rxidx + 1;
+	rxidx = (portidx * VIOCON_PORT_NQS) + VIOCON_PORT_RX;
+	txidx = (portidx * VIOCON_PORT_NQS) + VIOCON_PORT_TX;
 
 	snprintf(name, sizeof(name), "p%drx", portidx);
 	if (virtio_alloc_vq(vsc, >sc_vqs[rxidx], rxidx, BUFSIZE, 1,



CVS commit: src/sys/dev/virtio

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 03:44:28 UTC 2023

Modified Files:
src/sys/dev/virtio: viocon.c

Log Message:
viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/virtio/viocon.c

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



CVS commit: src/sys/dev

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 03:27:48 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c ld_virtio.c vio9p.c viomb.c viornd.c
vioscsi.c virtio.c virtio_pci.c virtiovar.h
src/sys/dev/virtio: viocon.c

Log Message:
Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/pci/if_vioif.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/ld_virtio.c \
src/sys/dev/pci/vioscsi.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/vio9p.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/viomb.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/pci/viornd.c
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/pci/virtio_pci.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/virtiovar.h
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/virtio/viocon.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.102 src/sys/dev/pci/if_vioif.c:1.103
--- src/sys/dev/pci/if_vioif.c:1.102	Thu Mar 23 03:02:17 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 03:27:48 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.102 2023/03/23 03:02:17 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.103 2023/03/23 03:27:48 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.102 2023/03/23 03:02:17 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.103 2023/03/23 03:27:48 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -465,7 +465,7 @@ vioif_attach(device_t parent, device_t s
 	u_int softint_flags;
 	int r, i, req_flags;
 	char xnamebuf[MAXCOMLEN];
-	size_t netq_num;
+	size_t nvqs;
 
 	if (virtio_child(vsc) != NULL) {
 		aprint_normal(": child already attached for %s; "
@@ -509,11 +509,11 @@ vioif_attach(device_t parent, device_t s
 #ifdef VIOIF_MULTIQ
 	req_features |= VIRTIO_NET_F_MQ;
 #endif
-	virtio_child_attach_start(vsc, self, IPL_NET, NULL,
-	vioif_config_change, virtio_vq_intrhand, req_flags,
-	req_features, VIRTIO_NET_FLAG_BITS);
 
+	virtio_child_attach_start(vsc, self, IPL_NET,
+	req_features, VIRTIO_NET_FLAG_BITS);
 	features = virtio_features(vsc);
+
 	if (features == 0)
 		goto err;
 
@@ -565,10 +565,12 @@ vioif_attach(device_t parent, device_t s
 
 		/* Limit the number of queue pairs to use */
 		sc->sc_req_nvq_pairs = MIN(sc->sc_max_nvq_pairs, ncpu);
+
+		if (sc->sc_max_nvq_pairs > 1)
+			req_flags |= VIRTIO_F_INTR_PERVQ;
 	}
 
 	vioif_alloc_queues(sc);
-	virtio_child_attach_set_vqs(vsc, sc->sc_vqs, sc->sc_req_nvq_pairs);
 
 #ifdef VIOIF_MPSAFE
 	softint_flags = SOFTINT_NET | SOFTINT_MPSAFE;
@@ -579,15 +581,17 @@ vioif_attach(device_t parent, device_t s
 	/*
 	 * Initialize network queues
 	 */
-	netq_num = sc->sc_max_nvq_pairs * 2;
-	for (i = 0; i < netq_num; i++) {
+	nvqs = sc->sc_max_nvq_pairs * 2;
+	for (i = 0; i < nvqs; i++) {
 		r = vioif_netqueue_init(sc, vsc, i, softint_flags);
 		if (r != 0)
 			goto err;
 	}
 
 	if (sc->sc_has_ctrl) {
-		int ctrlq_idx = sc->sc_max_nvq_pairs * 2;
+		int ctrlq_idx = nvqs;
+
+		nvqs++;
 		/*
 		 * Allocating a virtqueue for control channel
 		 */
@@ -618,7 +622,9 @@ vioif_attach(device_t parent, device_t s
 	if (vioif_alloc_mems(sc) < 0)
 		goto err;
 
-	if (virtio_child_attach_finish(vsc) != 0)
+	r = virtio_child_attach_finish(vsc, sc->sc_vqs, nvqs,
+	vioif_config_change, virtio_vq_intrhand, req_flags);
+	if (r != 0)
 		goto err;
 
 	if (vioif_setup_sysctl(sc) != 0) {
@@ -656,8 +662,8 @@ vioif_attach(device_t parent, device_t s
 	return;
 
 err:
-	netq_num = sc->sc_max_nvq_pairs * 2;
-	for (i = 0; i < netq_num; i++) {
+	nvqs = sc->sc_max_nvq_pairs * 2;
+	for (i = 0; i < nvqs; i++) {
 		vioif_netqueue_teardown(sc, vsc, i);
 	}
 

Index: src/sys/dev/pci/ld_virtio.c
diff -u src/sys/dev/pci/ld_virtio.c:1.30 src/sys/dev/pci/ld_virtio.c:1.31
--- src/sys/dev/pci/ld_virtio.c:1.30	Wed Apr 13 10:42:12 2022
+++ src/sys/dev/pci/ld_virtio.c	Thu Mar 23 03:27:48 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_virtio.c,v 1.30 2022/04/13 10:42:12 uwe Exp $	*/
+/*	$NetBSD: ld_virtio.c,v 1.31 2023/03/23 03:27:48 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.30 2022/04/13 10:42:12 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.31 2023/03/23 03:27:48 yamaguchi Exp $");
 
 #include 
 #include 
@@ -275,8 +275,7 @@ ld_virtio_attach(device_t parent, device
 	sc->sc_dev = self;
 	sc->sc_virtio = vsc;
 
-	virtio_child_attach_start(vsc, self, IPL_BIO, >sc_vq,
-	NULL, virtio_vq_intr, VIRTIO_F_INTR_MSIX,
+	

CVS commit: src/sys/dev

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 03:27:48 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c ld_virtio.c vio9p.c viomb.c viornd.c
vioscsi.c virtio.c virtio_pci.c virtiovar.h
src/sys/dev/virtio: viocon.c

Log Message:
Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/pci/if_vioif.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/ld_virtio.c \
src/sys/dev/pci/vioscsi.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/vio9p.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/viomb.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/pci/viornd.c
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/pci/virtio_pci.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/virtiovar.h
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/virtio/viocon.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 03:02:17 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): divide IFF_OACTIVE into per-queue


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.101 src/sys/dev/pci/if_vioif.c:1.102
--- src/sys/dev/pci/if_vioif.c:1.101	Thu Mar 23 02:57:54 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 03:02:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.101 2023/03/23 02:57:54 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.102 2023/03/23 03:02:17 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.101 2023/03/23 02:57:54 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.102 2023/03/23 03:02:17 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -266,6 +266,7 @@ struct vioif_netqueue {
 
 struct vioif_tx_context {
 	bool			 txc_link_active;
+	bool			 txc_no_free_slots;
 	pcq_t			*txc_intrq;
 	void			*txc_deferred_transmit;
 
@@ -730,7 +731,6 @@ vioif_init(struct ifnet *ifp)
 		sc->sc_act_nvq_pairs = 1;
 
 	SET(ifp->if_flags, IFF_RUNNING);
-	CLR(ifp->if_flags, IFF_OACTIVE);
 
 	vioif_net_intr_enable(sc, vsc);
 
@@ -860,7 +860,12 @@ vioif_watchdog(struct ifnet *ifp)
 	struct vioif_netqueue *netq;
 	int i;
 
-	if (ifp->if_flags & IFF_RUNNING) {
+	if (ISSET(ifp->if_flags, IFF_RUNNING)) {
+		if (ISSET(ifp->if_flags, IFF_DEBUG)) {
+			log(LOG_DEBUG, "%s: watchdog timed out\n",
+			ifp->if_xname);
+		}
+
 		for (i = 0; i < sc->sc_act_nvq_pairs; i++) {
 			netq = >sc_netqs[VIOIF_NETQ_TXQID(i)];
 
@@ -1496,6 +1501,7 @@ vioif_netqueue_init(struct vioif_softc *
 			goto err;
 		}
 		txc->txc_link_active = VIOIF_IS_LINK_ACTIVE(sc);
+		txc->txc_no_free_slots = false;
 		txc->txc_intrq = pcq_create(vq->vq_num, KM_SLEEP);
 		break;
 	}
@@ -1971,18 +1977,17 @@ vioif_send_common_locked(struct ifnet *i
 
 	txc = netq->netq_ctx;
 
-	if (!txc->txc_link_active)
-		return;
-
-	if (!is_transmit &&
-	ISSET(ifp->if_flags, IFF_OACTIVE))
+	if (!txc->txc_link_active ||
+	txc->txc_no_free_slots)
 		return;
 
 	for (;;) {
 		int slot, r;
 		r = virtio_enqueue_prep(vsc, vq, );
-		if (r == EAGAIN)
+		if (r == EAGAIN) {
+			txc->txc_no_free_slots = true;
 			break;
+		}
 		if (__predict_false(r != 0))
 			panic("enqueue_prep for tx buffers");
 
@@ -2049,21 +2054,25 @@ vioif_send_common_locked(struct ifnet *i
 /* dequeue sent mbufs */
 static bool
 vioif_tx_deq_locked(struct vioif_softc *sc, struct virtio_softc *vsc,
-struct vioif_netqueue *netq, u_int limit)
+struct vioif_netqueue *netq, u_int limit, size_t *ndeqp)
 {
 	struct virtqueue *vq = netq->netq_vq;
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	struct vioif_net_map *map;
 	struct mbuf *m;
 	int slot, len;
-	bool more = false;
+	bool more;
+	size_t ndeq;
 
 	KASSERT(mutex_owned(>netq_lock));
 
+	more = false;
+	ndeq = 0;
+
 	if (virtio_vq_is_enqueued(vsc, vq) == false)
-		return false;
+		goto done;
 
-	for (;;) {
+	for (;;ndeq++) {
 		if (limit-- == 0) {
 			more = true;
 			break;
@@ -2082,6 +2091,9 @@ vioif_tx_deq_locked(struct vioif_softc *
 		m_freem(m);
 	}
 
+done:
+	if (ndeqp != NULL)
+		*ndeqp = ndeq;
 	return more;
 }
 
@@ -2089,6 +2101,7 @@ static void
 vioif_tx_queue_clear(struct vioif_softc *sc, struct virtio_softc *vsc,
 struct vioif_netqueue *netq)
 {
+	struct vioif_tx_context *txc;
 	struct vioif_net_map *map;
 	struct mbuf *m;
 	unsigned int i, vq_num;
@@ -2096,9 +2109,11 @@ vioif_tx_queue_clear(struct vioif_softc 
 
 	mutex_enter(>netq_lock);
 
+	txc = netq->netq_ctx;
 	vq_num = netq->netq_vq->vq_num;
+
 	for (;;) {
-		more = vioif_tx_deq_locked(sc, vsc, netq, vq_num);
+		more = vioif_tx_deq_locked(sc, vsc, netq, vq_num, NULL);
 		if (more == false)
 			break;
 	}
@@ -2113,6 +2128,9 @@ vioif_tx_queue_clear(struct vioif_softc 
 		vioif_net_unload_mbuf(vsc, map);
 		m_freem(m);
 	}
+
+	txc->txc_no_free_slots = false;
+
 	mutex_exit(>netq_lock);
 }
 
@@ -2157,11 +2175,17 @@ vioif_tx_handle_locked(struct vioif_netq
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	bool more;
 	int enqueued;
+	size_t ndeq;
 
 	KASSERT(mutex_owned(>netq_lock));
 	KASSERT(!netq->netq_stopping);
 
-	more = vioif_tx_deq_locked(sc, vsc, netq, limit);
+	more = vioif_tx_deq_locked(sc, vsc, netq, limit, );
+	if (txc->txc_no_free_slots && ndeq > 0) {
+		txc->txc_no_free_slots = false;
+		softint_schedule(txc->txc_deferred_transmit);
+	}
+
 	if (more) {
 		vioif_net_sched_handle(sc, netq);
 		return;
@@ -2179,10 +2203,9 @@ vioif_tx_handle_locked(struct vioif_netq
 	netq->netq_running_handle = false;
 
 	/* for ALTQ */
-	if (netq == >sc_netqs[VIOIF_NETQ_TXQID(0)]) {
+	if (netq == >sc_netqs[VIOIF_NETQ_TXQID(0)])
 	

CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 03:02:17 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): divide IFF_OACTIVE into per-queue


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:57:54 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): reorganize functions

iThis change is move of function and rename,
and this is no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.100 src/sys/dev/pci/if_vioif.c:1.101
--- src/sys/dev/pci/if_vioif.c:1.100	Thu Mar 23 02:52:29 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 02:57:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.100 2023/03/23 02:52:29 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.101 2023/03/23 02:57:54 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.100 2023/03/23 02:52:29 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.101 2023/03/23 02:57:54 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -330,7 +330,7 @@ struct vioif_softc {
 	void			*sc_dmamem;
 	void			*sc_kmem;
 
-	void			*sc_ctl_softint;
+	void			*sc_cfg_softint;
 
 	struct workqueue	*sc_txrx_workqueue;
 	bool			 sc_txrx_workqueue_sysctl;
@@ -360,1171 +360,1213 @@ static int	vioif_finalize_teardown(devic
 static int	vioif_init(struct ifnet *);
 static void	vioif_stop(struct ifnet *, int);
 static void	vioif_start(struct ifnet *);
-static void	vioif_start_locked(struct ifnet *, struct vioif_netqueue *);
 static int	vioif_transmit(struct ifnet *, struct mbuf *);
-static void	vioif_transmit_locked(struct ifnet *, struct vioif_netqueue *);
 static int	vioif_ioctl(struct ifnet *, u_long, void *);
 static void	vioif_watchdog(struct ifnet *);
+static int	vioif_ifflags(struct vioif_softc *);
 static int	vioif_ifflags_cb(struct ethercom *);
 
 /* tx & rx */
-static void	vioif_net_sched_handle(struct vioif_softc *,
-		struct vioif_netqueue *);
-static int	vioif_net_load_mbuf(struct virtio_softc *,
-		struct vioif_net_map *, struct mbuf *, int);
-static void	vioif_net_unload_mbuf(struct virtio_softc *,
-		struct vioif_net_map *);
-static int	vioif_net_enqueue_tx(struct virtio_softc *, struct virtqueue *,
-		int, struct vioif_net_map *);
-static int	vioif_net_enqueue_rx(struct virtio_softc *, struct virtqueue *,
-		int, struct vioif_net_map *);
-static struct mbuf *
-		vioif_net_dequeue_commit(struct virtio_softc *,
-		struct virtqueue *, int, struct vioif_net_map *, int);
+static int	vioif_netqueue_init(struct vioif_softc *,
+		struct virtio_softc *, size_t, u_int);
+static void	vioif_netqueue_teardown(struct vioif_softc *,
+		struct virtio_softc *, size_t);
 static void	vioif_net_intr_enable(struct vioif_softc *,
 		struct virtio_softc *);
 static void	vioif_net_intr_disable(struct vioif_softc *,
 		struct virtio_softc *);
+static void	vioif_net_sched_handle(struct vioif_softc *,
+		struct vioif_netqueue *);
 
 /* rx */
 static void	vioif_populate_rx_mbufs_locked(struct vioif_softc *,
 		struct vioif_netqueue *);
-static void	vioif_rx_queue_clear(struct vioif_softc *, struct virtio_softc *,
-		struct vioif_netqueue *);
-static bool	vioif_rx_deq_locked(struct vioif_softc *, struct virtio_softc *,
-		struct vioif_netqueue *, u_int, size_t *);
 static int	vioif_rx_intr(void *);
 static void	vioif_rx_handle(void *);
+static void	vioif_rx_queue_clear(struct vioif_softc *,
+		struct virtio_softc *, struct vioif_netqueue *);
 
 /* tx */
+static void	vioif_start_locked(struct ifnet *, struct vioif_netqueue *);
+static void	vioif_transmit_locked(struct ifnet *, struct vioif_netqueue *);
+static void	vioif_deferred_transmit(void *);
 static int	vioif_tx_intr(void *);
 static void	vioif_tx_handle(void *);
 static void	vioif_tx_queue_clear(struct vioif_softc *, struct virtio_softc *,
 		struct vioif_netqueue *);
-static bool	vioif_tx_deq_locked(struct vioif_softc *, struct virtio_softc *,
-		struct vioif_netqueue *, u_int);
-static void	vioif_deferred_transmit(void *);
-
-/* workqueue */
-static struct workqueue*
-		vioif_workq_create(const char *, pri_t, int, int);
-static void	vioif_workq_destroy(struct workqueue *);
-static void	vioif_workq_work(struct work *, void *);
-static void	vioif_work_set(struct vioif_work *, void(*)(void *), void *);
-static void	vioif_work_add(struct workqueue *, struct vioif_work *);
-static void	vioif_work_wait(struct workqueue *, struct vioif_work *);
 
-/* other control */
-static int	vioif_get_link_status(struct vioif_softc *);
-static void	vioif_update_link_status(struct vioif_softc *);
+/* controls */
+static int	vioif_ctrl_intr(void *);
 static int	vioif_ctrl_rx(struct vioif_softc *, int, bool);
 static int	vioif_set_promisc(struct vioif_softc *, bool);
 static int	

CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:57:54 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): reorganize functions

iThis change is move of function and rename,
and this is no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:52:29 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): rename sc_hdr_segs to sc_segs


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:52:29 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): rename sc_hdr_segs to sc_segs


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.99 src/sys/dev/pci/if_vioif.c:1.100
--- src/sys/dev/pci/if_vioif.c:1.99	Thu Mar 23 02:48:29 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 02:52:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.99 2023/03/23 02:48:29 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.100 2023/03/23 02:52:29 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.99 2023/03/23 02:48:29 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.100 2023/03/23 02:52:29 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -326,7 +326,7 @@ struct vioif_softc {
 	bool			sc_has_ctrl;
 	struct vioif_ctrlqueue	sc_ctrlq;
 
-	bus_dma_segment_t	sc_hdr_segs[1];
+	bus_dma_segment_t	 sc_segs[1];
 	void			*sc_dmamem;
 	void			*sc_kmem;
 
@@ -752,14 +752,14 @@ vioif_alloc_mems(struct vioif_softc *sc)
 	}
 
 	r = bus_dmamem_alloc(virtio_dmat(vsc), dmamemsize, 0, 0,
-	>sc_hdr_segs[0], 1, , BUS_DMA_NOWAIT);
+	>sc_segs[0], 1, , BUS_DMA_NOWAIT);
 	if (r != 0) {
 		aprint_error_dev(sc->sc_dev,
 		"DMA memory allocation failed, size %zu, "
 		"error code %d\n", dmamemsize, r);
 		goto err_none;
 	}
-	r = bus_dmamem_map(virtio_dmat(vsc),>sc_hdr_segs[0], 1,
+	r = bus_dmamem_map(virtio_dmat(vsc), >sc_segs[0], 1,
 	dmamemsize, , BUS_DMA_NOWAIT);
 	if (r != 0) {
 		aprint_error_dev(sc->sc_dev,
@@ -953,7 +953,7 @@ err_reqs:
 	}
 	bus_dmamem_unmap(virtio_dmat(vsc), sc->sc_dmamem, dmamemsize);
 err_dmamem_alloc:
-	bus_dmamem_free(virtio_dmat(vsc), >sc_hdr_segs[0], 1);
+	bus_dmamem_free(virtio_dmat(vsc), >sc_segs[0], 1);
 err_none:
 	return -1;
 }



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:48:30 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): added functions to manipulate network queues


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:48:30 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): added functions to manipulate network queues


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.98 src/sys/dev/pci/if_vioif.c:1.99
--- src/sys/dev/pci/if_vioif.c:1.98	Thu Mar 23 02:42:49 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 02:48:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.98 2023/03/23 02:42:49 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.99 2023/03/23 02:48:29 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.98 2023/03/23 02:42:49 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.99 2023/03/23 02:48:29 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -259,7 +259,7 @@ struct vioif_netqueue {
 
 	char			 netq_evgroup[32];
 	struct evcnt		 netq_mbuf_load_failed;
-	struct evcnt		 netq_enqueue_reserve_failed;
+	struct evcnt		 netq_enqueue_failed;
 
 	void			*netq_ctx;
 };
@@ -370,6 +370,21 @@ static int	vioif_ifflags_cb(struct ether
 /* tx & rx */
 static void	vioif_net_sched_handle(struct vioif_softc *,
 		struct vioif_netqueue *);
+static int	vioif_net_load_mbuf(struct virtio_softc *,
+		struct vioif_net_map *, struct mbuf *, int);
+static void	vioif_net_unload_mbuf(struct virtio_softc *,
+		struct vioif_net_map *);
+static int	vioif_net_enqueue_tx(struct virtio_softc *, struct virtqueue *,
+		int, struct vioif_net_map *);
+static int	vioif_net_enqueue_rx(struct virtio_softc *, struct virtqueue *,
+		int, struct vioif_net_map *);
+static struct mbuf *
+		vioif_net_dequeue_commit(struct virtio_softc *,
+		struct virtqueue *, int, struct vioif_net_map *, int);
+static void	vioif_net_intr_enable(struct vioif_softc *,
+		struct virtio_softc *);
+static void	vioif_net_intr_disable(struct vioif_softc *,
+		struct virtio_softc *);
 
 /* rx */
 static void	vioif_populate_rx_mbufs_locked(struct vioif_softc *,
@@ -412,12 +427,11 @@ static int	vioif_ctrl_intr(void *);
 static int	vioif_config_change(struct virtio_softc *);
 static void	vioif_ctl_softint(void *);
 static int	vioif_ctrl_mq_vq_pairs_set(struct vioif_softc *, int);
-static void	vioif_enable_interrupt_vqpairs(struct vioif_softc *);
-static void	vioif_disable_interrupt_vqpairs(struct vioif_softc *);
 static int	vioif_setup_sysctl(struct vioif_softc *);
 static void	vioif_setup_stats(struct vioif_softc *);
 static int	vioif_ifflags(struct vioif_softc *);
 static void	vioif_intr_barrier(void);
+static void	vioif_notify(struct virtio_softc *, struct virtqueue *);
 
 CFATTACH_DECL_NEW(vioif, sizeof(struct vioif_softc),
 		  vioif_match, vioif_attach, NULL, NULL);
@@ -1180,34 +1194,6 @@ vioif_finalize_teardown(device_t self)
 	return 0;
 }
 
-static void
-vioif_enable_interrupt_vqpairs(struct vioif_softc *sc)
-{
-	struct virtio_softc *vsc = sc->sc_virtio;
-	struct vioif_netqueue *netq;
-	size_t i, netq_act_num;
-
-	netq_act_num = sc->sc_act_nvq_pairs * 2;
-	for (i = 0; i < netq_act_num; i++) {
-		netq = >sc_netqs[i];
-		virtio_start_vq_intr(vsc, netq->netq_vq);
-	}
-}
-
-static void
-vioif_disable_interrupt_vqpairs(struct vioif_softc *sc)
-{
-	struct virtio_softc *vsc = sc->sc_virtio;
-	struct vioif_netqueue *netq;
-	size_t i, netq_act_num;
-
-	netq_act_num = sc->sc_act_nvq_pairs * 2;
-	for (i = 0; i < netq_act_num; i++) {
-		netq = >sc_netqs[i];
-		virtio_stop_vq_intr(vsc, netq->netq_vq);
-	}
-}
-
 /*
  * Interface functions for ifnet
  */
@@ -1252,7 +1238,7 @@ vioif_init(struct ifnet *ifp)
 	SET(ifp->if_flags, IFF_RUNNING);
 	CLR(ifp->if_flags, IFF_OACTIVE);
 
-	vioif_enable_interrupt_vqpairs(sc);
+	vioif_net_intr_enable(sc, vsc);
 
 	vioif_update_link_status(sc);
 	r = vioif_rx_filter(sc);
@@ -1267,12 +1253,12 @@ vioif_stop(struct ifnet *ifp, int disabl
 	struct virtio_softc *vsc = sc->sc_virtio;
 	struct vioif_netqueue *netq;
 	struct vioif_ctrlqueue *ctrlq = >sc_ctrlq;
-	size_t i, netq_act_num;
+	size_t i, act_qnum;
 
-	netq_act_num = sc->sc_act_nvq_pairs * 2;
+	act_qnum = sc->sc_act_nvq_pairs * 2;
 
 	CLR(ifp->if_flags, IFF_RUNNING);
-	for (i = 0; i < netq_act_num; i++) {
+	for (i = 0; i < act_qnum; i++) {
 		netq = >sc_netqs[i];
 
 		mutex_enter(>netq_lock);
@@ -1281,7 +1267,7 @@ vioif_stop(struct ifnet *ifp, int disabl
 	}
 
 	/* disable interrupts */
-	vioif_disable_interrupt_vqpairs(sc);
+	vioif_net_intr_disable(sc, vsc);
 	if (sc->sc_has_ctrl)
 		virtio_stop_vq_intr(vsc, ctrlq->ctrlq_vq);
 
@@ -1295,7 +1281,7 @@ vioif_stop(struct ifnet *ifp, int disabl
 
 	vioif_intr_barrier();
 
-	for (i = 0; i < netq_act_num; i++) {
+	for (i = 0; i < act_qnum; i++) {
 		

CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:42:49 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): added new data structure for network queues

and moved the same parameters in vioif_txqueue and
vioif_rxqueue into the new structure


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.97 src/sys/dev/pci/if_vioif.c:1.98
--- src/sys/dev/pci/if_vioif.c:1.97	Thu Mar 23 02:33:34 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 02:42:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.97 2023/03/23 02:33:34 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.98 2023/03/23 02:42:49 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.97 2023/03/23 02:33:34 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.98 2023/03/23 02:42:49 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -205,12 +205,13 @@ struct virtio_net_ctrl_mq {
 
 /*
  * Locking notes:
- * + a field in vioif_txqueue is protected by txq_lock (a spin mutex), and
- *   a field in vioif_rxqueue is protected by rxq_lock (a spin mutex).
+ * + a field in vioif_netueue is protected by netq_lock (a spin mutex)
  *  - more than one lock cannot be held at onece
+ * + a field in vioif_tx_context and vioif_rx_context is also protected
+ *   by netq_lock.
  * + ctrlq_inuse is protected by ctrlq_wait_lock.
  *  - other fields in vioif_ctrlqueue are protected by ctrlq_inuse
- *  - txq_lock or rxq_lock cannot be held along with ctrlq_wait_lock
+ *  - netq_lock cannot be held along with ctrlq_wait_lock
  * + fields in vioif_softc except queues are protected by
  *   sc->sc_lock(an adaptive mutex)
  *  - the lock is held before acquisition of other locks
@@ -236,49 +237,44 @@ struct vioif_net_map {
 	bus_dmamap_t		 vnm_mbuf_map;
 };
 
-struct vioif_txqueue {
-	kmutex_t		*txq_lock;	/* lock for tx operations */
+#define VIOIF_NETQ_RX		0
+#define VIOIF_NETQ_TX		1
+#define VIOIF_NETQ_IDX		2
+#define VIOIF_NETQ_DIR(n)	((n) % VIOIF_NETQ_IDX)
+#define VIOIF_NETQ_PAIRIDX(n)	((n) / VIOIF_NETQ_IDX)
+#define VIOIF_NETQ_RXQID(n)	((n) * VIOIF_NETQ_IDX + VIOIF_NETQ_RX)
+#define VIOIF_NETQ_TXQID(n)	((n) * VIOIF_NETQ_IDX + VIOIF_NETQ_TX)
+
+struct vioif_netqueue {
+	kmutex_t		 netq_lock;
+	struct virtqueue	*netq_vq;
+	bool			 netq_stopping;
+	bool			 netq_running_handle;
+	void			*netq_maps_kva;
+	struct vioif_net_map	*netq_maps;
+
+	void			*netq_softint;
+	struct vioif_work	 netq_work;
+	bool			 netq_workqueue;
+
+	char			 netq_evgroup[32];
+	struct evcnt		 netq_mbuf_load_failed;
+	struct evcnt		 netq_enqueue_reserve_failed;
 
-	struct virtqueue	*txq_vq;
-	bool			txq_stopping;
-	bool			txq_link_active;
-	pcq_t			*txq_intrq;
-
-	void			*txq_maps_kva;
-	struct vioif_net_map	*txq_maps;
-
-	void			*txq_deferred_transmit;
-	void			*txq_handle_si;
-	struct vioif_work	 txq_work;
-	bool			 txq_workqueue;
-	bool			 txq_running_handle;
-
-	char			 txq_evgroup[16];
-	struct evcnt		 txq_defrag_failed;
-	struct evcnt		 txq_mbuf_load_failed;
-	struct evcnt		 txq_enqueue_reserve_failed;
+	void			*netq_ctx;
 };
 
-struct vioif_rxqueue {
-	kmutex_t		*rxq_lock;	/* lock for rx operations */
+struct vioif_tx_context {
+	bool			 txc_link_active;
+	pcq_t			*txc_intrq;
+	void			*txc_deferred_transmit;
 
-	struct virtqueue	*rxq_vq;
-	bool			rxq_stopping;
-
-	void			*rxq_maps_kva;
-	struct vioif_net_map	*rxq_maps;
-
-	void			*rxq_handle_si;
-	struct vioif_work	 rxq_work;
-	bool			 rxq_workqueue;
-	bool			 rxq_running_handle;
-
-	char			 rxq_evgroup[16];
-	struct evcnt		 rxq_mbuf_enobufs;
-	struct evcnt		 rxq_mbuf_load_failed;
-	struct evcnt		 rxq_enqueue_reserve_failed;
+	struct evcnt		 txc_defrag_failed;
 };
 
+struct vioif_rx_context {
+	struct evcnt		 rxc_mbuf_enobufs;
+};
 struct vioif_ctrlqueue {
 	struct virtqueue		*ctrlq_vq;
 	enum {
@@ -325,8 +321,7 @@ struct vioif_softc {
 	struct ethercom		sc_ethercom;
 	int			sc_link_state;
 
-	struct vioif_txqueue	*sc_txq;
-	struct vioif_rxqueue	*sc_rxq;
+	struct vioif_netqueue	*sc_netqs;
 
 	bool			sc_has_ctrl;
 	struct vioif_ctrlqueue	sc_ctrlq;
@@ -365,34 +360,34 @@ static int	vioif_finalize_teardown(devic
 static int	vioif_init(struct ifnet *);
 static void	vioif_stop(struct ifnet *, int);
 static void	vioif_start(struct ifnet *);
-static void	vioif_start_locked(struct ifnet *, struct vioif_txqueue *);
+static void	vioif_start_locked(struct ifnet *, struct vioif_netqueue *);
 static int	vioif_transmit(struct ifnet *, struct mbuf *);
-static void	vioif_transmit_locked(struct ifnet *, struct vioif_txqueue *);
+static void	vioif_transmit_locked(struct ifnet *, struct vioif_netqueue *);
 static int	

CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:42:49 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): added new data structure for network queues

and moved the same parameters in vioif_txqueue and
vioif_rxqueue into the new structure


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:33:34 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): added __predct_false to error check


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.96 src/sys/dev/pci/if_vioif.c:1.97
--- src/sys/dev/pci/if_vioif.c:1.96	Thu Mar 23 02:30:14 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 02:33:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.96 2023/03/23 02:30:14 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.97 2023/03/23 02:33:34 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.96 2023/03/23 02:30:14 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.97 2023/03/23 02:33:34 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1532,7 +1532,7 @@ vioif_populate_rx_mbufs_locked(struct vi
 		r = virtio_enqueue_prep(vsc, vq, );
 		if (r == EAGAIN)
 			break;
-		if (r != 0)
+		if (__predict_false(r != 0))
 			panic("enqueue_prep for rx buffers");
 
 		map = >rxq_maps[slot];



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:33:34 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): added __predct_false to error check


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:30:14 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): prepare slot before dequeuing


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.95 src/sys/dev/pci/if_vioif.c:1.96
--- src/sys/dev/pci/if_vioif.c:1.95	Thu Mar 23 02:26:43 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 02:30:14 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.95 2023/03/23 02:26:43 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.96 2023/03/23 02:30:14 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.95 2023/03/23 02:26:43 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.96 2023/03/23 02:30:14 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1307,24 +1307,21 @@ vioif_send_common_locked(struct ifnet *i
 
 	for (;;) {
 		int slot, r;
+		r = virtio_enqueue_prep(vsc, vq, );
+		if (r == EAGAIN)
+			break;
+		if (__predict_false(r != 0))
+			panic("enqueue_prep for tx buffers");
 
 		if (is_transmit)
 			m = pcq_get(txq->txq_intrq);
 		else
 			IFQ_DEQUEUE(>if_snd, m);
 
-		if (m == NULL)
-			break;
-
-		r = virtio_enqueue_prep(vsc, vq, );
-		if (r == EAGAIN) {
-			ifp->if_flags |= IFF_OACTIVE;
-			m_freem(m);
-			if_statinc(ifp, if_oerrors);
+		if (m == NULL) {
+			virtio_enqueue_abort(vsc, vq, slot);
 			break;
 		}
-		if (r != 0)
-			panic("enqueue_prep for a tx buffer");
 
 		map = >txq_maps[slot];
 		KASSERT(map->vnm_mbuf == NULL);



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:30:14 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): prepare slot before dequeuing


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:26:43 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): added a structure to manage variables for packet processings


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.94 src/sys/dev/pci/if_vioif.c:1.95
--- src/sys/dev/pci/if_vioif.c:1.94	Thu Mar 23 02:15:53 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 02:26:43 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.94 2023/03/23 02:15:53 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.95 2023/03/23 02:26:43 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.94 2023/03/23 02:15:53 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.95 2023/03/23 02:26:43 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -229,6 +229,13 @@ struct vioif_work {
 	unsigned int	 added;
 };
 
+struct vioif_net_map {
+	struct virtio_net_hdr	*vnm_hdr;
+	bus_dmamap_t		 vnm_hdr_map;
+	struct mbuf		*vnm_mbuf;
+	bus_dmamap_t		 vnm_mbuf_map;
+};
+
 struct vioif_txqueue {
 	kmutex_t		*txq_lock;	/* lock for tx operations */
 
@@ -237,11 +244,8 @@ struct vioif_txqueue {
 	bool			txq_link_active;
 	pcq_t			*txq_intrq;
 
-	struct virtio_net_hdr	*txq_hdrs;
-	bus_dmamap_t		*txq_hdr_dmamaps;
-
-	struct mbuf		**txq_mbufs;
-	bus_dmamap_t		*txq_dmamaps;
+	void			*txq_maps_kva;
+	struct vioif_net_map	*txq_maps;
 
 	void			*txq_deferred_transmit;
 	void			*txq_handle_si;
@@ -261,11 +265,8 @@ struct vioif_rxqueue {
 	struct virtqueue	*rxq_vq;
 	bool			rxq_stopping;
 
-	struct virtio_net_hdr	*rxq_hdrs;
-	bus_dmamap_t		*rxq_hdr_dmamaps;
-
-	struct mbuf		**rxq_mbufs;
-	bus_dmamap_t		*rxq_dmamaps;
+	void			*rxq_maps_kva;
+	struct vioif_net_map	*rxq_maps;
 
 	void			*rxq_handle_si;
 	struct vioif_work	 rxq_work;
@@ -552,8 +553,8 @@ vioif_free_queues(struct vioif_softc *sc
 /* allocate memory */
 /*
  * dma memory is used for:
- *   rxq_hdrs[slot]:	 metadata array for received frames (READ)
- *   txq_hdrs[slot]:	 metadata array for frames to be sent (WRITE)
+ *   rxq_maps_kva:	 metadata array for received frames (READ)
+ *   txq_maps_kva:	 metadata array for frames to be sent (WRITE)
  *   ctrlq_cmd:		 command to be sent via ctrl vq (WRITE)
  *   ctrlq_status:	 return value for a command via ctrl vq (READ)
  *   ctrlq_rx:		 parameter for a VIRTIO_NET_CTRL_RX class command
@@ -565,21 +566,13 @@ vioif_free_queues(struct vioif_softc *sc
  * ctrlq_* structures are allocated only one each; they are protected by
  * ctrlq_inuse variable and ctrlq_wait condvar.
  */
-/*
- * dynamically allocated memory is used for:
- *   rxq_hdr_dmamaps[slot]:	bus_dmamap_t array for sc_rx_hdrs[slot]
- *   txq_hdr_dmamaps[slot]:	bus_dmamap_t array for sc_tx_hdrs[slot]
- *   rxq_dmamaps[slot]:		bus_dmamap_t array for received payload
- *   txq_dmamaps[slot]:		bus_dmamap_t array for sent payload
- *   rxq_mbufs[slot]:		mbuf pointer array for received frames
- *   txq_mbufs[slot]:		mbuf pointer array for sent frames
- */
 static int
 vioif_alloc_mems(struct vioif_softc *sc)
 {
 	struct virtio_softc *vsc = sc->sc_virtio;
 	struct vioif_txqueue *txq;
 	struct vioif_rxqueue *rxq;
+	struct vioif_net_map *maps;
 	struct vioif_ctrlqueue *ctrlq = >sc_ctrlq;
 	int allocsize, allocsize2, r, rsegs, i, qid;
 	void *vaddr;
@@ -628,9 +621,9 @@ vioif_alloc_mems(struct vioif_softc *sc)
 		rxq = >sc_rxq[qid];
 		txq = >sc_txq[qid];
 
-		rxq->rxq_hdrs = vioif_assign_mem(,
+		rxq->rxq_maps_kva = vioif_assign_mem(,
 		sizeof(struct virtio_net_hdr) * rxq->rxq_vq->vq_num);
-		txq->txq_hdrs = vioif_assign_mem(,
+		txq->txq_maps_kva = vioif_assign_mem(,
 		sizeof(struct virtio_net_hdr) * txq->txq_vq->vq_num);
 	}
 	if (sc->sc_has_ctrl) {
@@ -657,16 +650,12 @@ vioif_alloc_mems(struct vioif_softc *sc)
 
 		rxq = >sc_rxq[qid];
 		txq = >sc_txq[qid];
+
 		rxqsize = rxq->rxq_vq->vq_num;
 		txqsize = txq->txq_vq->vq_num;
 
-		allocsize2 += sizeof(rxq->rxq_dmamaps[0]) * rxqsize;
-		allocsize2 += sizeof(rxq->rxq_hdr_dmamaps[0]) * rxqsize;
-		allocsize2 += sizeof(rxq->rxq_mbufs[0]) * rxqsize;
-
-		allocsize2 += sizeof(txq->txq_dmamaps[0]) * txqsize;
-		allocsize2 += sizeof(txq->txq_hdr_dmamaps[0]) * txqsize;
-		allocsize2 += sizeof(txq->txq_mbufs[0]) * txqsize;
+		allocsize2 += sizeof(rxq->rxq_maps[0]) * rxqsize;
+		allocsize2 += sizeof(txq->txq_maps[0]) * txqsize;
 	}
 	vaddr = kmem_zalloc(allocsize2, KM_SLEEP);
 	sc->sc_kmem = vaddr;
@@ -679,46 +668,48 @@ vioif_alloc_mems(struct vioif_softc *sc)
 		rxqsize = rxq->rxq_vq->vq_num;
 		txqsize = txq->txq_vq->vq_num;
 
-		rxq->rxq_hdr_dmamaps = vioif_assign_mem(,
-		sizeof(rxq->rxq_hdr_dmamaps[0]) * rxqsize);
-		

CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:26:43 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): added a structure to manage variables for packet processings


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:15:53 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): increase output error counter


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.93 src/sys/dev/pci/if_vioif.c:1.94
--- src/sys/dev/pci/if_vioif.c:1.93	Thu Mar 23 02:03:01 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 02:15:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.93 2023/03/23 02:03:01 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.94 2023/03/23 02:15:53 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.93 2023/03/23 02:03:01 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.94 2023/03/23 02:15:53 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1322,6 +1322,7 @@ vioif_send_common_locked(struct ifnet *i
 		if (r == EAGAIN) {
 			ifp->if_flags |= IFF_OACTIVE;
 			m_freem(m);
+			if_statinc(ifp, if_oerrors);
 			break;
 		}
 		if (r != 0)
@@ -1347,6 +1348,7 @@ vioif_send_common_locked(struct ifnet *i
 txq->txq_mbuf_load_failed.ev_count++;
 skip:
 m_freem(m);
+if_statinc(ifp, if_oerrors);
 virtio_enqueue_abort(vsc, vq, slot);
 continue;
 			}
@@ -1361,6 +1363,7 @@ skip:
 			 txq->txq_dmamaps[slot]);
 			/* slot already freed by virtio_enqueue_reserve */
 			m_freem(m);
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:15:53 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): increase output error counter


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:03:01 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): merge drain into clear of queue


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.92 src/sys/dev/pci/if_vioif.c:1.93
--- src/sys/dev/pci/if_vioif.c:1.92	Thu Mar 23 01:58:04 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 02:03:01 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.92 2023/03/23 01:58:04 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.93 2023/03/23 02:03:01 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.92 2023/03/23 01:58:04 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.93 2023/03/23 02:03:01 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -374,24 +374,24 @@ static int	vioif_ifflags_cb(struct ether
 /* rx */
 static void	vioif_populate_rx_mbufs_locked(struct vioif_softc *,
 		struct vioif_rxqueue *);
-static void	vioif_rx_queue_clear(struct vioif_rxqueue *);
+static void	vioif_rx_queue_clear(struct vioif_softc *, struct virtio_softc *,
+		struct vioif_rxqueue *);
 static bool	vioif_rx_deq_locked(struct vioif_softc *, struct virtio_softc *,
 		struct vioif_rxqueue *, u_int, size_t *);
 static int	vioif_rx_intr(void *);
 static void	vioif_rx_handle(void *);
 static void	vioif_rx_sched_handle(struct vioif_softc *,
 		struct vioif_rxqueue *);
-static void	vioif_rx_drain(struct vioif_rxqueue *);
 
 /* tx */
 static int	vioif_tx_intr(void *);
 static void	vioif_tx_handle(void *);
 static void	vioif_tx_sched_handle(struct vioif_softc *,
 		struct vioif_txqueue *);
-static void	vioif_tx_queue_clear(struct vioif_txqueue *);
+static void	vioif_tx_queue_clear(struct vioif_softc *, struct virtio_softc *,
+		struct vioif_txqueue *);
 static bool	vioif_tx_deq_locked(struct vioif_softc *, struct virtio_softc *,
 		struct vioif_txqueue *, u_int);
-static void	vioif_tx_drain(struct vioif_txqueue *);
 static void	vioif_deferred_transmit(void *);
 
 /* workqueue */
@@ -1262,8 +1262,8 @@ vioif_stop(struct ifnet *ifp, int disabl
 	}
 
 	for (i = 0; i < sc->sc_act_nvq_pairs; i++) {
-		vioif_rx_queue_clear(>sc_rxq[i]);
-		vioif_tx_queue_clear(>sc_txq[i]);
+		vioif_rx_queue_clear(sc, vsc, >sc_rxq[i]);
+		vioif_tx_queue_clear(sc, vsc, >sc_txq[i]);
 	}
 
 	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
@@ -1283,14 +1283,6 @@ vioif_stop(struct ifnet *ifp, int disabl
 		KASSERT(!txq->txq_running_handle);
 		mutex_exit(txq->txq_lock);
 	}
-
-	for (i = 0; i < sc->sc_act_nvq_pairs; i++) {
-		txq = >sc_txq[i];
-		rxq = >sc_rxq[i];
-
-		vioif_rx_drain(rxq);
-		vioif_tx_drain(txq);
-	}
 }
 
 static void
@@ -1505,11 +1497,19 @@ void
 vioif_watchdog(struct ifnet *ifp)
 {
 	struct vioif_softc *sc = ifp->if_softc;
+	struct vioif_txqueue *txq;
 	int i;
 
 	if (ifp->if_flags & IFF_RUNNING) {
 		for (i = 0; i < sc->sc_act_nvq_pairs; i++) {
-			vioif_tx_queue_clear(>sc_txq[i]);
+			txq = >sc_txq[i];
+
+			mutex_enter(txq->txq_lock);
+			if (!txq->txq_running_handle) {
+txq->txq_running_handle = true;
+vioif_tx_sched_handle(sc, txq);
+			}
+			mutex_exit(txq->txq_lock);
 		}
 	}
 }
@@ -1589,20 +1589,31 @@ vioif_populate_rx_mbufs_locked(struct vi
 }
 
 static void
-vioif_rx_queue_clear(struct vioif_rxqueue *rxq)
+vioif_rx_queue_clear(struct vioif_softc *sc, struct virtio_softc *vsc,
+struct vioif_rxqueue *rxq)
 {
-	struct virtqueue *vq = rxq->rxq_vq;
-	struct virtio_softc *vsc = vq->vq_owner;
-	struct vioif_softc *sc = device_private(virtio_child(vsc));
-	u_int limit = UINT_MAX;
+	struct mbuf *m;
+	unsigned int i, vq_num;
 	bool more;
 
 	mutex_enter(rxq->rxq_lock);
+	vq_num = rxq->rxq_vq->vq_num;
+
 	for (;;) {
-		more = vioif_rx_deq_locked(sc, vsc, rxq, limit, NULL);
+		more = vioif_rx_deq_locked(sc, vsc, rxq, vq_num, NULL);
 		if (more == false)
 			break;
 	}
+
+	for (i = 0; i < vq_num; i++) {
+		m = rxq->rxq_mbufs[i];
+		if (m == NULL)
+			continue;
+		rxq->rxq_mbufs[i] = NULL;
+
+		bus_dmamap_unload(virtio_dmat(vsc), rxq->rxq_dmamaps[i]);
+		m_freem(m);
+	}
 	mutex_exit(rxq->rxq_lock);
 }
 
@@ -1764,25 +1775,6 @@ vioif_rx_sched_handle(struct vioif_softc
 		softint_schedule(rxq->rxq_handle_si);
 }
 
-/* free all the mbufs; called from if_stop(disable) */
-static void
-vioif_rx_drain(struct vioif_rxqueue *rxq)
-{
-	struct virtqueue *vq = rxq->rxq_vq;
-	struct virtio_softc *vsc = vq->vq_owner;
-	struct mbuf *m;
-	int i;
-
-	for (i = 0; i < vq->vq_num; i++) {
-		m = rxq->rxq_mbufs[i];
-		if (m == NULL)
-			continue;
-		rxq->rxq_mbufs[i] = NULL;
-		bus_dmamap_unload(virtio_dmat(vsc), rxq->rxq_dmamaps[i]);
-		m_freem(m);
-	}
-}
-
 /*
  * 

CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 02:03:01 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): merge drain into clear of queue


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 01:58:04 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): divide interrupt handler for receiving
into dequeuing and preparing of buffers


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.91 src/sys/dev/pci/if_vioif.c:1.92
--- src/sys/dev/pci/if_vioif.c:1.91	Thu Mar 23 01:52:42 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 01:58:04 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.91 2023/03/23 01:52:42 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.92 2023/03/23 01:58:04 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.91 2023/03/23 01:52:42 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.92 2023/03/23 01:58:04 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -376,7 +376,7 @@ static void	vioif_populate_rx_mbufs_lock
 		struct vioif_rxqueue *);
 static void	vioif_rx_queue_clear(struct vioif_rxqueue *);
 static bool	vioif_rx_deq_locked(struct vioif_softc *, struct virtio_softc *,
-		struct vioif_rxqueue *, u_int);
+		struct vioif_rxqueue *, u_int, size_t *);
 static int	vioif_rx_intr(void *);
 static void	vioif_rx_handle(void *);
 static void	vioif_rx_sched_handle(struct vioif_softc *,
@@ -1528,9 +1528,6 @@ vioif_populate_rx_mbufs_locked(struct vi
 
 	KASSERT(mutex_owned(rxq->rxq_lock));
 
-	if (rxq->rxq_stopping)
-		return;
-
 	for (i = 0; i < vq->vq_num; i++) {
 		int slot;
 		r = virtio_enqueue_prep(vsc, vq, );
@@ -1600,11 +1597,9 @@ vioif_rx_queue_clear(struct vioif_rxqueu
 	u_int limit = UINT_MAX;
 	bool more;
 
-	KASSERT(rxq->rxq_stopping);
-
 	mutex_enter(rxq->rxq_lock);
 	for (;;) {
-		more = vioif_rx_deq_locked(sc, vsc, rxq, limit);
+		more = vioif_rx_deq_locked(sc, vsc, rxq, limit, NULL);
 		if (more == false)
 			break;
 	}
@@ -1614,21 +1609,25 @@ vioif_rx_queue_clear(struct vioif_rxqueu
 /* dequeue received packets */
 static bool
 vioif_rx_deq_locked(struct vioif_softc *sc, struct virtio_softc *vsc,
-struct vioif_rxqueue *rxq, u_int limit)
+struct vioif_rxqueue *rxq, u_int limit, size_t *ndeqp)
 {
 	struct virtqueue *vq = rxq->rxq_vq;
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	struct mbuf *m;
 	int slot, len;
-	bool more = false, dequeued = false;
+	bool more;
+	size_t ndeq;
 
 	KASSERT(mutex_owned(rxq->rxq_lock));
 
+	more = false;
+	ndeq = 0;
+
 	if (virtio_vq_is_enqueued(vsc, vq) == false)
-		return false;
+		goto done;
 
-	for (;;) {
-		if (limit-- == 0) {
+	for (;;ndeq++) {
+		if (ndeq >= limit) {
 			more = true;
 			break;
 		}
@@ -1636,8 +1635,6 @@ vioif_rx_deq_locked(struct vioif_softc *
 		if (virtio_dequeue(vsc, vq, , ) != 0)
 			break;
 
-		dequeued = true;
-
 		len -= sc->sc_hdr_size;
 		bus_dmamap_sync(virtio_dmat(vsc), rxq->rxq_hdr_dmamaps[slot],
 		0, sc->sc_hdr_size, BUS_DMASYNC_POSTREAD);
@@ -1654,8 +1651,10 @@ vioif_rx_deq_locked(struct vioif_softc *
 		if_percpuq_enqueue(ifp->if_percpuq, m);
 	}
 
-	if (dequeued)
-		vioif_populate_rx_mbufs_locked(sc, rxq);
+
+done:
+	if (ndeqp != NULL)
+		*ndeqp = ndeq;
 
 	return more;
 }
@@ -1671,11 +1670,15 @@ vioif_rx_handle_locked(void *xrxq, u_int
 	struct vioif_softc *sc = device_private(virtio_child(vsc));
 	bool more;
 	int enqueued;
+	size_t ndeq;
 
 	KASSERT(mutex_owned(rxq->rxq_lock));
 	KASSERT(!rxq->rxq_stopping);
 
-	more = vioif_rx_deq_locked(sc, vsc, rxq, limit);
+	more = vioif_rx_deq_locked(sc, vsc, rxq, limit, );
+	if (ndeq > 0)
+		vioif_populate_rx_mbufs_locked(sc, rxq);
+
 	if (more) {
 		vioif_rx_sched_handle(sc, rxq);
 		return;



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 01:58:04 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): divide interrupt handler for receiving
into dequeuing and preparing of buffers


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/pci/if_vioif.c

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



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 01:52:42 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): drain receive buffer on stopping the device
to remove branch in vioif_populate_rx_mbufs_locked()


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.90 src/sys/dev/pci/if_vioif.c:1.91
--- src/sys/dev/pci/if_vioif.c:1.90	Thu Mar 23 01:46:30 2023
+++ src/sys/dev/pci/if_vioif.c	Thu Mar 23 01:52:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.90 2023/03/23 01:46:30 yamaguchi Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.91 2023/03/23 01:52:42 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.90 2023/03/23 01:46:30 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.91 2023/03/23 01:52:42 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1288,9 +1288,7 @@ vioif_stop(struct ifnet *ifp, int disabl
 		txq = >sc_txq[i];
 		rxq = >sc_rxq[i];
 
-		if (disable)
-			vioif_rx_drain(rxq);
-
+		vioif_rx_drain(rxq);
 		vioif_tx_drain(txq);
 	}
 }
@@ -1541,36 +1539,31 @@ vioif_populate_rx_mbufs_locked(struct vi
 		if (r != 0)
 			panic("enqueue_prep for rx buffers");
 
-		m = rxq->rxq_mbufs[slot];
+		MGETHDR(m, M_DONTWAIT, MT_DATA);
 		if (m == NULL) {
-			MGETHDR(m, M_DONTWAIT, MT_DATA);
-			if (m == NULL) {
-virtio_enqueue_abort(vsc, vq, slot);
-rxq->rxq_mbuf_enobufs.ev_count++;
-break;
-			}
-			MCLGET(m, M_DONTWAIT);
-			if ((m->m_flags & M_EXT) == 0) {
-virtio_enqueue_abort(vsc, vq, slot);
-m_freem(m);
-rxq->rxq_mbuf_enobufs.ev_count++;
-break;
-			}
+			virtio_enqueue_abort(vsc, vq, slot);
+			rxq->rxq_mbuf_enobufs.ev_count++;
+			break;
+		}
+		MCLGET(m, M_DONTWAIT);
+		if ((m->m_flags & M_EXT) == 0) {
+			virtio_enqueue_abort(vsc, vq, slot);
+			m_freem(m);
+			rxq->rxq_mbuf_enobufs.ev_count++;
+			break;
+		}
 
-			m->m_len = m->m_pkthdr.len = MCLBYTES;
-			m_adj(m, ETHER_ALIGN);
+		m->m_len = m->m_pkthdr.len = MCLBYTES;
+		m_adj(m, ETHER_ALIGN);
 
-			r = bus_dmamap_load_mbuf(virtio_dmat(vsc),
-			rxq->rxq_dmamaps[slot], m, BUS_DMA_READ | BUS_DMA_NOWAIT);
+		r = bus_dmamap_load_mbuf(virtio_dmat(vsc),
+		rxq->rxq_dmamaps[slot], m, BUS_DMA_READ | BUS_DMA_NOWAIT);
 
-			if (r != 0) {
-virtio_enqueue_abort(vsc, vq, slot);
-m_freem(m);
-rxq->rxq_mbuf_load_failed.ev_count++;
-break;
-			}
-		} else {
-			rxq->rxq_mbufs[slot] = NULL;
+		if (r != 0) {
+			virtio_enqueue_abort(vsc, vq, slot);
+			m_freem(m);
+			rxq->rxq_mbuf_load_failed.ev_count++;
+			break;
 		}
 
 		r = virtio_enqueue_reserve(vsc, vq, slot,
@@ -1582,6 +1575,7 @@ vioif_populate_rx_mbufs_locked(struct vi
 			/* slot already freed by virtio_enqueue_reserve */
 			break;
 		}
+		KASSERT(rxq->rxq_mbufs[slot] == NULL);
 		rxq->rxq_mbufs[slot] = m;
 		bus_dmamap_sync(virtio_dmat(vsc), rxq->rxq_hdr_dmamaps[slot],
 		0, sc->sc_hdr_size, BUS_DMASYNC_PREREAD);



CVS commit: src/sys/dev/pci

2023-03-22 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 23 01:52:42 UTC 2023

Modified Files:
src/sys/dev/pci: if_vioif.c

Log Message:
vioif(4): drain receive buffer on stopping the device
to remove branch in vioif_populate_rx_mbufs_locked()


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/pci/if_vioif.c

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



  1   2   3   4   5   6   7   8   9   10   >