CVS commit: src/sys/arch/powerpc/fpu

2022-09-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep 14 05:55:08 UTC 2022

Modified Files:
src/sys/arch/powerpc/fpu: fpu_implode.c

Log Message:
Fix logic for FPSCR[OX]; set FPSCR[FI] (and therefore FPSCR[XX]).


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/powerpc/fpu/fpu_implode.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/powerpc/fpu/fpu_implode.c
diff -u src/sys/arch/powerpc/fpu/fpu_implode.c:1.23 src/sys/arch/powerpc/fpu/fpu_implode.c:1.24
--- src/sys/arch/powerpc/fpu/fpu_implode.c:1.23	Wed Sep 14 05:54:07 2022
+++ src/sys/arch/powerpc/fpu/fpu_implode.c	Wed Sep 14 05:55:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu_implode.c,v 1.23 2022/09/14 05:54:07 rin Exp $ */
+/*	$NetBSD: fpu_implode.c,v 1.24 2022/09/14 05:55:08 rin Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu_implode.c,v 1.23 2022/09/14 05:54:07 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_implode.c,v 1.24 2022/09/14 05:55:08 rin Exp $");
 
 #include 
 #include 
@@ -416,7 +416,7 @@ fpu_ftos(struct fpemu *fe, struct fpn *f
 	if (round(fe, fp, cx) && fp->fp_mant[3] == SNG_EXP(2))
 		exp++;
 	if (exp >= SNG_EXP_INFNAN) {
-		*cx |= FPSCR_OX;
+		*cx |= FPSCR_OX | FPSCR_FI;
 		/* overflow to inf or to max single */
 		if (toinf(fe, sign)) {
 			*cx |= FPRF_SIGN(sign) | FPSCR_FU;
@@ -486,7 +486,7 @@ fpu_ftod(struct fpemu *fe, struct fpn *f
 	if (round(fe, fp, cx) && fp->fp_mant[2] == DBL_EXP(2))
 		exp++;
 	if (exp >= DBL_EXP_INFNAN) {
-		*cx |= FPSCR_OX;
+		*cx |= FPSCR_OX | FPSCR_FI;
 		/* overflow to inf or to max double */
 		if (toinf(fe, sign)) {
 			*cx |= FPRF_SIGN(sign) | FPSCR_FU;



CVS commit: src/sys/arch/powerpc/fpu

2022-09-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep 14 05:55:08 UTC 2022

Modified Files:
src/sys/arch/powerpc/fpu: fpu_implode.c

Log Message:
Fix logic for FPSCR[OX]; set FPSCR[FI] (and therefore FPSCR[XX]).


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/powerpc/fpu/fpu_implode.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/powerpc/fpu

2022-09-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep 14 05:54:07 UTC 2022

Modified Files:
src/sys/arch/powerpc/fpu: fpu_implode.c

Log Message:
Fix logic for FPSCR[UX]:
- Correct FPSCR[FPRF] field when round to 0.0 or 0.0f.
- Simplify.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/powerpc/fpu/fpu_implode.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/powerpc/fpu

2022-09-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep 14 05:54:07 UTC 2022

Modified Files:
src/sys/arch/powerpc/fpu: fpu_implode.c

Log Message:
Fix logic for FPSCR[UX]:
- Correct FPSCR[FPRF] field when round to 0.0 or 0.0f.
- Simplify.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/powerpc/fpu/fpu_implode.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/powerpc/fpu/fpu_implode.c
diff -u src/sys/arch/powerpc/fpu/fpu_implode.c:1.22 src/sys/arch/powerpc/fpu/fpu_implode.c:1.23
--- src/sys/arch/powerpc/fpu/fpu_implode.c:1.22	Sun Sep  4 13:17:33 2022
+++ src/sys/arch/powerpc/fpu/fpu_implode.c	Wed Sep 14 05:54:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu_implode.c,v 1.22 2022/09/04 13:17:33 rin Exp $ */
+/*	$NetBSD: fpu_implode.c,v 1.23 2022/09/14 05:54:07 rin Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu_implode.c,v 1.22 2022/09/04 13:17:33 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_implode.c,v 1.23 2022/09/14 05:54:07 rin Exp $");
 
 #include 
 #include 
@@ -397,10 +397,14 @@ fpu_ftos(struct fpemu *fe, struct fpn *f
 			*cx |= FPRF_SIGN(sign);
 			return (sign | SNG_EXP(1) | 0);
 		}
-		*cx |= FPSCR_C | FPRF_SIGN(sign);
-		if (((fe->fe_cx | *cx) & FPSCR_FI) ||
-		(fe->fe_fpscr & FPSCR_UX))
+		if (*cx & FPSCR_FI) {
 			*cx |= FPSCR_UX;
+			if (fp->fp_mant[3] == 0) {
+*cx |= FPSCR_FE;
+return sign;
+			}
+		}
+		*cx |= FPSCR_C | FPRF_SIGN(sign);
 		return (sign | SNG_EXP(0) | fp->fp_mant[3]);
 	}
 	/* -FP_NG for g,r; -1 for implied 1; -SNG_FRACBITS for fraction */
@@ -466,10 +470,15 @@ fpu_ftod(struct fpemu *fe, struct fpn *f
 			*cx |= FPRF_SIGN(sign);
 			return HI_WORD(sign | DBL_EXP(1) | 0);
 		}
-		*cx |= FPSCR_C | FPRF_SIGN(sign);
-		if (((fe->fe_cx | *cx) & FPSCR_FI) ||
-		(fe->fe_fpscr & FPSCR_UX))
+		if (*cx & FPSCR_FI) {
 			*cx |= FPSCR_UX;
+			if ((fp->fp_mant[2] & DBL_MASK) == 0 &&
+			 fp->fp_mant[3] == 0) {
+*cx |= FPSCR_FE;
+return HI_WORD(sign);
+			}
+		}
+		*cx |= FPSCR_C | FPRF_SIGN(sign);
 		exp = 0;
 		goto done;
 	}



CVS commit: src/sys/dev/pci

2022-09-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep 14 01:05:43 UTC 2022

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

Log Message:
mfii: Don't panic on detach.

 Call sysmon_envsys_destroy() and clear sc->sc_sme to NULL if
sysmon_envsys_register failed.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/mfii.c

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

Modified files:

Index: src/sys/dev/pci/mfii.c
diff -u src/sys/dev/pci/mfii.c:1.26 src/sys/dev/pci/mfii.c:1.27
--- src/sys/dev/pci/mfii.c:1.26	Sat Jul 16 07:23:51 2022
+++ src/sys/dev/pci/mfii.c	Wed Sep 14 01:05:42 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mfii.c,v 1.26 2022/07/16 07:23:51 msaitoh Exp $ */
+/* $NetBSD: mfii.c,v 1.27 2022/09/14 01:05:42 msaitoh Exp $ */
 /* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.26 2022/07/16 07:23:51 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.27 2022/09/14 01:05:42 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -3982,6 +3982,8 @@ mfii_create_sensors(struct mfii_softc *s
 	if (rv) {
 		aprint_error_dev(sc->sc_dev,
 		"unable to register with sysmon (rv = %d)\n", rv);
+		sysmon_envsys_destroy(sc->sc_sme);
+		sc->sc_sme = NULL;
 	}
 	return rv;
 



CVS commit: src/sys/dev/pci

2022-09-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep 14 01:05:43 UTC 2022

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

Log Message:
mfii: Don't panic on detach.

 Call sysmon_envsys_destroy() and clear sc->sc_sme to NULL if
sysmon_envsys_register failed.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/mfii.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/nvmm

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 20:10:04 UTC 2022

Modified Files:
src/sys/dev/nvmm: nvmm.c nvmm_internal.h
src/sys/dev/nvmm/x86: nvmm_x86_vmx.c

Log Message:
nvmm(4): Add suspend/resume support.

New MD nvmm_impl callbacks:

- .suspend_interrupt forces all VMs on all physical CPUs to exit.
- .vcpu_suspend suspends an individual vCPU on a machine.
- .machine_suspend suspends an individual machine.
- .suspend suspends the whole system.
- .resume resumes the whole system.
- .machine_resume resumes an individual machine.
- .vcpu_resume resumes an indidivudal vCPU on a machine.

Suspending nvmm:

1. causes new VM operations (ioctl and close) to block until resumed,
2. uses .suspend_interrupt to interrupt any concurrent and force them
   to return early, and then
3. uses the various suspend callbacks to suspend all vCPUs, machines,
   and the whole system -- all vCPUs before the machine they're on,
   and all machines before the system.

Resuming nvmm does the reverse of (3) -- resume system, resume each
machine and then the vCPUs on that machine -- and then unblocks
operations.

Implemented only for x86-vmx for now:

- suspend_interrupt triggers a TLB IPI to cause VM exits;
- vcpu_suspend issues VMCLEAR to force any in-CPU state to be written
  to memory;
- machine_suspend does nothing;
- suspend does VMXOFF on all CPUs;
- resume does VMXON on all CPUs;
- machine_resume does nothing; and
- vcpu_resume just marks each vCPU as valid but inactive so
  subsequent use will clear it and load it with vmptrld.

x86-svm left as an exercise for the reader.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/nvmm/nvmm.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/nvmm/nvmm_internal.h
cvs rdiff -u -r1.84 -r1.85 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/dev/nvmm/nvmm.c
diff -u src/sys/dev/nvmm/nvmm.c:1.46 src/sys/dev/nvmm/nvmm.c:1.47
--- src/sys/dev/nvmm/nvmm.c:1.46	Thu Jul  7 23:50:33 2022
+++ src/sys/dev/nvmm/nvmm.c	Tue Sep 13 20:10:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm.c,v 1.46 2022/07/07 23:50:33 pgoyette Exp $	*/
+/*	$NetBSD: nvmm.c,v 1.47 2022/09/13 20:10:04 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.46 2022/07/07 23:50:33 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.47 2022/09/13 20:10:04 riastradh Exp $");
 
 #include 
 #include 
@@ -59,6 +59,15 @@ __KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.4
 static struct nvmm_machine machines[NVMM_MAX_MACHINES];
 static volatile unsigned int nmachines __cacheline_aligned;
 
+static struct {
+	kmutex_t	lock;
+	kcondvar_t	suspendcv;
+	kcondvar_t	resumecv;
+	unsigned	users;
+} suspension;
+
+volatile bool nvmm_suspending;
+
 static const struct nvmm_impl *nvmm_impl_list[] = {
 #if defined(__x86_64__)
 	_x86_svm,	/* x86 AMD SVM */
@@ -73,6 +82,50 @@ static struct nvmm_owner root_owner;
 /* -- */
 
 static int
+nvmm_enter_sig(void)
+{
+	int error;
+
+	mutex_enter();
+	while (nvmm_suspending) {
+		error = cv_wait_sig(, );
+		if (error)
+			goto out;
+	}
+	KASSERT(suspension.users < UINT_MAX);
+	suspension.users++;
+	error = 0;
+out:	mutex_exit();
+
+	return 0;
+}
+
+static void
+nvmm_enter(void)
+{
+
+	mutex_enter();
+	while (nvmm_suspending)
+		cv_wait(, );
+	KASSERT(suspension.users < UINT_MAX);
+	suspension.users++;
+	mutex_exit();
+}
+
+static void
+nvmm_exit(void)
+{
+
+	mutex_enter();
+	KASSERT(suspension.users > 0);
+	if (--suspension.users == 0)
+		cv_signal();
+	mutex_exit();
+}
+
+/* -- */
+
+static int
 nvmm_machine_alloc(struct nvmm_machine **ret)
 {
 	struct nvmm_machine *mach;
@@ -989,6 +1042,11 @@ nvmm_init(void)
 		}
 	}
 
+	mutex_init(, MUTEX_DEFAULT, IPL_NONE);
+	cv_init(, "nvmmsus");
+	cv_init(, "nvmmres");
+	suspension.users = 0;
+
 	(*nvmm_impl->init)();
 
 	return 0;
@@ -1080,7 +1138,11 @@ nvmm_close(file_t *fp)
 	struct nvmm_owner *owner = fp->f_data;
 
 	KASSERT(owner != NULL);
+
+	nvmm_enter();
 	nvmm_kill_machines(owner);
+	nvmm_exit();
+
 	if (owner != _owner) {
 		kmem_free(owner, sizeof(*owner));
 	}
@@ -1126,7 +1188,7 @@ nvmm_mmap(file_t *fp, off_t *offp, size_
 }
 
 static int
-nvmm_ioctl(file_t *fp, u_long cmd, void *data)
+nvmm_ioctl_internal(file_t *fp, u_long cmd, void *data)
 {
 	struct nvmm_owner *owner = fp->f_data;
 
@@ -1170,11 +1232,27 @@ nvmm_ioctl(file_t *fp, u_long cmd, void 
 	}
 }
 
+static int
+nvmm_ioctl(struct file *fp, u_long cmd, void *data)
+{
+	int error;
+
+	error = nvmm_enter_sig();
+	if (error)
+		return error;
+	error = nvmm_ioctl_internal(fp, cmd, data);
+	nvmm_exit();
+
+	return error;
+}
+
 /* 

CVS commit: src/sys/dev/nvmm

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 20:10:04 UTC 2022

Modified Files:
src/sys/dev/nvmm: nvmm.c nvmm_internal.h
src/sys/dev/nvmm/x86: nvmm_x86_vmx.c

Log Message:
nvmm(4): Add suspend/resume support.

New MD nvmm_impl callbacks:

- .suspend_interrupt forces all VMs on all physical CPUs to exit.
- .vcpu_suspend suspends an individual vCPU on a machine.
- .machine_suspend suspends an individual machine.
- .suspend suspends the whole system.
- .resume resumes the whole system.
- .machine_resume resumes an individual machine.
- .vcpu_resume resumes an indidivudal vCPU on a machine.

Suspending nvmm:

1. causes new VM operations (ioctl and close) to block until resumed,
2. uses .suspend_interrupt to interrupt any concurrent and force them
   to return early, and then
3. uses the various suspend callbacks to suspend all vCPUs, machines,
   and the whole system -- all vCPUs before the machine they're on,
   and all machines before the system.

Resuming nvmm does the reverse of (3) -- resume system, resume each
machine and then the vCPUs on that machine -- and then unblocks
operations.

Implemented only for x86-vmx for now:

- suspend_interrupt triggers a TLB IPI to cause VM exits;
- vcpu_suspend issues VMCLEAR to force any in-CPU state to be written
  to memory;
- machine_suspend does nothing;
- suspend does VMXOFF on all CPUs;
- resume does VMXON on all CPUs;
- machine_resume does nothing; and
- vcpu_resume just marks each vCPU as valid but inactive so
  subsequent use will clear it and load it with vmptrld.

x86-svm left as an exercise for the reader.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/nvmm/nvmm.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/nvmm/nvmm_internal.h
cvs rdiff -u -r1.84 -r1.85 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/dev/iscsi

2022-09-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Sep 13 13:09:16 UTC 2022

Modified Files:
src/sys/dev/iscsi: iscsi_globals.h iscsi_ioctl.c iscsi_main.c
iscsi_rcv.c iscsi_send.c iscsi_utils.c

Log Message:
kill_session now uses the session id to avoid stale session pointers.
protect network socket with rwlock to handle recconnects.
always take over socket from iscsid to prevent leaks.
keep a good connection alive.
don't forget child device when config_detach fails.
fix locking when reassigning CCBs.
pducount is protected by lock, no need for atomic.
some code rework, refined debug messages.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/iscsi/iscsi_globals.h
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/iscsi/iscsi_ioctl.c
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/iscsi/iscsi_main.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/iscsi/iscsi_rcv.c
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/iscsi/iscsi_send.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/iscsi/iscsi_utils.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/iscsi/iscsi_globals.h
diff -u src/sys/dev/iscsi/iscsi_globals.h:1.26 src/sys/dev/iscsi/iscsi_globals.h:1.27
--- src/sys/dev/iscsi/iscsi_globals.h:1.26	Sun Jun 21 23:08:16 2020
+++ src/sys/dev/iscsi/iscsi_globals.h	Tue Sep 13 13:09:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_globals.h,v 1.26 2020/06/21 23:08:16 chs Exp $	*/
+/*	$NetBSD: iscsi_globals.h,v 1.27 2022/09/13 13:09:16 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -37,6 +37,8 @@
 /* Includes we need in all files */
 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -354,6 +356,8 @@ struct connection_s {
 
 	struct lwp			*c_threadobj;
 		/* proc/thread pointer of socket owner */
+
+	krwlock_t			c_sock_rw;
 	struct file			*c_sock;	/* the connection's socket */
 	session_t			*c_session;
 	/* back pointer to the owning session */
@@ -366,7 +370,7 @@ struct connection_s {
 	intc_recover; /* recovery count */
 		/* (reset on first successful data transfer) */
 	volatile unsigned		c_usecount; /* number of active CCBs */
-	volatile unsigned		c_pducount; /* number of active PDUs */
+	unsigned			c_pducount; /* number of active PDUs */
 
 	boolc_destroy; /* conn will be destroyed */
 	boolc_in_session;
@@ -537,8 +541,8 @@ extern bool iscsi_hex_bignums;	/* Whethe
 #define DEBOUT(x) printf x
 #define DEB(lev,x) { if (iscsi_debug_level >= lev) printf x ;}
 #define DEBC(conn,lev,x) { if (iscsi_debug_level >= lev) { printf("S%dC%d: ", \
-conn ? conn->c_session->s_id : -1, \
-conn ? conn->c_id : -1); printf x ;}}
+			conn && conn->c_session ? conn->c_session->s_id : -1, \
+			conn ? conn->c_id : -1); printf x ;}}
 
 #define STATIC static
 
@@ -646,7 +650,7 @@ void iscsi_notify_cleanup(void);
 void add_event(iscsi_event_t, uint32_t, uint32_t, uint32_t);
 
 void kill_connection(connection_t *, uint32_t, int, bool);
-void kill_session(session_t *, uint32_t, int, bool);
+void kill_session(uint32_t, uint32_t, int, bool);
 int kill_all_sessions(void);
 void handle_connection_error(connection_t *, uint32_t, int);
 void add_connection_cleanup(connection_t *);

Index: src/sys/dev/iscsi/iscsi_ioctl.c
diff -u src/sys/dev/iscsi/iscsi_ioctl.c:1.32 src/sys/dev/iscsi/iscsi_ioctl.c:1.33
--- src/sys/dev/iscsi/iscsi_ioctl.c:1.32	Sun Jun 21 23:08:16 2020
+++ src/sys/dev/iscsi/iscsi_ioctl.c	Tue Sep 13 13:09:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_ioctl.c,v 1.32 2020/06/21 23:08:16 chs Exp $	*/
+/*	$NetBSD: iscsi_ioctl.c,v 1.33 2022/09/13 13:09:16 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -494,8 +494,8 @@ kill_connection(connection_t *conn, uint
 	if (recover &&
 	!conn->c_destroy &&
 	conn->c_recover > MAX_RECOVERY_ATTEMPTS) {
-		DEBC(conn, 1,
-			  ("Kill_connection: Too many recovery attempts, destroying\n"));
+		DEBC(conn, 1, ("Kill_connection: Too many recovery attempts, "
+		   "destroying\n"));
 		conn->c_destroy = TRUE;
 	}
 
@@ -547,6 +547,8 @@ kill_connection(connection_t *conn, uint
 			}
 			mutex_exit(_cleanup_mtx);
 
+			DEBC(conn, 1, ("Send_logout for reason %d\n", logout));
+
 			connection_timeout_start(conn, CONNECTION_TIMEOUT);
 
 			if (!send_logout(conn, conn, logout, FALSE)) {
@@ -591,14 +593,24 @@ done:
  */
 
 void
-kill_session(session_t *sess, uint32_t status, int logout, bool recover)
+kill_session(uint32_t sid, uint32_t status, int logout, bool recover)
 {
+	session_t *sess;
 	connection_t *conn;
 
 	DEB(1, ("ISCSI: kill_session %d, status %d, logout %d, recover %d\n",
-			sess->s_id, status, logout, recover));
+			sid, status, logout, recover));
 
 	mutex_enter(_cleanup_mtx);
+
+	sess = find_session(sid);
+	if (sess == NULL) {
+		mutex_exit(_cleanup_mtx);
+
+		DEB(5, ("Session %u already gone\n", sid));
+		return;
+	}
+
 	if (sess->s_terminating) 

CVS commit: src/sys/dev/iscsi

2022-09-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Sep 13 13:09:16 UTC 2022

Modified Files:
src/sys/dev/iscsi: iscsi_globals.h iscsi_ioctl.c iscsi_main.c
iscsi_rcv.c iscsi_send.c iscsi_utils.c

Log Message:
kill_session now uses the session id to avoid stale session pointers.
protect network socket with rwlock to handle recconnects.
always take over socket from iscsid to prevent leaks.
keep a good connection alive.
don't forget child device when config_detach fails.
fix locking when reassigning CCBs.
pducount is protected by lock, no need for atomic.
some code rework, refined debug messages.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/iscsi/iscsi_globals.h
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/iscsi/iscsi_ioctl.c
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/iscsi/iscsi_main.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/iscsi/iscsi_rcv.c
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/iscsi/iscsi_send.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/iscsi/iscsi_utils.c

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



CVS commit: src/sys/dev/pci

2022-09-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 13 11:47:54 UTC 2022

Modified Files:
src/sys/dev/pci: hdaudio_pci.c ichsmb.c

Log Message:
Add Intel 600 series PCH-LP devices support.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/hdaudio_pci.c
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pci/ichsmb.c

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

Modified files:

Index: src/sys/dev/pci/hdaudio_pci.c
diff -u src/sys/dev/pci/hdaudio_pci.c:1.12 src/sys/dev/pci/hdaudio_pci.c:1.13
--- src/sys/dev/pci/hdaudio_pci.c:1.12	Mon Mar 21 09:12:09 2022
+++ src/sys/dev/pci/hdaudio_pci.c	Tue Sep 13 11:47:54 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio_pci.c,v 1.12 2022/03/21 09:12:09 jmcneill Exp $ */
+/* $NetBSD: hdaudio_pci.c,v 1.13 2022/09/13 11:47:54 msaitoh Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd 
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hdaudio_pci.c,v 1.12 2022/03/21 09:12:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio_pci.c,v 1.13 2022/09/13 11:47:54 msaitoh Exp $");
 
 #include 
 #include 
@@ -95,6 +95,7 @@ static const struct device_compatible_en
 	{ .id = PCI_ID_CODE(PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_HDA) },
 	{ .id = PCI_ID_CODE(PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_CAVS) },
 	{ .id = PCI_ID_CODE(PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_HDA) },
+	{ .id = PCI_ID_CODE(PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_HDA) },
 	{ .id = PCI_ID_CODE(PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_CAVS) },
 
 	PCI_COMPAT_EOL

Index: src/sys/dev/pci/ichsmb.c
diff -u src/sys/dev/pci/ichsmb.c:1.76 src/sys/dev/pci/ichsmb.c:1.77
--- src/sys/dev/pci/ichsmb.c:1.76	Tue Jan 25 16:07:57 2022
+++ src/sys/dev/pci/ichsmb.c	Tue Sep 13 11:47:54 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichsmb.c,v 1.76 2022/01/25 16:07:57 msaitoh Exp $	*/
+/*	$NetBSD: ichsmb.c,v 1.77 2022/09/13 11:47:54 msaitoh Exp $	*/
 /*	$OpenBSD: ichiic.c,v 1.44 2020/10/07 11:23:05 jsg Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.76 2022/01/25 16:07:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.77 2022/09/13 11:47:54 msaitoh Exp $");
 
 #include 
 #include 
@@ -154,6 +154,7 @@ ichsmb_match(device_t parent, cfdata_t m
 		case PCI_PRODUCT_INTEL_5HS_H_SMB:
 		case PCI_PRODUCT_INTEL_5HS_LP_SMB:
 		case PCI_PRODUCT_INTEL_6HS_H_SMB:
+		case PCI_PRODUCT_INTEL_6HS_LP_SMB:
 			return 1;
 		}
 	}



CVS commit: src/sys/dev/pci

2022-09-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 13 11:47:54 UTC 2022

Modified Files:
src/sys/dev/pci: hdaudio_pci.c ichsmb.c

Log Message:
Add Intel 600 series PCH-LP devices support.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/hdaudio_pci.c
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pci/ichsmb.c

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



CVS commit: src/sys/dev/pci

2022-09-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 13 11:46:25 UTC 2022

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.1444 -r1.1445 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1443 -r1.1444 src/sys/dev/pci/pcidevs_data.h

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



CVS commit: src/sys/dev/pci

2022-09-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 13 11:45:52 UTC 2022

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add more Alder Lake devices.


To generate a diff of this commit:
cvs rdiff -u -r1.1461 -r1.1462 src/sys/dev/pci/pcidevs

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

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1461 src/sys/dev/pci/pcidevs:1.1462
--- src/sys/dev/pci/pcidevs:1.1461	Sun Sep 11 08:33:13 2022
+++ src/sys/dev/pci/pcidevs	Tue Sep 13 11:45:52 2022
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1461 2022/09/11 08:33:13 mrg Exp $
+$NetBSD: pcidevs,v 1.1462 2022/09/13 11:45:52 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -5750,17 +5750,27 @@ product INTEL EHL_GPU_32	0x4551	Elkhart 
 product INTEL EHL_DPTF		0x4503	Elkhart Lake DPTF
 product INTEL EHL_GNA		0x4511	Elkhart Lake GNA
 product INTEL EHL_TRACE_2	0x4529	Elkhart Lake Trace Hub (Compute Die)
+product INTEL ADL_U15_2_8_HOST	0x4601	Alder Lake (U15,2+8) Host
+product INTEL ADL_U9_2_8_HOST	0x4602	Alder Lake (U9,2+8) Host
+product INTEL ADL_U15_2_4_HOST	0x4609	Alder Lake (U15,2+4) Host
+product INTEL ADL_U9_2_4_HOST	0x460a	Alder Lake (U9,2+4) Host
 product INTEL ADL_PCIE_RP_0	0x460d	Alder Lake PCIe G5 Root Port 0 (x16)
 product INTEL ADL_XDCI		0x460e	Alder Lake USB-C Device (xDCI)
 product INTEL ADL_S_2_0_HOST	0x4610	Alder Lake (S,2+0) Host
+product INTEL ADL_U15_1_4_HOST	0x4619	Alder Lake (U15,1+4) Host
+product INTEL ADL_U9_1_4_HOST	0x461a	Alder Lake (U9,1+4) Host
 product INTEL ADL_DTT		0x461d	Alder Lake Dynamic Tuning Technology
 product INTEL ADL_XHCI		0x461e	Alder Lake USB-C Host (xHCI)
 product INTEL ADL_TBT_PCIE_3	0x461f	Alder Lake Thunderbolt PCIe 3
 product INTEL ADL_H_4_8_HOST	0x4621	Alder Lake (H,4+8) Host
+product INTEL ADL_HX_4_8_HOST	0x4623	Alder Lake (HX,4+8) Host
+product INTEL ADL_HX_4_4_HOST	0x462b	Alder Lake (HX,4+4) Host
 product INTEL ADL_H_4_4_HOST	0x4629	Alder Lake (H,4+4) Host
 product INTEL ADL_PCIE_RP_1	0x462d	Alder Lake PCIe G5 Root Port 1 (x8)
 product INTEL ADL_TBT_PCIE_2	0x462f	Alder Lake Thunderbolt PCIe 2
 product INTEL ADL_S_4_0_HOST	0x4630	Alder Lake (S,4+0) Host
+product INTEL ADL_HX_8_8_HOST	0x4637	Alder Lake (HX,8+8) Host
+product INTEL ADL_HX_6_8_HOST	0x463b	Alder Lake (HX,6+8) Host
 product INTEL ADL_PCIE_RP_3	0x463d	Alder Lake PCIe G4 Root Port 3 (x4)
 product INTEL ADL_TBTDMA_0	0x463e	Alder Lake Thunderbolt DMA 0
 product INTEL ADL_TBT_PCIE_1	0x463f	Alder Lake Thunderbolt PCIe 1
@@ -5780,11 +5790,17 @@ product INTEL ADL_CLSRAM	0x467d	Alder La
 product INTEL ADL_VMD		0x467f	Alder Lake Volume Management Device
 product INTEL ADL_IGD_1		0x4680	Alder Lake Graphics (32EU)
 product INTEL ADL_IGD_2		0x4682	Alder Lake Graphics (24EU)
+product INTEL ADL_IGD_8		0x4688	Alder Lake Graphics (32EU)
+product INTEL ADL_IGD_9		0x468b	Alder Lake Graphics (16EU)
 product INTEL ADL_IGD_3		0x4690	Alder Lake Graphics (32EU)
 product INTEL ADL_IGD_4		0x4692	Alder Lake Graphics (24EU)
 product INTEL ADL_IGD_5		0x4693	Alder Lake Graphics (16EU)
-product INTEL ADL_IGD_6		0x46a6	Alder Lake Graphics
-product INTEL ADL_IGD_7		0x46a3	Alder Lake Graphics
+product INTEL ADL_IGD_6		0x46a3	Alder Lake Graphics (48EU)
+product INTEL ADL_IGD_7		0x46a6	Alder Lake Graphics
+product INTEL ADL_IGD_10	0x46a8	Alder Lake Graphics
+product INTEL ADL_IGD_11	0x46aa	Alder Lake Graphics
+product INTEL ADL_IGD_12	0x46b3	Alder Lake Graphics
+product INTEL ADL_IGD_13	0x46c3	Alder Lake Graphics
 product INTEL EHL_ESPI		0x4b00	Elkhart Lake eSPI
 product INTEL EHL_P2SB		0x4b20	Elkhart Lake P2SB
 product INTEL EHL_PMC		0x4b21	Elkhart Lake PMC
@@ -5966,6 +5982,56 @@ product INTEL EP80579_RESERVED2	0x503f	E
 product INTEL EP80579_LAN_1	0x5040	EP80579 LAN
 product INTEL EP80579_LAN_2	0x5044	EP80579 LAN
 product INTEL EP80579_LAN_3	0x5048	EP80579 LAN
+product INTEL 6HS_LP_ESPI	0x5182	600 Series PCH-LP eSPI
+product INTEL 6HS_LP_P2SB	0x51a0	600 Series PCH-LP P2SB
+product INTEL 6HS_LP_PMC	0x51a1	600 Series PCH-LP PMC
+product INTEL 6HS_LP_SMB	0x51a3	600 Series PCH-LP SMBus
+product INTEL 6HS_LP_SPI	0x51a4	600 Series PCH-LP SPI (FLASH)
+product INTEL 6HS_LP_TRACE	0x51a6	600 Series PCH-LP Trace Hub
+product INTEL 6HS_LP_UART_0	0x51a8	600 Series PCH-LP UART 0
+product INTEL 6HS_LP_UART_1	0x51a9	600 Series PCH-LP UART 1
+product INTEL 6HS_LP_GSPI_0	0x51aa	600 Series PCH-LP GSPI 0
+product INTEL 6HS_LP_GSIP_1	0x51ab	600 Series PCH-LP GSPI 1
+product INTEL 6HS_LP_PCIE_9	0x51b0	600 Series PCH-LP PCIe RP 9
+product INTEL 6HS_LP_PCIE_10	0x51b1	600 Series PCH-LP PCIe RP 10
+product INTEL 6HS_LP_PCIE_11	0x51b2	600 Series PCH-LP PCIe RP 11
+product INTEL 6HS_LP_PCIE_12	0x51b3	600 Series PCH-LP PCIe RP 12
+product INTEL 6HS_LP_PCIE_1	0x51b8	600 Series PCH-LP PCIe RP 1
+product INTEL 6HS_LP_PCIE_2	0x51b9	600 Series PCH-LP PCIe RP 2
+product INTEL 6HS_LP_PCIE_3	0x51ba	600 Series PCH-LP PCIe RP 3
+product 

CVS commit: src/sys/dev/pci

2022-09-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 13 11:45:52 UTC 2022

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add more Alder Lake devices.


To generate a diff of this commit:
cvs rdiff -u -r1.1461 -r1.1462 src/sys/dev/pci/pcidevs

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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:33:37 UTC 2022

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

Log Message:
xhci(4): After attach, access to sc_child/2 requires sc_intr_lock.

Serializes access with xhci_intr.

XXX Need to ensure the interrupt handler is quiesced at this point or
else it will trip over the assertion in xhci_intr about having at
least one child.


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

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

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.170 src/sys/dev/usb/xhci.c:1.171
--- src/sys/dev/usb/xhci.c:1.170	Tue Sep 13 10:15:28 2022
+++ src/sys/dev/usb/xhci.c	Tue Sep 13 10:33:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.170 2022/09/13 10:15:28 riastradh Exp $	*/
+/*	$NetBSD: xhci.c,v 1.171 2022/09/13 10:33:37 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.170 2022/09/13 10:15:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.171 2022/09/13 10:33:37 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -605,11 +605,13 @@ xhci_childdet(device_t self, device_t ch
 {
 	struct xhci_softc * const sc = device_private(self);
 
+	mutex_enter(>sc_intr_lock);
 	KASSERT((sc->sc_child == child) || (sc->sc_child2 == child));
 	if (child == sc->sc_child2)
 		sc->sc_child2 = NULL;
 	else if (child == sc->sc_child)
 		sc->sc_child = NULL;
+	mutex_exit(>sc_intr_lock);
 }
 
 int



CVS commit: src/sys/dev/usb

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:33:37 UTC 2022

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

Log Message:
xhci(4): After attach, access to sc_child/2 requires sc_intr_lock.

Serializes access with xhci_intr.

XXX Need to ensure the interrupt handler is quiesced at this point or
else it will trip over the assertion in xhci_intr about having at
least one child.


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

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



CVS commit: src/sys/dev/usb

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:32:58 UTC 2022

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

Log Message:
usbdi(9): Sprinkle usbhist into usb xfer timeout logic.


To generate a diff of this commit:
cvs rdiff -u -r1.246 -r1.247 src/sys/dev/usb/usbdi.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/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.246 src/sys/dev/usb/usbdi.c:1.247
--- src/sys/dev/usb/usbdi.c:1.246	Tue Sep 13 10:32:41 2022
+++ src/sys/dev/usb/usbdi.c	Tue Sep 13 10:32:58 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.246 2022/09/13 10:32:41 riastradh Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.247 2022/09/13 10:32:58 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.246 2022/09/13 10:32:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.247 2022/09/13 10:32:58 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1510,6 +1510,10 @@ usbd_xfer_trycomplete(struct usbd_xfer *
 
 	KASSERT(bus->ub_usepolling || mutex_owned(bus->ub_lock));
 
+	USBHIST_FUNC();
+	USBHIST_CALLARGS(usbdebug, "xfer %#jx status %jd",
+	(uintptr_t)xfer, xfer->ux_status, 0, 0);
+
 	/*
 	 * If software has completed it, either by synchronous abort or
 	 * by timeout, too late.
@@ -1547,6 +1551,10 @@ usbd_xfer_abort(struct usbd_xfer *xfer)
 
 	KASSERT(mutex_owned(bus->ub_lock));
 
+	USBHIST_FUNC();
+	USBHIST_CALLARGS(usbdebug, "xfer %#jx status %jd",
+	(uintptr_t)xfer, xfer->ux_status, 0, 0);
+
 	/*
 	 * If host controller interrupt or timer interrupt has
 	 * completed it, too late.  But the xfer cannot be
@@ -1594,13 +1602,23 @@ usbd_xfer_timeout(void *cookie)
 	/* Acquire the lock so we can transition the timeout state.  */
 	mutex_enter(bus->ub_lock);
 
+	USBHIST_FUNC();
+	USBHIST_CALLARGS(usbdebug, "xfer %#jx status %jd",
+	(uintptr_t)xfer, xfer->ux_status, 0, 0);
+
 	/*
 	 * Use usbd_xfer_probe_timeout to check whether the timeout is
 	 * still valid, or to reschedule the callout if necessary.  If
 	 * it is still valid, schedule the task.
 	 */
-	if (usbd_xfer_probe_timeout(xfer))
+	if (usbd_xfer_probe_timeout(xfer)) {
+		USBHIST_LOG(usbdebug, "xfer %#jx schedule timeout task",
+		(uintptr_t)xfer, 0, 0, 0);
 		usb_add_task(dev, >ux_aborttask, USB_TASKQ_HC);
+	} else {
+		USBHIST_LOG(usbdebug, "xfer %#jx timeout cancelled",
+		(uintptr_t)xfer, 0, 0, 0);
+	}
 
 	/*
 	 * Notify usbd_xfer_cancel_timeout_async that we may have
@@ -1631,6 +1649,10 @@ usbd_xfer_timeout_task(void *cookie)
 	/* Acquire the lock so we can transition the timeout state.  */
 	mutex_enter(bus->ub_lock);
 
+	USBHIST_FUNC();
+	USBHIST_CALLARGS(usbdebug, "xfer %#jx status %jd",
+	(uintptr_t)xfer, xfer->ux_status, 0, 0);
+
 	/*
 	 * Use usbd_xfer_probe_timeout to check whether the timeout is
 	 * still valid, or to reschedule the callout if necessary.  If
@@ -1638,8 +1660,11 @@ usbd_xfer_timeout_task(void *cookie)
 	 * cancelled, or the xfer has already been resubmitted -- then
 	 * we're done here.
 	 */
-	if (!usbd_xfer_probe_timeout(xfer))
+	if (!usbd_xfer_probe_timeout(xfer)) {
+		USBHIST_LOG(usbdebug, "xfer %#jx timeout cancelled",
+		(uintptr_t)xfer, 0, 0, 0);
 		goto out;
+	}
 
 	/*
 	 * After this point, no further timeout probing will happen for
@@ -1656,14 +1681,19 @@ usbd_xfer_timeout_task(void *cookie)
 	 * no need to timeout.
 	 */
 	KASSERT(xfer->ux_status != USBD_TIMEOUT);
-	if (xfer->ux_status != USBD_IN_PROGRESS)
+	if (xfer->ux_status != USBD_IN_PROGRESS) {
+		USBHIST_LOG(usbdebug, "xfer %#jx timeout raced",
+		(uintptr_t)xfer, 0, 0, 0);
 		goto out;
+	}
 
 	/*
 	 * We beat everyone else.  Claim the status as timed out, do
 	 * the bus-specific dance to abort the hardware, and complete
 	 * the xfer.
 	 */
+	USBHIST_LOG(usbdebug, "xfer %#jx timed out",
+	(uintptr_t)xfer, 0, 0, 0);
 	xfer->ux_status = USBD_TIMEOUT;
 	bus->ub_methods->ubm_abortx(xfer);
 	usb_transfer_complete(xfer);
@@ -1686,6 +1716,12 @@ usbd_xfer_probe_timeout(struct usbd_xfer
 	struct usbd_bus *bus = xfer->ux_bus;
 	bool valid;
 
+	USBHIST_FUNC();
+	USBHIST_CALLARGS(usbdebug, "xfer %#jx timeout %jdms"
+	" set %jd reset %jd",
+	(uintptr_t)xfer, xfer->ux_timeout,
+	xfer->ux_timeout_set, xfer->ux_timeout_reset);
+
 	KASSERT(bus->ub_usepolling || mutex_owned(bus->ub_lock));
 
 	/* The timeout must be set.  */
@@ -1701,6 +1737,8 @@ usbd_xfer_probe_timeout(struct usbd_xfer
 	/* There are a few cases... */
 	if (bus->ub_methods->ubm_dying(bus)) {
 		/* Host controller dying.  Drop it all on the floor.  */
+		USBHIST_LOG(usbdebug, "xfer %#jx bus dying, not rescheduling",
+		(uintptr_t)xfer, 0, 0, 0);
 		xfer->ux_timeout_set = false;
 		xfer->ux_timeout_reset = false;
 		valid = false;
@@ -1713,11 +1751,17 @@ usbd_xfer_probe_timeout(struct usbd_xfer
 		 

CVS commit: src/sys/dev/usb

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:32:58 UTC 2022

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

Log Message:
usbdi(9): Sprinkle usbhist into usb xfer timeout logic.


To generate a diff of this commit:
cvs rdiff -u -r1.246 -r1.247 src/sys/dev/usb/usbdi.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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:32:41 UTC 2022

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

Log Message:
usbdi(9): Fix mistake in usbdi.c 1.244.

Need to clear ux_timeout_set only when we finally actually process
the timeout in usbdi_xfer_timeout_task, not in the callout which
schedules the task which asserts that the timeout is still set on
entry.

Must've exported the wrong version of my change from git.


To generate a diff of this commit:
cvs rdiff -u -r1.245 -r1.246 src/sys/dev/usb/usbdi.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/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.245 src/sys/dev/usb/usbdi.c:1.246
--- src/sys/dev/usb/usbdi.c:1.245	Tue Sep 13 09:47:17 2022
+++ src/sys/dev/usb/usbdi.c	Tue Sep 13 10:32:41 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.245 2022/09/13 09:47:17 riastradh Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.246 2022/09/13 10:32:41 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.245 2022/09/13 09:47:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.246 2022/09/13 10:32:41 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1642,6 +1642,15 @@ usbd_xfer_timeout_task(void *cookie)
 		goto out;
 
 	/*
+	 * After this point, no further timeout probing will happen for
+	 * the current incarnation of the timeout, so make the next
+	 * usbd_xfer_schedule_timout schedule a new callout.
+	 * usbd_xfer_probe_timeout has already processed any reset.
+	 */
+	KASSERT(!xfer->ux_timeout_reset);
+	xfer->ux_timeout_set = false;
+
+	/*
 	 * May have completed or been aborted, but we're the only one
 	 * who can time it out.  If it has completed or been aborted,
 	 * no need to timeout.
@@ -1683,15 +1692,6 @@ usbd_xfer_probe_timeout(struct usbd_xfer
 	KASSERT(xfer->ux_timeout_set);
 
 	/*
-	 * After this point, no further timeout probing will happen for
-	 * the current incarnation of the timeout, so make the next
-	 * usbd_xfer_schedule_timout schedule a new callout.
-	 * usbd_xfer_probe_timeout has already processed any reset.
-	 */
-	KASSERT(!xfer->ux_timeout_reset);
-	xfer->ux_timeout_set = false;
-
-	/*
 	 * Neither callout nor task may be pending; they execute
 	 * alternately in lock step.
 	 */



CVS commit: src/sys/dev/usb

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:32:41 UTC 2022

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

Log Message:
usbdi(9): Fix mistake in usbdi.c 1.244.

Need to clear ux_timeout_set only when we finally actually process
the timeout in usbdi_xfer_timeout_task, not in the callout which
schedules the task which asserts that the timeout is still set on
entry.

Must've exported the wrong version of my change from git.


To generate a diff of this commit:
cvs rdiff -u -r1.245 -r1.246 src/sys/dev/usb/usbdi.c

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



CVS commit: src/libexec/ld.elf_so

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:18:58 UTC 2022

Modified Files:
src/libexec/ld.elf_so: rtld.c

Log Message:
ld.elf_so(8): Make fork take a shared, not exclusive, lock.

We only need to ensure that there are no concurrent modifications to
the rtld data structures in flight, since the threads that began
those modifications will not exist in the child and will therefore be
unable to complete them in the child.

A shared lock suffices to ensure there are no such concurrent
modifications in flight; an exclusive lock is not necessary, and can
cause deadlock if fork is executed from a signal handler, which is
explicitly allowed by POSIX (and our own sigaction(2) man page) which
marks fork as async-signal-safe.

PR lib/56979


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/libexec/ld.elf_so/rtld.c

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

Modified files:

Index: src/libexec/ld.elf_so/rtld.c
diff -u src/libexec/ld.elf_so/rtld.c:1.211 src/libexec/ld.elf_so/rtld.c:1.212
--- src/libexec/ld.elf_so/rtld.c:1.211	Sat Apr  9 23:39:07 2022
+++ src/libexec/ld.elf_so/rtld.c	Tue Sep 13 10:18:58 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.c,v 1.211 2022/04/09 23:39:07 riastradh Exp $	 */
+/*	$NetBSD: rtld.c,v 1.212 2022/09/13 10:18:58 riastradh Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.211 2022/04/09 23:39:07 riastradh Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.212 2022/09/13 10:18:58 riastradh Exp $");
 #endif /* not lint */
 
 #include 
@@ -1539,14 +1539,13 @@ pid_t __fork(void);
 __dso_public pid_t
 __locked_fork(int *my_errno)
 {
-	sigset_t mask;
 	pid_t result;
 
-	_rtld_exclusive_enter();
+	_rtld_shared_enter();
 	result = __fork();
 	if (result == -1)
 		*my_errno = errno;
-	_rtld_exclusive_exit();
+	_rtld_shared_exit();
 
 	return result;
 }



CVS commit: src/libexec/ld.elf_so

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:18:58 UTC 2022

Modified Files:
src/libexec/ld.elf_so: rtld.c

Log Message:
ld.elf_so(8): Make fork take a shared, not exclusive, lock.

We only need to ensure that there are no concurrent modifications to
the rtld data structures in flight, since the threads that began
those modifications will not exist in the child and will therefore be
unable to complete them in the child.

A shared lock suffices to ensure there are no such concurrent
modifications in flight; an exclusive lock is not necessary, and can
cause deadlock if fork is executed from a signal handler, which is
explicitly allowed by POSIX (and our own sigaction(2) man page) which
marks fork as async-signal-safe.

PR lib/56979


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/libexec/ld.elf_so/rtld.c

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



CVS commit: src/lib/libc/gen

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:18:47 UTC 2022

Modified Files:
src/lib/libc/gen: pthread_atfork.c

Log Message:
pthread_atfork(3): Block signals during the call to pthread_atfork.

This doesn't affect the calls to the atfork handlers -- it only
protects access to the lists of handlers from interruption by a
signal, in case the signal handler calls fork(2).


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/gen/pthread_atfork.c

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

Modified files:

Index: src/lib/libc/gen/pthread_atfork.c
diff -u src/lib/libc/gen/pthread_atfork.c:1.16 src/lib/libc/gen/pthread_atfork.c:1.17
--- src/lib/libc/gen/pthread_atfork.c:1.16	Tue May 31 08:43:13 2022
+++ src/lib/libc/gen/pthread_atfork.c	Tue Sep 13 10:18:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread_atfork.c,v 1.16 2022/05/31 08:43:13 andvar Exp $	*/
+/*	$NetBSD: pthread_atfork.c,v 1.17 2022/09/13 10:18:47 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pthread_atfork.c,v 1.16 2022/05/31 08:43:13 andvar Exp $");
+__RCSID("$NetBSD: pthread_atfork.c,v 1.17 2022/09/13 10:18:47 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -101,15 +101,20 @@ pthread_atfork(void (*prepare)(void), vo
 void (*child)(void))
 {
 	struct atfork_callback *newprepare, *newparent, *newchild;
+	sigset_t mask, omask;
+	int error;
 
 	newprepare = newparent = newchild = NULL;
 
+	sigfillset();
+	thr_sigsetmask(SIG_SETMASK, , );
+
 	mutex_lock(_lock);
 	if (prepare != NULL) {
 		newprepare = af_alloc();
 		if (newprepare == NULL) {
-			mutex_unlock(_lock);
-			return ENOMEM;
+			error = ENOMEM;
+			goto out;
 		}
 		newprepare->fn = prepare;
 	}
@@ -119,8 +124,8 @@ pthread_atfork(void (*prepare)(void), vo
 		if (newparent == NULL) {
 			if (newprepare != NULL)
 af_free(newprepare);
-			mutex_unlock(_lock);
-			return ENOMEM;
+			error = ENOMEM;
+			goto out;
 		}
 		newparent->fn = parent;
 	}
@@ -132,8 +137,8 @@ pthread_atfork(void (*prepare)(void), vo
 af_free(newprepare);
 			if (newparent != NULL)
 af_free(newparent);
-			mutex_unlock(_lock);
-			return ENOMEM;
+			error = ENOMEM;
+			goto out;
 		}
 		newchild->fn = child;
 	}
@@ -150,9 +155,11 @@ pthread_atfork(void (*prepare)(void), vo
 		SIMPLEQ_INSERT_TAIL(, newparent, next);
 	if (child)
 		SIMPLEQ_INSERT_TAIL(, newchild, next);
-	mutex_unlock(_lock);
+	error = 0;
 
-	return 0;
+out:	mutex_unlock(_lock);
+	thr_sigsetmask(SIG_SETMASK, , NULL);
+	return error;
 }
 
 pid_t



CVS commit: src/lib/libc/gen

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:18:47 UTC 2022

Modified Files:
src/lib/libc/gen: pthread_atfork.c

Log Message:
pthread_atfork(3): Block signals during the call to pthread_atfork.

This doesn't affect the calls to the atfork handlers -- it only
protects access to the lists of handlers from interruption by a
signal, in case the signal handler calls fork(2).


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/gen/pthread_atfork.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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:15:29 UTC 2022

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

Log Message:
xhci(4): Resume commands even if USBSTS.SRE is set.

Commands might not work after this but let's at least not deadlock --
give them an opportunity to time out or fail.

XXX Maybe set sc_dying here to skip the timeout.


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

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

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.169 src/sys/dev/usb/xhci.c:1.170
--- src/sys/dev/usb/xhci.c:1.169	Thu Sep  1 18:09:45 2022
+++ src/sys/dev/usb/xhci.c	Tue Sep 13 10:15:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.169 2022/09/01 18:09:45 riastradh Exp $	*/
+/*	$NetBSD: xhci.c,v 1.170 2022/09/13 10:15:28 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.169 2022/09/01 18:09:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.170 2022/09/13 10:15:28 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1103,17 +1103,22 @@ xhci_resume(device_t self, const pmf_qua
 		goto out;
 	}
 
-	/* Resume command issuance.  */
+	/* Success!  */
+	ok = true;
+
+out:	/*
+	 * Resume command issuance.  If the hardware failed to resume,
+	 * well, tough -- deadlocking because everything is held up on
+	 * the suspension, with no opportunity to detach, isn't better
+	 * than timing out waiting for dead hardware.
+	 */
 	mutex_enter(>sc_lock);
 	KASSERT(sc->sc_suspender);
 	sc->sc_suspender = NULL;
 	cv_broadcast(>sc_cmdbusy_cv);
 	mutex_exit(>sc_lock);
 
-	/* Success!  */
-	ok = true;
-
-out:	mutex_exit(>sc_rhlock);
+	mutex_exit(>sc_rhlock);
 	return ok;
 }
 



CVS commit: src/sys/dev/usb

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:15:29 UTC 2022

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

Log Message:
xhci(4): Resume commands even if USBSTS.SRE is set.

Commands might not work after this but let's at least not deadlock --
give them an opportunity to time out or fail.

XXX Maybe set sc_dying here to skip the timeout.


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

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:14:43 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_execbuffer.c

Log Message:
i915: Fix error branches of execbuffer vma pinning.

PR kern/56591


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.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/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.c:1.4 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.c:1.4	Sun Dec 19 11:33:30 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.c	Tue Sep 13 10:14:43 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_execbuffer.c,v 1.4 2021/12/19 11:33:30 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_execbuffer.c,v 1.5 2022/09/13 10:14:43 riastradh Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_execbuffer.c,v 1.4 2021/12/19 11:33:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_execbuffer.c,v 1.5 2022/09/13 10:14:43 riastradh Exp $");
 
 #include 
 #include 
@@ -546,8 +546,12 @@ eb_add_vma(struct i915_execbuffer *eb,
 		list_add_tail(>exec_link, >unbound);
 		if (drm_mm_node_allocated(>node))
 			err = i915_vma_unbind(vma);
-		if (unlikely(err))
+		if (unlikely(err)) {
 			vma->exec_flags = NULL;
+			if (i == batch_idx)
+eb->batch = NULL;
+			eb->vma[i] = NULL;
+		}
 	}
 	return err;
 }
@@ -1906,6 +1910,8 @@ static int eb_move_to_gpu(struct i915_ex
 
 		__eb_unreserve_vma(vma, flags);
 		vma->exec_flags = NULL;
+		if (err)
+			eb->vma[i] = NULL;
 
 		if (unlikely(flags & __EXEC_OBJECT_HAS_REF))
 			i915_vma_put(vma);



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:14:43 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_execbuffer.c

Log Message:
i915: Fix error branches of execbuffer vma pinning.

PR kern/56591


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.c

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



CVS commit: src/sbin/cgdconfig

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:14:32 UTC 2022

Modified Files:
src/sbin/cgdconfig: cgdconfig.c

Log Message:
cgdconfig(8): Restore loop for password re-entry for non-shared keys.

Fixes mistake in previous which changed the semantics in the case
where _no_ keys are shared.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sbin/cgdconfig/cgdconfig.c

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

Modified files:

Index: src/sbin/cgdconfig/cgdconfig.c
diff -u src/sbin/cgdconfig/cgdconfig.c:1.59 src/sbin/cgdconfig/cgdconfig.c:1.60
--- src/sbin/cgdconfig/cgdconfig.c:1.59	Tue Aug 30 08:48:41 2022
+++ src/sbin/cgdconfig/cgdconfig.c	Tue Sep 13 10:14:32 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: cgdconfig.c,v 1.59 2022/08/30 08:48:41 riastradh Exp $ */
+/* $NetBSD: cgdconfig.c,v 1.60 2022/09/13 10:14:32 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2002, 2003\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: cgdconfig.c,v 1.59 2022/08/30 08:48:41 riastradh Exp $");
+__RCSID("$NetBSD: cgdconfig.c,v 1.60 2022/09/13 10:14:32 riastradh Exp $");
 #endif
 
 #ifdef HAVE_ARGON2
@@ -858,22 +858,24 @@ configure(int argc, char **argv, struct 
 		(void)prog_close(fd);
 
 		/*
-		 * If the shared keys were all verified already, assume
-		 * something is wrong with the disk and give up.  If
-		 * not, flush the cache of the ones that have not been
-		 * verified in case we can try again with passphrase
-		 * re-entry.
+		 * For shared keys: If the shared keys were all
+		 * verified already, assume something is wrong with the
+		 * disk and give up.  If not, flush the cache of the
+		 * ones that have not been verified in case we can try
+		 * again with passphrase re-entry.
 		 */
-		all_verified = 1;
-		SLIST_FOREACH_SAFE(sk, , used, sk1) {
-			all_verified &= sk->verified;
-			if (!sk->verified) {
-LIST_REMOVE(sk, list);
-free(sk);
+		if (!SLIST_EMPTY()) {
+			all_verified = 1;
+			SLIST_FOREACH_SAFE(sk, , used, sk1) {
+all_verified &= sk->verified;
+if (!sk->verified) {
+	LIST_REMOVE(sk, list);
+	free(sk);
+}
 			}
+			if (all_verified)
+loop = 0;
 		}
-		if (all_verified)
-			loop = 0;
 
 		if (!loop) {
 			warnx("verification failed permanently");



CVS commit: src/sbin/cgdconfig

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:14:32 UTC 2022

Modified Files:
src/sbin/cgdconfig: cgdconfig.c

Log Message:
cgdconfig(8): Restore loop for password re-entry for non-shared keys.

Fixes mistake in previous which changed the semantics in the case
where _no_ keys are shared.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sbin/cgdconfig/cgdconfig.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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:14:20 UTC 2022

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

Log Message:
nvme(4): Don't leak memory for queues on every resume.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 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.66 src/sys/dev/ic/nvme.c:1.67
--- src/sys/dev/ic/nvme.c:1.66	Tue Aug 30 08:48:24 2022
+++ src/sys/dev/ic/nvme.c	Tue Sep 13 10:14:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.66 2022/08/30 08:48:24 riastradh Exp $	*/
+/*	$NetBSD: nvme.c,v 1.67 2022/09/13 10:14:20 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.66 2022/08/30 08:48:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.67 2022/09/13 10:14:20 riastradh Exp $");
 
 #include 
 #include 
@@ -594,8 +594,6 @@ nvme_suspend(struct nvme_softc *sc)
 int
 nvme_resume(struct nvme_softc *sc)
 {
-	int ioq_entries = nvme_ioq_size;
-	uint64_t cap;
 	int i, error;
 
 	error = nvme_disable(sc);
@@ -613,23 +611,12 @@ nvme_resume(struct nvme_softc *sc)
 	}
 
 	for (i = 0; i < sc->sc_nq; i++) {
-		cap = nvme_read8(sc, NVME_CAP);
-		if (ioq_entries > NVME_CAP_MQES(cap))
-			ioq_entries = NVME_CAP_MQES(cap);
-		sc->sc_q[i] = nvme_q_alloc(sc, i + 1, ioq_entries,
-		sc->sc_dstrd);
-		if (sc->sc_q[i] == NULL) {
-			error = ENOMEM;
-			device_printf(sc->sc_dev, "unable to allocate io q %d"
-			"\n", i);
-			goto disable;
-		}
+		nvme_q_reset(sc, sc->sc_q[i]);
 		if (nvme_q_create(sc, sc->sc_q[i]) != 0) {
 			error = EIO;
 			device_printf(sc->sc_dev, "unable to create io q %d"
 			"\n", i);
-			nvme_q_free(sc, sc->sc_q[i]);
-			goto free_q;
+			goto disable;
 		}
 	}
 
@@ -637,9 +624,6 @@ nvme_resume(struct nvme_softc *sc)
 
 	return 0;
 
-free_q:
-	while (i --> 0)
-		nvme_q_free(sc, sc->sc_q[i]);
 disable:
 	(void)nvme_disable(sc);
 



CVS commit: src/sys/dev/ic

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 10:14:20 UTC 2022

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

Log Message:
nvme(4): Don't leak memory for queues on every resume.


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

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:47:17 UTC 2022

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

Log Message:
usbdi(9): Rule out possible race to read xfer->ux_status.

I think this might actually be safe, because when it's synchronous,
the xfer can't be reused except by the caller after usbd_transfer
returns.  But let's make it definitely not wrong instead of maybe
actually safe.


To generate a diff of this commit:
cvs rdiff -u -r1.244 -r1.245 src/sys/dev/usb/usbdi.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/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.244 src/sys/dev/usb/usbdi.c:1.245
--- src/sys/dev/usb/usbdi.c:1.244	Wed Sep  7 10:41:34 2022
+++ src/sys/dev/usb/usbdi.c	Tue Sep 13 09:47:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.244 2022/09/07 10:41:34 riastradh Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.245 2022/09/13 09:47:17 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.244 2022/09/07 10:41:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.245 2022/09/13 09:47:17 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -501,10 +501,10 @@ usbd_transfer(struct usbd_xfer *xfer)
 			break;
 		}
 	}
-	SDT_PROBE2(usb, device, xfer, done,  xfer, xfer->ux_status);
-	/* XXX Race to read xfer->ux_status?  */
+	err = xfer->ux_status;
+	SDT_PROBE2(usb, device, xfer, done,  xfer, err);
 	usbd_unlock_pipe(pipe);
-	return xfer->ux_status;
+	return err;
 }
 
 /* Like usbd_transfer(), but waits for completion. */



CVS commit: src/sys/dev/usb

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:47:17 UTC 2022

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

Log Message:
usbdi(9): Rule out possible race to read xfer->ux_status.

I think this might actually be safe, because when it's synchronous,
the xfer can't be reused except by the caller after usbd_transfer
returns.  But let's make it definitely not wrong instead of maybe
actually safe.


To generate a diff of this commit:
cvs rdiff -u -r1.244 -r1.245 src/sys/dev/usb/usbdi.c

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



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

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:45:37 UTC 2022

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

Log Message:
x86/genfb: Re-enable shadowfb by defualt for now.

Something makes radeondrmkmsfb, at at least, extremely slow, and it's
not yet clear what, and shadowfb=true fixes it.  I verified that the
framebuffer pages are correctly getting mapped write-combining, so
the page table entries aren't the problem -- not sure what is the
problem.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x86/x86/genfb_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/x86/x86/genfb_machdep.c
diff -u src/sys/arch/x86/x86/genfb_machdep.c:1.18 src/sys/arch/x86/x86/genfb_machdep.c:1.19
--- src/sys/arch/x86/x86/genfb_machdep.c:1.18	Sun Aug 14 23:09:30 2022
+++ src/sys/arch/x86/x86/genfb_machdep.c	Tue Sep 13 09:45:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: genfb_machdep.c,v 1.18 2022/08/14 23:09:30 riastradh Exp $ */
+/* $NetBSD: genfb_machdep.c,v 1.19 2022/09/13 09:45:36 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.18 2022/08/14 23:09:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.19 2022/09/13 09:45:36 riastradh Exp $");
 
 #include 
 #include 
@@ -59,7 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: genfb_machde
 
 #if NWSDISPLAY > 0 && NGENFB > 0
 struct vcons_screen x86_genfb_console_screen;
-bool x86_genfb_use_shadowfb = false;
+bool x86_genfb_use_shadowfb = true;
 
 #if NACPICA > 0
 extern int acpi_md_vesa_modenum;



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

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:45:37 UTC 2022

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

Log Message:
x86/genfb: Re-enable shadowfb by defualt for now.

Something makes radeondrmkmsfb, at at least, extremely slow, and it's
not yet clear what, and shadowfb=true fixes it.  I verified that the
framebuffer pages are correctly getting mapped write-combining, so
the page table entries aren't the problem -- not sure what is the
problem.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x86/x86/genfb_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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:43:33 UTC 2022

Modified Files:
src/sys/kern: subr_autoconf.c
src/sys/sys: device_impl.h

Log Message:
autoconf(9): New diagnostic to detect double-detach.

- Rename dv_detached -> dv_detach_committed.
- Add dv_detach_done, asserted false and then set in config_detach.

dv_detach_done may appear redundant with dv_del_gen, but dv_del_gen
will be used to safely detect config_detach on two valid references
to a device (e.g., a bus detaching its child concurrently with drvctl
detaching the same child), while dv_detach_done is strictly a
diagnostic to detect races in the config_detach API.

Currently the config_detach API itself is unsafe, but we can add a
config_detach_release function that simultaneously releases and
detaches a referenced device_t; this will continue to use dv_del_gen
to safely avoid multiple detach, and dv_detach_done to check for
races in usage.


To generate a diff of this commit:
cvs rdiff -u -r1.305 -r1.306 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.4 -r1.5 src/sys/sys/device_impl.h

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

Modified files:

Index: src/sys/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.305 src/sys/kern/subr_autoconf.c:1.306
--- src/sys/kern/subr_autoconf.c:1.305	Tue Sep 13 09:40:38 2022
+++ src/sys/kern/subr_autoconf.c	Tue Sep 13 09:43:33 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.305 2022/09/13 09:40:38 riastradh Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.306 2022/09/13 09:43:33 riastradh Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.305 2022/09/13 09:40:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.306 2022/09/13 09:43:33 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -2051,6 +2051,9 @@ config_detach(device_t dev, int flags)
 	} else
 		rv = EOPNOTSUPP;
 
+	KASSERTMSG(!dev->dv_detach_done, "%s detached twice, error=%d",
+	device_xname(dev), rv);
+
 	/*
 	 * If it was not possible to detach the device, then we either
 	 * panic() (for the forced but failed case), or return an error.
@@ -2060,9 +2063,9 @@ config_detach(device_t dev, int flags)
 		 * Detach failed -- likely EOPNOTSUPP or EBUSY.  Driver
 		 * must not have called config_detach_commit.
 		 */
-		KASSERTMSG(!dev->dv_detached,
-		"%s committed to detaching and then backed out",
-		device_xname(dev));
+		KASSERTMSG(!dev->dv_detach_committed,
+		"%s committed to detaching and then backed out, error=%d",
+		device_xname(dev), rv);
 		if (flags & DETACH_FORCE) {
 			panic("config_detach: forced detach of %s failed (%d)",
 			device_xname(dev), rv);
@@ -2073,6 +2076,7 @@ config_detach(device_t dev, int flags)
 	/*
 	 * The device has now been successfully detached.
 	 */
+	dev->dv_detach_done = true;
 
 	/*
 	 * If .ca_detach didn't commit to detach, then do that for it.
@@ -2193,7 +2197,7 @@ config_detach_commit(device_t dev)
 	"lwp %ld [%s] @ %p detaching %s",
 	(long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l,
 	device_xname(dev));
-	dev->dv_detached = true;
+	dev->dv_detach_committed = true;
 	cv_broadcast(_misc_cv);
 	mutex_exit(_misc_lock);
 }
@@ -2706,7 +2710,7 @@ device_lookup_acquire(cfdriver_t cd, int
 retry:	if (unit < 0 || unit >= cd->cd_ndevs ||
 	(dv = cd->cd_devs[unit]) == NULL ||
 	dv->dv_del_gen != 0 ||
-	dv->dv_detached) {
+	dv->dv_detach_committed) {
 		dv = NULL;
 	} else {
 		/*

Index: src/sys/sys/device_impl.h
diff -u src/sys/sys/device_impl.h:1.4 src/sys/sys/device_impl.h:1.5
--- src/sys/sys/device_impl.h:1.4	Wed Aug 24 11:47:52 2022
+++ src/sys/sys/device_impl.h	Tue Sep 13 09:43:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: device_impl.h,v 1.4 2022/08/24 11:47:52 riastradh Exp $	*/
+/*	$NetBSD: device_impl.h,v 1.5 2022/09/13 09:43:33 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -147,7 +147,8 @@ struct device {
 
 	struct lwp	*dv_attaching;	/* thread not yet finished in attach */
 	struct lwp	*dv_detaching;	/* detach lock (config_misc_lock/cv) */
-	bool		dv_detached;	/* config_misc_lock */
+	bool		dv_detach_committed;	/* config_misc_lock */
+	bool		dv_detach_done;		/* dv_detaching */
 
 	size_t		dv_activity_count;
 	void		(**dv_activity_handlers)(device_t, devactive_t);



CVS commit: src/sys

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:43:33 UTC 2022

Modified Files:
src/sys/kern: subr_autoconf.c
src/sys/sys: device_impl.h

Log Message:
autoconf(9): New diagnostic to detect double-detach.

- Rename dv_detached -> dv_detach_committed.
- Add dv_detach_done, asserted false and then set in config_detach.

dv_detach_done may appear redundant with dv_del_gen, but dv_del_gen
will be used to safely detect config_detach on two valid references
to a device (e.g., a bus detaching its child concurrently with drvctl
detaching the same child), while dv_detach_done is strictly a
diagnostic to detect races in the config_detach API.

Currently the config_detach API itself is unsafe, but we can add a
config_detach_release function that simultaneously releases and
detaches a referenced device_t; this will continue to use dv_del_gen
to safely avoid multiple detach, and dv_detach_done to check for
races in usage.


To generate a diff of this commit:
cvs rdiff -u -r1.305 -r1.306 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.4 -r1.5 src/sys/sys/device_impl.h

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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:40:38 UTC 2022

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

Log Message:
autoconf(9): Improve diagnostics for config_detach_enter/commit/exit.


To generate a diff of this commit:
cvs rdiff -u -r1.304 -r1.305 src/sys/kern/subr_autoconf.c

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

Modified files:

Index: src/sys/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.304 src/sys/kern/subr_autoconf.c:1.305
--- src/sys/kern/subr_autoconf.c:1.304	Wed Aug 24 11:19:25 2022
+++ src/sys/kern/subr_autoconf.c	Tue Sep 13 09:40:38 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.304 2022/08/24 11:19:25 riastradh Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.305 2022/09/13 09:40:38 riastradh Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.304 2022/08/24 11:19:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.305 2022/09/13 09:40:38 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1949,11 +1949,13 @@ config_detach_enter(device_t dev)
 	 * all new attempts to acquire references to block.
 	 */
 	KASSERTMSG((l = dev->dv_attaching) == NULL,
-	"lwp %ld [%s] @ %p attaching",
-	(long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l);
+	"lwp %ld [%s] @ %p attaching %s",
+	(long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l,
+	device_xname(dev));
 	KASSERTMSG((l = dev->dv_detaching) == NULL,
-	"lwp %ld [%s] @ %p detaching",
-	(long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l);
+	"lwp %ld [%s] @ %p detaching %s",
+	(long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l,
+	device_xname(dev));
 	dev->dv_detaching = curlwp;
 
 out:	mutex_exit(_misc_lock);
@@ -1966,9 +1968,12 @@ config_detach_exit(device_t dev)
 	struct lwp *l __diagused;
 
 	mutex_enter(_misc_lock);
+	KASSERTMSG(dev->dv_detaching != NULL, "not detaching %s",
+	device_xname(dev));
 	KASSERTMSG((l = dev->dv_detaching) == curlwp,
-	"lwp %ld [%s] @ %p detaching",
-	(long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l);
+	"lwp %ld [%s] @ %p detaching %s",
+	(long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l,
+	device_xname(dev));
 	dev->dv_detaching = NULL;
 	cv_broadcast(_misc_cv);
 	mutex_exit(_misc_lock);
@@ -2182,9 +2187,12 @@ config_detach_commit(device_t dev)
 	struct lwp *l __diagused;
 
 	mutex_enter(_misc_lock);
+	KASSERTMSG(dev->dv_detaching != NULL, "not detaching %s",
+	device_xname(dev));
 	KASSERTMSG((l = dev->dv_detaching) == curlwp,
-	"lwp %ld [%s] @ %p detaching",
-	(long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l);
+	"lwp %ld [%s] @ %p detaching %s",
+	(long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l,
+	device_xname(dev));
 	dev->dv_detached = true;
 	cv_broadcast(_misc_cv);
 	mutex_exit(_misc_lock);



CVS commit: src/sys/kern

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:40:38 UTC 2022

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

Log Message:
autoconf(9): Improve diagnostics for config_detach_enter/commit/exit.


To generate a diff of this commit:
cvs rdiff -u -r1.304 -r1.305 src/sys/kern/subr_autoconf.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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:40:18 UTC 2022

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

Log Message:
x86/pmap.h: Need machine/cpufunc.h for invlpg.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/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/x86/include/pmap_private.h
diff -u src/sys/arch/x86/include/pmap_private.h:1.2 src/sys/arch/x86/include/pmap_private.h:1.3
--- src/sys/arch/x86/include/pmap_private.h:1.2	Sat Aug 20 23:49:31 2022
+++ src/sys/arch/x86/include/pmap_private.h	Tue Sep 13 09:40:17 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/09/13 09:40:17 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -80,6 +80,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 



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

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:40:18 UTC 2022

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

Log Message:
x86/pmap.h: Need machine/cpufunc.h for invlpg.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/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/arch/amd64/include

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:39:50 UTC 2022

Modified Files:
src/sys/arch/amd64/include: asan.h msan.h

Log Message:
amd64/asan.h, amd64/msan.h: Add include guards.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amd64/include/asan.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/include/msan.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/asan.h
diff -u src/sys/arch/amd64/include/asan.h:1.11 src/sys/arch/amd64/include/asan.h:1.12
--- src/sys/arch/amd64/include/asan.h:1.11	Mon Aug 22 13:57:24 2022
+++ src/sys/arch/amd64/include/asan.h	Tue Sep 13 09:39:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.11 2022/08/22 13:57:24 hannken Exp $	*/
+/*	$NetBSD: asan.h,v 1.12 2022/09/13 09:39:49 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -28,6 +28,9 @@
  * SUCH DAMAGE.
  */
 
+#ifndef	_AMD64_ASAN_H_
+#define	_AMD64_ASAN_H_
+
 #include 
 
 #include 
@@ -294,3 +297,5 @@ kasan_md_unwind(void)
 		}
 	}
 }
+
+#endif	/* _AMD64_ASAN_H_ */

Index: src/sys/arch/amd64/include/msan.h
diff -u src/sys/arch/amd64/include/msan.h:1.7 src/sys/arch/amd64/include/msan.h:1.8
--- src/sys/arch/amd64/include/msan.h:1.7	Mon Aug 22 13:21:47 2022
+++ src/sys/arch/amd64/include/msan.h	Tue Sep 13 09:39:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: msan.h,v 1.7 2022/08/22 13:21:47 riastradh Exp $	*/
+/*	$NetBSD: msan.h,v 1.8 2022/09/13 09:39:49 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019-2020 Maxime Villard, m00nbsd.net
@@ -28,6 +28,9 @@
  * SUCH DAMAGE.
  */
 
+#ifndef	_AMD64_MSAN_H_
+#define	_AMD64_MSAN_H_
+
 #include 
 
 #include 
@@ -275,3 +278,5 @@ kmsan_md_unwind(void)
 		}
 	}
 }
+
+#endif	/* _AMD64_MSAN_H_ */



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

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:39:50 UTC 2022

Modified Files:
src/sys/arch/amd64/include: asan.h msan.h

Log Message:
amd64/asan.h, amd64/msan.h: Add include guards.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amd64/include/asan.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/include/msan.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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:38:19 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.110 -r1.111 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.110 src/sys/dev/usb/usbnet.c:1.111
--- src/sys/dev/usb/usbnet.c:1.110	Tue Aug 23 01:08:04 2022
+++ src/sys/dev/usb/usbnet.c	Tue Sep 13 09:38:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.110 2022/08/23 01:08:04 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.111 2022/09/13 09:38:19 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.110 2022/08/23 01:08:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.111 2022/09/13 09:38:19 riastradh Exp $");
 
 #include 
 #include 
@@ -1162,6 +1162,13 @@ usbnet_stop(struct usbnet *un, struct if
 		mutex_exit(>unp_miilock);
 	}
 
+	/*
+	 * 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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:38:19 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.110 -r1.111 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/kern

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:37:49 UTC 2022

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

Log Message:
kthread(9): Attribute uarea to caller for kmsan.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/kern/kern_kthread.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_kthread.c
diff -u src/sys/kern/kern_kthread.c:1.46 src/sys/kern/kern_kthread.c:1.47
--- src/sys/kern/kern_kthread.c:1.46	Sat Aug  1 02:04:55 2020
+++ src/sys/kern/kern_kthread.c	Tue Sep 13 09:37:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_kthread.c,v 1.46 2020/08/01 02:04:55 riastradh Exp $	*/
+/*	$NetBSD: kern_kthread.c,v 1.47 2022/09/13 09:37:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2007, 2009, 2019 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.46 2020/08/01 02:04:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.47 2022/09/13 09:37:49 riastradh Exp $");
 
 #include 
 #include 
@@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_kthread
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -76,6 +77,7 @@ kthread_create(pri_t pri, int flag, stru
 	if (uaddr == 0) {
 		return ENOMEM;
 	}
+	kmsan_orig((void *)uaddr, USPACE, KMSAN_TYPE_POOL, __RET_ADDR);
 	if ((flag & KTHREAD_TS) != 0) {
 		lc = SCHED_OTHER;
 	} else {



CVS commit: src/sys/kern

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:37:49 UTC 2022

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

Log Message:
kthread(9): Attribute uarea to caller for kmsan.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/kern/kern_kthread.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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:35:32 UTC 2022

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

Log Message:
vflush(9): Insert `involuntary' preemption point at each vnode.

Currently there is a voluntary yield every 100ms, but that's a long
time.  Should help to avoid hogging the CPU while flushing lots of
data to big disks on systems without kpreemption.


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

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

Modified files:

Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.96 src/sys/kern/vfs_mount.c:1.97
--- src/sys/kern/vfs_mount.c:1.96	Fri Aug 26 11:03:53 2022
+++ src/sys/kern/vfs_mount.c	Tue Sep 13 09:35:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.96 2022/08/26 11:03:53 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.97 2022/09/13 09:35:31 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.96 2022/08/26 11:03:53 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.97 2022/09/13 09:35:31 riastradh Exp $");
 
 #include 
 #include 
@@ -549,6 +549,7 @@ vflushnext(struct vnode_iterator *marker
 		yield();
 		*when = getticks() + hz / 10;
 	}
+	preempt_point();
 	return vfs_vnode_iterator_next1(marker, NULL, NULL, true);
 }
 



CVS commit: src/sys/kern

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:35:32 UTC 2022

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

Log Message:
vflush(9): Insert `involuntary' preemption point at each vnode.

Currently there is a voluntary yield every 100ms, but that's a long
time.  Should help to avoid hogging the CPU while flushing lots of
data to big disks on systems without kpreemption.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/kern/vfs_mount.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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:28:06 UTC 2022

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

Log Message:
KERNEL_LOCK(9): Avoid spinning out until 10sec have passed.

This means we'll never spin out if the hardclock timer is stuck.  But
the hardclock timer never runs with the kernel lock held itself, so
it's not immediately clear that's important.


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 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.179 src/sys/kern/kern_lock.c:1.180
--- src/sys/kern/kern_lock.c:1.179	Tue Sep 13 09:14:26 2022
+++ src/sys/kern/kern_lock.c	Tue Sep 13 09:28:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lock.c,v 1.179 2022/09/13 09:14:26 riastradh Exp $	*/
+/*	$NetBSD: kern_lock.c,v 1.180 2022/09/13 09:28:05 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.179 2022/09/13 09:14:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.180 2022/09/13 09:28:05 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lockdebug.h"
@@ -195,6 +195,7 @@ _kernel_lock(int nlocks)
 #ifdef LOCKDEBUG
 	static struct cpu_info *kernel_lock_holder;
 	u_int spins = 0;
+	u_int starttime = getticks();
 #endif
 	int s;
 	struct lwp *l = curlwp;
@@ -254,7 +255,8 @@ _kernel_lock(int nlocks)
 		while (__SIMPLELOCK_LOCKED_P(kernel_lock)) {
 #ifdef LOCKDEBUG
 			extern int start_init_exec;
-			if (SPINLOCK_SPINOUT(spins) && start_init_exec) {
+			if (SPINLOCK_SPINOUT(spins) && start_init_exec &&
+			(getticks() - starttime) > 10*hz) {
 ipi_msg_t msg = {
 	.func = kernel_lock_trace_ipi,
 };



CVS commit: src/sys/kern

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:28:06 UTC 2022

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

Log Message:
KERNEL_LOCK(9): Avoid spinning out until 10sec have passed.

This means we'll never spin out if the hardclock timer is stuck.  But
the hardclock timer never runs with the kernel lock held itself, so
it's not immediately clear that's important.


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:14:26 UTC 2022

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

Log Message:
KERNEL_LOCK(9): Restore backoff while spinning in !LOCKDEBUG case.

When the spinout logic was put under LOCKDEBUG among a series of
other changes that got reverted, the backoff was inadvertently made
LOCKDEBUG-only too.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:14:26 UTC 2022

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

Log Message:
KERNEL_LOCK(9): Restore backoff while spinning in !LOCKDEBUG case.

When the spinout logic was put under LOCKDEBUG among a series of
other changes that got reverted, the backoff was inadvertently made
LOCKDEBUG-only too.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 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.178 src/sys/kern/kern_lock.c:1.179
--- src/sys/kern/kern_lock.c:1.178	Sat Aug 20 23:37:12 2022
+++ src/sys/kern/kern_lock.c	Tue Sep 13 09:14:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lock.c,v 1.178 2022/08/20 23:37:12 riastradh Exp $	*/
+/*	$NetBSD: kern_lock.c,v 1.179 2022/09/13 09:14:26 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.178 2022/08/20 23:37:12 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.179 2022/09/13 09:14:26 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lockdebug.h"
@@ -264,9 +264,9 @@ _kernel_lock(int nlocks)
 kpreempt_enable();
 _KERNEL_LOCK_ABORT("spinout");
 			}
+#endif
 			SPINLOCK_BACKOFF_HOOK;
 			SPINLOCK_SPIN_HOOK;
-#endif
 		}
 		s = splvm();
 	} while (!__cpu_simple_lock_try(kernel_lock));



CVS commit: src/sys/kern

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:13:20 UTC 2022

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

Log Message:
vfs(9): For MP-safe mounts, don't kernel lock in mount/unmount.


To generate a diff of this commit:
cvs rdiff -u -r1.494 -r1.495 src/sys/kern/vfs_subr.c

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

Modified files:

Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.494 src/sys/kern/vfs_subr.c:1.495
--- src/sys/kern/vfs_subr.c:1.494	Tue Sep 13 08:48:20 2022
+++ src/sys/kern/vfs_subr.c	Tue Sep 13 09:13:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_subr.c,v 1.494 2022/09/13 08:48:20 riastradh Exp $	*/
+/*	$NetBSD: vfs_subr.c,v 1.495 2022/09/13 09:13:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008, 2019, 2020
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.494 2022/09/13 08:48:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.495 2022/09/13 09:13:19 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1385,11 +1385,24 @@ vtype2dt(enum vtype vt)
 int
 VFS_MOUNT(struct mount *mp, const char *a, void *b, size_t *c)
 {
+	int mpsafe = mp->mnt_iflag & IMNT_MPSAFE;
 	int error;
 
-	KERNEL_LOCK(1, NULL);
+	/*
+	 * Note: The first time through, the vfs_mount function may set
+	 * IMNT_MPSAFE, so we have to cache it on entry in order to
+	 * avoid leaking a kernel lock.
+	 *
+	 * XXX Maybe the MPSAFE bit should be set in struct vfsops and
+	 * not in struct mount.
+	 */
+	if (mpsafe) {
+		KERNEL_LOCK(1, NULL);
+	}
 	error = (*(mp->mnt_op->vfs_mount))(mp, a, b, c);
-	KERNEL_UNLOCK_ONE(NULL);
+	if (mpsafe) {
+		KERNEL_UNLOCK_ONE(NULL);
+	}
 
 	return error;
 }
@@ -1415,9 +1428,13 @@ VFS_UNMOUNT(struct mount *mp, int a)
 {
 	int error;
 
-	KERNEL_LOCK(1, NULL);
+	if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
+		KERNEL_LOCK(1, NULL);
+	}
 	error = (*(mp->mnt_op->vfs_unmount))(mp, a);
-	KERNEL_UNLOCK_ONE(NULL);
+	if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
+		KERNEL_UNLOCK_ONE(NULL);
+	}
 
 	return error;
 }



CVS commit: src/sys/kern

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:13:20 UTC 2022

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

Log Message:
vfs(9): For MP-safe mounts, don't kernel lock in mount/unmount.


To generate a diff of this commit:
cvs rdiff -u -r1.494 -r1.495 src/sys/kern/vfs_subr.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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 08:48:21 UTC 2022

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

Log Message:
vfs_subr.c: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.493 -r1.494 src/sys/kern/vfs_subr.c

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

Modified files:

Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.493 src/sys/kern/vfs_subr.c:1.494
--- src/sys/kern/vfs_subr.c:1.493	Mon Mar 28 12:38:33 2022
+++ src/sys/kern/vfs_subr.c	Tue Sep 13 08:48:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_subr.c,v 1.493 2022/03/28 12:38:33 riastradh Exp $	*/
+/*	$NetBSD: vfs_subr.c,v 1.494 2022/09/13 08:48:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008, 2019, 2020
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.493 2022/03/28 12:38:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.494 2022/09/13 08:48:20 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -827,11 +827,11 @@ sched_sync(void *arg)
  *
  * If we locked it yet arrive here, it's
  * likely that lazy sync is in progress and
- * so the vnode still has dirty metadata. 
+ * so the vnode still has dirty metadata.
  * syncdelay is mainly to get this vnode out
  * of the way so we do not consider it again
  * "soon" in this loop, so the delay time is
- * not critical as long as it is not "soon". 
+ * not critical as long as it is not "soon".
  * While write-back strategy is the file
  * system's domain, we expect write-back to
  * occur no later than syncdelay seconds
@@ -1393,7 +1393,7 @@ VFS_MOUNT(struct mount *mp, const char *
 
 	return error;
 }
-	
+
 int
 VFS_START(struct mount *mp, int a)
 {
@@ -1409,7 +1409,7 @@ VFS_START(struct mount *mp, int a)
 
 	return error;
 }
-	
+
 int
 VFS_UNMOUNT(struct mount *mp, int a)
 {



CVS commit: src/sys/kern

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 08:48:21 UTC 2022

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

Log Message:
vfs_subr.c: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.493 -r1.494 src/sys/kern/vfs_subr.c

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



CVS commit: src/usr.sbin/usbdevs

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 08:34:37 UTC 2022

Modified Files:
src/usr.sbin/usbdevs: usbdevs.c

Log Message:
usbdevs(8): Misc KNF.

- Fix whitespace and braces.
- malloc(n * sizeof(...)) -> calloc(n, sizeof(...))


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/usbdevs/usbdevs.c

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

Modified files:

Index: src/usr.sbin/usbdevs/usbdevs.c
diff -u src/usr.sbin/usbdevs/usbdevs.c:1.40 src/usr.sbin/usbdevs/usbdevs.c:1.41
--- src/usr.sbin/usbdevs/usbdevs.c:1.40	Wed Nov 27 17:56:08 2019
+++ src/usr.sbin/usbdevs/usbdevs.c	Tue Sep 13 08:34:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdevs.c,v 1.40 2019/11/27 17:56:08 christos Exp $	*/
+/*	$NetBSD: usbdevs.c,v 1.41 2022/09/13 08:34:37 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,24 +31,25 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: usbdevs.c,v 1.40 2019/11/27 17:56:08 christos Exp $");
+__RCSID("$NetBSD: usbdevs.c,v 1.41 2022/09/13 08:34:37 riastradh Exp $");
 #endif
 
 #include 
+
 #include 
 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 
 #include 
-#include 
-#include 
+#include 
 #include 
-#include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 
@@ -62,8 +63,9 @@ struct stringtable {
 	const char *string;
 };
 
-__dead static void usage(void);
-static void getstrings(const struct stringtable *, int, int, const char **, const char **);
+static void usage(void) __dead;
+static void getstrings(const struct stringtable *, int, int,
+const char **, const char **);
 static void usbdev(int f, int a, int rec);
 static void usbdump(int f);
 static void dumpone(char *name, int f, int addr);
@@ -100,7 +102,7 @@ u2t(const char *utf8str, char *termstr)
 		insz = strlen(utf8str);
 		outsz = MAXLEN - 1;
 		icres = iconv(ic, __UNCONST(), , ,
-			);
+		);
 		if (icres != (size_t)-1) {
 			*termstr = '\0';
 			return;
@@ -184,8 +186,9 @@ struct stringtable class_strings[] = {
 };
 
 static void
-getstrings(const struct stringtable *table,
-   int row, int col, const char **rp, const char **cp) {
+getstrings(const struct stringtable *table, int row, int col,
+const char **rp, const char **cp)
+{
 	static char rbuf[5], cbuf[5];
 
 	snprintf(rbuf, sizeof(rbuf), "0x%02x", row);
@@ -245,9 +248,9 @@ usbdev(int f, int a, int rec)
 	u2t(di.udi_serial, serial);
 	if (verbose) {
 		printf("%s(0x%04x), %s(0x%04x), rev %s(0x%04x)",
-		   product, di.udi_productNo,
-		   vendor, di.udi_vendorNo,
-			di.udi_release, di.udi_releaseNo);
+		product, di.udi_productNo,
+		vendor, di.udi_vendorNo,
+		di.udi_release, di.udi_releaseNo);
 		if (di.udi_serial[0])
 			printf(", serial %s", serial);
 	} else
@@ -255,40 +258,43 @@ usbdev(int f, int a, int rec)
 	printf("\n");
 	if (verbose > 1 && di.udi_class != UICLASS_UNSPEC) {
 		const char *cstr, *sstr;
-		getstrings(class_strings, di.udi_class, di.udi_subclass, , );
+		getstrings(class_strings, di.udi_class, di.udi_subclass,
+		, );
 		printf("%*s  %s(0x%02x), %s(0x%02x), proto %u\n", indent, "",
-			cstr, di.udi_class, sstr, di.udi_subclass,
-			di.udi_protocol);
+		cstr, di.udi_class, sstr, di.udi_subclass,
+		di.udi_protocol);
 	}
 	if (showdevs) {
-		for (i = 0; i < USB_MAX_DEVNAMES; i++)
-			if (di.udi_devnames[i][0])
+		for (i = 0; i < USB_MAX_DEVNAMES; i++) {
+			if (di.udi_devnames[i][0]) {
 printf("%*s  %s\n", indent, "",
-   di.udi_devnames[i]);
+di.udi_devnames[i]);
+			}
+		}
 	}
 	if (!rec)
 		return;
 
-	unsigned int nports = di.udi_nports;
+	unsigned int p, nports = di.udi_nports;
 
-	for (unsigned int p = 0; p < nports && p < __arraycount(di.udi_ports); p++) {
+	for (p = 0; p < nports && p < __arraycount(di.udi_ports); p++) {
 		int s = di.udi_ports[p];
 		if (s >= USB_MAX_DEVICES) {
 			if (verbose) {
-printf("%*sport %d %s\n", indent+1, "", p+1,
-   s == USB_PORT_ENABLED ? "enabled" :
-   s == USB_PORT_SUSPENDED ? "suspended" : 
-   s == USB_PORT_POWERED ? "powered" :
-   s == USB_PORT_DISABLED ? "disabled" :
-   "???");
-
+printf("%*sport %d %s\n", indent + 1, "",
+p + 1,
+s == USB_PORT_ENABLED ? "enabled" :
+s == USB_PORT_SUSPENDED ? "suspended" :
+s == USB_PORT_POWERED ? "powered" :
+s == USB_PORT_DISABLED ? "disabled" :
+"???");
 			}
 			continue;
 		}
 		indent++;
 		printf("%*s", indent, "");
 		if (verbose)
-			printf("port %d ", p+1);
+			printf("port %d ", p + 1);
 		if (s == 0)
 			printf("addr 0 should never happen!\n");
 		else
@@ -311,6 +317,7 @@ usbdump(int f)
 static void
 dumpone(char *name, int f, int addr)
 {
+
 	if (verbose)
 		printf("Controller %s:\n", name);
 	indent = 0;
@@ -325,8 +332,8 @@ static int
 getusbcount_device(int fd, const char 

CVS commit: src/usr.sbin/usbdevs

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 08:34:37 UTC 2022

Modified Files:
src/usr.sbin/usbdevs: usbdevs.c

Log Message:
usbdevs(8): Misc KNF.

- Fix whitespace and braces.
- malloc(n * sizeof(...)) -> calloc(n, sizeof(...))


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/usbdevs/usbdevs.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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 08:30:57 UTC 2022

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

Log Message:
sys/device_if.h: Need sys/stdint.h for uint64_t.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/sys/device_if.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-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 08:30:57 UTC 2022

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

Log Message:
sys/device_if.h: Need sys/stdint.h for uint64_t.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/sys/device_if.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/device_if.h
diff -u src/sys/sys/device_if.h:1.6 src/sys/sys/device_if.h:1.7
--- src/sys/sys/device_if.h:1.6	Sun Mar  4 18:07:34 2018
+++ src/sys/sys/device_if.h	Tue Sep 13 08:30:57 2022
@@ -1,8 +1,10 @@
-/*	$NetBSD: device_if.h,v 1.6 2018/03/04 18:07:34 kre Exp $	*/
+/*	$NetBSD: device_if.h,v 1.7 2022/09/13 08:30:57 riastradh Exp $	*/
 
 #ifndef	_SYS_DEVICE_IF_H
 #define	_SYS_DEVICE_IF_H
 
+#include 
+
 struct device;
 typedef struct device *device_t;