CVS commit: src/sys/dev/usb

2021-10-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 11 06:30:24 UTC 2021

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
Add missing inclusion of sys/bitops.h.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/dev/usb/uhub.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/usb/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.156 src/sys/dev/usb/uhub.c:1.157
--- src/sys/dev/usb/uhub.c:1.156	Mon Oct 11 00:16:08 2021
+++ src/sys/dev/usb/uhub.c	Mon Oct 11 06:30:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.156 2021/10/11 00:16:08 jmcneill Exp $	*/
+/*	$NetBSD: uhub.c,v 1.157 2021/10/11 06:30:23 msaitoh Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 /*	$OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.156 2021/10/11 00:16:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.157 2021/10/11 06:30:23 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.1
 
 #include 
 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/dev/usb

2021-10-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 11 06:30:24 UTC 2021

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
Add missing inclusion of sys/bitops.h.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/dev/usb/uhub.c

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



CVS commit: src/sys

2021-10-10 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Oct 11 05:13:11 UTC 2021

Modified Files:
src/sys/dev/pci: xmm7360.c
src/sys/net: if_ethersubr.c if_gif.c if_ipsec.c if_pppoe.c
if_spppsubr.c pktqueue.c pktqueue.h
src/sys/rump/librump/rumpnet: Makefile.rumpnet

Log Message:
Make pktq_rps_hash() pluggable for each interface type.  Reviewed by gdt@n.o, 
thorpej@n.o, and riastradh@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/xmm7360.c
cvs rdiff -u -r1.300 -r1.301 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.155 -r1.156 src/sys/net/if_gif.c
cvs rdiff -u -r1.30 -r1.31 src/sys/net/if_ipsec.c
cvs rdiff -u -r1.177 -r1.178 src/sys/net/if_pppoe.c
cvs rdiff -u -r1.258 -r1.259 src/sys/net/if_spppsubr.c
cvs rdiff -u -r1.13 -r1.14 src/sys/net/pktqueue.c
cvs rdiff -u -r1.4 -r1.5 src/sys/net/pktqueue.h
cvs rdiff -u -r1.23 -r1.24 src/sys/rump/librump/rumpnet/Makefile.rumpnet

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/xmm7360.c
diff -u src/sys/dev/pci/xmm7360.c:1.11 src/sys/dev/pci/xmm7360.c:1.12
--- src/sys/dev/pci/xmm7360.c:1.11	Mon Oct 11 01:07:36 2021
+++ src/sys/dev/pci/xmm7360.c	Mon Oct 11 05:13:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xmm7360.c,v 1.11 2021/10/11 01:07:36 thorpej Exp $	*/
+/*	$NetBSD: xmm7360.c,v 1.12 2021/10/11 05:13:10 knakahara Exp $	*/
 
 /*
  * Device driver for Intel XMM7360 LTE modems, eg. Fibocom L850-GL.
@@ -75,7 +75,7 @@ MODULE_DEVICE_TABLE(pci, xmm7360_ids);
 #include "opt_gateway.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.11 2021/10/11 01:07:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.12 2021/10/11 05:13:10 knakahara Exp $");
 #endif
 
 #include 
@@ -3110,11 +3110,7 @@ wwan_if_input(struct ifnet *ifp, struct 
 	/* No errors.  Receive the packet. */
 	m_set_rcvif(m, ifp);
 
-#ifdef NET_MPSAFE
-	const u_int h = curcpu()->ci_index;
-#else
-	const uint32_t h = pktq_rps_hash(m);
-#endif
+	const uint32_t h = pktq_rps_hash(&pktq_rps_hash_default, m);
 	if (__predict_false(!pktq_enqueue(pktq, m, h))) {
 		m_freem(m);
 	}

Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.300 src/sys/net/if_ethersubr.c:1.301
--- src/sys/net/if_ethersubr.c:1.300	Thu Sep 30 04:29:16 2021
+++ src/sys/net/if_ethersubr.c	Mon Oct 11 05:13:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.300 2021/09/30 04:29:16 yamaguchi Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.301 2021/10/11 05:13:11 knakahara Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.300 2021/09/30 04:29:16 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.301 2021/10/11 05:13:11 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -183,6 +183,8 @@ const uint8_t ethermulticastaddr_slowpro
 { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x02 };
 #define senderr(e) { error = (e); goto bad;}
 
+static pktq_rps_hash_func_t ether_pktq_rps_hash_p;
+
 /* if_lagg(4) support */
 struct mbuf *(*lagg_input_ethernet_p)(struct ifnet *, struct mbuf *);
 
@@ -955,11 +957,7 @@ ether_input(struct ifnet *ifp, struct mb
 	}
 
 	if (__predict_true(pktq)) {
-#ifdef NET_MPSAFE
-		const u_int h = curcpu()->ci_index;
-#else
-		const uint32_t h = pktq_rps_hash(m);
-#endif
+		const uint32_t h = pktq_rps_hash(ðer_pktq_rps_hash_p, m);
 		if (__predict_false(!pktq_enqueue(pktq, m, h))) {
 			m_freem(m);
 		}
@@ -1766,6 +1764,14 @@ ether_sysctl_setup(struct sysctllog **cl
 		   SYSCTL_DESCR("multicast addresses"),
 		   ether_multicast_sysctl, 0, NULL, 0,
 		   CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(clog, 0, &rnode, NULL,
+		   CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+		   CTLTYPE_STRING, "rps_hash",
+		   SYSCTL_DESCR("Interface rps hash function control"),
+		   sysctl_pktq_rps_hash_handler, 0, (void *)ðer_pktq_rps_hash_p,
+		   PKTQ_RPS_HASH_NAME_LEN,
+		   CTL_CREATE, CTL_EOL);
 }
 
 void
@@ -1775,5 +1781,6 @@ etherinit(void)
 #ifdef DIAGNOSTIC
 	mutex_init(&bigpktpps_lock, MUTEX_DEFAULT, IPL_NET);
 #endif
+	ether_pktq_rps_hash_p = pktq_rps_hash_default;
 	ether_sysctl_setup(NULL);
 }

Index: src/sys/net/if_gif.c
diff -u src/sys/net/if_gif.c:1.155 src/sys/net/if_gif.c:1.156
--- src/sys/net/if_gif.c:1.155	Wed Jun 16 00:21:19 2021
+++ src/sys/net/if_gif.c	Mon Oct 11 05:13:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gif.c,v 1.155 2021/06/16 00:21:19 riastradh Exp $	*/
+/*	$NetBSD: if_gif.c,v 1.156 2021/10/11 05:13:11 knakahara Exp $	*/
 /*	$KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.155 2021/06/16 00:21:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.156 2021/10/11 05:13:11 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -105,6 +105,8 @@ sta

CVS commit: src/sys

2021-10-10 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Oct 11 05:13:11 UTC 2021

Modified Files:
src/sys/dev/pci: xmm7360.c
src/sys/net: if_ethersubr.c if_gif.c if_ipsec.c if_pppoe.c
if_spppsubr.c pktqueue.c pktqueue.h
src/sys/rump/librump/rumpnet: Makefile.rumpnet

Log Message:
Make pktq_rps_hash() pluggable for each interface type.  Reviewed by gdt@n.o, 
thorpej@n.o, and riastradh@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/xmm7360.c
cvs rdiff -u -r1.300 -r1.301 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.155 -r1.156 src/sys/net/if_gif.c
cvs rdiff -u -r1.30 -r1.31 src/sys/net/if_ipsec.c
cvs rdiff -u -r1.177 -r1.178 src/sys/net/if_pppoe.c
cvs rdiff -u -r1.258 -r1.259 src/sys/net/if_spppsubr.c
cvs rdiff -u -r1.13 -r1.14 src/sys/net/pktqueue.c
cvs rdiff -u -r1.4 -r1.5 src/sys/net/pktqueue.h
cvs rdiff -u -r1.23 -r1.24 src/sys/rump/librump/rumpnet/Makefile.rumpnet

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



CVS commit: src/sys/conf

2021-10-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 11 03:50:45 UTC 2021

Modified Files:
src/sys/conf: files

Log Message:
defparam NMBCLUSTERS_MAX.


To generate a diff of this commit:
cvs rdiff -u -r1.1287 -r1.1288 src/sys/conf/files

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



CVS commit: src/sys/conf

2021-10-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 11 03:50:45 UTC 2021

Modified Files:
src/sys/conf: files

Log Message:
defparam NMBCLUSTERS_MAX.


To generate a diff of this commit:
cvs rdiff -u -r1.1287 -r1.1288 src/sys/conf/files

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

Modified files:

Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1287 src/sys/conf/files:1.1288
--- src/sys/conf/files:1.1287	Wed Jul 21 23:16:09 2021
+++ src/sys/conf/files	Mon Oct 11 03:50:45 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.1287 2021/07/21 23:16:09 jmcneill Exp $
+#	$NetBSD: files,v 1.1288 2021/10/11 03:50:45 msaitoh Exp $
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
 version 	20171118
@@ -301,6 +301,7 @@ defparam opt_sppp.h		SPPP_KEEPALIVE_INTE
 #
 defflagGATEWAY
 defparam opt_nmbclusters.h	NMBCLUSTERS
+	 			NMBCLUSTERS_MAX
 defparam			SB_MAX
 
 # file system options



CVS commit: src/share/man/man4

2021-10-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct 11 03:00:18 UTC 2021

Modified Files:
src/share/man/man4: ep.4

Log Message:
Add description for 3c572B aka OfficeConnect 572B.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/share/man/man4/ep.4

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

Modified files:

Index: src/share/man/man4/ep.4
diff -u src/share/man/man4/ep.4:1.37 src/share/man/man4/ep.4:1.38
--- src/share/man/man4/ep.4:1.37	Wed May 29 15:03:09 2013
+++ src/share/man/man4/ep.4	Mon Oct 11 03:00:18 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ep.4,v 1.37 2013/05/29 15:03:09 wiz Exp $
+.\"	$NetBSD: ep.4,v 1.38 2021/10/11 03:00:18 rin Exp $
 .\"
 .\" Copyright (c) 1997 Jonathan Stone
 .\" All rights reserved.
@@ -32,7 +32,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 30, 2007
+.Dd October 11, 2021
 .Dt EP 4
 .Os
 .Sh NAME
@@ -137,6 +137,9 @@ MCA 10Mbps card, in UTP+AUI and BNC+AUI 
 PCMCIA 56K modem-10/100Mbps Ethernet combo card with dongle
 .It 3c562
 PCMCIA modem-10Mbps Ethernet combo card with dongle
+.It 3c572B
+OfficeConnect. Same as 3c574, but with newer revision of
+.Xr tqphy 4
 .It 3c574
 PCMCIA 10/100Mbps card with dongle
 .It 3c579



CVS commit: src/share/man/man4

2021-10-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct 11 03:00:18 UTC 2021

Modified Files:
src/share/man/man4: ep.4

Log Message:
Add description for 3c572B aka OfficeConnect 572B.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/share/man/man4/ep.4

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

2021-10-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct 11 02:42:46 UTC 2021

Modified Files:
src/sys/dev/ic: elink3.c

Log Message:
epget: Tiny clean up for 16-bit buses.

- (offset & 1) must be zero, since IP header is aligned.

- Use bus_space_read_1(9) instead of bus_space_read_multi_1(9) for
  single-byte read.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/dev/ic/elink3.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/ic/elink3.c
diff -u src/sys/dev/ic/elink3.c:1.152 src/sys/dev/ic/elink3.c:1.153
--- src/sys/dev/ic/elink3.c:1.152	Fri Feb  7 01:19:46 2020
+++ src/sys/dev/ic/elink3.c	Mon Oct 11 02:42:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: elink3.c,v 1.152 2020/02/07 01:19:46 thorpej Exp $	*/
+/*	$NetBSD: elink3.c,v 1.153 2021/10/11 02:42:46 rin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: elink3.c,v 1.152 2020/02/07 01:19:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: elink3.c,v 1.153 2021/10/11 02:42:46 rin Exp $");
 
 #include "opt_inet.h"
 
@@ -1638,12 +1638,7 @@ epget(struct ep_softc *sc, int totlen)
 			rxreg, (u_int8_t *) offset, remaining);
 		}
 	} else {
-		if ((remaining > 1) && (offset & 1)) {
-			bus_space_read_multi_1(iot, ioh,
-			rxreg, (u_int8_t *) offset, 1);
-			remaining -= 1;
-			offset += 1;
-		}
+		/* (offset & 1) == 0 since IP header is aligned */
 		if (remaining > 1) {
 			bus_space_read_multi_stream_2(iot, ioh,
 			rxreg, (u_int16_t *) offset,
@@ -1651,8 +1646,8 @@ epget(struct ep_softc *sc, int totlen)
 			offset += remaining & ~1;
 		}
 		if (remaining & 1) {
-bus_space_read_multi_1(iot, ioh,
-			rxreg, (u_int8_t *) offset, remaining & 1);
+			*(uint8_t *)offset =
+			bus_space_read_1(iot, ioh, rxreg);
 		}
 	}
 



CVS commit: src/sys/dev/ic

2021-10-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct 11 02:42:46 UTC 2021

Modified Files:
src/sys/dev/ic: elink3.c

Log Message:
epget: Tiny clean up for 16-bit buses.

- (offset & 1) must be zero, since IP header is aligned.

- Use bus_space_read_1(9) instead of bus_space_read_multi_1(9) for
  single-byte read.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/dev/ic/elink3.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/hpcsh/conf

2021-10-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct 11 02:35:18 UTC 2021

Modified Files:
src/sys/arch/hpcsh/conf: GENERIC

Log Message:
Add commented-out ep(4) at pcmcia(4); it works just fine now.

Also add commented-out tqphy(4) for some ep(4) models.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/arch/hpcsh/conf/GENERIC

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



CVS commit: src/sys/arch/hpcsh/conf

2021-10-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct 11 02:35:18 UTC 2021

Modified Files:
src/sys/arch/hpcsh/conf: GENERIC

Log Message:
Add commented-out ep(4) at pcmcia(4); it works just fine now.

Also add commented-out tqphy(4) for some ep(4) models.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/arch/hpcsh/conf/GENERIC

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/hpcsh/conf/GENERIC
diff -u src/sys/arch/hpcsh/conf/GENERIC:1.113 src/sys/arch/hpcsh/conf/GENERIC:1.114
--- src/sys/arch/hpcsh/conf/GENERIC:1.113	Wed Mar 25 17:06:19 2020
+++ src/sys/arch/hpcsh/conf/GENERIC	Mon Oct 11 02:35:18 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.113 2020/03/25 17:06:19 jdolecek Exp $
+# $NetBSD: GENERIC,v 1.114 2021/10/11 02:35:18 rin Exp $
 #
 # GENERIC machine description file
 #
@@ -291,6 +291,7 @@ atabus1 at wdc1 channel ?		# PC Card slo
 wd*	at atabus? drive ? flags 0x
 
 # PCMCIA network interfaces
+#ep*	at pcmcia0 function ?		# 3Com EtherLink III Ethernet
 mbe*	at pcmcia0 function ?		# MB8696x based Ethernet
 ne*	at pcmcia0 function ?		# NE2000-compatible Ethernet
 wi*	at pcmcia0 function ?		# Lucent/Intersil WaveLan IEEE (802.11)
@@ -298,6 +299,7 @@ wi*	at pcmcia0 function ?		# Lucent/Inte
 # MII/PHY support
 lxtphy*	at mii? phy ?			# Level One LXT-970 PHYs
 nsphyter* at mii? phy ?			# NS83843 PHYs
+#tqphy* at mii? phy?			# TDK Semiconductor PHYs
 ukphy*	at mii? phy ?			# generic unknown PHYs
 
 # PCMCIA Serial Devices



CVS commit: src/sys/arch/hpcsh/dev/hd64461

2021-10-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct 11 02:30:01 UTC 2021

Modified Files:
src/sys/arch/hpcsh/dev/hd64461: hd64461pcmcia.c

Log Message:
Fix workaround for SH-3 PCMCIA bug in accordance with description
found in TECH I vol. 14 (CQ Publishing, Tokyo, 2002, in Japanese),
as well as experiment on real hardware:

Byte-access to area 6 becomes word-access (both CE1# and CE2# are
wrongly asserted), if preceding access is word-wise. Inserting a
dummy byte-access works around the problem. Area 5 is not affected.

Therefore,

(1) Insert a dummy byte-read before all byte-wise operations.

(2) Restrict the workaround to area 6 (channel 0), and rename
fixup_sh3_pcmcia_area() to fixup_sh3_pcmcia_area6() for clarity.

Also, we used to use 0xba00 (== HD64461_PCC0_IOBASE) as target
for the dummy read. However, this can modify device states, which
breaks ep(4) at least. Thus,

(3) Use HD64461_PCC0_MEMBASE as target for the dummy read. This is
assigned to attribute memory space, and byte-read should be
harmless.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.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/hpcsh/dev/hd64461/hd64461pcmcia.c
diff -u src/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c:1.54 src/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c:1.55
--- src/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c:1.54	Sat Aug  7 16:18:54 2021
+++ src/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c	Mon Oct 11 02:30:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hd64461pcmcia.c,v 1.54 2021/08/07 16:18:54 thorpej Exp $	*/
+/*	$NetBSD: hd64461pcmcia.c,v 1.55 2021/10/11 02:30:00 rin Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hd64461pcmcia.c,v 1.54 2021/08/07 16:18:54 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hd64461pcmcia.c,v 1.55 2021/10/11 02:30:00 rin Exp $");
 
 #include "opt_hd64461pcmcia.h"
 
@@ -223,17 +223,37 @@ STATIC void hd64461_set_bus_width(enum c
 #ifdef HD64461PCMCIA_DEBUG
 STATIC void hd64461pcmcia_info(struct hd64461pcmcia_softc *);
 #endif
-/* fix SH3 Area[56] bug */
-STATIC void fixup_sh3_pcmcia_area(bus_space_tag_t);
+
+/*
+ * Workaround for SH-3 PCMCIA bug on area 6:
+ *
+ * According to TECH I vol. 14 (CQ Publishing, Tokyo, 2002) p. 184,
+ * byte-access to area 6 becomes word-access if preceding access is
+ * word-wise. Inserting a dummy byte-access works around the problem.
+ * Area 5 is not affected by this bug.
+ *
+ * Therefore, we insert a dummy byte-wise read to HD64461_PCC0_MEMBASE
+ * before any byte-access to area 6 (channel 0).
+ *
+ * Note that we used to use HD64461_PCC0_IOBASE for this purpose. But,
+ * read access to that register can modify device states, which breaks
+ * ep(4) at least. On the other hand, since HD64461_PCC0_MEMBASE is
+ * assigned to attribute memory, read access should be harmless.
+ */
+STATIC void fixup_sh3_pcmcia_area6(bus_space_tag_t);
 #define	_BUS_SPACE_ACCESS_HOOK()	\
-do {	\
-	uint8_t dummy __attribute__((__unused__)) =			\
-	 *(volatile uint8_t *)0xba00;\
-} while (/*CONSTCOND*/0)
+do {\
+	uint8_t dummy __unused =	\
+	*(volatile uint8_t *)HD64461_PCC0_MEMBASE;			\
+} while (0)
+_BUS_SPACE_READ(_sh3_pcmcia_bug, 1, 8)
+_BUS_SPACE_READ_MULTI(_sh3_pcmcia_bug, 1, 8)
+_BUS_SPACE_READ_REGION(_sh3_pcmcia_bug, 1, 8)
 _BUS_SPACE_WRITE(_sh3_pcmcia_bug, 1, 8)
 _BUS_SPACE_WRITE_MULTI(_sh3_pcmcia_bug, 1, 8)
 _BUS_SPACE_WRITE_REGION(_sh3_pcmcia_bug, 1, 8)
 _BUS_SPACE_SET_MULTI(_sh3_pcmcia_bug, 1, 8)
+_BUS_SPACE_COPY_REGION(_sh3_pcmcia_bug, 1, 8)
 #undef _BUS_SPACE_ACCESS_HOOK
 
 #define	DELAY_MS(x)	delay((x) * 1000)
@@ -386,7 +406,8 @@ hd64461pcmcia_attach_channel(struct hd64
 	bus_space_alloc(ch->ch_memt, 0, 0x00ff, 0x0100,
 	0x0100, 0x0100, 0, &ch->ch_membase_addr,
 	&ch->ch_memh);
-	fixup_sh3_pcmcia_area(ch->ch_memt);
+	if (channel == CHANNEL_0)
+		fixup_sh3_pcmcia_area6(ch->ch_memt);
 
 	/* Common memory space extent */
 	ch->ch_memsize = 0x0100;
@@ -394,7 +415,8 @@ hd64461pcmcia_attach_channel(struct hd64
 		ch->ch_cmemt[i] = bus_space_create(0, "PCMCIA common memory",
 		membase + 0x0100,
 		ch->ch_memsize);
-		fixup_sh3_pcmcia_area(ch->ch_cmemt[i]);
+		if (channel == CHANNEL_0)
+			fixup_sh3_pcmcia_area6(ch->ch_cmemt[i]);
 	}
 
 	/* I/O port extent and interrupt staff */
@@ -406,7 +428,7 @@ hd64461pcmcia_attach_channel(struct hd64
 		ch->ch_iot = bus_space_create(0, "PCMCIA I/O port",
 		HD64461_PCC0_IOBASE,
 		ch->ch_iosize);
-		fixup_sh3_pcmcia_area(ch->ch_iot);
+		fixup_sh3_pcmcia_area6(ch->ch_iot);
 
 		hd6446x_intr_establish(HD64461_INTC_PCC0, IST_LEVEL, IPL_TTY,
 		hd64461pcmcia_channel0_intr, ch);
@@ -1081,14 +1103,18 @@ hd64461_set_bus_width(enum controller_ch
 }
 
 STATIC void
-fixup

CVS commit: src/sys/arch/hpcsh/dev/hd64461

2021-10-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct 11 02:30:01 UTC 2021

Modified Files:
src/sys/arch/hpcsh/dev/hd64461: hd64461pcmcia.c

Log Message:
Fix workaround for SH-3 PCMCIA bug in accordance with description
found in TECH I vol. 14 (CQ Publishing, Tokyo, 2002, in Japanese),
as well as experiment on real hardware:

Byte-access to area 6 becomes word-access (both CE1# and CE2# are
wrongly asserted), if preceding access is word-wise. Inserting a
dummy byte-access works around the problem. Area 5 is not affected.

Therefore,

(1) Insert a dummy byte-read before all byte-wise operations.

(2) Restrict the workaround to area 6 (channel 0), and rename
fixup_sh3_pcmcia_area() to fixup_sh3_pcmcia_area6() for clarity.

Also, we used to use 0xba00 (== HD64461_PCC0_IOBASE) as target
for the dummy read. However, this can modify device states, which
breaks ep(4) at least. Thus,

(3) Use HD64461_PCC0_MEMBASE as target for the dummy read. This is
assigned to attribute memory space, and byte-read should be
harmless.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c

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



CVS commit: src/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Oct 11 01:49:08 UTC 2021

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c
src/sys/nfs: nfs_kq.c

Log Message:
Mark the EVFILT_VNODE filters MP-safe.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/miscfs/genfs/genfs_vnops.c
cvs rdiff -u -r1.30 -r1.31 src/sys/nfs/nfs_kq.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/miscfs/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.214 src/sys/miscfs/genfs/genfs_vnops.c:1.215
--- src/sys/miscfs/genfs/genfs_vnops.c:1.214	Mon Oct 11 01:07:36 2021
+++ src/sys/miscfs/genfs/genfs_vnops.c	Mon Oct 11 01:49:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.214 2021/10/11 01:07:36 thorpej Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.215 2021/10/11 01:49:08 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.214 2021/10/11 01:07:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.215 2021/10/11 01:49:08 thorpej Exp $");
 
 #include 
 #include 
@@ -596,21 +596,21 @@ filt_genfsvnode(struct knote *kn, long h
 }
 
 static const struct filterops genfsread_filtops = {
-	.f_flags = FILTEROP_ISFD,
+	.f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
 	.f_attach = NULL,
 	.f_detach = filt_genfsdetach,
 	.f_event = filt_genfsread,
 };
 
 static const struct filterops genfswrite_filtops = {
-	.f_flags = FILTEROP_ISFD,
+	.f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
 	.f_attach = NULL,
 	.f_detach = filt_genfsdetach,
 	.f_event = filt_genfswrite,
 };
 
 static const struct filterops genfsvnode_filtops = {
-	.f_flags = FILTEROP_ISFD,
+	.f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
 	.f_attach = NULL,
 	.f_detach = filt_genfsdetach,
 	.f_event = filt_genfsvnode,

Index: src/sys/nfs/nfs_kq.c
diff -u src/sys/nfs/nfs_kq.c:1.30 src/sys/nfs/nfs_kq.c:1.31
--- src/sys/nfs/nfs_kq.c:1.30	Mon Oct 11 01:07:36 2021
+++ src/sys/nfs/nfs_kq.c	Mon Oct 11 01:49:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_kq.c,v 1.30 2021/10/11 01:07:36 thorpej Exp $	*/
+/*	$NetBSD: nfs_kq.c,v 1.31 2021/10/11 01:49:08 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_kq.c,v 1.30 2021/10/11 01:07:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_kq.c,v 1.31 2021/10/11 01:49:08 thorpej Exp $");
 
 #include 
 #include 
@@ -277,14 +277,14 @@ filt_nfsvnode(struct knote *kn, long hin
 
 
 static const struct filterops nfsread_filtops = {
-	.f_flags = FILTEROP_ISFD,
+	.f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
 	.f_attach = NULL,
 	.f_detach = filt_nfsdetach,
 	.f_event = filt_nfsread,
 };
 
 static const struct filterops nfsvnode_filtops = {
-	.f_flags = FILTEROP_ISFD,
+	.f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
 	.f_attach = NULL,
 	.f_detach = filt_nfsdetach,
 	.f_event = filt_nfsvnode,



CVS commit: src/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Oct 11 01:49:08 UTC 2021

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c
src/sys/nfs: nfs_kq.c

Log Message:
Mark the EVFILT_VNODE filters MP-safe.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/miscfs/genfs/genfs_vnops.c
cvs rdiff -u -r1.30 -r1.31 src/sys/nfs/nfs_kq.c

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



CVS commit: src/sys/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Oct 11 01:21:28 UTC 2021

Modified Files:
src/sys/sys: event.h

Log Message:
Add a clarifying comment about it being safe to modify knote::kn_flags
without synchronization in the filter attach routine.  This is safe
because the knote has not yet been published, and is typically used to
force EV_CLEAR and/or EV_ONESHOT on that filter's knotes.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/sys/event.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/sys/event.h
diff -u src/sys/sys/event.h:1.46 src/sys/sys/event.h:1.47
--- src/sys/sys/event.h:1.46	Mon Oct 11 01:07:36 2021
+++ src/sys/sys/event.h	Mon Oct 11 01:21:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: event.h,v 1.46 2021/10/11 01:07:36 thorpej Exp $	*/
+/*	$NetBSD: event.h,v 1.47 2021/10/11 01:21:28 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1999,2000,2001 Jonathan Lemon 
@@ -267,6 +267,12 @@ struct knote {
 "\7WILLDETACH"
 
 
+/*
+ * The only time knote::kn_flags can be modified without synchronization
+ * is during filter attach, because the knote has not yet been published.
+ * This is usually to set EV_CLEAR or EV_ONESHOT as mandatory flags for
+ * that filter.
+ */
 #define	kn_id		kn_kevent.ident
 #define	kn_filter	kn_kevent.filter
 #define	kn_flags	kn_kevent.flags		/* q */



CVS commit: src/sys/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Oct 11 01:21:28 UTC 2021

Modified Files:
src/sys/sys: event.h

Log Message:
Add a clarifying comment about it being safe to modify knote::kn_flags
without synchronization in the filter attach routine.  This is safe
because the knote has not yet been published, and is typically used to
force EV_CLEAR and/or EV_ONESHOT on that filter's knotes.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/sys/event.h

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



CVS commit: src/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Oct 11 01:07:37 UTC 2021

Modified Files:
src/sys/dev/pci: xmm7360.c
src/sys/kern: kern_event.c sys_pipe.c tty_pty.c uipc_socket.c
src/sys/miscfs/fifofs: fifo_vnops.c
src/sys/miscfs/genfs: genfs_vnops.c
src/sys/nfs: nfs_kq.c
src/sys/sys: event.h param.h

Log Message:
Setting EV_EOF requires modifying kn->kn_flags.  However, that relies on
holding the kq_lock of that note's kq.  Rather than exposing this directly,
add new knote_set_eof() and knote_clear_eof() functions that handle the
necessary locking and don't leak as many implementation details to modules.

NetBSD 9.99.91


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/xmm7360.c
cvs rdiff -u -r1.130 -r1.131 src/sys/kern/kern_event.c
cvs rdiff -u -r1.157 -r1.158 src/sys/kern/sys_pipe.c
cvs rdiff -u -r1.148 -r1.149 src/sys/kern/tty_pty.c
cvs rdiff -u -r1.298 -r1.299 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.90 -r1.91 src/sys/miscfs/fifofs/fifo_vnops.c
cvs rdiff -u -r1.213 -r1.214 src/sys/miscfs/genfs/genfs_vnops.c
cvs rdiff -u -r1.29 -r1.30 src/sys/nfs/nfs_kq.c
cvs rdiff -u -r1.45 -r1.46 src/sys/sys/event.h
cvs rdiff -u -r1.703 -r1.704 src/sys/sys/param.h

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



CVS commit: src/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Oct 11 01:07:37 UTC 2021

Modified Files:
src/sys/dev/pci: xmm7360.c
src/sys/kern: kern_event.c sys_pipe.c tty_pty.c uipc_socket.c
src/sys/miscfs/fifofs: fifo_vnops.c
src/sys/miscfs/genfs: genfs_vnops.c
src/sys/nfs: nfs_kq.c
src/sys/sys: event.h param.h

Log Message:
Setting EV_EOF requires modifying kn->kn_flags.  However, that relies on
holding the kq_lock of that note's kq.  Rather than exposing this directly,
add new knote_set_eof() and knote_clear_eof() functions that handle the
necessary locking and don't leak as many implementation details to modules.

NetBSD 9.99.91


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/xmm7360.c
cvs rdiff -u -r1.130 -r1.131 src/sys/kern/kern_event.c
cvs rdiff -u -r1.157 -r1.158 src/sys/kern/sys_pipe.c
cvs rdiff -u -r1.148 -r1.149 src/sys/kern/tty_pty.c
cvs rdiff -u -r1.298 -r1.299 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.90 -r1.91 src/sys/miscfs/fifofs/fifo_vnops.c
cvs rdiff -u -r1.213 -r1.214 src/sys/miscfs/genfs/genfs_vnops.c
cvs rdiff -u -r1.29 -r1.30 src/sys/nfs/nfs_kq.c
cvs rdiff -u -r1.45 -r1.46 src/sys/sys/event.h
cvs rdiff -u -r1.703 -r1.704 src/sys/sys/param.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/xmm7360.c
diff -u src/sys/dev/pci/xmm7360.c:1.10 src/sys/dev/pci/xmm7360.c:1.11
--- src/sys/dev/pci/xmm7360.c:1.10	Sun Sep 26 01:16:09 2021
+++ src/sys/dev/pci/xmm7360.c	Mon Oct 11 01:07:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xmm7360.c,v 1.10 2021/09/26 01:16:09 thorpej Exp $	*/
+/*	$NetBSD: xmm7360.c,v 1.11 2021/10/11 01:07:36 thorpej Exp $	*/
 
 /*
  * Device driver for Intel XMM7360 LTE modems, eg. Fibocom L850-GL.
@@ -75,7 +75,7 @@ MODULE_DEVICE_TABLE(pci, xmm7360_ids);
 #include "opt_gateway.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.10 2021/09/26 01:16:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.11 2021/10/11 01:07:36 thorpej Exp $");
 #endif
 
 #include 
@@ -166,6 +166,7 @@ typedef struct mutex spinlock_t;
 #define device_private(devt)			(void *)devt;
 #define if_deferred_start_init(ifp, arg)	/* nothing */
 #define IF_OUTPUT_CONST/* nothing */
+#define knote_set_eof(kn, f)			(kn)->kn_flags |= EV_EOF | (f)
 #define tty_lock()int s = spltty()
 #define tty_unlock()splx(s)
 #define tty_locked()/* nothing */
@@ -2762,7 +2763,7 @@ filt_wwancread(struct knote *kn, long hi
 	kn->kn_data = 0;
 
 	if (!qp->open) {
-		kn->kn_flags |= EV_EOF;
+		knote_set_eof(kn, 0);
 		return (1);
 	} else {
 		kn->kn_data = xmm7360_qp_has_data(qp) ? 1 : 0;

Index: src/sys/kern/kern_event.c
diff -u src/sys/kern/kern_event.c:1.130 src/sys/kern/kern_event.c:1.131
--- src/sys/kern/kern_event.c:1.130	Sun Oct 10 19:11:56 2021
+++ src/sys/kern/kern_event.c	Mon Oct 11 01:07:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_event.c,v 1.130 2021/10/10 19:11:56 thorpej Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.131 2021/10/11 01:07:36 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2021 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #endif /* _KERNEL_OPT */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.130 2021/10/10 19:11:56 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.131 2021/10/11 01:07:36 thorpej Exp $");
 
 #include 
 #include 
@@ -2578,3 +2578,30 @@ knote_activate(struct knote *kn)
  out:
 	mutex_spin_exit(&kq->kq_lock);
 }
+
+/*
+ * Set EV_EOF on the specified knote.  Also allows additional
+ * EV_* flags to be set (e.g. EV_ONESHOT).
+ */
+void
+knote_set_eof(struct knote *kn, uint32_t flags)
+{
+	struct kqueue *kq = kn->kn_kq;
+
+	mutex_spin_enter(&kq->kq_lock);
+	kn->kn_flags |= EV_EOF | flags;
+	mutex_spin_exit(&kq->kq_lock);
+}
+
+/*
+ * Clear EV_EOF on the specified knote.
+ */
+void
+knote_clear_eof(struct knote *kn)
+{
+	struct kqueue *kq = kn->kn_kq;
+
+	mutex_spin_enter(&kq->kq_lock);
+	kn->kn_flags &= ~EV_EOF;
+	mutex_spin_exit(&kq->kq_lock);
+}

Index: src/sys/kern/sys_pipe.c
diff -u src/sys/kern/sys_pipe.c:1.157 src/sys/kern/sys_pipe.c:1.158
--- src/sys/kern/sys_pipe.c:1.157	Sat Oct  2 07:35:40 2021
+++ src/sys/kern/sys_pipe.c	Mon Oct 11 01:07:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_pipe.c,v 1.157 2021/10/02 07:35:40 hannken Exp $	*/
+/*	$NetBSD: sys_pipe.c,v 1.158 2021/10/11 01:07:36 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.157 2021/10/02 07:35:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.158 2021/10/11 01:07:36 thorpej Exp $");
 
 #include 
 #include 
@@ -1056,7 +1056,7 @@ filt_piperead(struct knote *kn, long hin
 
 	if ((rpipe->pipe_state & PIPE_EOF) ||
 	(wpipe == NULL) || (wpipe->pipe_state & PIPE_EOF)) {
-		kn->kn_flags |= EV_EOF;
+		knote_set_eof(kn, 0);
 		rv = 1;
 	} else {
 		rv = kn->kn

CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:25:05 UTC 2021

Modified Files:
src/sys/dev/usb: usb.h

Log Message:
Update USB_PORT_RESET_RECOVERT to comply with the USB 2.0 specification
which says it should be max 10 milliseconds.

>From FreeBSD: 
>https://github.com/freebsd/freebsd-src/commit/70ffaaa69c830d26b59136d0b0447ab2f8683db8


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/usb/usb.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/usb/usb.h
diff -u src/sys/dev/usb/usb.h:1.118 src/sys/dev/usb/usb.h:1.119
--- src/sys/dev/usb/usb.h:1.118	Fri Aug 23 07:17:31 2019
+++ src/sys/dev/usb/usb.h	Mon Oct 11 00:25:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.h,v 1.118 2019/08/23 07:17:31 mrg Exp $	*/
+/*	$NetBSD: usb.h,v 1.119 2021/10/11 00:25:05 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -771,7 +771,7 @@ typedef struct {
 /* Allow for marginal (i.e. non-conforming) devices. */
 #define USB_PORT_RESET_DELAY	50  /* ms */
 #define USB_PORT_ROOT_RESET_DELAY 250  /* ms */
-#define USB_PORT_RESET_RECOVERY	250  /* ms */
+#define USB_PORT_RESET_RECOVERY	10  /* ms */
 #define USB_PORT_POWERUP_DELAY	300 /* ms */
 #define USB_SET_ADDRESS_SETTLE	10  /* ms */
 #define USB_RESUME_DELAY	(50*5)  /* ms */



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:25:05 UTC 2021

Modified Files:
src/sys/dev/usb: usb.h

Log Message:
Update USB_PORT_RESET_RECOVERT to comply with the USB 2.0 specification
which says it should be max 10 milliseconds.

>From FreeBSD: 
>https://github.com/freebsd/freebsd-src/commit/70ffaaa69c830d26b59136d0b0447ab2f8683db8


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/usb/usb.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/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:16:08 UTC 2021

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
uhub: Skip USB_POWER_DOWN_TIME delay for root hubs


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/dev/usb/uhub.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/usb/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.155 src/sys/dev/usb/uhub.c:1.156
--- src/sys/dev/usb/uhub.c:1.155	Mon Oct 11 00:08:31 2021
+++ src/sys/dev/usb/uhub.c	Mon Oct 11 00:16:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.155 2021/10/11 00:08:31 jmcneill Exp $	*/
+/*	$NetBSD: uhub.c,v 1.156 2021/10/11 00:16:08 jmcneill Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 /*	$OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.155 2021/10/11 00:08:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.156 2021/10/11 00:16:08 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -388,8 +388,9 @@ uhub_attach(device_t parent, device_t se
 		goto bad;
 	}
 
-	/* Wait with power off for a while. */
-	usbd_delay_ms(dev, USB_POWER_DOWN_TIME);
+	/* Wait with power off for a while if we are not a root hub */
+	if (dev->ud_powersrc->up_parent != NULL)
+		usbd_delay_ms(dev, USB_POWER_DOWN_TIME);
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, dev, sc->sc_dev);
 



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:16:08 UTC 2021

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
uhub: Skip USB_POWER_DOWN_TIME delay for root hubs


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/dev/usb/uhub.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/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:08:31 UTC 2021

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
Fix previous; restore 'up' pointer in second uhub_explore loop.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/dev/usb/uhub.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/usb/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.154 src/sys/dev/usb/uhub.c:1.155
--- src/sys/dev/usb/uhub.c:1.154	Sun Oct 10 23:39:50 2021
+++ src/sys/dev/usb/uhub.c	Mon Oct 11 00:08:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.154 2021/10/10 23:39:50 jmcneill Exp $	*/
+/*	$NetBSD: uhub.c,v 1.155 2021/10/11 00:08:31 jmcneill Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 /*	$OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.154 2021/10/10 23:39:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.155 2021/10/11 00:08:31 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -701,6 +701,8 @@ uhub_explore(struct usbd_device *dev)
 			continue;
 		}
 
+		up = &dev->ud_hub->uh_ports[port - 1];
+
 		/* Reset port, which implies enabling it. */
 		if (usbd_reset_port(dev, port, &up->up_status)) {
 			aprint_error_dev(sc->sc_dev,



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:08:31 UTC 2021

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
Fix previous; restore 'up' pointer in second uhub_explore loop.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/dev/usb/uhub.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/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:00:03 UTC 2021

Modified Files:
src/sys/dev/usb: ukbd.c

Log Message:
ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/dev/usb/ukbd.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/usb/ukbd.c
diff -u src/sys/dev/usb/ukbd.c:1.152 src/sys/dev/usb/ukbd.c:1.153
--- src/sys/dev/usb/ukbd.c:1.152	Sat Aug  7 16:19:17 2021
+++ src/sys/dev/usb/ukbd.c	Mon Oct 11 00:00:03 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: ukbd.c,v 1.152 2021/08/07 16:19:17 thorpej Exp $*/
+/*  $NetBSD: ukbd.c,v 1.153 2021/10/11 00:00:03 jmcneill Exp $*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.152 2021/08/07 16:19:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.153 2021/10/11 00:00:03 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -343,6 +343,7 @@ Static void	ukbd_delayed_decode(void *);
 Static int	ukbd_enable(void *, int);
 Static void	ukbd_set_leds(void *, int);
 Static void	ukbd_set_leds_task(void *);
+Static void	ukbd_delayed_leds_off(void *);
 
 Static int	ukbd_ioctl(void *, u_long, void *, int, struct lwp *);
 #if  defined(WSDISPLAY_COMPAT_RAWKBD) && defined(UKBD_REPEAT)
@@ -486,8 +487,7 @@ ukbd_attach(device_t parent, device_t se
 	/* Flash the leds; no real purpose, just shows we're alive. */
 	ukbd_set_leds(sc, WSKBD_LED_SCROLL | WSKBD_LED_NUM | WSKBD_LED_CAPS
 			| WSKBD_LED_COMPOSE);
-	usbd_delay_ms(uha->parent->sc_udev, 400);
-	ukbd_set_leds(sc, 0);
+	callout_reset(&sc->sc_delay, mstohz(400), ukbd_delayed_leds_off, sc);
 
 	sc->sc_wskbddev = config_found(self, &a, wskbddevprint, CFARGS_NONE);
 
@@ -706,6 +706,14 @@ ukbd_intr(struct uhidev *addr, void *ibu
 	}
 }
 
+Static void
+ukbd_delayed_leds_off(void *addr)
+{
+	struct ukbd_softc *sc = addr;
+
+	ukbd_set_leds(sc, 0);
+}
+
 void
 ukbd_delayed_decode(void *addr)
 {



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:00:03 UTC 2021

Modified Files:
src/sys/dev/usb: ukbd.c

Log Message:
ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/dev/usb/ukbd.c

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



CVS commit: src/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 23:46:23 UTC 2021

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c
src/sys/nfs: nfs_kq.c

Log Message:
Must hold kn->kn_kq->kq_lock to modify kn->kn_flags.


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/sys/miscfs/genfs/genfs_vnops.c
cvs rdiff -u -r1.28 -r1.29 src/sys/nfs/nfs_kq.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/miscfs/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.212 src/sys/miscfs/genfs/genfs_vnops.c:1.213
--- src/sys/miscfs/genfs/genfs_vnops.c:1.212	Sun Sep 26 01:16:10 2021
+++ src/sys/miscfs/genfs/genfs_vnops.c	Sun Oct 10 23:46:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.212 2021/09/26 01:16:10 thorpej Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.213 2021/10/10 23:46:23 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.212 2021/09/26 01:16:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.213 2021/10/10 23:46:23 thorpej Exp $");
 
 #include 
 #include 
@@ -68,6 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: genfs_vnops.
 #include 
 #include 
 #include 
+#include 		/* XXX for kq->kq_lock */
 #include 
 #include 
 #include 
@@ -525,7 +526,9 @@ filt_genfsread(struct knote *kn, long hi
 	switch (hint) {
 	case NOTE_REVOKE:
 		KASSERT(mutex_owned(vp->v_interlock));
+		mutex_spin_enter(&kn->kn_kq->kq_lock);
 		kn->kn_flags |= (EV_EOF | EV_ONESHOT);
+		mutex_spin_exit(&kn->kn_kq->kq_lock);
 		return (1);
 	case 0:
 		mutex_enter(vp->v_interlock);
@@ -552,7 +555,9 @@ filt_genfswrite(struct knote *kn, long h
 	switch (hint) {
 	case NOTE_REVOKE:
 		KASSERT(mutex_owned(vp->v_interlock));
+		mutex_spin_enter(&kn->kn_kq->kq_lock);
 		kn->kn_flags |= (EV_EOF | EV_ONESHOT);
+		mutex_spin_exit(&kn->kn_kq->kq_lock);
 		return (1);
 	case 0:
 		mutex_enter(vp->v_interlock);
@@ -575,7 +580,9 @@ filt_genfsvnode(struct knote *kn, long h
 	switch (hint) {
 	case NOTE_REVOKE:
 		KASSERT(mutex_owned(vp->v_interlock));
+		mutex_spin_enter(&kn->kn_kq->kq_lock);
 		kn->kn_flags |= EV_EOF;
+		mutex_spin_exit(&kn->kn_kq->kq_lock);
 		if ((kn->kn_sfflags & hint) != 0)
 			kn->kn_fflags |= hint;
 		return (1);

Index: src/sys/nfs/nfs_kq.c
diff -u src/sys/nfs/nfs_kq.c:1.28 src/sys/nfs/nfs_kq.c:1.29
--- src/sys/nfs/nfs_kq.c:1.28	Sun Sep 26 01:16:10 2021
+++ src/sys/nfs/nfs_kq.c	Sun Oct 10 23:46:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_kq.c,v 1.28 2021/09/26 01:16:10 thorpej Exp $	*/
+/*	$NetBSD: nfs_kq.c,v 1.29 2021/10/10 23:46:22 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_kq.c,v 1.28 2021/09/26 01:16:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_kq.c,v 1.29 2021/10/10 23:46:22 thorpej Exp $");
 
 #include 
 #include 
@@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: nfs_kq.c,v 1
 #include 
 #include 
 #include 
+#include 		/* XXX for kq->kq_lock */
 #include 
 
 #include 
@@ -231,7 +232,9 @@ filt_nfsread(struct knote *kn, long hint
 	switch (hint) {
 	case NOTE_REVOKE:
 		KASSERT(mutex_owned(vp->v_interlock));
+		mutex_spin_enter(&kn->kn_kq->kq_lock);
 		kn->kn_flags |= (EV_EOF | EV_ONESHOT);
+		mutex_spin_exit(&kn->kn_kq->kq_lock);
 		return (1);
 	case 0:
 		mutex_enter(vp->v_interlock);
@@ -255,7 +258,9 @@ filt_nfsvnode(struct knote *kn, long hin
 	switch (hint) {
 	case NOTE_REVOKE:
 		KASSERT(mutex_owned(vp->v_interlock));
+		mutex_spin_enter(&kn->kn_kq->kq_lock);
 		kn->kn_flags |= EV_EOF;
+		mutex_spin_exit(&kn->kn_kq->kq_lock);
 		if ((kn->kn_sfflags & hint) != 0)
 			kn->kn_fflags |= hint;
 		return (1);



CVS commit: src/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 23:46:23 UTC 2021

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c
src/sys/nfs: nfs_kq.c

Log Message:
Must hold kn->kn_kq->kq_lock to modify kn->kn_flags.


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/sys/miscfs/genfs/genfs_vnops.c
cvs rdiff -u -r1.28 -r1.29 src/sys/nfs/nfs_kq.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/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 10 23:39:50 UTC 2021

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
usb: uhub: remove unnecessary delays when powering on ports

In uhub_explore instead of waiting 300ms after powering up each
connected port, power up all of the connected ports and then wait for
300ms total.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/dev/usb/uhub.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/usb/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.153 src/sys/dev/usb/uhub.c:1.154
--- src/sys/dev/usb/uhub.c:1.153	Sun Jun 13 14:48:10 2021
+++ src/sys/dev/usb/uhub.c	Sun Oct 10 23:39:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.153 2021/06/13 14:48:10 riastradh Exp $	*/
+/*	$NetBSD: uhub.c,v 1.154 2021/10/10 23:39:50 jmcneill Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 /*	$OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.153 2021/06/13 14:48:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.154 2021/10/10 23:39:50 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -124,6 +124,8 @@ struct uhub_softc {
 	struct lwp		*sc_exploring;
 };
 
+typedef __BITMAP_TYPE(, uint8_t, UHD_NPORTS_MAX + 1) usb_port_mask;
+
 #define UHUB_IS_HIGH_SPEED(sc) \
 ((sc)->sc_proto == UDPROTO_HSHUBSTT || (sc)->sc_proto == UDPROTO_HSHUBMTT)
 #define UHUB_IS_SINGLE_TT(sc) ((sc)->sc_proto == UDPROTO_HSHUBSTT)
@@ -494,6 +496,8 @@ uhub_explore(struct usbd_device *dev)
 	int speed;
 	int port;
 	int change, status, reconnect, rescan;
+	usb_port_mask powerup_port;
+	int powerup_port_count = 0;
 
 	UHUBHIST_FUNC();
 	UHUBHIST_CALLARGS("uhub%jd dev=%#jx addr=%jd speed=%ju",
@@ -546,6 +550,8 @@ uhub_explore(struct usbd_device *dev)
 		}
 	}
 
+	__BITMAP_ZERO(&powerup_port);
+
 	for (port = 1; port <= hd->bNbrPorts; port++) {
 		up = &dev->ud_hub->uh_ports[port - 1];
 
@@ -676,8 +682,24 @@ uhub_explore(struct usbd_device *dev)
 		DPRINTF("unit %jd dev->speed=%ju dev->depth=%ju",
 		device_unit(sc->sc_dev), dev->ud_speed, dev->ud_depth, 0);
 
-		/* Wait for maximum device power up time. */
-		usbd_delay_ms(dev, USB_PORT_POWERUP_DELAY);
+		__BITMAP_SET(port, &powerup_port);
+		powerup_port_count++;
+	}
+
+	if (powerup_port_count == 0) {
+		goto explore;
+	}
+
+	aprint_debug_dev(sc->sc_dev, "power up %u port(s)\n",
+	powerup_port_count);
+
+	/* Wait for maximum device power up time. */
+	usbd_delay_ms(dev, USB_PORT_POWERUP_DELAY);
+
+	for (port = 1; port <= hd->bNbrPorts; port++) {
+		if (!__BITMAP_ISSET(port, &powerup_port)) {
+			continue;
+		}
 
 		/* Reset port, which implies enabling it. */
 		if (usbd_reset_port(dev, port, &up->up_status)) {
@@ -815,6 +837,8 @@ uhub_explore(struct usbd_device *dev)
 up->up_dev->ud_hub->uh_explore(up->up_dev);
 		}
 	}
+
+explore:
 	mutex_enter(&sc->sc_lock);
 	sc->sc_explorepending = false;
 	for (int i = 0; i < sc->sc_statuslen; i++) {



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 10 23:39:50 UTC 2021

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
usb: uhub: remove unnecessary delays when powering on ports

In uhub_explore instead of waiting 300ms after powering up each
connected port, power up all of the connected ports and then wait for
300ms total.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/dev/usb/uhub.c

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



CVS commit: src/sys/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 23:30:44 UTC 2021

Modified Files:
src/sys/sys: event.h

Log Message:
Document the locking rules for the fields of the kevent that's
embedded in a knote.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/sys/event.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/sys/event.h
diff -u src/sys/sys/event.h:1.44 src/sys/sys/event.h:1.45
--- src/sys/sys/event.h:1.44	Sun Oct 10 18:07:51 2021
+++ src/sys/sys/event.h	Sun Oct 10 23:30:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: event.h,v 1.44 2021/10/10 18:07:51 thorpej Exp $	*/
+/*	$NetBSD: event.h,v 1.45 2021/10/10 23:30:44 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1999,2000,2001 Jonathan Lemon 
@@ -237,7 +237,7 @@ struct knote {
 	SLIST_ENTRY(knote)	kn_selnext;	/* o: for struct selinfo */
 	TAILQ_ENTRY(knote)	kn_tqe;		/* q: for struct kqueue */
 	struct kqueue		*kn_kq;		/* q: which queue we are on */
-	struct kevent		kn_kevent;
+	struct kevent		kn_kevent;	/* (see below for locking) */
 	uint32_t		kn_status;	/* q: flags below */
 	uint32_t		kn_sfflags;	/*saved filter flags */
 	uintptr_t		kn_sdata;	/*saved data field */
@@ -269,9 +269,9 @@ struct knote {
 
 #define	kn_id		kn_kevent.ident
 #define	kn_filter	kn_kevent.filter
-#define	kn_flags	kn_kevent.flags
-#define	kn_fflags	kn_kevent.fflags
-#define	kn_data		kn_kevent.data
+#define	kn_flags	kn_kevent.flags		/* q */
+#define	kn_fflags	kn_kevent.fflags	/* o */
+#define	kn_data		kn_kevent.data		/* o */
 };
 
 #include 	/* for copyin_t */



CVS commit: src/sys/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 23:30:44 UTC 2021

Modified Files:
src/sys/sys: event.h

Log Message:
Document the locking rules for the fields of the kevent that's
embedded in a knote.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/sys/event.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

2021-10-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Oct 10 23:28:36 UTC 2021

Modified Files:
src/sys/dev/pci: pci.c pci_subr.c pcireg.h ppb.c

Log Message:
Use PCI-SIG official acronyms:

 - RP stands for Root Port.
 - RC stands for Root Complex.
 - RCIEP stands for Root Complex Integrated End Point.


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/sys/dev/pci/pci.c
cvs rdiff -u -r1.231 -r1.232 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.160 -r1.161 src/sys/dev/pci/pcireg.h
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/pci/ppb.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/pci.c
diff -u src/sys/dev/pci/pci.c:1.162 src/sys/dev/pci/pci.c:1.163
--- src/sys/dev/pci/pci.c:1.162	Wed Sep 15 17:33:08 2021
+++ src/sys/dev/pci/pci.c	Sun Oct 10 23:28:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci.c,v 1.162 2021/09/15 17:33:08 thorpej Exp $	*/
+/*	$NetBSD: pci.c,v 1.163 2021/10/10 23:28:36 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 1998
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.162 2021/09/15 17:33:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.163 2021/10/10 23:28:36 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -735,7 +735,7 @@ pci_enumerate_bus(struct pci_softc *sc, 
 		if (pci_get_capability(ppbpc, ppbtag, PCI_CAP_PCIEXPRESS,
 		&pciecap, &capreg) != 0) {
 			switch (PCIE_XCAP_TYPE(capreg)) {
-			case PCIE_XCAP_TYPE_ROOT:
+			case PCIE_XCAP_TYPE_RP:
 			case PCIE_XCAP_TYPE_DOWN:
 			case PCIE_XCAP_TYPE_PCI2PCIE:
 downstream_port = true;

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.231 src/sys/dev/pci/pci_subr.c:1.232
--- src/sys/dev/pci/pci_subr.c:1.231	Sun Oct 10 07:20:01 2021
+++ src/sys/dev/pci/pci_subr.c	Sun Oct 10 23:28:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.231 2021/10/10 07:20:01 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.232 2021/10/10 23:28:36 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.231 2021/10/10 07:20:01 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.232 2021/10/10 23:28:36 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -914,7 +914,7 @@ pci_conf_print_common(
 
 		if (pci_conf_find_cap(regs, PCI_CAP_PCIEXPRESS, &pcie_capoff)) {
 			reg = regs[o2i(pcie_capoff + PCIE_XCAP)];
-			if (PCIE_XCAP_TYPE(reg) == PCIE_XCAP_TYPE_ROOT_EVNTC)
+			if (PCIE_XCAP_TYPE(reg) == PCIE_XCAP_TYPE_RC_EVNTC)
 subclass = PCI_SUBCLASS_SYSTEM_RCEC;
 		}
 	}
@@ -1861,7 +1861,7 @@ pci_conf_print_pcie_cap(const pcireg_t *
 		printf("Legacy PCI Express Endpoint device\n");
 		check_upstreamport = true;
 		break;
-	case PCIE_XCAP_TYPE_ROOT:	/* 0x4 */
+	case PCIE_XCAP_TYPE_RP:		/* 0x4 */
 		printf("Root Port of PCI Express Root Complex\n");
 		check_slot = true;
 		break;
@@ -1882,10 +1882,10 @@ pci_conf_print_pcie_cap(const pcireg_t *
 		/* Upstream port is not PCIe */
 		check_slot = true;
 		break;
-	case PCIE_XCAP_TYPE_ROOT_INTEP:	/* 0x9 */
+	case PCIE_XCAP_TYPE_RCIEP:	/* 0x9 */
 		printf("Root Complex Integrated Endpoint\n");
 		break;
-	case PCIE_XCAP_TYPE_ROOT_EVNTC:	/* 0xa */
+	case PCIE_XCAP_TYPE_RC_EVNTC:	/* 0xa */
 		printf("Root Complex Event Collector\n");
 		break;
 	default:
@@ -2930,8 +2930,8 @@ pci_conf_print_aer_cap(const pcireg_t *r
 	extcapoff + PCI_AER_ROOTERR_CMD);
 
 	switch (pcie_devtype) {
-	case PCIE_XCAP_TYPE_ROOT: /* Root Port of PCI Express Root Complex */
-	case PCIE_XCAP_TYPE_ROOT_EVNTC:	/* Root Complex Event Collector */
+	case PCIE_XCAP_TYPE_RP:	/* Root Port of PCI Express Root Complex */
+	case PCIE_XCAP_TYPE_RC_EVNTC:	/* Root Complex Event Collector */
 		reg = regs[o2i(extcapoff + PCI_AER_ROOTERR_CMD)];
 		printf("Root Error Command register: 0x%08x\n", reg);
 		pci_conf_print_aer_cap_rooterr_cmd(reg);
@@ -4149,7 +4149,7 @@ pci_conf_print_l1pm_cap(const pcireg_t *
 	if (pci_conf_find_cap(regs, PCI_CAP_PCIEXPRESS, &pcie_capoff)) {
 		uint32_t t = regs[o2i(pcie_capoff)];
 
-		if ((t == PCIE_XCAP_TYPE_ROOT) || (t == PCIE_XCAP_TYPE_DOWN))
+		if ((t == PCIE_XCAP_TYPE_RP) || (t == PCIE_XCAP_TYPE_DOWN))
 			onoff("Link Activation Supported", reg,
 			PCI_L1PM_CAP_LA);
 	}

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.160 src/sys/dev/pci/pcireg.h:1.161
--- src/sys/dev/pci/pcireg.h:1.160	Sun Oct 10 07:20:01 2021
+++ src/sys/dev/pci/pcireg.h	Sun Oct 10 23:28:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.160 2021/10/10 07:20:01 msaitoh Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.161 2021/10/10 23:28:36 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -983,13 +983,13 @@ typedef u_int8_t pci_revision_t;
 #define	PCIE_XCAP_TYPE(x)	__SHIFTOUT((x), PCIE_XCAP_TYPE_MASK)
 #define	 PCIE_XCAP_TYPE_PCIE_DEV	0x0
 #define	 PCIE_XCAP_TYPE_PCI_DEV		0x1
-#define

CVS commit: src/sys/dev/pci

2021-10-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Oct 10 23:28:36 UTC 2021

Modified Files:
src/sys/dev/pci: pci.c pci_subr.c pcireg.h ppb.c

Log Message:
Use PCI-SIG official acronyms:

 - RP stands for Root Port.
 - RC stands for Root Complex.
 - RCIEP stands for Root Complex Integrated End Point.


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/sys/dev/pci/pci.c
cvs rdiff -u -r1.231 -r1.232 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.160 -r1.161 src/sys/dev/pci/pcireg.h
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/pci/ppb.c

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



CVS commit: src/sys/ufs/ufs

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 23:02:10 UTC 2021

Modified Files:
src/sys/ufs/ufs: ufs_acl.c

Log Message:
Use VN_KNOTE() to send our NOTE_ATTRIB and NOTE_REVOKE events.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ufs/ufs_acl.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/ufs/ufs/ufs_acl.c
diff -u src/sys/ufs/ufs/ufs_acl.c:1.1 src/sys/ufs/ufs/ufs_acl.c:1.2
--- src/sys/ufs/ufs/ufs_acl.c:1.1	Sat May 16 18:31:54 2020
+++ src/sys/ufs/ufs/ufs_acl.c	Sun Oct 10 23:02:10 2021
@@ -36,7 +36,7 @@
 #if 0
 __FBSDID("$FreeBSD: head/sys/ufs/ufs/ufs_acl.c 356669 2020-01-13 02:31:51Z mjg $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: ufs_acl.c,v 1.1 2020/05/16 18:31:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_acl.c,v 1.2 2021/10/10 23:02:10 thorpej Exp $");
 
 #if defined(_KERNEL_OPT) 
 #include "opt_ffs.h"
@@ -425,7 +425,7 @@ ufs_setacl_nfs4_internal(struct vnode *v
 	DIP_ASSIGN(ip, mode, ip->i_mode);
 	ip->i_flag |= IN_CHANGE;
 
-	KNOTE(&vp->v_klist, NOTE_REVOKE);
+	VN_KNOTE(vp, NOTE_REVOKE);
 
 	error = UFS_UPDATE(vp, NULL, NULL, 0);
 	if (lock)
@@ -607,7 +607,7 @@ ufs_setacl_posix1e(struct vnode *vp, int
 		UFS_WAPBL_END(vp->v_mount);
 	}
 
-	KNOTE(&vp->v_klist, NOTE_ATTRIB);
+	VN_KNOTE(vp, NOTE_ATTRIB);
 	return (error);
 }
 



CVS commit: src/sys/ufs/ufs

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 23:02:10 UTC 2021

Modified Files:
src/sys/ufs/ufs: ufs_acl.c

Log Message:
Use VN_KNOTE() to send our NOTE_ATTRIB and NOTE_REVOKE events.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ufs/ufs_acl.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/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 10 20:14:09 UTC 2021

Modified Files:
src/sys/dev/usb: usb.c

Log Message:
usb: usb_event_thread: remove delay at startup for USB >= 2.0 HCs

The delay at the start of usb_event_thread is meant to slow down EHCI
companion controllers. Skip the 500ms delay if the bus that owns this
thread is USB >= 2.0 since those are never companions.


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/sys/dev/usb/usb.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/usb/usb.c
diff -u src/sys/dev/usb/usb.c:1.197 src/sys/dev/usb/usb.c:1.198
--- src/sys/dev/usb/usb.c:1.197	Sun Sep 26 01:16:09 2021
+++ src/sys/dev/usb/usb.c	Sun Oct 10 20:14:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.c,v 1.197 2021/09/26 01:16:09 thorpej Exp $	*/
+/*	$NetBSD: usb.c,v 1.198 2021/10/10 20:14:09 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.197 2021/09/26 01:16:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.198 2021/10/10 20:14:09 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -724,7 +724,9 @@ usb_event_thread(void *arg)
 	 * know how to synchronize the creation of the threads so it
 	 * will work.
 	 */
-	usb_delay_ms(bus, 500);
+	if (bus->ub_revision < USBREV_2_0) {
+		usb_delay_ms(bus, 500);
+	}
 
 	/* Make sure first discover does something. */
 	mutex_enter(bus->ub_lock);



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 10 20:14:09 UTC 2021

Modified Files:
src/sys/dev/usb: usb.c

Log Message:
usb: usb_event_thread: remove delay at startup for USB >= 2.0 HCs

The delay at the start of usb_event_thread is meant to slow down EHCI
companion controllers. Skip the 500ms delay if the bus that owns this
thread is USB >= 2.0 since those are never companions.


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/sys/dev/usb/usb.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/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 10 20:10:12 UTC 2021

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci: shrink port reset delay

Instead of waiting for USB_PORT_ROOT_RESET_DELAY (250ms) before checking
the port reset status, poll the PORTSC register and return early if the
reset has completed.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/dev/usb/xhci.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/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.148 src/sys/dev/usb/xhci.c:1.149
--- src/sys/dev/usb/xhci.c:1.148	Tue Aug 17 22:00:32 2021
+++ src/sys/dev/usb/xhci.c	Sun Oct 10 20:10:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.148 2021/08/17 22:00:32 andvar Exp $	*/
+/*	$NetBSD: xhci.c,v 1.149 2021/10/10 20:10:12 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.148 2021/08/17 22:00:32 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.149 2021/10/10 20:10:12 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -4121,18 +4121,17 @@ xhci_roothub_ctrl(struct usbd_bus *bus, 
 			/* XXX suspend */
 			break;
 		case UHF_PORT_RESET:
-			v &= ~(XHCI_PS_PED | XHCI_PS_PR);
 			xhci_op_write_4(sc, port, v | XHCI_PS_PR);
 			/* Wait for reset to complete. */
-			usb_delay_ms(&sc->sc_bus, USB_PORT_ROOT_RESET_DELAY);
-			if (sc->sc_dying) {
-return -1;
-			}
-			v = xhci_op_read_4(sc, port);
-			if (v & XHCI_PS_PR) {
-xhci_op_write_4(sc, port, v & ~XHCI_PS_PR);
+			for (i = 0; i < USB_PORT_ROOT_RESET_DELAY / 10; i++) {
+if (sc->sc_dying) {
+	return -1;
+}
+v = xhci_op_read_4(sc, port);
+if ((v & XHCI_PS_PR) == 0) {
+	break;
+}
 usb_delay_ms(&sc->sc_bus, 10);
-/* XXX */
 			}
 			break;
 		case UHF_PORT_POWER:



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 10 20:10:12 UTC 2021

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci: shrink port reset delay

Instead of waiting for USB_PORT_ROOT_RESET_DELAY (250ms) before checking
the port reset status, poll the PORTSC register and return early if the
reset has completed.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/dev/usb/xhci.c

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



CVS commit: src/tests/kernel/kqueue

2021-10-10 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Oct 10 19:17:32 UTC 2021

Modified Files:
src/tests/kernel/kqueue: t_scan.c

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/kernel/kqueue/t_scan.c

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

Modified files:

Index: src/tests/kernel/kqueue/t_scan.c
diff -u src/tests/kernel/kqueue/t_scan.c:1.1 src/tests/kernel/kqueue/t_scan.c:1.2
--- src/tests/kernel/kqueue/t_scan.c:1.1	Sun Oct 10 17:47:39 2021
+++ src/tests/kernel/kqueue/t_scan.c	Sun Oct 10 19:17:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_scan.c,v 1.1 2021/10/10 17:47:39 thorpej Exp $ */
+/* $NetBSD: t_scan.c,v 1.2 2021/10/10 19:17:31 wiz Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_scan.c,v 1.1 2021/10/10 17:47:39 thorpej Exp $");
+__RCSID("$NetBSD: t_scan.c,v 1.2 2021/10/10 19:17:31 wiz Exp $");
 
 #include 
 #include 
@@ -44,7 +44,7 @@ __RCSID("$NetBSD: t_scan.c,v 1.1 2021/10
 /*
  * Each kevent thread will make this many kevent() calls, and if it
  * achieves this mark, we assume the race condition has not occurred
- * the delcare the test passes.
+ * the declare the test passes.
  */
 #define	NKEVENT_CALLS		1
 



CVS commit: src/tests/kernel/kqueue

2021-10-10 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Oct 10 19:17:32 UTC 2021

Modified Files:
src/tests/kernel/kqueue: t_scan.c

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/kernel/kqueue/t_scan.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

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 19:11:56 UTC 2021

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

Log Message:
Check _KERNEL_OPT before including opt_ddb.h.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/kern/kern_event.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

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 19:11:56 UTC 2021

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

Log Message:
Check _KERNEL_OPT before including opt_ddb.h.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/kern/kern_event.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/kern_event.c
diff -u src/sys/kern/kern_event.c:1.129 src/sys/kern/kern_event.c:1.130
--- src/sys/kern/kern_event.c:1.129	Sun Oct 10 18:07:51 2021
+++ src/sys/kern/kern_event.c	Sun Oct 10 19:11:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_event.c,v 1.129 2021/10/10 18:07:51 thorpej Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.130 2021/10/10 19:11:56 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2021 The NetBSD Foundation, Inc.
@@ -58,10 +58,12 @@
  * FreeBSD: src/sys/kern/kern_event.c,v 1.27 2001/07/05 17:10:44 rwatson Exp
  */
 
+#ifdef _KERNEL_OPT
 #include "opt_ddb.h"
+#endif /* _KERNEL_OPT */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.129 2021/10/10 18:07:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.130 2021/10/10 19:11:56 thorpej Exp $");
 
 #include 
 #include 



CVS commit: src/bin/echo

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 19:07:19 UTC 2021

Modified Files:
src/bin/echo: Makefile echo.c

Log Message:
echo: clean up, increase WARNS to 6

Lint can handle __COPYRIGHT and __RCSID, so there is no need to hide
them anymore.

Use proper type 'bool' for nflag, ensure correct types via lint's strict
bool mode.

Remove unnecessary call to exit(0); returning from main is equivalent
since C99.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/bin/echo/Makefile
cvs rdiff -u -r1.20 -r1.21 src/bin/echo/echo.c

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



CVS commit: src/bin/echo

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 19:07:19 UTC 2021

Modified Files:
src/bin/echo: Makefile echo.c

Log Message:
echo: clean up, increase WARNS to 6

Lint can handle __COPYRIGHT and __RCSID, so there is no need to hide
them anymore.

Use proper type 'bool' for nflag, ensure correct types via lint's strict
bool mode.

Remove unnecessary call to exit(0); returning from main is equivalent
since C99.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/bin/echo/Makefile
cvs rdiff -u -r1.20 -r1.21 src/bin/echo/echo.c

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

Modified files:

Index: src/bin/echo/Makefile
diff -u src/bin/echo/Makefile:1.8 src/bin/echo/Makefile:1.9
--- src/bin/echo/Makefile:1.8	Sun Jul 20 22:36:53 1997
+++ src/bin/echo/Makefile	Sun Oct 10 19:07:19 2021
@@ -1,6 +1,9 @@
-#	$NetBSD: Makefile,v 1.8 1997/07/20 22:36:53 christos Exp $
+#	$NetBSD: Makefile,v 1.9 2021/10/10 19:07:19 rillig Exp $
 #	@(#)Makefile	8.1 (Berkeley) 5/31/93
 
 PROG=	echo
 
+WARNS=		6
+LINTFLAGS+=	-T -w
+
 .include 

Index: src/bin/echo/echo.c
diff -u src/bin/echo/echo.c:1.20 src/bin/echo/echo.c:1.21
--- src/bin/echo/echo.c:1.20	Wed May 19 22:12:36 2021
+++ src/bin/echo/echo.c	Sun Oct 10 19:07:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: echo.c,v 1.20 2021/05/19 22:12:36 kre Exp $	*/
+/* $NetBSD: echo.c,v 1.21 2021/10/10 19:07:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -30,22 +30,19 @@
  */
 
 #include 
-#ifndef lint
 __COPYRIGHT(
 "@(#) Copyright (c) 1989, 1993\
  The Regents of the University of California.  All rights reserved.");
-#endif /* not lint */
 
-#ifndef lint
 #if 0
 static char sccsid[] = "@(#)echo.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: echo.c,v 1.20 2021/05/19 22:12:36 kre Exp $");
+__RCSID("$NetBSD: echo.c,v 1.21 2021/10/10 19:07:19 rillig Exp $");
 #endif
-#endif /* not lint */
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -54,29 +51,24 @@ __RCSID("$NetBSD: echo.c,v 1.20 2021/05/
 int
 main(int argc, char *argv[])
 {
-	int nflag;
+	bool nflag;
 
 	setprogname(argv[0]);
 	(void)setlocale(LC_ALL, "");
 
 	/* This utility may NOT do getopt(3) option parsing. */
-	if (*++argv && !strcmp(*argv, "-n")) {
+	nflag = *++argv != NULL && strcmp(*argv, "-n") == 0;
+	if (nflag)
 		++argv;
-		nflag = 1;
-	}
-	else
-		nflag = 0;
 
-	while (*argv) {
+	while (*argv != NULL) {
 		(void)printf("%s", *argv);
-		if (*++argv)
+		if (*++argv != NULL)
 			(void)putchar(' ');
 	}
-	if (nflag == 0)
+	if (!nflag)
 		(void)putchar('\n');
 	fflush(stdout);
 	if (ferror(stdout))
 		err(1, "write error");
-	exit(0);
-	/* NOTREACHED */
 }



CVS commit: src/bin/sh

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 18:46:25 UTC 2021

Modified Files:
src/bin/sh: jobs.c

Log Message:
sh: remove useless do-while-0 loop

28 years was more than enough for the useless 'continue' statement in
this do-while-0 "loop". Without the 'continue' statement, there is no
need for the "loop" anymore. The comment at its top was confusing since
the word 'while' suggested a loop, but there was none, so remove that as
well.

Pointed out by Tom Ivar Helbekkmo on source-changes-d.

No change to the resulting binary.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/bin/sh/jobs.c

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



CVS commit: src/bin/sh

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 18:46:25 UTC 2021

Modified Files:
src/bin/sh: jobs.c

Log Message:
sh: remove useless do-while-0 loop

28 years was more than enough for the useless 'continue' statement in
this do-while-0 "loop". Without the 'continue' statement, there is no
need for the "loop" anymore. The comment at its top was confusing since
the word 'while' suggested a loop, but there was none, so remove that as
well.

Pointed out by Tom Ivar Helbekkmo on source-changes-d.

No change to the resulting binary.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/bin/sh/jobs.c

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

Modified files:

Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.113 src/bin/sh/jobs.c:1.114
--- src/bin/sh/jobs.c:1.113	Sun Oct 10 08:35:34 2021
+++ src/bin/sh/jobs.c	Sun Oct 10 18:46:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: jobs.c,v 1.113 2021/10/10 08:35:34 rillig Exp $	*/
+/*	$NetBSD: jobs.c,v 1.114 2021/10/10 18:46:25 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)jobs.c	8.5 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: jobs.c,v 1.113 2021/10/10 08:35:34 rillig Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.114 2021/10/10 18:46:25 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -187,18 +187,16 @@ setjobctl(int on)
 		out2str("sh: Need FIOCLEX or FD_CLOEXEC to support job control");
 		goto out;
 #endif
-		do { /* while we are in the background */
-			if ((initialpgrp = tcgetpgrp(ttyfd)) < 0) {
+		if ((initialpgrp = tcgetpgrp(ttyfd)) < 0) {
  out:
-out2str("sh: can't access tty; job control turned off\n");
-mflag = 0;
-return;
-			}
-			if (initialpgrp == -1)
-initialpgrp = getpgrp();
-			else if (initialpgrp != getpgrp())
-killpg(0, SIGTTIN);
-		} while (0);
+			out2str("sh: can't access tty; job control turned off\n");
+			mflag = 0;
+			return;
+		}
+		if (initialpgrp == -1)
+			initialpgrp = getpgrp();
+		else if (initialpgrp != getpgrp())
+			killpg(0, SIGTTIN);
 
 #ifdef OLD_TTY_DRIVER
 		if (ioctl(ttyfd, TIOCGETD, (char *)&ldisc) < 0



CVS commit: src/tests/usr.bin/xlint/lint1

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 18:16:12 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: t_integration.sh
Added Files:
src/tests/usr.bin/xlint/lint1: gen-platforms.sh

Log Message:
tests/lint: remove duplicate platform, generate platforms list

It was an unreliable idea to extract the platform properties from the
targparam.h files manually, even if it was a one-time job. I still made
a mistake by accidentally marking aarch64 as schar, even though it is
uchar, plus I duplicated the line for powerpc64.

Remove the duplicate line, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/gen-platforms.sh
cvs rdiff -u -r1.72 -r1.73 src/tests/usr.bin/xlint/lint1/t_integration.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.72 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.73
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.72	Sun Oct 10 08:45:51 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Sun Oct 10 18:16:12 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.72 2021/10/10 08:45:51 skrll Exp $
+# $NetBSD: t_integration.sh,v 1.73 2021/10/10 18:16:12 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -52,7 +52,6 @@ configure_test_case()
 			platform["or1k"]	= "schar ilp32 int  ldbl-64"
 			platform["powerpc"]	= "uchar ilp32 int  ldbl-64"
 			platform["powerpc64"]	= "uchar lp64  long ldbl-64"
-			platform["powerpc64"]	= "uchar lp64  long ldbl-64"
 			platform["riscv32"]	= "schar ilp32 int  ldbl-64"
 			platform["riscv64"]	= "schar lp64  long ldbl-64"
 			platform["sh3"]		= "schar ilp32 int  ldbl-64"

Added files:

Index: src/tests/usr.bin/xlint/lint1/gen-platforms.sh
diff -u /dev/null src/tests/usr.bin/xlint/lint1/gen-platforms.sh:1.1
--- /dev/null	Sun Oct 10 18:16:12 2021
+++ src/tests/usr.bin/xlint/lint1/gen-platforms.sh	Sun Oct 10 18:16:12 2021
@@ -0,0 +1,52 @@
+#! /bin/sh
+# $NetBSD: gen-platforms.sh,v 1.1 2021/10/10 18:16:12 rillig Exp $
+
+#
+# Copyright (c) 2021 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# Regenerate the platforms list, to be used in t_integration.sh.
+
+set -eu
+
+exec 1>'gen-platforms.out'
+
+for file in ../../../../usr.bin/xlint/arch/*/targparam.h; do
+	platform=${file%/*}
+	platform=${platform##*/}
+
+	char=$(sed -n -E 's,.*"([su]char)\.h".*,\1,p' "$file")
+	ilp=$(sed -n -E 's,.*"(ilp32|lp64)\.h".*,\1,p' "$file")
+	size=$(awk '/#.*LONG$/ { l = "long" } /#.*INT$/ { i = "int" } END { print(i "" l) }' "$file")
+	ldbl=$(sed -n -E 's,^#.*LDOUBLE[^0-9]+([0-9]+)$,ldbl-\1,p' "$file")
+
+	if [ "$size" != "int" ] && [ "$size" != "long" ]; then
+		size=""	# mips
+	fi
+
+	case $platform in *) indent='\t';; *) indent='\t\t';; esac
+
+	printf '\t\t\t''platform["%s"]'"$indent"'= "%s %-5s %-4s %s"\n' \
+	"$platform" "$char" "$ilp" "$size" "$ldbl"
+done



CVS commit: src/tests/usr.bin/xlint/lint1

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 18:16:12 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: t_integration.sh
Added Files:
src/tests/usr.bin/xlint/lint1: gen-platforms.sh

Log Message:
tests/lint: remove duplicate platform, generate platforms list

It was an unreliable idea to extract the platform properties from the
targparam.h files manually, even if it was a one-time job. I still made
a mistake by accidentally marking aarch64 as schar, even though it is
uchar, plus I duplicated the line for powerpc64.

Remove the duplicate line, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/gen-platforms.sh
cvs rdiff -u -r1.72 -r1.73 src/tests/usr.bin/xlint/lint1/t_integration.sh

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



CVS commit: src/tests/kernel/kqueue

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 18:11:31 UTC 2021

Modified Files:
src/tests/kernel/kqueue: t_sig.c

Log Message:
The knotes for EVFILT_SIGNAL and EVFILT_PROC are maintained on a single
per-process list, and kern_event.c,v 1.129 has several KASSERT()s in
various code paths that process this list related to the mixing of these
two knote types.  This new unit test is designed specifically to exercise
those KASSERT()s and thus validate their assumptions.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/kernel/kqueue/t_sig.c

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

Modified files:

Index: src/tests/kernel/kqueue/t_sig.c
diff -u src/tests/kernel/kqueue/t_sig.c:1.3 src/tests/kernel/kqueue/t_sig.c:1.4
--- src/tests/kernel/kqueue/t_sig.c:1.3	Fri Jan 13 21:30:41 2017
+++ src/tests/kernel/kqueue/t_sig.c	Sun Oct 10 18:11:31 2021
@@ -1,7 +1,7 @@
-/* $NetBSD: t_sig.c,v 1.3 2017/01/13 21:30:41 christos Exp $ */
+/* $NetBSD: t_sig.c,v 1.4 2021/10/10 18:11:31 thorpej Exp $ */
 
 /*-
- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 2002, 2008, 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -32,7 +32,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sig.c,v 1.3 2017/01/13 21:30:41 christos Exp $");
+__RCSID("$NetBSD: t_sig.c,v 1.4 2021/10/10 18:11:31 thorpej Exp $");
 
 #include 
 #include 
@@ -125,9 +125,87 @@ ATF_TC_BODY(sig, tc)
 	(void)printf("sig: finished successfully\n");
 }
 
+/*
+ * This test case exercises code paths in the kernel that KASSERT()
+ * some assumptions about EVFILT_SIGNAL and EVFILT_PROC implementation
+ * details.
+ */
+ATF_TC(sig_and_proc);
+ATF_TC_HEAD(sig_and_proc, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Validates implementation detail assumptions about "
+	"EVFILT_SIGNAL and EVFILT_PROC");
+}
+ATF_TC_BODY(sig_and_proc, tc)
+{
+	struct kevent events[3];
+	pid_t pid;
+	int kq;
+
+	pid = fork();
+	ATF_REQUIRE(pid != -1);
+
+	if (pid == 0) {
+		/*
+		 * Child: create a kqueue and attach signal knotes
+		 * to curproc->p_klist.
+		 */
+		kq = kqueue();
+		ATF_REQUIRE(kq >= 0);
+
+		ATF_REQUIRE(signal(SIGUSR1, SIG_IGN) != SIG_ERR);
+		ATF_REQUIRE(signal(SIGUSR2, SIG_IGN) != SIG_ERR);
+
+		EV_SET(&events[0], SIGUSR1, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL);
+		EV_SET(&events[1], SIGUSR2, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL);
+
+		ATF_REQUIRE(kevent(kq, events, 2, &events[2], 1, NULL) == 1);
+		ATF_REQUIRE(events[2].filter == EVFILT_SIGNAL);
+		ATF_REQUIRE(events[2].ident == SIGUSR1);
+
+		/*
+		 * When we exit here, the kernel will close all of
+		 * its file descriptors (including our kq), which
+		 * will in turn remove the signal notes from
+		 * curproc->p_klist.
+		 *
+		 * Then, later on, the kernel will post a NOTE_EXIT
+		 * on our parent's kqueue using the proc note that
+		 * our parent attached to (our) curproc->p_klist.
+		 * That code path KASSERT()s that the signal knotes
+		 * have already been removed.
+		 */
+		_exit(0);
+	}
+
+	/*
+	 * Parent: create a kqueue and attach a proc note to
+	 * child->p_klist.
+	 */
+	kq = kqueue();
+	ATF_REQUIRE(kq >= 0);
+
+	EV_SET(&events[0], pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL);
+
+	ATF_REQUIRE(kevent(kq, events, 1, NULL, 0, NULL) == 0);
+
+	/* Ensure we never see stale data. */
+	memset(events, 0, sizeof(events));
+
+	/* Signal child to exit. */
+	ATF_REQUIRE(kill(pid, SIGUSR1) == 0);
+
+	ATF_REQUIRE(kevent(kq, NULL, 0, events, 1, NULL) == 1);
+	ATF_REQUIRE(events[0].filter == EVFILT_PROC);
+	ATF_REQUIRE(events[0].ident == (uintptr_t)pid);
+	ATF_REQUIRE(events[0].fflags = NOTE_EXIT);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, sig);
+	ATF_TP_ADD_TC(tp, sig_and_proc);
 
 	return atf_no_error();
 }



CVS commit: src/tests/kernel/kqueue

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 18:11:31 UTC 2021

Modified Files:
src/tests/kernel/kqueue: t_sig.c

Log Message:
The knotes for EVFILT_SIGNAL and EVFILT_PROC are maintained on a single
per-process list, and kern_event.c,v 1.129 has several KASSERT()s in
various code paths that process this list related to the mixing of these
two knote types.  This new unit test is designed specifically to exercise
those KASSERT()s and thus validate their assumptions.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/kernel/kqueue/t_sig.c

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



CVS commit: src/sys/ddb

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 18:08:12 UTC 2021

Modified Files:
src/sys/ddb: db_command.c

Log Message:
Add a "show kqueue " command.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/sys/ddb/db_command.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/ddb/db_command.c
diff -u src/sys/ddb/db_command.c:1.178 src/sys/ddb/db_command.c:1.179
--- src/sys/ddb/db_command.c:1.178	Sat Aug 21 23:00:31 2021
+++ src/sys/ddb/db_command.c	Sun Oct 10 18:08:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_command.c,v 1.178 2021/08/21 23:00:31 andvar Exp $	*/
+/*	$NetBSD: db_command.c,v 1.179 2021/10/10 18:08:12 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009, 2019
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.178 2021/08/21 23:00:31 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.179 2021/10/10 18:08:12 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -79,6 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_command.c
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -204,6 +205,7 @@ static void	db_show_all_freelists(db_exp
 static void	db_mount_print_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void	db_show_all_mount(db_expr_t, bool, db_expr_t, const char *);
 static void	db_mbuf_print_cmd(db_expr_t, bool, db_expr_t, const char *);
+static void	db_kqueue_print_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void	db_map_print_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void	db_namecache_print_cmd(db_expr_t, bool, db_expr_t,
 		const char *);
@@ -269,6 +271,8 @@ static const struct db_command db_show_c
 	{ DDB_ADD_CMD("lockstats",
 db_show_lockstats,	0,
 	"Print statistics of locks", NULL, NULL) },
+	{ DDB_ADD_CMD("kqueue",	db_kqueue_print_cmd,	0,
+	"Print the kqueue at address.", "[/f] address",NULL) },
 	{ DDB_ADD_CMD("map",	db_map_print_cmd,	0,
 	"Print the vm_map at address.", "[/f] address",NULL) },
 	{ DDB_ADD_CMD("mbuf",	db_mbuf_print_cmd,	0,NULL,NULL,
@@ -1014,6 +1018,28 @@ const char *modif)
 
 /*ARGSUSED*/
 static void
+db_kqueue_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
+const char *modif)
+{
+#ifdef _KERNEL
+	bool full = false;
+
+	if (modif[0] == 'f')
+		full = true;
+
+	if (have_addr == false) {
+		db_printf("%s: must specify kqueue address\n", __func__);
+		return;
+	}
+
+	kqueue_printit((struct kqueue *)(uintptr_t) addr, full, db_printf);
+#else
+	db_kernelonly();
+#endif	/* XXX CRASH(8) */
+}
+
+/*ARGSUSED*/
+static void
 db_map_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
 const char *modif)
 {



CVS commit: src/sys/ddb

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 18:08:12 UTC 2021

Modified Files:
src/sys/ddb: db_command.c

Log Message:
Add a "show kqueue " command.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/sys/ddb/db_command.c

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



CVS commit: src/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 18:07:52 UTC 2021

Modified Files:
src/sys/kern: kern_event.c kern_exec.c kern_exit.c kern_fork.c
src/sys/sys: event.h eventvar.h proc.h

Log Message:
Changes to make EVFILT_PROC MP-safe:

Because the locking protocol around processes is somewhat complex
compared to other events that can be posted on kqueues, introduce
new functions for posting NOTE_EXEC, NOTE_EXIT, and NOTE_FORK,
rather than just using the generic knote() function.  These functions
KASSERT() their locking expectations, and deal with other complexities
for each situation.

knote_proc_fork(), in particiular, needs to handle NOTE_TRACK, which
requires allocation of a new knote to attach to the child process.  We
don't want to be allocating memory while holding the parent's p_lock.
Furthermore, we also have to attach the tracking note to the child
process, which means we have to acquire the child's p_lock.

So, to handle all this, we introduce some additional synchronization
infrastructure around the 'knote' structure:

- Add the ability to mark a knote as being in a state of flux.  Knotes
  in this state are guaranteed not to be detached/deleted, thus allowing
  a code path drop other locks after putting a knote in this state.

- Code paths that wish to detach/delete a knote must first check if the
  knote is in-flux.  If so, they must wait for it to quiesce.  Because
  multiple threads of execution may attempt this concurrently, a mechanism
  exists for a single LWP to claim the detach responsibility; all other
  threads simply wait for the knote to disappear before they can make
  further progress.

- When kqueue_scan() encounters an in-flux knote, it simply treats the
  situation just like encountering another thread's queue marker -- wait
  for the flux to settle and continue on.

(The "in-flux knote" idea was inspired by FreeBSD, but this works differently
from their implementation, as the two kqueue implementations have diverged
quite a bit.)

knote_proc_fork() uses this infrastructure to implement NOTE_TRACK like so:

- Attempt to put the original tracking knote into a state of flux; if this
  fails (because the note has a detach pending), we skip all processing
  (the original process has lost interest, and we simply won the race).

- Once the note is in-flux, drop the kq and forking process's locks, and
  allocate 2 knotes: one to post the NOTE_CHILD event, and one to attach
  a new NOTE_TRACK to the child process.  Notably, we do NOT go through
  kqueue_register() to do this, but rather do all of the work directly
  and KASSERT() our assumptions; this allows us to directly control our
  interaction with locks.  All memory allocations here are performed with
  KM_NOSLEEP, in order to prevent holding the original knote in-flux
  indefinitely.

- Because the NOTE_TRACK use case adds knotes to kqueues through a
  sort of back-door mechanism, we must serialize with the closing of
  the destination kqueue's file descriptor, so steal another bit from
  the kq_count field to notify other threads that a kqueue is on its
  way out to prevent new knotes from being enqueued while the close
  path detaches them.

In addition to fixing EVFILT_PROC's reliance on KERNEL_LOCK, this also
fixes a long-standing bug whereby a NOTE_CHILD event could be dropped
if the child process exited before the interested process received the
NOTE_CHILD event (the same knote would be used to deliver the NOTE_EXIT
event, and would clobber the NOTE_CHILD's 'data' field).

Add a bunch of comments to explain what's going on in various critical
sections, and sprinkle additional KASSERT()s to validate assumptions
in several more locations.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/kern/kern_event.c
cvs rdiff -u -r1.509 -r1.510 src/sys/kern/kern_exec.c
cvs rdiff -u -r1.291 -r1.292 src/sys/kern/kern_exit.c
cvs rdiff -u -r1.226 -r1.227 src/sys/kern/kern_fork.c
cvs rdiff -u -r1.43 -r1.44 src/sys/sys/event.h
cvs rdiff -u -r1.9 -r1.10 src/sys/sys/eventvar.h
cvs rdiff -u -r1.368 -r1.369 src/sys/sys/proc.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/kern/kern_event.c
diff -u src/sys/kern/kern_event.c:1.128 src/sys/kern/kern_event.c:1.129
--- src/sys/kern/kern_event.c:1.128	Thu Sep 30 01:20:53 2021
+++ src/sys/kern/kern_event.c	Sun Oct 10 18:07:51 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: kern_event.c,v 1.128 2021/09/30 01:20:53 thorpej Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.129 2021/10/10 18:07:51 thorpej Exp $	*/
 
 /*-
- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2009, 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -58,8 +58,10 @@
  * FreeBSD: src/sys/kern/kern_event.c,v 1.27 2001/07/05 17:10:44 rwatson Exp
  */
 
+#include "opt_ddb.h"
+
 #in

CVS commit: src/sys

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 18:07:52 UTC 2021

Modified Files:
src/sys/kern: kern_event.c kern_exec.c kern_exit.c kern_fork.c
src/sys/sys: event.h eventvar.h proc.h

Log Message:
Changes to make EVFILT_PROC MP-safe:

Because the locking protocol around processes is somewhat complex
compared to other events that can be posted on kqueues, introduce
new functions for posting NOTE_EXEC, NOTE_EXIT, and NOTE_FORK,
rather than just using the generic knote() function.  These functions
KASSERT() their locking expectations, and deal with other complexities
for each situation.

knote_proc_fork(), in particiular, needs to handle NOTE_TRACK, which
requires allocation of a new knote to attach to the child process.  We
don't want to be allocating memory while holding the parent's p_lock.
Furthermore, we also have to attach the tracking note to the child
process, which means we have to acquire the child's p_lock.

So, to handle all this, we introduce some additional synchronization
infrastructure around the 'knote' structure:

- Add the ability to mark a knote as being in a state of flux.  Knotes
  in this state are guaranteed not to be detached/deleted, thus allowing
  a code path drop other locks after putting a knote in this state.

- Code paths that wish to detach/delete a knote must first check if the
  knote is in-flux.  If so, they must wait for it to quiesce.  Because
  multiple threads of execution may attempt this concurrently, a mechanism
  exists for a single LWP to claim the detach responsibility; all other
  threads simply wait for the knote to disappear before they can make
  further progress.

- When kqueue_scan() encounters an in-flux knote, it simply treats the
  situation just like encountering another thread's queue marker -- wait
  for the flux to settle and continue on.

(The "in-flux knote" idea was inspired by FreeBSD, but this works differently
from their implementation, as the two kqueue implementations have diverged
quite a bit.)

knote_proc_fork() uses this infrastructure to implement NOTE_TRACK like so:

- Attempt to put the original tracking knote into a state of flux; if this
  fails (because the note has a detach pending), we skip all processing
  (the original process has lost interest, and we simply won the race).

- Once the note is in-flux, drop the kq and forking process's locks, and
  allocate 2 knotes: one to post the NOTE_CHILD event, and one to attach
  a new NOTE_TRACK to the child process.  Notably, we do NOT go through
  kqueue_register() to do this, but rather do all of the work directly
  and KASSERT() our assumptions; this allows us to directly control our
  interaction with locks.  All memory allocations here are performed with
  KM_NOSLEEP, in order to prevent holding the original knote in-flux
  indefinitely.

- Because the NOTE_TRACK use case adds knotes to kqueues through a
  sort of back-door mechanism, we must serialize with the closing of
  the destination kqueue's file descriptor, so steal another bit from
  the kq_count field to notify other threads that a kqueue is on its
  way out to prevent new knotes from being enqueued while the close
  path detaches them.

In addition to fixing EVFILT_PROC's reliance on KERNEL_LOCK, this also
fixes a long-standing bug whereby a NOTE_CHILD event could be dropped
if the child process exited before the interested process received the
NOTE_CHILD event (the same knote would be used to deliver the NOTE_EXIT
event, and would clobber the NOTE_CHILD's 'data' field).

Add a bunch of comments to explain what's going on in various critical
sections, and sprinkle additional KASSERT()s to validate assumptions
in several more locations.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/kern/kern_event.c
cvs rdiff -u -r1.509 -r1.510 src/sys/kern/kern_exec.c
cvs rdiff -u -r1.291 -r1.292 src/sys/kern/kern_exit.c
cvs rdiff -u -r1.226 -r1.227 src/sys/kern/kern_fork.c
cvs rdiff -u -r1.43 -r1.44 src/sys/sys/event.h
cvs rdiff -u -r1.9 -r1.10 src/sys/sys/eventvar.h
cvs rdiff -u -r1.368 -r1.369 src/sys/sys/proc.h

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



CVS commit: src

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 17:47:39 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/kernel/kqueue: Makefile
Added Files:
src/tests/kernel/kqueue: t_scan.c

Log Message:
Add a test case for the race condition in PR kern/50094, modeled after
the Go run-time scenario described in the PR.


To generate a diff of this commit:
cvs rdiff -u -r1.363 -r1.364 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1134 -r1.1135 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.5 -r1.6 src/tests/kernel/kqueue/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/kernel/kqueue/t_scan.c

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

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.363 src/distrib/sets/lists/debug/mi:1.364
--- src/distrib/sets/lists/debug/mi:1.363	Sun Oct 10 17:43:15 2021
+++ src/distrib/sets/lists/debug/mi	Sun Oct 10 17:47:38 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.363 2021/10/10 17:43:15 thorpej Exp $
+# $NetBSD: mi,v 1.364 2021/10/10 17:47:38 thorpej Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -1765,6 +1765,7 @@
 ./usr/libdata/debug/usr/tests/kernel/kqueue/t_proc2.debug		tests-kernel-tests	debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/kernel/kqueue/t_proc3.debug		tests-kernel-tests	debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/kernel/kqueue/t_proc4.debug		tests-kernel-tests	debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/kqueue/t_scan.debug		tests-kernel-tests	debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/kernel/kqueue/t_sig.debug			tests-kernel-tests	debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/kernel/kqueue/t_vnode.debug		tests-kernel-tests	debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/kernel/kqueue/write/t_fifo.debug		tests-kernel-tests	debug,atf,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1134 src/distrib/sets/lists/tests/mi:1.1135
--- src/distrib/sets/lists/tests/mi:1.1134	Sun Oct 10 17:43:15 2021
+++ src/distrib/sets/lists/tests/mi	Sun Oct 10 17:47:38 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1134 2021/10/10 17:43:15 thorpej Exp $
+# $NetBSD: mi,v 1.1135 2021/10/10 17:47:38 thorpej Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2185,6 +2185,7 @@
 ./usr/tests/kernel/kqueue/t_proc2			tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/kqueue/t_proc3			tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/kqueue/t_proc4			tests-kernel-tests	compattestfile,atf
+./usr/tests/kernel/kqueue/t_scan			tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/kqueue/t_sigtests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/kqueue/t_vnode			tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/kqueue/writetests-kernel-tests	compattestfile,atf

Index: src/tests/kernel/kqueue/Makefile
diff -u src/tests/kernel/kqueue/Makefile:1.5 src/tests/kernel/kqueue/Makefile:1.6
--- src/tests/kernel/kqueue/Makefile:1.5	Fri Apr 29 07:12:34 2016
+++ src/tests/kernel/kqueue/Makefile	Sun Oct 10 17:47:39 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.5 2016/04/29 07:12:34 ryoon Exp $
+# $NetBSD: Makefile,v 1.6 2021/10/10 17:47:39 thorpej Exp $
 
 WARNS?=6
 NOMAN=		# defined
@@ -14,7 +14,11 @@ TESTS_C=	t_ioctl
 TESTS_C+=	t_proc1
 TESTS_C+=	t_proc2
 TESTS_C+=	t_proc3
+TESTS_C+=	t_proc4
+TESTS_C+=	t_scan
 TESTS_C+=	t_sig
 TESTS_C+=	t_vnode
 
+LDADD.t_scan+=	-lpthread
+
 .include 

Added files:

Index: src/tests/kernel/kqueue/t_scan.c
diff -u /dev/null src/tests/kernel/kqueue/t_scan.c:1.1
--- /dev/null	Sun Oct 10 17:47:39 2021
+++ src/tests/kernel/kqueue/t_scan.c	Sun Oct 10 17:47:39 2021
@@ -0,0 +1,117 @@
+/* $NetBSD: t_scan.c,v 1.1 2021/10/10 17:47:39 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR AN

CVS commit: src

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 17:47:39 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/kernel/kqueue: Makefile
Added Files:
src/tests/kernel/kqueue: t_scan.c

Log Message:
Add a test case for the race condition in PR kern/50094, modeled after
the Go run-time scenario described in the PR.


To generate a diff of this commit:
cvs rdiff -u -r1.363 -r1.364 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1134 -r1.1135 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.5 -r1.6 src/tests/kernel/kqueue/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/kernel/kqueue/t_scan.c

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



CVS commit: src

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 17:43:15 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
Added Files:
src/tests/kernel/kqueue: t_proc4.c

Log Message:
Add a test case to heavily exercise EVFILT_PROC + NOTE_TRACK.


To generate a diff of this commit:
cvs rdiff -u -r1.362 -r1.363 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1133 -r1.1134 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r0 -r1.1 src/tests/kernel/kqueue/t_proc4.c

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

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.362 src/distrib/sets/lists/debug/mi:1.363
--- src/distrib/sets/lists/debug/mi:1.362	Thu Sep 30 02:00:19 2021
+++ src/distrib/sets/lists/debug/mi	Sun Oct 10 17:43:15 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.362 2021/09/30 02:00:19 yamaguchi Exp $
+# $NetBSD: mi,v 1.363 2021/10/10 17:43:15 thorpej Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -1764,6 +1764,7 @@
 ./usr/libdata/debug/usr/tests/kernel/kqueue/t_proc1.debug		tests-kernel-tests	debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/kernel/kqueue/t_proc2.debug		tests-kernel-tests	debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/kernel/kqueue/t_proc3.debug		tests-kernel-tests	debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/kqueue/t_proc4.debug		tests-kernel-tests	debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/kernel/kqueue/t_sig.debug			tests-kernel-tests	debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/kernel/kqueue/t_vnode.debug		tests-kernel-tests	debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/kernel/kqueue/write/t_fifo.debug		tests-kernel-tests	debug,atf,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1133 src/distrib/sets/lists/tests/mi:1.1134
--- src/distrib/sets/lists/tests/mi:1.1133	Thu Oct  7 18:07:25 2021
+++ src/distrib/sets/lists/tests/mi	Sun Oct 10 17:43:15 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1133 2021/10/07 18:07:25 rillig Exp $
+# $NetBSD: mi,v 1.1134 2021/10/10 17:43:15 thorpej Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2184,6 +2184,7 @@
 ./usr/tests/kernel/kqueue/t_proc1			tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/kqueue/t_proc2			tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/kqueue/t_proc3			tests-kernel-tests	compattestfile,atf
+./usr/tests/kernel/kqueue/t_proc4			tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/kqueue/t_sigtests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/kqueue/t_vnode			tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/kqueue/writetests-kernel-tests	compattestfile,atf

Added files:

Index: src/tests/kernel/kqueue/t_proc4.c
diff -u /dev/null src/tests/kernel/kqueue/t_proc4.c:1.1
--- /dev/null	Sun Oct 10 17:43:15 2021
+++ src/tests/kernel/kqueue/t_proc4.c	Sun Oct 10 17:43:15 2021
@@ -0,0 +1,170 @@
+/* $NetBSD: t_proc4.c,v 1.1 2021/10/10 17:43:15 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__RCSID("$NetBSD: t_proc4.c,v 1.1 2021/10/10 17:43:15 thorpej Exp $");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/* 10 children each create 10 grandchildren. */
+#define	TOTAL_CHILDREN		10
+#defin

CVS commit: src

2021-10-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Oct 10 17:43:15 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
Added Files:
src/tests/kernel/kqueue: t_proc4.c

Log Message:
Add a test case to heavily exercise EVFILT_PROC + NOTE_TRACK.


To generate a diff of this commit:
cvs rdiff -u -r1.362 -r1.363 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1133 -r1.1134 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r0 -r1.1 src/tests/kernel/kqueue/t_proc4.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

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 10 14:52:30 UTC 2021

Modified Files:
src/sys/dev: efi.c

Log Message:
UEFI calls can modify size inputs, so stash them for use with kmem_free


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/efi.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/efi.c
diff -u src/sys/dev/efi.c:1.1 src/sys/dev/efi.c:1.2
--- src/sys/dev/efi.c:1.1	Sun Oct 10 13:03:09 2021
+++ src/sys/dev/efi.c	Sun Oct 10 14:52:30 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efi.c,v 1.1 2021/10/10 13:03:09 jmcneill Exp $ */
+/* $NetBSD: efi.c,v 1.2 2021/10/10 14:52:30 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2021 Jared McNeill 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.1 2021/10/10 13:03:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.2 2021/10/10 14:52:30 jmcneill Exp $");
 
 #include 
 #include 
@@ -151,6 +151,7 @@ efi_ioctl_var_get(struct efi_var_ioc *va
 {
 	uint16_t *namebuf;
 	void *databuf = NULL;
+	size_t datasize;
 	efi_status status;
 	int error;
 
@@ -171,9 +172,10 @@ efi_ioctl_var_get(struct efi_var_ioc *va
 		error = EINVAL;
 		goto done;
 	}
-	if (var->datasize != 0) {
-		databuf = kmem_alloc(var->datasize, KM_SLEEP);
-		error = copyin(var->data, databuf, var->datasize);
+	datasize = var->datasize;
+	if (datasize != 0) {
+		databuf = kmem_alloc(datasize, KM_SLEEP);
+		error = copyin(var->data, databuf, datasize);
 		if (error != 0) {
 			goto done;
 		}
@@ -194,7 +196,7 @@ efi_ioctl_var_get(struct efi_var_ioc *va
 done:
 	kmem_free(namebuf, var->namesize);
 	if (databuf != NULL) {
-		kmem_free(databuf, var->datasize);
+		kmem_free(databuf, datasize);
 	}
 	return error;
 }
@@ -204,6 +206,7 @@ efi_ioctl_var_next(struct efi_var_ioc *v
 {
 	efi_status status;
 	uint16_t *namebuf;
+	size_t namesize;
 	int error;
 
 	if (var->name == NULL || var->namesize == 0) {
@@ -213,8 +216,9 @@ efi_ioctl_var_next(struct efi_var_ioc *v
 		return ENOMEM;
 	}
 
-	namebuf = kmem_alloc(var->namesize, KM_SLEEP);
-	error = copyin(var->name, namebuf, var->namesize);
+	namesize = var->namesize;
+	namebuf = kmem_alloc(namesize, KM_SLEEP);
+	error = copyin(var->name, namebuf, namesize);
 	if (error != 0) {
 		goto done;
 	}
@@ -231,7 +235,7 @@ efi_ioctl_var_next(struct efi_var_ioc *v
 	}
 
 done:
-	kmem_free(namebuf, var->namesize);
+	kmem_free(namebuf, namesize);
 	return error;
 }
 



CVS commit: src/sys/dev

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 10 14:52:30 UTC 2021

Modified Files:
src/sys/dev: efi.c

Log Message:
UEFI calls can modify size inputs, so stash them for use with kmem_free


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

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



Re: CVS commit: src/sys/dev/wscons

2021-10-10 Thread Izumi Tsutsui
> Module Name:  src
> Committed By: nia
> Date: Tue Sep 28 06:14:28 UTC 2021
> 
> Modified Files:
>   src/sys/dev/wscons: wsconsio.h wsmouse.c wsmousevar.h
> 
> Log Message:
> wsmouse: add support for "precision scrolling" events and (GET|SET)PARAMS

Could you please also update wsmouse(4) and wsmouse(9) man pages?
Even the current version lacks various info (especially about ioctl(2))
but no reason to make it worse.

Thanks,
---
Izumi Tsutsui


CVS commit: src

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 10 13:03:10 UTC 2021

Modified Files:
src/distrib/sets/lists/comp: mi
src/etc: MAKEDEV.tmpl
src/etc/etc.evbarm: MAKEDEV.conf
src/sys/arch/arm/arm: efi_runtime.c efi_runtime.h
src/sys/arch/arm/fdt: arm_fdt.c
src/sys/arch/evbarm/conf: GENERIC64
src/sys/conf: majors
src/sys/dev: files.dev
src/sys/sys: Makefile
Added Files:
src/sys/dev: efi.c efivar.h
src/sys/sys: efiio.h

Log Message:
efi: Add /dev/efi character device

Introduce a /dev/efi character device that provides a means for accessing
UEFI RT variable services from userland. Compatible with the FreeBSD ioctl
interface for ease of porting their libefivar and associated tools.

The ioctl interface is defined in sys/efiio.h.

To enable support for this on an arch, the kernel needs `pseudo-device efi`
and the MD EFI implementation needs to register its backend by calling
efi_ops_register(). This commit includes an implementation for Arm.


To generate a diff of this commit:
cvs rdiff -u -r1.2395 -r1.2396 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.224 -r1.225 src/etc/MAKEDEV.tmpl
cvs rdiff -u -r1.21 -r1.22 src/etc/etc.evbarm/MAKEDEV.conf
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/arm/efi_runtime.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/arm/efi_runtime.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/fdt/arm_fdt.c
cvs rdiff -u -r1.186 -r1.187 src/sys/arch/evbarm/conf/GENERIC64
cvs rdiff -u -r1.98 -r1.99 src/sys/conf/majors
cvs rdiff -u -r0 -r1.1 src/sys/dev/efi.c src/sys/dev/efivar.h
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/files.dev
cvs rdiff -u -r1.179 -r1.180 src/sys/sys/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/sys/efiio.h

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

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2395 src/distrib/sets/lists/comp/mi:1.2396
--- src/distrib/sets/lists/comp/mi:1.2395	Thu Sep 30 02:00:19 2021
+++ src/distrib/sets/lists/comp/mi	Sun Oct 10 13:03:09 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2395 2021/09/30 02:00:19 yamaguchi Exp $
+#	$NetBSD: mi,v 1.2396 2021/10/10 13:03:09 jmcneill Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -3273,6 +3273,7 @@
 ./usr/include/sys/domain.h			comp-c-include
 ./usr/include/sys/drvctlio.h			comp-c-include
 ./usr/include/sys/dvdio.h			comp-c-include
+./usr/include/sys/efiio.h			comp-c-include
 ./usr/include/sys/elfdefinitions.h		comp-c-include
 ./usr/include/sys/endian.h			comp-c-include
 ./usr/include/sys/envsys.h			comp-c-include

Index: src/etc/MAKEDEV.tmpl
diff -u src/etc/MAKEDEV.tmpl:1.224 src/etc/MAKEDEV.tmpl:1.225
--- src/etc/MAKEDEV.tmpl:1.224	Sat Jul 24 11:39:18 2021
+++ src/etc/MAKEDEV.tmpl	Sun Oct 10 13:03:08 2021
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#	$NetBSD: MAKEDEV.tmpl,v 1.224 2021/07/24 11:39:18 jmcneill Exp $
+#	$NetBSD: MAKEDEV.tmpl,v 1.225 2021/10/10 13:03:08 jmcneill Exp $
 #
 # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -2244,6 +2244,10 @@ smbios)
 	mkdev smbios c %smbios_chr% 0
 	;;
 
+efi)
+	mkdev efi c %efi_chr% 0 660
+	;;
+
 midevend)
 %MI_DEVICES_END%
 local)

Index: src/etc/etc.evbarm/MAKEDEV.conf
diff -u src/etc/etc.evbarm/MAKEDEV.conf:1.21 src/etc/etc.evbarm/MAKEDEV.conf:1.22
--- src/etc/etc.evbarm/MAKEDEV.conf:1.21	Tue Nov 10 08:52:36 2020
+++ src/etc/etc.evbarm/MAKEDEV.conf	Sun Oct 10 13:03:09 2021
@@ -1,4 +1,4 @@
-# $NetBSD: MAKEDEV.conf,v 1.21 2020/11/10 08:52:36 rin Exp $
+# $NetBSD: MAKEDEV.conf,v 1.22 2021/10/10 13:03:09 jmcneill Exp $
 
 all_md)
 	makedev wscons fd0 fd1 wd0 wd1 wd2 wd3 sd0 sd1 sd2 sd3
@@ -27,6 +27,7 @@ all_md)
 	makedev spiflash0
 	makedev bpf
 	makedev openfirm
+	makedev acpi smbios efi
 	;;
 
 ramdisk|floppy)

Index: src/sys/arch/arm/arm/efi_runtime.c
diff -u src/sys/arch/arm/arm/efi_runtime.c:1.5 src/sys/arch/arm/arm/efi_runtime.c:1.6
--- src/sys/arch/arm/arm/efi_runtime.c:1.5	Fri Dec 18 07:40:27 2020
+++ src/sys/arch/arm/arm/efi_runtime.c	Sun Oct 10 13:03:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efi_runtime.c,v 1.5 2020/12/18 07:40:27 skrll Exp $ */
+/* $NetBSD: efi_runtime.c,v 1.6 2021/10/10 13:03:09 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -29,8 +29,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "efi.h"
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi_runtime.c,v 1.5 2020/12/18 07:40:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi_runtime.c,v 1.6 2021/10/10 13:03:09 jmcneill Exp $");
 
 #include 
 #include 
@@ -38,12 +40,33 @@ __KERNEL_RCSID(0, "$NetBSD: efi_runtime.
 
 #include 
 
+#include 
+
 #include 
 
+#ifdef _LP64
+#define	EFIERR(x)	(0x8000 | x)
+#else
+#define	EFIERR(x)	(0x8000 | x)
+#endif
+
+#define	EFI_UNSUPPORTED		EFIERR(3)
+#define	EFI_DEVICE_ERROR	EFIERR(7)
+
 static kmutex_t efi_lock;
 
 s

CVS commit: src

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 10 13:03:10 UTC 2021

Modified Files:
src/distrib/sets/lists/comp: mi
src/etc: MAKEDEV.tmpl
src/etc/etc.evbarm: MAKEDEV.conf
src/sys/arch/arm/arm: efi_runtime.c efi_runtime.h
src/sys/arch/arm/fdt: arm_fdt.c
src/sys/arch/evbarm/conf: GENERIC64
src/sys/conf: majors
src/sys/dev: files.dev
src/sys/sys: Makefile
Added Files:
src/sys/dev: efi.c efivar.h
src/sys/sys: efiio.h

Log Message:
efi: Add /dev/efi character device

Introduce a /dev/efi character device that provides a means for accessing
UEFI RT variable services from userland. Compatible with the FreeBSD ioctl
interface for ease of porting their libefivar and associated tools.

The ioctl interface is defined in sys/efiio.h.

To enable support for this on an arch, the kernel needs `pseudo-device efi`
and the MD EFI implementation needs to register its backend by calling
efi_ops_register(). This commit includes an implementation for Arm.


To generate a diff of this commit:
cvs rdiff -u -r1.2395 -r1.2396 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.224 -r1.225 src/etc/MAKEDEV.tmpl
cvs rdiff -u -r1.21 -r1.22 src/etc/etc.evbarm/MAKEDEV.conf
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/arm/efi_runtime.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/arm/efi_runtime.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/fdt/arm_fdt.c
cvs rdiff -u -r1.186 -r1.187 src/sys/arch/evbarm/conf/GENERIC64
cvs rdiff -u -r1.98 -r1.99 src/sys/conf/majors
cvs rdiff -u -r0 -r1.1 src/sys/dev/efi.c src/sys/dev/efivar.h
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/files.dev
cvs rdiff -u -r1.179 -r1.180 src/sys/sys/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/sys/efiio.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/audio

2021-10-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 10 11:21:05 UTC 2021

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(9): Issue pserialize_perform outside sc_lock in audiodetach.

Breaks another deadlock between sc_lock and high-priority xcalls at
softint serial.  With any luck, this should be the last such softint
deadlock in audio!


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/dev/audio/audio.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.109 src/sys/dev/audio/audio.c:1.110
--- src/sys/dev/audio/audio.c:1.109	Sun Oct 10 11:20:29 2021
+++ src/sys/dev/audio/audio.c	Sun Oct 10 11:21:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.109 2021/10/10 11:20:29 riastradh Exp $	*/
+/*	$NetBSD: audio.c,v 1.110 2021/10/10 11:21:05 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.109 2021/10/10 11:20:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.110 2021/10/10 11:21:05 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1322,6 +1322,7 @@ audiodetach(device_t self, int flags)
 	SLIST_FOREACH(file, &sc->sc_files, entry) {
 		atomic_store_relaxed(&file->dying, true);
 	}
+	mutex_exit(sc->sc_lock);
 
 	/*
 	 * Wait for existing users to drain.
@@ -1331,7 +1332,6 @@ audiodetach(device_t self, int flags)
 	 *   be psref_released.
 	 */
 	pserialize_perform(sc->sc_psz);
-	mutex_exit(sc->sc_lock);
 	psref_target_destroy(&sc->sc_psref, audio_psref_class);
 
 	/*



CVS commit: src/sys/dev/audio

2021-10-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 10 11:21:05 UTC 2021

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(9): Issue pserialize_perform outside sc_lock in audiodetach.

Breaks another deadlock between sc_lock and high-priority xcalls at
softint serial.  With any luck, this should be the last such softint
deadlock in audio!


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

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



CVS commit: src

2021-10-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 10 11:20:47 UTC 2021

Modified Files:
src/share/man/man9: pserialize.9
src/sys/kern: subr_pserialize.c

Log Message:
pserialize(9): Lift rule that pserialize_perform be serialized.

There may have been a technical reason for this back when we were
following the expired passive serialization patent to the letter, but
no more -- and this is a real burden for some applications.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/share/man/man9/pserialize.9
cvs rdiff -u -r1.17 -r1.18 src/sys/kern/subr_pserialize.c

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

Modified files:

Index: src/share/man/man9/pserialize.9
diff -u src/share/man/man9/pserialize.9:1.13 src/share/man/man9/pserialize.9:1.14
--- src/share/man/man9/pserialize.9:1.13	Mon Jul  3 21:28:48 2017
+++ src/share/man/man9/pserialize.9	Sun Oct 10 11:20:46 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pserialize.9,v 1.13 2017/07/03 21:28:48 wiz Exp $
+.\"	$NetBSD: pserialize.9,v 1.14 2021/10/10 11:20:46 riastradh Exp $
 .\"
 .\" Copyright (c) 2011 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -67,9 +67,10 @@ Takes the IPL value returned by
 .It Fn pserialize_perform
 Perform the passive serialization on the writer side.
 Passing of this function ensures that no readers are in action.
-Writers must be additionally serialized with a separate mechanism,
-e.g.
-.Xr mutex 9 .
+Writers are typically additionally serialized with a separate
+mechanism, e.g.
+.Xr mutex 9 ,
+to remove objects used by readers from a published list.
 Operation blocks and it may only be performed from thread context.
 .El
 .\" -
@@ -152,14 +153,15 @@ readers:
 			break;
 		}
 	}
+	mutex_exit(&frobbotzim.lock);
+
 	/*
 	 * Wait for all existing readers to complete.  New readers will
 	 * not see f because the list no longer points to it.
 	 */
 	pserialize_perform(frobbotzim.psz);
-	/* Now nobody else can be touching f, so it is safe to free.  */
-	mutex_exit(&frobbotzim.lock);
 
+	/* Now nobody else can be touching f, so it is safe to free.  */
 	if (f != NULL)
 		pool_put(&frotz_pool, f);
 .Ed

Index: src/sys/kern/subr_pserialize.c
diff -u src/sys/kern/subr_pserialize.c:1.17 src/sys/kern/subr_pserialize.c:1.18
--- src/sys/kern/subr_pserialize.c:1.17	Thu Dec  5 03:21:29 2019
+++ src/sys/kern/subr_pserialize.c	Sun Oct 10 11:20:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pserialize.c,v 1.17 2019/12/05 03:21:29 riastradh Exp $	*/
+/*	$NetBSD: subr_pserialize.c,v 1.18 2021/10/10 11:20:46 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.17 2019/12/05 03:21:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.18 2021/10/10 11:20:46 riastradh Exp $");
 
 #include 
 #include 
@@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_pserial
 #include 
 
 struct pserialize {
-	lwp_t *			psz_owner;
+	char			psz_dummy;
 };
 
 static kmutex_t			psz_lock	__cacheline_aligned;
@@ -86,16 +86,13 @@ void
 pserialize_destroy(pserialize_t psz)
 {
 
-	KASSERT(psz->psz_owner == NULL);
 	kmem_free(psz, sizeof(*psz));
 }
 
 /*
  * pserialize_perform:
  *
- *	Perform the write side of passive serialization.  This operation
- *	MUST be serialized at a caller level (e.g. with a mutex or by a
- *	single-threaded use).
+ *	Perform the write side of passive serialization.
  */
 void
 pserialize_perform(pserialize_t psz)
@@ -107,22 +104,17 @@ pserialize_perform(pserialize_t psz)
 	if (__predict_false(panicstr != NULL)) {
 		return;
 	}
-	KASSERT(psz->psz_owner == NULL);
 
 	if (__predict_false(mp_online == false)) {
 		psz_ev_excl.ev_count++;
 		return;
 	}
 
-	psz->psz_owner = curlwp;
-
 	/*
 	 * Broadcast a NOP to all CPUs and wait until all of them complete.
 	 */
 	xc_barrier(XC_HIGHPRI);
 
-	KASSERT(psz->psz_owner == curlwp);
-	psz->psz_owner = NULL;
 	mutex_enter(&psz_lock);
 	psz_ev_excl.ev_count++;
 	mutex_exit(&psz_lock);



CVS commit: src

2021-10-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 10 11:20:47 UTC 2021

Modified Files:
src/share/man/man9: pserialize.9
src/sys/kern: subr_pserialize.c

Log Message:
pserialize(9): Lift rule that pserialize_perform be serialized.

There may have been a technical reason for this back when we were
following the expired passive serialization patent to the letter, but
no more -- and this is a real burden for some applications.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/share/man/man9/pserialize.9
cvs rdiff -u -r1.17 -r1.18 src/sys/kern/subr_pserialize.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/audio

2021-10-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 10 11:20:29 UTC 2021

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(9): Call hw_if->getdev without sc_lock.

Holding sc_lock is not necessary -- I reviewed all ~70 cases in-tree,
and none of them rely on state protected by sc_lock.  Essentially
everything just copies from static data or data initialized at attach
time.

(Exceptions: tms320av110.c issues a bus_space_read_1, but I don't see
any reason why that needs to be serialized; and uaudio.c reads from
sc_dying, but that's not necessary and also not protected by sc_lock
anyway.)

Holding sc_lock is harmful because at least hdafg(4) can trigger module
autoload that leads to pserialize_perform, which waits for logic to run
at softint serial on all CPUs; at the same time, audio_softintr_rd/wr
run at softint serial and take sc_lock, so this leads to deadlock.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/dev/audio/audio.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.108 src/sys/dev/audio/audio.c:1.109
--- src/sys/dev/audio/audio.c:1.108	Sun Sep 26 01:16:08 2021
+++ src/sys/dev/audio/audio.c	Sun Oct 10 11:20:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.108 2021/09/26 01:16:08 thorpej Exp $	*/
+/*	$NetBSD: audio.c,v 1.109 2021/10/10 11:20:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -114,7 +114,7 @@
  *	halt_output 		x	x +
  *	halt_input 		x	x +
  *	speaker_ctl 		x	x
- *	getdev 			-	x
+ *	getdev 			-	-
  *	set_port 		-	x +
  *	get_port 		-	x +
  *	query_devinfo 		-	x
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.108 2021/09/26 01:16:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.109 2021/10/10 11:20:29 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -3113,9 +3113,7 @@ audio_ioctl(dev_t dev, struct audio_soft
 		break;
 
 	case AUDIO_GETDEV:
-		mutex_enter(sc->sc_lock);
 		error = sc->hw_if->getdev(sc->hw_hdl, (audio_device_t *)addr);
-		mutex_exit(sc->sc_lock);
 		break;
 
 	case AUDIO_GETENC:
@@ -8291,9 +8289,7 @@ mixer_ioctl(struct audio_softc *sc, u_lo
 
 	case AUDIO_GETDEV:
 		TRACE(2, "AUDIO_GETDEV");
-		mutex_enter(sc->sc_lock);
 		error = sc->hw_if->getdev(sc->hw_hdl, (audio_device_t *)addr);
-		mutex_exit(sc->sc_lock);
 		break;
 
 	case AUDIO_MIXER_DEVINFO:



CVS commit: src/sys/dev/audio

2021-10-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 10 11:20:29 UTC 2021

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(9): Call hw_if->getdev without sc_lock.

Holding sc_lock is not necessary -- I reviewed all ~70 cases in-tree,
and none of them rely on state protected by sc_lock.  Essentially
everything just copies from static data or data initialized at attach
time.

(Exceptions: tms320av110.c issues a bus_space_read_1, but I don't see
any reason why that needs to be serialized; and uaudio.c reads from
sc_dying, but that's not necessary and also not protected by sc_lock
anyway.)

Holding sc_lock is harmful because at least hdafg(4) can trigger module
autoload that leads to pserialize_perform, which waits for logic to run
at softint serial on all CPUs; at the same time, audio_softintr_rd/wr
run at softint serial and take sc_lock, so this leads to deadlock.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/dev/audio/audio.c

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



Re: CVS commit: src/bin/sh

2021-10-10 Thread Tom Ivar Helbekkmo
Roland Illig  writes:

> Anyway, the code in question was more verbose than necessary, so I made
> it simpler. I also experimented with replacing the switch with a single
> if statement, but that would have become too dense and thus difficult to
> decipher.

Yes, the code in exec.c looks much better now.  The do .. while (0)
construct in jobs.c, however, looks like it could be improved by
removing the 'do' and 'while (0)' lines altogether, including the
misleading comment on the 'do' line.  That would also pull the goto
target 'out' one level up, making its context less confusing.

-tih
-- 
Most people who graduate with CS degrees don't understand the significance
of Lisp.  Lisp is the most important idea in computer science.  --Alan Kay


CVS commit: src/tests/usr.bin/xlint/lint1

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 09:17:25 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_323.c msg_323.exp

Log Message:
tests/lint: add more examples for continue in do-while-0


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_323.c \
src/tests/usr.bin/xlint/lint1/msg_323.exp

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



CVS commit: src/tests/usr.bin/xlint/lint1

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 09:17:25 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_323.c msg_323.exp

Log Message:
tests/lint: add more examples for continue in do-while-0


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_323.c \
src/tests/usr.bin/xlint/lint1/msg_323.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_323.c
diff -u src/tests/usr.bin/xlint/lint1/msg_323.c:1.3 src/tests/usr.bin/xlint/lint1/msg_323.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_323.c:1.3	Sat Oct  9 21:25:39 2021
+++ src/tests/usr.bin/xlint/lint1/msg_323.c	Sun Oct 10 09:17:24 2021
@@ -1,11 +1,35 @@
-/*	$NetBSD: msg_323.c,v 1.3 2021/10/09 21:25:39 rillig Exp $	*/
+/*	$NetBSD: msg_323.c,v 1.4 2021/10/10 09:17:24 rillig Exp $	*/
 # 3 "msg_323.c"
 
 // Test for message: continue in 'do ... while (0)' loop [323]
+
 void println(const char *);
 
+/*
+ * In simple cases of a do-while-0 loop, the statements 'break' and
+ * 'continue' have the same effect, and 'break' is much more common.
+ *
+ * This is also covered by Clang-Tidy.
+ */
+void
+simple_case(const char *p)
+{
+	do {
+		if (p[0] == '+')
+			break;
+		if (p[1] == '-')
+			continue;
+		println("no sign");
+	/* expect+1: error: continue in 'do ... while (0)' loop [323] */
+	} while (0);
+}
+
+/*
+ * If there is a 'switch' statement inside the do-while-0 loop, the 'break'
+ * statement is tied to the 'switch' statement instead of the loop.
+ */
 void
-example(const char *p)
+nested_switch(const char *p)
 {
 	do {
 		switch (*p) {
@@ -19,3 +43,18 @@ example(const char *p)
 	/* expect+1: error: continue in 'do ... while (0)' loop [323] */
 	} while (0);
 }
+
+/*
+ * In a nested loop, the 'continue' statement is bound to the inner loop,
+ * thus no warning.
+ */
+void
+nested_for(void)
+{
+	do {
+		for (int i = 0; i < 6; i++) {
+			if (i < 3)
+continue;
+		}
+	} while (0);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_323.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_323.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_323.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_323.exp:1.3	Sat Oct  9 21:25:39 2021
+++ src/tests/usr.bin/xlint/lint1/msg_323.exp	Sun Oct 10 09:17:24 2021
@@ -1 +1,2 @@
-msg_323.c(20): error: continue in 'do ... while (0)' loop [323]
+msg_323.c(24): error: continue in 'do ... while (0)' loop [323]
+msg_323.c(44): error: continue in 'do ... while (0)' loop [323]



Re: CVS commit: src/bin/sh

2021-10-10 Thread Roland Illig
Am 10.10.2021 um 08:40 schrieb Tom Ivar Helbekkmo:
> Roland Illig  writes:
>
>> sh: ignore lint error about 'continue' in 'do while' loop
>>
>> exec.c(575): error: continue in 'do ... while (0)' loop [323]
>> jobs.c(203): error: continue in 'do ... while (0)' loop [323]
>>
>> It is certainly a rarely used feature, I saw it the first time today
>> and I don't see why a 'continue' statement in a 'do while' loop should
>> be an error.
>
> The only reason I can think of for using a 'do ... while (0)' construct
> outside of a '#define' is to have a block that's executed once, but that
> you can break out of without having to use 'goto'.  When you do this,
> the keywords 'break' and 'continue' both break out of the block.  I
> guess what lint is saying here is that because of this, you should use
> 'break', and not 'continue', to make it explicit what's happening.

Perfect guess, that's exactly the reason, as stated in
https://github.com/NetBSD/src/commit/d4d6980a4bb5db5188b919db from
2008-07-25.

At that time, the test suite for lint didn't contain a test for a
do-while-0 loop containing a switch statement containing a continue
statement, and this case where continue is actually different from break
was probably not on the author's mind.

I had not looked up the history of the message yesterday since I assumed
this error message had been there from the beginning. I should have
known the message ID 323 better since that looks really high. Oh well,
on a second look it's not that high either since even in 1995 there were
already the messages from 0 to 309.

Anyway, the code in question was more verbose than necessary, so I made
it simpler. I also experimented with replacing the switch with a single
if statement, but that would have become too dense and thus difficult to
decipher.

Roland


CVS commit: src/sys/arch/aarch64/aarch64

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 08:59:45 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: idle_machdep.S

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/idle_machdep.S

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/aarch64/aarch64/idle_machdep.S
diff -u src/sys/arch/aarch64/aarch64/idle_machdep.S:1.10 src/sys/arch/aarch64/aarch64/idle_machdep.S:1.11
--- src/sys/arch/aarch64/aarch64/idle_machdep.S:1.10	Mon Aug 30 22:28:50 2021
+++ src/sys/arch/aarch64/aarch64/idle_machdep.S	Sun Oct 10 08:59:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: idle_machdep.S,v 1.10 2021/08/30 22:28:50 jmcneill Exp $ */
+/* $NetBSD: idle_machdep.S,v 1.11 2021/10/10 08:59:45 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: idle_machdep.S,v 1.10 2021/08/30 22:28:50 jmcneill Exp $");
+RCSID("$NetBSD: idle_machdep.S,v 1.11 2021/10/10 08:59:45 skrll Exp $");
 
 #ifdef ARM_INTR_IMPL
 #include ARM_INTR_IMPL
@@ -55,7 +55,7 @@ ENTRY(cpu_idle)
 	/*
 	 * hardware interrupt -> trap handler -> interrupt handler
 	 */
-	dsb sy
+	dsb	sy
 	wfi
 
 #else /* LAZY_CPUIDLE */
@@ -94,7 +94,7 @@ ENTRY(cpu_idle)
 	 */
 	str	w2, [x28, #CI_INTR_DEPTH]	/* ci->ci_intr_depth = 1 */
 
-	dsb sy
+	dsb	sy
 	wfi
 	bl	ARM_IRQ_HANDLER			/* irqhandler(trapframe) */
 1:



CVS commit: src/sys/arch/aarch64/aarch64

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 08:59:45 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: idle_machdep.S

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/idle_machdep.S

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



CVS commit: src/tests/usr.bin/xlint/lint1

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 08:45:52 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: t_integration.sh

Log Message:
aarch64 has unsigned char


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/tests/usr.bin/xlint/lint1/t_integration.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.71 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.72
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.71	Sun Sep 26 03:17:59 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Sun Oct 10 08:45:51 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.71 2021/09/26 03:17:59 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.72 2021/10/10 08:45:51 skrll Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -37,7 +37,7 @@ configure_test_case()
 	awk='
 		BEGIN {
 			# see usr.bin/xlint/arch/*/targparam.h
-			platform["aarch64"]	= "schar lp64  long ldbl-128"
+			platform["aarch64"]	= "uchar lp64  long ldbl-128"
 			platform["alpha"]	= "schar lp64  long ldbl-64"
 			platform["arm"]		= "uchar ilp32 long ldbl-64"
 			platform["coldfire"]	= "schar ilp32 int  ldbl-64"



CVS commit: src/tests/usr.bin/xlint/lint1

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 08:45:52 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: t_integration.sh

Log Message:
aarch64 has unsigned char


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/tests/usr.bin/xlint/lint1/t_integration.sh

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



CVS commit: src/doc

2021-10-10 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun Oct 10 08:42:43 UTC 2021

Modified Files:
src/doc: CHANGES

Log Message:
doc: wscons changes


To generate a diff of this commit:
cvs rdiff -u -r1.2836 -r1.2837 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2836 src/doc/CHANGES:1.2837
--- src/doc/CHANGES:1.2836	Fri Oct  1 22:42:28 2021
+++ src/doc/CHANGES	Sun Oct 10 08:42:43 2021
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2836 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2837 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -425,9 +425,13 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	compat_linux: Added eventfd, timerfd, POSIX timers, and preadv() /
 		pwritev() system calls to COMPAT_LINUX and COMPAT_LINXU32.
 		[thorpej 20210919]
+	wskbd(4): Added French BEPO layout. [nia 20210922]
 	aarch64: Add initial COMPAT_LINUX support. [ryo 20210923]
 	libfido2: Import 1.8.0 [christos 20210924]
 	pam-u2f: Import pam u2f 1.2.0 [christos 20210924]
 	OpenSSH: Import 8.8. [christos 20210927]
+	wsmouse(4): Added WSCONS_EVENT_(H|V)SCROLL event types from OpenBSD
+		and integrated them into the synaptics(4) driver and
+		xf86-input-ws. [nia 20210928]
 	gnu-efi: Import version 3.0.14. [jmcneill 20210930]
 	tzdata partly updated to 2021b [kre 20211001] 



CVS commit: src/doc

2021-10-10 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun Oct 10 08:42:43 UTC 2021

Modified Files:
src/doc: CHANGES

Log Message:
doc: wscons changes


To generate a diff of this commit:
cvs rdiff -u -r1.2836 -r1.2837 src/doc/CHANGES

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



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

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 08:36:49 UTC 2021

Modified Files:
src/sys/arch/arm/include: armreg.h

Log Message:
Add a placeholder for PRRR


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/arm/include/armreg.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/arm/include/armreg.h
diff -u src/sys/arch/arm/include/armreg.h:1.131 src/sys/arch/arm/include/armreg.h:1.132
--- src/sys/arch/arm/include/armreg.h:1.131	Fri Sep  3 21:55:00 2021
+++ src/sys/arch/arm/include/armreg.h	Sun Oct 10 08:36:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: armreg.h,v 1.131 2021/09/03 21:55:00 andvar Exp $	*/
+/*	$NetBSD: armreg.h,v 1.132 2021/10/10 08:36:49 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Ben Harris
@@ -538,6 +538,7 @@
 #define PRRR_TR_STRONG	0		// Strongly Ordered
 #define PRRR_TR_DEVICE	1		// Device
 #define PRRR_TR_NORMAL	2		// Normal Memory
+	// 3 is reserved
 
 /* ARMv7 MPIDR, Multiprocessor Affinity Register generic format  */
 #define MPIDR_MP		__BIT(31)	/* 1 = Have MP Extension */



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

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 08:36:49 UTC 2021

Modified Files:
src/sys/arch/arm/include: armreg.h

Log Message:
Add a placeholder for PRRR


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/arm/include/armreg.h

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



CVS commit: src/bin/sh

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 08:35:34 UTC 2021

Modified Files:
src/bin/sh: Makefile jobs.c

Log Message:
sh: remove no-op 'continue' from do-while-0 loop

With Clang, the only change to the binary are the line number changes
from __LINE__, GCC generates a bit different code.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/bin/sh/Makefile
cvs rdiff -u -r1.112 -r1.113 src/bin/sh/jobs.c

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

Modified files:

Index: src/bin/sh/Makefile
diff -u src/bin/sh/Makefile:1.119 src/bin/sh/Makefile:1.120
--- src/bin/sh/Makefile:1.119	Sat Oct  9 21:06:31 2021
+++ src/bin/sh/Makefile	Sun Oct 10 08:35:34 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.119 2021/10/09 21:06:31 rillig Exp $
+#	$NetBSD: Makefile,v 1.120 2021/10/10 08:35:34 rillig Exp $
 #	@(#)Makefile	8.4 (Berkeley) 5/5/95
 
 .include 
@@ -30,7 +30,6 @@ CPPFLAGS+= -DUSE_LRAND48
 #COPTS+=-g
 #CFLAGS+=-funsigned-char
 #TARGET_CHARFLAG?= -DTARGET_CHAR="unsigned char" -funsigned-char
-LINTFLAGS+=	-X 323		# continue in 'do ... while (0)' loop
 
 # Reproducible build parameters ... export into sh for NETBSD_SHELL setting
 .if ${MKREPRO_TIMESTAMP:Uno} != "no"

Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.112 src/bin/sh/jobs.c:1.113
--- src/bin/sh/jobs.c:1.112	Sun Sep 12 01:30:41 2021
+++ src/bin/sh/jobs.c	Sun Oct 10 08:35:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: jobs.c,v 1.112 2021/09/12 01:30:41 kre Exp $	*/
+/*	$NetBSD: jobs.c,v 1.113 2021/10/10 08:35:34 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)jobs.c	8.5 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: jobs.c,v 1.112 2021/09/12 01:30:41 kre Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.113 2021/10/10 08:35:34 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -196,10 +196,8 @@ setjobctl(int on)
 			}
 			if (initialpgrp == -1)
 initialpgrp = getpgrp();
-			else if (initialpgrp != getpgrp()) {
+			else if (initialpgrp != getpgrp())
 killpg(0, SIGTTIN);
-continue;
-			}
 		} while (0);
 
 #ifdef OLD_TTY_DRIVER



CVS commit: src/bin/sh

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 08:35:34 UTC 2021

Modified Files:
src/bin/sh: Makefile jobs.c

Log Message:
sh: remove no-op 'continue' from do-while-0 loop

With Clang, the only change to the binary are the line number changes
from __LINE__, GCC generates a bit different code.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/bin/sh/Makefile
cvs rdiff -u -r1.112 -r1.113 src/bin/sh/jobs.c

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



CVS commit: src/bin/sh

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 08:19:02 UTC 2021

Modified Files:
src/bin/sh: exec.c

Log Message:
sh: make find_command simpler

Lint complained about the do-while-0 loop that contained a continue. It
didn't state the reason for it, but indeed the code looked complicated.
Rewrite the code to be less verbose and to use common coding patterns.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/bin/sh/exec.c

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

Modified files:

Index: src/bin/sh/exec.c
diff -u src/bin/sh/exec.c:1.55 src/bin/sh/exec.c:1.56
--- src/bin/sh/exec.c:1.55	Tue Feb 16 15:30:12 2021
+++ src/bin/sh/exec.c	Sun Oct 10 08:19:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.55 2021/02/16 15:30:12 kre Exp $	*/
+/*	$NetBSD: exec.c,v 1.56 2021/10/10 08:19:02 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)exec.c	8.4 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: exec.c,v 1.55 2021/02/16 15:30:12 kre Exp $");
+__RCSID("$NetBSD: exec.c,v 1.56 2021/10/10 08:19:02 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -548,31 +548,23 @@ find_command(char *name, struct cmdentry
 
 	/* If name is in the table, check answer will be ok */
 	if ((cmdp = cmdlookup(name, 0)) != NULL) {
-		do {
-			switch (cmdp->cmdtype) {
-			case CMDNORMAL:
-if (act & DO_ALTPATH) {
-	cmdp = NULL;
-	continue;
-}
-break;
-			case CMDFUNCTION:
-if (act & DO_NOFUNC) {
-	cmdp = NULL;
-	continue;
-}
-break;
-			case CMDBUILTIN:
-if ((act & DO_ALTBLTIN) || builtinloc >= 0) {
-	cmdp = NULL;
-	continue;
-}
-break;
-			}
-			/* if not invalidated by cd, we're done */
-			if (cmdp->rehash == 0)
-goto success;
-		} while (0);
+		switch (cmdp->cmdtype) {
+		case CMDNORMAL:
+			if (act & DO_ALTPATH)
+cmdp = NULL;
+			break;
+		case CMDFUNCTION:
+			if (act & DO_NOFUNC)
+cmdp = NULL;
+			break;
+		case CMDBUILTIN:
+			if ((act & DO_ALTBLTIN) || builtinloc >= 0)
+cmdp = NULL;
+			break;
+		}
+		/* if not invalidated by cd, we're done */
+		if (cmdp != NULL && cmdp->rehash == 0)
+			goto success;
 	}
 
 	/* If %builtin not in path, check for builtin next */



CVS commit: src/bin/sh

2021-10-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 10 08:19:02 UTC 2021

Modified Files:
src/bin/sh: exec.c

Log Message:
sh: make find_command simpler

Lint complained about the do-while-0 loop that contained a continue. It
didn't state the reason for it, but indeed the code looked complicated.
Rewrite the code to be less verbose and to use common coding patterns.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/bin/sh/exec.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

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 07:50:53 UTC 2021

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

Log Message:
Catch up with pcireg.h change


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/nvme_pci.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/nvme_pci.c
diff -u src/sys/dev/pci/nvme_pci.c:1.30 src/sys/dev/pci/nvme_pci.c:1.31
--- src/sys/dev/pci/nvme_pci.c:1.30	Sat May 29 08:46:38 2021
+++ src/sys/dev/pci/nvme_pci.c	Sun Oct 10 07:50:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme_pci.c,v 1.30 2021/05/29 08:46:38 riastradh Exp $	*/
+/*	$NetBSD: nvme_pci.c,v 1.31 2021/10/10 07:50:53 skrll Exp $	*/
 /*	$OpenBSD: nvme_pci.c,v 1.3 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.30 2021/05/29 08:46:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.31 2021/10/10 07:50:53 skrll Exp $");
 
 #include 
 #include 
@@ -137,7 +137,7 @@ nvme_pci_match(device_t parent, cfdata_t
 
 	if (PCI_CLASS(pa->pa_class) == PCI_CLASS_MASS_STORAGE &&
 	PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_NVM &&
-	PCI_INTERFACE(pa->pa_class) == PCI_INTERFACE_NVM_NVME)
+	PCI_INTERFACE(pa->pa_class) == PCI_INTERFACE_NVM_NVME_IO)
 		return 1;
 
 	return 0;



CVS commit: src/sys/dev/pci

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 07:50:53 UTC 2021

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

Log Message:
Catch up with pcireg.h change


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/nvme_pci.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/aarch64/aarch64

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 07:41:21 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Need to call pmap_tlb_info_attach for each CPU.  Missed in previous
commit.
CVS --


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/aarch64/aarch64/cpu.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/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.62 src/sys/arch/aarch64/aarch64/cpu.c:1.63
--- src/sys/arch/aarch64/aarch64/cpu.c:1.62	Mon Oct  4 09:39:18 2021
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sun Oct 10 07:41:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.62 2021/10/04 09:39:18 skrll Exp $ */
+/* $NetBSD: cpu.c,v 1.63 2021/10/10 07:41:21 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.62 2021/10/04 09:39:18 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.63 2021/10/10 07:41:21 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -153,6 +153,7 @@ cpu_attach(device_t dv, cpuid_t id)
 #ifdef MULTIPROCESSOR
 	if (unit != 0) {
 		mi_cpu_attach(ci);
+		pmap_tlb_info_attach(&pmap_tlb0_info, ci);
 		return;
 	}
 #endif /* MULTIPROCESSOR */



CVS commit: src/sys/arch/aarch64/aarch64

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 07:41:21 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Need to call pmap_tlb_info_attach for each CPU.  Missed in previous
commit.
CVS --


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/aarch64/aarch64/cpu.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

2021-10-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Oct 10 07:20:01 UTC 2021

Modified Files:
src/sys/dev/pci: pci_subr.c pcireg.h

Log Message:
Add Some PCI config information:

 - Lane Margining at the Receiver
 - NVME admin interface
 - UFSHCI
 - InfiniBand
 - Host fabric
 - HDA 1.0 with vendor ext
 - USB4 HCI
 - MIPI I3C
 - Cellular controller/modem (+ Ethernet)


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.159 -r1.160 src/sys/dev/pci/pcireg.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/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.230 src/sys/dev/pci/pci_subr.c:1.231
--- src/sys/dev/pci/pci_subr.c:1.230	Sat Sep 11 19:56:51 2021
+++ src/sys/dev/pci/pci_subr.c	Sun Oct 10 07:20:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.230 2021/09/11 19:56:51 mrg Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.231 2021/10/10 07:20:01 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.230 2021/09/11 19:56:51 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.231 2021/10/10 07:20:01 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -174,7 +174,15 @@ static const struct pci_class pci_interf
 static const struct pci_class pci_interface_nvm[] = {
 	{ "vendor specific",	PCI_INTERFACE_NVM_VND,		NULL,	},
 	{ "NVMHCI 1.0",		PCI_INTERFACE_NVM_NVMHCI10,	NULL,	},
-	{ "NVMe",		PCI_INTERFACE_NVM_NVME,		NULL,	},
+	{ "NVMe I/O",		PCI_INTERFACE_NVM_NVME_IO,	NULL,	},
+	{ "NVMe admin",		PCI_INTERFACE_NVM_NVME_ADMIN,	NULL,	},
+	{ NULL,			0,NULL,	},
+};
+
+/* UFS programming interface */
+static const struct pci_class pci_interface_ufs[] = {
+	{ "vendor specific",	PCI_INTERFACE_UFS_VND,		NULL,	},
+	{ "UFSHCI",		PCI_INTERFACE_UFS_UFSHCI,	NULL,	},
 	{ NULL,			0,NULL,	},
 };
 
@@ -192,6 +200,8 @@ static const struct pci_class pci_subcla
 	{ "SAS",		PCI_SUBCLASS_MASS_STORAGE_SAS,	NULL,	},
 	{ "Flash",		PCI_SUBCLASS_MASS_STORAGE_NVM,
 	  pci_interface_nvm,	},
+	{ "UFS",		PCI_SUBCLASS_MASS_STORAGE_UFS,
+	  pci_interface_ufs,	},
 	{ "miscellaneous",	PCI_SUBCLASS_MASS_STORAGE_MISC,	NULL,	},
 	{ NULL,			0,NULL,	},
 };
@@ -208,6 +218,8 @@ static const struct pci_class pci_subcla
 	{ "ISDN",		PCI_SUBCLASS_NETWORK_ISDN,	NULL,	},
 	{ "WorldFip",		PCI_SUBCLASS_NETWORK_WORLDFIP,	NULL,	},
 	{ "PCMIG Multi Computing", PCI_SUBCLASS_NETWORK_PCIMGMULTICOMP, NULL, },
+	{ "InfiniBand",		PCI_SUBCLASS_NETWORK_INFINIBAND, NULL, },
+	{ "Host fabric",	PCI_SUBCLASS_NETWORK_HFC,	NULL, },
 	{ "miscellaneous",	PCI_SUBCLASS_NETWORK_MISC,	NULL,	},
 	{ NULL,			0,NULL,	},
 };
@@ -236,11 +248,20 @@ static const struct pci_class pci_subcla
  * Class 0x04.
  * Multimedia device.
  */
+
+/* HD Audio programming interface */
+static const struct pci_class pci_interface_hda[] = {
+	{ "HD Audio 1.0",	PCI_INTERFACE_HDAUDIO,		NULL,	},
+	{ "HD Audio 1.0 + vendor ext",	PCI_INTERFACE_HDAUDIO_VND, NULL, },
+	{ NULL,			0,NULL,	},
+};
+
 static const struct pci_class pci_subclass_multimedia[] = {
 	{ "video",		PCI_SUBCLASS_MULTIMEDIA_VIDEO,	NULL,	},
 	{ "audio",		PCI_SUBCLASS_MULTIMEDIA_AUDIO,	NULL,	},
 	{ "telephony",		PCI_SUBCLASS_MULTIMEDIA_TELEPHONY, NULL,},
-	{ "mixed mode",		PCI_SUBCLASS_MULTIMEDIA_HDAUDIO, NULL, },
+	{ "mixed mode",		PCI_SUBCLASS_MULTIMEDIA_HDAUDIO,
+	  pci_interface_hda, },
 	{ "miscellaneous",	PCI_SUBCLASS_MULTIMEDIA_MISC,	NULL,	},
 	{ NULL,			0,NULL,	},
 };
@@ -476,6 +497,7 @@ static const struct pci_class pci_interf
 	{ "OHCI",		PCI_INTERFACE_USB_OHCI,		NULL,	},
 	{ "EHCI",		PCI_INTERFACE_USB_EHCI,		NULL,	},
 	{ "xHCI",		PCI_INTERFACE_USB_XHCI,		NULL,	},
+	{ "USB4 HCI",		PCI_INTERFACE_USB_USB4HCI,	NULL,	},
 	{ "other HC",		PCI_INTERFACE_USB_OTHERHC,	NULL,	},
 	{ "device",		PCI_INTERFACE_USB_DEVICE,	NULL,	},
 	{ NULL,			0,NULL,	},
@@ -505,6 +527,7 @@ static const struct pci_class pci_subcla
 	  pci_interface_ipmi, },
 	{ "SERCOS",		PCI_SUBCLASS_SERIALBUS_SERCOS,	NULL,	},
 	{ "CANbus",		PCI_SUBCLASS_SERIALBUS_CANBUS,	NULL,	},
+	{ "MIPI I3C",		PCI_SUBCLASS_SERIALBUS_MIPI_I3C, NULL,	},
 	{ "miscellaneous",	PCI_SUBCLASS_SERIALBUS_MISC,	NULL,	},
 	{ NULL,			0,NULL,	},
 };
@@ -521,6 +544,8 @@ static const struct pci_class pci_subcla
 	{ "broadband",		PCI_SUBCLASS_WIRELESS_BROADBAND, NULL,	},
 	{ "802.11a (5 GHz)",	PCI_SUBCLASS_WIRELESS_802_11A,	NULL,	},
 	{ "802.11b (2.4 GHz)",	PCI_SUBCLASS_WIRELESS_802_11B,	NULL,	},
+	{ "Cellular",		PCI_SUBCLASS_WIRELESS_CELL,	NULL,	},
+	{ "Cellular + Ethernet", PCI_SUBCLASS_WIRELESS_CELL_E,	NULL,	},
 	{ "miscellaneous",	PCI_SUBCLASS_WIRELESS_MISC,	NULL,	},
 	{ NULL,			0,NULL,	},
 };
@@ -4326,9 +4351,9 @@ static struct {
 	  NULL },
 	{ PCI_EXTCAP_VF_RESIZBAR, "VF Resizable BARs",
 	  NULL },
-	{ PCI_EXTCAP_DLF, "Data link Feature", pci_conf_print_dlf_cap },
+	{ PCI_EXTCAP_DLF,	

CVS commit: src/sys/dev/pci

2021-10-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Oct 10 07:20:01 UTC 2021

Modified Files:
src/sys/dev/pci: pci_subr.c pcireg.h

Log Message:
Add Some PCI config information:

 - Lane Margining at the Receiver
 - NVME admin interface
 - UFSHCI
 - InfiniBand
 - Host fabric
 - HDA 1.0 with vendor ext
 - USB4 HCI
 - MIPI I3C
 - Cellular controller/modem (+ Ethernet)


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.159 -r1.160 src/sys/dev/pci/pcireg.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/aarch64

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 07:15:25 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c
src/sys/arch/aarch64/conf: files.aarch64
src/sys/arch/aarch64/include: cpu.h pmap.h pte.h types.h
Added Files:
src/sys/arch/aarch64/aarch64: aarch64_tlb.c

Log Message:
Use sys/uvm/pmap/pmap_tlb.c on Aarch64 in the same way that some Arm, MIPS,
and some PPC kernels do.  This removes the limitation of 256 processes on
CPUs with 8bit ASID field, e.g. Apple M1.

Additionally the following changes have been made

- removed a couple of unnecessary aarch64_tlbi_all calls
- removed any invalidation after freeing page tables due to
  _pmap_sweep_pdp. This was never necessary afaict.
- all kernel mappings are marked global and userland mapping not-global.

Performance testing hasn't show a significant difference.  The data here
is from building a kernel on an lx2k system with nvme.

before
1489.6u 400.4s 2:40.65 1176.5% 228+224k 0+32289io 57pf+0w
1482.6u 403.2s 2:38.49 1189.9% 228+222k 0+32274io 46pf+0w
1485.4u 402.2s 2:37.27 1200.2% 228+222k 0+32275io 12pf+0w

after
1493.9u 404.6s 2:37.50 1205.4% 227+221k 0+32265io 48pf+0w
1485.0u 408.0s 2:38.54 1194.0% 227+222k 0+32272io 36pf+0w
1484.3u 407.0s 2:35.88 1213.3% 228+224k 0+32268io 14pf+0w

>>> stats.ttest_ind([160.65,158.49,157.27], [157.5,158.54,155.88])
Ttest_indResult(statistic=1.1923622711296888, pvalue=0.2990182944606766)
>>>


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/aarch64/aarch64/aarch64_tlb.c
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/aarch64/include/cpu.h
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/aarch64/include/pmap.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/include/pte.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/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/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.116 src/sys/arch/aarch64/aarch64/pmap.c:1.117
--- src/sys/arch/aarch64/aarch64/pmap.c:1.116	Thu Sep 30 21:19:16 2021
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sun Oct 10 07:15:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.116 2021/09/30 21:19:16 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.117 2021/10/10 07:15:25 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.116 2021/09/30 21:19:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.117 2021/10/10 07:15:25 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.1
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -181,10 +182,10 @@ PMAP_COUNTER(unwire_failure, "pmap_unwir
  * change the pte to accessible temporarly before cpu_icache_sync_range().
  * this macro modifies PTE (*ptep). need to update PTE after this.
  */
-#define PTE_ICACHE_SYNC_PAGE(pte, ptep, pm, va, ll)			\
+#define PTE_ICACHE_SYNC_PAGE(pte, ptep, asid, va, ll)			\
 	do {\
 		atomic_swap_64((ptep), (pte) | LX_BLKPAG_AF);		\
-		AARCH64_TLBI_BY_ASID_VA((pm)->pm_asid, (va), (ll));	\
+		AARCH64_TLBI_BY_ASID_VA((asid), (va), (ll));		\
 		cpu_icache_sync_range((va), PAGE_SIZE);			\
 	} while (0/*CONSTCOND*/)
 
@@ -336,7 +337,6 @@ pmap_map_chunk(vaddr_t va, paddr_t pa, v
 	attr = _pmap_pte_adjust_prot(0, prot, VM_PROT_ALL, false);
 	attr = _pmap_pte_adjust_cacheflags(attr, flags);
 	pmapboot_enter_range(va, pa, resid, attr, printf);
-	aarch64_tlbi_all();
 
 	return resid;
 }
@@ -472,18 +472,23 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	virtual_end = vend;
 	pmap_maxkvaddr = vstart;
 
-	aarch64_tlbi_all();
-
 	l0pa = reg_ttbr1_el1_read();
 	l0 = (void *)AARCH64_PA_TO_KVA(l0pa);
 
+	pmap_tlb_info_init(&pmap_tlb0_info);
+
 	memset(&kernel_pmap, 0, sizeof(kernel_pmap));
+
 	kpm = pmap_kernel();
-	kpm->pm_asid = 0;
+	struct pmap_asid_info * const pai = PMAP_PAI(kpm, cpu_tlb_info(ci));
+
+	pai->pai_asid = KERNEL_PID;
 	kpm->pm_refcnt = 1;
 	kpm->pm_idlepdp = 0;
 	kpm->pm_l0table = l0;
 	kpm->pm_l0table_pa = l0pa;
+	kpm->pm_onproc = kcpuset_running;
+	kpm->pm_active = kcpuset_running;
 	kpm->pm_activated = true;
 	LIST_INIT(&kpm->pm_vmlist);
 	LIST_INIT(&kpm->pm_pvlist);	/* not used for kernel pmap */
@@ -493,6 +498,12 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	CTASSERT(sizeof(kpm->pm_stats.resident_count) == sizeof(long));
 }
 
+void
+pmap_md_tlb_info_attach(struct pmap_tlb_info *ti, struct cpu_info *ci)
+{
+	/* nothing */
+}
+
 static inline void
 _pmap_adj_wired_count(struct pmap *pm, int adj)
 {
@@ -556,9 +567,7 @@ pmap_init(void)
 	32, 0, PR_LARGECACHE, "pvpl", NULL, IPL_NONE, _pmap_pv_ctor,
 	NULL, NULL);
 
-	int nmaxproc = cpu_maxproc();
-	if (maxproc > nmaxproc)
-		maxproc = nmaxproc;
+

CVS commit: src/sys/arch/aarch64

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 07:15:25 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c
src/sys/arch/aarch64/conf: files.aarch64
src/sys/arch/aarch64/include: cpu.h pmap.h pte.h types.h
Added Files:
src/sys/arch/aarch64/aarch64: aarch64_tlb.c

Log Message:
Use sys/uvm/pmap/pmap_tlb.c on Aarch64 in the same way that some Arm, MIPS,
and some PPC kernels do.  This removes the limitation of 256 processes on
CPUs with 8bit ASID field, e.g. Apple M1.

Additionally the following changes have been made

- removed a couple of unnecessary aarch64_tlbi_all calls
- removed any invalidation after freeing page tables due to
  _pmap_sweep_pdp. This was never necessary afaict.
- all kernel mappings are marked global and userland mapping not-global.

Performance testing hasn't show a significant difference.  The data here
is from building a kernel on an lx2k system with nvme.

before
1489.6u 400.4s 2:40.65 1176.5% 228+224k 0+32289io 57pf+0w
1482.6u 403.2s 2:38.49 1189.9% 228+222k 0+32274io 46pf+0w
1485.4u 402.2s 2:37.27 1200.2% 228+222k 0+32275io 12pf+0w

after
1493.9u 404.6s 2:37.50 1205.4% 227+221k 0+32265io 48pf+0w
1485.0u 408.0s 2:38.54 1194.0% 227+222k 0+32272io 36pf+0w
1484.3u 407.0s 2:35.88 1213.3% 228+224k 0+32268io 14pf+0w

>>> stats.ttest_ind([160.65,158.49,157.27], [157.5,158.54,155.88])
Ttest_indResult(statistic=1.1923622711296888, pvalue=0.2990182944606766)
>>>


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/aarch64/aarch64/aarch64_tlb.c
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/aarch64/include/cpu.h
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/aarch64/include/pmap.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/include/pte.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/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

2021-10-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Oct 10 07:09:20 UTC 2021

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

Log Message:
 Whitespace fix. No functional change.


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

2021-10-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Oct 10 07:09:20 UTC 2021

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

Log Message:
 Whitespace fix. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sys/dev/pci/pcireg.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/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.158 src/sys/dev/pci/pcireg.h:1.159
--- src/sys/dev/pci/pcireg.h:1.158	Thu Sep  9 08:11:42 2021
+++ src/sys/dev/pci/pcireg.h	Sun Oct 10 07:09:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.158 2021/09/09 08:11:42 mrg Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.159 2021/10/10 07:09:20 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -567,7 +567,7 @@ typedef u_int8_t pci_revision_t;
 #define	PCI_CAP_SUBVENDOR	0x0d
 #define	PCI_CAP_AGP8		0x0e
 #define	PCI_CAP_SECURE		0x0f
-#define	PCI_CAP_PCIEXPRESS 	0x10
+#define	PCI_CAP_PCIEXPRESS	0x10
 #define	PCI_CAP_MSIX		0x11
 #define	PCI_CAP_SATA		0x12
 #define	PCI_CAP_PCIAF		0x13
@@ -1050,7 +1050,7 @@ typedef u_int8_t pci_revision_t;
 #define	PCIE_LCSR_NLW		__BITS(25, 20) /* Negotiated Link Width */
 #define	PCIE_LCSR_LINKTRAIN_ERR	__BIT(10 + 16) /* Link Training Error */
 #define	PCIE_LCSR_LINKTRAIN	__BIT(11 + 16) /* Link Training */
-#define	PCIE_LCSR_SLOTCLKCFG 	__BIT(12 + 16) /* Slot Clock Configuration */
+#define	PCIE_LCSR_SLOTCLKCFG	__BIT(12 + 16) /* Slot Clock Configuration */
 #define	PCIE_LCSR_DLACTIVE	__BIT(13 + 16) /* Data Link Layer Link Active*/
 #define	PCIE_LCSR_LINK_BW_MGMT	__BIT(14 + 16) /* Link BW Management Status */
 #define	PCIE_LCSR_LINK_AUTO_BW	__BIT(15 + 16) /* Link Autonomous BW Status */
@@ -1984,9 +1984,9 @@ struct pci_rom {
 #define	PCI_TPH_REQ_CAP_DEVSPEC	__BIT(2)   /* Device Specific Mode Supported */
 #define	PCI_TPH_REQ_CAP_XTPHREQ	__BIT(8)/* Extend TPH Requester Supported */
 #define	PCI_TPH_REQ_CAP_STTBLLOC __BITS(10, 9)	/* ST Table Location */
-#define	PCI_TPH_REQ_STTBLLOC_NONE 	0	/* not present */
-#define	PCI_TPH_REQ_STTBLLOC_TPHREQ 	1	/* in the TPHREQ cap */
-#define	PCI_TPH_REQ_STTBLLOC_MSIX 	2	/* in the MSI-X table */
+#define	PCI_TPH_REQ_STTBLLOC_NONE	0	 /* not present */
+#define	PCI_TPH_REQ_STTBLLOC_TPHREQ	1	 /* in the TPHREQ cap */
+#define	PCI_TPH_REQ_STTBLLOC_MSIX	2	 /* in the MSI-X table */
 #define	PCI_TPH_REQ_CAP_STTBLSIZ __BITS(26, 16)	/* ST Table Size */
 #define	PCI_TPH_REQ_CTL	0x08	/* TPH Requester Control */
 #define	PCI_TPH_REQ_CTL_STSEL	__BITS(2, 0)	/* ST Mode Select */