CVS commit: src/share/man/man9

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:50:41 UTC 2022

Modified Files:
src/share/man/man9: usbnet.9

Log Message:
usbnet(9): Clarify how mii functions are used.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/share/man/man9/usbnet.9

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

Modified files:

Index: src/share/man/man9/usbnet.9
diff -u src/share/man/man9/usbnet.9:1.19 src/share/man/man9/usbnet.9:1.20
--- src/share/man/man9/usbnet.9:1.19	Sat Aug 20 14:08:59 2022
+++ src/share/man/man9/usbnet.9	Sat Aug 20 23:50:41 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: usbnet.9,v 1.19 2022/08/20 14:08:59 riastradh Exp $
+.\"	$NetBSD: usbnet.9,v 1.20 2022/08/20 23:50:41 riastradh Exp $
 .\"
 .\" Copyright (c) 2019 Matthew R. Green
 .\" All rights reserved.
@@ -403,29 +403,29 @@ when bringing the interface up.
 .It Ft int Fn (*uno_read_reg) "struct usbnet *un" "int phy" "int reg" "uint16_t *val"
 Read MII register.
 Required with MII.
-Serialized with other MII functions, and with
+Serialized with other MII functions, and only called after
 .Dq uno_init
-and
+and before
 .Dq uno_stop .
 .It Ft int Fn (*uno_write_reg) "struct usbnet *un" "int phy" "int reg" "uint16_t val"
 Write MII register.
 Required with MII.
-Serialized with other MII functions, and with
+Serialized with other MII functions, and only called after
 .Dq uno_init
-and
+and before
 .Dq uno_stop .
 .It Ft usbd_status Fn (*uno_statchg) "struct ifnet *ifp"
 Handle MII status change.
 Required with MII.
-Serialized with other MII functions, and with
+Serialized with other MII functions, and only called after
 .Dq uno_init
-and
+and before
 .Dq uno_stop .
 .It Ft unsigned Fn (*uno_tx_prepare) "struct usbnet *un" "struct mbuf *m" "struct usbnet_chain *c"
 Prepare an mbuf for transmit.
 Required.
 Called sequentially between, and not during,
-.Dq uno_init .
+.Dq uno_init
 and
 .Dq uno_stop .
 .It Ft void Fn (*uno_rx_loop) "struct usbnet *un" "struct usbnet_chain *c" "uint32_t total_len"



CVS commit: src/share/man/man9

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:50:41 UTC 2022

Modified Files:
src/share/man/man9: usbnet.9

Log Message:
usbnet(9): Clarify how mii functions are used.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/share/man/man9/usbnet.9

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



CVS commit: src/sys/arch

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:49:48 UTC 2022

Modified Files:
src/sys/arch/amd64/include: pmap_private.h
src/sys/arch/i386/include: pmap_private.h

Log Message:
{amd64,i386}/pmap_private.h: Fix minor whitespace issues.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amd64/include/pmap_private.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/include/pmap_private.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/amd64/include/pmap_private.h
diff -u src/sys/arch/amd64/include/pmap_private.h:1.2 src/sys/arch/amd64/include/pmap_private.h:1.3
--- src/sys/arch/amd64/include/pmap_private.h:1.2	Sat Aug 20 23:49:31 2022
+++ src/sys/arch/amd64/include/pmap_private.h	Sat Aug 20 23:49:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_private.h,v 1.2 2022/08/20 23:49:31 riastradh Exp $	*/
+/*	$NetBSD: pmap_private.h,v 1.3 2022/08/20 23:49:48 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -202,6 +202,7 @@ extern bool svs_pcid;
 #undef	_MACHINE_PMAP_PRIVATE_H_X86
 
 #ifndef XENPV
+
 #define pmap_pa2pte(a)			(a)
 #define pmap_pte2pa(a)			((a) & PTE_FRAME)
 #define pmap_pte_set(p, n)		do { *(p) = (n); } while (0)
@@ -213,7 +214,9 @@ extern bool svs_pcid;
 #define pmap_pte_clearbits(p, b)	\
 atomic_and_ulong((volatile unsigned long *)p, ~(b))
 #define pmap_pte_flush()		/* nothing */
+
 #else
+
 extern kmutex_t pte_lock;
 
 static __inline pt_entry_t
@@ -247,7 +250,6 @@ pmap_pte_cas(volatile pt_entry_t *ptep, 
 		xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(ptep)), n);
 		xpq_flush_queue();
 	}
-
 	mutex_exit(_lock);
 	return opte;
 }
@@ -291,6 +293,7 @@ pmap_pte_flush(void)
 	xpq_flush_queue();
 	splx(s);
 }
+
 #endif
 
 #ifdef __HAVE_DIRECT_MAP

Index: src/sys/arch/i386/include/pmap_private.h
diff -u src/sys/arch/i386/include/pmap_private.h:1.2 src/sys/arch/i386/include/pmap_private.h:1.3
--- src/sys/arch/i386/include/pmap_private.h:1.2	Sat Aug 20 23:49:31 2022
+++ src/sys/arch/i386/include/pmap_private.h	Sat Aug 20 23:49:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_private.h,v 1.2 2022/08/20 23:49:31 riastradh Exp $	*/
+/*	$NetBSD: pmap_private.h,v 1.3 2022/08/20 23:49:48 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -260,6 +260,7 @@
 #undef	_MACHINE_PMAP_PRIVATE_H_X86
 
 #ifndef XENPV
+
 #define pmap_pa2pte(a)			(a)
 #define pmap_pte2pa(a)			((a) & PTE_FRAME)
 #define pmap_pte_set(p, n)		do { *(p) = (n); } while (0)
@@ -284,6 +285,7 @@
 #endif /* PAE */
 
 #else /* XENPV */
+
 extern kmutex_t pte_lock;
 
 static __inline pt_entry_t
@@ -297,6 +299,7 @@ pmap_pte2pa(pt_entry_t pte)
 {
 	return xpmap_mtop_masked(pte & PTE_FRAME);
 }
+
 static __inline void
 pmap_pte_set(pt_entry_t *pte, pt_entry_t npte)
 {
@@ -327,8 +330,7 @@ pmap_pte_testset(volatile pt_entry_t *pt
 
 	mutex_enter(_lock);
 	opte = *pte;
-	xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(pte)),
-	npte);
+	xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(pte)), npte);
 	xpq_flush_queue();
 	mutex_exit(_lock);
 	return opte;
@@ -345,7 +347,7 @@ pmap_pte_setbits(volatile pt_entry_t *pt
 
 static __inline void
 pmap_pte_clearbits(volatile pt_entry_t *pte, pt_entry_t bits)
-{	
+{
 	mutex_enter(_lock);
 	xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(pte)),
 	(*pte) & ~bits);



CVS commit: src/sys

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:49:32 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: netbsd32_machdep.c
src/sys/arch/amd64/include: pmap.h pmap_private.h
src/sys/arch/i386/i386: compat_16_machdep.c
src/sys/arch/i386/include: pmap.h pmap_private.h
src/sys/arch/x86/include: pmap.h pmap_private.h
src/sys/arch/x86/x86: pmap.c sys_machdep.c
src/sys/external/bsd/drm2/include/linux: shmem_fs.h

Log Message:
x86: Move definition of struct pmap to pmap_private.h.

This makes pmap_resident_count and pmap_wired_count out-of-line
functions instead of inline.  No functional change intended
otherwise.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/arch/amd64/amd64/netbsd32_machdep.c
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amd64/include/pmap_private.h
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/i386/i386/compat_16_machdep.c
cvs rdiff -u -r1.128 -r1.129 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/include/pmap_private.h
cvs rdiff -u -r1.133 -r1.134 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/include/pmap_private.h
cvs rdiff -u -r1.419 -r1.420 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/x86/x86/sys_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/shmem_fs.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/amd64/amd64/netbsd32_machdep.c
diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.140 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.141
--- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.140	Sat Nov  6 20:42:56 2021
+++ src/sys/arch/amd64/amd64/netbsd32_machdep.c	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.140 2021/11/06 20:42:56 thorpej Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.141 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.140 2021/11/06 20:42:56 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.141 2022/08/20 23:49:31 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -75,6 +75,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mac
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 

Index: src/sys/arch/amd64/include/pmap.h
diff -u src/sys/arch/amd64/include/pmap.h:1.68 src/sys/arch/amd64/include/pmap.h:1.69
--- src/sys/arch/amd64/include/pmap.h:1.68	Sat Aug 20 23:48:50 2022
+++ src/sys/arch/amd64/include/pmap.h	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,3 @@
-/*	$NetBSD: pmap.h,v 1.68 2022/08/20 23:48:50 riastradh Exp $	*/
+/*	$NetBSD: pmap.h,v 1.69 2022/08/20 23:49:31 riastradh Exp $	*/
 
-#define PTP_LEVELS	4
 #include 

Index: src/sys/arch/amd64/include/pmap_private.h
diff -u src/sys/arch/amd64/include/pmap_private.h:1.1 src/sys/arch/amd64/include/pmap_private.h:1.2
--- src/sys/arch/amd64/include/pmap_private.h:1.1	Sat Aug 20 23:48:50 2022
+++ src/sys/arch/amd64/include/pmap_private.h	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_private.h,v 1.1 2022/08/20 23:48:50 riastradh Exp $	*/
+/*	$NetBSD: pmap_private.h,v 1.2 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -175,6 +175,8 @@ extern pt_entry_t *pte_base;
 #define NBPD_INITIALIZER	{ NBPD_L1, NBPD_L2, NBPD_L3, NBPD_L4 }
 #define PDES_INITIALIZER	{ L2_BASE, L3_BASE, L4_BASE }
 
+#define PTP_LEVELS	4
+
 /*
  * PTE_AVL usage: we make use of the ignored bits of the PTE
  */

Index: src/sys/arch/i386/i386/compat_16_machdep.c
diff -u src/sys/arch/i386/i386/compat_16_machdep.c:1.33 src/sys/arch/i386/i386/compat_16_machdep.c:1.34
--- src/sys/arch/i386/i386/compat_16_machdep.c:1.33	Wed Oct 27 04:14:59 2021
+++ src/sys/arch/i386/i386/compat_16_machdep.c	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_16_machdep.c,v 1.33 2021/10/27 04:14:59 thorpej Exp $	*/
+/*	$NetBSD: compat_16_machdep.c,v 1.34 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.33 2021/10/27 04:14:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.34 2022/08/20 23:49:31 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: compat_16_ma
 #include 
 
 #include 
+#include 
 #include 
 #include 
 

Index: src/sys/arch/i386/include/pmap.h
diff -u src/sys/arch/i386/include/pmap.h:1.128 src/sys/arch/i386/include/pmap.h:1.129
--- src/sys/arch/i386/include/pmap.h:1.128	Sat Aug 20 23:48:50 2022
+++ src/sys/arch/i386/include/pmap.h	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,3 @@
-/*	

CVS commit: src/sys/arch

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:49:48 UTC 2022

Modified Files:
src/sys/arch/amd64/include: pmap_private.h
src/sys/arch/i386/include: pmap_private.h

Log Message:
{amd64,i386}/pmap_private.h: Fix minor whitespace issues.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amd64/include/pmap_private.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/include/pmap_private.h

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



CVS commit: src/sys

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:49:32 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: netbsd32_machdep.c
src/sys/arch/amd64/include: pmap.h pmap_private.h
src/sys/arch/i386/i386: compat_16_machdep.c
src/sys/arch/i386/include: pmap.h pmap_private.h
src/sys/arch/x86/include: pmap.h pmap_private.h
src/sys/arch/x86/x86: pmap.c sys_machdep.c
src/sys/external/bsd/drm2/include/linux: shmem_fs.h

Log Message:
x86: Move definition of struct pmap to pmap_private.h.

This makes pmap_resident_count and pmap_wired_count out-of-line
functions instead of inline.  No functional change intended
otherwise.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/arch/amd64/amd64/netbsd32_machdep.c
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amd64/include/pmap_private.h
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/i386/i386/compat_16_machdep.c
cvs rdiff -u -r1.128 -r1.129 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/include/pmap_private.h
cvs rdiff -u -r1.133 -r1.134 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/include/pmap_private.h
cvs rdiff -u -r1.419 -r1.420 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/x86/x86/sys_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/shmem_fs.h

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



CVS commit: src/sys

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:48:51 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: gdt.c genassym.cf machdep.c
src/sys/arch/amd64/include: pmap.h vmparam.h
src/sys/arch/i386/i386: dumpsys.c gdt.c genassym.cf machdep.c trap.c
src/sys/arch/i386/include: pmap.h vmparam.h
src/sys/arch/x86/acpi: acpi_machdep.c
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: bus_dma.c cpu.c db_memrw.c idt.c lapic.c patch.c
pmap.c svs.c x86_machdep.c x86_tlb.c
src/sys/arch/xen/x86: cpu.c hypervisor_machdep.c x86_xpmap.c
xen_bus_dma.c xen_pmap.c xenfunc.c
src/sys/arch/xen/xen: xen_machdep.c
src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c
Added Files:
src/sys/arch/amd64/include: pmap_private.h
src/sys/arch/i386/include: pmap_private.h
src/sys/arch/x86/include: pmap_private.h

Log Message:
x86: Split most of pmap.h into pmap_private.h or vmparam.h.

This way pmap.h only contains the MD definition of the MI pmap(9)
API, which loads of things in the kernel rely on, so changing x86
pmap internals no longer requires recompiling the entire kernel every
time.

Callers needing these internals must now use machine/pmap_private.h.
Note: This is not x86/pmap_private.h because it contains three parts:

1. CPU-specific (different for i386/amd64) definitions used by...

2. common definitions, including Xenisms like xpmap_ptetomach,
   further used by...

3. more CPU-specific inlines for pmap_pte_* operations

So {amd64,i386}/pmap_private.h defines 1, includes x86/pmap_private.h
for 2, and then defines 3.  Maybe we should split that out into a new
pmap_pte.h to reduce this trouble.

No functional change intended, other than that some .c files must
include machine/pmap_private.h when previously uvm/uvm_pmap.h
polluted the namespace with pmap internals.

Note: This migrates part of i386/pmap.h into i386/vmparam.h --
specifically the parts that are needed for several constants defined
in vmparam.h:

VM_MAXUSER_ADDRESS
VM_MAX_ADDRESS
VM_MAX_KERNEL_ADDRESS
VM_MIN_KERNEL_ADDRESS

Since i386 needs PDP_SIZE in vmparam.h, I added it there on amd64
too, just to keep things parallel.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/amd64/amd64/gdt.c
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/amd64/amd64/genassym.cf
cvs rdiff -u -r1.362 -r1.363 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/amd64/include/pmap_private.h
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/amd64/include/vmparam.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/i386/dumpsys.c
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/i386/i386/gdt.c
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.836 -r1.837 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.307 -r1.308 src/sys/arch/i386/i386/trap.c
cvs rdiff -u -r1.127 -r1.128 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/include/pmap_private.h
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/i386/include/vmparam.h
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/x86/acpi/acpi_machdep.c
cvs rdiff -u -r1.132 -r1.133 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/include/pmap_private.h
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/x86/x86/bus_dma.c
cvs rdiff -u -r1.204 -r1.205 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/x86/db_memrw.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/x86/idt.c
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/x86/x86/lapic.c
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/x86/x86/patch.c
cvs rdiff -u -r1.418 -r1.419 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x86/x86/svs.c
cvs rdiff -u -r1.151 -r1.152 src/sys/arch/x86/x86/x86_machdep.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x86/x86/x86_tlb.c
cvs rdiff -u -r1.141 -r1.142 src/sys/arch/xen/x86/cpu.c
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/xen/x86/x86_xpmap.c
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/xen/x86/xen_bus_dma.c
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/xen/x86/xen_pmap.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/xen/x86/xenfunc.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/xen/xen/xen_machdep.c
cvs rdiff -u -r1.83 -r1.84 src/sys/dev/nvmm/x86/nvmm_x86_svm.c \
src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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



CVS commit: src/sys

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:48:51 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: gdt.c genassym.cf machdep.c
src/sys/arch/amd64/include: pmap.h vmparam.h
src/sys/arch/i386/i386: dumpsys.c gdt.c genassym.cf machdep.c trap.c
src/sys/arch/i386/include: pmap.h vmparam.h
src/sys/arch/x86/acpi: acpi_machdep.c
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: bus_dma.c cpu.c db_memrw.c idt.c lapic.c patch.c
pmap.c svs.c x86_machdep.c x86_tlb.c
src/sys/arch/xen/x86: cpu.c hypervisor_machdep.c x86_xpmap.c
xen_bus_dma.c xen_pmap.c xenfunc.c
src/sys/arch/xen/xen: xen_machdep.c
src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c
Added Files:
src/sys/arch/amd64/include: pmap_private.h
src/sys/arch/i386/include: pmap_private.h
src/sys/arch/x86/include: pmap_private.h

Log Message:
x86: Split most of pmap.h into pmap_private.h or vmparam.h.

This way pmap.h only contains the MD definition of the MI pmap(9)
API, which loads of things in the kernel rely on, so changing x86
pmap internals no longer requires recompiling the entire kernel every
time.

Callers needing these internals must now use machine/pmap_private.h.
Note: This is not x86/pmap_private.h because it contains three parts:

1. CPU-specific (different for i386/amd64) definitions used by...

2. common definitions, including Xenisms like xpmap_ptetomach,
   further used by...

3. more CPU-specific inlines for pmap_pte_* operations

So {amd64,i386}/pmap_private.h defines 1, includes x86/pmap_private.h
for 2, and then defines 3.  Maybe we should split that out into a new
pmap_pte.h to reduce this trouble.

No functional change intended, other than that some .c files must
include machine/pmap_private.h when previously uvm/uvm_pmap.h
polluted the namespace with pmap internals.

Note: This migrates part of i386/pmap.h into i386/vmparam.h --
specifically the parts that are needed for several constants defined
in vmparam.h:

VM_MAXUSER_ADDRESS
VM_MAX_ADDRESS
VM_MAX_KERNEL_ADDRESS
VM_MIN_KERNEL_ADDRESS

Since i386 needs PDP_SIZE in vmparam.h, I added it there on amd64
too, just to keep things parallel.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/amd64/amd64/gdt.c
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/amd64/amd64/genassym.cf
cvs rdiff -u -r1.362 -r1.363 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/amd64/include/pmap_private.h
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/amd64/include/vmparam.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/i386/dumpsys.c
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/i386/i386/gdt.c
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.836 -r1.837 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.307 -r1.308 src/sys/arch/i386/i386/trap.c
cvs rdiff -u -r1.127 -r1.128 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/include/pmap_private.h
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/i386/include/vmparam.h
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/x86/acpi/acpi_machdep.c
cvs rdiff -u -r1.132 -r1.133 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/include/pmap_private.h
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/x86/x86/bus_dma.c
cvs rdiff -u -r1.204 -r1.205 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/x86/db_memrw.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/x86/idt.c
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/x86/x86/lapic.c
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/x86/x86/patch.c
cvs rdiff -u -r1.418 -r1.419 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x86/x86/svs.c
cvs rdiff -u -r1.151 -r1.152 src/sys/arch/x86/x86/x86_machdep.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x86/x86/x86_tlb.c
cvs rdiff -u -r1.141 -r1.142 src/sys/arch/xen/x86/cpu.c
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/xen/x86/x86_xpmap.c
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/xen/x86/xen_bus_dma.c
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/xen/x86/xen_pmap.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/xen/x86/xenfunc.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/xen/xen/xen_machdep.c
cvs rdiff -u -r1.83 -r1.84 src/sys/dev/nvmm/x86/nvmm_x86_svm.c \
src/sys/dev/nvmm/x86/nvmm_x86_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/arch/amd64/amd64/gdt.c
diff -u src/sys/arch/amd64/amd64/gdt.c:1.47 src/sys/arch/amd64/amd64/gdt.c:1.48
--- src/sys/arch/amd64/amd64/gdt.c:1.47	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/amd64/amd64/gdt.c	Sat Aug 20 23:48:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: gdt.c,v 1.47 2019/03/09 08:42:25 maxv Exp $	*/
+/*	$NetBSD: gdt.c,v 1.48 2022/08/20 23:48:50 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1996, 

CVS commit: src/sys/kern

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:37:12 UTC 2022

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

Log Message:
KERNEL_LOCK(9): Limit ipi trace diagnostic to after init has started.


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/kern/kern_lock.c

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



CVS commit: src/sys/kern

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:37:12 UTC 2022

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

Log Message:
KERNEL_LOCK(9): Limit ipi trace diagnostic to after init has started.


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/kern/kern_lock.c

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

Modified files:

Index: src/sys/kern/kern_lock.c
diff -u src/sys/kern/kern_lock.c:1.177 src/sys/kern/kern_lock.c:1.178
--- src/sys/kern/kern_lock.c:1.177	Tue Aug 16 21:23:37 2022
+++ src/sys/kern/kern_lock.c	Sat Aug 20 23:37:12 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lock.c,v 1.177 2022/08/16 21:23:37 riastradh Exp $	*/
+/*	$NetBSD: kern_lock.c,v 1.178 2022/08/20 23:37:12 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2020 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.177 2022/08/16 21:23:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.178 2022/08/20 23:37:12 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lockdebug.h"
@@ -253,8 +253,8 @@ _kernel_lock(int nlocks)
 		splx(s);
 		while (__SIMPLELOCK_LOCKED_P(kernel_lock)) {
 #ifdef LOCKDEBUG
-			if (SPINLOCK_SPINOUT(spins)) {
-extern int start_init_exec;
+			extern int start_init_exec;
+			if (SPINLOCK_SPINOUT(spins) && start_init_exec) {
 ipi_msg_t msg = {
 	.func = kernel_lock_trace_ipi,
 };
@@ -262,8 +262,7 @@ _kernel_lock(int nlocks)
 ipi_unicast(, kernel_lock_holder);
 ipi_wait();
 kpreempt_enable();
-if (start_init_exec)
-	_KERNEL_LOCK_ABORT("spinout");
+_KERNEL_LOCK_ABORT("spinout");
 			}
 			SPINLOCK_BACKOFF_HOOK;
 			SPINLOCK_SPIN_HOOK;



CVS commit: src/sys/uvm

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:26:02 UTC 2022

Modified Files:
src/sys/uvm: uvm_pdpolicy.h

Log Message:
uvm_pdpolicy.h: Fix missing forward declarations and includes.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/uvm/uvm_pdpolicy.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/uvm/uvm_pdpolicy.h
diff -u src/sys/uvm/uvm_pdpolicy.h:1.8 src/sys/uvm/uvm_pdpolicy.h:1.9
--- src/sys/uvm/uvm_pdpolicy.h:1.8	Sun May 17 19:38:17 2020
+++ src/sys/uvm/uvm_pdpolicy.h	Sat Aug 20 23:26:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_pdpolicy.h,v 1.8 2020/05/17 19:38:17 ad Exp $	*/
+/*	$NetBSD: uvm_pdpolicy.h,v 1.9 2022/08/20 23:26:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c)2005, 2006 YAMAMOTO Takashi,
@@ -29,8 +29,15 @@
 #ifndef _UVM_PDPOLICY_H_
 #define _UVM_PDPOLICY_H_
 
-struct vm_page;
+#include 
+#include 
+
+#include 
+
+struct krwlock;
+struct uvm_cpu;
 struct vm_anon;
+struct vm_page;
 
 /*
  * these API is for uvm internal use only.
@@ -56,7 +63,7 @@ void uvmpdpol_anfree(struct vm_anon *);
 void uvmpdpol_tune(void);
 void uvmpdpol_scaninit(void);
 void uvmpdpol_scanfini(void);
-struct vm_page *uvmpdpol_selectvictim(krwlock_t **lock);
+struct vm_page *uvmpdpol_selectvictim(struct krwlock **);
 void uvmpdpol_balancequeue(int);
 
 void uvmpdpol_sysctlsetup(void);



CVS commit: src/sys/uvm

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:26:02 UTC 2022

Modified Files:
src/sys/uvm: uvm_pdpolicy.h

Log Message:
uvm_pdpolicy.h: Fix missing forward declarations and includes.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/uvm/uvm_pdpolicy.h

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



CVS commit: src/sys

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:19:09 UTC 2022

Modified Files:
src/sys/arch/amd64/include: pte.h
src/sys/arch/i386/include: pte.h
src/sys/arch/x86/include: pte.h
src/sys/external/bsd/drm2/dist/drm/i915: i915_gem_gtt.c
src/sys/external/bsd/drm2/dist/drm/i915/gt: intel_gtt.h

Log Message:
x86: Forbid using x86/pte.h directly; use machine/pte.h.

machine/pte.h already used outside sys/arch, so let's make it the
primary thing and make sure to use x86/pte.h only as a subroutine.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/amd64/include/pte.h
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/i386/include/pte.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/include/pte.h
cvs rdiff -u -r1.23 -r1.24 \
src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c
cvs rdiff -u -r1.12 -r1.13 \
src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.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/amd64/include/pte.h
diff -u src/sys/arch/amd64/include/pte.h:1.15 src/sys/arch/amd64/include/pte.h:1.16
--- src/sys/arch/amd64/include/pte.h:1.15	Sat Aug 20 23:18:39 2022
+++ src/sys/arch/amd64/include/pte.h	Sat Aug 20 23:19:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pte.h,v 1.15 2022/08/20 23:18:39 riastradh Exp $	*/
+/*	$NetBSD: pte.h,v 1.16 2022/08/20 23:19:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -121,7 +121,9 @@ typedef uint64_t pt_entry_t;		/* PTE */
 #define PTE_FRAME	PTE_4KFRAME
 #define PTE_LGFRAME	PTE_2MFRAME
 
+#define	_MACHINE_PTE_H_X86
 #include 
+#undef	_MACHINE_PTE_H_X86
 
 #else   /*  !__x86_64__  */
 

Index: src/sys/arch/i386/include/pte.h
diff -u src/sys/arch/i386/include/pte.h:1.34 src/sys/arch/i386/include/pte.h:1.35
--- src/sys/arch/i386/include/pte.h:1.34	Sat Aug 20 23:18:40 2022
+++ src/sys/arch/i386/include/pte.h	Sat Aug 20 23:19:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pte.h,v 1.34 2022/08/20 23:18:40 riastradh Exp $	*/
+/*	$NetBSD: pte.h,v 1.35 2022/08/20 23:19:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -168,6 +168,8 @@ typedef uint32_t pt_entry_t;		/* PTE */
 #define PTE_NX		0		/* Dummy */
 #endif
 
+#define	_MACHINE_PTE_H_X86
 #include 
+#undef	_MACHINE_PTE_H_X86
 
 #endif /* _I386_PTE_H_ */

Index: src/sys/arch/x86/include/pte.h
diff -u src/sys/arch/x86/include/pte.h:1.6 src/sys/arch/x86/include/pte.h:1.7
--- src/sys/arch/x86/include/pte.h:1.6	Sat Aug 20 23:18:51 2022
+++ src/sys/arch/x86/include/pte.h	Sat Aug 20 23:19:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pte.h,v 1.6 2022/08/20 23:18:51 riastradh Exp $	*/
+/*	$NetBSD: pte.h,v 1.7 2022/08/20 23:19:09 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -32,6 +32,10 @@
 #ifndef _X86_PTE_H
 #define _X86_PTE_H
 
+#ifndef _MACHINE_PTE_H_X86
+#error Use machine/pte.h, not x86/pte.h directly.
+#endif
+
 /* Cacheability bits when we are using PAT */
 #define PGC_WB		0			/* The default */
 #define PGC_WC		PTE_PWT			/* WT and CD is WC */

Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c:1.23 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c:1.24
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c:1.23	Sun Dec 19 11:33:30 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c	Sat Aug 20 23:19:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_gtt.c,v 1.23 2021/12/19 11:33:30 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_gtt.c,v 1.24 2022/08/20 23:19:09 riastradh Exp $	*/
 
 // SPDX-License-Identifier: MIT
 /*
@@ -6,7 +6,7 @@
  * Copyright © 2020 Intel Corporation
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_gtt.c,v 1.23 2021/12/19 11:33:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_gtt.c,v 1.24 2022/08/20 23:19:09 riastradh Exp $");
 
 #include  /* fault-inject.h is not standalone! */
 
@@ -33,7 +33,7 @@ __KERNEL_RCSID(0, "$NetBSD: i915_gem_gtt
 #ifdef __NetBSD__
 #include 
 #include 
-#include 
+#include 
 #define	_PAGE_PRESENT	PTE_P	/* 0x01 PTE is present */
 #define	_PAGE_RW	PTE_W	/* 0x02 read/write */
 #define	_PAGE_PWT	PTE_PWT	/* 0x08 page write-through */

Index: src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.h
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.h:1.12 src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.h:1.13
--- src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.h:1.12	Sun Dec 19 11:39:55 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.h	Sat Aug 20 23:19:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_gtt.h,v 1.12 2021/12/19 11:39:55 riastradh Exp $	*/
+/*	$NetBSD: intel_gtt.h,v 1.13 2022/08/20 23:19:09 riastradh Exp $	*/
 
 /* SPDX-License-Identifier: MIT */
 /*
@@ -37,7 +37,7 @@
 #ifdef __NetBSD__
 #include 
 #include 
-#include 
+#include 
 #define	_PAGE_PRESENT	PTE_P	/* 0x01 PTE is present / valid */
 

CVS commit: src/sys

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:19:09 UTC 2022

Modified Files:
src/sys/arch/amd64/include: pte.h
src/sys/arch/i386/include: pte.h
src/sys/arch/x86/include: pte.h
src/sys/external/bsd/drm2/dist/drm/i915: i915_gem_gtt.c
src/sys/external/bsd/drm2/dist/drm/i915/gt: intel_gtt.h

Log Message:
x86: Forbid using x86/pte.h directly; use machine/pte.h.

machine/pte.h already used outside sys/arch, so let's make it the
primary thing and make sure to use x86/pte.h only as a subroutine.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/amd64/include/pte.h
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/i386/include/pte.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/include/pte.h
cvs rdiff -u -r1.23 -r1.24 \
src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c
cvs rdiff -u -r1.12 -r1.13 \
src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.h

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



CVS commit: src/sys/arch/x86

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:18:51 UTC 2022

Modified Files:
src/sys/arch/x86/include: pmap.h pte.h
src/sys/arch/x86/x86: pmap.c

Log Message:
x86: Move pl*_i, pl_i_roundup, and ptp_va2o out of x86/pmap.h.

- pl[1-4]_i -> x86/pte.h
- pl_i, pl_i_roundup, ptp_va2o -> x86/pmap.c


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/include/pte.h
cvs rdiff -u -r1.417 -r1.418 src/sys/arch/x86/x86/pmap.c

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

Modified files:

Index: src/sys/arch/x86/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.131 src/sys/arch/x86/include/pmap.h:1.132
--- src/sys/arch/x86/include/pmap.h:1.131	Sat Aug 20 23:18:20 2022
+++ src/sys/arch/x86/include/pmap.h	Sat Aug 20 23:18:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.131 2022/08/20 23:18:20 riastradh Exp $	*/
+/*	$NetBSD: pmap.h,v 1.132 2022/08/20 23:18:51 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -67,40 +67,6 @@
 #ifndef _X86_PMAP_H_
 #define	_X86_PMAP_H_
 
-/*
- * pl*_pi: index in the ptp page for a pde mapping a VA.
- * (pl*_i below is the index in the virtual array of all pdes per level)
- */
-#define pl1_pi(VA)	(((VA_SIGN_POS(VA)) & L1_MASK) >> L1_SHIFT)
-#define pl2_pi(VA)	(((VA_SIGN_POS(VA)) & L2_MASK) >> L2_SHIFT)
-#define pl3_pi(VA)	(((VA_SIGN_POS(VA)) & L3_MASK) >> L3_SHIFT)
-#define pl4_pi(VA)	(((VA_SIGN_POS(VA)) & L4_MASK) >> L4_SHIFT)
-#define pl_pi(va, lvl) \
-(((VA_SIGN_POS(va)) & ptp_masks[(lvl)-1]) >> ptp_shifts[(lvl)-1])
-
-/*
- * pl*_i: generate index into pde/pte arrays in virtual space
- *
- * pl_i(va, X) == plX_i(va) <= pl_i_roundup(va, X)
- */
-#define pl1_i(VA)	(((VA_SIGN_POS(VA)) & L1_FRAME) >> L1_SHIFT)
-#define pl2_i(VA)	(((VA_SIGN_POS(VA)) & L2_FRAME) >> L2_SHIFT)
-#define pl3_i(VA)	(((VA_SIGN_POS(VA)) & L3_FRAME) >> L3_SHIFT)
-#define pl4_i(VA)	(((VA_SIGN_POS(VA)) & L4_FRAME) >> L4_SHIFT)
-#define pl_i(va, lvl) \
-(((VA_SIGN_POS(va)) & ptp_frames[(lvl)-1]) >> ptp_shifts[(lvl)-1])
-
-#define	pl_i_roundup(va, lvl)	pl_i((va)+ ~ptp_frames[(lvl)-1], (lvl))
-
-/*
- * PTP macros:
- *   a PTP's index is the PD index of the PDE that points to it
- *   a PTP's offset is the byte-offset in the PTE space that this PTP is at
- *   a PTP's VA is the first VA mapped by that PTP
- */
-
-#define ptp_va2o(va, lvl)	(pl_i(va, (lvl)+1) * PAGE_SIZE)
-
 /* size of a PDP: usually one page, except for PAE */
 #ifdef PAE
 #define PDP_SIZE 4
@@ -108,7 +74,6 @@
 #define PDP_SIZE 1
 #endif
 
-
 #if defined(_KERNEL)
 #include 
 #include 

Index: src/sys/arch/x86/include/pte.h
diff -u src/sys/arch/x86/include/pte.h:1.5 src/sys/arch/x86/include/pte.h:1.6
--- src/sys/arch/x86/include/pte.h:1.5	Sat Sep  5 07:26:37 2020
+++ src/sys/arch/x86/include/pte.h	Sat Aug 20 23:18:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pte.h,v 1.5 2020/09/05 07:26:37 maxv Exp $	*/
+/*	$NetBSD: pte.h,v 1.6 2022/08/20 23:18:51 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -49,4 +49,23 @@
 #define PGEX_PK		0x0020	/* access disallowed by protection key */
 #define PGEX_SGX	0x8000	/* violation of sgx-specific access rights */
 
+/*
+ * pl*_pi: index in the ptp page for a pde mapping a VA.
+ * (pl*_i below is the index in the virtual array of all pdes per level)
+ */
+#define pl1_pi(VA)	(((VA_SIGN_POS(VA)) & L1_MASK) >> L1_SHIFT)
+#define pl2_pi(VA)	(((VA_SIGN_POS(VA)) & L2_MASK) >> L2_SHIFT)
+#define pl3_pi(VA)	(((VA_SIGN_POS(VA)) & L3_MASK) >> L3_SHIFT)
+#define pl4_pi(VA)	(((VA_SIGN_POS(VA)) & L4_MASK) >> L4_SHIFT)
+#define pl_pi(va, lvl) \
+(((VA_SIGN_POS(va)) & ptp_masks[(lvl)-1]) >> ptp_shifts[(lvl)-1])
+
+/*
+ * pl*_i: generate index into pde/pte arrays in virtual space
+ */
+#define pl1_i(VA)	(((VA_SIGN_POS(VA)) & L1_FRAME) >> L1_SHIFT)
+#define pl2_i(VA)	(((VA_SIGN_POS(VA)) & L2_FRAME) >> L2_SHIFT)
+#define pl3_i(VA)	(((VA_SIGN_POS(VA)) & L3_FRAME) >> L3_SHIFT)
+#define pl4_i(VA)	(((VA_SIGN_POS(VA)) & L4_FRAME) >> L4_SHIFT)
+
 #endif /* _X86_PTE_H */

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.417 src/sys/arch/x86/x86/pmap.c:1.418
--- src/sys/arch/x86/x86/pmap.c:1.417	Sat Aug 20 23:15:37 2022
+++ src/sys/arch/x86/x86/pmap.c	Sat Aug 20 23:18:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.417 2022/08/20 23:15:37 riastradh Exp $	*/
+/*	$NetBSD: pmap.c,v 1.418 2022/08/20 23:18:51 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.417 2022/08/20 23:15:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.418 2022/08/20 23:18:51 riastradh Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -281,6 +281,23 @@ static const struct uvm_pagerops pmap_pa
 	/* 

CVS commit: src/sys/arch/x86

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:18:51 UTC 2022

Modified Files:
src/sys/arch/x86/include: pmap.h pte.h
src/sys/arch/x86/x86: pmap.c

Log Message:
x86: Move pl*_i, pl_i_roundup, and ptp_va2o out of x86/pmap.h.

- pl[1-4]_i -> x86/pte.h
- pl_i, pl_i_roundup, ptp_va2o -> x86/pmap.c


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/include/pte.h
cvs rdiff -u -r1.417 -r1.418 src/sys/arch/x86/x86/pmap.c

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



CVS commit: src/sys/arch

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:18:40 UTC 2022

Modified Files:
src/sys/arch/amd64/include: pte.h
src/sys/arch/i386/include: pte.h

Log Message:
amd64/pte.h, i386/pte.h: Need sys/stdint.h for uintN_t.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/amd64/include/pte.h
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/i386/include/pte.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/amd64/include/pte.h
diff -u src/sys/arch/amd64/include/pte.h:1.14 src/sys/arch/amd64/include/pte.h:1.15
--- src/sys/arch/amd64/include/pte.h:1.14	Sat Apr 25 15:26:16 2020
+++ src/sys/arch/amd64/include/pte.h	Sat Aug 20 23:18:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pte.h,v 1.14 2020/04/25 15:26:16 bouyer Exp $	*/
+/*	$NetBSD: pte.h,v 1.15 2022/08/20 23:18:39 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -68,6 +68,7 @@
 /*
  * Here we define the data types for PDEs and PTEs.
  */
+#include 
 typedef uint64_t pd_entry_t;		/* PDE */
 typedef uint64_t pt_entry_t;		/* PTE */
 #endif

Index: src/sys/arch/i386/include/pte.h
diff -u src/sys/arch/i386/include/pte.h:1.33 src/sys/arch/i386/include/pte.h:1.34
--- src/sys/arch/i386/include/pte.h:1.33	Sat Apr 25 15:26:17 2020
+++ src/sys/arch/i386/include/pte.h	Sat Aug 20 23:18:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pte.h,v 1.33 2020/04/25 15:26:17 bouyer Exp $	*/
+/*	$NetBSD: pte.h,v 1.34 2022/08/20 23:18:40 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -86,6 +86,7 @@
 /*
  * here we define the data types for PDEs and PTEs
  */
+#include 
 #ifdef PAE
 typedef uint64_t pd_entry_t;		/* PDE */
 typedef uint64_t pt_entry_t;		/* PTE */



CVS commit: src/sys/arch

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:18:40 UTC 2022

Modified Files:
src/sys/arch/amd64/include: pte.h
src/sys/arch/i386/include: pte.h

Log Message:
amd64/pte.h, i386/pte.h: Need sys/stdint.h for uintN_t.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/amd64/include/pte.h
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/i386/include/pte.h

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



CVS commit: src/sys/arch

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:18:20 UTC 2022

Modified Files:
src/sys/arch/amd64/include: pmap.h
src/sys/arch/i386/include: pmap.h
src/sys/arch/x86/include: pmap.h

Log Message:
x86: Move struct vm_page_md to common x86/pmap.h.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r1.126 -r1.127 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r1.130 -r1.131 src/sys/arch/x86/include/pmap.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/amd64/include/pmap.h
diff -u src/sys/arch/amd64/include/pmap.h:1.66 src/sys/arch/amd64/include/pmap.h:1.67
--- src/sys/arch/amd64/include/pmap.h:1.66	Fri May 15 22:17:45 2020
+++ src/sys/arch/amd64/include/pmap.h	Sat Aug 20 23:18:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.66 2020/05/15 22:17:45 ad Exp $	*/
+/*	$NetBSD: pmap.h,v 1.67 2022/08/20 23:18:20 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -307,17 +307,6 @@ pmap_direct_process(paddr_t pa, voff_t p
 
 void pmap_changeprot_local(vaddr_t, vm_prot_t);
 
-#include 
-
-#define	__HAVE_VM_PAGE_MD
-#define	VM_MDPAGE_INIT(pg) \
-	memset(&(pg)->mdpage, 0, sizeof((pg)->mdpage)); \
-	PMAP_PAGE_INIT(&(pg)->mdpage.mp_pp)
-
-struct vm_page_md {
-	struct pmap_page mp_pp;
-};
-
 #else	/*	!__x86_64__	*/
 
 #include 

Index: src/sys/arch/i386/include/pmap.h
diff -u src/sys/arch/i386/include/pmap.h:1.126 src/sys/arch/i386/include/pmap.h:1.127
--- src/sys/arch/i386/include/pmap.h:1.126	Sun Jul 19 13:55:09 2020
+++ src/sys/arch/i386/include/pmap.h	Sat Aug 20 23:18:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.126 2020/07/19 13:55:09 maxv Exp $	*/
+/*	$NetBSD: pmap.h,v 1.127 2022/08/20 23:18:20 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -400,15 +400,4 @@ struct pcb;
 
 int	pmap_exec_fixup(struct vm_map *, struct trapframe *, struct pcb *);
 
-#include 
-
-#define	__HAVE_VM_PAGE_MD
-#define	VM_MDPAGE_INIT(pg) \
-	memset(&(pg)->mdpage, 0, sizeof((pg)->mdpage)); \
-	PMAP_PAGE_INIT(&(pg)->mdpage.mp_pp)
-
-struct vm_page_md {
-	struct pmap_page mp_pp;
-};
-
 #endif	/* _I386_PMAP_H_ */

Index: src/sys/arch/x86/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.130 src/sys/arch/x86/include/pmap.h:1.131
--- src/sys/arch/x86/include/pmap.h:1.130	Sat Aug 20 23:15:37 2022
+++ src/sys/arch/x86/include/pmap.h	Sat Aug 20 23:18:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.130 2022/08/20 23:15:37 riastradh Exp $	*/
+/*	$NetBSD: pmap.h,v 1.131 2022/08/20 23:18:20 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -557,6 +557,15 @@ extern vaddr_t pmap_direct_end;
 
 void	svs_quad_copy(void *, void *, long);
 
+#define	__HAVE_VM_PAGE_MD
+#define	VM_MDPAGE_INIT(pg) \
+	memset(&(pg)->mdpage, 0, sizeof((pg)->mdpage)); \
+	PMAP_PAGE_INIT(&(pg)->mdpage.mp_pp)
+
+struct vm_page_md {
+	struct pmap_page mp_pp;
+};
+
 #endif /* _KERNEL */
 
 #endif /* _X86_PMAP_H_ */



CVS commit: src/sys/arch

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:18:20 UTC 2022

Modified Files:
src/sys/arch/amd64/include: pmap.h
src/sys/arch/i386/include: pmap.h
src/sys/arch/x86/include: pmap.h

Log Message:
x86: Move struct vm_page_md to common x86/pmap.h.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r1.126 -r1.127 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r1.130 -r1.131 src/sys/arch/x86/include/pmap.h

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



CVS commit: src/sys/arch

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:15:37 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/amd64/include: asan.h
src/sys/arch/i386/i386: machdep.c
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: db_memrw.c patch.c pmap.c x86_machdep.c
Added Files:
src/sys/arch/x86/include: bootspace.h

Log Message:
x86: Split bootspace out of x86/pmap.h into new x86/bootspace.h.


To generate a diff of this commit:
cvs rdiff -u -r1.361 -r1.362 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amd64/include/asan.h
cvs rdiff -u -r1.835 -r1.836 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/include/bootspace.h
cvs rdiff -u -r1.129 -r1.130 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/x86/db_memrw.c
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/x86/x86/patch.c
cvs rdiff -u -r1.416 -r1.417 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.150 -r1.151 src/sys/arch/x86/x86/x86_machdep.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/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.361 src/sys/arch/amd64/amd64/machdep.c:1.362
--- src/sys/arch/amd64/amd64/machdep.c:1.361	Sun Dec 26 21:33:48 2021
+++ src/sys/arch/amd64/amd64/machdep.c	Sat Aug 20 23:15:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.361 2021/12/26 21:33:48 riastradh Exp $	*/
+/*	$NetBSD: machdep.c,v 1.362 2022/08/20 23:15:36 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.361 2021/12/26 21:33:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.362 2022/08/20 23:15:36 riastradh Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -183,6 +183,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 

Index: src/sys/arch/amd64/include/asan.h
diff -u src/sys/arch/amd64/include/asan.h:1.9 src/sys/arch/amd64/include/asan.h:1.10
--- src/sys/arch/amd64/include/asan.h:1.9	Thu Sep 10 14:10:46 2020
+++ src/sys/arch/amd64/include/asan.h	Sat Aug 20 23:15:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.9 2020/09/10 14:10:46 maxv Exp $	*/
+/*	$NetBSD: asan.h,v 1.10 2022/08/20 23:15:36 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -35,6 +35,8 @@
 #include 
 #include 
 
+#include 
+
 #ifdef __HAVE_PCPU_AREA
 #error "PCPU area not allowed with KASAN"
 #endif

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.835 src/sys/arch/i386/i386/machdep.c:1.836
--- src/sys/arch/i386/i386/machdep.c:1.835	Tue May 31 18:04:11 2022
+++ src/sys/arch/i386/i386/machdep.c	Sat Aug 20 23:15:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.835 2022/05/31 18:04:11 bouyer Exp $	*/
+/*	$NetBSD: machdep.c,v 1.836 2022/08/20 23:15:36 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.835 2022/05/31 18:04:11 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.836 2022/08/20 23:15:36 riastradh Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -136,6 +136,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 

Index: src/sys/arch/x86/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.129 src/sys/arch/x86/include/pmap.h:1.130
--- src/sys/arch/x86/include/pmap.h:1.129	Sat Aug 20 23:13:51 2022
+++ src/sys/arch/x86/include/pmap.h	Sat Aug 20 23:15:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.129 2022/08/20 23:13:51 riastradh Exp $	*/
+/*	$NetBSD: pmap.h,v 1.130 2022/08/20 23:15:37 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -115,49 +115,6 @@
 #include 
 #include 
 
-#define BTSEG_NONE	0
-#define BTSEG_TEXT	1
-#define BTSEG_RODATA	2
-#define BTSEG_DATA	3
-#define BTSPACE_NSEGS	64
-
-struct bootspace {
-	struct {
-		vaddr_t va;
-		paddr_t pa;
-		size_t sz;
-	} head;
-
-	/* Kernel segments. */
-	struct {
-		int type;
-		vaddr_t va;
-		paddr_t pa;
-		size_t sz;
-	} segs[BTSPACE_NSEGS];
-
-	/*
-	 * The area used by the early kernel bootstrap. It contains the kernel
-	 * symbols, the preloaded modules, the bootstrap tables, and the ISA I/O
-	 * mem.
-	 */
-	struct {
-		vaddr_t va;
-		paddr_t pa;
-		size_t sz;
-	} boot;
-
-	/* A magic VA usable by the bootstrap code. */
-	vaddr_t spareva;
-
-	/* Virtual address of the page directory. */
-	vaddr_t pdir;
-
-	/* Area dedicated to kernel modules (amd64 only). */
-	vaddr_t smodule;
-	vaddr_t emodule;
-};
-
 #define SLAREA_USER	0
 #define SLAREA_PTE	1
 #define SLAREA_MAIN	2

Index: src/sys/arch/x86/x86/db_memrw.c
diff -u 

CVS commit: src/sys/arch

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:15:37 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/amd64/include: asan.h
src/sys/arch/i386/i386: machdep.c
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: db_memrw.c patch.c pmap.c x86_machdep.c
Added Files:
src/sys/arch/x86/include: bootspace.h

Log Message:
x86: Split bootspace out of x86/pmap.h into new x86/bootspace.h.


To generate a diff of this commit:
cvs rdiff -u -r1.361 -r1.362 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amd64/include/asan.h
cvs rdiff -u -r1.835 -r1.836 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/include/bootspace.h
cvs rdiff -u -r1.129 -r1.130 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/x86/db_memrw.c
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/x86/x86/patch.c
cvs rdiff -u -r1.416 -r1.417 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.150 -r1.151 src/sys/arch/x86/x86/x86_machdep.c

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



CVS commit: src/sys

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:13:51 UTC 2022

Modified Files:
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: pmap.c
src/sys/dev/nvmm/x86: nvmm_x86.c
Added Files:
src/sys/arch/x86/include: pat.h

Log Message:
x86: Move page attribute table bits to x86/pat.h.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/include/pat.h
cvs rdiff -u -r1.128 -r1.129 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.415 -r1.416 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/nvmm/x86/nvmm_x86.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/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.128 src/sys/arch/x86/include/pmap.h:1.129
--- src/sys/arch/x86/include/pmap.h:1.128	Sat Jun 18 22:11:01 2022
+++ src/sys/arch/x86/include/pmap.h	Sat Aug 20 23:13:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.128 2022/06/18 22:11:01 andvar Exp $	*/
+/*	$NetBSD: pmap.h,v 1.129 2022/08/20 23:13:51 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -115,14 +115,6 @@
 #include 
 #include 
 
-#define	PATENTRY(n, type)	(type << ((n) * 8))
-#define	PAT_UC		0x0ULL
-#define	PAT_WC		0x1ULL
-#define	PAT_WT		0x4ULL
-#define	PAT_WP		0x5ULL
-#define	PAT_WB		0x6ULL
-#define	PAT_UCMINUS	0x7ULL
-
 #define BTSEG_NONE	0
 #define BTSEG_TEXT	1
 #define BTSEG_RODATA	2

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.415 src/sys/arch/x86/x86/pmap.c:1.416
--- src/sys/arch/x86/x86/pmap.c:1.415	Fri May 13 09:39:40 2022
+++ src/sys/arch/x86/x86/pmap.c	Sat Aug 20 23:13:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.415 2022/05/13 09:39:40 riastradh Exp $	*/
+/*	$NetBSD: pmap.c,v 1.416 2022/08/20 23:13:51 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.415 2022/05/13 09:39:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.416 2022/08/20 23:13:51 riastradh Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -167,6 +167,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.4
 #include 
 #include 
 
+#include 
 #include 
 
 #include 

Index: src/sys/dev/nvmm/x86/nvmm_x86.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86.c:1.21 src/sys/dev/nvmm/x86/nvmm_x86.c:1.22
--- src/sys/dev/nvmm/x86/nvmm_x86.c:1.21	Tue Sep  8 16:58:38 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86.c	Sat Aug 20 23:13:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86.c,v 1.21 2020/09/08 16:58:38 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86.c,v 1.22 2022/08/20 23:13:51 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.21 2020/09/08 16:58:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.22 2022/08/20 23:13:51 riastradh Exp $");
 
 #include 
 #include 
@@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v
 #include 
 
 #include 
+#include 
 #include 
 
 #include 

Added files:

Index: src/sys/arch/x86/include/pat.h
diff -u /dev/null src/sys/arch/x86/include/pat.h:1.1
--- /dev/null	Sat Aug 20 23:13:51 2022
+++ src/sys/arch/x86/include/pat.h	Sat Aug 20 23:13:51 2022
@@ -0,0 +1,40 @@
+/*	$NetBSD: pat.h,v 1.1 2022/08/20 23:13:51 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef	_X86_PAT_H_
+#define	_X86_PAT_H_
+
+#define	PATENTRY(n, type)	((type) << ((n) * 8))
+#define	PAT_UC			

CVS commit: src/sys

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:13:51 UTC 2022

Modified Files:
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: pmap.c
src/sys/dev/nvmm/x86: nvmm_x86.c
Added Files:
src/sys/arch/x86/include: pat.h

Log Message:
x86: Move page attribute table bits to x86/pat.h.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/include/pat.h
cvs rdiff -u -r1.128 -r1.129 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.415 -r1.416 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/nvmm/x86/nvmm_x86.c

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



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

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:12:01 UTC 2022

Modified Files:
src/sys/arch/x86/include: bootinfo.h

Log Message:
x86/bootinfo.h: Add include guard.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/x86/include/bootinfo.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/x86/include/bootinfo.h
diff -u src/sys/arch/x86/include/bootinfo.h:1.30 src/sys/arch/x86/include/bootinfo.h:1.31
--- src/sys/arch/x86/include/bootinfo.h:1.30	Fri Jun 21 02:08:55 2019
+++ src/sys/arch/x86/include/bootinfo.h	Sat Aug 20 23:12:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.h,v 1.30 2019/06/21 02:08:55 nonaka Exp $	*/
+/*	$NetBSD: bootinfo.h,v 1.31 2022/08/20 23:12:00 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -26,6 +26,9 @@
  *
  */
 
+#ifndef	_X86_BOOTINFO_H_
+#define	_X86_BOOTINFO_H_
+
 #define BTINFO_BOOTPATH		0
 #define BTINFO_ROOTDEVICE	1
 #define BTINFO_BOOTDISK		3
@@ -275,3 +278,5 @@ void  aprint_bootinfo(void);
 #endif /* _LOCORE */
 
 #endif /* _KERNEL */
+
+#endif	/* _X86_BOOTINFO_H_ */



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

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:12:01 UTC 2022

Modified Files:
src/sys/arch/x86/include: bootinfo.h

Log Message:
x86/bootinfo.h: Add include guard.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/x86/include/bootinfo.h

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



CVS commit: src/sys/uvm

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:08:54 UTC 2022

Modified Files:
src/sys/uvm: uvm_pmap.h

Log Message:
uvm/uvm_pmap.h: Fix missing types and forward declarations.

- Need sys/types.h for vaddr_t, paddr_t, u_int, 
- Forward-declare struct vm_page so we don't have to rely on
  machine/pmap.h to do so.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/uvm/uvm_pmap.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/uvm/uvm_pmap.h
diff -u src/sys/uvm/uvm_pmap.h:1.42 src/sys/uvm/uvm_pmap.h:1.43
--- src/sys/uvm/uvm_pmap.h:1.42	Wed Feb 16 20:13:58 2022
+++ src/sys/uvm/uvm_pmap.h	Sat Aug 20 23:08:53 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_pmap.h,v 1.42 2022/02/16 20:13:58 riastradh Exp $	*/
+/*	$NetBSD: uvm_pmap.h,v 1.43 2022/08/20 23:08:53 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -68,7 +68,12 @@
 #ifndef	_PMAP_VM_
 #define	_PMAP_VM_
 
+#include 
+
+#include 
+
 struct lwp;		/* for pmap_activate()/pmap_deactivate() proto */
+struct vm_page;
 
 struct pmap;
 typedef struct pmap *pmap_t;



CVS commit: src/sys/uvm

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 23:08:54 UTC 2022

Modified Files:
src/sys/uvm: uvm_pmap.h

Log Message:
uvm/uvm_pmap.h: Fix missing types and forward declarations.

- Need sys/types.h for vaddr_t, paddr_t, u_int, 
- Forward-declare struct vm_page so we don't have to rely on
  machine/pmap.h to do so.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/uvm/uvm_pmap.h

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



CVS commit: src/distrib/atari/floppies/common

2022-08-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Aug 20 20:50:41 UTC 2022

Modified Files:
src/distrib/atari/floppies/common: dot.profile

Log Message:
Fix yet another "[: SMALL test, no fallback usage" error on installation.

The same problem as PR/54835 of the miniroot scripts, i.e.
avoid and replace use of -o binary primary marked obsolescent
by POSIX.1-2017:
 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_12
8_16

Noticed on installation of NetBSD 9.3 on TT030, and
maybe should be pulled up to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/distrib/atari/floppies/common/dot.profile

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

Modified files:

Index: src/distrib/atari/floppies/common/dot.profile
diff -u src/distrib/atari/floppies/common/dot.profile:1.8 src/distrib/atari/floppies/common/dot.profile:1.9
--- src/distrib/atari/floppies/common/dot.profile:1.8	Thu Jan  9 19:17:41 2020
+++ src/distrib/atari/floppies/common/dot.profile	Sat Aug 20 20:50:41 2022
@@ -1,4 +1,4 @@
-# $NetBSD: dot.profile,v 1.8 2020/01/09 19:17:41 martin Exp $
+# $NetBSD: dot.profile,v 1.9 2022/08/20 20:50:41 tsutsui Exp $
 #
 # Copyright (c) 1995 Jason R. Thorpe
 # Copyright (c) 1994 Christopher G. Demetriou
@@ -95,7 +95,7 @@ if [ "X${DONEPROFILE}" = "X" ]; then
 		# Check if the answer is valid (in range). Note that an answer
 		# < 0 cannot happen because the sed(1) above also removes the
 		# sign.
-		if [ -z "$_ans" -o "$_ans" -ge $_num ]; then
+		if [ -z "$_ans" ] || [ "$_ans" -ge $_num ]; then
 		echo "You entered an invalid response, please try again."
 		continue
 		fi



CVS commit: src/distrib/atari/floppies/common

2022-08-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Aug 20 20:50:41 UTC 2022

Modified Files:
src/distrib/atari/floppies/common: dot.profile

Log Message:
Fix yet another "[: SMALL test, no fallback usage" error on installation.

The same problem as PR/54835 of the miniroot scripts, i.e.
avoid and replace use of -o binary primary marked obsolescent
by POSIX.1-2017:
 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_12
8_16

Noticed on installation of NetBSD 9.3 on TT030, and
maybe should be pulled up to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/distrib/atari/floppies/common/dot.profile

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



CVS commit: src/sys/arch/mac68k/obio

2022-08-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Aug 20 20:02:22 UTC 2022

Modified Files:
src/sys/arch/mac68k/obio: wdc_obio.c

Log Message:
Unmap resources and print error messages properly in error paths.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/mac68k/obio/wdc_obio.c

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



CVS commit: src/sys/arch/mac68k/obio

2022-08-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Aug 20 20:02:22 UTC 2022

Modified Files:
src/sys/arch/mac68k/obio: wdc_obio.c

Log Message:
Unmap resources and print error messages properly in error paths.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/mac68k/obio/wdc_obio.c

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

Modified files:

Index: src/sys/arch/mac68k/obio/wdc_obio.c
diff -u src/sys/arch/mac68k/obio/wdc_obio.c:1.31 src/sys/arch/mac68k/obio/wdc_obio.c:1.32
--- src/sys/arch/mac68k/obio/wdc_obio.c:1.31	Sat Aug 20 19:05:07 2022
+++ src/sys/arch/mac68k/obio/wdc_obio.c	Sat Aug 20 20:02:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc_obio.c,v 1.31 2022/08/20 19:05:07 tsutsui Exp $ */
+/*	$NetBSD: wdc_obio.c,v 1.32 2022/08/20 20:02:22 tsutsui Exp $ */
 
 /*
  * Copyright (c) 2002 Takeshi Shibagaki  All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.31 2022/08/20 19:05:07 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.32 2022/08/20 20:02:22 tsutsui Exp $");
 
 #include 
 #include 
@@ -110,21 +110,20 @@ wdc_obio_match(device_t parent, cfdata_t
 		for (i = 0; i < WDC_NREG; i++) {
 			if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
 			i * 4, 4, >cmd_iohs[i]) != 0)
-goto out;
+goto unmap;
 		}
 		wdc_init_shadow_regs(wdr);
 
 		if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
 		WDC_OBIO_AUXREG_OFFSET, WDC_OBIO_AUXREG_NPORTS,
 		>ctl_ioh))
-			goto out;
+			goto unmap;
 
 		result = wdcprobe(wdr);
 
+ unmap:
 		bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh,
 		WDC_OBIO_REG_NPORTS);
-
-		goto out;
 	}
  out:
 	kmem_free(wdr, sizeof(*wdr));
@@ -148,7 +147,7 @@ wdc_obio_attach(device_t parent, device_
 
 	if (bus_space_map(wdr->cmd_iot, oa->oa_addr, WDC_OBIO_REG_NPORTS, 0,
 	>cmd_baseioh)) {
-		aprint_error_dev(self, "couldn't map registers\n");
+		aprint_error(": couldn't map registers\n");
 		return;
 	}
 
@@ -157,24 +156,24 @@ wdc_obio_attach(device_t parent, device_
 	for (i = 0; i < WDC_NREG; i++) {
 		if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
 		i * 4, 4, >cmd_iohs[i]) != 0) {
-			aprint_error_dev(self,
-			"unable to subregion control register\n");
-			return;
+			aprint_error(
+			": unable to subregion control register\n");
+			goto err;
 		}
 	}
 
 	if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
 	WDC_OBIO_AUXREG_OFFSET, WDC_OBIO_AUXREG_NPORTS, >ctl_ioh)) {
-		aprint_error_dev(self, "unable to subregion aux register\n");
-		return;
+		aprint_error(": unable to subregion aux register\n");
+		goto err;
 	}
 
 	wdc_obio_isr_tag = oa->oa_tag;
 
 	if (bus_space_map(wdc_obio_isr_tag, oa->oa_addr + WDC_OBIO_ISR_OFFSET,
 	WDC_OBIO_ISR_NPORTS, 0, _obio_isr_hdl)) {
-		aprint_error_dev(self, " couldn't map intr status register\n");
-		return;
+		aprint_error(": couldn't map intr status register\n");
+		goto err;
 	}
 
 	switch (current_mac_model->machineid) {
@@ -218,6 +217,10 @@ wdc_obio_attach(device_t parent, device_
 	aprint_normal("\n");
 
 	wdcattach(chp);
+	return;
+
+ err:
+	bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh, WDC_OBIO_REG_NPORTS);
 }
 
 void



CVS commit: src/sys/dev/usb

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 19:11:08 UTC 2022

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

Log Message:
ural_start(): Replace "IFQ_DEQUEUE() -> IF_PREPEND() on failure" with
"IFQ_POLL() -> IFQ_DEQUEUE() on success".

(This one was an even worse anti-pattern than the others!)


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/usb/if_ural.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_ural.c
diff -u src/sys/dev/usb/if_ural.c:1.65 src/sys/dev/usb/if_ural.c:1.66
--- src/sys/dev/usb/if_ural.c:1.65	Sun Mar 15 23:04:51 2020
+++ src/sys/dev/usb/if_ural.c	Sat Aug 20 19:11:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ural.c,v 1.65 2020/03/15 23:04:51 thorpej Exp $ */
+/*	$NetBSD: if_ural.c,v 1.66 2022/08/20 19:11:08 thorpej Exp $ */
 /*	$FreeBSD: /repoman/r/ncvs/src/sys/dev/usb/if_ural.c,v 1.40 2006/06/02 23:14:40 sam Exp $	*/
 
 /*-
@@ -24,7 +24,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.65 2020/03/15 23:04:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.66 2022/08/20 19:11:08 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1376,14 +1376,14 @@ ural_start(struct ifnet *ifp)
 		} else {
 			if (ic->ic_state != IEEE80211_S_RUN)
 break;
-			IFQ_DEQUEUE(>if_snd, m0);
+			IFQ_POLL(>if_snd, m0);
 			if (m0 == NULL)
 break;
 			if (sc->tx_queued >= RAL_TX_LIST_COUNT) {
-IF_PREPEND(>if_snd, m0);
 ifp->if_flags |= IFF_OACTIVE;
 break;
 			}
+			IFQ_DEQUEUE(>if_snd, m0);
 
 			if (m0->m_len < sizeof(struct ether_header) &&
 			!(m0 = m_pullup(m0, sizeof(struct ether_header



CVS commit: src/sys/dev/usb

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 19:11:08 UTC 2022

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

Log Message:
ural_start(): Replace "IFQ_DEQUEUE() -> IF_PREPEND() on failure" with
"IFQ_POLL() -> IFQ_DEQUEUE() on success".

(This one was an even worse anti-pattern than the others!)


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/usb/if_ural.c

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



CVS commit: src/sys/arch/mac68k/obio

2022-08-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Aug 20 19:05:07 UTC 2022

Modified Files:
src/sys/arch/mac68k/obio: wdc_obio.c

Log Message:
KNF and misc style fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/mac68k/obio/wdc_obio.c

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

Modified files:

Index: src/sys/arch/mac68k/obio/wdc_obio.c
diff -u src/sys/arch/mac68k/obio/wdc_obio.c:1.30 src/sys/arch/mac68k/obio/wdc_obio.c:1.31
--- src/sys/arch/mac68k/obio/wdc_obio.c:1.30	Sun May 31 08:59:40 2020
+++ src/sys/arch/mac68k/obio/wdc_obio.c	Sat Aug 20 19:05:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc_obio.c,v 1.30 2020/05/31 08:59:40 rin Exp $ */
+/*	$NetBSD: wdc_obio.c,v 1.31 2022/08/20 19:05:07 tsutsui Exp $ */
 
 /*
  * Copyright (c) 2002 Takeshi Shibagaki  All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.30 2020/05/31 08:59:40 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.31 2022/08/20 19:05:07 tsutsui Exp $");
 
 #include 
 #include 
@@ -90,7 +90,7 @@ wdc_obio_match(device_t parent, cfdata_t
 	struct wdc_regs *wdr;
 	int i, result = 0;
 
-	wdr = kmem_alloc(sizeof(struct wdc_regs), KM_SLEEP);
+	wdr = kmem_alloc(sizeof(*wdr), KM_SLEEP);
 
 	switch (current_mac_model->machineid) {
 	case MACH_MACPB150:
@@ -101,7 +101,7 @@ wdc_obio_match(device_t parent, cfdata_t
 		wdr->cmd_iot = wdr->ctl_iot = oa->oa_tag;
 
 		if (bus_space_map(wdr->cmd_iot, IDEBase, WDC_OBIO_REG_NPORTS,
-0, >cmd_baseioh))
+		0, >cmd_baseioh))
 			goto out;
 
 		mac68k_bus_space_handle_swapped(wdr->cmd_iot,
@@ -109,16 +109,14 @@ wdc_obio_match(device_t parent, cfdata_t
 
 		for (i = 0; i < WDC_NREG; i++) {
 			if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
-	4 * i, 4, >cmd_iohs[i]) != 0)
+			i * 4, 4, >cmd_iohs[i]) != 0)
 goto out;
 		}
 		wdc_init_shadow_regs(wdr);
 
-
 		if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
-WDC_OBIO_AUXREG_OFFSET,
-	WDC_OBIO_AUXREG_NPORTS,
-	>ctl_ioh))
+		WDC_OBIO_AUXREG_OFFSET, WDC_OBIO_AUXREG_NPORTS,
+		>ctl_ioh))
 			goto out;
 
 		result = wdcprobe(wdr);
@@ -128,7 +126,8 @@ wdc_obio_match(device_t parent, cfdata_t
 
 		goto out;
 	}
-out:	kmem_free(wdr, sizeof(struct wdc_regs));
+ out:
+	kmem_free(wdr, sizeof(*wdr));
 	return result;
 }
 
@@ -147,38 +146,33 @@ wdc_obio_attach(device_t parent, device_
 	oa->oa_addr = IDEBase;
 	wdr->cmd_iot = wdr->ctl_iot = oa->oa_tag;
 
-	if (bus_space_map(wdr->cmd_iot, oa->oa_addr,
-		  WDC_OBIO_REG_NPORTS, 0, >cmd_baseioh)) {
+	if (bus_space_map(wdr->cmd_iot, oa->oa_addr, WDC_OBIO_REG_NPORTS, 0,
+	>cmd_baseioh)) {
 		aprint_error_dev(self, "couldn't map registers\n");
 		return;
 	}
 
-	mac68k_bus_space_handle_swapped(wdr->cmd_iot,
-  >cmd_baseioh);
+	mac68k_bus_space_handle_swapped(wdr->cmd_iot, >cmd_baseioh);
 
 	for (i = 0; i < WDC_NREG; i++) {
-		if (bus_space_subregion(wdr->cmd_iot,
-wdr->cmd_baseioh, 4 * i, 4,
->cmd_iohs[i]) != 0) {
+		if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
+		i * 4, 4, >cmd_iohs[i]) != 0) {
 			aprint_error_dev(self,
 			"unable to subregion control register\n");
 			return;
 		}
 	}
 
-	if (bus_space_subregion(wdr->cmd_iot,
-wdr->cmd_baseioh,
-WDC_OBIO_AUXREG_OFFSET, WDC_OBIO_AUXREG_NPORTS,
->ctl_ioh)) {
+	if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
+	WDC_OBIO_AUXREG_OFFSET, WDC_OBIO_AUXREG_NPORTS, >ctl_ioh)) {
 		aprint_error_dev(self, "unable to subregion aux register\n");
 		return;
 	}
 
-	wdc_obio_isr_tag = oa->oa_tag;
+	wdc_obio_isr_tag = oa->oa_tag;
 
-	if (bus_space_map(wdc_obio_isr_tag,
-			  oa->oa_addr+WDC_OBIO_ISR_OFFSET,
-			  WDC_OBIO_ISR_NPORTS, 0, _obio_isr_hdl)) {
+	if (bus_space_map(wdc_obio_isr_tag, oa->oa_addr + WDC_OBIO_ISR_OFFSET,
+	WDC_OBIO_ISR_NPORTS, 0, _obio_isr_hdl)) {
 		aprint_error_dev(self, " couldn't map intr status register\n");
 		return;
 	}
@@ -191,7 +185,7 @@ wdc_obio_attach(device_t parent, device_
 		 */
 		aprint_normal(" (Quadra/Performa series IDE interface)");
 
-		add_nubus_intr(0xf, (void (*)(void*))wdc_obio_intr, (void *)sc);
+		add_nubus_intr(0xf, wdc_obio_intr, sc);
 
 		break;
 	case MACH_MACPB150:
@@ -202,14 +196,13 @@ wdc_obio_attach(device_t parent, device_
 		 */
 		aprint_normal(" (PowerBook series IDE interface)");
 
-		add_nubus_intr(0xc, (void (*)(void*))wdc_obio_intr, (void *)sc);
+		add_nubus_intr(0xc, wdc_obio_intr, sc);
 
 		break;
 	}
 
 	ch_sc = chp;
-	if (device_cfdata(sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags &
-	ATAC_CAP_NOIRQ)
+	if ((device_cfdata(self)->cf_flags & ATAC_CAP_NOIRQ) != 0)
 		sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_NOIRQ;
 	sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16;
 	sc->sc_wdcdev.sc_atac.atac_pio_cap = 0;
@@ -230,13 +223,12 @@ wdc_obio_attach(device_t parent, device_
 void
 wdc_obio_intr(void *arg)
 {
-	unsigned char 

CVS commit: src/sys/arch/mac68k/obio

2022-08-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Aug 20 19:05:07 UTC 2022

Modified Files:
src/sys/arch/mac68k/obio: wdc_obio.c

Log Message:
KNF and misc style fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/mac68k/obio/wdc_obio.c

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



CVS commit: src/sys/dev/marvell

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 19:04:07 UTC 2022

Modified Files:
src/sys/dev/marvell: if_gfe.c

Log Message:
gfe_ifstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/dev/marvell/if_gfe.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/marvell/if_gfe.c
diff -u src/sys/dev/marvell/if_gfe.c:1.59 src/sys/dev/marvell/if_gfe.c:1.60
--- src/sys/dev/marvell/if_gfe.c:1.59	Sat Aug  7 16:19:13 2021
+++ src/sys/dev/marvell/if_gfe.c	Sat Aug 20 19:04:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gfe.c,v 1.59 2021/08/07 16:19:13 thorpej Exp $	*/
+/*	$NetBSD: if_gfe.c,v 1.60 2022/08/20 19:04:07 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_gfe.c,v 1.59 2021/08/07 16:19:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gfe.c,v 1.60 2022/08/20 19:04:07 thorpej Exp $");
 
 #include "opt_inet.h"
 
@@ -691,7 +691,7 @@ gfe_ifstart(struct ifnet *ifp)
 	}
 
 	for (;;) {
-		IF_DEQUEUE(>if_snd, m);
+		IF_POLL(>if_snd, m);
 		if (m == NULL) {
 			ifp->if_flags &= ~IFF_OACTIVE;
 			GE_FUNC_EXIT(sc, "");
@@ -704,6 +704,8 @@ gfe_ifstart(struct ifnet *ifp)
 		if (IF_QFULL(>sc_txq[GE_TXPRIO_HI].txq_pendq))
 			break;
 
+		IF_DEQUEUE(>if_snd, m);
+
 		/*
 		 * Try to enqueue a mbuf to the device. If that fails, we
 		 * can always try to map the next mbuf.
@@ -718,7 +720,6 @@ gfe_ifstart(struct ifnet *ifp)
 	/*
 	 * Attempt to queue the mbuf for send failed.
 	 */
-	IF_PREPEND(>if_snd, m);
 	ifp->if_flags |= IFF_OACTIVE;
 	GE_FUNC_EXIT(sc, "%%");
 }



CVS commit: src/sys/dev/marvell

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 19:04:07 UTC 2022

Modified Files:
src/sys/dev/marvell: if_gfe.c

Log Message:
gfe_ifstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/dev/marvell/if_gfe.c

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



CVS commit: src/sys/dev/ieee1394

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 19:01:32 UTC 2022

Modified Files:
src/sys/dev/ieee1394: if_fwip.c

Log Message:
fwip_async_output(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/ieee1394/if_fwip.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/ieee1394/if_fwip.c
diff -u src/sys/dev/ieee1394/if_fwip.c:1.30 src/sys/dev/ieee1394/if_fwip.c:1.31
--- src/sys/dev/ieee1394/if_fwip.c:1.30	Wed Jan 29 06:19:39 2020
+++ src/sys/dev/ieee1394/if_fwip.c	Sat Aug 20 19:01:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_fwip.c,v 1.30 2020/01/29 06:19:39 thorpej Exp $	*/
+/*	$NetBSD: if_fwip.c,v 1.31 2022/08/20 19:01:31 thorpej Exp $	*/
 /*-
  * Copyright (c) 2004
  *	Doug Rabson
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_fwip.c,v 1.30 2020/01/29 06:19:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_fwip.c,v 1.31 2022/08/20 19:01:31 thorpej Exp $");
 
 #include 
 #include 
@@ -552,7 +552,7 @@ fwip_async_output(struct fwip_softc *sc,
 #endif
 			break;
 		}
-		IF_DEQUEUE(>if_snd, m);
+		IF_POLL(>if_snd, m);
 		if (m == NULL) {
 			mutex_exit(>sc_mtx);
 			break;
@@ -663,9 +663,9 @@ fwip_async_output(struct fwip_softc *sc,
 			mutex_enter(>sc_mtx);
 			STAILQ_INSERT_TAIL(>sc_xferlist, xfer, link);
 			mutex_exit(>sc_mtx);
-			IF_PREPEND(>if_snd, m);
 			break;
 		}
+		IF_DEQUEUE(>if_snd, m);
 		if (error) {
 			/* error */
 			if_statinc(ifp, if_oerrors);



CVS commit: src/sys/dev/ieee1394

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 19:01:32 UTC 2022

Modified Files:
src/sys/dev/ieee1394: if_fwip.c

Log Message:
fwip_async_output(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/ieee1394/if_fwip.c

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



CVS commit: src/sys/arch/newsmips/apbus

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 18:42:03 UTC 2022

Modified Files:
src/sys/arch/newsmips/apbus: if_sn.c

Log Message:
snstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/newsmips/apbus/if_sn.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/newsmips/apbus/if_sn.c
diff -u src/sys/arch/newsmips/apbus/if_sn.c:1.49 src/sys/arch/newsmips/apbus/if_sn.c:1.50
--- src/sys/arch/newsmips/apbus/if_sn.c:1.49	Wed Feb  5 13:08:19 2020
+++ src/sys/arch/newsmips/apbus/if_sn.c	Sat Aug 20 18:42:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sn.c,v 1.49 2020/02/05 13:08:19 martin Exp $	*/
+/*	$NetBSD: if_sn.c,v 1.50 2022/08/20 18:42:03 thorpej Exp $	*/
 
 /*
  * National Semiconductor  DP8393X SONIC Driver
@@ -16,7 +16,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_sn.c,v 1.49 2020/02/05 13:08:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sn.c,v 1.50 2022/08/20 18:42:03 thorpej Exp $");
 
 #include "opt_inet.h"
 
@@ -320,7 +320,7 @@ outloop:
 		return;
 	}
 
-	IF_DEQUEUE(>if_snd, m);
+	IF_POLL(>if_snd, m);
 	if (m == 0)
 		return;
 
@@ -336,13 +336,13 @@ outloop:
 
 	/*
 	 * If there is nothing in the o/p queue, and there is room in
-	 * the Tx ring, then send the packet directly.  Otherwise append
-	 * it to the o/p queue.
+	 * the Tx ring, then send the packet directly.  Otherwise it
+	 * stays on the queue.
 	 */
 	if ((sonicput(sc, m, mtd_next)) == 0) {
-		IF_PREPEND(>if_snd, m);
 		return;
 	}
+	IF_DEQUEUE(>if_snd, m);
 
 	sc->mtd_prev = sc->mtd_free;
 	sc->mtd_free = mtd_next;



CVS commit: src/sys/arch/newsmips/apbus

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 18:42:03 UTC 2022

Modified Files:
src/sys/arch/newsmips/apbus: if_sn.c

Log Message:
snstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/newsmips/apbus/if_sn.c

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



CVS commit: src/sys/arch/mips/sibyte/dev

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 18:40:35 UTC 2022

Modified Files:
src/sys/arch/mips/sibyte/dev: sbmac.c

Log Message:
sbmac_start(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/mips/sibyte/dev/sbmac.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/mips/sibyte/dev/sbmac.c
diff -u src/sys/arch/mips/sibyte/dev/sbmac.c:1.63 src/sys/arch/mips/sibyte/dev/sbmac.c:1.64
--- src/sys/arch/mips/sibyte/dev/sbmac.c:1.63	Sun Dec  5 07:21:59 2021
+++ src/sys/arch/mips/sibyte/dev/sbmac.c	Sat Aug 20 18:40:35 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: sbmac.c,v 1.63 2021/12/05 07:21:59 msaitoh Exp $ */
+/* $NetBSD: sbmac.c,v 1.64 2022/08/20 18:40:35 thorpej Exp $ */
 
 /*
  * Copyright 2000, 2001, 2004
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.63 2021/12/05 07:21:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.64 2022/08/20 18:40:35 thorpej Exp $");
 
 #include "opt_inet.h"
 #include "opt_ns.h"
@@ -1786,7 +1786,7 @@ sbmac_start(struct ifnet *ifp)
 
 	for (;;) {
 
-		IF_DEQUEUE(>if_snd, m_head);
+		IF_POLL(>if_snd, m_head);
 		if (m_head == NULL)
 		break;
 
@@ -1803,6 +1803,7 @@ sbmac_start(struct ifnet *ifp)
 			 * If there's a BPF listener, bounce a copy of this
 			 * frame to it.
 			 */
+			IF_DEQUEUE(>if_snd, m_head);
 			bpf_mtap(ifp, m_head, BPF_D_OUT);
 			if (!sc->sbm_pass3_dma) {
 /*
@@ -1813,7 +1814,6 @@ sbmac_start(struct ifnet *ifp)
 m_freem(m_head);
 			}
 		} else {
-		IF_PREPEND(>if_snd, m_head);
 		ifp->if_flags |= IFF_OACTIVE;
 		break;
 		}



CVS commit: src/sys/arch/mips/sibyte/dev

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 18:40:35 UTC 2022

Modified Files:
src/sys/arch/mips/sibyte/dev: sbmac.c

Log Message:
sbmac_start(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/mips/sibyte/dev/sbmac.c

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



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

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 18:36:17 UTC 2022

Modified Files:
src/sys/arch/arm/gemini: if_gpn.c

Log Message:
gpn_ifstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/gemini/if_gpn.c

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

Modified files:

Index: src/sys/arch/arm/gemini/if_gpn.c
diff -u src/sys/arch/arm/gemini/if_gpn.c:1.14 src/sys/arch/arm/gemini/if_gpn.c:1.15
--- src/sys/arch/arm/gemini/if_gpn.c:1.14	Sat Feb  1 21:45:11 2020
+++ src/sys/arch/arm/gemini/if_gpn.c	Sat Aug 20 18:36:16 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gpn.c,v 1.14 2020/02/01 21:45:11 thorpej Exp $ */
+/* $NetBSD: if_gpn.c,v 1.15 2022/08/20 18:36:16 thorpej Exp $ */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
 
 #include "opt_gemini.h"
 
-__KERNEL_RCSID(0, "$NetBSD: if_gpn.c,v 1.14 2020/02/01 21:45:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gpn.c,v 1.15 2022/08/20 18:36:16 thorpej Exp $");
 
 #include 
 #include 
@@ -363,7 +363,7 @@ gpn_ifstart(struct ifnet *ifp)
 			break;
 		}
 
-		IF_DEQUEUE(>if_snd, m);
+		IF_POLL(>if_snd, m);
 		if (!m)
 			break;
 
@@ -396,10 +396,10 @@ gpn_ifstart(struct ifnet *ifp)
 		 */
 		if (sc->sc_free < count
 		|| sc->sc_txactive + count > MAX_TXACTIVE) {
-			IF_PREPEND(>if_snd, m);
 			ifp->if_flags |= IFF_OACTIVE;
 			return;
 		}
+		IF_DEQUEUE(>if_snd, m);
 
 		bpf_mtap(ifp, m, BPF_D_OUT);
 #ifdef GPNDEBUG



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

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 18:36:17 UTC 2022

Modified Files:
src/sys/arch/arm/gemini: if_gpn.c

Log Message:
gpn_ifstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/gemini/if_gpn.c

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



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

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 18:35:50 UTC 2022

Modified Files:
src/sys/arch/arm/gemini: if_gmc.c

Log Message:
gmc_ifstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/gemini/if_gmc.c

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

Modified files:

Index: src/sys/arch/arm/gemini/if_gmc.c
diff -u src/sys/arch/arm/gemini/if_gmc.c:1.13 src/sys/arch/arm/gemini/if_gmc.c:1.14
--- src/sys/arch/arm/gemini/if_gmc.c:1.13	Sat Feb  1 21:46:49 2020
+++ src/sys/arch/arm/gemini/if_gmc.c	Sat Aug 20 18:35:50 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gmc.c,v 1.13 2020/02/01 21:46:49 thorpej Exp $ */
+/* $NetBSD: if_gmc.c,v 1.14 2022/08/20 18:35:50 thorpej Exp $ */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -47,7 +47,7 @@
 #include 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: if_gmc.c,v 1.13 2020/02/01 21:46:49 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gmc.c,v 1.14 2022/08/20 18:35:50 thorpej Exp $");
 
 #define	MAX_TXSEG	32
 
@@ -393,14 +393,14 @@ gmc_ifstart(struct ifnet *ifp)
 
 	for (;;) {
 		struct mbuf *m;
-		IF_DEQUEUE(>if_snd, m);
+		IF_POLL(>if_snd, m);
 		if (m == NULL)
 			break;
 		if (!gmc_txqueue(sc, sc->sc_txq[0], m)) {
-			IF_PREPEND(>if_snd, m);
 			ifp->if_flags |= IFF_OACTIVE;
 			break;
 		}
+		IF_DEQUEUE(>if_snd, m);
 	}
 }
 



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

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 18:35:50 UTC 2022

Modified Files:
src/sys/arch/arm/gemini: if_gmc.c

Log Message:
gmc_ifstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/gemini/if_gmc.c

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



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

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 16:47:01 UTC 2022

Modified Files:
src/sys/arch/amiga/dev: if_es.c

Log Message:
esstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/amiga/dev/if_es.c

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



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

2022-08-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Aug 20 16:47:01 UTC 2022

Modified Files:
src/sys/arch/amiga/dev: if_es.c

Log Message:
esstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/amiga/dev/if_es.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/amiga/dev/if_es.c
diff -u src/sys/arch/amiga/dev/if_es.c:1.66 src/sys/arch/amiga/dev/if_es.c:1.67
--- src/sys/arch/amiga/dev/if_es.c:1.66	Tue May 24 20:50:18 2022
+++ src/sys/arch/amiga/dev/if_es.c	Sat Aug 20 16:47:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_es.c,v 1.66 2022/05/24 20:50:18 andvar Exp $ */
+/*	$NetBSD: if_es.c,v 1.67 2022/08/20 16:47:01 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995 Michael L. Hitch
@@ -33,7 +33,7 @@
 #include "opt_ns.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.66 2022/05/24 20:50:18 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.67 2022/08/20 16:47:01 thorpej Exp $");
 
 
 #include 
@@ -780,7 +780,7 @@ esstart(struct ifnet *ifp)
 		 * Sneak a peek at the next packet to get the length
 		 * and see if the SMC 91C90 can accept it.
 		 */
-		m = sc->sc_ethercom.ec_if.if_snd.ifq_head;
+		IF_POLL(>sc_ethercom.ec_if.if_snd, m);
 		if (!m)
 			break;
 #ifdef ESDEBUG
@@ -815,7 +815,6 @@ esstart(struct ifnet *ifp)
 			smc->b2.bsr = BSR_BANK2;
 		}
 #endif
-		IF_DEQUEUE(>sc_ethercom.ec_if.if_snd, m);
 		smc->b2.ptr = PTR_AUTOINCR;
 		(void) smc->b2.mmucr;
 		data = (volatile u_short *)>b2.data;
@@ -912,10 +911,10 @@ esstart(struct ifnet *ifp)
 			start_ptr, end_ptr, SWAP(smc->b2.ptr));
 			--sc->sc_smcbusy;
 #endif
-			IF_PREPEND(>sc_ethercom.ec_if.if_snd, m0);
 			esinit(sc);	/* It's really hosed - reset */
 			return;
 		}
+		IF_DEQUEUE(>sc_ethercom.ec_if.if_snd, m);
 		smc->b2.mmucr = MMUCR_ENQ_TX;
 		if (smc->b2.pnr != active_pnr)
 			printf("%s: esstart - PNR changed %x->%x\n",



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

2022-08-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Aug 20 15:12:27 UTC 2022

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
config cosmetics (avoid a warning from config(1):
no need to repeat COMPAT_NETBSD32, we get that from GENERIC.common
already (where it is used for aout support, but here it means elf32
support). Add a comment explaining what goes on.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/sys/arch/evbarm/conf/GENERIC64

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/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.202 src/sys/arch/evbarm/conf/GENERIC64:1.203
--- src/sys/arch/evbarm/conf/GENERIC64:1.202	Sat Aug 13 16:55:10 2022
+++ src/sys/arch/evbarm/conf/GENERIC64	Sat Aug 20 15:12:27 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.202 2022/08/13 16:55:10 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.203 2022/08/20 15:12:27 martin Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -89,8 +89,8 @@ makeoptions	COPY_SYMTAB=1
 
 config		netbsd		root on ? type ?
 
-options 	COMPAT_NETBSD32
-options 	EXEC_ELF32
+#options 	COMPAT_NETBSD32	# already defined in GENERIC.common (there
+options 	EXEC_ELF32	# for a.out, but here we need it for elf32)
 
 #options 	COMPAT_LINUX	# binary compatibility with Linux
 #options 	COMPAT_LINUX32	# binary compatibility with Linux 32-bit



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

2022-08-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Aug 20 15:12:27 UTC 2022

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
config cosmetics (avoid a warning from config(1):
no need to repeat COMPAT_NETBSD32, we get that from GENERIC.common
already (where it is used for aout support, but here it means elf32
support). Add a comment explaining what goes on.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/sys/arch/evbarm/conf/GENERIC64

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



CVS commit: src/sys/net

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 15:11:27 UTC 2022

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

Log Message:
ifnet(9): Make sure to use if_timer and if_watchdog at IPL_NET.


To generate a diff of this commit:
cvs rdiff -u -r1.516 -r1.517 src/sys/net/if.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.c
diff -u src/sys/net/if.c:1.516 src/sys/net/if.c:1.517
--- src/sys/net/if.c:1.516	Sat Aug 20 14:05:22 2022
+++ src/sys/net/if.c	Sat Aug 20 15:11:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.516 2022/08/20 14:05:22 riastradh Exp $	*/
+/*	$NetBSD: if.c,v 1.517 2022/08/20 15:11:27 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.516 2022/08/20 14:05:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.517 2022/08/20 15:11:27 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2691,11 +2691,14 @@ static bool
 if_slowtimo_countdown(struct ifnet *ifp)
 {
 	bool fire = false;
+	int s;
 
-	KERNEL_LOCK(1, NULL); /* for ifp->ifp_timer */
+	s = splnet();
+	KERNEL_LOCK(1, NULL);
 	if (ifp->if_timer != 0 && --ifp->if_timer == 0)
 		fire = true;
 	KERNEL_UNLOCK_ONE(NULL);
+	splx(s);
 
 	return fire;
 }
@@ -2727,10 +2730,13 @@ if_slowtimo_work(struct work *work, void
 	struct if_slowtimo_data *isd =
 	container_of(work, struct if_slowtimo_data, isd_work);
 	struct ifnet *ifp = isd->isd_ifp;
+	int s;
 
+	s = splnet();
 	KERNEL_LOCK(1, NULL);
 	(*ifp->if_slowtimo)(ifp);
 	KERNEL_UNLOCK_ONE(NULL);
+	splx(s);
 
 	mutex_enter(>isd_lock);
 	if (isd->isd_trigger) {



CVS commit: src/sys/net

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 15:11:27 UTC 2022

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

Log Message:
ifnet(9): Make sure to use if_timer and if_watchdog at IPL_NET.


To generate a diff of this commit:
cvs rdiff -u -r1.516 -r1.517 src/sys/net/if.c

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



CVS commit: src/share/man/man9

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:17:36 UTC 2022

Modified Files:
src/share/man/man9: mutex.9

Log Message:
mutex(9): Note counterintuitive IPL change releasing spin locks.

No functional change -- documentation only.

Details:

https://mail-index.netbsd.org/tech-kern/2010/11/12/msg009203.html


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/share/man/man9/mutex.9

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

Modified files:

Index: src/share/man/man9/mutex.9
diff -u src/share/man/man9/mutex.9:1.31 src/share/man/man9/mutex.9:1.32
--- src/share/man/man9/mutex.9:1.31	Sat Dec  9 16:00:19 2017
+++ src/share/man/man9/mutex.9	Sat Aug 20 14:17:36 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mutex.9,v 1.31 2017/12/09 16:00:19 wiz Exp $
+.\"	$NetBSD: mutex.9,v 1.32 2022/08/20 14:17:36 riastradh Exp $
 .\"
 .\" Copyright (c) 2007, 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -141,6 +141,19 @@ try to acquire adaptive mutexes or other
 .Pp
 A processor will always busy-wait when attempting to acquire
 a spin mutex that is already held.
+.Pp
+.Sy Note :
+Releasing a spin mutex may not lower the IPL to what it was when
+entered.
+If other spin mutexes are held, the IPL will not be lowered until the
+last one is released.
+.Pp
+This is usually not a problem because spin mutexes should held only for
+very short durations anyway, so blocking higher-priority interrupts a
+little longer doesn't hurt much.
+But it interferes with writing assertions that the IPL is
+.Em no higher than
+a specified level.
 .El
 .Pp
 See



CVS commit: src/share/man/man9

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:17:36 UTC 2022

Modified Files:
src/share/man/man9: mutex.9

Log Message:
mutex(9): Note counterintuitive IPL change releasing spin locks.

No functional change -- documentation only.

Details:

https://mail-index.netbsd.org/tech-kern/2010/11/12/msg009203.html


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/share/man/man9/mutex.9

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:09:21 UTC 2022

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

Log Message:
udav(4): Prune dead branch: legacy IFF_ALLMULTI is never set here.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/usb/if_udav.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_udav.c
diff -u src/sys/dev/usb/if_udav.c:1.98 src/sys/dev/usb/if_udav.c:1.99
--- src/sys/dev/usb/if_udav.c:1.98	Sat Aug 20 14:08:59 2022
+++ src/sys/dev/usb/if_udav.c	Sat Aug 20 14:09:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_udav.c,v 1.98 2022/08/20 14:08:59 riastradh Exp $	*/
+/*	$NetBSD: if_udav.c,v 1.99 2022/08/20 14:09:20 riastradh Exp $	*/
 /*	$nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $	*/
 
 /*
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.98 2022/08/20 14:08:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.99 2022/08/20 14:09:20 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -582,14 +582,6 @@ udav_uno_mcast(struct ifnet *ifp)
 		ETHER_UNLOCK(ec);
 		UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL | UDAV_RCR_PRMSC);
 		return;
-	} else if (ifp->if_flags & IFF_ALLMULTI) { /* XXX ??? Can't happen? */
-		ETHER_LOCK(ec);
-allmulti:
-		ec->ec_flags |= ETHER_F_ALLMULTI;
-		ETHER_UNLOCK(ec);
-		UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL);
-		UDAV_CLRBIT(un, UDAV_RCR, UDAV_RCR_PRMSC);
-		return;
 	}
 
 	/* first, zot all the existing hash bits */
@@ -603,7 +595,11 @@ allmulti:
 	while (enm != NULL) {
 		if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
 		ETHER_ADDR_LEN) != 0) {
-			goto allmulti;
+			ec->ec_flags |= ETHER_F_ALLMULTI;
+			ETHER_UNLOCK(ec);
+			UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL);
+			UDAV_CLRBIT(un, UDAV_RCR, UDAV_RCR_PRMSC);
+			return;
 		}
 
 		h = UDAV_CALCHASH(enm->enm_addrlo);



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:09:21 UTC 2022

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

Log Message:
udav(4): Prune dead branch: legacy IFF_ALLMULTI is never set here.


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

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:09:10 UTC 2022

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

Log Message:
cue(4): Prune dead branch: IFF_BROADCAST is always set here.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/usb/if_cue.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_cue.c
diff -u src/sys/dev/usb/if_cue.c:1.107 src/sys/dev/usb/if_cue.c:1.108
--- src/sys/dev/usb/if_cue.c:1.107	Sat Aug 20 14:08:59 2022
+++ src/sys/dev/usb/if_cue.c	Sat Aug 20 14:09:10 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cue.c,v 1.107 2022/08/20 14:08:59 riastradh Exp $	*/
+/*	$NetBSD: if_cue.c,v 1.108 2022/08/20 14:09:10 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.107 2022/08/20 14:08:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.108 2022/08/20 14:09:10 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -405,10 +405,8 @@ allmulti:
 	 * Also include the broadcast address in the filter
 	 * so we can receive broadcast frames.
 	 */
-	if (ifp->if_flags & IFF_BROADCAST) {
-		h = cue_crc(etherbroadcastaddr);
-		sc->cue_mctab[h >> 3] |= 1 << (h & 0x7);
-	}
+	h = cue_crc(etherbroadcastaddr);
+	sc->cue_mctab[h >> 3] |= 1 << (h & 0x7);
 
 	cue_mem(un, CUE_CMD_WRITESRAM, CUE_MCAST_TABLE_ADDR,
 	>cue_mctab, CUE_MCAST_TABLE_LEN);



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:09:10 UTC 2022

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

Log Message:
cue(4): Prune dead branch: IFF_BROADCAST is always set here.


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

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



CVS commit: src

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:59 UTC 2022

Modified Files:
src/share/man/man9: usbnet.9
src/sys/dev/usb: if_aue.c if_axe.c if_axen.c if_cue.c if_kue.c if_mos.c
if_mue.c if_smsc.c if_udav.c if_ure.c if_url.c usbnet.c usbnet.h

Log Message:
usbnet(9): New usbnet_ispromisc(un).

Replaces ifp->if_flags & IFF_PROMISC in multicast filter updates.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/share/man/man9/usbnet.9
cvs rdiff -u -r1.190 -r1.191 src/sys/dev/usb/if_aue.c
cvs rdiff -u -r1.150 -r1.151 src/sys/dev/usb/if_axe.c
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/usb/if_axen.c
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/usb/if_cue.c
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/usb/if_kue.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/usb/if_mos.c
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/usb/if_mue.c
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/usb/if_smsc.c
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/usb/if_udav.c
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/usb/if_ure.c
cvs rdiff -u -r1.96 -r1.97 src/sys/dev/usb/if_url.c
cvs rdiff -u -r1.108 -r1.109 src/sys/dev/usb/usbnet.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/usb/usbnet.h

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

Modified files:

Index: src/share/man/man9/usbnet.9
diff -u src/share/man/man9/usbnet.9:1.18 src/share/man/man9/usbnet.9:1.19
--- src/share/man/man9/usbnet.9:1.18	Fri Aug 12 15:30:41 2022
+++ src/share/man/man9/usbnet.9	Sat Aug 20 14:08:59 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: usbnet.9,v 1.18 2022/08/12 15:30:41 riastradh Exp $
+.\"	$NetBSD: usbnet.9,v 1.19 2022/08/20 14:08:59 riastradh Exp $
 .\"
 .\" Copyright (c) 2019 Matthew R. Green
 .\" All rights reserved.
@@ -47,6 +47,8 @@
 .Fn usbnet_softc "struct usbnet *un"
 .Ft bool
 .Fn usbnet_havelink "struct usbnet *un"
+.Ft int
+.Fn usbnet_ispromisc "struct usbnet *un"
 .Ft bool
 .Fn usbnet_isdying "struct usbnet *un"
 .Ft void
@@ -243,6 +245,20 @@ Returns pointer to this
 device softc.
 .It Fn usbnet_havelink un
 Returns true if link is active.
+.It Fn usbnet_ispromisc un
+True if
+.Dv IFF_PROMISC
+is enabled, false if not.
+.Pp
+May be used only in
+.Dq uno_init
+and
+.Dq uno_mcast .
+.Pp
+Drivers must use this in
+.Dq uno_mcast
+instead of reading
+.Li ifp->if_flags .
 .It Fn usbnet_isdying un
 Returns true if device is dying (has been pulled or deactivated,
 pending detach).

Index: src/sys/dev/usb/if_aue.c
diff -u src/sys/dev/usb/if_aue.c:1.190 src/sys/dev/usb/if_aue.c:1.191
--- src/sys/dev/usb/if_aue.c:1.190	Thu Mar  3 05:56:28 2022
+++ src/sys/dev/usb/if_aue.c	Sat Aug 20 14:08:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_aue.c,v 1.190 2022/03/03 05:56:28 riastradh Exp $	*/
+/*	$NetBSD: if_aue.c,v 1.191 2022/08/20 14:08:59 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.190 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.191 2022/08/20 14:08:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -619,7 +619,7 @@ aue_uno_mcast(struct ifnet *ifp)
 	AUEHIST_FUNC();
 	AUEHIST_CALLARGSN(5, "aue%jd: enter", device_unit(un->un_dev), 0, 0, 0);
 
-	if (ifp->if_flags & IFF_PROMISC) {
+	if (usbnet_ispromisc(un)) {
 		ETHER_LOCK(ec);
 allmulti:
 		ec->ec_flags |= ETHER_F_ALLMULTI;
@@ -962,7 +962,7 @@ aue_uno_init(struct ifnet *ifp)
 		aue_csr_write_1(sc, AUE_PAR0 + i, eaddr[i]);
 
 	 /* If we want promiscuous mode, set the allframes bit. */
-	if (ifp->if_flags & IFF_PROMISC)
+	if (usbnet_ispromisc(un))
 		AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
 	else
 		AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);

Index: src/sys/dev/usb/if_axe.c
diff -u src/sys/dev/usb/if_axe.c:1.150 src/sys/dev/usb/if_axe.c:1.151
--- src/sys/dev/usb/if_axe.c:1.150	Thu Mar  3 05:56:28 2022
+++ src/sys/dev/usb/if_axe.c	Sat Aug 20 14:08:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axe.c,v 1.150 2022/03/03 05:56:28 riastradh Exp $	*/
+/*	$NetBSD: if_axe.c,v 1.151 2022/08/20 14:08:59 riastradh Exp $	*/
 /*	$OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.150 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.151 2022/08/20 14:08:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -452,7 +452,7 @@ axe_uno_mcast(struct ifnet *ifp)
 	~(AXE_RXCMD_ALLMULTI | AXE_RXCMD_PROMISC | AXE_RXCMD_MULTICAST);
 
 	ETHER_LOCK(ec);
-	if (ifp->if_flags & IFF_PROMISC) {
+	if (usbnet_ispromisc(un)) {
 		ec->ec_flags |= ETHER_F_ALLMULTI;
 		ETHER_UNLOCK(ec);
 		/* run promisc. mode */

Index: src/sys/dev/usb/if_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.93 src/sys/dev/usb/if_axen.c:1.94
--- src/sys/dev/usb/if_axen.c:1.93	Thu Mar  3 05:56:28 2022
+++ src/sys/dev/usb/if_axen.c	Sat Aug 20 14:08:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axen.c,v 1.93 

CVS commit: src

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:59 UTC 2022

Modified Files:
src/share/man/man9: usbnet.9
src/sys/dev/usb: if_aue.c if_axe.c if_axen.c if_cue.c if_kue.c if_mos.c
if_mue.c if_smsc.c if_udav.c if_ure.c if_url.c usbnet.c usbnet.h

Log Message:
usbnet(9): New usbnet_ispromisc(un).

Replaces ifp->if_flags & IFF_PROMISC in multicast filter updates.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/share/man/man9/usbnet.9
cvs rdiff -u -r1.190 -r1.191 src/sys/dev/usb/if_aue.c
cvs rdiff -u -r1.150 -r1.151 src/sys/dev/usb/if_axe.c
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/usb/if_axen.c
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/usb/if_cue.c
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/usb/if_kue.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/usb/if_mos.c
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/usb/if_mue.c
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/usb/if_smsc.c
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/usb/if_udav.c
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/usb/if_ure.c
cvs rdiff -u -r1.96 -r1.97 src/sys/dev/usb/if_url.c
cvs rdiff -u -r1.108 -r1.109 src/sys/dev/usb/usbnet.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/usb/usbnet.h

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:47 UTC 2022

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

Log Message:
usbnet(9): Rename core lock -> mii lock.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.107 src/sys/dev/usb/usbnet.c:1.108
--- src/sys/dev/usb/usbnet.c:1.107	Sat Aug 20 14:08:38 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 14:08:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.107 2022/08/20 14:08:38 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.108 2022/08/20 14:08:47 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.107 2022/08/20 14:08:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.108 2022/08/20 14:08:47 riastradh Exp $");
 
 #include 
 #include 
@@ -52,17 +52,17 @@ struct usbnet_cdata {
 
 struct usbnet_private {
 	/*
-	 * - unp_core_lock protects the MII / media data and tick scheduling.
+	 * - unp_miilock protects the MII / media data and tick scheduling.
 	 * - unp_rxlock protects the rx path and its data
 	 * - unp_txlock protects the tx path and its data
 	 *
 	 * the lock ordering is:
-	 *	ifnet lock -> unp_core_lock
+	 *	ifnet lock -> unp_miilock
 	 *		   -> unp_rxlock
 	 *		   -> unp_txlock
 	 *		   -> unp_mcastlock
 	 */
-	kmutex_t		unp_core_lock;
+	kmutex_t		unp_miilock;
 	kmutex_t		unp_rxlock;
 	kmutex_t		unp_txlock;
 
@@ -104,9 +104,9 @@ static void usbnet_isowned_rx(struct usb
 static void usbnet_isowned_tx(struct usbnet *);
 
 static inline void
-usbnet_isowned_core(struct usbnet *un)
+usbnet_isowned_mii(struct usbnet *un)
 {
-	KASSERT(mutex_owned(>un_pri->unp_core_lock));
+	KASSERT(mutex_owned(>un_pri->unp_miilock));
 }
 
 static int usbnet_modcmd(modcmd_t, void *);
@@ -162,7 +162,7 @@ static void
 uno_stop(struct usbnet *un, struct ifnet *ifp, int disable)
 {
 	KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
-	usbnet_isowned_core(un);
+	usbnet_isowned_mii(un);
 	if (un->un_ops->uno_stop)
 		(*un->un_ops->uno_stop)(ifp, disable);
 }
@@ -205,21 +205,21 @@ uno_init(struct usbnet *un, struct ifnet
 static int
 uno_read_reg(struct usbnet *un, int phy, int reg, uint16_t *val)
 {
-	usbnet_isowned_core(un);
+	usbnet_isowned_mii(un);
 	return (*un->un_ops->uno_read_reg)(un, phy, reg, val);
 }
 
 static int
 uno_write_reg(struct usbnet *un, int phy, int reg, uint16_t val)
 {
-	usbnet_isowned_core(un);
+	usbnet_isowned_mii(un);
 	return (*un->un_ops->uno_write_reg)(un, phy, reg, val);
 }
 
 static void
 uno_mii_statchg(struct usbnet *un, struct ifnet *ifp)
 {
-	usbnet_isowned_core(un);
+	usbnet_isowned_mii(un);
 	(*un->un_ops->uno_statchg)(ifp);
 }
 
@@ -882,10 +882,10 @@ usbnet_init_rx_tx(struct usbnet * const 
 	usbnet_rx_start_pipes(un);
 
 	/* Kick off the watchdog/stats/mii tick.  */
-	mutex_enter(>unp_core_lock);
+	mutex_enter(>unp_miilock);
 	unp->unp_stopped = false;
 	callout_schedule(>unp_stat_ch, hz);
-	mutex_exit(>unp_core_lock);
+	mutex_exit(>unp_miilock);
 
 out:
 	if (error) {
@@ -899,9 +899,9 @@ out:
 	 * here as an active link.
 	 */
 	if (un->un_ops->uno_statchg == NULL) {
-		mutex_enter(>unp_core_lock);
+		mutex_enter(>unp_miilock);
 		usbnet_set_link(un, error == 0);
-		mutex_exit(>unp_core_lock);
+		mutex_exit(>unp_miilock);
 	}
 
 	return error;
@@ -916,8 +916,8 @@ usbnet_mii_readreg(device_t dev, int phy
 	struct usbnet * const un = device_private(dev);
 	int err;
 
-	/* MII layer ensures core_lock is held. */
-	usbnet_isowned_core(un);
+	/* MII layer ensures miilock is held. */
+	usbnet_isowned_mii(un);
 
 	if (usbnet_isdying(un)) {
 		return EIO;
@@ -940,8 +940,8 @@ usbnet_mii_writereg(device_t dev, int ph
 	struct usbnet * const un = device_private(dev);
 	int err;
 
-	/* MII layer ensures core_lock is held. */
-	usbnet_isowned_core(un);
+	/* MII layer ensures miilock is held. */
+	usbnet_isowned_mii(un);
 
 	if (usbnet_isdying(un)) {
 		return EIO;
@@ -963,8 +963,8 @@ usbnet_mii_statchg(struct ifnet *ifp)
 	USBNETHIST_FUNC(); USBNETHIST_CALLED();
 	struct usbnet * const un = ifp->if_softc;
 
-	/* MII layer ensures core_lock is held. */
-	usbnet_isowned_core(un);
+	/* MII layer ensures miilock is held. */
+	usbnet_isowned_mii(un);
 
 	uno_mii_statchg(un, ifp);
 }
@@ -977,8 +977,8 @@ usbnet_media_upd(struct ifnet *ifp)
 	struct usbnet_private * const unp = un->un_pri;
 	struct mii_data * const mii = usbnet_mii(un);
 
-	/* ifmedia layer ensures core_lock is held. */
-	usbnet_isowned_core(un);
+	/* ifmedia layer ensures miilock is held. */
+	usbnet_isowned_mii(un);
 
 	/* ifmedia changes only with IFNET_LOCK held.  */
 	KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
@@ -1102,9 +1102,9 @@ usbnet_stop(struct usbnet *un, struct if
 	 * 

CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:47 UTC 2022

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

Log Message:
usbnet(9): Rename core lock -> mii lock.

No functional change intended.


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

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:38 UTC 2022

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

Log Message:
usbnet(9): Limit scope of core lock to mii and tick scheduling.

Bringing the interface up or down is serialized by IFNET_LOCK, and we
prevent further mii callbacks with mii_down, so there's no need for
another lock to serialize uno_init, uno_stop, and the mii callbacks.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.106 src/sys/dev/usb/usbnet.c:1.107
--- src/sys/dev/usb/usbnet.c:1.106	Sat Aug 20 14:08:27 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 14:08:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.106 2022/08/20 14:08:27 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.107 2022/08/20 14:08:38 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.106 2022/08/20 14:08:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.107 2022/08/20 14:08:38 riastradh Exp $");
 
 #include 
 #include 
@@ -52,17 +52,15 @@ struct usbnet_cdata {
 
 struct usbnet_private {
 	/*
-	 * - unp_core_lock protects most of this structure, the public one,
-	 *   and the MII / media data.
+	 * - unp_core_lock protects the MII / media data and tick scheduling.
 	 * - unp_rxlock protects the rx path and its data
 	 * - unp_txlock protects the tx path and its data
 	 *
 	 * the lock ordering is:
-	 *	ifnet lock -> unp_core_lock -> unp_rxlock
-	 *-> unp_txlock
-	 *-> unp_mcastlock
-	 * - ifnet lock is not needed for unp_core_lock, but if ifnet lock is
-	 *   involved, it must be taken first
+	 *	ifnet lock -> unp_core_lock
+	 *		   -> unp_rxlock
+	 *		   -> unp_txlock
+	 *		   -> unp_mcastlock
 	 */
 	kmutex_t		unp_core_lock;
 	kmutex_t		unp_rxlock;
@@ -832,8 +830,6 @@ usbnet_init_rx_tx(struct usbnet * const 
 
 	KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
 
-	usbnet_isowned_core(un);
-
 	if (usbnet_isdying(un)) {
 		return EIO;
 	}
@@ -886,8 +882,10 @@ usbnet_init_rx_tx(struct usbnet * const 
 	usbnet_rx_start_pipes(un);
 
 	/* Kick off the watchdog/stats/mii tick.  */
+	mutex_enter(>unp_core_lock);
 	unp->unp_stopped = false;
 	callout_schedule(>unp_stat_ch, hz);
+	mutex_exit(>unp_core_lock);
 
 out:
 	if (error) {
@@ -900,10 +898,11 @@ out:
 	 * For devices without any media autodetection, treat success
 	 * here as an active link.
 	 */
-	if (un->un_ops->uno_statchg == NULL)
+	if (un->un_ops->uno_statchg == NULL) {
+		mutex_enter(>unp_core_lock);
 		usbnet_set_link(un, error == 0);
-
-	usbnet_isowned_core(un);
+		mutex_exit(>unp_core_lock);
+	}
 
 	return error;
 }
@@ -1087,13 +1086,11 @@ usbnet_stop(struct usbnet *un, struct if
 	USBNETHIST_FUNC(); USBNETHIST_CALLED();
 
 	KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
-	usbnet_isowned_core(un);
 
 	/*
 	 * For drivers with hardware multicast filter update callbacks:
 	 * Prevent concurrent access to the hardware registers by
-	 * multicast filter updates, which happens without IFNET_LOCK
-	 * or the usbnet core lock.
+	 * multicast filter updates, which happens without IFNET_LOCK.
 	 */
 	if (un->un_ops->uno_mcast) {
 		mutex_enter(>unp_mcastlock);
@@ -1105,7 +1102,9 @@ usbnet_stop(struct usbnet *un, struct if
 	 * Prevent new activity (rescheduling ticks, xfers, ) and
 	 * clear the watchdog timer.
 	 */
+	mutex_enter(>unp_core_lock);
 	unp->unp_stopped = true;
+	mutex_exit(>unp_core_lock);
 
 	mutex_enter(>unp_rxlock);
 	unp->unp_rxstopped = true;
@@ -1119,19 +1118,22 @@ usbnet_stop(struct usbnet *un, struct if
 	/*
 	 * Stop the timer first, then the task -- if the timer was
 	 * already firing, we stop the task or wait for it complete
-	 * only after if last fired.  Setting unp_stopped prevents the
+	 * only after it last fired.  Setting unp_stopped prevents the
 	 * timer task from being scheduled again.
 	 */
-	callout_halt(>unp_stat_ch, >unp_core_lock);
+	callout_halt(>unp_stat_ch, NULL);
 	usb_rem_task_wait(un->un_udev, >unp_ticktask, USB_TASKQ_DRIVER,
-	>unp_core_lock);
+	NULL);
 
 	/*
 	 * Now that we have stopped calling mii_tick, bring the MII
 	 * state machine down.
 	 */
-	if (mii)
+	if (mii) {
+		mutex_enter(>unp_core_lock);
 		mii_down(mii);
+		mutex_exit(>unp_core_lock);
+	}
 
 	/* Stop transfers. */
 	usbnet_ep_stop_pipes(un);
@@ -1165,7 +1167,6 @@ static void
 usbnet_if_stop(struct ifnet *ifp, int disable)
 {
 	struct usbnet * const un = ifp->if_softc;
-	struct usbnet_private * const unp = un->un_pri;
 
 	KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
 
@@ -1179,9 +1180,7 @@ usbnet_if_stop(struct ifnet *ifp, int di
 	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return;
 
-	mutex_enter(>unp_core_lock);
 	usbnet_stop(un, ifp, disable);
-	

CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:38 UTC 2022

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

Log Message:
usbnet(9): Limit scope of core lock to mii and tick scheduling.

Bringing the interface up or down is serialized by IFNET_LOCK, and we
prevent further mii callbacks with mii_down, so there's no need for
another lock to serialize uno_init, uno_stop, and the mii callbacks.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/usb/usbnet.c

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:27 UTC 2022

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

Log Message:
usbnet(9): Call mii_down once we've finished with mii_tick.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/dev/usb/usbnet.c

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:27 UTC 2022

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

Log Message:
usbnet(9): Call mii_down once we've finished with mii_tick.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.105 src/sys/dev/usb/usbnet.c:1.106
--- src/sys/dev/usb/usbnet.c:1.105	Sat Aug 20 14:08:17 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 14:08:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.105 2022/08/20 14:08:17 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.106 2022/08/20 14:08:27 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.105 2022/08/20 14:08:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.106 2022/08/20 14:08:27 riastradh Exp $");
 
 #include 
 #include 
@@ -1082,6 +1082,7 @@ static void
 usbnet_stop(struct usbnet *un, struct ifnet *ifp, int disable)
 {
 	struct usbnet_private * const unp = un->un_pri;
+	struct mii_data * const mii = usbnet_mii(un);
 
 	USBNETHIST_FUNC(); USBNETHIST_CALLED();
 
@@ -1125,6 +1126,13 @@ usbnet_stop(struct usbnet *un, struct if
 	usb_rem_task_wait(un->un_udev, >unp_ticktask, USB_TASKQ_DRIVER,
 	>unp_core_lock);
 
+	/*
+	 * Now that we have stopped calling mii_tick, bring the MII
+	 * state machine down.
+	 */
+	if (mii)
+		mii_down(mii);
+
 	/* Stop transfers. */
 	usbnet_ep_stop_pipes(un);
 



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:17 UTC 2022

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

Log Message:
usbnet(9): Simplify core lock use in usbnet_tick_task.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.104 src/sys/dev/usb/usbnet.c:1.105
--- src/sys/dev/usb/usbnet.c:1.104	Sat Aug 20 14:08:05 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 14:08:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.104 2022/08/20 14:08:05 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.105 2022/08/20 14:08:17 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.104 2022/08/20 14:08:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.105 2022/08/20 14:08:17 riastradh Exp $");
 
 #include 
 #include 
@@ -1237,16 +1237,14 @@ usbnet_tick_task(void *arg)
 	/* Call driver if requested. */
 	uno_tick(un);
 
+	mutex_enter(>unp_core_lock);
 	DPRINTFN(8, "mii %#jx ifp %#jx", (uintptr_t)mii, (uintptr_t)ifp, 0, 0);
 	if (mii) {
-		mutex_enter(>unp_core_lock);
 		mii_tick(mii);
 		if (!unp->unp_link)
 			(*mii->mii_statchg)(ifp);
-		mutex_exit(>unp_core_lock);
 	}
 
-	mutex_enter(>unp_core_lock);
 	if (!unp->unp_stopped && !usbnet_isdying(un))
 		callout_schedule(>unp_stat_ch, hz);
 	mutex_exit(>unp_core_lock);



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:17 UTC 2022

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

Log Message:
usbnet(9): Simplify core lock use in usbnet_tick_task.


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

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:05 UTC 2022

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

Log Message:
usbnet(9): Call uno_tick before mii stuff.

The one driver that uses it, cue(4), uses it just for statistics
gathering; hard to imagine that order could be important here.  But
this will allow for some simplification of the surrounding code.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.103 src/sys/dev/usb/usbnet.c:1.104
--- src/sys/dev/usb/usbnet.c:1.103	Sat Aug 20 14:07:53 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 14:08:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.103 2022/08/20 14:07:53 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.104 2022/08/20 14:08:05 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.103 2022/08/20 14:07:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.104 2022/08/20 14:08:05 riastradh Exp $");
 
 #include 
 #include 
@@ -1234,6 +1234,9 @@ usbnet_tick_task(void *arg)
 	if (timeout)
 		usbnet_watchdog(ifp);
 
+	/* Call driver if requested. */
+	uno_tick(un);
+
 	DPRINTFN(8, "mii %#jx ifp %#jx", (uintptr_t)mii, (uintptr_t)ifp, 0, 0);
 	if (mii) {
 		mutex_enter(>unp_core_lock);
@@ -1243,9 +1246,6 @@ usbnet_tick_task(void *arg)
 		mutex_exit(>unp_core_lock);
 	}
 
-	/* Call driver if requested. */
-	uno_tick(un);
-
 	mutex_enter(>unp_core_lock);
 	if (!unp->unp_stopped && !usbnet_isdying(un))
 		callout_schedule(>unp_stat_ch, hz);



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:08:05 UTC 2022

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

Log Message:
usbnet(9): Call uno_tick before mii stuff.

The one driver that uses it, cue(4), uses it just for statistics
gathering; hard to imagine that order could be important here.  But
this will allow for some simplification of the surrounding code.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/usb/usbnet.c

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:07:53 UTC 2022

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

Log Message:
usbnet(9): Assert core lock is held on usbnet_set_link.

This is only allowed to be called via the uno_statchg callback, which
in turn is called only with the core lock held.  (usbnet_set_link is
also called internally in usbnet(9) with the core lock held.)


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.102 src/sys/dev/usb/usbnet.c:1.103
--- src/sys/dev/usb/usbnet.c:1.102	Sat Aug 20 14:06:20 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 14:07:53 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.102 2022/08/20 14:06:20 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.103 2022/08/20 14:07:53 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.102 2022/08/20 14:06:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.103 2022/08/20 14:07:53 riastradh Exp $");
 
 #include 
 #include 
@@ -1296,6 +1296,7 @@ out:	mutex_exit(>un_pri->unp_core_lo
 void
 usbnet_set_link(struct usbnet *un, bool link)
 {
+	usbnet_isowned_core(un);
 	un->un_pri->unp_link = link;
 }
 



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:07:53 UTC 2022

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

Log Message:
usbnet(9): Assert core lock is held on usbnet_set_link.

This is only allowed to be called via the uno_statchg callback, which
in turn is called only with the core lock held.  (usbnet_set_link is
also called internally in usbnet(9) with the core lock held.)


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/usb/usbnet.c

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:06:21 UTC 2022

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

Log Message:
usbnet(9): Split unp_stopping into stopped/txstopped/rxstopped.

In practical terms this could be done with one variable and an atomic
store, but serializing all access with a lock makes reasoning easier,
and the locks have to be taken by the logic that queries the
variables anyway, and the variables are set only under heavy-weight
configuration changes anyway.

What this accomplishes is disentangling lock order between rxlock and
txlock: they are never taken at the same time, so no order is needed.

I renamed unp_stopping to unp_stopped for a compiler-assisted audit
to make sure I reviewed every case of it.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.101 src/sys/dev/usb/usbnet.c:1.102
--- src/sys/dev/usb/usbnet.c:1.101	Sat Aug 20 14:06:09 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 14:06:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.101 2022/08/20 14:06:09 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.102 2022/08/20 14:06:20 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.101 2022/08/20 14:06:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.102 2022/08/20 14:06:20 riastradh Exp $");
 
 #include 
 #include 
@@ -58,7 +58,8 @@ struct usbnet_private {
 	 * - unp_txlock protects the tx path and its data
 	 *
 	 * the lock ordering is:
-	 *	ifnet lock -> unp_core_lock -> unp_rxlock -> unp_txlock
+	 *	ifnet lock -> unp_core_lock -> unp_rxlock
+	 *-> unp_txlock
 	 *-> unp_mcastlock
 	 * - ifnet lock is not needed for unp_core_lock, but if ifnet lock is
 	 *   involved, it must be taken first
@@ -79,7 +80,9 @@ struct usbnet_private {
 	struct usbd_pipe	*unp_ep[USBNET_ENDPT_MAX];
 
 	volatile bool		unp_dying;
-	bool			unp_stopping;
+	bool			unp_stopped;
+	bool			unp_rxstopped;
+	bool			unp_txstopped;
 	bool			unp_attached;
 	bool			unp_ifp_attached;
 	bool			unp_link;
@@ -360,7 +363,7 @@ usbnet_rxeof(struct usbd_xfer *xfer, voi
 
 	mutex_enter(>unp_rxlock);
 
-	if (usbnet_isdying(un) || unp->unp_stopping ||
+	if (usbnet_isdying(un) || unp->unp_rxstopped ||
 	status == USBD_INVAL || status == USBD_NOT_STARTED ||
 	status == USBD_CANCELLED)
 		goto out;
@@ -387,7 +390,7 @@ usbnet_rxeof(struct usbd_xfer *xfer, voi
 	usbnet_isowned_rx(un);
 
 done:
-	if (usbnet_isdying(un) || unp->unp_stopping)
+	if (usbnet_isdying(un) || unp->unp_rxstopped)
 		goto out;
 
 	mutex_exit(>unp_rxlock);
@@ -416,7 +419,7 @@ usbnet_txeof(struct usbd_xfer *xfer, voi
 	unp->unp_number, status, (uintptr_t)xfer, 0);
 
 	mutex_enter(>unp_txlock);
-	if (unp->unp_stopping || usbnet_isdying(un)) {
+	if (unp->unp_txstopped || usbnet_isdying(un)) {
 		mutex_exit(>unp_txlock);
 		return;
 	}
@@ -588,11 +591,11 @@ usbnet_if_start(struct ifnet *ifp)
 	struct usbnet_private * const unp = un->un_pri;
 
 	USBNETHIST_FUNC();
-	USBNETHIST_CALLARGS("%jd: stopping %jd",
-	unp->unp_number, unp->unp_stopping, 0, 0);
+	USBNETHIST_CALLARGS("%jd: txstopped %jd",
+	unp->unp_number, unp->unp_txstopped, 0, 0);
 
 	mutex_enter(>unp_txlock);
-	if (!unp->unp_stopping)
+	if (!unp->unp_txstopped)
 		usbnet_start_locked(ifp);
 	mutex_exit(>unp_txlock);
 }
@@ -678,8 +681,8 @@ usbnet_rx_start_pipes(struct usbnet * co
 	struct usbnet_private * const unp = un->un_pri;
 
 	mutex_enter(>unp_rxlock);
-	mutex_enter(>unp_txlock);
-	unp->unp_stopping = false;
+	KASSERT(unp->unp_rxstopped);
+	unp->unp_rxstopped = false;
 
 	for (size_t i = 0; i < un->un_rx_list_cnt; i++) {
 		struct usbnet_chain *c = >uncd_rx_chain[i];
@@ -689,7 +692,6 @@ usbnet_rx_start_pipes(struct usbnet * co
 		usbd_transfer(c->unc_xfer);
 	}
 
-	mutex_exit(>unp_txlock);
 	mutex_exit(>unp_rxlock);
 }
 
@@ -874,9 +876,17 @@ usbnet_init_rx_tx(struct usbnet * const 
 		mutex_exit(>unp_mcastlock);
 	}
 
+	/* Allow transmit.  */
+	mutex_enter(>unp_txlock);
+	KASSERT(unp->unp_txstopped);
+	unp->unp_txstopped = false;
+	mutex_exit(>unp_txlock);
+
 	/* Start up the receive pipe(s). */
 	usbnet_rx_start_pipes(un);
 
+	/* Kick off the watchdog/stats/mii tick.  */
+	unp->unp_stopped = false;
 	callout_schedule(>unp_stat_ch, hz);
 
 out:
@@ -1094,17 +1104,21 @@ usbnet_stop(struct usbnet *un, struct if
 	 * Prevent new activity (rescheduling ticks, xfers, ) and
 	 * clear the watchdog timer.
 	 */
+	unp->unp_stopped = true;
+
 	mutex_enter(>unp_rxlock);
+	unp->unp_rxstopped = true;
+	mutex_exit(>unp_rxlock);
+
 	mutex_enter(>unp_txlock);
-	unp->unp_stopping = true;
+	unp->unp_txstopped = true;
 	unp->unp_timer = 0;
 	mutex_exit(>unp_txlock);
-	mutex_exit(>unp_rxlock);
 
 	/*
 	 * Stop 

CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:06:21 UTC 2022

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

Log Message:
usbnet(9): Split unp_stopping into stopped/txstopped/rxstopped.

In practical terms this could be done with one variable and an atomic
store, but serializing all access with a lock makes reasoning easier,
and the locks have to be taken by the logic that queries the
variables anyway, and the variables are set only under heavy-weight
configuration changes anyway.

What this accomplishes is disentangling lock order between rxlock and
txlock: they are never taken at the same time, so no order is needed.

I renamed unp_stopping to unp_stopped for a compiler-assisted audit
to make sure I reviewed every case of it.


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

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:06:09 UTC 2022

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

Log Message:
usbnet(9): Don't touch unp_stopping in usbnet_pipe_intr.

This access was unprotected by a lock, but it's not necessary anyway:
usbnet_stop aborts the pipes, and the xfer doesn't call usbd_transfer
to reschedule itself -- it's an intr pipe, so it's rescheduled
internally by usbdi(9) in a way that usbd_abort_pipe atomically
prevents.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.100 src/sys/dev/usb/usbnet.c:1.101
--- src/sys/dev/usb/usbnet.c:1.100	Sat Aug 20 14:05:58 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 14:06:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.100 2022/08/20 14:05:58 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.101 2022/08/20 14:06:09 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.100 2022/08/20 14:05:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.101 2022/08/20 14:06:09 riastradh Exp $");
 
 #include 
 #include 
@@ -460,12 +460,12 @@ usbnet_pipe_intr(struct usbd_xfer *xfer,
 	struct usbnet_private * const unp = un->un_pri;
 	struct usbnet_intr * const uni __unused = un->un_intr;
 
-	if (usbnet_isdying(un) || unp->unp_stopping ||
+	if (usbnet_isdying(un) ||
 	status == USBD_INVAL || status == USBD_NOT_STARTED ||
 	status == USBD_CANCELLED) {
-		USBNETHIST_CALLARGS("%jd: uni %#jx d/s %#jx status %#jx",
+		USBNETHIST_CALLARGS("%jd: uni %#jx dying %#jx status %#jx",
 		unp->unp_number, (uintptr_t)uni,
-		(usbnet_isdying(un) << 8) | unp->unp_stopping, status);
+		usbnet_isdying(un), status);
 		return;
 	}
 



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:06:09 UTC 2022

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

Log Message:
usbnet(9): Don't touch unp_stopping in usbnet_pipe_intr.

This access was unprotected by a lock, but it's not necessary anyway:
usbnet_stop aborts the pipes, and the xfer doesn't call usbd_transfer
to reschedule itself -- it's an intr pipe, so it's rescheduled
internally by usbdi(9) in a way that usbd_abort_pipe atomically
prevents.


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

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:05:58 UTC 2022

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

Log Message:
usbnet(9): Omit needless un->un_intr test in usbnet_pipe_intr.

un->un_intr can't change after attach, and we don't open the pipe if
it's null.  So no need to test it.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.99 src/sys/dev/usb/usbnet.c:1.100
--- src/sys/dev/usb/usbnet.c:1.99	Sat Aug 20 12:30:00 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 14:05:58 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.99 2022/08/20 12:30:00 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.100 2022/08/20 14:05:58 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.99 2022/08/20 12:30:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.100 2022/08/20 14:05:58 riastradh Exp $");
 
 #include 
 #include 
@@ -458,9 +458,9 @@ usbnet_pipe_intr(struct usbd_xfer *xfer,
 	USBNETHIST_FUNC();
 	struct usbnet * const un = priv;
 	struct usbnet_private * const unp = un->un_pri;
-	struct usbnet_intr * const uni = un->un_intr;
+	struct usbnet_intr * const uni __unused = un->un_intr;
 
-	if (uni == NULL || usbnet_isdying(un) || unp->unp_stopping ||
+	if (usbnet_isdying(un) || unp->unp_stopping ||
 	status == USBD_INVAL || status == USBD_NOT_STARTED ||
 	status == USBD_CANCELLED) {
 		USBNETHIST_CALLARGS("%jd: uni %#jx d/s %#jx status %#jx",



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:05:58 UTC 2022

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

Log Message:
usbnet(9): Omit needless un->un_intr test in usbnet_pipe_intr.

un->un_intr can't change after attach, and we don't open the pipe if
it's null.  So no need to test it.


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

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



CVS commit: src/sys/net

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:05:22 UTC 2022

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

Log Message:
ifnet(9): On if_deactivate, don't make null if_slowtimo nonnull.

Fixes crash on detach.


To generate a diff of this commit:
cvs rdiff -u -r1.515 -r1.516 src/sys/net/if.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.c
diff -u src/sys/net/if.c:1.515 src/sys/net/if.c:1.516
--- src/sys/net/if.c:1.515	Sat Aug 20 12:42:51 2022
+++ src/sys/net/if.c	Sat Aug 20 14:05:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.515 2022/08/20 12:42:51 riastradh Exp $	*/
+/*	$NetBSD: if.c,v 1.516 2022/08/20 14:05:22 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.515 2022/08/20 12:42:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.516 2022/08/20 14:05:22 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1223,7 +1223,8 @@ if_deactivate(struct ifnet *ifp)
 	ifp->if_ioctl	 = if_nullioctl;
 	ifp->if_init	 = if_nullinit;
 	ifp->if_stop	 = if_nullstop;
-	ifp->if_slowtimo = if_nullslowtimo;
+	if (ifp->if_slowtimo)
+		ifp->if_slowtimo = if_nullslowtimo;
 	ifp->if_drain	 = if_nulldrain;
 
 	/* No more packets may be enqueued. */



CVS commit: src/sys/net

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 14:05:22 UTC 2022

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

Log Message:
ifnet(9): On if_deactivate, don't make null if_slowtimo nonnull.

Fixes crash on detach.


To generate a diff of this commit:
cvs rdiff -u -r1.515 -r1.516 src/sys/net/if.c

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



CVS commit: src/sys/net

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 12:42:51 UTC 2022

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

Log Message:
ifnet(9): Kernel lock for struct ifnet::if_timer.


To generate a diff of this commit:
cvs rdiff -u -r1.514 -r1.515 src/sys/net/if.c

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



CVS commit: src/sys/net

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 12:42:51 UTC 2022

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

Log Message:
ifnet(9): Kernel lock for struct ifnet::if_timer.


To generate a diff of this commit:
cvs rdiff -u -r1.514 -r1.515 src/sys/net/if.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.c
diff -u src/sys/net/if.c:1.514 src/sys/net/if.c:1.515
--- src/sys/net/if.c:1.514	Sat Aug 20 11:09:41 2022
+++ src/sys/net/if.c	Sat Aug 20 12:42:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.514 2022/08/20 11:09:41 riastradh Exp $	*/
+/*	$NetBSD: if.c,v 1.515 2022/08/20 12:42:51 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.514 2022/08/20 11:09:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.515 2022/08/20 12:42:51 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2686,6 +2686,19 @@ if_up_locked(struct ifnet *ifp)
  * from softclock, we decrement timer (if set) and
  * call the appropriate interface routine on expiration.
  */
+static bool
+if_slowtimo_countdown(struct ifnet *ifp)
+{
+	bool fire = false;
+
+	KERNEL_LOCK(1, NULL); /* for ifp->ifp_timer */
+	if (ifp->if_timer != 0 && --ifp->if_timer == 0)
+		fire = true;
+	KERNEL_UNLOCK_ONE(NULL);
+
+	return fire;
+}
+
 static void
 if_slowtimo_intr(void *arg)
 {
@@ -2694,8 +2707,7 @@ if_slowtimo_intr(void *arg)
 
 	mutex_enter(>isd_lock);
 	if (!isd->isd_dying) {
-		if (isd->isd_trigger ||
-		(ifp->if_timer != 0 && --ifp->if_timer == 0)) {
+		if (isd->isd_trigger || if_slowtimo_countdown(ifp)) {
 			if (!isd->isd_queued) {
 isd->isd_queued = true;
 workqueue_enqueue(if_slowtimo_wq,



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 12:30:00 UTC 2022

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

Log Message:
usbnet(9): Revert previous -- usbnet_media_upd does have IFNET_LOCK.

Not sure why I thought otherwise.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.98 src/sys/dev/usb/usbnet.c:1.99
--- src/sys/dev/usb/usbnet.c:1.98	Sat Aug 20 12:28:25 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 12:30:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.98 2022/08/20 12:28:25 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.99 2022/08/20 12:30:00 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.98 2022/08/20 12:28:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.99 2022/08/20 12:30:00 riastradh Exp $");
 
 #include 
 #include 
@@ -986,8 +986,6 @@ usbnet_media_upd(struct ifnet *ifp)
 			mii_phy_reset(miisc);
 	}
 
-	if (unp->unp_stopping)
-		return 0;
 	return ether_mediachange(ifp);
 }
 



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 12:30:00 UTC 2022

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

Log Message:
usbnet(9): Revert previous -- usbnet_media_upd does have IFNET_LOCK.

Not sure why I thought otherwise.


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

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 12:28:25 UTC 2022

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

Log Message:
usbnet(9): Avoid ether_mediachange if stopped.

We are called without IFNET_LOCK held here, so touching ifp->if_flags
is forbidden, but that's the first thing ether_mediachange does.

XXX not right either, need to eliminate the check from
ether_mediachange


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

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 12:28:25 UTC 2022

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

Log Message:
usbnet(9): Avoid ether_mediachange if stopped.

We are called without IFNET_LOCK held here, so touching ifp->if_flags
is forbidden, but that's the first thing ether_mediachange does.

XXX not right either, need to eliminate the check from
ether_mediachange


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.97 src/sys/dev/usb/usbnet.c:1.98
--- src/sys/dev/usb/usbnet.c:1.97	Tue Aug 16 00:44:20 2022
+++ src/sys/dev/usb/usbnet.c	Sat Aug 20 12:28:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.97 2022/08/16 00:44:20 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.98 2022/08/20 12:28:25 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.97 2022/08/16 00:44:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.98 2022/08/20 12:28:25 riastradh Exp $");
 
 #include 
 #include 
@@ -986,6 +986,8 @@ usbnet_media_upd(struct ifnet *ifp)
 			mii_phy_reset(miisc);
 	}
 
+	if (unp->unp_stopping)
+		return 0;
 	return ether_mediachange(ifp);
 }
 



CVS commit: src/sys/dev

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:42:50 UTC 2022

Modified Files:
src/sys/dev: Makefile

Log Message:
sys/dev/Makefile: Split INCS onto separate lines for ease of sorting.

Also sort.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/Makefile

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/Makefile
diff -u src/sys/dev/Makefile:1.47 src/sys/dev/Makefile:1.48
--- src/sys/dev/Makefile:1.47	Sun Sep 27 11:57:28 2020
+++ src/sys/dev/Makefile	Sat Aug 20 11:42:49 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.47 2020/09/27 11:57:28 jmcneill Exp $
+#	$NetBSD: Makefile,v 1.48 2022/08/20 11:42:49 riastradh Exp $
 
 SUBDIR=	apm ata bluetooth dec dm dmover dtv hdaudio hdmicec hid hpc \
 	i2c i2o ic ieee1394 ir isa \
@@ -18,7 +18,15 @@ SUBDIR+= iscsi
 INCSDIR= /usr/include/dev
 
 # Only install includes which are used by userland
-INCS=	biovar.h ccdvar.h cgdvar.h fssvar.h keylock.h kttcpio.h lockstat.h \
-	md.h vndvar.h spkrio.h
+INCS+=	biovar.h
+INCS+=	ccdvar.h
+INCS+=	cgdvar.h
+INCS+=	fssvar.h
+INCS+=	keylock.h
+INCS+=	kttcpio.h
+INCS+=	lockstat.h
+INCS+=	md.h
+INCS+=	spkrio.h
+INCS+=	vndvar.h
 
 .include 



CVS commit: src/sys/dev

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:42:50 UTC 2022

Modified Files:
src/sys/dev: Makefile

Log Message:
sys/dev/Makefile: Split INCS onto separate lines for ease of sorting.

Also sort.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/Makefile

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



CVS commit: src/sys/arch

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:34:08 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: fpu.c
src/sys/arch/arm/vfp: vfp_init.c
src/sys/arch/x86/x86: fpu.c

Log Message:
fpu_kern_enter/leave: Disable IPL assertions.

These don't work because mutex_enter/exit on a spin lock may raise an
IPL but not lower it, if another spin lock was already held.  For
example,

mutex_enter(some_lock_at_IPL_VM);
printf("foo\n");
fpu_kern_enter();
...
fpu_kern_leave();
mutex_exit(some_lock_at_IPL_VM);

will trigger the panic, because printf takes a lock at IPL_HIGH where
the IPL wil remain until the mutex_exit.  (This was a nightmare to
track down before I remembered that detail of spin lock IPL
semantics...)


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/aarch64/fpu.c
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/arm/vfp/vfp_init.c
cvs rdiff -u -r1.78 -r1.79 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/aarch64/aarch64/fpu.c
diff -u src/sys/arch/aarch64/aarch64/fpu.c:1.12 src/sys/arch/aarch64/aarch64/fpu.c:1.13
--- src/sys/arch/aarch64/aarch64/fpu.c:1.12	Fri Apr  1 19:57:22 2022
+++ src/sys/arch/aarch64/aarch64/fpu.c	Sat Aug 20 11:34:08 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.12 2022/04/01 19:57:22 riastradh Exp $ */
+/* $NetBSD: fpu.c,v 1.13 2022/08/20 11:34:08 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: fpu.c,v 1.12 2022/04/01 19:57:22 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: fpu.c,v 1.13 2022/08/20 11:34:08 riastradh Exp $");
 
 #include 
 #include 
@@ -214,7 +214,14 @@ fpu_kern_enter(void)
 	 */
 	s = splvm();
 	ci = curcpu();
+#if 0
+	/*
+	 * Can't assert this because if the caller holds a spin lock at
+	 * IPL_VM, and previously held and released a spin lock at
+	 * higher IPL, the IPL remains raised above IPL_VM.
+	 */
 	KASSERTMSG(ci->ci_cpl <= IPL_VM || cold, "cpl=%d", ci->ci_cpl);
+#endif
 	KASSERT(ci->ci_kfpu_spl == -1);
 	ci->ci_kfpu_spl = s;
 
@@ -242,7 +249,14 @@ fpu_kern_leave(void)
 
 	ci = curcpu();
 
+#if 0
+	/*
+	 * Can't assert this because if the caller holds a spin lock at
+	 * IPL_VM, and previously held and released a spin lock at
+	 * higher IPL, the IPL remains raised above IPL_VM.
+	 */
 	KASSERT(ci->ci_cpl == IPL_VM || cold);
+#endif
 	KASSERT(ci->ci_kfpu_spl != -1);
 
 	/*

Index: src/sys/arch/arm/vfp/vfp_init.c
diff -u src/sys/arch/arm/vfp/vfp_init.c:1.77 src/sys/arch/arm/vfp/vfp_init.c:1.78
--- src/sys/arch/arm/vfp/vfp_init.c:1.77	Fri Apr  1 19:57:22 2022
+++ src/sys/arch/arm/vfp/vfp_init.c	Sat Aug 20 11:34:08 2022
@@ -1,4 +1,4 @@
-/*  $NetBSD: vfp_init.c,v 1.77 2022/04/01 19:57:22 riastradh Exp $ */
+/*  $NetBSD: vfp_init.c,v 1.78 2022/08/20 11:34:08 riastradh Exp $ */
 
 /*
  * Copyright (c) 2008 ARM Ltd
@@ -32,7 +32,7 @@
 #include "opt_cputypes.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v 1.77 2022/04/01 19:57:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v 1.78 2022/08/20 11:34:08 riastradh Exp $");
 
 #include 
 #include 
@@ -695,7 +695,14 @@ fpu_kern_enter(void)
 	 */
 	s = splvm();
 	ci = curcpu();
+#if 0
+	/*
+	 * Can't assert this because if the caller holds a spin lock at
+	 * IPL_VM, and previously held and released a spin lock at
+	 * higher IPL, the IPL remains raised above IPL_VM.
+	 */
 	KASSERTMSG(ci->ci_cpl <= IPL_VM || cold, "cpl=%d", ci->ci_cpl);
+#endif
 	KASSERT(ci->ci_kfpu_spl == -1);
 	ci->ci_kfpu_spl = s;
 
@@ -721,7 +728,14 @@ fpu_kern_leave(void)
 		return;
 	}
 
+#if 0
+	/*
+	 * Can't assert this because if the caller holds a spin lock at
+	 * IPL_VM, and previously held and released a spin lock at
+	 * higher IPL, the IPL remains raised above IPL_VM.
+	 */
 	KASSERT(ci->ci_cpl == IPL_VM || cold);
+#endif
 	KASSERT(ci->ci_kfpu_spl != -1);
 
 	/*

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.78 src/sys/arch/x86/x86/fpu.c:1.79
--- src/sys/arch/x86/x86/fpu.c:1.78	Tue May 24 06:28:00 2022
+++ src/sys/arch/x86/x86/fpu.c	Sat Aug 20 11:34:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.78 2022/05/24 06:28:00 andvar Exp $	*/
+/*	$NetBSD: fpu.c,v 1.79 2022/08/20 11:34:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.78 2022/05/24 06:28:00 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.79 2022/08/20 11:34:08 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -380,8 +380,15 @@ fpu_kern_enter(void)
 	s = splvm();
 
 	ci = curcpu();
+#if 0
+	/*
+	 * Can't assert this because if the caller holds a spin lock at
+	 * IPL_VM, and previously held and released a spin lock at
+	 * higher IPL, the IPL remains 

CVS commit: src/sys/arch

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:34:08 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: fpu.c
src/sys/arch/arm/vfp: vfp_init.c
src/sys/arch/x86/x86: fpu.c

Log Message:
fpu_kern_enter/leave: Disable IPL assertions.

These don't work because mutex_enter/exit on a spin lock may raise an
IPL but not lower it, if another spin lock was already held.  For
example,

mutex_enter(some_lock_at_IPL_VM);
printf("foo\n");
fpu_kern_enter();
...
fpu_kern_leave();
mutex_exit(some_lock_at_IPL_VM);

will trigger the panic, because printf takes a lock at IPL_HIGH where
the IPL wil remain until the mutex_exit.  (This was a nightmare to
track down before I remembered that detail of spin lock IPL
semantics...)


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/aarch64/fpu.c
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/arm/vfp/vfp_init.c
cvs rdiff -u -r1.78 -r1.79 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: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:32:20 UTC 2022

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

Log Message:
usbdi(9): Nix resurrected usbd_request_async.

We killed this back in 2013, but it came back from the dead on a
driver imported from OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/usb/usbdi.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/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.242 src/sys/dev/usb/usbdi.c:1.243
--- src/sys/dev/usb/usbdi.c:1.242	Wed Apr  6 22:01:45 2022
+++ src/sys/dev/usb/usbdi.c	Sat Aug 20 11:32:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.242 2022/04/06 22:01:45 mlelstv Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.243 2022/08/20 11:32:20 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.242 2022/04/06 22:01:45 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.243 2022/08/20 11:32:20 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -137,7 +137,6 @@ static void *usbd_alloc_buffer(struct us
 static void usbd_free_buffer(struct usbd_xfer *);
 static struct usbd_xfer *usbd_alloc_xfer(struct usbd_device *, unsigned int);
 static void usbd_free_xfer(struct usbd_xfer *);
-static void usbd_request_async_cb(struct usbd_xfer *, void *, usbd_status);
 static void usbd_xfer_timeout(void *);
 static void usbd_xfer_timeout_task(void *);
 static bool usbd_xfer_probe_timeout(struct usbd_xfer *);
@@ -1333,36 +1332,6 @@ usbd_do_request_len(struct usbd_device *
 	return err;
 }
 
-static void
-usbd_request_async_cb(struct usbd_xfer *xfer, void *priv, usbd_status status)
-{
-	usbd_destroy_xfer(xfer);
-}
-
-/*
- * Execute a request without waiting for completion.
- * Can be used from interrupt context.
- */
-usbd_status
-usbd_request_async(struct usbd_device *dev, struct usbd_xfer *xfer,
-usb_device_request_t *req, void *priv, usbd_callback callback)
-{
-	usbd_status err;
-
-	if (callback == NULL)
-		callback = usbd_request_async_cb;
-
-	usbd_setup_default_xfer(xfer, dev, priv,
-	USBD_DEFAULT_TIMEOUT, req, NULL, UGETW(req->wLength), 0,
-	callback);
-	err = usbd_transfer(xfer);
-	if (err != USBD_IN_PROGRESS) {
-		usbd_destroy_xfer(xfer);
-		return (err);
-	}
-	return (USBD_NORMAL_COMPLETION);
-}
-
 const struct usbd_quirks *
 usbd_get_quirks(struct usbd_device *dev)
 {

Index: src/sys/dev/usb/usbdi.h
diff -u src/sys/dev/usb/usbdi.h:1.107 src/sys/dev/usb/usbdi.h:1.108
--- src/sys/dev/usb/usbdi.h:1.107	Thu Mar  3 06:09:33 2022
+++ src/sys/dev/usb/usbdi.h	Sat Aug 20 11:32:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.h,v 1.107 2022/03/03 06:09:33 riastradh Exp $	*/
+/*	$NetBSD: usbdi.h,v 1.108 2022/08/20 11:32:20 riastradh Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $	*/
 
 /*
@@ -146,8 +146,6 @@ usbd_status usbd_sync_transfer(struct us
 usbd_status usbd_sync_transfer_sig(struct usbd_xfer *);
 
 usbd_status usbd_do_request(struct usbd_device *, usb_device_request_t *, void *);
-usbd_status usbd_request_async(struct usbd_device *, struct usbd_xfer *,
-usb_device_request_t *, void *, usbd_callback);
 usbd_status usbd_do_request_flags(struct usbd_device *, usb_device_request_t *,
 void *, uint16_t, int *, uint32_t);
 usbd_status usbd_do_request_len(struct usbd_device *dev,



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:32:20 UTC 2022

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

Log Message:
usbdi(9): Nix resurrected usbd_request_async.

We killed this back in 2013, but it came back from the dead on a
driver imported from OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/usb/usbdi.h

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



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:32:08 UTC 2022

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

Log Message:
umb(4): Use usbd_do_request as drivers are intended to do.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/usb/if_umb.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_umb.c
diff -u src/sys/dev/usb/if_umb.c:1.24 src/sys/dev/usb/if_umb.c:1.25
--- src/sys/dev/usb/if_umb.c:1.24	Sun Apr 17 13:17:56 2022
+++ src/sys/dev/usb/if_umb.c	Sat Aug 20 11:32:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_umb.c,v 1.24 2022/04/17 13:17:56 riastradh Exp $ */
+/*	$NetBSD: if_umb.c,v 1.25 2022/08/20 11:32:08 riastradh Exp $ */
 /*	$OpenBSD: if_umb.c,v 1.20 2018/09/10 17:00:45 gerhard Exp $ */
 
 /*
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.24 2022/04/17 13:17:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.25 2022/08/20 11:32:08 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2061,18 +2061,11 @@ fail:
 Static usbd_status
 umb_send_encap_command(struct umb_softc *sc, void *data, int len)
 {
-	struct usbd_xfer *xfer;
 	usb_device_request_t req;
-	char *buf;
 
 	if (len > sc->sc_ctrl_len)
 		return USBD_INVAL;
 
-	if (usbd_create_xfer(sc->sc_udev->ud_pipe0, len, 0, 0, ) != 0)
-		return USBD_NOMEM;
-	buf = usbd_get_buffer(xfer);
-	memcpy(buf, data, len);
-
 	/* XXX FIXME: if (total len > sc->sc_ctrl_len) => must fragment */
 	req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
 	req.bRequest = UCDC_SEND_ENCAPSULATED_COMMAND;
@@ -2080,7 +2073,7 @@ umb_send_encap_command(struct umb_softc 
 	USETW(req.wIndex, sc->sc_ctrl_ifaceno);
 	USETW(req.wLength, len);
 	DELAY(umb_delay);
-	return usbd_request_async(sc->sc_udev, xfer, , NULL, NULL);
+	return usbd_do_request(sc->sc_udev, , data);
 }
 
 Static int



CVS commit: src/sys/dev/usb

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:32:08 UTC 2022

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

Log Message:
umb(4): Use usbd_do_request as drivers are intended to do.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/usb/if_umb.c

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



CVS commit: src/sys/dev/ic

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:31:39 UTC 2022

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

Log Message:
nvme(4): Read cqe flags and cid in that order.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/ic/nvme.c

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

Modified files:

Index: src/sys/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.63 src/sys/dev/ic/nvme.c:1.64
--- src/sys/dev/ic/nvme.c:1.63	Mon Aug 15 10:15:59 2022
+++ src/sys/dev/ic/nvme.c	Sat Aug 20 11:31:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.63 2022/08/15 10:15:59 riastradh Exp $	*/
+/*	$NetBSD: nvme.c,v 1.64 2022/08/20 11:31:38 riastradh Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.63 2022/08/15 10:15:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.64 2022/08/20 11:31:38 riastradh Exp $");
 
 #include 
 #include 
@@ -1508,6 +1508,14 @@ nvme_q_complete(struct nvme_softc *sc, s
 		if ((flags & NVME_CQE_PHASE) != q->q_cq_phase)
 			break;
 
+		/*
+		 * Make sure we have read the flags _before_ we read
+		 * the cid.  Otherwise the CPU might speculatively read
+		 * the cid before the entry has been assigned to our
+		 * phase.
+		 */
+		nvme_dmamem_sync(sc, q->q_cq_dmamem, BUS_DMASYNC_POSTREAD);
+
 		ccb = >q_ccbs[lemtoh16(>cid)];
 
 		if (++q->q_cq_head >= q->q_entries) {



CVS commit: src/sys/dev/ic

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:31:39 UTC 2022

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

Log Message:
nvme(4): Read cqe flags and cid in that order.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/ic/nvme.c

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



CVS commit: src/sys/sys

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:27:09 UTC 2022

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

Log Message:
sys/uuid.h: sys/stdint.h suffices for uintN_t.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/sys/uuid.h

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



CVS commit: src/sys/sys

2022-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 20 11:27:09 UTC 2022

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

Log Message:
sys/uuid.h: sys/stdint.h suffices for uintN_t.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/sys/uuid.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/uuid.h
diff -u src/sys/sys/uuid.h:1.7 src/sys/sys/uuid.h:1.8
--- src/sys/sys/uuid.h:1.7	Fri Aug 19 12:49:55 2022
+++ src/sys/sys/uuid.h	Sat Aug 20 11:27:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uuid.h,v 1.7 2022/08/19 12:49:55 riastradh Exp $	*/
+/*	$NetBSD: uuid.h,v 1.8 2022/08/20 11:27:09 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2002 Marcel Moolenaar
@@ -32,7 +32,7 @@
 #define	_SYS_UUID_H_
 
 #include 
-#include 
+#include 
 
 /* Length of a node address (an IEEE 802 address). */
 #define	_UUID_NODE_LEN		6



  1   2   >