CVS commit: [netbsd-10] src/sys/dev/sdmmc

2024-10-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 14 17:47:00 UTC 2024

Modified Files:
src/sys/dev/sdmmc [netbsd-10]: sdmmc_cis.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #977):

sys/dev/sdmmc/sdmmc_cis.c: revision 1.9

sdmmc: Decode CISTPL_FUNCE of type PCMCIA_TPLFE_TYPE_LAN_NID


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.26.1 src/sys/dev/sdmmc/sdmmc_cis.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/sdmmc/sdmmc_cis.c
diff -u src/sys/dev/sdmmc/sdmmc_cis.c:1.8 src/sys/dev/sdmmc/sdmmc_cis.c:1.8.26.1
--- src/sys/dev/sdmmc/sdmmc_cis.c:1.8	Mon Oct 28 06:31:39 2019
+++ src/sys/dev/sdmmc/sdmmc_cis.c	Mon Oct 14 17:47:00 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_cis.c,v 1.8 2019/10/28 06:31:39 mlelstv Exp $	*/
+/*	$NetBSD: sdmmc_cis.c,v 1.8.26.1 2024/10/14 17:47:00 martin Exp $	*/
 /*	$OpenBSD: sdmmc_cis.c,v 1.1 2006/06/01 21:53:41 uwe Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Routines to decode the Card Information Structure of SD I/O cards */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.8 2019/10/28 06:31:39 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.8.26.1 2024/10/14 17:47:00 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -103,6 +103,30 @@ decode_funce_common(struct sdmmc_functio
 }
 
 static void
+decode_funce_lan_nid(struct sdmmc_function *sf, struct sdmmc_cis *cis,
+		 int tpllen, uint32_t reg)
+{
+	struct sdmmc_function *sf0 = sf->sc->sc_fn0;
+	device_t dev = sf->sc->sc_dev;
+	uint8_t mac[6] __unused;
+	int i;
+
+	if (tpllen != 8) {
+		aprint_error_dev(dev,
+		"CISTPL_FUNCE(lan_nid) too short\n");
+		return;
+	}
+
+	for (i = 0; i < 6; i++) {
+		mac[i] = sdmmc_io_read_1(sf0, reg++);
+	}
+
+	DPRINTF(
+	("CISTPL_FUNCE: LAN_NID=%02x:%02x:%02x:%02x:%02x:%02x\n",
+	mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]));
+}
+
+static void
 decode_funce_function(struct sdmmc_function *sf, struct sdmmc_cis *cis,
 		  int tpllen, uint32_t reg)
 {
@@ -221,10 +245,16 @@ sdmmc_read_cis(struct sdmmc_function *sf
 
 		switch (tplcode) {
 		case PCMCIA_CISTPL_FUNCE:
-			if (sdmmc_io_read_1(sf0, reg++) == 0)
+			switch (sdmmc_io_read_1(sf0, reg++)) {
+			case 0:
 decode_funce_common(sf, cis, tpllen, reg);
-			else
+break;
+			case PCMCIA_TPLFE_TYPE_LAN_NID:
+decode_funce_lan_nid(sf, cis, tpllen, reg);
+break;
+			default:
 decode_funce_function(sf, cis, tpllen, reg);
+			}
 			reg += (tpllen - 1);
 			break;
 



CVS commit: [netbsd-10] src/sys/dev/sdmmc

2024-10-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 14 17:47:00 UTC 2024

Modified Files:
src/sys/dev/sdmmc [netbsd-10]: sdmmc_cis.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #977):

sys/dev/sdmmc/sdmmc_cis.c: revision 1.9

sdmmc: Decode CISTPL_FUNCE of type PCMCIA_TPLFE_TYPE_LAN_NID


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.26.1 src/sys/dev/sdmmc/sdmmc_cis.c

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



CVS commit: [netbsd-10] src/sys/arch/evbppc

2024-10-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 14 16:44:43 UTC 2024

Modified Files:
src/sys/arch/evbppc/include [netbsd-10]: wii.h
src/sys/arch/evbppc/wii [netbsd-10]: autoconf.c machdep.c wii_locore.S
wii_mmuinit.S
src/sys/arch/evbppc/wii/dev [netbsd-10]: avenc.c ehci_hollywood.c
vireg.h wiifb.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #974):

sys/arch/evbppc/wii/dev/wiifb.c: revision 1.7
sys/arch/evbppc/wii/wii_mmuinit.S: revision 1.2
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.4
sys/arch/evbppc/wii/machdep.c: revision 1.7
sys/arch/evbppc/wii/wii_locore.S: revision 1.3
sys/arch/evbppc/wii/dev/avenc.c: revision 1.2
sys/arch/evbppc/include/wii.h: revision 1.9
sys/arch/evbppc/wii/dev/vireg.h: revision 1.3
sys/arch/evbppc/wii/autoconf.c: revision 1.3

wii: Support loading the kernel from boot2

Improve hardware initialization steps so the NetBSD kernel can be launched
directly from boot2 and does not rely on any other PPC software to setup
the hardware.


To generate a diff of this commit:
cvs rdiff -u -r1.7.2.3 -r1.7.2.4 src/sys/arch/evbppc/include/wii.h
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/arch/evbppc/wii/autoconf.c \
src/sys/arch/evbppc/wii/wii_locore.S
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/arch/evbppc/wii/machdep.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/evbppc/wii/wii_mmuinit.S
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/evbppc/wii/dev/avenc.c
cvs rdiff -u -r1.2.2.3 -r1.2.2.4 src/sys/arch/evbppc/wii/dev/ehci_hollywood.c
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/arch/evbppc/wii/dev/vireg.h
cvs rdiff -u -r1.5.2.3 -r1.5.2.4 src/sys/arch/evbppc/wii/dev/wiifb.c

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



CVS commit: [netbsd-10] src/sys/arch/evbppc

2024-10-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 14 16:44:43 UTC 2024

Modified Files:
src/sys/arch/evbppc/include [netbsd-10]: wii.h
src/sys/arch/evbppc/wii [netbsd-10]: autoconf.c machdep.c wii_locore.S
wii_mmuinit.S
src/sys/arch/evbppc/wii/dev [netbsd-10]: avenc.c ehci_hollywood.c
vireg.h wiifb.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #974):

sys/arch/evbppc/wii/dev/wiifb.c: revision 1.7
sys/arch/evbppc/wii/wii_mmuinit.S: revision 1.2
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.4
sys/arch/evbppc/wii/machdep.c: revision 1.7
sys/arch/evbppc/wii/wii_locore.S: revision 1.3
sys/arch/evbppc/wii/dev/avenc.c: revision 1.2
sys/arch/evbppc/include/wii.h: revision 1.9
sys/arch/evbppc/wii/dev/vireg.h: revision 1.3
sys/arch/evbppc/wii/autoconf.c: revision 1.3

wii: Support loading the kernel from boot2

Improve hardware initialization steps so the NetBSD kernel can be launched
directly from boot2 and does not rely on any other PPC software to setup
the hardware.


To generate a diff of this commit:
cvs rdiff -u -r1.7.2.3 -r1.7.2.4 src/sys/arch/evbppc/include/wii.h
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/arch/evbppc/wii/autoconf.c \
src/sys/arch/evbppc/wii/wii_locore.S
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/arch/evbppc/wii/machdep.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/evbppc/wii/wii_mmuinit.S
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/evbppc/wii/dev/avenc.c
cvs rdiff -u -r1.2.2.3 -r1.2.2.4 src/sys/arch/evbppc/wii/dev/ehci_hollywood.c
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/arch/evbppc/wii/dev/vireg.h
cvs rdiff -u -r1.5.2.3 -r1.5.2.4 src/sys/arch/evbppc/wii/dev/wiifb.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/evbppc/include/wii.h
diff -u src/sys/arch/evbppc/include/wii.h:1.7.2.3 src/sys/arch/evbppc/include/wii.h:1.7.2.4
--- src/sys/arch/evbppc/include/wii.h:1.7.2.3	Wed Oct  2 12:28:15 2024
+++ src/sys/arch/evbppc/include/wii.h	Mon Oct 14 16:44:42 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: wii.h,v 1.7.2.3 2024/10/02 12:28:15 martin Exp $ */
+/* $NetBSD: wii.h,v 1.7.2.4 2024/10/14 16:44:42 martin Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -119,6 +119,8 @@
 #define  IOPOH1EN			__BIT(22)
 #define  IOPOH0EN			__BIT(21)
 #define  IOPEHCEN			__BIT(20)
+#define HW_AIPPROT			(HOLLYWOOD_PRIV_BASE + 0x070)
+#define  ENAHBIOPI			__BIT(0)
 #define HW_GPIOB_OUT			(HOLLYWOOD_BASE + 0x0c0)
 #define HW_GPIOB_DIR			(HOLLYWOOD_BASE + 0x0c4)
 #define HW_GPIOB_IN			(HOLLYWOOD_BASE + 0x0c8)
@@ -155,4 +157,19 @@ wii_slot_led_blink(u_int interval_us)
 	}
 }
 
+/* Enable or disable the slot LED. */
+static inline void
+wii_slot_led(bool enable)
+{
+	uint32_t val;
+
+	val = in32(HW_GPIOB_OUT);
+	if (enable) {
+		val |= __BIT(GPIO_SLOT_LED);
+	} else {
+		val &= ~__BIT(GPIO_SLOT_LED);
+	}
+	out32(HW_GPIOB_OUT, val);
+}
+
 #endif /* !_WII_H */

Index: src/sys/arch/evbppc/wii/autoconf.c
diff -u src/sys/arch/evbppc/wii/autoconf.c:1.2.2.2 src/sys/arch/evbppc/wii/autoconf.c:1.2.2.3
--- src/sys/arch/evbppc/wii/autoconf.c:1.2.2.2	Sat Feb  3 11:47:07 2024
+++ src/sys/arch/evbppc/wii/autoconf.c	Mon Oct 14 16:44:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.2.2.2 2024/02/03 11:47:07 martin Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.2.2.3 2024/10/14 16:44:42 martin Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.2.2.2 2024/02/03 11:47:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.2.2.3 2024/10/14 16:44:42 martin Exp $");
 
 #include 
 #include 
@@ -77,6 +77,8 @@ cpu_configure(void)
 		panic("configure: mainbus not configured");
 
 	genppc_cpu_configure();
+
+	wii_slot_led(false);
 }
 
 void
Index: src/sys/arch/evbppc/wii/wii_locore.S
diff -u src/sys/arch/evbppc/wii/wii_locore.S:1.2.2.2 src/sys/arch/evbppc/wii/wii_locore.S:1.2.2.3
--- src/sys/arch/evbppc/wii/wii_locore.S:1.2.2.2	Sat Feb  3 11:47:07 2024
+++ src/sys/arch/evbppc/wii/wii_locore.S	Mon Oct 14 16:44:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: wii_locore.S,v 1.2.2.2 2024/02/03 11:47:07 martin Exp $	*/
+/*	$NetBSD: wii_locore.S,v 1.2.2.3 2024/10/14 16:44:42 martin Exp $	*/
 /*	$OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $	*/
 
 /*
@@ -97,27 +97,35 @@ __mmu_init:
 #include "wii_mmuinit.S"
 
 	/* compute end of kernel memory */
-	lis	4,_C_LABEL(end)@ha
-	addi	4,4,_C_LABEL(end)@l
-	rlwinm	4,4,0,1,31
-
-	INIT_CPUINFO(4,1,9,5)
-
-	lis	3,__start@ha
-	addi	3,3,__start@l
-	rlwinm	3,3,0,1,31
-
-	xor	5,5,5
-	xor	6,6,6
-	bl	_C_LABEL(cpu_model_init)
+	lis	%r4, _C_LABEL(end)@ha
+	addi	%r4, %r4, _C_LABEL(end)@l
+
+#if NKSYMS || defined(DDB) || defined(MODULAR)
+	/* If we had symbol table location we'd store it here and would've adjusted r4 here */
+	lis	%r7, _C_

CVS commit: [netbsd-10] src/sys/sys

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 14 04:47:55 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: rbtree.h

Log Message:
Actually pull up

sys/sys/rbtree.h1.9

as I tried in previous commit but typoed the revision number.

Ticket #952: sys/endian.h: PR 57806 + 57807: fix declaration visibility.


To generate a diff of this commit:
cvs rdiff -u -r1.5.30.1 -r1.5.30.2 src/sys/sys/rbtree.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/rbtree.h
diff -u src/sys/sys/rbtree.h:1.5.30.1 src/sys/sys/rbtree.h:1.5.30.2
--- src/sys/sys/rbtree.h:1.5.30.1	Sun Oct 13 10:05:58 2024
+++ src/sys/sys/rbtree.h	Mon Oct 14 04:47:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: rbtree.h,v 1.5.30.1 2024/10/13 10:05:58 martin Exp $	*/
+/*	$NetBSD: rbtree.h,v 1.5.30.2 2024/10/14 04:47:55 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -32,12 +32,7 @@
 #ifndef _SYS_RBTREE_H_
 #define	_SYS_RBTREE_H_
 
-#if defined(_KERNEL) || defined(_STANDALONE)
 #include 
-#else
-#include 
-#include 
-#endif
 #include 
 #include 
 



CVS commit: [netbsd-10] src/sys/sys

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 14 04:47:55 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: rbtree.h

Log Message:
Actually pull up

sys/sys/rbtree.h1.9

as I tried in previous commit but typoed the revision number.

Ticket #952: sys/endian.h: PR 57806 + 57807: fix declaration visibility.


To generate a diff of this commit:
cvs rdiff -u -r1.5.30.1 -r1.5.30.2 src/sys/sys/rbtree.h

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



CVS commit: [netbsd-10] src/sys/sys

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 16:15:07 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: cdefs.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #973):

sys/sys/cdefs.h: revision 1.162

sys/cdefs.h: Make various macros work more robustly.

Use predefined __-namespace macros inside __BIT, __type_min,
__type_max, and __type_fit:
- Use __CHAR_BIT__ instead of NBBY so this works without sys/types.h
  and without _NETBSD_SOURCE.
- Use __INTMAX_TYPE__, __UINTMAX_TYPE__ instead of intmax_t, uintmax_t
  so this works without stdint.h.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.159.4.1 src/sys/sys/cdefs.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/cdefs.h
diff -u src/sys/sys/cdefs.h:1.159 src/sys/sys/cdefs.h:1.159.4.1
--- src/sys/sys/cdefs.h:1.159	Sat Jan 22 08:58:48 2022
+++ src/sys/sys/cdefs.h	Sun Oct 13 16:15:07 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cdefs.h,v 1.159 2022/01/22 08:58:48 skrll Exp $	*/
+/*	$NetBSD: cdefs.h,v 1.159.4.1 2024/10/13 16:15:07 martin Exp $	*/
 
 /* * Copyright (c) 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -645,9 +645,12 @@
 
 #ifndef __ASSEMBLER__
 /* __BIT(n): nth bit, where __BIT(0) == 0x1. */
-#define	__BIT(__n)	\
-(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \
-((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1
+#define	__BIT(__n)			  \
+	(((__UINTMAX_TYPE__)(__n) >= __CHAR_BIT__ * sizeof(__UINTMAX_TYPE__)) \
+	? 0  \
+	: ((__UINTMAX_TYPE__)1 <<	  \
+		(__UINTMAX_TYPE__)((__n) &  \
+		(__CHAR_BIT__ * sizeof(__UINTMAX_TYPE__) - 1
 
 /* __MASK(n): first n bits all set, where __MASK(4) == 0b. */
 #define	__MASK(__n)	(__BIT(__n) - 1)
@@ -689,8 +692,8 @@
 
 #define __USE(a) (/*LINTED*/(void)(a))
 
-#define __type_mask(t) (/*LINTED*/sizeof(t) < sizeof(intmax_t) ? \
-(~((1ULL << (sizeof(t) * NBBY)) - 1)) : 0ULL)
+#define __type_mask(t) (/*LINTED*/sizeof(t) < sizeof(__INTMAX_TYPE__) ? \
+(~((1ULL << (sizeof(t) * __CHAR_BIT__)) - 1)) : 0ULL)
 
 #ifndef __ASSEMBLER__
 static __inline long long __zeroll(void) { return 0; }
@@ -702,8 +705,8 @@ static __inline unsigned long long __zer
 
 #define __negative_p(x) (!((x) > 0) && ((x) != 0))
 
-#define __type_min_s(t) ((t)((1ULL << (sizeof(t) * NBBY - 1
-#define __type_max_s(t) ((t)~((1ULL << (sizeof(t) * NBBY - 1
+#define __type_min_s(t) ((t)((1ULL << (sizeof(t) * __CHAR_BIT__ - 1
+#define __type_max_s(t) ((t)~((1ULL << (sizeof(t) * __CHAR_BIT__ - 1
 #define __type_min_u(t) ((t)0ULL)
 #define __type_max_u(t) ((t)~0ULL)
 #define __type_is_signed(t) (/*LINTED*/__type_min_s(t) + (t)1 < (t)1)
@@ -711,13 +714,18 @@ static __inline unsigned long long __zer
 #define __type_max(t) (__type_is_signed(t) ? __type_max_s(t) : __type_max_u(t))
 
 
-#define __type_fit_u(t, a) (/*LINTED*/!__negative_p(a) && \
-(uintmax_t)((a) + __zeroull()) <= (uintmax_t)__type_max_u(t))
-
-#define __type_fit_s(t, a) (/*LINTED*/__negative_p(a) ? \
-((intmax_t)((a) + __zeroll()) >= (intmax_t)__type_min_s(t)) : \
-((intmax_t)((a) + __zeroll()) >= (intmax_t)0 && \
- (intmax_t)((a) + __zeroll()) <= (intmax_t)__type_max_s(t)))
+#define __type_fit_u(t, a)		  \
+	(/*LINTED*/!__negative_p(a) &&	  \
+	((__UINTMAX_TYPE__)((a) + __zeroull()) <=			  \
+		(__UINTMAX_TYPE__)__type_max_u(t)))
+
+#define __type_fit_s(t, a)		  \
+	(/*LINTED*/__negative_p(a)	  \
+	? ((__INTMAX_TYPE__)((a) + __zeroll()) >=			  \
+		(__INTMAX_TYPE__)__type_min_s(t))			  \
+	: ((__INTMAX_TYPE__)((a) + __zeroll()) >= (__INTMAX_TYPE__)0 &&   \
+		((__INTMAX_TYPE__)((a) + __zeroll()) <=			  \
+		(__INTMAX_TYPE__)__type_max_s(t
 
 /*
  * return true if value 'a' fits in type 't'



CVS commit: [netbsd-10] src/sys/kern

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 16:13:18 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: subr_devsw.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #972):

sys/kern/subr_devsw.c: revision 1.52

devsw(9): Don't leak devsw reference on open d_devtounit failure.

PR kern/56816: Deadlock: sleep during unloading module with
kernconfig_lock being held


To generate a diff of this commit:
cvs rdiff -u -r1.49.2.1 -r1.49.2.2 src/sys/kern/subr_devsw.c

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



CVS commit: [netbsd-10] src/sys/sys

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 16:15:07 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: cdefs.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #973):

sys/sys/cdefs.h: revision 1.162

sys/cdefs.h: Make various macros work more robustly.

Use predefined __-namespace macros inside __BIT, __type_min,
__type_max, and __type_fit:
- Use __CHAR_BIT__ instead of NBBY so this works without sys/types.h
  and without _NETBSD_SOURCE.
- Use __INTMAX_TYPE__, __UINTMAX_TYPE__ instead of intmax_t, uintmax_t
  so this works without stdint.h.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.159.4.1 src/sys/sys/cdefs.h

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



CVS commit: [netbsd-10] src/sys/kern

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 16:13:18 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: subr_devsw.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #972):

sys/kern/subr_devsw.c: revision 1.52

devsw(9): Don't leak devsw reference on open d_devtounit failure.

PR kern/56816: Deadlock: sleep during unloading module with
kernconfig_lock being held


To generate a diff of this commit:
cvs rdiff -u -r1.49.2.1 -r1.49.2.2 src/sys/kern/subr_devsw.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/subr_devsw.c
diff -u src/sys/kern/subr_devsw.c:1.49.2.1 src/sys/kern/subr_devsw.c:1.49.2.2
--- src/sys/kern/subr_devsw.c:1.49.2.1	Tue Feb 14 16:16:30 2023
+++ src/sys/kern/subr_devsw.c	Sun Oct 13 16:13:18 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_devsw.c,v 1.49.2.1 2023/02/14 16:16:30 martin Exp $	*/
+/*	$NetBSD: subr_devsw.c,v 1.49.2.2 2024/10/13 16:13:18 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.49.2.1 2023/02/14 16:16:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.49.2.2 2024/10/13 16:13:18 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
@@ -1181,10 +1181,15 @@ bdev_open(dev_t dev, int flag, int devty
 		 * reviewing them all to find and verify a common
 		 * pattern.
 		 */
-		if ((unit = (*d->d_devtounit)(dev)) == -1)
-			return ENXIO;
-		if ((dv = device_lookup_acquire(d->d_cfdriver, unit)) == NULL)
-			return ENXIO;
+		if ((unit = (*d->d_devtounit)(dev)) == -1) {
+			rv = ENXIO;
+			goto out;
+		}
+		if ((dv = device_lookup_acquire(d->d_cfdriver, unit)) ==
+		NULL) {
+			rv = ENXIO;
+			goto out;
+		}
 		SDT_PROBE6(sdt, bdev, open, acquire,
 		d, dev, flag, devtype, unit, dv);
 	}
@@ -1201,7 +1206,7 @@ bdev_open(dev_t dev, int flag, int devty
 		device_release(dv);
 	}
 
-	bdevsw_release(d, lc);
+out:	bdevsw_release(d, lc);
 
 	return rv;
 }
@@ -1412,10 +1417,15 @@ cdev_open(dev_t dev, int flag, int devty
 		 * reviewing them all to find and verify a common
 		 * pattern.
 		 */
-		if ((unit = (*d->d_devtounit)(dev)) == -1)
-			return ENXIO;
-		if ((dv = device_lookup_acquire(d->d_cfdriver, unit)) == NULL)
-			return ENXIO;
+		if ((unit = (*d->d_devtounit)(dev)) == -1) {
+			rv = ENXIO;
+			goto out;
+		}
+		if ((dv = device_lookup_acquire(d->d_cfdriver, unit)) ==
+		NULL) {
+			rv = ENXIO;
+			goto out;
+		}
 		SDT_PROBE6(sdt, cdev, open, acquire,
 		d, dev, flag, devtype, unit, dv);
 	}
@@ -1432,7 +1442,7 @@ cdev_open(dev_t dev, int flag, int devty
 		device_release(dv);
 	}
 
-	cdevsw_release(d, lc);
+out:	cdevsw_release(d, lc);
 
 	return rv;
 }



CVS commit: [netbsd-10] src/sys/dev/pci

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 15:44:54 UTC 2024

Modified Files:
src/sys/dev/pci [netbsd-10]: if_bge.c if_bgevar.h

Log Message:
Pull up following revision(s) (requested by skrll in ticket #968):

sys/dev/pci/if_bgevar.h: revision 1.41
sys/dev/pci/if_bgevar.h: revision 1.42
sys/dev/pci/if_bge.c: revision 1.394

s/jumo/jumbo/ in comments.

Apply changes from PR/58584 after testing (and fixing).
Tested on an Apple M1.


To generate a diff of this commit:
cvs rdiff -u -r1.388 -r1.388.2.1 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.40 -r1.40.4.1 src/sys/dev/pci/if_bgevar.h

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



CVS commit: [netbsd-10] src/sys/dev/pci

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 15:44:54 UTC 2024

Modified Files:
src/sys/dev/pci [netbsd-10]: if_bge.c if_bgevar.h

Log Message:
Pull up following revision(s) (requested by skrll in ticket #968):

sys/dev/pci/if_bgevar.h: revision 1.41
sys/dev/pci/if_bgevar.h: revision 1.42
sys/dev/pci/if_bge.c: revision 1.394

s/jumo/jumbo/ in comments.

Apply changes from PR/58584 after testing (and fixing).
Tested on an Apple M1.


To generate a diff of this commit:
cvs rdiff -u -r1.388 -r1.388.2.1 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.40 -r1.40.4.1 src/sys/dev/pci/if_bgevar.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/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.388 src/sys/dev/pci/if_bge.c:1.388.2.1
--- src/sys/dev/pci/if_bge.c:1.388	Tue Oct 11 22:03:37 2022
+++ src/sys/dev/pci/if_bge.c	Sun Oct 13 15:44:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.388 2022/10/11 22:03:37 andvar Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.388.2.1 2024/10/13 15:44:54 martin Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.388 2022/10/11 22:03:37 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.388.2.1 2024/10/13 15:44:54 martin Exp $");
 
 #include 
 #include 
@@ -203,9 +203,7 @@ static void bge_start_locked(struct ifne
 static int bge_ifflags_cb(struct ethercom *);
 static int bge_ioctl(struct ifnet *, u_long, void *);
 static int bge_init(struct ifnet *);
-static int bge_init_locked(struct ifnet *);
 static void bge_stop(struct ifnet *, int);
-static void bge_stop_locked(struct ifnet *, bool);
 static bool bge_watchdog_tick(struct ifnet *);
 static int bge_ifmedia_upd(struct ifnet *);
 static void bge_ifmedia_sts(struct ifnet *, struct ifmediareq *);
@@ -1091,6 +1089,8 @@ bge_miibus_readreg(device_t dev, int phy
 	int rv = 0;
 	int i;
 
+	KASSERT(mutex_owned(sc->sc_intr_lock));
+
 	if (bge_ape_lock(sc, sc->bge_phy_ape_lock) != 0)
 		return -1;
 
@@ -1144,6 +1144,8 @@ bge_miibus_writereg(device_t dev, int ph
 	int rv = 0;
 	int i;
 
+	KASSERT(mutex_owned(sc->sc_intr_lock));
+
 	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906 &&
 	(reg == MII_GTCR || reg == BRGPHY_MII_AUXCTL))
 		return 0;
@@ -1198,6 +1200,8 @@ bge_miibus_statchg(struct ifnet *ifp)
 	struct mii_data *mii = &sc->bge_mii;
 	uint32_t mac_mode, rx_mode, tx_mode;
 
+	KASSERT(mutex_owned(sc->sc_intr_lock));
+
 	/*
 	 * Get flow control negotiation result.
 	 */
@@ -1840,7 +1844,7 @@ bge_setmulti(struct bge_softc *sc)
 	uint32_t		h;
 	int			i;
 
-	KASSERT(mutex_owned(sc->sc_core_lock));
+	KASSERT(mutex_owned(sc->sc_mcast_lock));
 	if (sc->bge_if_flags & IFF_PROMISC)
 		goto allmulti;
 
@@ -2768,10 +2772,16 @@ bge_blockinit(struct bge_softc *sc)
 
 	/* 5718 step 35, 36, 37 */
 	/* Set up host coalescing defaults */
-	CSR_WRITE_4(sc, BGE_HCC_RX_COAL_TICKS, sc->bge_rx_coal_ticks);
-	CSR_WRITE_4(sc, BGE_HCC_TX_COAL_TICKS, sc->bge_tx_coal_ticks);
-	CSR_WRITE_4(sc, BGE_HCC_RX_MAX_COAL_BDS, sc->bge_rx_max_coal_bds);
-	CSR_WRITE_4(sc, BGE_HCC_TX_MAX_COAL_BDS, sc->bge_tx_max_coal_bds);
+	mutex_enter(sc->sc_intr_lock);
+	const uint32_t rx_coal_ticks = sc->bge_rx_coal_ticks;
+	const uint32_t tx_coal_ticks = sc->bge_tx_coal_ticks;
+	const uint32_t rx_max_coal_bds = sc->bge_rx_max_coal_bds;
+	const uint32_t tx_max_coal_bds = sc->bge_tx_max_coal_bds;
+	mutex_exit(sc->sc_intr_lock);
+	CSR_WRITE_4(sc, BGE_HCC_RX_COAL_TICKS, rx_coal_ticks);
+	CSR_WRITE_4(sc, BGE_HCC_TX_COAL_TICKS, tx_coal_ticks);
+	CSR_WRITE_4(sc, BGE_HCC_RX_MAX_COAL_BDS, rx_max_coal_bds);
+	CSR_WRITE_4(sc, BGE_HCC_TX_MAX_COAL_BDS, tx_max_coal_bds);
 	if (!(BGE_IS_5705_PLUS(sc))) {
 		CSR_WRITE_4(sc, BGE_HCC_RX_COAL_TICKS_INT, 0);
 		CSR_WRITE_4(sc, BGE_HCC_TX_COAL_TICKS_INT, 0);
@@ -3297,7 +3307,6 @@ bge_attach(device_t parent, device_t sel
 		return;
 	}
 
-	sc->bge_stopping = false;
 	sc->bge_txrx_stopping = false;
 
 	/* Save various chip information. */
@@ -3871,7 +3880,7 @@ bge_attach(device_t parent, device_t sel
 	else
 		sc->bge_return_ring_cnt = BGE_RETURN_RING_CNT;
 
-	sc->sc_core_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
+	sc->sc_mcast_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET);
 	sc->sc_intr_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
 
 	/* Set up ifnet structure */
@@ -3990,6 +3999,7 @@ bge_attach(device_t parent, device_t sel
 			mii_flags |= MIIF_HAVEFIBER;
 again:
 		bge_asf_driver_up(sc);
+		mutex_enter(sc->sc_intr_lock);
 		rv = bge_miibus_readreg(sc->bge_dev, sc->bge_phy_addr,
 		MII_BMCR, &phyreg);
 		if ((rv != 0) || ((phyreg & BMCR_PDOWN) != 0)) {
@@ -4006,6 +4016,7 @@ again:
 DELAY(1000);
 			}
 		}
+		mutex_exit(sc->sc_intr_lock);
 
 		mii_attach(sc->bge_dev, mii, capmask, sc->bge_phy_addr,
 		MII_OFFSET_ANY, mii_flags);
@@ -4080,6 +4091,8 @@ again:
 #ifdef BGE_DEBUG
 	bge_debug_info(sc);

CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 15:27:01 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: if_ure.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #967):

sys/dev/usb/usbdevs: revision 1.816
sys/dev/usb/if_ure.c: revision 1.60

PR/58250: RVP: Add TP-Link UE300 USB LAN adapter


To generate a diff of this commit:
cvs rdiff -u -r1.58.4.1 -r1.58.4.2 src/sys/dev/usb/if_ure.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/if_ure.c
diff -u src/sys/dev/usb/if_ure.c:1.58.4.1 src/sys/dev/usb/if_ure.c:1.58.4.2
--- src/sys/dev/usb/if_ure.c:1.58.4.1	Sat Oct 14 06:58:19 2023
+++ src/sys/dev/usb/if_ure.c	Sun Oct 13 15:27:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ure.c,v 1.58.4.1 2023/10/14 06:58:19 martin Exp $	*/
+/*	$NetBSD: if_ure.c,v 1.58.4.2 2024/10/13 15:27:01 martin Exp $	*/
 /*	$OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $	*/
 
 /*-
@@ -30,7 +30,7 @@
 /* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.58.4.1 2023/10/14 06:58:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.58.4.2 2024/10/13 15:27:01 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -72,7 +72,8 @@ int	uredebug = 0;
 
 static const struct usb_devno ure_devs[] = {
 	{ USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8152 },
-	{ USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8153 }
+	{ USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8153 },
+	{ USB_VENDOR_TPLINK,  USB_PRODUCT_TPLINK_UE300 },
 };
 
 #define URE_BUFSZ	(16 * 1024)



CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 15:27:01 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: if_ure.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #967):

sys/dev/usb/usbdevs: revision 1.816
sys/dev/usb/if_ure.c: revision 1.60

PR/58250: RVP: Add TP-Link UE300 USB LAN adapter


To generate a diff of this commit:
cvs rdiff -u -r1.58.4.1 -r1.58.4.2 src/sys/dev/usb/if_ure.c

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



CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 15:26:39 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: usbdevs.h usbdevs_data.h

Log Message:
Regen for ticket #967 (add TP-Link UE300)


To generate a diff of this commit:
cvs rdiff -u -r1.798.4.4 -r1.798.4.5 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.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/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.798.4.4 src/sys/dev/usb/usbdevs.h:1.798.4.5
--- src/sys/dev/usb/usbdevs.h:1.798.4.4	Thu Jun 20 17:52:50 2024
+++ src/sys/dev/usb/usbdevs.h	Sun Oct 13 15:26:37 2024
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.798.4.4 2024/06/20 17:52:50 martin Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.798.4.5 2024/10/13 15:26:37 martin Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.806.4.4 2024/06/20 17:52:12 martin Exp
+ *	NetBSD: usbdevs,v 1.806.4.5 2024/10/13 15:25:37 martin Exp
  */
 
 /*-
@@ -3466,6 +3466,7 @@
 #define	USB_PRODUCT_TPLINK_T4UV2	0x010d		/* Archer T4U ver 2 */
 #define	USB_PRODUCT_TPLINK_T4UHV2	0x010e		/* Archer T4UH ver 2 */
 #define	USB_PRODUCT_TPLINK_T2UNANO	0x011e		/* Archer T2U Nano */
+#define	USB_PRODUCT_TPLINK_UE300	0x0601		/* UE300 10/100/1000 LAN */
 
 /* Trek Technology products */
 #define	USB_PRODUCT_TREK_THUMBDRIVE	0x		/* ThumbDrive */
Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.798.4.4 src/sys/dev/usb/usbdevs_data.h:1.798.4.5
--- src/sys/dev/usb/usbdevs_data.h:1.798.4.4	Thu Jun 20 17:52:50 2024
+++ src/sys/dev/usb/usbdevs_data.h	Sun Oct 13 15:26:37 2024
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.798.4.4 2024/06/20 17:52:50 martin Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.798.4.5 2024/10/13 15:26:37 martin Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.806.4.4 2024/06/20 17:52:12 martin Exp
+ *	NetBSD: usbdevs,v 1.806.4.5 2024/10/13 15:25:37 martin Exp
  */
 
 /*-
@@ -4756,168 +4756,170 @@ static const uint32_t usb_products[] = {
 	19993, 20004, 7631, 6612, 0,
 	USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_T2UNANO, 
 	19993, 20009, 6963, 0,
+	USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_UE300, 
+	20013, 20019, 7447, 0,
 	USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE, 
-	20013, 0,
+	20031, 0,
 	USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE_8MB, 
-	20013, 20024, 0,
+	20031, 20042, 0,
 	USB_VENDOR_TRENDNET, USB_PRODUCT_TRENDNET_RTL8192CU, 
 	5270, 0,
 	USB_VENDOR_TRENDNET, USB_PRODUCT_TRENDNET_RTL8188CU, 
 	5290, 0,
 	USB_VENDOR_TRENDNET, USB_PRODUCT_TRENDNET_TEW648UBM, 
-	20028, 0,
+	20046, 0,
 	USB_VENDOR_TRIPPLITE, USB_PRODUCT_TRIPPLITE_U209, 
-	20039, 7032, 4995, 0,
+	20057, 7032, 4995, 0,
 	USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_UPS, 
 	3207, 3213, 480, 0,
 	USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_SMARTLCD, 
-	20044, 480, 0,
+	20062, 480, 0,
 	USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_AVR550U, 
-	3207, 3213, 20053, 0,
+	3207, 3213, 20071, 0,
 	USB_VENDOR_TRUMPION, USB_PRODUCT_TRUMPION_T33521, 
-	20061, 20069, 0,
+	20079, 20087, 0,
 	USB_VENDOR_TRUMPION, USB_PRODUCT_TRUMPION_XXX1100, 
-	16353, 20077, 0,
+	16353, 20095, 0,
 	USB_VENDOR_TSUNAMI, USB_PRODUCT_TSUNAMI_SM2000, 
-	20082, 0,
+	20100, 0,
 	USB_VENDOR_TWINMOS, USB_PRODUCT_TWINMOS_G240, 
-	20090, 0,
+	20108, 0,
 	USB_VENDOR_ULTIMA, USB_PRODUCT_ULTIMA_1200UBPLUS, 
 	11613, 15235, 11503, 7333, 0,
 	USB_VENDOR_ULTIMA, USB_PRODUCT_ULTIMA_T14BR, 
-	20095, 20101, 6933, 0,
+	20113, 20119, 6933, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1236U, 
-	20107, 5766, 20113, 0,
+	20125, 5766, 20131, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1220U, 
-	20107, 20121, 20113, 0,
+	20125, 20139, 20131, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2000U, 
-	20107, 20127, 20113, 0,
+	20125, 20145, 20131, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA3400, 
-	20107, 20133, 20113, 0,
+	20125, 20151, 20131, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2100U, 
-	20107, 20138, 20113, 0,
+	20125, 20156, 20131, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2200U, 
-	20107, 20144, 20113, 0,
+	20125, 20162, 20131, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UB_A, 
-	20150, 0,
+	20168, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UB, 
-	20162, 0,
+	20180, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UBC1, 
-	20162, 9539, 0,
+	20180, 9539, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_RT2870_1, 
 	5149, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW645UB, 
-	20172, 0,
+	20190, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_ALL

CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 15:26:39 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: usbdevs.h usbdevs_data.h

Log Message:
Regen for ticket #967 (add TP-Link UE300)


To generate a diff of this commit:
cvs rdiff -u -r1.798.4.4 -r1.798.4.5 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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



CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 15:25:38 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: usbdevs

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #967):

sys/dev/usb/usbdevs: revision 1.816
sys/dev/usb/if_ure.c: revision 1.60

PR/58250: RVP: Add TP-Link UE300 USB LAN adapter


To generate a diff of this commit:
cvs rdiff -u -r1.806.4.4 -r1.806.4.5 src/sys/dev/usb/usbdevs

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



CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 15:25:38 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: usbdevs

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #967):

sys/dev/usb/usbdevs: revision 1.816
sys/dev/usb/if_ure.c: revision 1.60

PR/58250: RVP: Add TP-Link UE300 USB LAN adapter


To generate a diff of this commit:
cvs rdiff -u -r1.806.4.4 -r1.806.4.5 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.806.4.4 src/sys/dev/usb/usbdevs:1.806.4.5
--- src/sys/dev/usb/usbdevs:1.806.4.4	Thu Jun 20 17:52:12 2024
+++ src/sys/dev/usb/usbdevs	Sun Oct 13 15:25:37 2024
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.806.4.4 2024/06/20 17:52:12 martin Exp $
+$NetBSD: usbdevs,v 1.806.4.5 2024/10/13 15:25:37 martin Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -3459,6 +3459,7 @@ product TPLINK RTL8188EU	0x010c	RTL8188E
 product	TPLINK T4UV2		0x010d  Archer T4U ver 2
 product	TPLINK T4UHV2		0x010e  Archer T4UH ver 2
 product	TPLINK T2UNANO		0x011e  Archer T2U Nano
+product	TPLINK UE300		0x0601	UE300 10/100/1000 LAN
 
 /* Trek Technology products */
 product TREK THUMBDRIVE		0x	ThumbDrive



CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 15:18:08 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: if_url.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #965):

sys/dev/usb/if_url.c: revision 1.98

url(4): uint32_t for 32-bit hash so h>>31 becomes 0/1, not +1/-1.

Should avoid buffer overrun in PR 58382.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.97.4.1 src/sys/dev/usb/if_url.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/if_url.c
diff -u src/sys/dev/usb/if_url.c:1.97 src/sys/dev/usb/if_url.c:1.97.4.1
--- src/sys/dev/usb/if_url.c:1.97	Sat Aug 20 14:08:59 2022
+++ src/sys/dev/usb/if_url.c	Sun Oct 13 15:18:07 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_url.c,v 1.97 2022/08/20 14:08:59 riastradh Exp $	*/
+/*	$NetBSD: if_url.c,v 1.97.4.1 2024/10/13 15:18:07 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.97 2022/08/20 14:08:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.97.4.1 2024/10/13 15:18:07 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -422,7 +422,7 @@ url_uno_mcast(struct ifnet *ifp)
 	struct ether_multi *enm;
 	struct ether_multistep step;
 	uint32_t mchash[2] = { 0, 0 };
-	int h = 0, rcr;
+	uint32_t h = 0, rcr;
 
 	DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
 



CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 15:18:08 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: if_url.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #965):

sys/dev/usb/if_url.c: revision 1.98

url(4): uint32_t for 32-bit hash so h>>31 becomes 0/1, not +1/-1.

Should avoid buffer overrun in PR 58382.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.97.4.1 src/sys/dev/usb/if_url.c

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



CVS commit: [netbsd-10] src/sys/arch/xen/xen

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 14:38:13 UTC 2024

Modified Files:
src/sys/arch/xen/xen [netbsd-10]: xen_clock.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #961):

sys/arch/xen/xen/xen_clock.c: revision 1.19

xen_rtc_set: Zero-initialize op before passing to hypervisor.

PR port-xen/58362


To generate a diff of this commit:
cvs rdiff -u -r1.8.18.1 -r1.8.18.2 src/sys/arch/xen/xen/xen_clock.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/xen/xen/xen_clock.c
diff -u src/sys/arch/xen/xen/xen_clock.c:1.8.18.1 src/sys/arch/xen/xen/xen_clock.c:1.8.18.2
--- src/sys/arch/xen/xen/xen_clock.c:1.8.18.1	Wed Jul 19 14:31:40 2023
+++ src/sys/arch/xen/xen/xen_clock.c	Sun Oct 13 14:38:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_clock.c,v 1.8.18.1 2023/07/19 14:31:40 martin Exp $	*/
+/*	$NetBSD: xen_clock.c,v 1.8.18.2 2024/10/13 14:38:13 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017, 2018 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_clock.c,v 1.8.18.1 2023/07/19 14:31:40 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_clock.c,v 1.8.18.2 2024/10/13 14:38:13 martin Exp $");
 
 #include 
 #include 
@@ -946,6 +946,7 @@ xen_rtc_set(struct todr_chip_handle *tod
 		systime_ns = xen_global_systime_ns();
 
 		/* Set the hypervisor wall clock time.  */
+		memset(&op, 0, sizeof(op));
 		op.cmd = XENPF_settime;
 		op.u.settime.secs = tvp->tv_sec;
 		op.u.settime.nsecs = tvp->tv_usec * 1000;



CVS commit: [netbsd-10] src/sys/arch/xen/xen

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 14:38:13 UTC 2024

Modified Files:
src/sys/arch/xen/xen [netbsd-10]: xen_clock.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #961):

sys/arch/xen/xen/xen_clock.c: revision 1.19

xen_rtc_set: Zero-initialize op before passing to hypervisor.

PR port-xen/58362


To generate a diff of this commit:
cvs rdiff -u -r1.8.18.1 -r1.8.18.2 src/sys/arch/xen/xen/xen_clock.c

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



CVS commit: [netbsd-10] src/sys/arch/aarch64

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 10:43:11 UTC 2024

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-10]: cpu.c
src/sys/arch/aarch64/include [netbsd-10]: cpu.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #955):

sys/arch/aarch64/aarch64/cpu.c: revision 1.78
sys/arch/aarch64/include/cpu.h: revision 1.51

aarch64: Count RNDRRS failure events and add dtrace probe.

PR port-arm/58572: aarch64 RNDRRS failures should be evcounted and
dtraced


To generate a diff of this commit:
cvs rdiff -u -r1.70.4.3 -r1.70.4.4 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.48 -r1.48.2.1 src/sys/arch/aarch64/include/cpu.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/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.70.4.3 src/sys/arch/aarch64/aarch64/cpu.c:1.70.4.4
--- src/sys/arch/aarch64/aarch64/cpu.c:1.70.4.3	Thu Oct  3 16:11:36 2024
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sun Oct 13 10:43:11 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.70.4.3 2024/10/03 16:11:36 martin Exp $ */
+/* $NetBSD: cpu.c,v 1.70.4.4 2024/10/13 10:43:11 martin Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.70.4.3 2024/10/03 16:11:36 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.70.4.4 2024/10/13 10:43:11 martin Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -42,6 +42,7 @@ __KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.70
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -166,6 +167,8 @@ cpu_attach(device_t dv, cpuid_t id)
 	aarch64_printcacheinfo(dv, ci);
 	cpu_identify2(dv, ci);
 
+	cpu_setup_rng(dv, ci);
+
 	if (unit != 0) {
 	return;
 	}
@@ -177,7 +180,6 @@ cpu_attach(device_t dv, cpuid_t id)
 	cpu_init_counter(ci);
 
 	/* These currently only check the BP. */
-	cpu_setup_rng(dv, ci);
 	cpu_setup_aes(dv, ci);
 	cpu_setup_chacha(dv, ci);
 }
@@ -584,8 +586,9 @@ rndrrs_get(size_t nbytes, void *cookie)
 	const unsigned bpb = 4;
 	size_t nbits = nbytes*NBBY;
 	uint64_t x;
-	int error;
+	int error, bound;
 
+	bound = curlwp_bind();	/* bind to CPU for rndrrs_fail evcnt */
 	while (nbits) {
 		/*
 		 * x := random 64-bit sample
@@ -605,12 +608,16 @@ rndrrs_get(size_t nbytes, void *cookie)
 		"mrs	%0, s3_3_c2_c4_1\n"
 		"cset	%w1, eq"
 		: "=r"(x), "=r"(error));
-		if (error)
+		if (error) {
+			DTRACE_PROBE(rndrrs_fail);
+			curcpu()->ci_rndrrs_fail.ev_count++;
 			break;
+		}
 		rnd_add_data_sync(&rndrrs_source, &x, sizeof(x),
 		bpb*sizeof(x));
 		nbits -= MIN(nbits, bpb*sizeof(x));
 	}
+	curlwp_bindx(bound);
 
 	explicit_memset(&x, 0, sizeof x);
 }
@@ -631,7 +638,16 @@ cpu_setup_rng(device_t dv, struct cpu_in
 		return;
 	}
 
-	/* Attach it.  */
+	/* Attach event counter for RNDRRS failure.  */
+	evcnt_attach_dynamic(&ci->ci_rndrrs_fail, EVCNT_TYPE_MISC, NULL,
+	ci->ci_cpuname, "rndrrs fail");
+
+	/*
+	 * On the primary CPU, attach random source -- this only
+	 * happens once globally.
+	 */
+	if (!CPU_IS_PRIMARY(ci))
+		return;
 	rndsource_setcb(&rndrrs_source, rndrrs_get, NULL);
 	rnd_attach_source(&rndrrs_source, "rndrrs", RND_TYPE_RNG,
 	RND_FLAG_DEFAULT|RND_FLAG_HASCB);

Index: src/sys/arch/aarch64/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.48 src/sys/arch/aarch64/include/cpu.h:1.48.2.1
--- src/sys/arch/aarch64/include/cpu.h:1.48	Thu Nov  3 09:04:56 2022
+++ src/sys/arch/aarch64/include/cpu.h	Sun Oct 13 10:43:11 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.48 2022/11/03 09:04:56 skrll Exp $ */
+/* $NetBSD: cpu.h,v 1.48.2.1 2024/10/13 10:43:11 martin Exp $ */
 
 /*-
  * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -154,6 +154,7 @@ struct cpu_info {
 	struct evcnt ci_vfp_release;
 	struct evcnt ci_uct_trap;
 	struct evcnt ci_intr_preempt;
+	struct evcnt ci_rndrrs_fail;
 
 	/* FDT or similar supplied "cpu capacity" */
 	uint32_t ci_capacity_dmips_mhz;



CVS commit: [netbsd-10] src/sys/arch/aarch64

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 10:43:11 UTC 2024

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-10]: cpu.c
src/sys/arch/aarch64/include [netbsd-10]: cpu.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #955):

sys/arch/aarch64/aarch64/cpu.c: revision 1.78
sys/arch/aarch64/include/cpu.h: revision 1.51

aarch64: Count RNDRRS failure events and add dtrace probe.

PR port-arm/58572: aarch64 RNDRRS failures should be evcounted and
dtraced


To generate a diff of this commit:
cvs rdiff -u -r1.70.4.3 -r1.70.4.4 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.48 -r1.48.2.1 src/sys/arch/aarch64/include/cpu.h

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



CVS commit: [netbsd-10] src/sys/sys

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 10:05:58 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: rbtree.h

Log Message:
Additionaly pull up following revision(s) (requested by riastradh in ticket 
#952):

sys/sys/rbtree.h: revision 1.10
sys/sys/rbtree.h: revision 1.11
sys/sys/rbtree.h: revision 1.9

This uses size_t, so it always needs , remove ifdefs.

Put back  - but only when RBDEBUG is defined (the
similarly conditional rb_tree_check() prototype needs "bool").

Fix previous so  isn't included with _KERNEL (etc).
Like it used to be.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.30.1 src/sys/sys/rbtree.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/rbtree.h
diff -u src/sys/sys/rbtree.h:1.5 src/sys/sys/rbtree.h:1.5.30.1
--- src/sys/sys/rbtree.h:1.5	Thu Mar  7 14:39:21 2019
+++ src/sys/sys/rbtree.h	Sun Oct 13 10:05:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: rbtree.h,v 1.5 2019/03/07 14:39:21 roy Exp $	*/
+/*	$NetBSD: rbtree.h,v 1.5.30.1 2024/10/13 10:05:58 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -41,6 +41,10 @@
 #include 
 #include 
 
+#if !defined(_KERNEL) && !defined(_STANDALONE) && defined(RBDEBUG)
+#include 
+#endif
+
 __BEGIN_DECLS
 
 typedef struct rb_node {



CVS commit: [netbsd-10] src/sys/sys

2024-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 13 10:05:58 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: rbtree.h

Log Message:
Additionaly pull up following revision(s) (requested by riastradh in ticket 
#952):

sys/sys/rbtree.h: revision 1.10
sys/sys/rbtree.h: revision 1.11
sys/sys/rbtree.h: revision 1.9

This uses size_t, so it always needs , remove ifdefs.

Put back  - but only when RBDEBUG is defined (the
similarly conditional rb_tree_check() prototype needs "bool").

Fix previous so  isn't included with _KERNEL (etc).
Like it used to be.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.30.1 src/sys/sys/rbtree.h

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



CVS commit: [netbsd-10] src/sys/conf

2024-10-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Oct 12 11:16:04 UTC 2024

Modified Files:
src/sys/conf [netbsd-10]: newvers.mk newvers.sh newvers_stand.mk
newvers_stand.sh

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #953):

sys/conf/newvers_stand.sh: revision 1.10
sys/conf/newvers.mk: revision 1.3
sys/conf/newvers.mk: revision 1.4
sys/conf/newvers.sh: revision 1.63
sys/conf/newvers.sh: revision 1.64
sys/conf/newvers_stand.mk: revision 1.5

Use ${TOOL_DATE} (Jan-Benedict Glaw)
PR/58220: Kouichi Hashikawa: use ${TOOL_AWK}


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.46.1 src/sys/conf/newvers.mk
cvs rdiff -u -r1.62 -r1.62.44.1 src/sys/conf/newvers.sh
cvs rdiff -u -r1.4 -r1.4.12.1 src/sys/conf/newvers_stand.mk
cvs rdiff -u -r1.9 -r1.9.44.1 src/sys/conf/newvers_stand.sh

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



CVS commit: [netbsd-10] src/sys/conf

2024-10-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Oct 12 11:16:04 UTC 2024

Modified Files:
src/sys/conf [netbsd-10]: newvers.mk newvers.sh newvers_stand.mk
newvers_stand.sh

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #953):

sys/conf/newvers_stand.sh: revision 1.10
sys/conf/newvers.mk: revision 1.3
sys/conf/newvers.mk: revision 1.4
sys/conf/newvers.sh: revision 1.63
sys/conf/newvers.sh: revision 1.64
sys/conf/newvers_stand.mk: revision 1.5

Use ${TOOL_DATE} (Jan-Benedict Glaw)
PR/58220: Kouichi Hashikawa: use ${TOOL_AWK}


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.46.1 src/sys/conf/newvers.mk
cvs rdiff -u -r1.62 -r1.62.44.1 src/sys/conf/newvers.sh
cvs rdiff -u -r1.4 -r1.4.12.1 src/sys/conf/newvers_stand.mk
cvs rdiff -u -r1.9 -r1.9.44.1 src/sys/conf/newvers_stand.sh

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/newvers.mk
diff -u src/sys/conf/newvers.mk:1.2 src/sys/conf/newvers.mk:1.2.46.1
--- src/sys/conf/newvers.mk:1.2	Sat Apr  8 18:24:09 2017
+++ src/sys/conf/newvers.mk	Sat Oct 12 11:16:04 2024
@@ -1,4 +1,4 @@
-# $NetBSD: newvers.mk,v 1.2 2017/04/08 18:24:09 christos Exp $
+# $NetBSD: newvers.mk,v 1.2.46.1 2024/10/12 11:16:04 martin Exp $
 
 MKREPRO?=no
 
@@ -17,7 +17,8 @@ newvers: vers.o
 vers.o: ${SYSTEM_OBJ:O} Makefile $S/conf/newvers.sh \
 		$S/conf/osrelease.sh ${_NETBSD_VERSION_DEPENDS}
 	${_MKMSG_CREATE} vers.c
-	${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
+	TOOL_AWK=${TOOL_AWK} TOOL_DATE=${TOOL_DATE} \
+	${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
 	${_MKTARGET_COMPILE}
 	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
 	${COMPILE_CTFCONVERT}

Index: src/sys/conf/newvers.sh
diff -u src/sys/conf/newvers.sh:1.62 src/sys/conf/newvers.sh:1.62.44.1
--- src/sys/conf/newvers.sh:1.62	Sat Apr  8 18:24:09 2017
+++ src/sys/conf/newvers.sh	Sat Oct 12 11:16:04 2024
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#	$NetBSD: newvers.sh,v 1.62 2017/04/08 18:24:09 christos Exp $
+#	$NetBSD: newvers.sh,v 1.62.44.1 2024/10/12 11:16:04 martin Exp $
 #
 # Copyright (c) 1984, 1986, 1990, 1993
 #	The Regents of the University of California.  All rights reserved.
@@ -134,7 +134,7 @@ source_lines()
 	else
 		cat
 	fi \
-	| awk '{
+	| "${AWK}" '{
 		# awk does not care about whether or not the last line
 		# of input ends with a newline.
 		# Convert  to .
@@ -153,6 +153,8 @@ if [ ! -e version ]; then
 	echo 0 > version
 fi
 
+DATE=${TOOL_DATE:-date}
+AWK=${TOOL_AWK:-awk}
 Rflag=false
 nflag=false
 timestamp=
@@ -206,7 +208,7 @@ if ${Rflag}; then
 else
 	if [ -z "${timestamp}" ]; then
 		v=$(cat version)
-		t=$(LC_ALL=C date)
+		t=$(LC_ALL=C ${DATE})
 		u=${USER-root}
 		h=$(hostname)
 		d=$(pwd)
@@ -214,7 +216,7 @@ else
 		echo $(expr ${v} + 1) > version
 	else
 		v=0
-		t=$(LC_ALL=C TZ=UTC date -r "${timestamp}")
+		t=$(LC_ALL=C TZ=UTC ${DATE} -r "${timestamp}")
 		u=mkrepro
 		h=mkrepro.NetBSD.org
 		d="/usr/src/sys/arch/${machine}/compile/${id}"

Index: src/sys/conf/newvers_stand.mk
diff -u src/sys/conf/newvers_stand.mk:1.4 src/sys/conf/newvers_stand.mk:1.4.12.1
--- src/sys/conf/newvers_stand.mk:1.4	Fri May 21 11:28:11 2021
+++ src/sys/conf/newvers_stand.mk	Sat Oct 12 11:16:04 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: newvers_stand.mk,v 1.4 2021/05/21 11:28:11 nakayama Exp $
+#	$NetBSD: newvers_stand.mk,v 1.4.12.1 2024/10/12 11:16:04 martin Exp $
 
 VERSIONFILE?=version
 VERSIONMACHINE?=${MACHINE}
@@ -19,7 +19,7 @@ VERSIONFLAGS+=-d
 
 vers.c:	${VERSIONFILE} ${_NETBSD_VERSION_DEPENDS}
 	${_MKTARGET_CREATE}
-	${HOST_SH} ${S}/conf/newvers_stand.sh \
+	TOOL_DATE=${TOOL_DATE} ${HOST_SH} ${S}/conf/newvers_stand.sh \
 	-m ${VERSIONMACHINE} ${VERSIONFLAGS} ${.ALLSRC:[1]} ${NEWVERSWHAT}
 
 .endif

Index: src/sys/conf/newvers_stand.sh
diff -u src/sys/conf/newvers_stand.sh:1.9 src/sys/conf/newvers_stand.sh:1.9.44.1
--- src/sys/conf/newvers_stand.sh:1.9	Sat Apr  8 19:53:54 2017
+++ src/sys/conf/newvers_stand.sh	Sat Oct 12 11:16:04 2024
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-# $NetBSD: newvers_stand.sh,v 1.9 2017/04/08 19:53:54 christos Exp $
+# $NetBSD: newvers_stand.sh,v 1.9.44.1 2024/10/12 11:16:04 martin Exp $
 #
 # Copyright (c) 2000 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -35,6 +35,8 @@
 # Called as:
 #	sh ${S}/conf/newvers_stand.sh [-dkn] [-D ] [-m ] VERSION_TEMPLATE [EXTRA_MSG]
 
+DATE=${TOOL_DATE:-date}
+
 cwd=$(dirname "$0")
 
 add_name=true
@@ -45,8 +47,8 @@ dateargs=
 
 # parse command args
 while getopts "m:D:dknm:" OPT; do
-	case $OPT in
-	D)	dateargs="-r $OPTARG";;
+	case ${OPT} in
+	D)	dateargs="-r ${OPTARG}";;
 	d)	add_date=false;;
 	k)	add_kernrev=false;;
 	m)	machine=${OPTARG};;
@@ -56,25 +58,25 @@ while getopts "m:D:dknm:" OPT; do
 	esac
 done
 
-shift $(expr $OPTIND - 1)
+shift $(expr ${OPTIND} - 1)
 
 r=$(awk -F: '$1 ~ /^[0-9.]*$/ { it = $1; } END { print it }' "$1")
 shift
-t=$(LC_ALL=C 

CVS commit: [netbsd-10] src/sys/sys

2024-10-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 11 19:07:20 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: endian.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #952):

sys/sys/endian.h: revision 1.32
sys/sys/endian.h: revision 1.33
sys/sys/endian.h: revision 1.34
sys/sys/endian.h: revision 1.35

break the cycle: this does not need  it only needs 

arpa/inet.h: Define htonl &c. under _POSIX_C_SOURCE >= 200112L too.
These do not require _XOPEN_SOURCE as of POSIX 2001:
https://pubs.opengroup.org/onlinepubs/009696799/functions/htonl.html

XXX Since this change is actually sys/endian.h, in principle it might
bleed into header files than just arpa/inet.h.  But sys/endian.h is
not used by anything that looks especially risky to me.

PR standards/57806: #include  fails to define
htonl/htons/ntohl/ntohs under _POSIX_C_SOURCE=200809L

sys/endian.h: Hide le32enc/be32enc/... under _NETBSD_SOURCE.
These are non-standard extensions, so they should not be exposed by,
e.g., _XOPEN_SOURCE=700.

PR standards/57807: #include  spuriously defines
le32enc/be32enc/... under _XOPEN_SOURCE=700

sys/endian.h: sync comment with code


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.4.1 src/sys/sys/endian.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/endian.h
diff -u src/sys/sys/endian.h:1.31 src/sys/sys/endian.h:1.31.4.1
--- src/sys/sys/endian.h:1.31	Mon Aug  8 18:55:18 2022
+++ src/sys/sys/endian.h	Fri Oct 11 19:07:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: endian.h,v 1.31 2022/08/08 18:55:18 rillig Exp $	*/
+/*	$NetBSD: endian.h,v 1.31.4.1 2024/10/11 19:07:20 martin Exp $	*/
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -45,14 +45,16 @@
 #define	_PDP_ENDIAN	3412	/* LSB first in word, MSW first in long */
 
 
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+#if defined(_XOPEN_SOURCE) || \
+(_POSIX_C_SOURCE - 0) >= 200112L || \
+defined(_NETBSD_SOURCE)
 #ifndef _LOCORE
 
 /* C-family endian-ness definitions */
 
 #include 
 #include 
-#include 
+#include 
 
 #ifndef in_addr_t
 typedef __in_addr_t	in_addr_t;
@@ -72,7 +74,7 @@ uint16_t ntohs(uint16_t) __constfunc;
 __END_DECLS
 
 #endif /* !_LOCORE */
-#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
+#endif /* _XOPEN_SOURCE || _POSIX_C_SOURCE >= 200112L || _NETBSD_SOURCE */
 
 
 #include 
@@ -190,6 +192,8 @@ __END_DECLS
  * to/from an octet stream.
  */
 
+#ifdef _NETBSD_SOURCE
+
 #if __GNUC_PREREQ__(2, 95)
 
 #define __GEN_ENDIAN_ENC(bits, endian) \
@@ -335,6 +339,8 @@ le64dec(const void *buf)
 
 #endif	/* GCC >= 2.95 */
 
+#endif	/* _NETBSD_SOURCE */
+
 #endif /* !_LOCORE */
 #endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
 #endif /* !_SYS_ENDIAN_H_ */



CVS commit: [netbsd-10] src/sys/sys

2024-10-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 11 19:07:20 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: endian.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #952):

sys/sys/endian.h: revision 1.32
sys/sys/endian.h: revision 1.33
sys/sys/endian.h: revision 1.34
sys/sys/endian.h: revision 1.35

break the cycle: this does not need  it only needs 

arpa/inet.h: Define htonl &c. under _POSIX_C_SOURCE >= 200112L too.
These do not require _XOPEN_SOURCE as of POSIX 2001:
https://pubs.opengroup.org/onlinepubs/009696799/functions/htonl.html

XXX Since this change is actually sys/endian.h, in principle it might
bleed into header files than just arpa/inet.h.  But sys/endian.h is
not used by anything that looks especially risky to me.

PR standards/57806: #include  fails to define
htonl/htons/ntohl/ntohs under _POSIX_C_SOURCE=200809L

sys/endian.h: Hide le32enc/be32enc/... under _NETBSD_SOURCE.
These are non-standard extensions, so they should not be exposed by,
e.g., _XOPEN_SOURCE=700.

PR standards/57807: #include  spuriously defines
le32enc/be32enc/... under _XOPEN_SOURCE=700

sys/endian.h: sync comment with code


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.4.1 src/sys/sys/endian.h

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



CVS commit: [netbsd-10] src/sys/sys

2024-10-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 11 18:51:21 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: featuretest.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #949):

sys/sys/featuretest.h: revision 1.13

sys/featuretest.h: Define _POSIX_C_SOURCE according to _XOPEN_SOURCE.

If _XOPEN_SOURCE is defined but _POSIX_C_SOURCE is not, there is a
corresponding value of _POSIX_C_SOURCE that _XOPEN_SOURCE is supposed
to be equivalent to.  We could sprinkle conditionals for
_XOPEN_SOURCE everywhere we already have conditionals for
_POSIX_C_SOURCE, like in , but it's simpler and more
reliable to simply define _POSIX_C_SOURCE based on _XOPEN_SOURCE in
one place.

PR standards/55577: locale_t not defined if _XOPEN_SOURCE is defined


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.66.1 src/sys/sys/featuretest.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/featuretest.h
diff -u src/sys/sys/featuretest.h:1.10 src/sys/sys/featuretest.h:1.10.66.1
--- src/sys/sys/featuretest.h:1.10	Fri Apr 26 18:29:06 2013
+++ src/sys/sys/featuretest.h	Fri Oct 11 18:51:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: featuretest.h,v 1.10 2013/04/26 18:29:06 christos Exp $	*/
+/*	$NetBSD: featuretest.h,v 1.10.66.1 2024/10/11 18:51:20 martin Exp $	*/
 
 /*
  * Written by Klaus Klein , February 2, 1998.
@@ -74,3 +74,61 @@
 !defined(_REENTRANT)
 #define _REENTRANT
 #endif
+
+/*
+ * The _XOPEN_SOURCE namespaces are supersets of corresponding
+ * _POSIX_C_SOURCE namespaces, so to keep the namespace tests in header
+ * files simpler, if _XOPEN_SOURCE is defined but _POSIX_C_SOURCE is
+ * not, define _POSIX_C_SOURCE to the corresponding value.
+ */
+#if defined(_XOPEN_SOURCE) && !defined(_POSIX_C_SOURCE)
+
+/*
+ * `[I]f _XOPEN_SOURCE is set equal to 800 and _POSIX_C_SOURCE is set
+ *  equal to 202405L, the behavior is the same as if only _XOPEN_SOURCE
+ *  is defined and set equal to 800.
+ *
+ * IEEE Std 1003.1-2024, 2.2.1.2 `The _XOPEN_SOURCE Feature Test Macro'
+ * https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/V2_chap02.html#tag_16_02_01_02
+ */
+#if (_XOPEN_SOURCE - 0) == 800
+#define	_POSIX_C_SOURCE	202405L
+
+/*
+ * `[I]f _XOPEN_SOURCE is set equal to 700 and _POSIX_C_SOURCE is set
+ *  equal to 200809L, the behavior is the same as if only _XOPEN_SOURCE
+ *  is defined and set equal to 700.'
+ *
+ * IEEE Std 1003.1-2008, 2.2.1 `POSIX.1 Symbols', subsection `The
+ * _XOPEN_SOURCE Feature Test Macro'
+ * https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/V2_chap02.html
+ */
+#elif (_XOPEN_SOURCE - 0) == 700
+#define	_POSIX_C_SOURCE	200809L
+
+/*
+ * `[I]f _XOPEN_SOURCE is set equal to 600 and _POSIX_C_SOURCE is set
+ *  equal to 200112L, the behavior is the same as if only _XOPEN_SOURCE
+ *  is defined and set equal to 600.'
+ *
+ * IEEE Std 1003.1-2001, 2.2.1 `POSIX.1 Symbols', subsection `The
+ * _XOPEN_SOURCE Feature Test Macro'
+ * https://pubs.opengroup.org/onlinepubs/007904875/functions/xsh_chap02_02.html
+ */
+#elif (_XOPEN_SOURCE - 0) == 600
+#define	_POSIX_C_SOURCE	200112L
+
+/*
+ * `[I]f _XOPEN_SOURCE is set equal to 500 and _POSIX_SOURCE is
+ *  defined, or _POSIX_C_SOURCE is set greater than zero and less than
+ *  or equal to 199506L, the behaviour is the same as if only
+ *  _XOPEN_SOURCE is defined and set equal to 500.'
+ *
+ * Single UNIX Specification, Version 2, `The Compilation Environment'
+ * https://pubs.opengroup.org/onlinepubs/007908799/xsh/compilation.html
+ */
+#elif (_XOPEN_SOURCE - 0) == 500
+#define	_POSIX_C_SOURCE	199506L
+#endif
+
+#endif



CVS commit: [netbsd-10] src/sys/sys

2024-10-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 11 18:51:21 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: featuretest.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #949):

sys/sys/featuretest.h: revision 1.13

sys/featuretest.h: Define _POSIX_C_SOURCE according to _XOPEN_SOURCE.

If _XOPEN_SOURCE is defined but _POSIX_C_SOURCE is not, there is a
corresponding value of _POSIX_C_SOURCE that _XOPEN_SOURCE is supposed
to be equivalent to.  We could sprinkle conditionals for
_XOPEN_SOURCE everywhere we already have conditionals for
_POSIX_C_SOURCE, like in , but it's simpler and more
reliable to simply define _POSIX_C_SOURCE based on _XOPEN_SOURCE in
one place.

PR standards/55577: locale_t not defined if _XOPEN_SOURCE is defined


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.66.1 src/sys/sys/featuretest.h

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



CVS commit: [netbsd-10] src/sys/sys

2024-10-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 11 18:48:01 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: signal.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #948):

sys/sys/signal.h: revision 1.76

signal.h: Fix namespacing for various SA_* constants.

References:
POSIX 2001 (items labeled XSI are restricted by _XOPEN_SOURCE):
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html

POSIX 2008 (items no longer labeled XSI are available if
_POSIX_C_SOURCE >= 200809L):
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html

PR standards/55429: SA_RESTART not available if
-D_POSIX_C_SOURCE=200809L


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.75.4.1 src/sys/sys/signal.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/signal.h
diff -u src/sys/sys/signal.h:1.75 src/sys/sys/signal.h:1.75.4.1
--- src/sys/sys/signal.h:1.75	Tue Nov  2 20:12:26 2021
+++ src/sys/sys/signal.h	Fri Oct 11 18:48:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: signal.h,v 1.75 2021/11/02 20:12:26 christos Exp $	*/
+/*	$NetBSD: signal.h,v 1.75.4.1 2024/10/11 18:48:01 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -215,17 +215,18 @@ struct	sigaction {
 #endif
 
 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
-(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
+(_XOPEN_SOURCE - 0) >= 500 || (_POSIX_C_SOURCE - 0) >= 200809L || \
+defined(_NETBSD_SOURCE)
 #define SA_ONSTACK	0x0001	/* take signal on signal stack */
 #define SA_RESTART	0x0002	/* restart system call on signal return */
 #define SA_RESETHAND	0x0004	/* reset to SIG_DFL when taking signal */
 #define SA_NODEFER	0x0010	/* don't mask the signal we're delivering */
-#endif /* _XOPEN_SOURCE_EXTENDED || XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
+#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L || _NETBSD_SOURCE */
 /* Only valid for SIGCHLD. */
 #define SA_NOCLDSTOP	0x0008	/* do not generate SIGCHLD on child stop */
-#define SA_NOCLDWAIT	0x0020	/* do not generate zombies on unwaited child */
 #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
 defined(_NETBSD_SOURCE)
+#define SA_NOCLDWAIT	0x0020	/* do not generate zombies on unwaited child */
 #define SA_SIGINFO	0x0040	/* take sa_sigaction handler */
 #endif /* (_POSIX_C_SOURCE - 0) >= 199309L || ... */
 #if defined(_NETBSD_SOURCE)



CVS commit: [netbsd-10] src/sys/sys

2024-10-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 11 18:48:01 UTC 2024

Modified Files:
src/sys/sys [netbsd-10]: signal.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #948):

sys/sys/signal.h: revision 1.76

signal.h: Fix namespacing for various SA_* constants.

References:
POSIX 2001 (items labeled XSI are restricted by _XOPEN_SOURCE):
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html

POSIX 2008 (items no longer labeled XSI are available if
_POSIX_C_SOURCE >= 200809L):
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html

PR standards/55429: SA_RESTART not available if
-D_POSIX_C_SOURCE=200809L


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.75.4.1 src/sys/sys/signal.h

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



CVS commit: [netbsd-10] src/sys/arch/x86/pci

2024-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  9 13:27:52 UTC 2024

Modified Files:
src/sys/arch/x86/pci [netbsd-10]: amdzentemp.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #940):

sys/arch/x86/pci/amdzentemp.c: revision 1.21

amdzentemp(4): Add support for CPU family 0x1a model 0x40...0x4f (Zen 5)


To generate a diff of this commit:
cvs rdiff -u -r1.16.2.2 -r1.16.2.3 src/sys/arch/x86/pci/amdzentemp.c

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

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.16.2.2 src/sys/arch/x86/pci/amdzentemp.c:1.16.2.3
--- src/sys/arch/x86/pci/amdzentemp.c:1.16.2.2	Tue Aug 22 16:07:34 2023
+++ src/sys/arch/x86/pci/amdzentemp.c	Wed Oct  9 13:27:51 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.16.2.2 2023/08/22 16:07:34 martin Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.16.2.3 2024/10/09 13:27:51 martin Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.16.2.2 2023/08/22 16:07:34 martin Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.16.2.3 2024/10/09 13:27:51 martin Exp $ ");
 
 #include 
 #include 
@@ -208,6 +208,7 @@ amdzentemp_attach(device_t parent, devic
 		break;
 	case 0x17:
 	case 0x19:
+	case 0x1a:
 		sc->sc_sme->sme_refresh = amdzentemp_family17_refresh;
 		break;
 	default:
@@ -429,6 +430,25 @@ amdzentemp_probe_ccd_sensors19h(struct a
 }
 
 static int
+amdzentemp_probe_ccd_sensors1ah(struct amdzentemp_softc *sc, int model)
+{
+	int maxreg;
+
+	switch (model) {
+	case 0x40 ... 0x4f: /* Zen5 */
+		sc->sc_ccd_offset = 0x300;
+		maxreg = 8;
+		break;
+	default:
+		aprint_error_dev(sc->sc_dev,
+		"Unrecognized Family 19h Model: %02xh\n", model);
+		return 0;
+	}
+
+	return maxreg;
+}
+
+static int
 amdzentemp_probe_ccd_sensors(struct amdzentemp_softc *sc, int family, int model)
 {
 	int nccd;
@@ -440,6 +460,9 @@ amdzentemp_probe_ccd_sensors(struct amdz
 	case 0x19:
 		nccd = amdzentemp_probe_ccd_sensors19h(sc, model);
 		break;
+	case 0x1a:
+		nccd = amdzentemp_probe_ccd_sensors1ah(sc, model);
+		break;
 	default:
 		return 0;
 	}



CVS commit: [netbsd-10] src/sys/arch/x86/pci

2024-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  9 13:27:52 UTC 2024

Modified Files:
src/sys/arch/x86/pci [netbsd-10]: amdzentemp.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #940):

sys/arch/x86/pci/amdzentemp.c: revision 1.21

amdzentemp(4): Add support for CPU family 0x1a model 0x40...0x4f (Zen 5)


To generate a diff of this commit:
cvs rdiff -u -r1.16.2.2 -r1.16.2.3 src/sys/arch/x86/pci/amdzentemp.c

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



CVS commit: [netbsd-10] src/sys

2024-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  9 13:04:17 UTC 2024

Modified Files:
src/sys/dev [netbsd-10]: random.c
src/sys/kern [netbsd-10]: kern_entropy.c
src/sys/sys [netbsd-10]: entropy.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #937):

sys/dev/random.c: revision 1.11
sys/kern/kern_entropy.c: revision 1.67
sys/kern/kern_entropy.c: revision 1.68
sys/kern/kern_entropy.c: revision 1.69
sys/sys/entropy.h: revision 1.5

entropy(9): New function entropy_consolidate_sig.

This is the same as entropy_consolidate, but it returns EINTR if
interrupted by a signal and 0 otherwise.  (entropy_consolidate can
already be interrupted by a signal -- it just doesn't tell you if it
was.)

Eventually these will be merged into a single entropy_consolidate
that returns the error code, but adding a new symbol first makes it
safe for pullup-10.
PR kern/58646: /dev/random, kern.entropy.*: signal bugs

/dev/random: Fix two signal bugs.
1. If a long write to /dev/random is interrupted by a signal, it may
   proceed to sleep on the entropy source lock instead of returning
   promptly.
   => Don't try to consolidate entropy if we've already been
  interrupted by a signal.
2. If a write to /dev/random is interrupted by a signal while
   sleeping on the entropy source lock, it may fail to report EINTR.
   => Pass through EINTR from entropy consolidation via new
  entropy_consolidate_sig function.
PR kern/58646: /dev/random, kern.entropy.*: signal bugs

kern.entropy.consolidate, ioctl(RNDCTL): Fail with EINTR on signal.

This can happen if another thread is currently running consolidation
and has the entropy source lock held.  Use the new function
entropy_consolidate_sig to get at EINTR.
PR kern/58646: /dev/random, kern.entropy.*: signal bugs

kern.entropy.gather: Fail with EINTR on signal.

Just don't throw away the error code we already have!
PR kern/58646: /dev/random, kern.entropy.*: signal bugs


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/dev/random.c
cvs rdiff -u -r1.57.4.4 -r1.57.4.5 src/sys/kern/kern_entropy.c
cvs rdiff -u -r1.4 -r1.4.20.1 src/sys/sys/entropy.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/random.c
diff -u src/sys/dev/random.c:1.10 src/sys/dev/random.c:1.10.4.1
--- src/sys/dev/random.c:1.10	Tue Dec 28 13:22:43 2021
+++ src/sys/dev/random.c	Wed Oct  9 13:04:16 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: random.c,v 1.10 2021/12/28 13:22:43 riastradh Exp $	*/
+/*	$NetBSD: random.c,v 1.10.4.1 2024/10/09 13:04:16 martin Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.10 2021/12/28 13:22:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.10.4.1 2024/10/09 13:04:16 martin Exp $");
 
 #include 
 #include 
@@ -298,8 +298,8 @@ random_write(dev_t dev, struct uio *uio,
 	kmem_free(buf, RANDOM_BUFSIZE);
 
 	/* If we added anything, consolidate entropy now.  */
-	if (any)
-		entropy_consolidate();
+	if (any && error == 0)
+		error = entropy_consolidate_sig();
 
 	return error;
 }

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.57.4.4 src/sys/kern/kern_entropy.c:1.57.4.5
--- src/sys/kern/kern_entropy.c:1.57.4.4	Fri Aug 11 14:35:25 2023
+++ src/sys/kern/kern_entropy.c	Wed Oct  9 13:04:16 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.57.4.4 2023/08/11 14:35:25 martin Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.57.4.5 2024/10/09 13:04:16 martin Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.57.4.4 2023/08/11 14:35:25 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.57.4.5 2024/10/09 13:04:16 martin Exp $");
 
 #include 
 #include 
@@ -1354,7 +1354,21 @@ entropy_notify(void)
 /*
  * entropy_consolidate()
  *
- *	Trigger entropy consolidation and wait for it to complete.
+ *	Trigger entropy consolidation and wait for it to complete, or
+ *	return early if interrupted by a signal.
+ */
+void
+entropy_consolidate(void)
+{
+
+	(void)entropy_consolidate_sig();
+}
+
+/*
+ * entropy_consolidate_sig()
+ *
+ *	Trigger entropy consolidation and wait for it to complete, or
+ *	return EINTR if interrupted by a signal.
  *
  *	This should be used sparingly, not periodically -- requiring
  *	conscious intervention by the operator or a clear policy
@@ -1362,8 +1376,8 @@ entropy_notify(void)
  *	when enough entropy has been gathered into per-CPU pools to
  *	transition to full entropy.
  */
-void
-entropy_consolidate(void)
+int
+entropy_consolidate_sig(void)
 {
 	uint64_t ticket;
 	int error;
@@ -1381,6 +1395,8 @@ entropy_consolidate(void)
 			break;
 	}
 	mutex_exit(&E->lock);
+
+	return error;
 }
 
 /*
@@ -1404,7 +1420,7 @@ sysctl_entrop

CVS commit: [netbsd-10] src/sys

2024-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  9 13:04:17 UTC 2024

Modified Files:
src/sys/dev [netbsd-10]: random.c
src/sys/kern [netbsd-10]: kern_entropy.c
src/sys/sys [netbsd-10]: entropy.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #937):

sys/dev/random.c: revision 1.11
sys/kern/kern_entropy.c: revision 1.67
sys/kern/kern_entropy.c: revision 1.68
sys/kern/kern_entropy.c: revision 1.69
sys/sys/entropy.h: revision 1.5

entropy(9): New function entropy_consolidate_sig.

This is the same as entropy_consolidate, but it returns EINTR if
interrupted by a signal and 0 otherwise.  (entropy_consolidate can
already be interrupted by a signal -- it just doesn't tell you if it
was.)

Eventually these will be merged into a single entropy_consolidate
that returns the error code, but adding a new symbol first makes it
safe for pullup-10.
PR kern/58646: /dev/random, kern.entropy.*: signal bugs

/dev/random: Fix two signal bugs.
1. If a long write to /dev/random is interrupted by a signal, it may
   proceed to sleep on the entropy source lock instead of returning
   promptly.
   => Don't try to consolidate entropy if we've already been
  interrupted by a signal.
2. If a write to /dev/random is interrupted by a signal while
   sleeping on the entropy source lock, it may fail to report EINTR.
   => Pass through EINTR from entropy consolidation via new
  entropy_consolidate_sig function.
PR kern/58646: /dev/random, kern.entropy.*: signal bugs

kern.entropy.consolidate, ioctl(RNDCTL): Fail with EINTR on signal.

This can happen if another thread is currently running consolidation
and has the entropy source lock held.  Use the new function
entropy_consolidate_sig to get at EINTR.
PR kern/58646: /dev/random, kern.entropy.*: signal bugs

kern.entropy.gather: Fail with EINTR on signal.

Just don't throw away the error code we already have!
PR kern/58646: /dev/random, kern.entropy.*: signal bugs


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/dev/random.c
cvs rdiff -u -r1.57.4.4 -r1.57.4.5 src/sys/kern/kern_entropy.c
cvs rdiff -u -r1.4 -r1.4.20.1 src/sys/sys/entropy.h

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



CVS commit: [netbsd-10] src/sys

2024-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  9 10:49:04 UTC 2024

Modified Files:
src/sys/external/isc/libsodium/conf [netbsd-10]: files.libsodium
src/sys/external/isc/libsodium/include [netbsd-10]: core.h
crypto_verify_16.h stdint.h stdlib.h string.h
src/sys/external/isc/libsodium/src [netbsd-10]: sodium_module.c
src/sys/modules/sodium [netbsd-10]: Makefile.sodmod
src/sys/rump/kern/lib/libcrypto [netbsd-10]: Makefile
Added Files:
src/sys/crypto/sodium [netbsd-10]: sodium_selftest.h
src/sys/external/isc/libsodium/src [netbsd-10]: sodium_selftest.c
Removed Files:
src/sys/external/isc/libsodium/include [netbsd-10]: assert.h errno.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #933):

sys/external/isc/libsodium/src/sodium_module.c: revision 1.2
sys/external/isc/libsodium/include/core.h: revision 1.2
sys/external/isc/libsodium/include/stdlib.h: revision 1.2
sys/modules/sodium/Makefile.sodmod: revision 1.4
sys/external/isc/libsodium/include/crypto_verify_16.h: revision 1.2
sys/external/isc/libsodium/include/errno.h: file removal
sys/crypto/sodium/sodium_selftest.h: revision 1.1
sys/external/isc/libsodium/include/stdint.h: revision 1.2
sys/crypto/sodium/sodium_selftest.h: revision 1.2
sys/external/isc/libsodium/include/assert.h: file removal
sys/external/isc/libsodium/conf/files.libsodium: revision 1.7
sys/rump/kern/lib/libcrypto/Makefile: revision 1.24
sys/external/isc/libsodium/src/sodium_selftest.c: revision 1.1
sys/external/isc/libsodium/src/sodium_selftest.c: revision 1.2
sys/external/isc/libsodium/include/string.h: revision 1.2

sys/crypto/sodium: Add a self-test for IETF ChaCha20/Poly1305 AEAD.
PR kern/58468

sys/crypto/sodium: Fill out crypto_verify_16 stub.

Without this change, libsodium silently accepts forgeries.

This one's a doozy, and it's a sobering reminder that:
(a) wg(4) is still experimental (only user of libsodium in kernel;
both are available only through default-off optional modules).
(b) Known-answer test vectors are critical, including negative tests
(test that forgeries are rejected), and must be mandatory for all
new crypto code -- and should be added to old crypto code too.
(c) Crypto code must also have self-tests that run in the same
environment, not just the same code in a different build or test
environment -- the libsodium code itself is fine, but we built it
differently and need to exercise it differently from upstream's
automatic tests.

It's my fault for not catching this earlier.  What happened is:
1. ozaki-r@ adapted libsodium to build in the kernel with various
   glue to build code meant for standard userland C, like errno.h and
   string.h.
2. Since libsodium's crypto_verify_16.c uses various SIMD intrinsics
   on various architectures, it couldn't be used directly in the
   kernel build, because -- at the time -- we hadn't wired up any
   header files for SIMD intrinsics or any runtime support for saving
   and restoring SIMD state appropriately in the kernel.
3. ozaki-r@ put a similar glue header file crypto_verify_16.h to
   override libsodium's, with a stub to be implemented later, and
   presumably forgot to remind me about it.
4. I missed the stub in crypto_verify_16.h when reviewing the
   libsodium import and wg(4) code because it was in the same
   directory as various other simple glue code that I deemed
   low-risk.
   (I did make one change to that glue code, to replace cprng_fast by
   cprng_strong, but I suspect I found that by searching for
   cprng_fast users rather than by reviewing this code.)
5. I broke my own rule about always having known-answer test vectors
   for crypto code because I figured libsodium was well-enough
   exercised that we could skimp on it for now, and my focus was more
   on the state machine and synchronization logic than on the crypto.
6. I had not yet written known-answer test vectors for the
   higher-level wg(4) protocol messages.

Before we can remove the `experimental' tag from wg(4) we will need
to (among other things):
  i. Write self-tests for the rest of (what we use from) libsodium.
 ii. Write extensive known-answer test vectors for all the wg(4)
 protocol messages (and ideally state machine transitions).
iii. Write self-tests for a reasonable subset of the wg(4) KATs.
 iv. Review all of the libsodium glue code I neglected to review.
PR kern/58468

sys/crypto/sodium: Simplify string.h stub.

Not sure of any particular problem with the previous stub, but let's
make sure to use the same prototypes for memset/memcpy/memmove as
everything else in the kernel.
PR kern/58468

sys/crypto/sodium: Nix unused assert.h stub.

Maybe this was a vestige of an earlier draft of the libsodium import,
but it doesn't appear to be needed now by any libsodium fil

CVS commit: [netbsd-10] src/sys

2024-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  9 10:49:04 UTC 2024

Modified Files:
src/sys/external/isc/libsodium/conf [netbsd-10]: files.libsodium
src/sys/external/isc/libsodium/include [netbsd-10]: core.h
crypto_verify_16.h stdint.h stdlib.h string.h
src/sys/external/isc/libsodium/src [netbsd-10]: sodium_module.c
src/sys/modules/sodium [netbsd-10]: Makefile.sodmod
src/sys/rump/kern/lib/libcrypto [netbsd-10]: Makefile
Added Files:
src/sys/crypto/sodium [netbsd-10]: sodium_selftest.h
src/sys/external/isc/libsodium/src [netbsd-10]: sodium_selftest.c
Removed Files:
src/sys/external/isc/libsodium/include [netbsd-10]: assert.h errno.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #933):

sys/external/isc/libsodium/src/sodium_module.c: revision 1.2
sys/external/isc/libsodium/include/core.h: revision 1.2
sys/external/isc/libsodium/include/stdlib.h: revision 1.2
sys/modules/sodium/Makefile.sodmod: revision 1.4
sys/external/isc/libsodium/include/crypto_verify_16.h: revision 1.2
sys/external/isc/libsodium/include/errno.h: file removal
sys/crypto/sodium/sodium_selftest.h: revision 1.1
sys/external/isc/libsodium/include/stdint.h: revision 1.2
sys/crypto/sodium/sodium_selftest.h: revision 1.2
sys/external/isc/libsodium/include/assert.h: file removal
sys/external/isc/libsodium/conf/files.libsodium: revision 1.7
sys/rump/kern/lib/libcrypto/Makefile: revision 1.24
sys/external/isc/libsodium/src/sodium_selftest.c: revision 1.1
sys/external/isc/libsodium/src/sodium_selftest.c: revision 1.2
sys/external/isc/libsodium/include/string.h: revision 1.2

sys/crypto/sodium: Add a self-test for IETF ChaCha20/Poly1305 AEAD.
PR kern/58468

sys/crypto/sodium: Fill out crypto_verify_16 stub.

Without this change, libsodium silently accepts forgeries.

This one's a doozy, and it's a sobering reminder that:
(a) wg(4) is still experimental (only user of libsodium in kernel;
both are available only through default-off optional modules).
(b) Known-answer test vectors are critical, including negative tests
(test that forgeries are rejected), and must be mandatory for all
new crypto code -- and should be added to old crypto code too.
(c) Crypto code must also have self-tests that run in the same
environment, not just the same code in a different build or test
environment -- the libsodium code itself is fine, but we built it
differently and need to exercise it differently from upstream's
automatic tests.

It's my fault for not catching this earlier.  What happened is:
1. ozaki-r@ adapted libsodium to build in the kernel with various
   glue to build code meant for standard userland C, like errno.h and
   string.h.
2. Since libsodium's crypto_verify_16.c uses various SIMD intrinsics
   on various architectures, it couldn't be used directly in the
   kernel build, because -- at the time -- we hadn't wired up any
   header files for SIMD intrinsics or any runtime support for saving
   and restoring SIMD state appropriately in the kernel.
3. ozaki-r@ put a similar glue header file crypto_verify_16.h to
   override libsodium's, with a stub to be implemented later, and
   presumably forgot to remind me about it.
4. I missed the stub in crypto_verify_16.h when reviewing the
   libsodium import and wg(4) code because it was in the same
   directory as various other simple glue code that I deemed
   low-risk.
   (I did make one change to that glue code, to replace cprng_fast by
   cprng_strong, but I suspect I found that by searching for
   cprng_fast users rather than by reviewing this code.)
5. I broke my own rule about always having known-answer test vectors
   for crypto code because I figured libsodium was well-enough
   exercised that we could skimp on it for now, and my focus was more
   on the state machine and synchronization logic than on the crypto.
6. I had not yet written known-answer test vectors for the
   higher-level wg(4) protocol messages.

Before we can remove the `experimental' tag from wg(4) we will need
to (among other things):
  i. Write self-tests for the rest of (what we use from) libsodium.
 ii. Write extensive known-answer test vectors for all the wg(4)
 protocol messages (and ideally state machine transitions).
iii. Write self-tests for a reasonable subset of the wg(4) KATs.
 iv. Review all of the libsodium glue code I neglected to review.
PR kern/58468

sys/crypto/sodium: Simplify string.h stub.

Not sure of any particular problem with the previous stub, but let's
make sure to use the same prototypes for memset/memcpy/memmove as
everything else in the kernel.
PR kern/58468

sys/crypto/sodium: Nix unused assert.h stub.

Maybe this was a vestige of an earlier draft of the libsodium import,
but it doesn't appear to be needed now by any libsodium fil

CVS commit: [netbsd-10] src/sys/netinet

2024-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct  8 11:24:50 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: tcp_input.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #932):

sys/netinet/tcp_input.c: revision 1.441

tcp_reass: Mitigate CVE-2018-6922 (SegmentSmack)
at a level of FreeBSD, by introducing an arbitrary (100) limit to
the length of TCP reassembly queues:
https://github.com/freebsd/freebsd-src/commit/95a914f6316874f5b0c45d491f2843dc810071ef

Originally authored by ryo@.

We thank Tomoyuki Sahara , who has analyzed the
problem again, updated the patch, and carried out experiments for
vulnerability scenarios. The confidential PR below is based on
his work.

PR security/58708


To generate a diff of this commit:
cvs rdiff -u -r1.438 -r1.438.2.1 src/sys/netinet/tcp_input.c

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

Modified files:

Index: src/sys/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.438 src/sys/netinet/tcp_input.c:1.438.2.1
--- src/sys/netinet/tcp_input.c:1.438	Fri Nov  4 09:01:53 2022
+++ src/sys/netinet/tcp_input.c	Tue Oct  8 11:24:50 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.438 2022/11/04 09:01:53 ozaki-r Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.438.2.1 2024/10/08 11:24:50 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.438 2022/11/04 09:01:53 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.438.2.1 2024/10/08 11:24:50 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -231,6 +231,8 @@ int	tcp_autorcvbuf_inc = 16 * 1024;
 int	tcp_autorcvbuf_max = 256 * 1024;
 int	tcp_msl = (TCPTV_MSL / PR_SLOWHZ);
 
+int tcp_reass_maxqueuelen = 100;
+
 static int tcp_rst_ppslim_count = 0;
 static struct timeval tcp_rst_ppslim_last;
 static int tcp_ackdrop_ppslim_count = 0;
@@ -707,6 +709,13 @@ tcp_reass(struct tcpcb *tp, const struct
 #endif
 
 insert_it:
+	/* limit tcp segments per reassembly queue */
+	if (tp->t_segqlen > tcp_reass_maxqueuelen) {
+		TCP_STATINC(TCP_STAT_RCVMEMDROP);
+		m_freem(m);
+		goto out;
+	}
+
 	/*
 	 * Allocate a new queue entry (block) since the received segment
 	 * did not collapse onto any other out-of-order block. If it had



CVS commit: [netbsd-10] src/sys/netinet

2024-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct  8 11:24:50 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: tcp_input.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #932):

sys/netinet/tcp_input.c: revision 1.441

tcp_reass: Mitigate CVE-2018-6922 (SegmentSmack)
at a level of FreeBSD, by introducing an arbitrary (100) limit to
the length of TCP reassembly queues:
https://github.com/freebsd/freebsd-src/commit/95a914f6316874f5b0c45d491f2843dc810071ef

Originally authored by ryo@.

We thank Tomoyuki Sahara , who has analyzed the
problem again, updated the patch, and carried out experiments for
vulnerability scenarios. The confidential PR below is based on
his work.

PR security/58708


To generate a diff of this commit:
cvs rdiff -u -r1.438 -r1.438.2.1 src/sys/netinet/tcp_input.c

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



CVS commit: [netbsd-10] src/sys/arch/x86/x86

2024-10-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct  3 16:23:54 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: mpacpi.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #927):

sys/arch/x86/x86/mpacpi.c: revision 1.111

Remove check (x2apic->LocalApicId <= 0xff) in mpacpi_config_cpu(),
the ACPI spec mentions this for compatibility with "legacy OSes" but
doens't explicitely forbid it (AFAIK). This makes a recent Dell
poweredge R750 boot to the installer.

See
 https://mail-index.netbsd.org/port-amd64/2023/12/30/msg003666.html
and
 https://mail-index.netbsd.org/port-amd64/2024/09/28/msg003695.html

It should help for PR kern/57737


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

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

Modified files:

Index: src/sys/arch/x86/x86/mpacpi.c
diff -u src/sys/arch/x86/x86/mpacpi.c:1.109.4.1 src/sys/arch/x86/x86/mpacpi.c:1.109.4.2
--- src/sys/arch/x86/x86/mpacpi.c:1.109.4.1	Thu Mar 30 11:43:17 2023
+++ src/sys/arch/x86/x86/mpacpi.c	Thu Oct  3 16:23:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpacpi.c,v 1.109.4.1 2023/03/30 11:43:17 martin Exp $	*/
+/*	$NetBSD: mpacpi.c,v 1.109.4.2 2024/10/03 16:23:54 martin Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.109.4.1 2023/03/30 11:43:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.109.4.2 2024/10/03 16:23:54 martin Exp $");
 
 #include "acpica.h"
 #include "opt_acpi.h"
@@ -393,17 +393,6 @@ mpacpi_config_cpu(ACPI_SUBTABLE_HEADER *
 	case ACPI_MADT_TYPE_LOCAL_X2APIC:
 		x2apic = (ACPI_MADT_LOCAL_X2APIC *)hdrp;
 
-		/* ACPI spec: "Logical processors with APIC ID values
-		 * less than 255 must use the Processor Local APIC
-		 * structure to convey their APIC information to OSPM."
-		 * But Xen with PVH dom0 breaks this ACPI spec.
-		 */
-		if (x2apic->LocalApicId <= 0xff && vm_guest != VM_GUEST_XENPVH) {
-			printf("bogus MADT X2APIC entry (id = 0x%"PRIx32")\n",
-			x2apic->LocalApicId);
-			break;
-		}
-
 		if (x2apic->LapicFlags & ACPI_MADT_ENABLED) {
 			if (x2apic->LocalApicId != cpunum)
 caa.cpu_role = CPU_ROLE_AP;



CVS commit: [netbsd-10] src/sys/arch/x86/x86

2024-10-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct  3 16:23:54 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: mpacpi.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #927):

sys/arch/x86/x86/mpacpi.c: revision 1.111

Remove check (x2apic->LocalApicId <= 0xff) in mpacpi_config_cpu(),
the ACPI spec mentions this for compatibility with "legacy OSes" but
doens't explicitely forbid it (AFAIK). This makes a recent Dell
poweredge R750 boot to the installer.

See
 https://mail-index.netbsd.org/port-amd64/2023/12/30/msg003666.html
and
 https://mail-index.netbsd.org/port-amd64/2024/09/28/msg003695.html

It should help for PR kern/57737


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

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



CVS commit: [netbsd-10] src/sys/rump/net/lib/libshmif

2024-10-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct  3 16:19:59 UTC 2024

Modified Files:
src/sys/rump/net/lib/libshmif [netbsd-10]: if_shmem.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #924):

sys/rump/net/lib/libshmif/if_shmem.c: revision 1.89

shmif: Fix logics for media change and status

- shmif_mediachange: Drop check for if_link_state. Otherwise,
   there can be race b/w events in if_link_queue.
- shmif_mediastatus: Set ifm_status appropriately, by which
   link state appears in ifconfig(8) "status:" line.

Pointed out by roy@, and taken from his codes in vether(4). Thanks!!


To generate a diff of this commit:
cvs rdiff -u -r1.84.4.2 -r1.84.4.3 src/sys/rump/net/lib/libshmif/if_shmem.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/rump/net/lib/libshmif/if_shmem.c
diff -u src/sys/rump/net/lib/libshmif/if_shmem.c:1.84.4.2 src/sys/rump/net/lib/libshmif/if_shmem.c:1.84.4.3
--- src/sys/rump/net/lib/libshmif/if_shmem.c:1.84.4.2	Thu Sep  5 09:22:44 2024
+++ src/sys/rump/net/lib/libshmif/if_shmem.c	Thu Oct  3 16:19:59 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_shmem.c,v 1.84.4.2 2024/09/05 09:22:44 martin Exp $	*/
+/*	$NetBSD: if_shmem.c,v 1.84.4.3 2024/10/03 16:19:59 martin Exp $	*/
 
 /*
  * Copyright (c) 2009, 2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.84.4.2 2024/09/05 09:22:44 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.84.4.3 2024/10/03 16:19:59 martin Exp $");
 
 #include 
 #include 
@@ -455,14 +455,14 @@ static int
 shmif_mediachange(struct ifnet *ifp)
 {
 	struct shmif_sc *sc = ifp->if_softc;
+	int link_state;
 
-	if (IFM_SUBTYPE(sc->sc_im.ifm_cur->ifm_media) == IFM_NONE &&
-	ifp->if_link_state != LINK_STATE_DOWN) {
-		if_link_state_change(ifp, LINK_STATE_DOWN);
-	} else if (IFM_SUBTYPE(sc->sc_im.ifm_cur->ifm_media) == IFM_AUTO &&
-	ifp->if_link_state != LINK_STATE_UP) {
-		if_link_state_change(ifp, LINK_STATE_UP);
-	}
+	if (IFM_SUBTYPE(sc->sc_im.ifm_cur->ifm_media) == IFM_NONE)
+		link_state = LINK_STATE_DOWN;
+	else
+		link_state = LINK_STATE_UP;
+
+	if_link_state_change(ifp, link_state);
 	return 0;
 }
 
@@ -470,7 +470,12 @@ static void
 shmif_mediastatus(struct ifnet *ifp, struct ifmediareq *imr)
 {
 	struct shmif_sc *sc = ifp->if_softc;
+
 	imr->ifm_active = sc->sc_im.ifm_cur->ifm_media;
+
+	imr->ifm_status = IFM_AVALID;
+	if (IFM_SUBTYPE(imr->ifm_active) != IFM_NONE)
+		imr->ifm_status |= IFM_ACTIVE;
 }
 
 static int



CVS commit: [netbsd-10] src/sys/rump/net/lib/libshmif

2024-10-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct  3 16:19:59 UTC 2024

Modified Files:
src/sys/rump/net/lib/libshmif [netbsd-10]: if_shmem.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #924):

sys/rump/net/lib/libshmif/if_shmem.c: revision 1.89

shmif: Fix logics for media change and status

- shmif_mediachange: Drop check for if_link_state. Otherwise,
   there can be race b/w events in if_link_queue.
- shmif_mediastatus: Set ifm_status appropriately, by which
   link state appears in ifconfig(8) "status:" line.

Pointed out by roy@, and taken from his codes in vether(4). Thanks!!


To generate a diff of this commit:
cvs rdiff -u -r1.84.4.2 -r1.84.4.3 src/sys/rump/net/lib/libshmif/if_shmem.c

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



CVS commit: [netbsd-10] src/sys/altq

2024-10-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct  3 11:56:23 UTC 2024

Modified Files:
src/sys/altq [netbsd-10]: altq_cbq.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #917):

sys/altq/altq_cbq.c: revision 1.40
sys/altq/altq_cbq.c: revision 1.41

altq, cbq: fix NSEC_TO_PSEC
Pointed out by manu@, thanks.

altq, cbq: fix default class assignment
Fix typo in v1.34.
Tested by me and manu@.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.39.4.1 src/sys/altq/altq_cbq.c

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



CVS commit: [netbsd-10] src/sys/altq

2024-10-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct  3 11:56:23 UTC 2024

Modified Files:
src/sys/altq [netbsd-10]: altq_cbq.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #917):

sys/altq/altq_cbq.c: revision 1.40
sys/altq/altq_cbq.c: revision 1.41

altq, cbq: fix NSEC_TO_PSEC
Pointed out by manu@, thanks.

altq, cbq: fix default class assignment
Fix typo in v1.34.
Tested by me and manu@.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.39.4.1 src/sys/altq/altq_cbq.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/altq/altq_cbq.c
diff -u src/sys/altq/altq_cbq.c:1.39 src/sys/altq/altq_cbq.c:1.39.4.1
--- src/sys/altq/altq_cbq.c:1.39	Fri Dec 31 20:22:48 2021
+++ src/sys/altq/altq_cbq.c	Thu Oct  3 11:56:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_cbq.c,v 1.39 2021/12/31 20:22:48 andvar Exp $	*/
+/*	$NetBSD: altq_cbq.c,v 1.39.4.1 2024/10/03 11:56:22 martin Exp $	*/
 /*	$KAME: altq_cbq.c,v 1.21 2005/04/13 03:44:24 suz Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.39 2021/12/31 20:22:48 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.39.4.1 2024/10/03 11:56:22 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq.h"
@@ -306,7 +306,7 @@ cbq_remove_altq(struct pf_altq *a)
 	return (0);
 }
 
-#define NSEC_TO_PSEC(s)	((uint64_t)(s) * 1000 * 1000)
+#define NSEC_TO_PSEC(s)	((uint64_t)(s) * 1000)
 int
 cbq_add_queue(struct pf_altq *a)
 {
@@ -750,7 +750,7 @@ cbq_class_create(cbq_state_t *cbqp, stru
 	/* save the allocated class */
 	cbqp->cbq_class_tbl[i] = cl;
 
-	if ((spec->flags & CBQCLF_CLASSMASK) != 0)
+	if ((spec->flags & CBQCLF_DEFCLASS) != 0)
 		cbqp->ifnp.default_ = cl;
 	if ((spec->flags & CBQCLF_CTLCLASS) != 0)
 		cbqp->ifnp.ctl_ = cl;



CVS commit: [netbsd-10] src/sys/arch/x86/x86

2024-10-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  2 18:24:35 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: tsc.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #915):

sys/arch/x86/x86/tsc.c: revision 1.59
sys/arch/x86/x86/tsc.c: revision 1.60

make TSC get a quality of -100 on AMD Family 15h and 16h
this should "fix" PR#56322 and is known as AMD errata
"778: Processor Core Time Stamp Counters May Experience Drift"

remove unintended printf() in previous.  (thx dh)


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.57.4.1 src/sys/arch/x86/x86/tsc.c

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

Modified files:

Index: src/sys/arch/x86/x86/tsc.c
diff -u src/sys/arch/x86/x86/tsc.c:1.57 src/sys/arch/x86/x86/tsc.c:1.57.4.1
--- src/sys/arch/x86/x86/tsc.c:1.57	Fri Oct 15 18:12:48 2021
+++ src/sys/arch/x86/x86/tsc.c	Wed Oct  2 18:24:35 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tsc.c,v 1.57 2021/10/15 18:12:48 jmcneill Exp $	*/
+/*	$NetBSD: tsc.c,v 1.57.4.1 2024/10/02 18:24:35 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.57 2021/10/15 18:12:48 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.57.4.1 2024/10/02 18:24:35 martin Exp $");
 
 #include 
 #include 
@@ -132,6 +132,18 @@ tsc_is_invariant(void)
 		 * Manual Volume 3: General-Purpose and System Instructions.
 		 * The check is done below.
 		 */
+
+		 /*
+		  * AMD Errata 778: Processor Core Time Stamp Counters May
+		  * Experience Drift
+		  *
+		  * This affects all family 15h and family 16h processors.
+		  */
+		switch (CPUID_TO_FAMILY(ci->ci_signature)) {
+		case 0x15:
+		case 0x16:
+			return false;
+		}
 	}
 
 	/*



CVS commit: [netbsd-10] src/sys/arch/x86/x86

2024-10-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  2 18:24:35 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: tsc.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #915):

sys/arch/x86/x86/tsc.c: revision 1.59
sys/arch/x86/x86/tsc.c: revision 1.60

make TSC get a quality of -100 on AMD Family 15h and 16h
this should "fix" PR#56322 and is known as AMD errata
"778: Processor Core Time Stamp Counters May Experience Drift"

remove unintended printf() in previous.  (thx dh)


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.57.4.1 src/sys/arch/x86/x86/tsc.c

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



CVS commit: [netbsd-10] src/sys/dev

2024-10-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  2 18:20:48 UTC 2024

Modified Files:
src/sys/dev/pci [netbsd-10]: ld_virtio.c vioscsi.c virtio.c
virtio_pci.c
src/sys/dev/virtio [netbsd-10]: viocon.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #914):

sys/dev/pci/virtio_pci.c: revision 1.50
sys/dev/pci/virtio_pci.c: revision 1.51
sys/dev/pci/virtio_pci.c: revision 1.52
sys/dev/pci/virtio_pci.c: revision 1.53
sys/dev/pci/virtio_pci.c: revision 1.54
sys/dev/pci/vioscsi.c: revision 1.35
sys/dev/pci/ld_virtio.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.34
sys/dev/virtio/viocon.c: revision 1.9
sys/dev/pci/ld_virtio.c: revision 1.35
sys/dev/pci/virtio.c: revision 1.80
sys/dev/pci/virtio.c: revision 1.81
sys/dev/pci/virtio.c: revision 1.82
sys/dev/pci/virtio_pci.c: revision 1.45
sys/dev/pci/virtio_pci.c: revision 1.46
sys/dev/pci/virtio_pci.c: revision 1.47
sys/dev/pci/virtio_pci.c: revision 1.48
sys/dev/pci/virtio_pci.c: revision 1.49
sys/dev/pci/virtio.c: revision 1.79

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

viocon(4): Show error in assertion failure.

virtio_read_device_config_le_[24]: Fix for {aarch64,arm}eb
Stop byte-swapping for big-endian aarch64 and arm to fix
corrupted read for, e.g., sc_taglen for vio9p(4).

As described as comments in virtio_pci.c, big-endian aarch64 and
armv7 (armeb) are somewhat special. At the moment, all supported
virtual/real machines are configured as little-endian, and only
CPU cores are switched to big-endian mode during early boot stage.

Most peripheral buses for armeb are LSB as a result, and their
default bus_space(9) functions swap byte-order. Therefore, PIOed
data from memory-mapped devices, as well as pci(4) ones, are
actually LSB, but observed as MSB for armeb.

Therefore, we should not swap byte-order further in
virtio_read_device_config_le_[24] on armeb.

See virtio_pci.c and sys/dev/fdt/virtio_mmio_fdt.c also.
fix spelling mistakes, mainly in comments and log messages.

Split KASSERT(A && B) into KASSERT(A); KASSERT(B).

Fix typo in error message.

Modify a confused expression in ld_virtio_attach().

VIRTIO_BLK_MIN_SEGMENTS should be the total number of non-data segments,
so I rename it to VIRTIO_BLK_CTRL_SEGMENTS.
PR kern/57981.

ld@virtio(4): Fix maximum size parameters.
- SEG_MAX is the maximum number of segments.
- SIZE_MAX is the maximum number of bytes in a single segment.
The maximum transfer size is, therefore, SEG_MAX * SIZE_MAX.
=> Don't add two extra segments in the dmamap vr_payload for the
   header and status -- we already have a separate dmamap vr_cmdsts
   for that.
=> Don't recalculate payload dmamap parameters based on division by
   NBPG, just use the ones specified by the host.
=> Allow SIZE_MAX below MAXPHYS as long as SIZE_MAX*SEG_MAX >=
   MAXPHYS.
Even though ldattach clamps ld->sc_maxxfer to MAXPHYS, make sure to
clamp it in ld_virtio_attach before ld_virtio_alloc_reqs since it
determines the dmamap sizes and bounce buffer allocation and there's
no sense in allocating those larger than ld will use anyway.
PR kern/58338

virtio_pci.c: Nix trailing whitespace.

virtio@pci: Unmap the BARs we actually mapped on >=1.0 detach.
PR kern/58335

virtio@pci: Nix useless sc_mapped_iosize.
This appears to have been a mistaken attempt to pass the subregion
length through to bus_space_unmap, which doesn't make any sense --
bus_space_subregion does not allocate anything and the resulting
handle must not be passed to bus_space_unmap.

Once we pass the size that was actually returned by pci_mapreg_map to
bus_space_unmap, which matches the size passed internally by
pci_mapreg_map to bus_space_map, sc_mapped_iosize is no longer used
and can be flushed.
Prompted by PR kern/58335.

virtio@pci: Don't detach on shutdown.
The virtio bus does not keep state in memory that needs to flushed to
persistent storage.  Typically DVF_DETACH_SHUTDOWN is only needed by,
e.g., disk drivers to flush disk caches (although really, vfs sync
should do that anyway, so maybe we should just nix the option
altogether).
Prompted by PR kern/58335.

virtio@pci: Zero sc_bars_iosize[i] on unmap.
No functional change intended, but this makes the code less brittle.
Prompted by PR kern/58335.

virtio_pci.c: Sort includes.
No functional change intended.

virtio_pci.c: Omit needless blank lines and commented code.
No functional change intended.

virtio_pci.c: Sprinkle KNF.
- No parameter names in function prototypes.
- Fix indentation.
- Break overlong lines.
- Blank line between declarations and rest of block.
virtio_pci.c: Sprinkle const.
No functional change intended.

virtio_pci.c: Use container_of, not cast.
virtio(4): Assert child

CVS commit: [netbsd-10] src/sys/dev

2024-10-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  2 18:20:48 UTC 2024

Modified Files:
src/sys/dev/pci [netbsd-10]: ld_virtio.c vioscsi.c virtio.c
virtio_pci.c
src/sys/dev/virtio [netbsd-10]: viocon.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #914):

sys/dev/pci/virtio_pci.c: revision 1.50
sys/dev/pci/virtio_pci.c: revision 1.51
sys/dev/pci/virtio_pci.c: revision 1.52
sys/dev/pci/virtio_pci.c: revision 1.53
sys/dev/pci/virtio_pci.c: revision 1.54
sys/dev/pci/vioscsi.c: revision 1.35
sys/dev/pci/ld_virtio.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.34
sys/dev/virtio/viocon.c: revision 1.9
sys/dev/pci/ld_virtio.c: revision 1.35
sys/dev/pci/virtio.c: revision 1.80
sys/dev/pci/virtio.c: revision 1.81
sys/dev/pci/virtio.c: revision 1.82
sys/dev/pci/virtio_pci.c: revision 1.45
sys/dev/pci/virtio_pci.c: revision 1.46
sys/dev/pci/virtio_pci.c: revision 1.47
sys/dev/pci/virtio_pci.c: revision 1.48
sys/dev/pci/virtio_pci.c: revision 1.49
sys/dev/pci/virtio.c: revision 1.79

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

viocon(4): Show error in assertion failure.

virtio_read_device_config_le_[24]: Fix for {aarch64,arm}eb
Stop byte-swapping for big-endian aarch64 and arm to fix
corrupted read for, e.g., sc_taglen for vio9p(4).

As described as comments in virtio_pci.c, big-endian aarch64 and
armv7 (armeb) are somewhat special. At the moment, all supported
virtual/real machines are configured as little-endian, and only
CPU cores are switched to big-endian mode during early boot stage.

Most peripheral buses for armeb are LSB as a result, and their
default bus_space(9) functions swap byte-order. Therefore, PIOed
data from memory-mapped devices, as well as pci(4) ones, are
actually LSB, but observed as MSB for armeb.

Therefore, we should not swap byte-order further in
virtio_read_device_config_le_[24] on armeb.

See virtio_pci.c and sys/dev/fdt/virtio_mmio_fdt.c also.
fix spelling mistakes, mainly in comments and log messages.

Split KASSERT(A && B) into KASSERT(A); KASSERT(B).

Fix typo in error message.

Modify a confused expression in ld_virtio_attach().

VIRTIO_BLK_MIN_SEGMENTS should be the total number of non-data segments,
so I rename it to VIRTIO_BLK_CTRL_SEGMENTS.
PR kern/57981.

ld@virtio(4): Fix maximum size parameters.
- SEG_MAX is the maximum number of segments.
- SIZE_MAX is the maximum number of bytes in a single segment.
The maximum transfer size is, therefore, SEG_MAX * SIZE_MAX.
=> Don't add two extra segments in the dmamap vr_payload for the
   header and status -- we already have a separate dmamap vr_cmdsts
   for that.
=> Don't recalculate payload dmamap parameters based on division by
   NBPG, just use the ones specified by the host.
=> Allow SIZE_MAX below MAXPHYS as long as SIZE_MAX*SEG_MAX >=
   MAXPHYS.
Even though ldattach clamps ld->sc_maxxfer to MAXPHYS, make sure to
clamp it in ld_virtio_attach before ld_virtio_alloc_reqs since it
determines the dmamap sizes and bounce buffer allocation and there's
no sense in allocating those larger than ld will use anyway.
PR kern/58338

virtio_pci.c: Nix trailing whitespace.

virtio@pci: Unmap the BARs we actually mapped on >=1.0 detach.
PR kern/58335

virtio@pci: Nix useless sc_mapped_iosize.
This appears to have been a mistaken attempt to pass the subregion
length through to bus_space_unmap, which doesn't make any sense --
bus_space_subregion does not allocate anything and the resulting
handle must not be passed to bus_space_unmap.

Once we pass the size that was actually returned by pci_mapreg_map to
bus_space_unmap, which matches the size passed internally by
pci_mapreg_map to bus_space_map, sc_mapped_iosize is no longer used
and can be flushed.
Prompted by PR kern/58335.

virtio@pci: Don't detach on shutdown.
The virtio bus does not keep state in memory that needs to flushed to
persistent storage.  Typically DVF_DETACH_SHUTDOWN is only needed by,
e.g., disk drivers to flush disk caches (although really, vfs sync
should do that anyway, so maybe we should just nix the option
altogether).
Prompted by PR kern/58335.

virtio@pci: Zero sc_bars_iosize[i] on unmap.
No functional change intended, but this makes the code less brittle.
Prompted by PR kern/58335.

virtio_pci.c: Sort includes.
No functional change intended.

virtio_pci.c: Omit needless blank lines and commented code.
No functional change intended.

virtio_pci.c: Sprinkle KNF.
- No parameter names in function prototypes.
- Fix indentation.
- Break overlong lines.
- Blank line between declarations and rest of block.
virtio_pci.c: Sprinkle const.
No functional change intended.

virtio_pci.c: Use container_of, not cast.
virtio(4): Assert child

CVS commit: [netbsd-10] src/sys

2024-10-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  2 12:28:16 UTC 2024

Modified Files:
src/sys/arch/evbppc/conf [netbsd-10]: WII
src/sys/arch/evbppc/include [netbsd-10]: wii.h
src/sys/arch/evbppc/wii/dev [netbsd-10]: ehci_hollywood.c hollywood.c
hollywood.h ohci_hollywood.c sdhc_hollywood.c
src/sys/dev/usb [netbsd-10]: ohci.c ohcireg.h ohcivar.h

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #910):

sys/arch/evbppc/wii/dev/hollywood.h: revision 1.3
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.3
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.3
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.3
sys/dev/usb/ohcireg.h: revision 1.29
sys/arch/evbppc/include/wii.h: revision 1.8
sys/arch/evbppc/conf/WII: revision 1.6
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.3
sys/dev/usb/ohcivar.h: revision 1.63
sys/dev/usb/ohci.c: revision 1.329

wii: Restrict IOP access to shared peripherals.

Ensure that the IOP cannot access peripherals by clearing the appropriate
bus access bit. I have observed OHCI reporting completion for TDs living
in ARM reserved memory at runtime, this seems to suppress that.

ohci: Allocate a whole cacheline for all descriptors

Allocate a whole cacheline for all descriptor types such that:
 i) they can be alloc'ed without USBMALLOC_COHERENT which can mean they're
now mapped cacheable, and
ii) the "soft" versions are cacheable, and mapped as small as possible.

Patch/idea mainly from Nick (skrll@) with a few fixes from me.

wii: Enable ohci(4) driver.
This seems to be stable now, let's enable support for plugging in LS/FS
devices directly into the system without a hub.


To generate a diff of this commit:
cvs rdiff -u -r1.4.2.3 -r1.4.2.4 src/sys/arch/evbppc/conf/WII
cvs rdiff -u -r1.7.2.2 -r1.7.2.3 src/sys/arch/evbppc/include/wii.h
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/arch/evbppc/wii/dev/ehci_hollywood.c \
src/sys/arch/evbppc/wii/dev/hollywood.c \
src/sys/arch/evbppc/wii/dev/hollywood.h \
src/sys/arch/evbppc/wii/dev/ohci_hollywood.c \
src/sys/arch/evbppc/wii/dev/sdhc_hollywood.c
cvs rdiff -u -r1.323.4.2 -r1.323.4.3 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.28 -r1.28.20.1 src/sys/dev/usb/ohcireg.h
cvs rdiff -u -r1.62 -r1.62.18.1 src/sys/dev/usb/ohcivar.h

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



CVS commit: [netbsd-10] src/sys

2024-10-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  2 12:28:16 UTC 2024

Modified Files:
src/sys/arch/evbppc/conf [netbsd-10]: WII
src/sys/arch/evbppc/include [netbsd-10]: wii.h
src/sys/arch/evbppc/wii/dev [netbsd-10]: ehci_hollywood.c hollywood.c
hollywood.h ohci_hollywood.c sdhc_hollywood.c
src/sys/dev/usb [netbsd-10]: ohci.c ohcireg.h ohcivar.h

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #910):

sys/arch/evbppc/wii/dev/hollywood.h: revision 1.3
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.3
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.3
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.3
sys/dev/usb/ohcireg.h: revision 1.29
sys/arch/evbppc/include/wii.h: revision 1.8
sys/arch/evbppc/conf/WII: revision 1.6
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.3
sys/dev/usb/ohcivar.h: revision 1.63
sys/dev/usb/ohci.c: revision 1.329

wii: Restrict IOP access to shared peripherals.

Ensure that the IOP cannot access peripherals by clearing the appropriate
bus access bit. I have observed OHCI reporting completion for TDs living
in ARM reserved memory at runtime, this seems to suppress that.

ohci: Allocate a whole cacheline for all descriptors

Allocate a whole cacheline for all descriptor types such that:
 i) they can be alloc'ed without USBMALLOC_COHERENT which can mean they're
now mapped cacheable, and
ii) the "soft" versions are cacheable, and mapped as small as possible.

Patch/idea mainly from Nick (skrll@) with a few fixes from me.

wii: Enable ohci(4) driver.
This seems to be stable now, let's enable support for plugging in LS/FS
devices directly into the system without a hub.


To generate a diff of this commit:
cvs rdiff -u -r1.4.2.3 -r1.4.2.4 src/sys/arch/evbppc/conf/WII
cvs rdiff -u -r1.7.2.2 -r1.7.2.3 src/sys/arch/evbppc/include/wii.h
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/arch/evbppc/wii/dev/ehci_hollywood.c \
src/sys/arch/evbppc/wii/dev/hollywood.c \
src/sys/arch/evbppc/wii/dev/hollywood.h \
src/sys/arch/evbppc/wii/dev/ohci_hollywood.c \
src/sys/arch/evbppc/wii/dev/sdhc_hollywood.c
cvs rdiff -u -r1.323.4.2 -r1.323.4.3 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.28 -r1.28.20.1 src/sys/dev/usb/ohcireg.h
cvs rdiff -u -r1.62 -r1.62.18.1 src/sys/dev/usb/ohcivar.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/evbppc/conf/WII
diff -u src/sys/arch/evbppc/conf/WII:1.4.2.3 src/sys/arch/evbppc/conf/WII:1.4.2.4
--- src/sys/arch/evbppc/conf/WII:1.4.2.3	Fri Sep 20 11:33:51 2024
+++ src/sys/arch/evbppc/conf/WII	Wed Oct  2 12:28:15 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: WII,v 1.4.2.3 2024/09/20 11:33:51 martin Exp $
+#	$NetBSD: WII,v 1.4.2.4 2024/10/02 12:28:15 martin Exp $
 #
 #	Nintendo Wii
 #
@@ -147,8 +147,8 @@ avenc0		at iic0 addr 0x70			# A/V Encode
 resetbtn0	at hollywood0 irq 17			# Reset button
 
 ehci0		at hollywood0 addr 0x0d04 irq 4	# EHCI
-#ohci0		at hollywood0 addr 0x0d05 irq 5	# OHCI0
-#ohci1		at hollywood0 addr 0x0d06 irq 6	# OHCI1
+ohci0		at hollywood0 addr 0x0d05 irq 5	# OHCI0
+ohci1		at hollywood0 addr 0x0d06 irq 6	# OHCI1
 usb*		at usbus?
 
 sdhc0		at hollywood0 addr 0x0d07 irq 7	# SD card

Index: src/sys/arch/evbppc/include/wii.h
diff -u src/sys/arch/evbppc/include/wii.h:1.7.2.2 src/sys/arch/evbppc/include/wii.h:1.7.2.3
--- src/sys/arch/evbppc/include/wii.h:1.7.2.2	Sat Feb  3 11:47:08 2024
+++ src/sys/arch/evbppc/include/wii.h	Wed Oct  2 12:28:15 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: wii.h,v 1.7.2.2 2024/02/03 11:47:08 martin Exp $ */
+/* $NetBSD: wii.h,v 1.7.2.3 2024/10/02 12:28:15 martin Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -114,6 +114,11 @@
 #define HW_ARMIRQFLAGS			(HOLLYWOOD_PRIV_BASE + 0x038)
 #define HW_ARMIRQMASK			(HOLLYWOOD_PRIV_BASE + 0x03c)
 #define HW_AHBPROT			(HOLLYWOOD_PRIV_BASE + 0x064)
+#define  IOPSD1EN			__BIT(24)
+#define  IOPSD0EN			__BIT(23)
+#define  IOPOH1EN			__BIT(22)
+#define  IOPOH0EN			__BIT(21)
+#define  IOPEHCEN			__BIT(20)
 #define HW_GPIOB_OUT			(HOLLYWOOD_BASE + 0x0c0)
 #define HW_GPIOB_DIR			(HOLLYWOOD_BASE + 0x0c4)
 #define HW_GPIOB_IN			(HOLLYWOOD_BASE + 0x0c8)

Index: src/sys/arch/evbppc/wii/dev/ehci_hollywood.c
diff -u src/sys/arch/evbppc/wii/dev/ehci_hollywood.c:1.2.2.2 src/sys/arch/evbppc/wii/dev/ehci_hollywood.c:1.2.2.3
--- src/sys/arch/evbppc/wii/dev/ehci_hollywood.c:1.2.2.2	Sat Feb  3 11:47:04 2024
+++ src/sys/arch/evbppc/wii/dev/ehci_hollywood.c	Wed Oct  2 12:28:15 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci_hollywood.c,v 1.2.2.2 2024/02/03 11:47:04 martin Exp $ */
+/* $NetBSD: ehci_hollywood.c,v 1.2.2.3 2024/10/02 12:28:15 martin Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci_hollywood.c,v 1.2.2.2 2024/02/03 11:47:04 martin Exp $");
+_

CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  2 12:19:37 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: ohci.c

Log Message:
Fix previous, pullup of revision 1.328 totally gone wrong, try again:

Pull up following revision(s) (requested by skrll in ticket #926):

sys/dev/usb/ohci.c: revision 1.328

Fix some usb_syncmem calls and add some missing ones.


To generate a diff of this commit:
cvs rdiff -u -r1.323.4.1 -r1.323.4.2 src/sys/dev/usb/ohci.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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.323.4.1 src/sys/dev/usb/ohci.c:1.323.4.2
--- src/sys/dev/usb/ohci.c:1.323.4.1	Wed Oct  2 11:02:43 2024
+++ src/sys/dev/usb/ohci.c	Wed Oct  2 12:19:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.323.4.1 2024/10/02 11:02:43 martin Exp $	*/
+/*	$NetBSD: ohci.c,v 1.323.4.2 2024/10/02 12:19:37 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.323.4.1 2024/10/02 11:02:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.323.4.2 2024/10/02 12:19:37 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -409,29 +409,19 @@ ohci_alloc_sed(ohci_softc_t *sc)
 		DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
 		mutex_exit(&sc->sc_lock);
 
-		int err = usb_allocmem(sc->sc_bus.ub_dmatag,
-		OHCI_ED_SIZE * OHCI_ED_CHUNK,
-		OHCI_ED_ALIGN, 0, &dma);
+		int err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_SED_SIZE * OHCI_SED_CHUNK,
+		OHCI_ED_ALIGN, 0 /*!USBMALLOC_COHERENT*/, &dma);
 		if (err)
 			return NULL;
 
-		ohci_soft_ed_t *seds =
-		kmem_alloc(sizeof(*sed) * OHCI_ED_CHUNK, KM_SLEEP);
-		/*
-		 * We can avoid USBMALLOC_COHERENT as the EDs are each on a
-		 * cacheline.
-		 */
 		mutex_enter(&sc->sc_lock);
-		for (i = 0; i < OHCI_ED_CHUNK; i++) {
-			offs = i * OHCI_ED_SIZE;
-
-			sed = &seds[i];
-			sed->ed = KERNADDR(&dma, offs);
+		for (i = 0; i < OHCI_SED_CHUNK; i++) {
+			offs = i * OHCI_SED_SIZE;
+			sed = KERNADDR(&dma, offs);
 			sed->physaddr = DMAADDR(&dma, offs);
 			sed->dma = dma;
 			sed->offs = offs;
 			sed->next = sc->sc_freeeds;
-
 			sc->sc_freeeds = sed;
 		}
 	}
@@ -439,7 +429,7 @@ ohci_alloc_sed(ohci_softc_t *sc)
 	sc->sc_freeeds = sed->next;
 	mutex_exit(&sc->sc_lock);
 
-	memset(sed->ed, 0, sizeof(*sed->ed));
+	memset(&sed->ed, 0, sizeof(ohci_ed_t));
 	sed->next = 0;
 	return sed;
 }
@@ -477,29 +467,19 @@ ohci_alloc_std(ohci_softc_t *sc)
 		DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
 		mutex_exit(&sc->sc_lock);
 
-		ohci_soft_td_t *stds =
-		kmem_alloc(sizeof(*std) * OHCI_TD_CHUNK, KM_SLEEP);
-		/*
-		 * We can avoid USBMALLOC_COHERENT as the TDs are each on a
-		 * cacheline.
-		 */
-		int err = usb_allocmem(sc->sc_bus.ub_dmatag,
-		OHCI_TD_SIZE * OHCI_TD_CHUNK,
-		OHCI_TD_ALIGN, 0, &dma);
+		int err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_STD_SIZE * OHCI_STD_CHUNK,
+		   OHCI_TD_ALIGN, USBMALLOC_COHERENT, &dma);
 		if (err)
 			return NULL;
 
 		mutex_enter(&sc->sc_lock);
-		for (i = 0; i < OHCI_TD_CHUNK; i++) {
-			offs = i * OHCI_TD_SIZE;
-
-			std = &stds[i];
-			std->td = KERNADDR(&dma, offs);
+		for (i = 0; i < OHCI_STD_CHUNK; i++) {
+			offs = i * OHCI_STD_SIZE;
+			std = KERNADDR(&dma, offs);
 			std->physaddr = DMAADDR(&dma, offs);
 			std->dma = dma;
 			std->offs = offs;
 			std->nexttd = sc->sc_freetds;
-
 			sc->sc_freetds = std;
 		}
 	}
@@ -508,7 +488,7 @@ ohci_alloc_std(ohci_softc_t *sc)
 	sc->sc_freetds = std->nexttd;
 	mutex_exit(&sc->sc_lock);
 
-	memset(std->td, 0, sizeof(*std->td));
+	memset(&std->td, 0, sizeof(ohci_td_t));
 	std->nexttd = NULL;
 	std->xfer = NULL;
 	std->held = NULL;
@@ -671,10 +651,10 @@ ohci_reset_std_chain(ohci_softc_t *sc, s
 		DPRINTFN(4, "sdataphys=0x%08jx edataphys=0x%08jx "
 		"len=%jd curlen=%jd", sdataphys, edataphys, len, curlen);
 
-		cur->td->td_flags = tdflags;
-		cur->td->td_cbp = HTOO32(sdataphys);
-		cur->td->td_be = HTOO32(edataphys);
-		cur->td->td_nexttd = (next != NULL) ? HTOO32(next->physaddr) : 0;
+		cur->td.td_flags = tdflags;
+		cur->td.td_cbp = HTOO32(sdataphys);
+		cur->td.td_be = HTOO32(edataphys);
+		cur->td.td_nexttd = (next != NULL) ? HTOO32(next->physaddr) : 0;
 		cur->nexttd = next;
 		cur->len = curlen;
 		cur->flags = OHCI_ADD_LEN;
@@ -687,20 +667,20 @@ ohci_reset_std_chain(ohci_softc_t *sc, s
 		if (len != 0) {
 			KASSERT(next != NULL);
 			DPRINTFN(10, "extend chain", 0, 0, 0, 0);
-			usb_syncmem(&cur->dma, cur->offs, sizeof(*cur->td),
+			usb_syncmem(&cur->dma, cur->offs, sizeof(cur->td),
 			BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 
 			cur = next;
 		}
 	}
-	cur->td->td_flags |=
+	cur->td.td_flags |=
 	HTOO32(xfer->ux_flags & USBD_SHORT_XFER_OK ? OHCI_TD_R : 0);
 
 	if (!rd &&
 	(flags & USBD_FORCE_SHORT_XFER) &&
 	alen % mps == 0) {
 		/* We're

CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  2 12:19:37 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: ohci.c

Log Message:
Fix previous, pullup of revision 1.328 totally gone wrong, try again:

Pull up following revision(s) (requested by skrll in ticket #926):

sys/dev/usb/ohci.c: revision 1.328

Fix some usb_syncmem calls and add some missing ones.


To generate a diff of this commit:
cvs rdiff -u -r1.323.4.1 -r1.323.4.2 src/sys/dev/usb/ohci.c

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



CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  2 11:02:44 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: ohci.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #926):

sys/dev/usb/ohci.c: revision 1.328

Fix some usb_syncmem calls and add some missing ones.


To generate a diff of this commit:
cvs rdiff -u -r1.323 -r1.323.4.1 src/sys/dev/usb/ohci.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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.323 src/sys/dev/usb/ohci.c:1.323.4.1
--- src/sys/dev/usb/ohci.c:1.323	Wed Mar  9 22:18:54 2022
+++ src/sys/dev/usb/ohci.c	Wed Oct  2 11:02:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.323 2022/03/09 22:18:54 riastradh Exp $	*/
+/*	$NetBSD: ohci.c,v 1.323.4.1 2024/10/02 11:02:43 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.323 2022/03/09 22:18:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.323.4.1 2024/10/02 11:02:43 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -409,19 +409,29 @@ ohci_alloc_sed(ohci_softc_t *sc)
 		DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
 		mutex_exit(&sc->sc_lock);
 
-		int err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_SED_SIZE * OHCI_SED_CHUNK,
-		OHCI_ED_ALIGN, 0 /*!USBMALLOC_COHERENT*/, &dma);
+		int err = usb_allocmem(sc->sc_bus.ub_dmatag,
+		OHCI_ED_SIZE * OHCI_ED_CHUNK,
+		OHCI_ED_ALIGN, 0, &dma);
 		if (err)
 			return NULL;
 
+		ohci_soft_ed_t *seds =
+		kmem_alloc(sizeof(*sed) * OHCI_ED_CHUNK, KM_SLEEP);
+		/*
+		 * We can avoid USBMALLOC_COHERENT as the EDs are each on a
+		 * cacheline.
+		 */
 		mutex_enter(&sc->sc_lock);
-		for (i = 0; i < OHCI_SED_CHUNK; i++) {
-			offs = i * OHCI_SED_SIZE;
-			sed = KERNADDR(&dma, offs);
+		for (i = 0; i < OHCI_ED_CHUNK; i++) {
+			offs = i * OHCI_ED_SIZE;
+
+			sed = &seds[i];
+			sed->ed = KERNADDR(&dma, offs);
 			sed->physaddr = DMAADDR(&dma, offs);
 			sed->dma = dma;
 			sed->offs = offs;
 			sed->next = sc->sc_freeeds;
+
 			sc->sc_freeeds = sed;
 		}
 	}
@@ -429,7 +439,7 @@ ohci_alloc_sed(ohci_softc_t *sc)
 	sc->sc_freeeds = sed->next;
 	mutex_exit(&sc->sc_lock);
 
-	memset(&sed->ed, 0, sizeof(ohci_ed_t));
+	memset(sed->ed, 0, sizeof(*sed->ed));
 	sed->next = 0;
 	return sed;
 }
@@ -467,19 +477,29 @@ ohci_alloc_std(ohci_softc_t *sc)
 		DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
 		mutex_exit(&sc->sc_lock);
 
-		int err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_STD_SIZE * OHCI_STD_CHUNK,
-		   OHCI_TD_ALIGN, USBMALLOC_COHERENT, &dma);
+		ohci_soft_td_t *stds =
+		kmem_alloc(sizeof(*std) * OHCI_TD_CHUNK, KM_SLEEP);
+		/*
+		 * We can avoid USBMALLOC_COHERENT as the TDs are each on a
+		 * cacheline.
+		 */
+		int err = usb_allocmem(sc->sc_bus.ub_dmatag,
+		OHCI_TD_SIZE * OHCI_TD_CHUNK,
+		OHCI_TD_ALIGN, 0, &dma);
 		if (err)
 			return NULL;
 
 		mutex_enter(&sc->sc_lock);
-		for (i = 0; i < OHCI_STD_CHUNK; i++) {
-			offs = i * OHCI_STD_SIZE;
-			std = KERNADDR(&dma, offs);
+		for (i = 0; i < OHCI_TD_CHUNK; i++) {
+			offs = i * OHCI_TD_SIZE;
+
+			std = &stds[i];
+			std->td = KERNADDR(&dma, offs);
 			std->physaddr = DMAADDR(&dma, offs);
 			std->dma = dma;
 			std->offs = offs;
 			std->nexttd = sc->sc_freetds;
+
 			sc->sc_freetds = std;
 		}
 	}
@@ -488,7 +508,7 @@ ohci_alloc_std(ohci_softc_t *sc)
 	sc->sc_freetds = std->nexttd;
 	mutex_exit(&sc->sc_lock);
 
-	memset(&std->td, 0, sizeof(ohci_td_t));
+	memset(std->td, 0, sizeof(*std->td));
 	std->nexttd = NULL;
 	std->xfer = NULL;
 	std->held = NULL;
@@ -651,10 +671,10 @@ ohci_reset_std_chain(ohci_softc_t *sc, s
 		DPRINTFN(4, "sdataphys=0x%08jx edataphys=0x%08jx "
 		"len=%jd curlen=%jd", sdataphys, edataphys, len, curlen);
 
-		cur->td.td_flags = tdflags;
-		cur->td.td_cbp = HTOO32(sdataphys);
-		cur->td.td_be = HTOO32(edataphys);
-		cur->td.td_nexttd = (next != NULL) ? HTOO32(next->physaddr) : 0;
+		cur->td->td_flags = tdflags;
+		cur->td->td_cbp = HTOO32(sdataphys);
+		cur->td->td_be = HTOO32(edataphys);
+		cur->td->td_nexttd = (next != NULL) ? HTOO32(next->physaddr) : 0;
 		cur->nexttd = next;
 		cur->len = curlen;
 		cur->flags = OHCI_ADD_LEN;
@@ -667,20 +687,20 @@ ohci_reset_std_chain(ohci_softc_t *sc, s
 		if (len != 0) {
 			KASSERT(next != NULL);
 			DPRINTFN(10, "extend chain", 0, 0, 0, 0);
-			usb_syncmem(&cur->dma, cur->offs, sizeof(cur->td),
+			usb_syncmem(&cur->dma, cur->offs, sizeof(*cur->td),
 			BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 
 			cur = next;
 		}
 	}
-	cur->td.td_flags |=
+	cur->td->td_flags |=
 	HTOO32(xfer->ux_flags & USBD_SHORT_XFER_OK ? OHCI_TD_R : 0);
 
 	if (!rd &&
 	(flags & USBD_FORCE_SHORT_XFER) &&
 	alen % mps == 0) {
 		/* We're adding a ZLP so sync the previous TD */
-		usb_syncmem(&cur->dma, cur->offs, sizeof(

CVS commit: [netbsd-10] src/sys/dev/usb

2024-10-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct  2 11:02:44 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: ohci.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #926):

sys/dev/usb/ohci.c: revision 1.328

Fix some usb_syncmem calls and add some missing ones.


To generate a diff of this commit:
cvs rdiff -u -r1.323 -r1.323.4.1 src/sys/dev/usb/ohci.c

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



CVS commit: [netbsd-10] src/sys/arch/i386/i386

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:37:02 UTC 2024

Modified Files:
src/sys/arch/i386/i386 [netbsd-10]: vector.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #908):

sys/arch/i386/i386/vector.S: revision 1.90

PR/58653: me: Revert btsl of negative value to orl


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.89.4.1 src/sys/arch/i386/i386/vector.S

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



CVS commit: [netbsd-10] src/sys/arch/i386/i386

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:37:02 UTC 2024

Modified Files:
src/sys/arch/i386/i386 [netbsd-10]: vector.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #908):

sys/arch/i386/i386/vector.S: revision 1.90

PR/58653: me: Revert btsl of negative value to orl


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.89.4.1 src/sys/arch/i386/i386/vector.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/i386/i386/vector.S
diff -u src/sys/arch/i386/i386/vector.S:1.89 src/sys/arch/i386/i386/vector.S:1.89.4.1
--- src/sys/arch/i386/i386/vector.S:1.89	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/i386/i386/vector.S	Sat Sep 21 12:37:02 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.89 2022/09/07 00:40:18 knakahara Exp $	*/
+/*	$NetBSD: vector.S,v 1.89.4.1 2024/09/21 12:37:02 martin Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.89 2022/09/07 00:40:18 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.89.4.1 2024/09/21 12:37:02 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -354,7 +354,7 @@ IDTVEC(resume_hyperv_hypercall)
 	cli
 	jmp	_C_LABEL(Xdoreti)
 2:
-	btsl	$(LIR_HV - 32),CPUVAR(IPENDING)+4
+	orl	$(1 << LIR_HV),CPUVAR(IPENDING)
 	INTRFASTEXIT
 IDTVEC_END(resume_hyperv_hypercall)
 #endif	/* NHYPERV > 0 */



CVS commit: [netbsd-10] src/sys/kern

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:32:39 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: subr_xcall.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #905):

sys/kern/subr_xcall.c: revision 1.36

xcall(9): If !mp_online, raise spl or set LP_BOUND to call func.

High-priority xcalls may reasonably assume that the spl is raised to
splsoftserial, so make sure to do that in xc_broadcast.

Low-priority xcalls may reasonably enter paths that assume the lwp is
bound to a CPU, so let's make it assertable even if it doesn't have
any other consequences when !mp_online.


To generate a diff of this commit:
cvs rdiff -u -r1.34.18.1 -r1.34.18.2 src/sys/kern/subr_xcall.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/subr_xcall.c
diff -u src/sys/kern/subr_xcall.c:1.34.18.1 src/sys/kern/subr_xcall.c:1.34.18.2
--- src/sys/kern/subr_xcall.c:1.34.18.1	Wed Sep 11 10:09:19 2024
+++ src/sys/kern/subr_xcall.c	Sat Sep 21 12:32:39 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_xcall.c,v 1.34.18.1 2024/09/11 10:09:19 martin Exp $	*/
+/*	$NetBSD: subr_xcall.c,v 1.34.18.2 2024/09/21 12:32:39 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007-2010, 2019 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.34.18.1 2024/09/11 10:09:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.34.18.2 2024/09/21 12:32:39 martin Exp $");
 
 #include 
 #include 
@@ -261,7 +261,17 @@ xc_broadcast(unsigned int flags, xcfunc_
 	ASSERT_SLEEPABLE();
 
 	if (__predict_false(!mp_online)) {
+		int s, bound;
+
+		if (flags & XC_HIGHPRI)
+			s = splsoftserial();
+		else
+			bound = curlwp_bind();
 		(*func)(arg1, arg2);
+		if (flags & XC_HIGHPRI)
+			splx(s);
+		else
+			curlwp_bindx(bound);
 		return 0;
 	}
 
@@ -301,19 +311,28 @@ xc_barrier(unsigned int flags)
  */
 uint64_t
 xc_unicast(unsigned int flags, xcfunc_t func, void *arg1, void *arg2,
-	   struct cpu_info *ci)
+struct cpu_info *ci)
 {
-	int s;
 
 	KASSERT(ci != NULL);
 	KASSERT(!cpu_intr_p() && !cpu_softintr_p());
 	ASSERT_SLEEPABLE();
 
 	if (__predict_false(!mp_online)) {
+		int s, bound;
+
 		KASSERT(ci == curcpu());
-		s = splsoftserial();
+
+		if (flags & XC_HIGHPRI)
+			s = splsoftserial();
+		else
+			bound = curlwp_bind();
 		(*func)(arg1, arg2);
-		splx(s);
+		if (flags & XC_HIGHPRI)
+			splx(s);
+		else
+			curlwp_bindx(bound);
+
 		return 0;
 	}
 



CVS commit: [netbsd-10] src/sys/kern

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:32:39 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: subr_xcall.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #905):

sys/kern/subr_xcall.c: revision 1.36

xcall(9): If !mp_online, raise spl or set LP_BOUND to call func.

High-priority xcalls may reasonably assume that the spl is raised to
splsoftserial, so make sure to do that in xc_broadcast.

Low-priority xcalls may reasonably enter paths that assume the lwp is
bound to a CPU, so let's make it assertable even if it doesn't have
any other consequences when !mp_online.


To generate a diff of this commit:
cvs rdiff -u -r1.34.18.1 -r1.34.18.2 src/sys/kern/subr_xcall.c

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



CVS commit: [netbsd-10] src/sys/dev/pci

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:30:43 UTC 2024

Modified Files:
src/sys/dev/pci [netbsd-10]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #904):

sys/dev/pci/if_vmx.c: revision 1.12

vmxnet(4): Fix various MP bugs.
- Defer reset to workqueue.
   => vmxnet3_stop_locked is forbidden in softint.
   => XXX Problem: We still take the core lock in softint, and we
  still take the core lock around vmxnet3_stop_locked.  TBD.
- Touch if_flags only under IFNET_LOCK.
   => Cache ifp->if_flags & IFF_PROMISC in vmxnet3_ifflags_cb.
   => Don't call vmxnet3_set_rxfilter unless up and running; cache
  this as vmx_mcastactive.  Use ENETRESET in vmxnet3_ifflags_cb
  instead of calling vmxnet3_set_rxfilter directly.
  . (The cache is currently serialized by the core lock, but it
might reasonably be serialized by an independent lock like in
usbnet(9).)
- Fix vmxnet3_stop_rendezvous so it actually does something.
   => New vxtxq_stopping, vxrxq_stopping variables synchronize with
  Rx/Tx interrupt handlers.
- Sprinkle IFNET_LOCK and core lock assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.11.4.1 -r1.11.4.2 src/sys/dev/pci/if_vmx.c

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

Modified files:

Index: src/sys/dev/pci/if_vmx.c
diff -u src/sys/dev/pci/if_vmx.c:1.11.4.1 src/sys/dev/pci/if_vmx.c:1.11.4.2
--- src/sys/dev/pci/if_vmx.c:1.11.4.1	Sat May 11 14:49:51 2024
+++ src/sys/dev/pci/if_vmx.c	Sat Sep 21 12:30:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.11.4.1 2024/05/11 14:49:51 martin Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.11.4.2 2024/09/21 12:30:43 martin Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.11.4.1 2024/05/11 14:49:51 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.11.4.2 2024/09/21 12:30:43 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_if_vmx.h"
@@ -212,6 +212,8 @@ struct vmxnet3_txqueue {
 	struct evcnt vxtxq_watchdogto;
 	struct evcnt vxtxq_defragged;
 	struct evcnt vxtxq_defrag_failed;
+
+	bool vxtxq_stopping;
 };
 
 
@@ -230,6 +232,8 @@ struct vmxnet3_rxqueue {
 	struct evcnt vxrxq_deferreq;
 	struct evcnt vxrxq_mgetcl_failed;
 	struct evcnt vxrxq_mbuf_load_failed;
+
+	bool vxrxq_stopping;
 };
 
 struct vmxnet3_queue {
@@ -291,6 +295,9 @@ struct vmxnet3_softc {
 
 	kmutex_t *vmx_mtx;
 
+	int vmx_if_flags;
+	bool vmx_promisc;
+	bool vmx_mcastactive;
 	uint8_t *vmx_mcast;
 	void *vmx_qs;
 	struct vmxnet3_rss_shared *vmx_rss;
@@ -311,6 +318,10 @@ struct vmxnet3_softc {
 
 	bool vmx_txrx_workqueue;
 	struct workqueue *vmx_queue_wq;
+
+	struct workqueue *vmx_reset_wq;
+	struct work vmx_reset_work;
+	bool vmx_reset_pending;
 };
 
 #define VMXNET3_STAT
@@ -435,6 +446,7 @@ static int vmxnet3_ifflags_cb(struct eth
 static int vmxnet3_watchdog(struct vmxnet3_txqueue *);
 static void vmxnet3_refresh_host_stats(struct vmxnet3_softc *);
 static void vmxnet3_tick(void *);
+static void vmxnet3_reset_work(struct work *, void *);
 static void vmxnet3_if_link_status(struct vmxnet3_softc *);
 static bool vmxnet3_cmd_link_status(struct ifnet *);
 static void vmxnet3_ifmedia_status(struct ifnet *, struct ifmediareq *);
@@ -633,6 +645,18 @@ vmxnet3_attach(device_t parent, device_t
 	if (error)
 		return;
 
+	char buf[128];
+	snprintf(buf, sizeof(buf), "%s_reset", device_xname(sc->vmx_dev));
+	error = workqueue_create(&sc->vmx_reset_wq, "%s_reset",
+	vmxnet3_reset_work, sc, VMXNET3_WORKQUEUE_PRI, IPL_SOFTCLOCK,
+	WQ_MPSAFE);
+	if (error) {
+		aprint_error_dev(sc->vmx_dev,
+		"failed to create reset workqueue: %d\n",
+		error);
+		return;
+	}
+
 	sc->vmx_flags |= VMXNET3_FLAG_ATTACHED;
 }
 
@@ -1124,6 +1148,8 @@ vmxnet3_init_rxq(struct vmxnet3_softc *s
 		rxq->vxrxq_comp_ring.vxcr_ndesc += sc->vmx_nrxdescs;
 	}
 
+	rxq->vxrxq_stopping = true;
+
 	return (0);
 }
 
@@ -1159,6 +1185,8 @@ vmxnet3_init_txq(struct vmxnet3_softc *s
 
 	txq->vxtxq_interq = pcq_create(sc->vmx_ntxdescs, KM_SLEEP);
 
+	txq->vxtxq_stopping = true;
+
 	return (0);
 }
 
@@ -2336,7 +2364,7 @@ vmxnet3_rxq_eof(struct vmxnet3_rxqueue *
 
 	VMXNET3_RXQ_LOCK_ASSERT(rxq);
 
-	if ((ifp->if_flags & IFF_RUNNING) == 0)
+	if (rxq->vxrxq_stopping)
 		return more;
 
 	m_head = rxq->vxrxq_mhead;
@@ -2442,7 +2470,7 @@ vmxnet3_rxq_eof(struct vmxnet3_rxqueue *
 			m_head = m_tail = NULL;
 
 			/* Must recheck after dropping the Rx lock. */
-			if ((ifp->if_flags & IFF_RUNNING) == 0)
+			if (rxq->vxrxq_stopping)
 break;
 		}
 
@@ -2711,11 +2739,13 @@ vmxnet3_stop_rendezvous(struct vmxnet3_s
 	for (i = 0; i < sc->vmx_nrxqueues; i++) {
 		rxq = &sc->vmx_queue[i].vxq_rxqueue;
 		VMXNET3_RXQ_LOCK(rxq);
+		rxq->vxrxq_stopping = true;
 		VMXNET3_RXQ_UNLOCK(rxq);
 	}
 	for (i = 0; i < sc->vmx_ntxqueues; i++) {
 		txq = &sc->vmx_queue[i]

CVS commit: [netbsd-10] src/sys/dev/pci

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:30:43 UTC 2024

Modified Files:
src/sys/dev/pci [netbsd-10]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #904):

sys/dev/pci/if_vmx.c: revision 1.12

vmxnet(4): Fix various MP bugs.
- Defer reset to workqueue.
   => vmxnet3_stop_locked is forbidden in softint.
   => XXX Problem: We still take the core lock in softint, and we
  still take the core lock around vmxnet3_stop_locked.  TBD.
- Touch if_flags only under IFNET_LOCK.
   => Cache ifp->if_flags & IFF_PROMISC in vmxnet3_ifflags_cb.
   => Don't call vmxnet3_set_rxfilter unless up and running; cache
  this as vmx_mcastactive.  Use ENETRESET in vmxnet3_ifflags_cb
  instead of calling vmxnet3_set_rxfilter directly.
  . (The cache is currently serialized by the core lock, but it
might reasonably be serialized by an independent lock like in
usbnet(9).)
- Fix vmxnet3_stop_rendezvous so it actually does something.
   => New vxtxq_stopping, vxrxq_stopping variables synchronize with
  Rx/Tx interrupt handlers.
- Sprinkle IFNET_LOCK and core lock assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.11.4.1 -r1.11.4.2 src/sys/dev/pci/if_vmx.c

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



CVS commit: [netbsd-10] src/sys/netinet

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:28:46 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: ip_output.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #903):

sys/netinet/ip_output.c: revision 1.326

Again allow multicast packets to be sent from unnumbered interfaces.


To generate a diff of this commit:
cvs rdiff -u -r1.324.2.1 -r1.324.2.2 src/sys/netinet/ip_output.c

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

Modified files:

Index: src/sys/netinet/ip_output.c
diff -u src/sys/netinet/ip_output.c:1.324.2.1 src/sys/netinet/ip_output.c:1.324.2.2
--- src/sys/netinet/ip_output.c:1.324.2.1	Tue Apr 25 16:15:14 2023
+++ src/sys/netinet/ip_output.c	Sat Sep 21 12:28:46 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_output.c,v 1.324.2.1 2023/04/25 16:15:14 martin Exp $	*/
+/*	$NetBSD: ip_output.c,v 1.324.2.2 2024/09/21 12:28:46 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.324.2.1 2023/04/25 16:15:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.324.2.2 2024/09/21 12:28:46 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -348,11 +348,6 @@ ip_output(struct mbuf *m0, struct mbuf *
 		}
 		mtu = ifp->if_mtu;
 		ia = in_get_ia_from_ifp_psref(ifp, &psref_ia);
-		if (ia == NULL) {
-			IP_STATINC(IP_STAT_IFNOADDR);
-			error = EADDRNOTAVAIL;
-			goto bad;
-		}
 		if (IN_MULTICAST(ip->ip_dst.s_addr) ||
 		ip->ip_dst.s_addr == INADDR_BROADCAST) {
 			isbroadcast = 0;



CVS commit: [netbsd-10] src/sys/netinet

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:28:46 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: ip_output.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #903):

sys/netinet/ip_output.c: revision 1.326

Again allow multicast packets to be sent from unnumbered interfaces.


To generate a diff of this commit:
cvs rdiff -u -r1.324.2.1 -r1.324.2.2 src/sys/netinet/ip_output.c

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



CVS commit: [netbsd-10] src/sys/net

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:22:36 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: if_gif.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #901):

sys/net/if_gif.c: revision 1.159

Drop locks before freeing unreferenced memory in gif_set_tunnel


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.157.4.1 src/sys/net/if_gif.c

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

Modified files:

Index: src/sys/net/if_gif.c
diff -u src/sys/net/if_gif.c:1.157 src/sys/net/if_gif.c:1.157.4.1
--- src/sys/net/if_gif.c:1.157	Sat Sep  3 02:47:59 2022
+++ src/sys/net/if_gif.c	Sat Sep 21 12:22:36 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gif.c,v 1.157 2022/09/03 02:47:59 thorpej Exp $	*/
+/*	$NetBSD: if_gif.c,v 1.157.4.1 2024/09/21 12:22:36 martin 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.157 2022/09/03 02:47:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.157.4.1 2024/09/21 12:22:36 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1160,12 +1160,13 @@ gif_set_tunnel(struct ifnet *ifp, struct
 	return 0;
 
  out:
+	mutex_exit(&sc->gif_lock);
+	encap_lock_exit();
+
 	sockaddr_free(nsrc);
 	sockaddr_free(ndst);
 	kmem_free(nvar, sizeof(*nvar));
 
-	mutex_exit(&sc->gif_lock);
-	encap_lock_exit();
 #ifndef GIF_MPSAFE
 	splx(s);
 #endif



CVS commit: [netbsd-10] src/sys/net

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:22:36 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: if_gif.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #901):

sys/net/if_gif.c: revision 1.159

Drop locks before freeing unreferenced memory in gif_set_tunnel


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.157.4.1 src/sys/net/if_gif.c

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



CVS commit: [netbsd-10] src/sys/arch

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:20:23 UTC 2024

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-10]: db_interface.c
src/sys/arch/i386/i386 [netbsd-10]: db_interface.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #900):

sys/arch/amd64/amd64/db_interface.c: revision 1.42
sys/arch/i386/i386/db_interface.c: revision 1.89

when cpus are paused (spinning) in DDB, call x86_pause() in the loop,
hopefully this can reduce power usage while doing nothing.

ok chs@
XXX: apply to i386

i386: DDB: Call x86_pause() (`pause` insn) when CPUs are paused
as already done for amd64:
https://mail-index.netbsd.org/source-changes/2023/07/31/msg146423.html

`pause` insn has been introduced to Pentium 4. However, its opcode is
consisted of `nop` (0x90) followed by `rep` prefix (0xf3), and therefore
interpreted as `nop` for older processors. Intel assured this behavior [1].

Also note that we already use `pause` unconditionally for i386.

Briefly tested on QEMU.

[1] Intel, ``AP-949 Using Spin-Loops on Intel Pentium 4 Processor and
Intel Xeon Processor'', Version 2.1, Sec 2.1.1. (2001)


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.2.1 src/sys/arch/amd64/amd64/db_interface.c
cvs rdiff -u -r1.88 -r1.88.2.1 src/sys/arch/i386/i386/db_interface.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/amd64/amd64/db_interface.c
diff -u src/sys/arch/amd64/amd64/db_interface.c:1.41 src/sys/arch/amd64/amd64/db_interface.c:1.41.2.1
--- src/sys/arch/amd64/amd64/db_interface.c:1.41	Wed Oct 26 23:38:06 2022
+++ src/sys/arch/amd64/amd64/db_interface.c	Sat Sep 21 12:20:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.41 2022/10/26 23:38:06 riastradh Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.41.2.1 2024/09/21 12:20:22 martin Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.41 2022/10/26 23:38:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.41.2.1 2024/09/21 12:20:22 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -303,7 +303,7 @@ ddb_suspend(struct trapframe *frame)
 	atomic_or_32(&ci->ci_flags, CPUF_PAUSE);
 
 	while (ci->ci_flags & CPUF_PAUSE)
-		;
+		x86_pause();
 	ci->ci_ddb_regs = 0;
 	tlbflushg();
 }

Index: src/sys/arch/i386/i386/db_interface.c
diff -u src/sys/arch/i386/i386/db_interface.c:1.88 src/sys/arch/i386/i386/db_interface.c:1.88.2.1
--- src/sys/arch/i386/i386/db_interface.c:1.88	Wed Oct 26 23:38:07 2022
+++ src/sys/arch/i386/i386/db_interface.c	Sat Sep 21 12:20:23 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.88 2022/10/26 23:38:07 riastradh Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.88.2.1 2024/09/21 12:20:23 martin Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.88 2022/10/26 23:38:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.88.2.1 2024/09/21 12:20:23 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -369,7 +369,7 @@ ddb_suspend(struct trapframe *frame)
 	atomic_or_32(&ci->ci_flags, CPUF_PAUSE);
 
 	while (ci->ci_flags & CPUF_PAUSE)
-		;
+		x86_pause();
 	ci->ci_ddb_regs = 0;
 	tlbflushg();
 }



CVS commit: [netbsd-10] src/sys/arch

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:20:23 UTC 2024

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-10]: db_interface.c
src/sys/arch/i386/i386 [netbsd-10]: db_interface.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #900):

sys/arch/amd64/amd64/db_interface.c: revision 1.42
sys/arch/i386/i386/db_interface.c: revision 1.89

when cpus are paused (spinning) in DDB, call x86_pause() in the loop,
hopefully this can reduce power usage while doing nothing.

ok chs@
XXX: apply to i386

i386: DDB: Call x86_pause() (`pause` insn) when CPUs are paused
as already done for amd64:
https://mail-index.netbsd.org/source-changes/2023/07/31/msg146423.html

`pause` insn has been introduced to Pentium 4. However, its opcode is
consisted of `nop` (0x90) followed by `rep` prefix (0xf3), and therefore
interpreted as `nop` for older processors. Intel assured this behavior [1].

Also note that we already use `pause` unconditionally for i386.

Briefly tested on QEMU.

[1] Intel, ``AP-949 Using Spin-Loops on Intel Pentium 4 Processor and
Intel Xeon Processor'', Version 2.1, Sec 2.1.1. (2001)


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.2.1 src/sys/arch/amd64/amd64/db_interface.c
cvs rdiff -u -r1.88 -r1.88.2.1 src/sys/arch/i386/i386/db_interface.c

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



CVS commit: [netbsd-10] src/sys/net

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:17:27 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: if_tun.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #899):

sys/net/if_tun.c: revision 1.177

tun(4): Mark tunread_filtops `FILTEROP_MPSAFE`

Filter handlers have already been MP-safe since 2018:
https://mail-index.netbsd.org/source-changes/2018/08/06/msg097317.html

Note that we do not expect deadlocks similar to bpf(4) (PR kern/58531),
b/w KERNEL_LOCK and spin mutex for TX queue.

For tun(4), filt_tunread() acquires adaptive mutex. This is forbidden
when spin mutex is already held.

Such a path must have already been detected if present.

Thanks ozaki-r@ for discussion.


To generate a diff of this commit:
cvs rdiff -u -r1.173.4.2 -r1.173.4.3 src/sys/net/if_tun.c

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

Modified files:

Index: src/sys/net/if_tun.c
diff -u src/sys/net/if_tun.c:1.173.4.2 src/sys/net/if_tun.c:1.173.4.3
--- src/sys/net/if_tun.c:1.173.4.2	Mon Mar 11 19:28:45 2024
+++ src/sys/net/if_tun.c	Sat Sep 21 12:17:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tun.c,v 1.173.4.2 2024/03/11 19:28:45 martin Exp $	*/
+/*	$NetBSD: if_tun.c,v 1.173.4.3 2024/09/21 12:17:27 martin Exp $	*/
 
 /*
  * Copyright (c) 1988, Julian Onions 
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.173.4.2 2024/03/11 19:28:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.173.4.3 2024/09/21 12:17:27 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1098,7 +1098,7 @@ filt_tunread(struct knote *kn, long hint
 }
 
 static const struct filterops tunread_filtops = {
-	.f_flags = FILTEROP_ISFD,
+	.f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
 	.f_attach = NULL,
 	.f_detach = filt_tunrdetach,
 	.f_event = filt_tunread,



CVS commit: [netbsd-10] src/sys/net

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:17:27 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: if_tun.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #899):

sys/net/if_tun.c: revision 1.177

tun(4): Mark tunread_filtops `FILTEROP_MPSAFE`

Filter handlers have already been MP-safe since 2018:
https://mail-index.netbsd.org/source-changes/2018/08/06/msg097317.html

Note that we do not expect deadlocks similar to bpf(4) (PR kern/58531),
b/w KERNEL_LOCK and spin mutex for TX queue.

For tun(4), filt_tunread() acquires adaptive mutex. This is forbidden
when spin mutex is already held.

Such a path must have already been detected if present.

Thanks ozaki-r@ for discussion.


To generate a diff of this commit:
cvs rdiff -u -r1.173.4.2 -r1.173.4.3 src/sys/net/if_tun.c

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



CVS commit: [netbsd-10] src/sys/stand/efiboot

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:13:05 UTC 2024

Modified Files:
src/sys/stand/efiboot [netbsd-10]: exec.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #898):

sys/stand/efiboot/exec.c: revision 1.26

When freeing pages, pass page count instead of byte count.


To generate a diff of this commit:
cvs rdiff -u -r1.23.4.1 -r1.23.4.2 src/sys/stand/efiboot/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/sys/stand/efiboot/exec.c
diff -u src/sys/stand/efiboot/exec.c:1.23.4.1 src/sys/stand/efiboot/exec.c:1.23.4.2
--- src/sys/stand/efiboot/exec.c:1.23.4.1	Fri Nov  3 09:59:04 2023
+++ src/sys/stand/efiboot/exec.c	Sat Sep 21 12:13:05 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.23.4.1 2023/11/03 09:59:04 martin Exp $ */
+/* $NetBSD: exec.c,v 1.23.4.2 2024/09/21 12:13:05 martin Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -154,7 +154,8 @@ generate_efirng(void)
 
 	/* Fill the page with whatever the EFI RNG will do.  */
 	if (efi_rng((void *)(uintptr_t)addr, size)) {
-		uefi_call_wrapper(BS->FreePages, 2, addr, size);
+		uefi_call_wrapper(BS->FreePages, 2, addr,
+		EFI_SIZE_TO_PAGES(size));
 		return;
 	}
 



CVS commit: [netbsd-10] src/sys/stand/efiboot

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:13:05 UTC 2024

Modified Files:
src/sys/stand/efiboot [netbsd-10]: exec.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #898):

sys/stand/efiboot/exec.c: revision 1.26

When freeing pages, pass page count instead of byte count.


To generate a diff of this commit:
cvs rdiff -u -r1.23.4.1 -r1.23.4.2 src/sys/stand/efiboot/exec.c

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



CVS commit: [netbsd-10] src/sys/nfs

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:44:58 UTC 2024

Modified Files:
src/sys/nfs [netbsd-10]: nfs_clntsubs.c nfs_iod.c nfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #880):

sys/nfs/nfs_iod.c: revision 1.9
sys/nfs/nfs_vfsops.c: revision 1.245
sys/nfs/nfs_clntsubs.c: revision 1.7

PR/57279: Izumi Tsutsui: Fix some {int,long} -> time_t. Still things will
break eventually because parts of the nfs protocol assume time_t will fit
in 32 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.4.1 src/sys/nfs/nfs_clntsubs.c
cvs rdiff -u -r1.8 -r1.8.30.1 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.243.10.1 -r1.243.10.2 src/sys/nfs/nfs_vfsops.c

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



CVS commit: [netbsd-10] src/sys/nfs

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:44:58 UTC 2024

Modified Files:
src/sys/nfs [netbsd-10]: nfs_clntsubs.c nfs_iod.c nfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #880):

sys/nfs/nfs_iod.c: revision 1.9
sys/nfs/nfs_vfsops.c: revision 1.245
sys/nfs/nfs_clntsubs.c: revision 1.7

PR/57279: Izumi Tsutsui: Fix some {int,long} -> time_t. Still things will
break eventually because parts of the nfs protocol assume time_t will fit
in 32 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.4.1 src/sys/nfs/nfs_clntsubs.c
cvs rdiff -u -r1.8 -r1.8.30.1 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.243.10.1 -r1.243.10.2 src/sys/nfs/nfs_vfsops.c

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

Modified files:

Index: src/sys/nfs/nfs_clntsubs.c
diff -u src/sys/nfs/nfs_clntsubs.c:1.6 src/sys/nfs/nfs_clntsubs.c:1.6.4.1
--- src/sys/nfs/nfs_clntsubs.c:1.6	Mon Feb 28 08:45:36 2022
+++ src/sys/nfs/nfs_clntsubs.c	Fri Sep 20 11:44:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $	*/
+/*	$NetBSD: nfs_clntsubs.c,v 1.6.4.1 2024/09/20 11:44:58 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.6.4.1 2024/09/20 11:44:58 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -390,7 +390,7 @@ nfs_check_wccdata(struct nfsnode *np, co
 	if (docheck) {
 		struct vnode *vp = NFSTOV(np);
 		struct nfsmount *nmp;
-		long now = time_second;
+		time_t now = time_second;
 		const struct timespec *omtime = &np->n_vattr->va_mtime;
 		const struct timespec *octime = &np->n_vattr->va_ctime;
 		const char *reason = NULL; /* XXX: gcc */

Index: src/sys/nfs/nfs_iod.c
diff -u src/sys/nfs/nfs_iod.c:1.8 src/sys/nfs/nfs_iod.c:1.8.30.1
--- src/sys/nfs/nfs_iod.c:1.8	Mon Sep  3 16:29:36 2018
+++ src/sys/nfs/nfs_iod.c	Fri Sep 20 11:44:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_iod.c,v 1.8 2018/09/03 16:29:36 riastradh Exp $	*/
+/*	$NetBSD: nfs_iod.c,v 1.8.30.1 2024/09/20 11:44:58 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_iod.c,v 1.8 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_iod.c,v 1.8.30.1 2024/09/20 11:44:58 martin Exp $");
 
 #include 
 #include 
@@ -409,7 +409,8 @@ nfs_savenickauth(struct nfsmount *nmp, k
 	struct timeval ktvin, ktvout;
 	u_int32_t nick;
 	char *dpos = *dposp, *cp2;
-	int deltasec, error = 0;
+	time_t deltasec;
+	int error = 0;
 
 	memset(&ktvout, 0, sizeof ktvout);	 /* XXX gcc */
 

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.243.10.1 src/sys/nfs/nfs_vfsops.c:1.243.10.2
--- src/sys/nfs/nfs_vfsops.c:1.243.10.1	Fri Sep 20 10:29:41 2024
+++ src/sys/nfs/nfs_vfsops.c	Fri Sep 20 11:44:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.243.10.1 2024/09/20 10:29:41 martin Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.243.10.2 2024/09/20 11:44:58 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243.10.1 2024/09/20 10:29:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243.10.2 2024/09/20 11:44:58 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -323,7 +323,7 @@ nfs_mountroot(void)
 	struct mount *mp;
 	struct vnode *vp;
 	struct lwp *l;
-	long n;
+	time_t n;
 	int error;
 
 	l = curlwp; /* XXX */
@@ -378,7 +378,7 @@ nfs_mountroot(void)
 		panic("nfs_mountroot: getattr for root");
 	n = attr.va_atime.tv_sec;
 #ifdef	DEBUG
-	printf("root time: 0x%lx\n", n);
+	printf("root time: 0x%jx\n", (intmax_t)n);
 #endif
 	setrootfstime(n);
 



CVS commit: [netbsd-10] src/sys/arch/evbppc/conf

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:33:52 UTC 2024

Modified Files:
src/sys/arch/evbppc/conf [netbsd-10]: WII

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #897):

sys/arch/evbppc/conf/WII: revision 1.5

Add DKWEDGE_AUTODISCOVER and DKWEDGE_METHOD_GPT to WII
>From Guilherme Janczak in PR 58676


To generate a diff of this commit:
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/arch/evbppc/conf/WII

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



CVS commit: [netbsd-10] src/sys/arch/evbppc/conf

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:33:52 UTC 2024

Modified Files:
src/sys/arch/evbppc/conf [netbsd-10]: WII

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #897):

sys/arch/evbppc/conf/WII: revision 1.5

Add DKWEDGE_AUTODISCOVER and DKWEDGE_METHOD_GPT to WII
>From Guilherme Janczak in PR 58676


To generate a diff of this commit:
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/arch/evbppc/conf/WII

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/evbppc/conf/WII
diff -u src/sys/arch/evbppc/conf/WII:1.4.2.2 src/sys/arch/evbppc/conf/WII:1.4.2.3
--- src/sys/arch/evbppc/conf/WII:1.4.2.2	Sat Feb  3 11:47:06 2024
+++ src/sys/arch/evbppc/conf/WII	Fri Sep 20 11:33:51 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: WII,v 1.4.2.2 2024/02/03 11:47:06 martin Exp $
+#	$NetBSD: WII,v 1.4.2.3 2024/09/20 11:33:51 martin Exp $
 #
 #	Nintendo Wii
 #
@@ -46,6 +46,10 @@ makeoptions DEBUG="-g"	# compile full sy
 include 	"conf/compat_netbsd50.config"
 #options 	COMPAT_386BSD_MBRPART # recognize old partition ID
 
+# Wedge support
+options 	DKWEDGE_AUTODISCOVER	# Automatically add dk(4) instances
+options 	DKWEDGE_METHOD_GPT	# Supports GPT partitions as wedges
+
 # File systems
 file-system 	FFS		# UFS
 file-system 	EXT2FS		# second extended file system (linux)



CVS commit: [netbsd-10] src/sys

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:31:32 UTC 2024

Modified Files:
src/sys/arch/i386/stand [netbsd-10]: Makefile.booters
src/sys/arch/i386/stand/efiboot [netbsd-10]: Makefile.efiboot
src/sys/arch/i386/stand/pxeboot [netbsd-10]: Makefile
src/sys/lib/libsa [netbsd-10]: nfs.c nfsv2.h rpcv2.h
Added Files:
src/sys/lib/libsa [netbsd-10]: nfsv3.h
Removed Files:
src/sys/arch/i386/stand/libsa [netbsd-10]: nfs.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC


To generate a diff of this commit:
cvs rdiff -u -r1.94.20.1 -r1.94.20.2 src/sys/arch/i386/stand/Makefile.booters
cvs rdiff -u -r1.19.4.1 -r1.19.4.2 \
src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.19 -r0 src/sys/arch/i386/stand/libsa/nfs.c
cvs rdiff -u -r1.28 -r1.28.26.1 src/sys/arch/i386/stand/pxeboot/Makefile
cvs rdiff -u -r1.50 -r1.50.24.1 src/sys/lib/libsa/nfs.c
cvs rdiff -u -r1.4 -r1.4.194.1 src/sys/lib/libsa/nfsv2.h
cvs rdiff -u -r0 -r1.1.4.2 src/sys/lib/libsa/nfsv3.h
cvs rdiff -u -r1.3 -r1.3.194.1 src/sys/lib/libsa/rpcv2.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/i386/stand/Makefile.booters
diff -u src/sys/arch/i386/stand/Makefile.booters:1.94.20.1 src/sys/arch/i386/stand/Makefile.booters:1.94.20.2
--- src/sys/arch/i386/stand/Makefile.booters:1.94.20.1	Thu Dec 14 17:56:08 2023
+++ src/sys/arch/i386/stand/Makefile.booters	Fri Sep 20 11:31:31 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.booters,v 1.94.20.1 2023/12/14 17:56:08 martin Exp $
+#	$NetBSD: Makefile.booters,v 1.94.20.2 2024/09/20 11:31:31 martin Exp $
 
 NOLIBCSANITIZER=
 NOSANITIZER=
@@ -64,6 +64,7 @@ LIBZ=		${ZLIB}
 ### find out what to use for libsa
 SA_AS=		library
 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
+SAMISCCPPFLAGS+=-DLIBSA_NFS_IMPLICIT_MOUNT
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA=		${SALIB}
 

Index: src/sys/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.19.4.1 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.19.4.2
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.19.4.1	Mon Sep 11 13:25:42 2023
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Fri Sep 20 11:31:32 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.19.4.1 2023/09/11 13:25:42 martin Exp $
+# $NetBSD: Makefile.efiboot,v 1.19.4.2 2024/09/20 11:31:32 martin Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -21,9 +21,7 @@ LIBI386SRCS= biosdisk.c bootinfo.c booti
 LIBI386SRCS+= comio_direct.c
 LIBI386SRCS+= diskbuf.c exec.c menuutils.c parseutils.c pread.c
 LIBI386SRCS+= exec_multiboot1.c exec_multiboot2.c
-# use our own nfs implementation
-LIBSASRCS+= nfs.c
-SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS} ${LIBSASRCS}
+SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
 
 .include 
 
@@ -86,6 +84,7 @@ GNUEFIARCH?= ${MACHINE_CPU}
 CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH}
 CPPFLAGS+= -I${EFIDIR}/inc/protocol
 
+SAMISCCPPFLAGS+= -DLIBSA_NFS_IMPLICIT_MOUNT
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
 SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)"

Index: src/sys/arch/i386/stand/pxeboot/Makefile
diff -u src/sys/arch/i386/stand/pxeboot/Makefile:1.28 src/sys/arch/i386/stand/pxeboot/Makefile:1.28.26.1
--- src/sys/arch/i386/stand/pxeboot/Makefile:1.28	Fri Sep 27 08:57:10 2019
+++ src/sys/arch/i386/stand/pxeboot/Makefile	Fri Sep 20 11:31:32 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.28 2019/09/27 08:57:10 gson Exp $
+#	$NetBSD: Makefile,v 1.28.26.1 2024/09/20 11:31:32 marti

CVS commit: [netbsd-10] src/sys

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:31:32 UTC 2024

Modified Files:
src/sys/arch/i386/stand [netbsd-10]: Makefile.booters
src/sys/arch/i386/stand/efiboot [netbsd-10]: Makefile.efiboot
src/sys/arch/i386/stand/pxeboot [netbsd-10]: Makefile
src/sys/lib/libsa [netbsd-10]: nfs.c nfsv2.h rpcv2.h
Added Files:
src/sys/lib/libsa [netbsd-10]: nfsv3.h
Removed Files:
src/sys/arch/i386/stand/libsa [netbsd-10]: nfs.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC


To generate a diff of this commit:
cvs rdiff -u -r1.94.20.1 -r1.94.20.2 src/sys/arch/i386/stand/Makefile.booters
cvs rdiff -u -r1.19.4.1 -r1.19.4.2 \
src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.19 -r0 src/sys/arch/i386/stand/libsa/nfs.c
cvs rdiff -u -r1.28 -r1.28.26.1 src/sys/arch/i386/stand/pxeboot/Makefile
cvs rdiff -u -r1.50 -r1.50.24.1 src/sys/lib/libsa/nfs.c
cvs rdiff -u -r1.4 -r1.4.194.1 src/sys/lib/libsa/nfsv2.h
cvs rdiff -u -r0 -r1.1.4.2 src/sys/lib/libsa/nfsv3.h
cvs rdiff -u -r1.3 -r1.3.194.1 src/sys/lib/libsa/rpcv2.h

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



CVS commit: [netbsd-10] src/sys/dev/wscons

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:24:59 UTC 2024

Modified Files:
src/sys/dev/wscons [netbsd-10]: wsmouse.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #892):

sys/dev/wscons/wsmouse.c: revision 1.73

wsmouse(4): Make wsmouse_input safe to call from MP-safe interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.72.4.1 src/sys/dev/wscons/wsmouse.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/wscons/wsmouse.c
diff -u src/sys/dev/wscons/wsmouse.c:1.72 src/sys/dev/wscons/wsmouse.c:1.72.4.1
--- src/sys/dev/wscons/wsmouse.c:1.72	Sun Jul 17 11:44:30 2022
+++ src/sys/dev/wscons/wsmouse.c	Fri Sep 20 11:24:59 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmouse.c,v 1.72 2022/07/17 11:44:30 riastradh Exp $ */
+/* $NetBSD: wsmouse.c,v 1.72.4.1 2024/09/20 11:24:59 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -104,7 +104,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.72 2022/07/17 11:44:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.72.4.1 2024/09/20 11:24:59 martin Exp $");
 
 #include "wsmouse.h"
 #include "wsdisplay.h"
@@ -372,17 +372,19 @@ wsmouse_input(device_t wsmousedev, u_int
 	/* one for each dimension (4) + a bit for each button */
 	struct wscons_event events[4 + sizeof(d) * 8];
 
+	KERNEL_LOCK(1, NULL);
+
 /*
  * Discard input if not open.
  */
 	evar = sc->sc_base.me_evp;
 	if (evar == NULL)
-		return;
+		goto out;
 
 #ifdef DIAGNOSTIC
 	if (evar->q == NULL) {
 		printf("wsmouse_input: evar->q=NULL\n");
-		return;
+		goto out;
 	}
 #endif
 
@@ -528,6 +530,8 @@ wsmouse_input(device_t wsmousedev, u_int
 			device_xname(sc->sc_base.me_dv), evar));
 #endif
 	}
+
+out:	KERNEL_UNLOCK_ONE(NULL);
 }
 
 void



CVS commit: [netbsd-10] src/sys/dev/wscons

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:24:59 UTC 2024

Modified Files:
src/sys/dev/wscons [netbsd-10]: wsmouse.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #892):

sys/dev/wscons/wsmouse.c: revision 1.73

wsmouse(4): Make wsmouse_input safe to call from MP-safe interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.72.4.1 src/sys/dev/wscons/wsmouse.c

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



CVS commit: [netbsd-10] src/sys/arch/x86/x86

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:08:25 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: fpu.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #890):

sys/arch/x86/x86/fpu.c: revision 1.87

x86/fpu: In kernel mode fpu traps, print the instruction pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.79.4.3 -r1.79.4.4 src/sys/arch/x86/x86/fpu.c

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



CVS commit: [netbsd-10] src/sys/arch/x86/x86

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:08:25 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: fpu.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #890):

sys/arch/x86/x86/fpu.c: revision 1.87

x86/fpu: In kernel mode fpu traps, print the instruction pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.79.4.3 -r1.79.4.4 src/sys/arch/x86/x86/fpu.c

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

Modified files:

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.79.4.3 src/sys/arch/x86/x86/fpu.c:1.79.4.4
--- src/sys/arch/x86/x86/fpu.c:1.79.4.3	Thu Jun 20 11:02:16 2024
+++ src/sys/arch/x86/x86/fpu.c	Fri Sep 20 11:08:25 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.79.4.3 2024/06/20 11:02:16 martin Exp $	*/
+/*	$NetBSD: fpu.c,v 1.79.4.4 2024/09/20 11:08:25 martin Exp $	*/
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,8 +96,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.79.4.3 2024/06/20 11:02:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.79.4.4 2024/09/20 11:08:25 martin Exp $");
 
+#include "opt_ddb.h"
 #include "opt_multiprocessor.h"
 
 #include 
@@ -121,6 +122,10 @@ __KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.79
 #include 
 #include 
 
+#ifdef DDB
+#include 
+#endif
+
 #ifdef XENPV
 #define clts() HYPERVISOR_fpu_taskswitch(0)
 #define stts() HYPERVISOR_fpu_taskswitch(1)
@@ -560,7 +565,16 @@ fputrap(struct trapframe *frame)
 	ksiginfo_t ksi;
 
 	if (__predict_false(!USERMODE(frame->tf_cs))) {
-		panic("fpu trap from kernel, trapframe %p\n", frame);
+		register_t ip = X86_TF_RIP(frame);
+		char where[128];
+
+#ifdef DDB
+		db_symstr(where, sizeof(where), (db_expr_t)ip, DB_STGY_PROC);
+#else
+		snprintf(where, sizeof(where), "%p", (void *)ip);
+#endif
+		panic("fpu trap from kernel at %s, trapframe %p\n", where,
+		frame);
 	}
 
 	KASSERT(curlwp->l_md.md_flags & MDL_FPU_IN_CPU);



CVS commit: [netbsd-10] src/sys/dev

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:02:23 UTC 2024

Modified Files:
src/sys/dev [netbsd-10]: dksubr.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #888):

sys/dev/dksubr.c: revision 1.114

Move the rnd_add_uint32 outside the lock and get rid of dk_done1() suggested
by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.113.16.1 src/sys/dev/dksubr.c

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



CVS commit: [netbsd-10] src/sys/dev

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:02:23 UTC 2024

Modified Files:
src/sys/dev [netbsd-10]: dksubr.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #888):

sys/dev/dksubr.c: revision 1.114

Move the rnd_add_uint32 outside the lock and get rid of dk_done1() suggested
by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.113.16.1 src/sys/dev/dksubr.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/dksubr.c
diff -u src/sys/dev/dksubr.c:1.113 src/sys/dev/dksubr.c:1.113.16.1
--- src/sys/dev/dksubr.c:1.113	Thu Apr 15 00:32:50 2021
+++ src/sys/dev/dksubr.c	Fri Sep 20 11:02:23 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.113 2021/04/15 00:32:50 rin Exp $ */
+/* $NetBSD: dksubr.c,v 1.113.16.1 2024/09/20 11:02:23 martin Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.113 2021/04/15 00:32:50 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.113.16.1 2024/09/20 11:02:23 martin Exp $");
 
 #include 
 #include 
@@ -77,7 +77,6 @@ static int dk_subr_modcmd(modcmd_t, void
 
 static void	dk_makedisklabel(struct dk_softc *);
 static int	dk_translate(struct dk_softc *, struct buf *);
-static void	dk_done1(struct dk_softc *, struct buf *, bool);
 
 void
 dk_init(struct dk_softc *dksc, device_t dev, int dtype)
@@ -442,7 +441,9 @@ dk_start(struct dk_softc *dksc, struct b
 			if (error != 0) {
 bp->b_error = error;
 bp->b_resid = bp->b_bcount;
-dk_done1(dksc, bp, false);
+mutex_exit(&dksc->sc_iolock);
+dk_done(dksc, bp);
+mutex_enter(&dksc->sc_iolock);
 			}
 
 			bp = bufq_get(dksc->sc_bufq);
@@ -454,8 +455,8 @@ done:
 	mutex_exit(&dksc->sc_iolock);
 }
 
-static void
-dk_done1(struct dk_softc *dksc, struct buf *bp, bool lock)
+void
+dk_done(struct dk_softc *dksc, struct buf *bp)
 {
 	struct disk *dk = &dksc->sc_dkdev;
 
@@ -467,25 +468,17 @@ dk_done1(struct dk_softc *dksc, struct b
 		printf("\n");
 	}
 
-	if (lock)
-		mutex_enter(&dksc->sc_iolock);
+	mutex_enter(&dksc->sc_iolock);
 	disk_unbusy(dk, bp->b_bcount - bp->b_resid, (bp->b_flags & B_READ));
+	mutex_exit(&dksc->sc_iolock);
 
 	if ((dksc->sc_flags & DKF_NO_RND) == 0)
 		rnd_add_uint32(&dksc->sc_rnd_source, bp->b_rawblkno);
-	if (lock)
-		mutex_exit(&dksc->sc_iolock);
 
 	biodone(bp);
 }
 
 void
-dk_done(struct dk_softc *dksc, struct buf *bp)
-{
-	dk_done1(dksc, bp, true);
-}
-
-void
 dk_drain(struct dk_softc *dksc)
 {
 	struct buf *bp;



CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:52:21 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: xhci.c xhcireg.h

Log Message:
Pull up following revision(s) (requested by rin in ticket #885):

sys/dev/usb/xhcireg.h: revision 1.23
sys/dev/usb/xhci.c: revision 1.178
sys/dev/usb/xhci.c: revision 1.179

Remove an unnecessary cast in a KASSERTMSG
- Fix clearing of EINT and other transient flags.

Patches from sc.dying in kern/56115:
- Set proper Max ESIT Payload value for interrupt/isoc endpoint context.
- Set proper Average TRB Length value.
- Not tested on superspeed/superspeedplus isochronous device.
- Add handling of some error paths for isochronous transfers.


To generate a diff of this commit:
cvs rdiff -u -r1.175.2.2 -r1.175.2.3 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.22 -r1.22.4.1 src/sys/dev/usb/xhcireg.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/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.175.2.2 src/sys/dev/usb/xhci.c:1.175.2.3
--- src/sys/dev/usb/xhci.c:1.175.2.2	Tue Aug  1 16:49:54 2023
+++ src/sys/dev/usb/xhci.c	Fri Sep 20 10:52:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.175.2.2 2023/08/01 16:49:54 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.175.2.3 2024/09/20 10:52:21 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.175.2.2 2023/08/01 16:49:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.175.2.3 2024/09/20 10:52:21 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -192,7 +192,7 @@ static void xhci_setup_ctx(struct usbd_p
 static void xhci_setup_route(struct usbd_pipe *, uint32_t *);
 static void xhci_setup_tthub(struct usbd_pipe *, uint32_t *);
 static void xhci_setup_maxburst(struct usbd_pipe *, uint32_t *);
-static uint32_t xhci_bival2ival(uint32_t, uint32_t);
+static uint32_t xhci_bival2ival(uint32_t, uint32_t, uint32_t);
 
 static void xhci_noop(struct usbd_pipe *);
 
@@ -1764,7 +1764,7 @@ xhci_intr1(struct xhci_softc * const sc)
 	 * next shared interrupt. Also, to avoid race, EINT must be cleared
 	 * before XHCI_IMAN_INTR_PEND is cleared.
 	 */
-	xhci_op_write_4(sc, XHCI_USBSTS, usbsts & XHCI_STS_RSVDP0);
+	xhci_op_write_4(sc, XHCI_USBSTS, usbsts & ~XHCI_STS_RSVDP0);
 
 #ifdef XHCI_DEBUG
 	usbsts = xhci_op_read_4(sc, XHCI_USBSTS);
@@ -2496,8 +2496,6 @@ xhci_event_transfer(struct xhci_softc * 
 			xfer->ux_frlengths[xx->xx_isoc_done] -=
 			XHCI_TRB_2_REM_GET(trb_2);
 			xfer->ux_actlen += xfer->ux_frlengths[xx->xx_isoc_done];
-			if (++xx->xx_isoc_done < xfer->ux_nframes)
-return;
 		} else
 		if ((trb_3 & XHCI_TRB_3_ED_BIT) == 0) {
 			if (xfer->ux_actlen == 0)
@@ -2529,6 +2527,22 @@ xhci_event_transfer(struct xhci_softc * 
 		break;
 	}
 
+	if (xfertype == UE_ISOCHRONOUS) {
+		switch (trbcode) {
+		case XHCI_TRB_ERROR_SHORT_PKT:
+		case XHCI_TRB_ERROR_SUCCESS:
+			break;
+		case XHCI_TRB_ERROR_MISSED_SERVICE:
+		case XHCI_TRB_ERROR_RING_UNDERRUN:
+		case XHCI_TRB_ERROR_RING_OVERRUN:
+		default:
+			xfer->ux_frlengths[xx->xx_isoc_done] = 0;
+			break;
+		}
+		if (++xx->xx_isoc_done < xfer->ux_nframes)
+			return;
+	}
+
 	if ((trb_3 & XHCI_TRB_3_ED_BIT) == 0 ||
 	(trb_0 & 0x3) == 0x0) {
 		/*
@@ -3551,9 +3565,7 @@ xhci_setup_ctx(struct usbd_pipe *pipe)
 	const u_int dci = xhci_ep_get_dci(ed);
 	const uint8_t xfertype = UE_GET_XFERTYPE(ed->bmAttributes);
 	uint32_t *cp;
-	uint16_t mps = UGETW(ed->wMaxPacketSize);
 	uint8_t speed = dev->ud_speed;
-	uint8_t ival = ed->bInterval;
 
 	XHCIHIST_FUNC();
 	XHCIHIST_CALLARGS("pipe %#jx: slot %ju dci %ju speed %ju",
@@ -3598,43 +3610,16 @@ xhci_setup_ctx(struct usbd_pipe *pipe)
 	if (xfertype != UE_ISOCHRONOUS)
 		cp[1] |= XHCI_EPCTX_1_CERR_SET(3);
 
-	if (xfertype == UE_CONTROL)
-		cp[4] = XHCI_EPCTX_4_AVG_TRB_LEN_SET(8); /* 6.2.3 */
-	else if (USB_IS_SS(speed))
-		cp[4] = XHCI_EPCTX_4_AVG_TRB_LEN_SET(mps);
-	else
-		cp[4] = XHCI_EPCTX_4_AVG_TRB_LEN_SET(UE_GET_SIZE(mps));
-
 	xhci_setup_maxburst(pipe, cp);
 
-	switch (xfertype) {
-	case UE_CONTROL:
-		break;
-	case UE_BULK:
-		/* XXX Set MaxPStreams, HID, and LSA if streams enabled */
-		break;
-	case UE_INTERRUPT:
-		if (pipe->up_interval != USBD_DEFAULT_INTERVAL)
-			ival = pipe->up_interval;
-
-		ival = xhci_bival2ival(ival, speed);
-		cp[0] |= XHCI_EPCTX_0_IVAL_SET(ival);
-		break;
-	case UE_ISOCHRONOUS:
-		if (pipe->up_interval != USBD_DEFAULT_INTERVAL)
-			ival = pipe->up_interval;
-
-		/* xHCI 6.2.3.6 Table 65, USB 2.0 9.6.6 */
-		if (speed == USB_SPEED_FULL)
-			ival += 3; /* 1ms -> 125us */
-		ival--;
-		cp[0] |= XHCI_EPCTX_0_IVAL_SET(ival);
-		break;
-	default:
-		break;
-	}
-	DPRINTFN(4, "setting ival %ju MaxBurst %#jx",
-	XHCI_EPCTX_0_IVAL_GET(cp[0]), XHCI_EPCTX_1_MAXB_GET(cp[1]), 0, 0);
+	DPRINTFN(4, "setting on dci %ju ival %ju mult %ju mps %#jx",
+	dci, XHCI_EPCTX_0_IVAL_GE

CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:52:21 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: xhci.c xhcireg.h

Log Message:
Pull up following revision(s) (requested by rin in ticket #885):

sys/dev/usb/xhcireg.h: revision 1.23
sys/dev/usb/xhci.c: revision 1.178
sys/dev/usb/xhci.c: revision 1.179

Remove an unnecessary cast in a KASSERTMSG
- Fix clearing of EINT and other transient flags.

Patches from sc.dying in kern/56115:
- Set proper Max ESIT Payload value for interrupt/isoc endpoint context.
- Set proper Average TRB Length value.
- Not tested on superspeed/superspeedplus isochronous device.
- Add handling of some error paths for isochronous transfers.


To generate a diff of this commit:
cvs rdiff -u -r1.175.2.2 -r1.175.2.3 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.22 -r1.22.4.1 src/sys/dev/usb/xhcireg.h

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



CVS commit: [netbsd-10] src/sys/kern

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:50:00 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: uipc_mbuf.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #882):

sys/kern/uipc_mbuf.c: revision 1.250
sys/kern/uipc_mbuf.c: revision 1.249

mbuf(9): Sprinkle KASSERTMSG.
No functional change intended.

0x%p -> %p in KASSERTMSGs


To generate a diff of this commit:
cvs rdiff -u -r1.247.2.1 -r1.247.2.2 src/sys/kern/uipc_mbuf.c

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



CVS commit: [netbsd-10] src/sys/kern

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:50:00 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: uipc_mbuf.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #882):

sys/kern/uipc_mbuf.c: revision 1.250
sys/kern/uipc_mbuf.c: revision 1.249

mbuf(9): Sprinkle KASSERTMSG.
No functional change intended.

0x%p -> %p in KASSERTMSGs


To generate a diff of this commit:
cvs rdiff -u -r1.247.2.1 -r1.247.2.2 src/sys/kern/uipc_mbuf.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/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.247.2.1 src/sys/kern/uipc_mbuf.c:1.247.2.2
--- src/sys/kern/uipc_mbuf.c:1.247.2.1	Mon Nov 27 20:00:17 2023
+++ src/sys/kern/uipc_mbuf.c	Fri Sep 20 10:50:00 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.247.2.1 2023/11/27 20:00:17 martin Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.247.2.2 2024/09/20 10:50:00 martin Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.247.2.1 2023/11/27 20:00:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.247.2.2 2024/09/20 10:50:00 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -539,7 +539,11 @@ m_get(int how, int type)
 	how == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : PR_NOWAIT);
 	if (m == NULL)
 		return NULL;
-	KASSERT(((vaddr_t)m->m_dat & PAGE_MASK) + MLEN <= PAGE_SIZE);
+	KASSERTMSG(((vaddr_t)m->m_dat & PAGE_MASK) + MLEN <= PAGE_SIZE,
+	"m=%p m->m_dat=%p"
+	" MLEN=%u PAGE_MASK=0x%x PAGE_SIZE=%u",
+	m, m->m_dat,
+	(unsigned)MLEN, (unsigned)PAGE_MASK, (unsigned)PAGE_SIZE);
 
 	mbstat_type_add(type, 1);
 
@@ -593,8 +597,12 @@ m_clget(struct mbuf *m, int how)
 	if (m->m_ext_storage.ext_buf == NULL)
 		return;
 
-	KASSERT(((vaddr_t)m->m_ext_storage.ext_buf & PAGE_MASK) + mclbytes
-	<= PAGE_SIZE);
+	KASSERTMSGvaddr_t)m->m_ext_storage.ext_buf & PAGE_MASK) + mclbytes
+		<= PAGE_SIZE),
+	"m=%p m->m_ext_storage.ext_buf=%p"
+	" mclbytes=%u PAGE_MASK=0x%x PAGE_SIZE=%u",
+	m, m->m_dat,
+	(unsigned)mclbytes, (unsigned)PAGE_MASK, (unsigned)PAGE_SIZE);
 
 	MCLINITREFERENCE(m);
 	m->m_data = m->m_ext.ext_buf;
@@ -691,6 +699,8 @@ m_copylen(int len, int copylen)
 static struct mbuf *
 m_copy_internal(struct mbuf *m, int off0, int len, int wait, bool deep)
 {
+	struct mbuf *m0 __diagused = m;
+	int len0 __diagused = len;
 	struct mbuf *n, **np;
 	int off = off0;
 	struct mbuf *top;
@@ -761,7 +771,9 @@ m_copy_internal(struct mbuf *m, int off0
 			len -= n->m_len;
 		off += n->m_len;
 
-		KASSERT(off <= m->m_len);
+		KASSERTMSG(off <= m->m_len,
+		"m=%p m->m_len=%d off=%d len=%d m0=%p off0=%d len0=%d",
+		m, m->m_len, off, len, m0, off0, len0);
 
 		if (off == m->m_len) {
 			m = m->m_next;
@@ -1117,7 +1129,8 @@ m_pulldown(struct mbuf *m, int off, int 
 			m_freem(m);
 			return NULL;	/* ENOBUFS */
 		}
-		KASSERT(o->m_len >= len);
+		KASSERTMSG(o->m_len >= len, "o=%p o->m_len=%d len=%d",
+		o, o->m_len, len);
 		for (mlast = o; mlast->m_next != NULL; mlast = mlast->m_next)
 			;
 		n->m_len = off;
@@ -1700,7 +1713,9 @@ m_defrag(struct mbuf *m, int how)
 			m0 = m_get(how, MT_DATA);
 			if (m0 == NULL)
 return NULL;
-			KASSERT(m->m_len <= MHLEN);
+			KASSERTMSG(m->m_len <= MHLEN,
+			"m=%p m->m_len=%d MHLEN=%u",
+			m, m->m_len, (unsigned)MHLEN);
 			m_copydata(m, 0, m->m_len, mtod(m0, void *));
 
 			MCLGET(m, how);
@@ -1711,7 +1726,10 @@ m_defrag(struct mbuf *m, int how)
 			memcpy(m->m_data, mtod(m0, void *), m->m_len);
 			m_free(m0);
 		}
-		KASSERT(M_TRAILINGSPACE(m) >= (m->m_pkthdr.len - m->m_len));
+		KASSERTMSG(M_TRAILINGSPACE(m) >= (m->m_pkthdr.len - m->m_len),
+		"m=%p M_TRAILINGSPACE(m)=%zd m->m_pkthdr.len=%d"
+		" m->m_len=%d",
+		m, M_TRAILINGSPACE(m), m->m_pkthdr.len, m->m_len);
 		m_copydata(m->m_next, 0, m->m_pkthdr.len - m->m_len,
 			mtod(m, char *) + m->m_len);
 		m->m_len = m->m_pkthdr.len;
@@ -1814,11 +1832,12 @@ m_align(struct mbuf *m, int len)
 	int buflen, adjust;
 
 	KASSERT(len != M_COPYALL);
-	KASSERT(M_LEADINGSPACE(m) == 0);
+	KASSERTMSG(M_LEADINGSPACE(m) == 0, "m=%p M_LEADINGSPACE(m)=%zd",
+	m, M_LEADINGSPACE(m));
 
 	buflen = M_BUFSIZE(m);
 
-	KASSERT(len <= buflen);
+	KASSERTMSG(len <= buflen, "m=%p len=%d buflen=%d", m, len, buflen);
 	adjust = buflen - len;
 	m->m_data += adjust &~ (sizeof(long)-1);
 }



CVS commit: [netbsd-10] src/sys/arch/x86/x86

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:47:52 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: bus_dma.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #881):

sys/arch/x86/x86/bus_dma.c: revision 1.90

x86/bus_dma.c: Sprinkle KASSERTMSG.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.89.4.1 src/sys/arch/x86/x86/bus_dma.c

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

Modified files:

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



CVS commit: [netbsd-10] src/sys/arch/x86/x86

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:47:52 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: bus_dma.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #881):

sys/arch/x86/x86/bus_dma.c: revision 1.90

x86/bus_dma.c: Sprinkle KASSERTMSG.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.89.4.1 src/sys/arch/x86/x86/bus_dma.c

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



CVS commit: [netbsd-10] src/sys/nfs

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:29:41 UTC 2024

Modified Files:
src/sys/nfs [netbsd-10]: nfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #879):

sys/nfs/nfs_vfsops.c: revision 1.244

Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.243.10.1 src/sys/nfs/nfs_vfsops.c

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

Modified files:

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.243 src/sys/nfs/nfs_vfsops.c:1.243.10.1
--- src/sys/nfs/nfs_vfsops.c:1.243	Sun Jun 13 10:25:11 2021
+++ src/sys/nfs/nfs_vfsops.c	Fri Sep 20 10:29:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.243 2021/06/13 10:25:11 mlelstv Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.243.10.1 2024/09/20 10:29:41 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243 2021/06/13 10:25:11 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243.10.1 2024/09/20 10:29:41 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -1135,6 +1135,7 @@ nfs_start(struct mount *mp, int flags)
 void
 nfs_vfs_init(void)
 {
+	unsigned scale;
 
 	/* Initialize NFS server / client shared data. */
 	nfs_init();
@@ -1145,7 +1146,8 @@ nfs_vfs_init(void)
 	/* Initialize the iod structures */
 	nfs_iodinit();
 
-	nfs_commitsize = uvmexp.npages << (PAGE_SHIFT - 4);
+	scale = PAGE_SHIFT - 4;
+	nfs_commitsize = uimin(uvmexp.npages, INT_MAX >> scale) << scale;
 }
 
 void



CVS commit: [netbsd-10] src/sys/nfs

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:29:41 UTC 2024

Modified Files:
src/sys/nfs [netbsd-10]: nfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #879):

sys/nfs/nfs_vfsops.c: revision 1.244

Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.243.10.1 src/sys/nfs/nfs_vfsops.c

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



CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:20:56 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: ucom.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #877):

sys/dev/usb/ucom.c: revision 1.138

ucom(4): Simplify logic fixing PR kern/57259.
cv_timedwait only ever returns 0 or EWOULDBLOCK, so this would always
return ERESTART anyway.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.134.2.2 -r1.134.2.3 src/sys/dev/usb/ucom.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.134.2.2 src/sys/dev/usb/ucom.c:1.134.2.3
--- src/sys/dev/usb/ucom.c:1.134.2.2	Tue Mar  7 19:52:01 2023
+++ src/sys/dev/usb/ucom.c	Fri Sep 20 10:20:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.134.2.2 2023/03/07 19:52:01 martin Exp $	*/
+/*	$NetBSD: ucom.c,v 1.134.2.3 2024/09/20 10:20:56 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.134.2.2 2023/03/07 19:52:01 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.134.2.3 2024/09/20 10:20:56 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -552,14 +552,10 @@ ucomopen(dev_t dev, int flag, int mode, 
 			ms = MIN(INT_MAX - 1000, delta.tv_sec*1000);
 			ms += howmany(delta.tv_usec, 1000);
 			ticks = MAX(1, MIN(INT_MAX, mstohz(ms)));
-			error = cv_timedwait(&sc->sc_statecv, &sc->sc_lock,
+			(void)cv_timedwait(&sc->sc_statecv, &sc->sc_lock,
 			ticks);
 			mutex_exit(&sc->sc_lock);
-			/* The successful passage of time is not an error. */
-			if (error == EWOULDBLOCK) {
-error = 0;
-			}
-			return error ? error : ERESTART;
+			return ERESTART;
 		}
 		timerclear(&sc->sc_hup_time);
 	}



CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:20:56 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: ucom.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #877):

sys/dev/usb/ucom.c: revision 1.138

ucom(4): Simplify logic fixing PR kern/57259.
cv_timedwait only ever returns 0 or EWOULDBLOCK, so this would always
return ERESTART anyway.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.134.2.2 -r1.134.2.3 src/sys/dev/usb/ucom.c

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



CVS commit: [netbsd-10] src/sys/arch/amd64/amd64

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:17:22 UTC 2024

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-10]: amd64_trap.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #876):

sys/arch/amd64/amd64/amd64_trap.S: revision 1.55

amd64_trap.S: Annotate trap vectors with their mnemonics.

Derived from Intel and AMD manuals.
Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3
(3A, 3B, 3C, & 3D: System Programming Guide, Order Number:
325384-077US, April 2022.
https://cdrdv2.intel.com/v1/dl/getContent/671447

AMD64 Technology: AMD64 Architecture Programmers' Manual, Volume 2:
System Programming, Publication No. 24953, Revision 3.40, January 2023.
https://www.amd.com/system/files/TechDocs/24593.pdf

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.54.4.1 src/sys/arch/amd64/amd64/amd64_trap.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/amd64/amd64/amd64_trap.S
diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.54 src/sys/arch/amd64/amd64/amd64_trap.S:1.54.4.1
--- src/sys/arch/amd64/amd64/amd64_trap.S:1.54	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/amd64/amd64/amd64_trap.S	Fri Sep 20 10:17:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: amd64_trap.S,v 1.54 2022/09/07 00:40:18 knakahara Exp $	*/
+/*	$NetBSD: amd64_trap.S,v 1.54.4.1 2024/09/20 10:17:22 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc.
@@ -159,7 +159,7 @@
 
 	TEXT_USER_BEGIN
 
-IDTVEC(trap00)
+IDTVEC(trap00)		/* #DE - Divide-by-zero error */
 	ZTRAP(T_DIVIDE)
 IDTVEC_END(trap00)
 
@@ -178,7 +178,7 @@ IDTVEC_END(trap00)
  * not a problem, because in this particular case, the frame is known not
  * to contain secrets.
  */
-IDTVEC(trap01)
+IDTVEC(trap01)		/* #DB - Debug */
 #ifndef XENPV
 	subq	$(TF_REGSIZE+16),%rsp
 
@@ -247,7 +247,7 @@ IDTVEC_END(trap01)
  * We need to be careful about %gs too, because it is possible that we were
  * running in kernel mode with a userland %gs.
  */
-IDTVEC(trap02)
+IDTVEC(trap02)		/* NMI - Non-maskable interrupt */
 #if defined(XENPV)
 	ZTRAP(T_NMI)
 #else /* XENPV */
@@ -302,7 +302,7 @@ IDTVEC(trap02)
 #endif /* XENPV */
 IDTVEC_END(trap02)
 
-IDTVEC(trap03)
+IDTVEC(trap03)		/* #BP - Breakpoint */
 #ifndef KDTRACE_HOOKS
 	ZTRAP(T_BPTFLT)
 #else
@@ -331,19 +331,19 @@ IDTVEC(trap03)
 #endif
 IDTVEC_END(trap03)
 
-IDTVEC(trap04)
+IDTVEC(trap04)		/* #OF - Overflow */
 	ZTRAP(T_OFLOW)
 IDTVEC_END(trap04)
 
-IDTVEC(trap05)
+IDTVEC(trap05)		/* #BR - BOUND range exceeded */
 	ZTRAP(T_BOUND)
 IDTVEC_END(trap05)
 
-IDTVEC(trap06)
+IDTVEC(trap06)		/* #UD - Invalid opcode */
 	ZTRAP(T_PRIVINFLT)
 IDTVEC_END(trap06)
 
-IDTVEC(trap07)
+IDTVEC(trap07)		/* #NM - Device not available (x87) */
 	ZTRAP_NJ(T_DNA)
 	INTRENTRY
 #ifdef DIAGNOSTIC
@@ -358,7 +358,7 @@ IDTVEC_END(trap07)
  * Double faults execute on a particular stack, and we must not jump out
  * of it. So don't enable interrupts.
  */
-IDTVEC(trap08)
+IDTVEC(trap08)		/* #DF - Double fault */
 #if defined(XENPV)
 	TRAP(T_DOUBLEFLT)
 #else /* XENPV */
@@ -399,11 +399,11 @@ IDTVEC(trap08)
 #endif /* XENPV */
 IDTVEC_END(trap08)
 
-IDTVEC(trap09)
+IDTVEC(trap09)		/* Coprocessor segment overrun (legacy x87) */
 	ZTRAP(T_FPOPFLT)
 IDTVEC_END(trap09)
 
-IDTVEC(trap10)
+IDTVEC(trap10)		/* #TS - Invalid TSS */
 	TRAP(T_TSSFLT)
 IDTVEC_END(trap10)
 
@@ -416,26 +416,26 @@ IDTVEC_END(trap10)
 #define kernuser_reenter alltraps
 #endif /* XENPV */
 
-IDTVEC(trap11)		/* #NP() Segment not present */
+IDTVEC(trap11)		/* #NP - Segment not present */
 	TRAP_NJ(T_SEGNPFLT)
 	jmp	kernuser_reenter
 IDTVEC_END(trap11)
 
-IDTVEC(trap12)		/* #SS() Stack exception */
+IDTVEC(trap12)		/* #SS - Stack fault */
 	TRAP_NJ(T_STKFLT)
 	jmp	kernuser_reenter
 IDTVEC_END(trap12)
 
-IDTVEC(trap13)		/* #GP() General protection */
+IDTVEC(trap13)		/* #GP - General protection */
 	TRAP_NJ(T_PROTFLT)
 	jmp	kernuser_reenter
 IDTVEC_END(trap13)
 
-IDTVEC(trap14)
+IDTVEC(trap14)		/* #PF - Page fault */
 	TRAP(T_PAGEFLT)
 IDTVEC_END(trap14)
 
-IDTVEC(trap15)
+IDTVEC(trap15)		/* XXX ??? */
 	ZTRAP_NJ(T_ASTFLT)
 	INTRENTRY
 #ifdef DIAGNOSTIC
@@ -444,7 +444,7 @@ IDTVEC(trap15)
 	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap15)
 
-IDTVEC(trap16)
+IDTVEC(trap16)		/* #MF - x87 floating-point exception */
 	ZTRAP_NJ(T_ARITHTRAP)
 .Ldo_fputrap:
 	INTRENTRY
@@ -464,30 +464,30 @@ IDTVEC(trap16)
 	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap16)
 
-IDTVEC(trap17)
+IDTVEC(trap17)		/* #AC - Alignment check */
 	TRAP(T_ALIGNFLT)
 IDTVEC_END(trap17)
 
-IDTVEC(trap18)
+IDTVEC(trap18)		/* #MC - Machine check */
 	ZTRAP(T_MCA)
 IDTVEC_END(trap18)
 
-IDTVEC(trap19)
+IDTVEC(trap19)		/* #XM - SIMD floating-point exception */
 	ZTRAP_NJ(T_XMM)
 	jmp	.Ldo_fputrap
 IDTVEC_END(trap19)
 
-IDTVEC(trap20)
-IDTVEC(trap21)
+IDTVEC(trap20)		/* #VE - Virtualization (Intel) */
+IDTVEC(trap21)		/*

CVS commit: [netbsd-10] src/sys/arch/amd64/amd64

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:17:22 UTC 2024

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-10]: amd64_trap.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #876):

sys/arch/amd64/amd64/amd64_trap.S: revision 1.55

amd64_trap.S: Annotate trap vectors with their mnemonics.

Derived from Intel and AMD manuals.
Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3
(3A, 3B, 3C, & 3D: System Programming Guide, Order Number:
325384-077US, April 2022.
https://cdrdv2.intel.com/v1/dl/getContent/671447

AMD64 Technology: AMD64 Architecture Programmers' Manual, Volume 2:
System Programming, Publication No. 24953, Revision 3.40, January 2023.
https://www.amd.com/system/files/TechDocs/24593.pdf

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.54.4.1 src/sys/arch/amd64/amd64/amd64_trap.S

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



CVS commit: [netbsd-10] src/sys/arch/i386/i386

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:00:14 UTC 2024

Modified Files:
src/sys/arch/i386/i386 [netbsd-10]: bioscall.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #875):

sys/arch/i386/i386/bioscall.S: revision 1.11

i386/bioscall: Disable preemption while we load the kernel pmap.

Fixes crash on boot in new KASSERT(kpreempt_disabled()) in
cpu_load_pmap.

We could do KASSERT(kpreempt_disabled() || cold), but I don't know if
bioscall is ever reachable after warm boot; this way is safer.

XXX Would be nice if bioscall were a C function, not asm -- I don't
see any reason why we need it to be asm?


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.30.1 src/sys/arch/i386/i386/bioscall.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/i386/i386/bioscall.S
diff -u src/sys/arch/i386/i386/bioscall.S:1.10 src/sys/arch/i386/i386/bioscall.S:1.10.30.1
--- src/sys/arch/i386/i386/bioscall.S:1.10	Sat Jul 14 14:29:40 2018
+++ src/sys/arch/i386/i386/bioscall.S	Fri Sep 20 10:00:14 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bioscall.S,v 1.10 2018/07/14 14:29:40 maxv Exp $ */
+/*	$NetBSD: bioscall.S,v 1.10.30.1 2024/09/20 10:00:14 martin Exp $ */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bioscall.S,v 1.10 2018/07/14 14:29:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bioscall.S,v 1.10.30.1 2024/09/20 10:00:14 martin Exp $");
 
 #include 
 
@@ -67,6 +67,8 @@ ENTRY(bioscall)
 	pushl	%ebp
 	movl	%esp,%ebp		/* set up frame ptr */
 
+	call	_C_LABEL(kpreempt_disable)
+
 	/* install lwp0 pmap */
 	movl	_C_LABEL(kernel_pmap_ptr),%eax
 	pushl	%eax
@@ -85,5 +87,7 @@ ENTRY(bioscall)
 	call	_C_LABEL(cpu_load_pmap)
 	addl	$4,%esp
 
+	call	_C_LABEL(kpreempt_enable)
+
 	leave
 	ret



CVS commit: [netbsd-10] src/sys/arch/i386/i386

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:00:14 UTC 2024

Modified Files:
src/sys/arch/i386/i386 [netbsd-10]: bioscall.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #875):

sys/arch/i386/i386/bioscall.S: revision 1.11

i386/bioscall: Disable preemption while we load the kernel pmap.

Fixes crash on boot in new KASSERT(kpreempt_disabled()) in
cpu_load_pmap.

We could do KASSERT(kpreempt_disabled() || cold), but I don't know if
bioscall is ever reachable after warm boot; this way is safer.

XXX Would be nice if bioscall were a C function, not asm -- I don't
see any reason why we need it to be asm?


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.30.1 src/sys/arch/i386/i386/bioscall.S

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



  1   2   3   4   5   6   7   8   9   10   >