CVS commit: [netbsd-9] src/sys/compat/common

2021-08-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug 15 09:27:50 UTC 2021

Modified Files:
src/sys/compat/common [netbsd-9]: vfs_syscalls_30.c vfs_syscalls_43.c
vfs_syscalls_50.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1337):

sys/compat/common/vfs_syscalls_43.c: revision 1.67
sys/compat/common/vfs_syscalls_50.c: revision 1.26
sys/compat/common/vfs_syscalls_30.c: revision 1.42

- memset struct stat to avoid kernel memory disclosure of padded fields
  (thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.4.1 src/sys/compat/common/vfs_syscalls_30.c
cvs rdiff -u -r1.64.4.1 -r1.64.4.2 src/sys/compat/common/vfs_syscalls_43.c
cvs rdiff -u -r1.23.2.1 -r1.23.2.2 src/sys/compat/common/vfs_syscalls_50.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/compat/common/vfs_syscalls_30.c
diff -u src/sys/compat/common/vfs_syscalls_30.c:1.38 src/sys/compat/common/vfs_syscalls_30.c:1.38.4.1
--- src/sys/compat/common/vfs_syscalls_30.c:1.38	Sun Jan 27 02:08:39 2019
+++ src/sys/compat/common/vfs_syscalls_30.c	Sun Aug 15 09:27:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls_30.c,v 1.38 2019/01/27 02:08:39 pgoyette Exp $	*/
+/*	$NetBSD: vfs_syscalls_30.c,v 1.38.4.1 2021/08/15 09:27:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.38 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.38.4.1 2021/08/15 09:27:50 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -61,8 +61,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls
 #include 
 #include 
 
-static void cvtstat(struct stat13 *, const struct stat *);
-
 static const struct syscall_package vfs_syscalls_30_syscalls[] = {
 	{ SYS_compat_30___fhstat30, 0, (sy_call_t *)compat_30_sys___fhstat30 },
 	{ SYS_compat_30___fstat13, 0, (sy_call_t *)compat_30_sys___fstat13 },
@@ -83,6 +81,8 @@ static void
 cvtstat(struct stat13 *ost, const struct stat *st)
 {
 
+	/* Handle any padding. */
+	memset(ost, 0, sizeof(*ost));
 	ost->st_dev = st->st_dev;
 	ost->st_ino = (uint32_t)st->st_ino;
 	ost->st_mode = st->st_mode;
@@ -121,8 +121,7 @@ compat_30_sys___stat13(struct lwp *l,
 	if (error)
 		return error;
 	cvtstat(, );
-	error = copyout(, SCARG(uap, ub), sizeof (osb));
-	return error;
+	return copyout(, SCARG(uap, ub), sizeof(osb));
 }
 
 
@@ -146,8 +145,7 @@ compat_30_sys___lstat13(struct lwp *l,
 	if (error)
 		return error;
 	cvtstat(, );
-	error = copyout(, SCARG(uap, ub), sizeof (osb));
-	return error;
+	return copyout(, SCARG(uap, ub), sizeof(osb));
 }
 
 /* ARGSUSED */
@@ -162,33 +160,12 @@ compat_30_sys_fhstat(struct lwp *l,
 	struct stat sb;
 	struct stat13 osb;
 	int error;
-	struct compat_30_fhandle fh;
-	struct mount *mp;
-	struct vnode *vp;
-
-	/*
-	 * Must be super user
-	 */
-	if ((error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FILEHANDLE,
-	0, NULL, NULL, NULL)))
-		return (error);
 
-	if ((error = copyin(SCARG(uap, fhp), , sizeof(fh))) != 0)
-		return (error);
-
-	if ((mp = vfs_getvfs(_fsid)) == NULL)
-		return (ESTALE);
-	if (mp->mnt_op->vfs_fhtovp == NULL)
-		return EOPNOTSUPP;
-	if ((error = VFS_FHTOVP(mp, (struct fid*)_fid, )))
-		return (error);
-	error = vn_stat(vp, );
-	vput(vp);
+	error = do_fhstat(l, SCARG(uap, fhp), sizeof(*SCARG(uap, fhp)), );
 	if (error)
-		return (error);
+		return error;
 	cvtstat(, );
-	error = copyout(, SCARG(uap, sb), sizeof(sb));
-	return (error);
+	return copyout(, SCARG(uap, sb), sizeof(osb));
 }
 
 /*
@@ -211,8 +188,7 @@ compat_30_sys___fstat13(struct lwp *l,
 	if (error)
 		return error;
 	cvtstat(, );
-	error = copyout(, SCARG(uap, sb), sizeof (osb));
-	return error;
+	return copyout(, SCARG(uap, sb), sizeof(osb));
 }
 
 /*
@@ -289,7 +265,7 @@ again:
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
 		if (reclen & _DIRENT_ALIGN(bdp))
-			panic("netbsd30_getdents: bad reclen %d", reclen);
+			panic("%s: bad reclen %d", __func__, reclen);
 		if (cookie)
 			off = *cookie++; /* each entry points to the next */
 		else
@@ -393,9 +369,8 @@ compat_30_sys_getfh(struct lwp *l, const
 		error = EINVAL;
 	}
 	if (error)
-		return (error);
-	error = copyout(, SCARG(uap, fhp), sizeof(struct compat_30_fhandle));
-	return (error);
+		return error;
+	return copyout(, SCARG(uap, fhp), sizeof(fh));
 }
 
 /*
@@ -434,8 +409,7 @@ compat_30_sys___fhstat30(struct lwp *l,
 	if (error)
 		return error;
 	cvtstat(, );
-	error = copyout(, SCARG(uap_30, sb), sizeof (osb));
-	return error;
+	return copyout(, SCARG(uap_30, sb), sizeof(osb));
 }
 
 /* ARGSUSED */

Index: src/sys/compat/common/vfs_syscalls_43.c
diff -u 

CVS commit: [netbsd-9] src/sys/netinet6

2021-08-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug 11 17:22:17 UTC 2021

Modified Files:
src/sys/netinet6 [netbsd-9]: in6_src.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1332):

sys/netinet6/in6_src.c: revision 1.88

PR kern/56348

MTU discovery fails with IPv6 sockets bound to IPv4 mapped address
pick up the IPv4 route for IPv4 mapped IPv6 address to get the correct
MTU and not any unrelated/inappropriate MTU from IPv6 routes. IPv4 mapped
IPv6 addresses are always handled by the IPv4 stack and MTU discovery
is solely handled with the IPv4 routing table.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.85.6.1 src/sys/netinet6/in6_src.c

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

Modified files:

Index: src/sys/netinet6/in6_src.c
diff -u src/sys/netinet6/in6_src.c:1.85 src/sys/netinet6/in6_src.c:1.85.6.1
--- src/sys/netinet6/in6_src.c:1.85	Tue May  1 07:21:39 2018
+++ src/sys/netinet6/in6_src.c	Wed Aug 11 17:22:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_src.c,v 1.85 2018/05/01 07:21:39 maxv Exp $	*/
+/*	$NetBSD: in6_src.c,v 1.85.6.1 2021/08/11 17:22:17 martin Exp $	*/
 /*	$KAME: in6_src.c,v 1.159 2005/10/19 01:40:32 t-momose Exp $	*/
 
 /*
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.85 2018/05/01 07:21:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.85.6.1 2021/08/11 17:22:17 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -612,6 +612,7 @@ in6_selectroute(struct sockaddr_in6 *dst
 	struct rtentry *rt = NULL;
 	union {
 		struct sockaddr		dst;
+		struct sockaddr_in	dst4;
 		struct sockaddr_in6	dst6;
 	} u;
 
@@ -678,9 +679,17 @@ in6_selectroute(struct sockaddr_in6 *dst
 	 * Use a cached route if it exists and is valid, else try to allocate
 	 * a new one.  Note that we should check the address family of the
 	 * cached destination, in case of sharing the cache with IPv4.
+	 *
+	 * for V4 mapped addresses we want to pick up the v4 route
+	 * see PR kern/56348
 	 */
-	u.dst6 = *dstsock;
-	u.dst6.sin6_scope_id = 0;
+	if (IN6_IS_ADDR_V4MAPPED(>sin6_addr)) {
+		in6_sin6_2_sin(, dstsock);
+	} else {
+		u.dst6 = *dstsock;
+		u.dst6.sin6_scope_id = 0;
+	}
+
 	rt = rtcache_lookup1(*ro, , 1);
 
 	if (rt == NULL)



CVS commit: [netbsd-9] src/sys/external/bsd/drm2/linux

2021-08-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  8 10:00:16 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/linux [netbsd-9]: linux_reservation.c

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

sys/external/bsd/drm2/linux/linux_reservation.c: revision 1.13
sys/external/bsd/drm2/linux/linux_reservation.c: revision 1.14

drm: Release fence if we're about to return too.

Should fix another fence leak.

XXX pullup-9

 -

drm: Plug another fence leak.

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.11.8.1 -r1.11.8.2 \
src/sys/external/bsd/drm2/linux/linux_reservation.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/linux/linux_reservation.c
diff -u src/sys/external/bsd/drm2/linux/linux_reservation.c:1.11.8.1 src/sys/external/bsd/drm2/linux/linux_reservation.c:1.11.8.2
--- src/sys/external/bsd/drm2/linux/linux_reservation.c:1.11.8.1	Thu Jul  8 11:23:28 2021
+++ src/sys/external/bsd/drm2/linux/linux_reservation.c	Sun Aug  8 10:00:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_reservation.c,v 1.11.8.1 2021/07/08 11:23:28 martin Exp $	*/
+/*	$NetBSD: linux_reservation.c,v 1.11.8.2 2021/08/08 10:00:16 martin Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.11.8.1 2021/07/08 11:23:28 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.11.8.2 2021/08/08 10:00:16 martin Exp $");
 
 #include 
 #include 
@@ -794,9 +794,9 @@ wait:
 	KASSERT(fence != NULL);
 	rcu_read_unlock();
 	ret = fence_wait_timeout(fence, intr, timeout);
+	fence_put(fence);
 	if (ret <= 0)
 		return ret;
-	fence_put(fence);
 	KASSERT(ret <= timeout);
 	timeout = ret;
 	goto top;
@@ -1003,6 +1003,7 @@ top:
 		 * assume the event is not ready.
 		 */
 		if (!claimed || callback) {
+			fence_put(fence);
 			revents = 0;
 			break;
 		}



CVS commit: [netbsd-9] src/sys/dev/audio

2021-07-28 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Jul 28 14:59:02 UTC 2021

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #1325):
sys/dev/audio/audio.c: revision 1.105
AUDIO_SETINFO: fix a bug that the gain and the balance could not be set
at the same time.  Fix PR kern/56308.


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

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.22 src/sys/dev/audio/audio.c:1.28.2.23
--- src/sys/dev/audio/audio.c:1.28.2.22	Wed May  5 17:01:41 2021
+++ src/sys/dev/audio/audio.c	Wed Jul 28 14:59:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.22 2021/05/05 17:01:41 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.23 2021/07/28 14:59:02 snj Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.22 2021/05/05 17:01:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.23 2021/07/28 14:59:02 snj Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -7381,59 +7381,46 @@ audio_hw_setinfo(struct audio_softc *sc,
 		}
 	}
 
-	/* Backup play.{gain,balance} */
+	/* play.{gain,balance} */
 	if (SPECIFIED(newpi->gain) || SPECIFIED_CH(newpi->balance)) {
 		au_get_gain(sc, >sc_outports, , );
 		if (oldai) {
 			oldpi->gain = pgain;
 			oldpi->balance = pbalance;
 		}
+
+		if (SPECIFIED(newpi->gain))
+			pgain = newpi->gain;
+		if (SPECIFIED_CH(newpi->balance))
+			pbalance = newpi->balance;
+		error = au_set_gain(sc, >sc_outports, pgain, pbalance);
+		if (error) {
+			audio_printf(sc,
+			"setting play.gain=%d/balance=%d failed: "
+			"errno=%d\n",
+			pgain, pbalance, error);
+			goto abort;
+		}
 	}
-	/* Backup record.{gain,balance} */
+
+	/* record.{gain,balance} */
 	if (SPECIFIED(newri->gain) || SPECIFIED_CH(newri->balance)) {
 		au_get_gain(sc, >sc_inports, , );
 		if (oldai) {
 			oldri->gain = rgain;
 			oldri->balance = rbalance;
 		}
-	}
-	if (SPECIFIED(newpi->gain)) {
-		error = au_set_gain(sc, >sc_outports,
-		newpi->gain, pbalance);
-		if (error) {
-			audio_printf(sc,
-			"setting play.gain=%d failed: errno=%d\n",
-			newpi->gain, error);
-			goto abort;
-		}
-	}
-	if (SPECIFIED(newri->gain)) {
-		error = au_set_gain(sc, >sc_inports,
-		newri->gain, rbalance);
-		if (error) {
-			audio_printf(sc,
-			"setting record.gain=%d failed: errno=%d\n",
-			newri->gain, error);
-			goto abort;
-		}
-	}
-	if (SPECIFIED_CH(newpi->balance)) {
-		error = au_set_gain(sc, >sc_outports,
-		pgain, newpi->balance);
-		if (error) {
-			audio_printf(sc,
-			"setting play.balance=%d failed: errno=%d\n",
-			newpi->balance, error);
-			goto abort;
-		}
-	}
-	if (SPECIFIED_CH(newri->balance)) {
-		error = au_set_gain(sc, >sc_inports,
-		rgain, newri->balance);
+
+		if (SPECIFIED(newri->gain))
+			rgain = newri->gain;
+		if (SPECIFIED_CH(newri->balance))
+			rbalance = newri->balance;
+		error = au_set_gain(sc, >sc_inports, rgain, rbalance);
 		if (error) {
 			audio_printf(sc,
-			"setting record.balance=%d failed: errno=%d\n",
-			newri->balance, error);
+			"setting record.gain=%d/balance=%d failed: "
+			"errno=%d\n",
+			rgain, rbalance, error);
 			goto abort;
 		}
 	}



CVS commit: [netbsd-9] src/sys/arch/arm/rockchip

2021-07-28 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Jul 28 14:56:35 UTC 2021

Modified Files:
src/sys/arch/arm/rockchip [netbsd-9]: rk_anxdp.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #1324):
sys/arch/arm/rockchip/rk_anxdp.c: revision 1.4
rockchip: edp: Force VOPB as CRTC for eDP.
Fixes display init on Pinebook Pro w/ U-Boot 2021.07.


To generate a diff of this commit:
cvs rdiff -u -r1.2.4.2 -r1.2.4.3 src/sys/arch/arm/rockchip/rk_anxdp.c

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

Modified files:

Index: src/sys/arch/arm/rockchip/rk_anxdp.c
diff -u src/sys/arch/arm/rockchip/rk_anxdp.c:1.2.4.2 src/sys/arch/arm/rockchip/rk_anxdp.c:1.2.4.3
--- src/sys/arch/arm/rockchip/rk_anxdp.c:1.2.4.2	Tue Jan 21 10:39:59 2020
+++ src/sys/arch/arm/rockchip/rk_anxdp.c	Wed Jul 28 14:56:35 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_anxdp.c,v 1.2.4.2 2020/01/21 10:39:59 martin Exp $ */
+/* $NetBSD: rk_anxdp.c,v 1.2.4.3 2021/07/28 14:56:35 snj Exp $ */
 
 /*-
  * Copyright (c) 2019 Jonathan A. Kollasch 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_anxdp.c,v 1.2.4.2 2020/01/21 10:39:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_anxdp.c,v 1.2.4.3 2021/07/28 14:56:35 snj Exp $");
 
 #include 
 #include 
@@ -172,7 +172,7 @@ rk_anxdp_ep_activate(device_t dev, struc
 		break;
 	}
 
-	sc->sc_encoder.possible_crtcs = 0x3; /* XXX */
+	sc->sc_encoder.possible_crtcs = 0x2; /* VOPB only */
 	drm_encoder_init(crtc->dev, >sc_encoder, _anxdp_encoder_funcs,
 	DRM_MODE_ENCODER_TMDS);
 	drm_encoder_helper_add(>sc_encoder, _anxdp_encoder_helper_funcs);



CVS commit: [netbsd-9] src/sys/arch/hppa/dev

2021-07-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jul 14 17:52:32 UTC 2021

Modified Files:
src/sys/arch/hppa/dev [netbsd-9]: sti_sgc.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1322):

sys/arch/hppa/dev/sti_sgc.c: revision 1.3

Fix silent freeze on probing sti(4) framebuffer on 712/60.  PR/52162

Ok'ed by skrll@.
Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.4.1 src/sys/arch/hppa/dev/sti_sgc.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/hppa/dev/sti_sgc.c
diff -u src/sys/arch/hppa/dev/sti_sgc.c:1.2 src/sys/arch/hppa/dev/sti_sgc.c:1.2.4.1
--- src/sys/arch/hppa/dev/sti_sgc.c:1.2	Mon Apr 15 20:40:37 2019
+++ src/sys/arch/hppa/dev/sti_sgc.c	Wed Jul 14 17:52:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti_sgc.c,v 1.2 2019/04/15 20:40:37 skrll Exp $	*/
+/*	$NetBSD: sti_sgc.c,v 1.2.4.1 2021/07/14 17:52:31 martin Exp $	*/
 
 /*	$OpenBSD: sti_sgc.c,v 1.38 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.2 2019/04/15 20:40:37 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.2.4.1 2021/07/14 17:52:31 martin Exp $");
 
 #include "opt_cputype.h"
 
@@ -73,6 +73,16 @@ extern int stidebug;
 #define	STI_ROMSIZE	(sizeof(struct sti_dd) * 4)
 #define	STI_ID_FDDI	0x280b31af	/* Medusa FDDI ROM id */
 
+/*
+ * hpa addresses to check on-board variants
+ * XXX should check via device_register(9)?
+ * 
+ * 0xf400: HPA1991AC19 on 715/33, 715/50
+ * 0xf800: HPA1439A on 735/99, HPA208LCxxx on 715/80, 715/100, 712
+ */
+#define	STI_ONBOARD_HPA0	0xf400
+#define	STI_ONBOARD_HPA1	0xf800
+
 /* gecko optional graphics */
 #define	STI_GOPT1_REV	0x17
 #define	STI_GOPT2_REV	0x70
@@ -118,7 +128,9 @@ sti_sgc_getrom(struct confargs *ca)
 	rom = PAGE0->pd_resv2[1];
 	hppa_pagezero_unmap(pagezero_cookie);
 
-	if (ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC) {
+	if (ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC &&
+	ca->ca_hpa != STI_ONBOARD_HPA0 &&
+	ca->ca_hpa != STI_ONBOARD_HPA1) {
 		int i;
 		for (i = sizeof(sti_sgc_opt); i--; )
 			if (sti_sgc_opt[i] == ca->ca_type.iodc_revision)



CVS commit: [netbsd-9] src/sys/rump/librump/rumpvfs

2021-07-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul  9 17:51:17 UTC 2021

Modified Files:
src/sys/rump/librump/rumpvfs [netbsd-9]: vm_vfs.c

Log Message:
Apply patch, requested by chs in ticket #1321:

sys/rump/librump/rumpvfs/vm_vfs.c   (apply patch)

Adapt the changes from ticket #1317 (the uvm_pageqlock does not exist any
more in HEAD)


To generate a diff of this commit:
cvs rdiff -u -r1.34.34.1 -r1.34.34.2 src/sys/rump/librump/rumpvfs/vm_vfs.c

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

Modified files:

Index: src/sys/rump/librump/rumpvfs/vm_vfs.c
diff -u src/sys/rump/librump/rumpvfs/vm_vfs.c:1.34.34.1 src/sys/rump/librump/rumpvfs/vm_vfs.c:1.34.34.2
--- src/sys/rump/librump/rumpvfs/vm_vfs.c:1.34.34.1	Tue Jul  6 04:22:34 2021
+++ src/sys/rump/librump/rumpvfs/vm_vfs.c	Fri Jul  9 17:51:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_vfs.c,v 1.34.34.1 2021/07/06 04:22:34 martin Exp $	*/
+/*	$NetBSD: vm_vfs.c,v 1.34.34.2 2021/07/09 17:51:17 martin Exp $	*/
 
 /*
  * Copyright (c) 2008-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.34.34.1 2021/07/06 04:22:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.34.34.2 2021/07/09 17:51:17 martin Exp $");
 
 #include 
 
@@ -44,6 +44,7 @@ uvm_aio_aiodone_pages(struct vm_page **p
 	int i;
 
 	mutex_enter(uobj->vmobjlock);
+	mutex_enter(_pageqlock);
 	for (i = 0; i < npages; i++) {
 		pg = pgs[i];
 		KASSERT((pg->flags & PG_PAGEOUT) == 0 ||
@@ -59,6 +60,7 @@ uvm_aio_aiodone_pages(struct vm_page **p
 
 	}
 	uvm_page_unbusy(pgs, npages);
+	mutex_exit(_pageqlock);
 	mutex_exit(uobj->vmobjlock);
 }
 



CVS commit: [netbsd-9] src/sys/external/bsd/drm2/linux

2021-07-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jul  8 11:23:29 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/linux [netbsd-9]: linux_reservation.c

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

sys/external/bsd/drm2/linux/linux_reservation.c: revision 1.12

drm: Release fence after use.

May plug the dreaded radeon kmem memory leak.
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.8.1 \
src/sys/external/bsd/drm2/linux/linux_reservation.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/linux/linux_reservation.c
diff -u src/sys/external/bsd/drm2/linux/linux_reservation.c:1.11 src/sys/external/bsd/drm2/linux/linux_reservation.c:1.11.8.1
--- src/sys/external/bsd/drm2/linux/linux_reservation.c:1.11	Mon Sep  3 18:02:11 2018
+++ src/sys/external/bsd/drm2/linux/linux_reservation.c	Thu Jul  8 11:23:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_reservation.c,v 1.11 2018/09/03 18:02:11 riastradh Exp $	*/
+/*	$NetBSD: linux_reservation.c,v 1.11.8.1 2021/07/08 11:23:28 martin Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.11 2018/09/03 18:02:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.11.8.1 2021/07/08 11:23:28 martin Exp $");
 
 #include 
 #include 
@@ -796,6 +796,7 @@ wait:
 	ret = fence_wait_timeout(fence, intr, timeout);
 	if (ret <= 0)
 		return ret;
+	fence_put(fence);
 	KASSERT(ret <= timeout);
 	timeout = ret;
 	goto top;



CVS commit: [netbsd-9] src/sys/arch/hppa/hppa

2021-07-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul  6 04:05:14 UTC 2021

Modified Files:
src/sys/arch/hppa/hppa [netbsd-9]: intr.c

Log Message:
Pull up following revision(s) (requested by macallan in ticket #1312):

sys/arch/hppa/hppa/intr.c: revision 1.4

fix off by one which resulted in all idle time reported as interrupt time
final fix from nick@


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.2.1 src/sys/arch/hppa/hppa/intr.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/hppa/hppa/intr.c
diff -u src/sys/arch/hppa/hppa/intr.c:1.3 src/sys/arch/hppa/hppa/intr.c:1.3.2.1
--- src/sys/arch/hppa/hppa/intr.c:1.3	Sat May  4 13:04:36 2019
+++ src/sys/arch/hppa/hppa/intr.c	Tue Jul  6 04:05:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.3 2019/05/04 13:04:36 skrll Exp $	*/
+/*	$NetBSD: intr.c,v 1.3.2.1 2021/07/06 04:05:14 martin Exp $	*/
 /*	$OpenBSD: intr.c,v 1.27 2009/12/31 12:52:35 jsing Exp $	*/
 
 /*
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.3 2019/05/04 13:04:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.3.2.1 2021/07/06 04:05:14 martin Exp $");
 
 #define __MUTEX_PRIVATE
 
@@ -435,7 +435,7 @@ hppa_intr_dispatch(int ncpl, int eiem, s
 		ib->ib_evcnt.ev_count++;
 		arg = ib->ib_arg;
 		if (arg == NULL) {
-			clkframe.cf_flags = (ci->ci_intr_depth ?
+			clkframe.cf_flags = (ci->ci_intr_depth > 1 ?
 			TFF_INTR : 0);
 			clkframe.cf_spl = ncpl;
 			if (frame != NULL) {



CVS commit: [netbsd-9] src/sys/miscfs/kernfs

2021-07-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul  6 03:45:11 UTC 2021

Modified Files:
src/sys/miscfs/kernfs [netbsd-9]: kernfs_vnops.c

Log Message:
Pull up following revision(s) (requested by dholland in ticket #1318):

sys/miscfs/kernfs/kernfs_vnops.c: revision 1.169
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.170

Add missing VOP_KQFILTER to kernfs.

Not sure if lack of it can be used for local DoS or not, but best to
fix.

 -

Fix perms on /kern/{r,}rootdev.


To generate a diff of this commit:
cvs rdiff -u -r1.160.4.2 -r1.160.4.3 src/sys/miscfs/kernfs/kernfs_vnops.c

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

Modified files:

Index: src/sys/miscfs/kernfs/kernfs_vnops.c
diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.160.4.2 src/sys/miscfs/kernfs/kernfs_vnops.c:1.160.4.3
--- src/sys/miscfs/kernfs/kernfs_vnops.c:1.160.4.2	Wed Feb 12 19:59:22 2020
+++ src/sys/miscfs/kernfs/kernfs_vnops.c	Tue Jul  6 03:45:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vnops.c,v 1.160.4.2 2020/02/12 19:59:22 martin Exp $	*/
+/*	$NetBSD: kernfs_vnops.c,v 1.160.4.3 2021/07/06 03:45:11 martin Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.160.4.2 2020/02/12 19:59:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.160.4.3 2021/07/06 03:45:11 martin Exp $");
 
 #include 
 #include 
@@ -91,8 +91,8 @@ const struct kern_target kern_targets[] 
 #if 0
  { DT_DIR, N("root"),  0,KFSnull,VDIR, DIR_MODE   },
 #endif
- { DT_BLK, N("rootdev"),   , KFSdevice,  VBLK, READ_MODE  },
- { DT_CHR, N("rrootdev"),  ,KFSdevice,  VCHR, READ_MODE  },
+ { DT_BLK, N("rootdev"),   , KFSdevice,  VBLK, UREAD_MODE  },
+ { DT_CHR, N("rrootdev"),  ,KFSdevice,  VCHR, UREAD_MODE  },
  { DT_REG, N("time"),  0,KFStime,VREG, READ_MODE  },
 			/* XXXUNCONST */
  { DT_REG, N("version"),   __UNCONST(version),
@@ -197,6 +197,7 @@ const struct vnodeopv_entry_desc kernfs_
 	{ _fcntl_desc, kernfs_fcntl },		/* fcntl */
 	{ _ioctl_desc, kernfs_ioctl },		/* ioctl */
 	{ _poll_desc, kernfs_poll },		/* poll */
+	{ _kqfilter_desc, genfs_kqfilter },		/* kqfilter */
 	{ _revoke_desc, kernfs_revoke },		/* revoke */
 	{ _fsync_desc, kernfs_fsync },		/* fsync */
 	{ _seek_desc, kernfs_seek },		/* seek */
@@ -245,6 +246,7 @@ const struct vnodeopv_entry_desc kernfs_
 	{ _fcntl_desc, spec_fcntl },		/* fcntl */
 	{ _ioctl_desc, spec_ioctl },		/* ioctl */
 	{ _poll_desc, spec_poll },			/* poll */
+	{ _kqfilter_desc, genfs_kqfilter },		/* kqfilter */
 	{ _revoke_desc, spec_revoke },		/* revoke */
 	{ _fsync_desc, spec_fsync },		/* fsync */
 	{ _seek_desc, spec_seek },			/* seek */



CVS commit: [netbsd-9] src/sys/dev/ic

2021-07-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jul  3 10:18:16 UTC 2021

Modified Files:
src/sys/dev/ic [netbsd-9]: ax88190.c dl10019.c dp8390.c

Log Message:
Pull up following revision(s) (requested by thorpej in ticket #1311):

sys/dev/ic/dp8390.c: revision 1.99
sys/dev/ic/dl10019.c: revision 1.17
sys/dev/ic/ax88190.c: revision 1.18

Make sure the media / mii members in struct ethercom are initialized
so that the media-related ioctls work.  Problem reported by Bj�rn Johannesson
on current-users@.

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/dev/ic/ax88190.c
cvs rdiff -u -r1.14 -r1.14.2.1 src/sys/dev/ic/dl10019.c
cvs rdiff -u -r1.95 -r1.95.2.1 src/sys/dev/ic/dp8390.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/ax88190.c
diff -u src/sys/dev/ic/ax88190.c:1.15 src/sys/dev/ic/ax88190.c:1.15.2.1
--- src/sys/dev/ic/ax88190.c:1.15	Wed May 29 06:17:28 2019
+++ src/sys/dev/ic/ax88190.c	Sat Jul  3 10:18:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ax88190.c,v 1.15 2019/05/29 06:17:28 msaitoh Exp $	*/
+/*	$NetBSD: ax88190.c,v 1.15.2.1 2021/07/03 10:18:16 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ax88190.c,v 1.15 2019/05/29 06:17:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ax88190.c,v 1.15.2.1 2021/07/03 10:18:16 martin Exp $");
 
 #include 
 #include 
@@ -86,6 +86,8 @@ ax88190_media_init(struct dp8390_softc *
 	struct ifnet *ifp = >sc_ec.ec_if;
 	struct mii_data *mii = >sc_mii;
 
+	sc->sc_ec.ec_mii = mii;
+
 	mii->mii_ifp = ifp;
 	mii->mii_readreg = ax88190_mii_readreg;
 	mii->mii_writereg = ax88190_mii_writereg;

Index: src/sys/dev/ic/dl10019.c
diff -u src/sys/dev/ic/dl10019.c:1.14 src/sys/dev/ic/dl10019.c:1.14.2.1
--- src/sys/dev/ic/dl10019.c:1.14	Wed May 29 06:17:28 2019
+++ src/sys/dev/ic/dl10019.c	Sat Jul  3 10:18:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dl10019.c,v 1.14 2019/05/29 06:17:28 msaitoh Exp $	*/
+/*	$NetBSD: dl10019.c,v 1.14.2.1 2021/07/03 10:18:16 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dl10019.c,v 1.14 2019/05/29 06:17:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dl10019.c,v 1.14.2.1 2021/07/03 10:18:16 martin Exp $");
 
 #include 
 #include 
@@ -119,6 +119,8 @@ dl10019_media_init(struct dp8390_softc *
 	struct ifnet *ifp = >sc_ec.ec_if;
 	struct mii_data *mii = >sc_mii;
 
+	sc->sc_ec.ec_mii = mii;
+
 	mii->mii_ifp = ifp;
 	mii->mii_readreg = dl10019_mii_readreg;
 	mii->mii_writereg = dl10019_mii_writereg;

Index: src/sys/dev/ic/dp8390.c
diff -u src/sys/dev/ic/dp8390.c:1.95 src/sys/dev/ic/dp8390.c:1.95.2.1
--- src/sys/dev/ic/dp8390.c:1.95	Wed May 29 10:07:29 2019
+++ src/sys/dev/ic/dp8390.c	Sat Jul  3 10:18:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dp8390.c,v 1.95 2019/05/29 10:07:29 msaitoh Exp $	*/
+/*	$NetBSD: dp8390.c,v 1.95.2.1 2021/07/03 10:18:16 martin Exp $	*/
 
 /*
  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -14,7 +14,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.95 2019/05/29 10:07:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.95.2.1 2021/07/03 10:18:16 martin Exp $");
 
 #include "opt_inet.h"
 
@@ -66,7 +66,6 @@ void
 dp8390_media_init(struct dp8390_softc *sc)
 {
 
-	sc->sc_ec.ec_ifmedia = >sc_media;
 	ifmedia_init(>sc_media, 0, dp8390_mediachange, dp8390_mediastatus);
 	ifmedia_add(>sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
 	ifmedia_set(>sc_media, IFM_ETHER | IFM_MANUAL);
@@ -131,7 +130,13 @@ dp8390_config(struct dp8390_softc *sc)
 	aprint_normal_dev(sc->sc_dev, "Ethernet address %s\n",
 	ether_sprintf(sc->sc_enaddr));
 
-	/* Initialize media goo. */
+	/*
+	 * Initialize media structures.  We'll default to pointing ec_ifmedia
+	 * at our embedded media structure.  A card front-end can initialize
+	 * ec_mii if it has an MII interface.  (Note that sc_media is an
+	 * alias of sc_mii.mii_media in dp8390_softc.)
+	 */
+	sc->sc_ec.ec_ifmedia = >sc_media;
 	(*sc->sc_media_init)(sc);
 
 	/* We can support 802.1Q VLAN-sized frames. */



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

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jun 22 05:10:50 UTC 2021

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

Log Message:
Fix pullup #1302 by adapting the changes to this branch
(there was a misunderstanding in the ticket handling)


To generate a diff of this commit:
cvs rdiff -u -r1.107.2.8 -r1.107.2.9 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.13.2.1 -r1.13.2.2 src/sys/dev/usb/xhcireg.h
cvs rdiff -u -r1.11.4.1 -r1.11.4.2 src/sys/dev/usb/xhcivar.h

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

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.107.2.8 src/sys/dev/usb/xhci.c:1.107.2.9
--- src/sys/dev/usb/xhci.c:1.107.2.8	Mon Jun 21 17:11:46 2021
+++ src/sys/dev/usb/xhci.c	Tue Jun 22 05:10:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.107.2.8 2021/06/21 17:11:46 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.107.2.9 2021/06/22 05:10:50 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.8 2021/06/21 17:11:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.9 2021/06/22 05:10:50 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -724,7 +724,7 @@ xhci_suspend(device_t self, const pmf_qu
 		if (xs->xs_idx == 0)
 			continue;
 
-		for (dci = XHCI_DCI_SLOT; dci <= XHCI_MAX_DCI; dci++) {
+		for (dci = 0; dci < 32; dci++) {
 			/* Skip if the endpoint is not Running.  */
 			/* XXX What about Busy?  */
 			if (xhci_get_epstate(sc, xs, dci) !=
@@ -951,7 +951,7 @@ xhci_resume(device_t self, const pmf_qua
 	 *
 	 * XXX Hope just zeroing it is good enough!
 	 */
-	xhci_host_dequeue(sc->sc_cr);
+	xhci_host_dequeue(>sc_cr);
 
 	/*
 	 * `7. Write the CRCR with the address and RCS value of the
@@ -959,8 +959,8 @@ xhci_resume(device_t self, const pmf_qua
 	 * cause the Command Ring to restart at the address
 	 * specified by the CRCR.'
 	 */
-	xhci_op_write_8(sc, XHCI_CRCR, xhci_ring_trbp(sc->sc_cr, 0) |
-	sc->sc_cr->xr_cs);
+	xhci_op_write_8(sc, XHCI_CRCR, xhci_ring_trbp(>sc_cr, 0) |
+	sc->sc_cr.xr_cs);
 
 	/*
 	 * `8. Enable the controller by setting Run/Stop (R/S) =
@@ -1049,7 +1049,7 @@ xhci_resume(device_t self, const pmf_qua
 		if (xs->xs_idx == 0)
 			continue;
 
-		for (dci = XHCI_DCI_SLOT; dci <= XHCI_MAX_DCI; dci++) {
+		for (dci = 0; dci < 32; dci++) {
 			/* Skip if the endpoint is not Running.  */
 			if (xhci_get_epstate(sc, xs, dci) !=
 			XHCI_EPSTATE_RUNNING)

Index: src/sys/dev/usb/xhcireg.h
diff -u src/sys/dev/usb/xhcireg.h:1.13.2.1 src/sys/dev/usb/xhcireg.h:1.13.2.2
--- src/sys/dev/usb/xhcireg.h:1.13.2.1	Mon Jun 21 17:11:46 2021
+++ src/sys/dev/usb/xhcireg.h	Tue Jun 22 05:10:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xhcireg.h,v 1.13.2.1 2021/06/21 17:11:46 martin Exp $ */
+/* $NetBSD: xhcireg.h,v 1.13.2.2 2021/06/22 05:10:50 martin Exp $ */
 
 /*-
  * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
@@ -162,8 +162,31 @@
 #define	 XHCI_PS_PED		0x0002	/* RW - port enabled / disabled */
 #define	 XHCI_PS_OCA		0x0008	/* RO - over current active */
 #define	 XHCI_PS_PR		0x0010	/* RW - port reset */
+#define	 XHCI_PS_PLS_MASK	__BITS(8, 5)
 #define	 XHCI_PS_PLS_GET(x)	(((x) >> 5) & 0xF)	/* RW - port link state */
 #define	 XHCI_PS_PLS_SET(x)	(((x) & 0xF) << 5)	/* RW - port link state */
+
+#define  XHCI_PS_PLS_SETU0	0
+#define  XHCI_PS_PLS_SETU2	2
+#define  XHCI_PS_PLS_SETU3	3
+#define  XHCI_PS_PLS_SETDISC	5
+#define  XHCI_PS_PLS_SETCOMP	10
+#define  XHCI_PS_PLS_SETRESUME	15
+
+#define  XHCI_PS_PLS_U0		0
+#define  XHCI_PS_PLS_U1		1
+#define  XHCI_PS_PLS_U2		2
+#define  XHCI_PS_PLS_U3		3
+#define  XHCI_PS_PLS_DISABLED	4
+#define  XHCI_PS_PLS_RXDETECT	5
+#define  XHCI_PS_PLS_INACTIVE	6
+#define  XHCI_PS_PLS_POLLING	7
+#define  XHCI_PS_PLS_RECOVERY	8
+#define  XHCI_PS_PLS_HOTRESET	9
+#define  XHCI_PS_PLS_COMPLIANCE	10
+#define  XHCI_PS_PLS_TEST	11
+#define  XHCI_PS_PLS_RESUME	15
+
 #define	 XHCI_PS_PP		0x0200	/* RW - port power */
 #define	 XHCI_PS_SPEED_GET(x)	(((x) >> 10) & 0xF)	/* RO - port speed */
 #define	 XHCI_PS_SPEED_FS	1

Index: src/sys/dev/usb/xhcivar.h
diff -u src/sys/dev/usb/xhcivar.h:1.11.4.1 src/sys/dev/usb/xhcivar.h:1.11.4.2
--- src/sys/dev/usb/xhcivar.h:1.11.4.1	Mon Jun 21 17:11:46 2021
+++ src/sys/dev/usb/xhcivar.h	Tue Jun 22 05:10:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhcivar.h,v 1.11.4.1 2021/06/21 17:11:46 martin Exp $	*/
+/*	$NetBSD: xhcivar.h,v 1.11.4.2 2021/06/22 05:10:50 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch



CVS commit: [netbsd-9] src/sys/arch/amd64/conf

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 17:34:42 UTC 2021

Modified Files:
src/sys/arch/amd64/conf [netbsd-9]: GENERIC

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

sys/arch/amd64/conf/GENERIC: revision 1.581

Enable tpm @ acpi (now that it can match TPM 1.2 devices, which are not,
as the comment implies, experimental).


To generate a diff of this commit:
cvs rdiff -u -r1.531.2.10 -r1.531.2.11 src/sys/arch/amd64/conf/GENERIC

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

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.531.2.10 src/sys/arch/amd64/conf/GENERIC:1.531.2.11
--- src/sys/arch/amd64/conf/GENERIC:1.531.2.10	Tue Jul  7 10:29:05 2020
+++ src/sys/arch/amd64/conf/GENERIC	Mon Jun 21 17:34:42 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.531.2.10 2020/07/07 10:29:05 martin Exp $
+# $NetBSD: GENERIC,v 1.531.2.11 2021/06/21 17:34:42 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.531.2.10 $"
+#ident		"GENERIC-$Revision: 1.531.2.11 $"
 
 maxusers	64		# estimated number of users
 
@@ -329,7 +329,7 @@ sony*		at acpi?		# Sony Notebook Control
 spic*		at acpi?		# Sony Programmable I/O Controller
 wsmouse*	at spic?		# mouse
 thinkpad*	at acpi?		# IBM/Lenovo Thinkpad hotkeys
-#tpm*		at acpi?		# ACPI TPM (Experimental)
+tpm*		at acpi?		# ACPI TPM (Experimental)
 ug*		at acpi?		# Abit uGuru Hardware monitor
 valz*		at acpi?		# Toshiba Dynabook hotkeys
 wb*		at acpi?		# Winbond W83L518D SD/MMC reader



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

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 17:32:52 UTC 2021

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-9]: db_disasm.c
src/sys/arch/i386/i386 [netbsd-9]: db_disasm.c

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

sys/arch/amd64/amd64/db_disasm.c: revision 1.28
sys/arch/i386/i386/db_disasm.c: revision 1.49

ddb/amd64: Don't go out of the way to detect invalid addresses.

db_disasm had logic to detect invalid addresses before trying to
disassemble them.  But when disassembling a null instruction address,
the logic to detect invalid addresses itself tried to dereference an
invalid address.

db_get_value can already handle this situation gracefully, so there is
no need for this faulty fault-avoidance logic.

Fixes double-fault in ddb on calling null function pointers.  With
any luck, this should make diagnosing such bugs easier in the future!

ddb/i386: Don't go out of the way to detect invalid addresses.
db_read_bytes already does this better (but didn't at the time this
check was originally added back in 1998).  Not sure if this code had
the same mistake as the amd64 code causing it to trip over its own
shoelaces, but there should be no need for it here.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.27.4.1 src/sys/arch/amd64/amd64/db_disasm.c
cvs rdiff -u -r1.48 -r1.48.4.1 src/sys/arch/i386/i386/db_disasm.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/db_disasm.c
diff -u src/sys/arch/amd64/amd64/db_disasm.c:1.27 src/sys/arch/amd64/amd64/db_disasm.c:1.27.4.1
--- src/sys/arch/amd64/amd64/db_disasm.c:1.27	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/amd64/amd64/db_disasm.c	Mon Jun 21 17:32:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.27 2019/03/09 08:42:25 maxv Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.27.4.1 2021/06/21 17:32:52 martin Exp $	*/
 
 /* 
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.27 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.27.4.1 2021/06/21 17:32:52 martin Exp $");
 
 #ifndef _KERNEL
 #include 
@@ -1191,33 +1191,8 @@ db_disasm(db_addr_t loc, bool altfmt)
 	uint64_t imm64;
 	int	len;
 	struct i_addr	address;
-#ifdef _KERNEL
-	pt_entry_t *pte, *pde;
-#endif
 	u_int	rex = 0;
 
-#ifdef _KERNEL
-	/*
-	 * Don't try to disassemble the location if the mapping is invalid.
-	 * If we do, we'll fault, and end up debugging the debugger!
-	 * in the case of largepages, "pte" is really the pde and "pde" is
-	 * really the entry for the pdp itself.
-	 */
-	if ((vaddr_t)loc >= VM_MIN_KERNEL_ADDRESS)
-		pte = kvtopte((vaddr_t)loc);
-	else
-		pte = vtopte((vaddr_t)loc);
-	if ((vaddr_t)pte >= VM_MIN_KERNEL_ADDRESS)
-		pde = kvtopte((vaddr_t)pte);
-	else
-		pde = vtopte((vaddr_t)pte);
-
-	if ((*pde & PTE_P) == 0 || (*pte & PTE_P) == 0) {
-		db_printf("invalid address\n");
-		return (loc);
-	}
-#endif
-
 	get_value_inc(inst, loc, 1, false);
 	short_addr = false;
 	size = LONG;

Index: src/sys/arch/i386/i386/db_disasm.c
diff -u src/sys/arch/i386/i386/db_disasm.c:1.48 src/sys/arch/i386/i386/db_disasm.c:1.48.4.1
--- src/sys/arch/i386/i386/db_disasm.c:1.48	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/i386/i386/db_disasm.c	Mon Jun 21 17:32:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.48 2019/03/09 08:42:25 maxv Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.48.4.1 2021/06/21 17:32:52 martin Exp $	*/
 
 /* 
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.48 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.48.4.1 2021/06/21 17:32:52 martin Exp $");
 
 #include 
 #include 
@@ -1132,26 +1132,6 @@ db_disasm(db_addr_t loc, bool altfmt)
 	int	len;
 	struct i_addr	address;
 
-#ifdef _KERNEL
-	pt_entry_t *pte, *pde;
-
-	/*
-	 * Don't try to disassemble the location if the mapping is invalid.
-	 * If we do, we'll fault, and end up debugging the debugger!
-	 * in the case of largepages, "pte" is really the pde and "pde" is
-	 * really the entry for the pdp itself.
-	 */
-	if ((vaddr_t)loc >= VM_MIN_KERNEL_ADDRESS)
-		pte = kvtopte((vaddr_t)loc);
-	else
-		pte = vtopte((vaddr_t)loc);
-	pde = vtopte((vaddr_t)pte);
-	if ((*pde & PTE_P) == 0 || (*pte & PTE_P) == 0) {
-		db_printf("invalid address\n");
-		return (loc);
-	}
-#endif
-
 	get_value_inc(inst, loc, 1, false);
 	short_addr = false;
 	size = LONG;



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

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 17:27:57 UTC 2021

Modified Files:
src/sys/dev/usb [netbsd-9]: umass.c umass_scsipi.c

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

sys/dev/usb/umass.c: revision 1.185
sys/dev/usb/umass_scsipi.c: revision 1.68

umass(4): Use an empty function callback, not null pointer.

This stupid bug, with an `XXX Broken!' comment right above, has been
preventing NetBSD from suspend/resume with a USB drive plugged in for
longer than I want to even think about admitting.  *sigh*
umass(4): Assert that we got a cb up front.

Avoids jump to zero waaay down the line where we've forgotten why
we wanted to jump into oblivion.


To generate a diff of this commit:
cvs rdiff -u -r1.175.2.1 -r1.175.2.2 src/sys/dev/usb/umass.c
cvs rdiff -u -r1.62 -r1.62.2.1 src/sys/dev/usb/umass_scsipi.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/umass.c
diff -u src/sys/dev/usb/umass.c:1.175.2.1 src/sys/dev/usb/umass.c:1.175.2.2
--- src/sys/dev/usb/umass.c:1.175.2.1	Sun Mar  1 12:38:59 2020
+++ src/sys/dev/usb/umass.c	Mon Jun 21 17:27:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: umass.c,v 1.175.2.1 2020/03/01 12:38:59 martin Exp $	*/
+/*	$NetBSD: umass.c,v 1.175.2.2 2021/06/21 17:27:57 martin Exp $	*/
 
 /*
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.175.2.1 2020/03/01 12:38:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.175.2.2 2021/06/21 17:27:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1105,6 +1105,7 @@ umass_bbb_transfer(struct umass_softc *s
 	UMASSHIST_FUNC(); UMASSHIST_CALLED();
 	static int dCBWtag = 42;	/* unique for CBW of transfer */
 
+	KASSERT(cb);
 	DPRINTFM(UDMASS_BBB, "sc %#jx cmd=0x%02jx", (uintptr_t)sc,
 	*(u_char *)cmd, 0, 0);
 
@@ -1629,6 +1630,7 @@ umass_cbi_transfer(struct umass_softc *s
 	DPRINTFM(UDMASS_CBI, "sc %#jx: cmd=0x%02jx, len=%jd",
 	 (uintptr_t)sc, *(u_char *)cmd, datalen, 0);
 
+	KASSERT(cb);
 	KASSERTMSG(sc->sc_wire & (UMASS_WPROTO_CBI|UMASS_WPROTO_CBI_I),
 		   "sc->sc_wire == 0x%02x wrong for umass_cbi_transfer\n",
 		   sc->sc_wire);

Index: src/sys/dev/usb/umass_scsipi.c
diff -u src/sys/dev/usb/umass_scsipi.c:1.62 src/sys/dev/usb/umass_scsipi.c:1.62.2.1
--- src/sys/dev/usb/umass_scsipi.c:1.62	Thu May 30 21:44:49 2019
+++ src/sys/dev/usb/umass_scsipi.c	Mon Jun 21 17:27:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: umass_scsipi.c,v 1.62 2019/05/30 21:44:49 mlelstv Exp $	*/
+/*	$NetBSD: umass_scsipi.c,v 1.62.2.1 2021/06/21 17:27:57 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.62 2019/05/30 21:44:49 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.62.2.1 2021/06/21 17:27:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -101,6 +101,8 @@ Static int umass_scsipi_ioctl(struct scs
 Static int umass_scsipi_getgeom(struct scsipi_periph *,
 struct disk_parms *, u_long);
 
+Static void umass_null_cb(struct umass_softc *, void *,
+			  int, int);
 Static void umass_scsipi_cb(struct umass_softc *, void *,
 			int, int);
 Static void umass_scsipi_sense_cb(struct umass_softc *, void *,
@@ -319,7 +321,7 @@ umass_scsipi_request(struct scsipi_chann
 		  cmdlen, xs->data,
 		  xs->datalen, dir,
 		  xs->timeout, USBD_SYNCHRONOUS,
-		  0, xs);
+		  umass_null_cb, xs);
 			DPRINTFM(UDMASS_SCSI, "done err=%jd",
 			scbus->sc_sync_status, 0, 0, 0);
 			switch (scbus->sc_sync_status) {
@@ -419,6 +421,12 @@ umass_scsipi_getgeom(struct scsipi_perip
 }
 
 Static void
+umass_null_cb(struct umass_softc *sc, void *priv, int residue, int status)
+{
+	UMASSHIST_FUNC(); UMASSHIST_CALLED();
+}
+
+Static void
 umass_scsipi_cb(struct umass_softc *sc, void *priv, int residue, int status)
 {
 	UMASSHIST_FUNC(); UMASSHIST_CALLED();



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

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 17:25:48 UTC 2021

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c nvmevar.h
src/sys/dev/pci [netbsd-9]: nvme_pci.c

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

sys/dev/ic/nvmevar.h: revision 1.22
sys/dev/ic/nvme.c: revision 1.56
sys/dev/ic/nvme.c: revision 1.57
sys/dev/pci/nvme_pci.c: revision 1.30

nvme(4): Add suspend/resume, derived from OpenBSD.

nvme(4): Move disestablishment of admin q interrupt to nvme_detach.

Nothing re-established this after suspend/resume, so attempting
suspend/resume/suspend would crash, and presumably we would miss
interrupts after resume.  This keeps the establish/disestablish more
symmetric in attach/detach.


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.5 -r1.44.2.6 src/sys/dev/ic/nvme.c
cvs rdiff -u -r1.20 -r1.20.2.1 src/sys/dev/ic/nvmevar.h
cvs rdiff -u -r1.26 -r1.26.4.1 src/sys/dev/pci/nvme_pci.c

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

Modified files:

Index: src/sys/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.44.2.5 src/sys/dev/ic/nvme.c:1.44.2.6
--- src/sys/dev/ic/nvme.c:1.44.2.5	Mon Dec  7 20:04:07 2020
+++ src/sys/dev/ic/nvme.c	Mon Jun 21 17:25:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.44.2.5 2020/12/07 20:04:07 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.44.2.6 2021/06/21 17:25:48 martin 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.44.2.5 2020/12/07 20:04:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.6 2021/06/21 17:25:48 martin Exp $");
 
 #include 
 #include 
@@ -81,6 +81,7 @@ static void	nvme_empty_done(struct nvme_
 static struct nvme_queue *
 		nvme_q_alloc(struct nvme_softc *, uint16_t, u_int, u_int);
 static int	nvme_q_create(struct nvme_softc *, struct nvme_queue *);
+static void	nvme_q_reset(struct nvme_softc *, struct nvme_queue *);
 static int	nvme_q_delete(struct nvme_softc *, struct nvme_queue *);
 static void	nvme_q_submit(struct nvme_softc *, struct nvme_queue *,
 		struct nvme_ccb *, void (*)(struct nvme_queue *,
@@ -338,7 +339,6 @@ nvme_attach(struct nvme_softc *sc)
 {
 	uint64_t cap;
 	uint32_t reg;
-	u_int dstrd;
 	u_int mps = PAGE_SHIFT;
 	u_int ncq, nsq;
 	uint16_t adminq_entries = nvme_adminq_size;
@@ -359,7 +359,7 @@ nvme_attach(struct nvme_softc *sc)
 		NVME_VS_MNR(reg), NVME_VS_TER(reg));
 
 	cap = nvme_read8(sc, NVME_CAP);
-	dstrd = NVME_CAP_DSTRD(cap);
+	sc->sc_dstrd = NVME_CAP_DSTRD(cap);
 	if (NVME_CAP_MPSMIN(cap) > PAGE_SHIFT) {
 		aprint_error_dev(sc->sc_dev, "NVMe minimum page size %u "
 		"is greater than CPU page size %u\n",
@@ -382,7 +382,8 @@ nvme_attach(struct nvme_softc *sc)
 		return 1;
 	}
 
-	sc->sc_admin_q = nvme_q_alloc(sc, NVME_ADMIN_Q, adminq_entries, dstrd);
+	sc->sc_admin_q = nvme_q_alloc(sc, NVME_ADMIN_Q, adminq_entries,
+	sc->sc_dstrd);
 	if (sc->sc_admin_q == NULL) {
 		aprint_error_dev(sc->sc_dev,
 		"unable to allocate admin queue\n");
@@ -427,7 +428,8 @@ nvme_attach(struct nvme_softc *sc)
 
 	sc->sc_q = kmem_zalloc(sizeof(*sc->sc_q) * sc->sc_nq, KM_SLEEP);
 	for (i = 0; i < sc->sc_nq; i++) {
-		sc->sc_q[i] = nvme_q_alloc(sc, i + 1, ioq_entries, dstrd);
+		sc->sc_q[i] = nvme_q_alloc(sc, i + 1, ioq_entries,
+		sc->sc_dstrd);
 		if (sc->sc_q[i] == NULL) {
 			aprint_error_dev(sc->sc_dev,
 			"unable to allocate io queue\n");
@@ -550,6 +552,7 @@ nvme_detach(struct nvme_softc *sc, int f
 		return error;
 
 	/* from now on we are committed to detach, following will never fail */
+	sc->sc_intr_disestablish(sc, NVME_ADMIN_Q);
 	for (i = 0; i < sc->sc_nq; i++)
 		nvme_q_free(sc, sc->sc_q[i]);
 	kmem_free(sc->sc_q, sizeof(*sc->sc_q) * sc->sc_nq);
@@ -558,6 +561,68 @@ nvme_detach(struct nvme_softc *sc, int f
 	return 0;
 }
 
+int
+nvme_suspend(struct nvme_softc *sc)
+{
+
+	return nvme_shutdown(sc);
+}
+
+int
+nvme_resume(struct nvme_softc *sc)
+{
+	int ioq_entries = nvme_ioq_size;
+	uint64_t cap;
+	int i, error;
+
+	error = nvme_disable(sc);
+	if (error) {
+		device_printf(sc->sc_dev, "unable to disable controller\n");
+		return error;
+	}
+
+	nvme_q_reset(sc, sc->sc_admin_q);
+
+	error = nvme_enable(sc, ffs(sc->sc_mps) - 1);
+	if (error) {
+		device_printf(sc->sc_dev, "unable to enable controller\n");
+		return error;
+	}
+
+	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;
+		}
+		if (nvme_q_create(sc, sc->sc_q[i]) != 0) {
+			error = EIO;
+			device_printf(sc->sc_dev, "unable to create io q %d"
+			"\n", 

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

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 17:23:13 UTC 2021

Modified Files:
src/sys/dev [netbsd-9]: ld.c ldvar.h

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

sys/dev/ldvar.h: revision 1.35
sys/dev/ld.c: revision 1.112

ld(4): Block requests while suspended until resumed.

Otherwise nothing stops us from continuing to feed I/O to the disk
controller when it expects that the queues are quiesced as it pokes
registers to change its power states.  Fixes resume during disk
activity on my T480 with nvme.


To generate a diff of this commit:
cvs rdiff -u -r1.106.4.2 -r1.106.4.3 src/sys/dev/ld.c
cvs rdiff -u -r1.33 -r1.33.4.1 src/sys/dev/ldvar.h

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

Modified files:

Index: src/sys/dev/ld.c
diff -u src/sys/dev/ld.c:1.106.4.2 src/sys/dev/ld.c:1.106.4.3
--- src/sys/dev/ld.c:1.106.4.2	Sat Mar 21 15:52:09 2020
+++ src/sys/dev/ld.c	Mon Jun 21 17:23:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld.c,v 1.106.4.2 2020/03/21 15:52:09 martin Exp $	*/
+/*	$NetBSD: ld.c,v 1.106.4.3 2021/06/21 17:23:13 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.106.4.2 2020/03/21 15:52:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.106.4.3 2021/06/21 17:23:13 martin Exp $");
 
 #include 
 #include 
@@ -63,6 +63,7 @@ __KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.106
 
 static void	ldminphys(struct buf *bp);
 static bool	ld_suspend(device_t, const pmf_qual_t *);
+static bool	ld_resume(device_t, const pmf_qual_t *);
 static bool	ld_shutdown(device_t, int);
 static int	ld_diskstart(device_t, struct buf *bp);
 static void	ld_iosize(device_t, int *);
@@ -160,7 +161,8 @@ ldattach(struct ld_softc *sc, const char
 	bufq_alloc(>sc_bufq, default_strategy, BUFQ_SORT_RAWBLOCK);
 
 	/* Register with PMF */
-	if (!pmf_device_register1(dksc->sc_dev, ld_suspend, NULL, ld_shutdown))
+	if (!pmf_device_register1(dksc->sc_dev, ld_suspend, ld_resume,
+		ld_shutdown))
 		aprint_error_dev(dksc->sc_dev,
 		"couldn't establish power handler\n");
 
@@ -266,7 +268,55 @@ ldenddetach(struct ld_softc *sc)
 static bool
 ld_suspend(device_t dev, const pmf_qual_t *qual)
 {
-	return ld_shutdown(dev, 0);
+	struct ld_softc *sc = device_private(dev);
+	int queuecnt;
+	bool ok = false;
+
+	/* Block new requests and wait for outstanding requests to drain.  */
+	mutex_enter(>sc_mutex);
+	KASSERT((sc->sc_flags & LDF_SUSPEND) == 0);
+	sc->sc_flags |= LDF_SUSPEND;
+	while ((queuecnt = sc->sc_queuecnt) > 0) {
+		if (cv_timedwait(>sc_drain, >sc_mutex, 30 * hz))
+			break;
+	}
+	mutex_exit(>sc_mutex);
+
+	/* Block suspend if we couldn't drain everything in 30sec.  */
+	if (queuecnt > 0) {
+		device_printf(dev, "timeout draining buffers\n");
+		goto out;
+	}
+
+	/* Flush cache before we lose power.  If we can't, block suspend.  */
+	if (ld_flush(dev, /*poll*/false) != 0) {
+		device_printf(dev, "failed to flush cache\n");
+		goto out;
+	}
+
+	/* Success!  */
+	ok = true;
+
+out:	if (!ok)
+		(void)ld_resume(dev, qual);
+	return ok;
+}
+
+static bool
+ld_resume(device_t dev, const pmf_qual_t *qual)
+{
+	struct ld_softc *sc = device_private(dev);
+
+	/* Allow new requests to come in.  */
+	mutex_enter(>sc_mutex);
+	KASSERT(sc->sc_flags & LDF_SUSPEND);
+	sc->sc_flags &= ~LDF_SUSPEND;
+	mutex_exit(>sc_mutex);
+
+	/* Restart any pending queued requests.  */
+	dk_start(>sc_dksc, NULL);
+
+	return true;
 }
 
 /* ARGSUSED */
@@ -428,17 +478,24 @@ ld_diskstart(device_t dev, struct buf *b
 	struct ld_softc *sc = device_private(dev);
 	int error;
 
-	if (sc->sc_queuecnt >= sc->sc_maxqueuecnt)
+	if (sc->sc_queuecnt >= sc->sc_maxqueuecnt ||
+	sc->sc_flags & LDF_SUSPEND) {
+		if (sc->sc_flags & LDF_SUSPEND)
+			aprint_debug_dev(dev, "i/o blocked while suspended\n");
 		return EAGAIN;
+	}
 
 	if ((sc->sc_flags & LDF_MPSAFE) == 0)
 		KERNEL_LOCK(1, curlwp);
 
 	mutex_enter(>sc_mutex);
 
-	if (sc->sc_queuecnt >= sc->sc_maxqueuecnt)
+	if (sc->sc_queuecnt >= sc->sc_maxqueuecnt ||
+	sc->sc_flags & LDF_SUSPEND) {
+		if (sc->sc_flags & LDF_SUSPEND)
+			aprint_debug_dev(dev, "i/o blocked while suspended\n");
 		error = EAGAIN;
-	else {
+	} else {
 		error = (*sc->sc_start)(sc, bp);
 		if (error == 0)
 			sc->sc_queuecnt++;

Index: src/sys/dev/ldvar.h
diff -u src/sys/dev/ldvar.h:1.33 src/sys/dev/ldvar.h:1.33.4.1
--- src/sys/dev/ldvar.h:1.33	Tue Mar 19 07:01:14 2019
+++ src/sys/dev/ldvar.h	Mon Jun 21 17:23:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldvar.h,v 1.33 2019/03/19 07:01:14 mlelstv Exp $	*/
+/*	$NetBSD: ldvar.h,v 1.33.4.1 2021/06/21 17:23:13 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -70,6 +70,7 @@ struct ld_softc {
 #define	LDF_DRAIN	0x020		/* maxqueuecnt has changed; drain */
 #define	LDF_NO_RND	0x040		/* do not attach rnd source */
 #define	LDF_MPSAFE	0x080		/* 

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

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 17:19:55 UTC 2021

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: dwiic_pci.c

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

sys/arch/x86/pci/dwiic_pci.c: revision 1.5 (patch)

dwiic(4): Attribute output correctly and relegate to debug-level.

Tidy up a little while here.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.4.1 src/sys/arch/x86/pci/dwiic_pci.c

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

Modified files:

Index: src/sys/arch/x86/pci/dwiic_pci.c
diff -u src/sys/arch/x86/pci/dwiic_pci.c:1.2 src/sys/arch/x86/pci/dwiic_pci.c:1.2.4.1
--- src/sys/arch/x86/pci/dwiic_pci.c:1.2	Wed Sep 26 19:06:33 2018
+++ src/sys/arch/x86/pci/dwiic_pci.c	Mon Jun 21 17:19:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dwiic_pci.c,v 1.2 2018/09/26 19:06:33 jakllsch Exp $ */
+/* $NetBSD: dwiic_pci.c,v 1.2.4.1 2021/06/21 17:19:55 martin Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwiic_pci.c,v 1.2 2018/09/26 19:06:33 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwiic_pci.c,v 1.2.4.1 2021/06/21 17:19:55 martin Exp $");
 
 #include 
 #include 
@@ -68,9 +68,8 @@ struct pci_dwiic_softc {
 static uint32_t
 lpss_read(struct pci_dwiic_softc *sc, int offset)
 {
-	u_int32_t b = bus_space_read_4(sc->sc_dwiic.sc_iot, sc->sc_dwiic.sc_ioh,
-	 offset);
-	return b;
+	return bus_space_read_4(sc->sc_dwiic.sc_iot, sc->sc_dwiic.sc_ioh,
+	offset);
 }
 
 static void
@@ -169,7 +168,7 @@ pci_dwiic_attach(device_t parent, device
 	pa->pa_bus, pa->pa_device, pa->pa_function);
 
 	if (sc->sc_acpinode) {
-		sc->sc_dwiic.sc_iba.iba_child_devices = 
+		sc->sc_dwiic.sc_iba.iba_child_devices =
 		acpi_enter_i2c_devs(sc->sc_acpinode);
 	} else {
 		aprint_verbose_dev(self, "no matching ACPI node\n");
@@ -188,13 +187,18 @@ out:
 static bool
 dwiic_pci_power(struct dwiic_softc *dwsc, bool power)
 {
-	struct pci_dwiic_softc *sc = (void *)dwsc;
-	pcireg_t pmreg;
-
-	printf("status 0x%x\n", pci_conf_read(sc->sc_pc, sc->sc_ptag, PCI_COMMAND_STATUS_REG));
-	printf("reset 0x%x\n", lpss_read(sc, LPSS_RESET));
-	printf("rlo 0x%x\n", lpss_read(sc, LPSS_REMAP_LO));
-	printf("rho 0x%x\n", lpss_read(sc, LPSS_REMAP_HI));
+	struct pci_dwiic_softc *sc = container_of(dwsc, struct pci_dwiic_softc,
+	sc_dwiic);
+	pcireg_t pmreg, csr;
+	uint32_t reset, rlo, rhi;
+
+	csr = pci_conf_read(sc->sc_pc, sc->sc_ptag, PCI_COMMAND_STATUS_REG);
+	reset = lpss_read(sc, LPSS_RESET);
+	rlo = lpss_read(sc, LPSS_REMAP_LO);
+	rhi = lpss_read(sc, LPSS_REMAP_HI);
+	aprint_debug_dev(dwsc->sc_dev,
+	"status 0x%x reset 0x%x rlo 0x%x rhi 0x%x\n",
+	csr, reset, rlo, rhi);
 
 	if (!power)
 		lpss_write(sc, LPSS_CLKGATE, LPSS_CLKGATE_CTRL_OFF);
@@ -205,7 +209,7 @@ dwiic_pci_power(struct dwiic_softc *dwsc
 		pci_conf_write(sc->sc_pc, sc->sc_ptag, pmreg + PCI_PMCSR,
 		power ? PCI_PMCSR_STATE_D0 : PCI_PMCSR_STATE_D3);
 		DELAY(1); /* 10 milliseconds */
-		DPRINTF((" -> 0x%x\n", 
+		DPRINTF((" -> 0x%x\n",
 		pci_conf_read(sc->sc_pc, sc->sc_ptag, pmreg + PCI_PMCSR)));
 	}
 	if (power) {



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

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 17:15:38 UTC 2021

Modified Files:
src/sys/dev/usb [netbsd-9]: ualea.c

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

sys/dev/usb/ualea.c: revision 1.13

ualea(4): Null suspend/resume handler.


To generate a diff of this commit:
cvs rdiff -u -r1.9.10.2 -r1.9.10.3 src/sys/dev/usb/ualea.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/ualea.c
diff -u src/sys/dev/usb/ualea.c:1.9.10.2 src/sys/dev/usb/ualea.c:1.9.10.3
--- src/sys/dev/usb/ualea.c:1.9.10.2	Wed Jul 15 13:52:05 2020
+++ src/sys/dev/usb/ualea.c	Mon Jun 21 17:15:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ualea.c,v 1.9.10.2 2020/07/15 13:52:05 martin Exp $	*/
+/*	$NetBSD: ualea.c,v 1.9.10.3 2021/06/21 17:15:38 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.9.10.2 2020/07/15 13:52:05 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.9.10.3 2021/06/21 17:15:38 martin Exp $");
 
 #include 
 #include 
@@ -144,6 +144,10 @@ ualea_attach(device_t parent, device_t s
 		return;
 	}
 
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(sc->sc_dev, "failed to register power handler"
+		"\n");
+
 	/* Success!  We are ready to run.  */
 	mutex_enter(>sc_lock);
 	sc->sc_attached = true;



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

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 17:11:46 UTC 2021

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

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

sys/dev/usb/xhci.c: revision 1.140
sys/dev/usb/xhci.c: revision 1.141
sys/dev/usb/xhci.c: revision 1.143
sys/dev/usb/xhcivar.h: revision 1.18
sys/dev/usb/xhcivar.h: revision 1.19
sys/dev/usb/xhcireg.h: revision 1.19
sys/dev/usb/xhci.c: revision 1.139

xhci(4): Draft suspend/resume.

Work almost entirely done and tested by maya@ based on xhci 1.2 spec;
tidied up and tweaked by me.

Not sure about issuing Stop Endpoint commands or ensuring the Command
Ring is in the Stopped or Idle state, but this seems to work as is,
so it's already an improvement over what we had before which was no
xhci suspend/resume at all.

In particular, it's not clear to us:
- if we don't have any pending USB activity whether we need to issue
  the Stop Endpoints or quiesce the command ring; but
- if we do have any pending USB activity whether issuing Stop
  Endpoint is enough or whether we also need to do anything to
  synchronize with other software logic to quiesce it too.

xhci(4): Block commands and issue Stop Endpoint on suspend.

xhci: Fix logic in waiting for command queue access.
_Either_ an existing command in progress, _or_ an existing suspend in
progress that is not done by us, should block us; the logic I wrote
previously erroneously blocked only if both conditions happened at
the same time.

Should fix issue reported by Andrius V in the PR kern/56050 followup
discussion.

xhci(4): Wait USB_RESUME_WAIT ms, not 20 ms.
Better to use the named constant, and although the spec says 20 ms is
enough, apparently for some devices it's not.


To generate a diff of this commit:
cvs rdiff -u -r1.107.2.7 -r1.107.2.8 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.13 -r1.13.2.1 src/sys/dev/usb/xhcireg.h
cvs rdiff -u -r1.11 -r1.11.4.1 src/sys/dev/usb/xhcivar.h

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

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.107.2.7 src/sys/dev/usb/xhci.c:1.107.2.8
--- src/sys/dev/usb/xhci.c:1.107.2.7	Wed Dec 23 12:34:38 2020
+++ src/sys/dev/usb/xhci.c	Mon Jun 21 17:11:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.107.2.7 2020/12/23 12:34:38 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.107.2.8 2021/06/21 17:11:46 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.7 2020/12/23 12:34:38 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.8 2021/06/21 17:11:46 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -154,6 +154,8 @@ static int xhci_roothub_ctrl(struct usbd
 static usbd_status xhci_configure_endpoint(struct usbd_pipe *);
 //static usbd_status xhci_unconfigure_endpoint(struct usbd_pipe *);
 static usbd_status xhci_reset_endpoint(struct usbd_pipe *);
+static usbd_status xhci_stop_endpoint_cmd(struct xhci_softc *,
+struct xhci_slot *, u_int, uint32_t);
 static usbd_status xhci_stop_endpoint(struct usbd_pipe *);
 
 static void xhci_host_dequeue(struct xhci_ring * const);
@@ -369,7 +371,6 @@ xhci_rt_write_4(const struct xhci_softc 
 	bus_space_write_4(sc->sc_iot, sc->sc_rbh, offset, value);
 }
 
-#if 0 /* unused */
 static inline uint64_t
 xhci_rt_read_8(const struct xhci_softc * const sc, bus_size_t offset)
 {
@@ -389,7 +390,6 @@ xhci_rt_read_8(const struct xhci_softc *
 
 	return value;
 }
-#endif /* unused */
 
 static inline void
 xhci_rt_write_8(const struct xhci_softc * const sc, bus_size_t offset,
@@ -678,15 +678,408 @@ xhci_activate(device_t self, enum devact
 }
 
 bool
-xhci_suspend(device_t dv, const pmf_qual_t *qual)
+xhci_suspend(device_t self, const pmf_qual_t *qual)
 {
-	return false;
+	struct xhci_softc * const sc = device_private(self);
+	size_t i, j, bn, dci;
+	int port;
+	uint32_t v;
+	usbd_status err;
+	bool ok = false;
+
+	XHCIHIST_FUNC(); XHCIHIST_CALLED();
+
+	mutex_enter(>sc_lock);
+
+	/*
+	 * Block issuance of new commands, and wait for all pending
+	 * commands to complete.
+	 */
+	KASSERT(sc->sc_suspender == NULL);
+	sc->sc_suspender = curlwp;
+	while (sc->sc_command_addr != 0)
+		cv_wait(>sc_cmdbusy_cv, >sc_lock);
+
+	/*
+	 * xHCI Requirements Specification 1.2, May 2019, Sec. 4.23.2:
+	 * xHCI Power Management, p. 342
+	 * https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/extensible-host-controler-interface-usb-xhci.pdf#page=342
+	 */
+
+	/*
+	 * `1. Stop all USB activity by issuing Stop Endpoint Commands
+	 * for Busy endpoints in the Running state.  If the Force
+	 * Save Context Capability (FSC = ``0'') is not supported,
+	 * then Stop Endpoint Commands shall be issued for all idle
+	 * endpoints in the Running 

CVS commit: [netbsd-9] src/sys/external/bsd/drm2/dist/drm/i915

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 16:41:02 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915 [netbsd-9]: i915_drv.h

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

sys/external/bsd/drm2/dist/drm/i915/i915_drv.h: revision 1.33 (patch)

i915drmkms: Fix LOCKDEBUG panic and potential deadlock.

This path is taken with a spin lock held, and possibly even in
interrupt context, where taking vmobjlock is not kosher, but we are
guaranteed to have the queue populated and unchanging.

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.29.2.1 -r1.29.2.2 \
src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.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/external/bsd/drm2/dist/drm/i915/i915_drv.h
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.29.2.1 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.29.2.2
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.29.2.1	Thu Dec 12 21:00:32 2019
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h	Mon Jun 21 16:41:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_drv.h,v 1.29.2.1 2019/12/12 21:00:32 martin Exp $	*/
+/*	$NetBSD: i915_drv.h,v 1.29.2.2 2021/06/21 16:41:02 martin Exp $	*/
 
 /* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
  */
@@ -3021,9 +3021,10 @@ i915_gem_object_get_page(struct drm_i915
 		 * lock to prevent them from disappearing.
 		 */
 		KASSERT(obj->pages != NULL);
-		mutex_enter(obj->base.filp->vmobjlock);
-		page = uvm_pagelookup(obj->base.filp, ptoa(n));
-		mutex_exit(obj->base.filp->vmobjlock);
+		TAILQ_FOREACH(page, >pageq, pageq.queue) {
+			if (n-- == 0)
+break;
+		}
 	}
 	KASSERT(page != NULL);
 	return container_of(page, struct page, p_vmp);



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

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 16:14:14 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: kern_ksyms.c

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

sys/kern/kern_ksyms.c: revision 1.90
sys/kern/kern_ksyms.c: revision 1.91
sys/kern/kern_ksyms.c: revision 1.92
sys/kern/kern_ksyms.c: revision 1.93
sys/kern/kern_ksyms.c: revision 1.94
sys/kern/kern_ksyms.c: revision 1.95
sys/kern/kern_ksyms.c: revision 1.96
sys/kern/kern_ksyms.c: revision 1.97

ksyms(4): Fix ksymsread synchronization.

Fixes crash on concurrent update and read of /dev/ksyms.
XXX Unclear why we have to skip sd_gone entries here -- it seems like
they should be preserved until ksymsclose.
ksyms(4): Modify ksyms_symtabs only at IPL_HIGH.

This limits the opportunities for ddb to witness an inconsistent
state of the symbol table list.
ksyms(4): Don't skip symbol tables that are soon to be freed.

They will not actually be freed until /dev/ksyms is closed, so
continued access to them remains kosher.
Revert "ksyms(4): Don't skip symbol tables that are soon to be freed."

Apparently the equality kassert this restored doesn't work; to be
analyzed.

Fix regression introduced in rev 1.90
in which the last element of ksyms_symtabs is skipped by mistake.

ksyms(4): Fix race in ksymsread iteration.
TAILQ_NEXT(ksyms_last_snapshot) might change while we are iterating,
but ksyms_last_snapshot itself cannot, so invert the loop structure.

Discussed with rin@.

ksyms(4): Don't skip symbol tables that are soon to be freed, take 2.

They will not actually be freed until /dev/ksyms is closed, so
continued access to them remains kosher.
The previous change was busted because of an off-by-one error in a
previous previous change's iteration over the symtabs; that error has
since been corrected.

ksyms(4): Allow multiple concurrent opens of /dev/ksyms.

First one takes a snapshot; others all agree with the snapshot.
Previously this code path was just broken (could fail horribly if
modules were unloaded after one of the opens is closed), so I just
blocked it off in an earlier commit, but that broke crash(8).  So
let's continue allowing multiple opens seeing the same snapshot, but
without the horrible bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.87.8.1 -r1.87.8.2 src/sys/kern/kern_ksyms.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_ksyms.c
diff -u src/sys/kern/kern_ksyms.c:1.87.8.1 src/sys/kern/kern_ksyms.c:1.87.8.2
--- src/sys/kern/kern_ksyms.c:1.87.8.1	Tue Jan  7 11:54:57 2020
+++ src/sys/kern/kern_ksyms.c	Mon Jun 21 16:14:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_ksyms.c,v 1.87.8.1 2020/01/07 11:54:57 martin Exp $	*/
+/*	$NetBSD: kern_ksyms.c,v 1.87.8.2 2021/06/21 16:14:14 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.87.8.1 2020/01/07 11:54:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.87.8.2 2021/06/21 16:14:14 martin Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_copy_symtab.h"
@@ -92,6 +92,8 @@ __KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #ifdef DDB
 #include 
@@ -110,7 +112,8 @@ static uint32_t *ksyms_nmap = NULL;
 #endif
 
 static int ksyms_maxlen;
-static bool ksyms_isopen;
+static uint64_t ksyms_opencnt;
+static struct ksyms_symtab *ksyms_last_snapshot;
 static bool ksyms_initted;
 static bool ksyms_loaded;
 static kmutex_t ksyms_lock __cacheline_aligned;
@@ -140,7 +143,7 @@ struct ksyms_hdr ksyms_hdr;
 int ksyms_symsz;
 int ksyms_strsz;
 int ksyms_ctfsz;	/* this is not currently used by savecore(8) */
-TAILQ_HEAD(, ksyms_symtab) ksyms_symtabs =
+TAILQ_HEAD(ksyms_symtab_queue, ksyms_symtab) ksyms_symtabs =
 TAILQ_HEAD_INITIALIZER(ksyms_symtabs);
 
 static int
@@ -296,6 +299,7 @@ addsymtab(const char *name, void *symsta
 	int i, j, n, nglob;
 	char *str;
 	int nsyms = symsize / sizeof(Elf_Sym);
+	int s;
 
 	/* Sanity check for pre-allocated map table used during startup. */
 	if ((nmap == ksyms_nmap) && (nsyms >= KSYMS_MAX_ID)) {
@@ -419,7 +423,7 @@ addsymtab(const char *name, void *symsta
 		for (new = 0; new < n; new++) {
 			uint32_t orig = nsym[new].st_size - 1;
 			uint32_t size = nmap[orig];
-	
+
 			nmap[orig] = new + 1;
 
 			/* restore the size */
@@ -428,9 +432,18 @@ addsymtab(const char *name, void *symsta
 	}
 #endif
 
-	/* ksymsread() is unlocked, so membar. */
-	membar_producer();
+	KASSERT(strcmp(name, "netbsd") == 0 || mutex_owned(_lock));
+	KASSERT(cold || mutex_owned(_lock));
+
+	/*
+	 * Ensure ddb never witnesses an inconsistent state of the
+	 * queue, unless memory is so corrupt that we crash in
+	 * TAILQ_INSERT_TAIL.
+	 */
+	s = splhigh();
 	

CVS commit: [netbsd-9] src/sys

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 14:52:58 UTC 2021

Modified Files:
src/sys/rump/include/rump [netbsd-9]: rump_namei.h
src/sys/sys [netbsd-9]: namei.h

Log Message:
Regen for ticket #1296


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.32.2.1 src/sys/rump/include/rump/rump_namei.h
cvs rdiff -u -r1.98 -r1.98.2.1 src/sys/sys/namei.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/rump/include/rump/rump_namei.h
diff -u src/sys/rump/include/rump/rump_namei.h:1.32 src/sys/rump/include/rump/rump_namei.h:1.32.2.1
--- src/sys/rump/include/rump/rump_namei.h:1.32	Mon Jun  3 06:05:39 2019
+++ src/sys/rump/include/rump/rump_namei.h	Mon Jun 21 14:52:58 2021
@@ -1,11 +1,11 @@
-/*	$NetBSD: rump_namei.h,v 1.32 2019/06/03 06:05:39 msaitoh Exp $	*/
+/*	$NetBSD: rump_namei.h,v 1.32.2.1 2021/06/21 14:52:58 martin Exp $	*/
 
 
 /*
  * WARNING: GENERATED FILE.  DO NOT EDIT
  * (edit namei.src and run make namei in src/sys/sys)
  *   by:   NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp 
- *   from: NetBSD: namei.src,v 1.42 2019/06/03 06:04:21 msaitoh Exp 
+ *   from: NetBSD: namei.src,v 1.42.2.1 2021/06/21 14:50:57 martin Exp 
  */
 
 #ifndef _RUMP_RUMP_NAMEI_H_
@@ -24,7 +24,8 @@
 #define RUMP_NAMEI_NOFOLLOW	0x
 #define RUMP_NAMEI_EMULROOTSET	0x0080
 #define RUMP_NAMEI_NOCHROOT	0x0100
-#define RUMP_NAMEI_MODMASK	0x01fc
+#define RUMP_NAMEI_NONEXCLHACK	0x0200
+#define RUMP_NAMEI_MODMASK	0x03fc
 #define RUMP_NAMEI_NOCROSSMOUNT	0x100
 #define RUMP_NAMEI_RDONLY	0x200
 #define RUMP_NAMEI_ISDOTDOT	0x0002000

Index: src/sys/sys/namei.h
diff -u src/sys/sys/namei.h:1.98 src/sys/sys/namei.h:1.98.2.1
--- src/sys/sys/namei.h:1.98	Mon Jun  3 06:05:39 2019
+++ src/sys/sys/namei.h	Mon Jun 21 14:52:58 2021
@@ -1,11 +1,11 @@
-/*	$NetBSD: namei.h,v 1.98 2019/06/03 06:05:39 msaitoh Exp $	*/
+/*	$NetBSD: namei.h,v 1.98.2.1 2021/06/21 14:52:58 martin Exp $	*/
 
 
 /*
  * WARNING: GENERATED FILE.  DO NOT EDIT
  * (edit namei.src and run make namei in src/sys/sys)
  *   by:   NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp 
- *   from: NetBSD: namei.src,v 1.42 2019/06/03 06:04:21 msaitoh Exp 
+ *   from: NetBSD: namei.src,v 1.42.2.1 2021/06/21 14:50:57 martin Exp 
  */
 
 /*
@@ -160,7 +160,8 @@ struct nameidata {
 #define	EMULROOTSET	0x0080	/* emulation root already
 	   in ni_erootdir */
 #define	NOCHROOT	0x0100	/* no chroot on abs path lookups */
-#define	MODMASK		0x01fc	/* mask of operational modifiers */
+#define	NONEXCLHACK	0x0200	/* open wwith O_CREAT but not O_EXCL */
+#define	MODMASK		0x03fc	/* mask of operational modifiers */
 /*
  * Namei parameter descriptors.
  */
@@ -351,7 +352,8 @@ struct	nchstats _NAMEI_CACHE_STATS(uint6
 #define NAMEI_NOFOLLOW	0x
 #define NAMEI_EMULROOTSET	0x0080
 #define NAMEI_NOCHROOT	0x0100
-#define NAMEI_MODMASK	0x01fc
+#define NAMEI_NONEXCLHACK	0x0200
+#define NAMEI_MODMASK	0x03fc
 #define NAMEI_NOCROSSMOUNT	0x100
 #define NAMEI_RDONLY	0x200
 #define NAMEI_ISDOTDOT	0x0002000



CVS commit: [netbsd-9] src/sys

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 14:50:57 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: vfs_lookup.c vfs_vnops.c
src/sys/sys [netbsd-9]: namei.src

Log Message:
Pull up following revision(s) (requested by dholland in ticket #1296):

sys/sys/namei.src: revision 1.59(via patch)
sys/kern/vfs_vnops.c: revision 1.215
sys/kern/vfs_lookup.c: revision 1.226

Add a new namei flag NONEXCLHACK for open with O_CREAT and not O_EXCL.
This case needs to be distinguished from the other CREATE operations
because it is supposed to successfully return (and open) the target if
it exists. In the case where that target is the root, or a mount
point, such that there's no parent dir, "real" CREATE operations fail,
but O_CREAT without O_EXCL needs to succeed.

So (a) add the flag, (b) test for it in namei in the situation
described above, (c) set it in open under the appropriate
circumstances, and (d) because this can result in namei returning
ni_dvp of NULL, cope with that case.

Should get into -9 and maybe even -8, because it was prompted by
issues with 3rd-party code. The use of a flag (vs. adding an
additional nameiop, which would be more appropriate) was deliberate to
make the patch small and noninvasive.


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.212.2.1 src/sys/kern/vfs_lookup.c
cvs rdiff -u -r1.200 -r1.200.4.1 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.42 -r1.42.2.1 src/sys/sys/namei.src

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_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.212 src/sys/kern/vfs_lookup.c:1.212.2.1
--- src/sys/kern/vfs_lookup.c:1.212	Thu Jul 18 09:39:40 2019
+++ src/sys/kern/vfs_lookup.c	Mon Jun 21 14:50:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.212 2019/07/18 09:39:40 hannken Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.212.2.1 2021/06/21 14:50:57 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.212 2019/07/18 09:39:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.212.2.1 2021/06/21 14:50:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_magiclinks.h"
@@ -1434,10 +1434,33 @@ namei_oneroot(struct namei_state *state,
 		 * a CREATE, DELETE, or RENAME), and we don't have one
 		 * (because this is the root directory, or we crossed
 		 * a mount point), then we must fail.
+		 *
+		 * 20210604 dholland when NONEXCLHACK is set (open
+		 * with O_CREAT but not O_EXCL) skip this logic. Since
+		 * we have a foundobj, open will not be creating, so
+		 * it doesn't actually need or use the searchdir, so
+		 * it's ok to return it even if it's on a different
+		 * volume, and it's also ok to return NULL; by setting
+		 * NONEXCLHACK the open code promises to cope with
+		 * those cases correctly. (That is, it should do what
+		 * it would do anyway, that is, just release the
+		 * searchdir, except not crash if it's null.) This is
+		 * needed because otherwise opening mountpoints with
+		 * O_CREAT but not O_EXCL fails... which is a silly
+		 * thing to do but ought to work. (This whole issue
+		 * came to light because 3rd party code wanted to open
+		 * certain procfs nodes with O_CREAT for some 3rd
+		 * party reason, and it failed.)
+		 *
+		 * Note that NONEXCLHACK is properly a different
+		 * nameiop (it is partway between LOOKUP and CREATE)
+		 * but it was stuffed in as a flag instead to make the
+		 * resulting patch less invasive for pullup. Blah.
 		 */
 		if (cnp->cn_nameiop != LOOKUP &&
 		(searchdir == NULL ||
-		 searchdir->v_mount != foundobj->v_mount)) {
+		 searchdir->v_mount != foundobj->v_mount) &&
+		(cnp->cn_flags & NONEXCLHACK) == 0) {
 			if (searchdir) {
 vput(searchdir);
 			}

Index: src/sys/kern/vfs_vnops.c
diff -u src/sys/kern/vfs_vnops.c:1.200 src/sys/kern/vfs_vnops.c:1.200.4.1
--- src/sys/kern/vfs_vnops.c:1.200	Thu Mar  7 11:09:48 2019
+++ src/sys/kern/vfs_vnops.c	Mon Jun 21 14:50:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnops.c,v 1.200 2019/03/07 11:09:48 hannken Exp $	*/
+/*	$NetBSD: vfs_vnops.c,v 1.200.4.1 2021/06/21 14:50:57 martin Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.200 2019/03/07 11:09:48 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.200.4.1 2021/06/21 14:50:57 martin Exp $");
 
 #include "veriexec.h"
 
@@ -161,6 +161,8 @@ vn_open(struct nameidata *ndp, int fmode
 		if ((fmode & O_EXCL) == 0 &&
 		((fmode & O_NOFOLLOW) == 0))
 			ndp->ni_cnd.cn_flags |= FOLLOW;
+		if ((fmode & O_EXCL) == 0)
+			ndp->ni_cnd.cn_flags |= NONEXCLHACK;
 	} else {
 		ndp->ni_cnd.cn_nameiop = LOOKUP;
 		ndp->ni_cnd.cn_flags |= LOCKLEAF;
@@ -183,7 +185,12 @@ vn_open(struct nameidata *ndp, int fmode
 	error = 

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

2021-06-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun  5 10:51:41 UTC 2021

Modified Files:
src/sys/dev/pci [netbsd-9]: if_iwmreg.h

Log Message:
Pull up following revision(s) (requested by nia in ticket #1282):

sys/dev/pci/if_iwmreg.h: revision 1.8

Can't left shift a signed int by 31. Found by kubsan.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.8.1 src/sys/dev/pci/if_iwmreg.h

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

Modified files:

Index: src/sys/dev/pci/if_iwmreg.h
diff -u src/sys/dev/pci/if_iwmreg.h:1.7 src/sys/dev/pci/if_iwmreg.h:1.7.8.1
--- src/sys/dev/pci/if_iwmreg.h:1.7	Thu Apr 19 21:50:09 2018
+++ src/sys/dev/pci/if_iwmreg.h	Sat Jun  5 10:51:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwmreg.h,v 1.7 2018/04/19 21:50:09 christos Exp $	*/
+/*	$NetBSD: if_iwmreg.h,v 1.7.8.1 2021/06/05 10:51:41 martin Exp $	*/
 /*	OpenBSD: if_iwmreg.h,v 1.19 2016/09/20 11:46:09 stsp Exp 	*/
 
 /*-
@@ -191,7 +191,7 @@
 
 /* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
  * acknowledged (reset) by host writing "1" to flagged bits. */
-#define IWM_CSR_INT_BIT_FH_RX	(1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
+#define IWM_CSR_INT_BIT_FH_RX	(1U << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
 #define IWM_CSR_INT_BIT_HW_ERR	(1 << 29) /* DMA hardware error FH_INT[31] */
 #define IWM_CSR_INT_BIT_RX_PERIODIC	(1 << 28) /* Rx periodic */
 #define IWM_CSR_INT_BIT_FH_TX	(1 << 27) /* Tx DMA FH_INT[1:0] */
@@ -214,7 +214,7 @@
  IWM_CSR_INT_BIT_RX_PERIODIC)
 
 /* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
-#define IWM_CSR_FH_INT_BIT_ERR   (1 << 31) /* Error */
+#define IWM_CSR_FH_INT_BIT_ERR   (1U << 31) /* Error */
 #define IWM_CSR_FH_INT_BIT_HI_PRIOR  (1 << 30) /* High priority Rx, bypass coalescing */
 #define IWM_CSR_FH_INT_BIT_RX_CHNL1  (1 << 17) /* Rx channel 1 */
 #define IWM_CSR_FH_INT_BIT_RX_CHNL0  (1 << 16) /* Rx channel 0 */
@@ -405,7 +405,7 @@
 #define IWM_CSR_DBG_HPET_MEM_REG_VAL	(0x)
 
 /* DRAM INT TABLE */
-#define IWM_CSR_DRAM_INT_TBL_ENABLE		(1 << 31)
+#define IWM_CSR_DRAM_INT_TBL_ENABLE		(1U << 31)
 #define IWM_CSR_DRAM_INIT_TBL_WRITE_POINTER	(1 << 28)
 #define IWM_CSR_DRAM_INIT_TBL_WRAP_CHECK	(1 << 27)
 
@@ -558,7 +558,7 @@ enum iwm_secure_load_status_reg {
 #define IWM_HOST_INT_TIMEOUT_MAX	(0xFF)
 #define IWM_HOST_INT_TIMEOUT_DEF	(0x40)
 #define IWM_HOST_INT_TIMEOUT_MIN	(0x0)
-#define IWM_HOST_INT_OPER_MODE		(1 << 31)
+#define IWM_HOST_INT_OPER_MODE		(1U << 31)
 
 /*
  *7000/3000 series SHR DTS addresses *
@@ -643,7 +643,7 @@ enum iwm_ucode_tlv_flag {
 	IWM_UCODE_TLV_FLAGS_P2P_PS_UAPSD	= (1 << 26),
 	IWM_UCODE_TLV_FLAGS_BCAST_FILTERING	= (1 << 29),
 	IWM_UCODE_TLV_FLAGS_GO_UAPSD		= (1 << 30),
-	IWM_UCODE_TLV_FLAGS_LTE_COEX		= (1 << 31),
+	IWM_UCODE_TLV_FLAGS_LTE_COEX		= (1U << 31),
 };
 #define IWM_UCODE_TLV_FLAG_BITS \
 	"\020\1PAN\2NEWSCAN\3MFP\4P2P\5DW_BC_TABLE\6NEWBT_COEX\7PM_CMD\10SHORT_BL\11RX_ENERGY\12TIME_EVENT_V2\13D3_6_IPV6\14BF_UPDATED\15NO_BASIC_SSID\17D3_CONTINUITY\20NEW_NSOFFL_S\21NEW_NSOFFL_L\22SCHED_SCAN\24STA_KEY_CMD\25DEVICE_PS_CMD\26P2P_PS\27P2P_PS_DCM\30P2P_PS_SCM\31UAPSD_SUPPORT\32EBS\33P2P_PS_UAPSD\36BCAST_FILTERING\37GO_UAPSD\40LTE_COEX"
@@ -4369,7 +4369,7 @@ enum iwm_tx_flags {
 	IWM_TX_CMD_FLG_FW_DROP		= (1 << 26),
 	IWM_TX_CMD_FLG_EXEC_PAPD	= (1 << 27),
 	IWM_TX_CMD_FLG_PAPD_TYPE	= (1 << 28),
-	IWM_TX_CMD_FLG_HCCA_CHUNK	= (1 << 31)
+	IWM_TX_CMD_FLG_HCCA_CHUNK	= (1U << 31)
 }; /* IWM_TX_FLAGS_BITS_API_S_VER_1 */
 
 /**



CVS commit: [netbsd-9] src/sys/arch/hp300/conf

2021-06-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun  5 10:35:28 UTC 2021

Modified Files:
src/sys/arch/hp300/conf [netbsd-9]: INSTALL

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1280):

sys/arch/hp300/conf/INSTALL: revision 1.67
sys/arch/hp300/conf/INSTALL: revision 1.68

Add missed 'nhpib at intio' for internal HP-IB.  Found on testing HPDisk.
Also fix comments for HP-IB devices.
Should be pulled up to netbsd-8 and netbsd-9.

Reduce maxusers to 8 as GENERIC.
Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.64.4.1 -r1.64.4.2 src/sys/arch/hp300/conf/INSTALL

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/hp300/conf/INSTALL
diff -u src/sys/arch/hp300/conf/INSTALL:1.64.4.1 src/sys/arch/hp300/conf/INSTALL:1.64.4.2
--- src/sys/arch/hp300/conf/INSTALL:1.64.4.1	Mon Dec 14 17:29:35 2020
+++ src/sys/arch/hp300/conf/INSTALL	Sat Jun  5 10:35:28 2021
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.64.4.1 2020/12/14 17:29:35 martin Exp $
+# $NetBSD: INSTALL,v 1.64.4.2 2021/06/05 10:35:28 martin Exp $
 #
 # INSTALL machine description file
 #
@@ -40,7 +40,7 @@ options 	HP433
 options 	FPSP		# floating point interface for 68040
 
 # Need to set locally
-maxusers	32
+maxusers	8
 
 # Standard system options
 #include 	"conf/compat_netbsd09.config"
@@ -183,10 +183,11 @@ dcm*		at dio? scode ?	flags 0xe # DCM 4-
 
 le*		at dio? scode ?		# LANCE ethernet interfaces
 
-nhpib0		at dio? scode 7		# slow internal HP-IB
+nhpib*		at intio?		# internal HP-IB
+nhpib0		at dio? scode 7		# 98624A HP-IB
 nhpib*		at dio? scode ?
 
-fhpib*		at dio? scode ?		# `fast' HP-IB
+fhpib*		at dio? scode ?		# 98625A/98625B HP-IB
 
 hpibbus0	at nhpib0
 hpibbus*	at nhpib?



CVS commit: [netbsd-9] src/sys/arch/arm/arm32

2021-06-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun  5 10:27:10 UTC 2021

Modified Files:
src/sys/arch/arm/arm32 [netbsd-9]: arm32_boot.c

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

sys/arch/arm/arm32/arm32_boot.c: revision 1.42
sys/arch/arm/arm32/arm32_boot.c: revision 1.43

G/C

 -

Mirror the changes around passing pages to UVM in aarch64_machdep.c:

Two fixes for loading free pages into UVM

- Only consider a boot_physmem (inner loop) range that has its end
   (bp_end) after the bootconfig.dram (outer loop) range start (start).
   This was harmless as a later condition correctly checks there is only
   something to do if start < bp_end.

- Stop processing boot_physmem ranges if all the bootconfig.dram range has
   been passed to UVM.  This fixes a boot problem for simon@

Copy a comment over and do the VPRINTF before the uvm_page_physload in
the same way as aarch64_machdep.c as well.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.4.1 src/sys/arch/arm/arm32/arm32_boot.c

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

Modified files:

Index: src/sys/arch/arm/arm32/arm32_boot.c
diff -u src/sys/arch/arm/arm32/arm32_boot.c:1.33 src/sys/arch/arm/arm32/arm32_boot.c:1.33.4.1
--- src/sys/arch/arm/arm32/arm32_boot.c:1.33	Sat Mar 16 10:05:40 2019
+++ src/sys/arch/arm/arm32/arm32_boot.c	Sat Jun  5 10:27:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm32_boot.c,v 1.33 2019/03/16 10:05:40 skrll Exp $	*/
+/*	$NetBSD: arm32_boot.c,v 1.33.4.1 2021/06/05 10:27:10 martin Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003, 2005  Genetec Corporation.  All rights reserved.
@@ -122,7 +122,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.33 2019/03/16 10:05:40 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.33.4.1 2021/06/05 10:27:10 martin Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cputypes.h"
@@ -264,15 +264,21 @@ initarm_common(vaddr_t kvm_base, vsize_t
 			continue;
 		}
 		VPRINTF("\n");
+
+		/*
+		 * This assumes the bp list is sorted in ascending
+		 * order.
+		 */
 		paddr_t segend = end;
-		for (size_t j = 0; j < nbp; j++ /*, start = segend, segend = end */) {
+		for (size_t j = 0; j < nbp && start < end; j++) {
 			paddr_t bp_start = bp[j].bp_start;
 			paddr_t bp_end = bp_start + bp[j].bp_pages;
 
 			VPRINTF("   bp %2zu start %08lx  end %08lx\n",
 			j, ptoa(bp_start), ptoa(bp_end));
+
 			KASSERT(bp_start < bp_end);
-			if (start > bp_end || segend < bp_start)
+			if (start >= bp_end || segend < bp_start)
 continue;
 
 			if (start < bp_start)
@@ -284,11 +290,13 @@ initarm_common(vaddr_t kvm_base, vsize_t
 }
 vm_freelist = bp[j].bp_freelist;
 
-uvm_page_physload(start, segend, start, segend,
-vm_freelist);
 VPRINTF(" start %08lx  end %08lx"
 "... loading in freelist %d\n", ptoa(start),
 ptoa(segend), vm_freelist);
+
+uvm_page_physload(start, segend, start, segend,
+vm_freelist);
+
 start = segend;
 segend = end;
 			}



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

2021-06-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jun  4 14:00:17 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: aarch64_machdep.c

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

sys/arch/aarch64/aarch64/aarch64_machdep.c: revision 1.50
sys/arch/aarch64/aarch64/aarch64_machdep.c: revision 1.60
sys/arch/aarch64/aarch64/aarch64_machdep.c: revision 1.61

G/C

 -

More debug

 -

Two fixes for loading free pages into UVM

- Only consider a boot_physmem (inner loop) range that has its end
   (bp_end) after the bootconfig.dram (outer loop) range start (start).
   This was harmless as a later condition correctly checks there is only
   something to do if start < bp_end.

- Stop processing boot_physmem ranges if all the bootconfig.dram range has
   been passed to UVM.  This fixes a boot problem for simon@


To generate a diff of this commit:
cvs rdiff -u -r1.28.4.3 -r1.28.4.4 \
src/sys/arch/aarch64/aarch64/aarch64_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/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.28.4.3 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.28.4.4
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.28.4.3	Wed Feb 12 20:10:09 2020
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Fri Jun  4 14:00:17 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.28.4.3 2020/02/12 20:10:09 martin Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.28.4.4 2021/06/04 14:00:17 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.28.4.3 2020/02/12 20:10:09 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.28.4.4 2021/06/04 14:00:17 martin Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -275,7 +275,7 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	vaddr_t kernstart, kernend;
 	vaddr_t kernstart_l2 __unused, kernend_l2;	/* L2 table 2MB aligned */
 	vaddr_t kernelvmstart;
-	int i;
+	size_t i;
 
 	cputype = cpu_idnum();	/* for compatible arm */
 
@@ -398,17 +398,24 @@ initarm_common(vaddr_t kvm_base, vsize_t
 		end = start + bootconfig.dram[i].pages;
 
 		int vm_freelist = VM_FREELIST_DEFAULT;
+
+		VPRINTF("block %2zu start %08lx  end %08lx\n", i, ptoa(start),
+		ptoa(end));
+
 		/*
 		 * This assumes the bp list is sorted in ascending
 		 * order.
 		 */
 		paddr_t segend = end;
-		for (size_t j = 0; j < nbp; j++ /*, start = segend, segend = end */) {
+		for (size_t j = 0; j < nbp && start < end; j++) {
 			paddr_t bp_start = bp[j].bp_start;
 			paddr_t bp_end = bp_start + bp[j].bp_pages;
 
+			VPRINTF("   bp %2zu start %08lx  end %08lx\n",
+			j, ptoa(bp_start), ptoa(bp_end));
+
 			KASSERT(bp_start < bp_end);
-			if (start > bp_end || segend < bp_start)
+			if (start >= bp_end || segend < bp_start)
 continue;
 
 			if (start < bp_start)
@@ -420,8 +427,13 @@ initarm_common(vaddr_t kvm_base, vsize_t
 }
 vm_freelist = bp[j].bp_freelist;
 
+VPRINTF(" start %08lx  end %08lx"
+"... loading in freelist %d\n", ptoa(start),
+ptoa(segend), vm_freelist);
+
 uvm_page_physload(start, segend, start, segend,
 vm_freelist);
+
 memsize_total += ptoa(segend - start);
 start = segend;
 segend = end;



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

2021-06-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jun  1 10:39:48 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: netbsd32_machdep.c

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

sys/arch/aarch64/aarch64/netbsd32_machdep.c: revision 1.18

Fix conversion between aarch64 and aarch32 fpreg's; in aarch32 mode,
d0-d31 are packed into v0-v15 (== q0-q15).

This fixes crashes in VFP-optimized codes running on COMPAT_NETBSD32.

OK ryo


To generate a diff of this commit:
cvs rdiff -u -r1.7.2.2 -r1.7.2.3 \
src/sys/arch/aarch64/aarch64/netbsd32_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/aarch64/aarch64/netbsd32_machdep.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.7.2.2 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.7.2.3
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.7.2.2	Fri Jan  1 12:58:35 2021
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep.c	Tue Jun  1 10:39:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.7.2.2 2021/01/01 12:58:35 martin Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.7.2.3 2021/06/01 10:39:48 martin Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.7.2.2 2021/01/01 12:58:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.7.2.3 2021/06/01 10:39:48 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -156,7 +156,7 @@ netbsd32_process_read_fpregs(struct lwp 
 {
 	struct proc * const p = l->l_proc;
 	struct pcb * const pcb = lwp_getpcb(l);
-	int i;
+	int i, j;
 
 	if ((p->p_flag & PK_32) == 0)
 		return EINVAL;
@@ -178,11 +178,17 @@ netbsd32_process_read_fpregs(struct lwp 
 	fpregs->fpr_vfp.vfp_fpinst = 0;
 	fpregs->fpr_vfp.vfp_fpinst2 = 0;
 
-	for (i = 0; i < 32; i++) {
+	for (i = j = 0; i < 16; i++) {
 #ifdef __AARCH64EB__
-		fpregs->fpr_vfp.vfp_regs[i] = pcb->pcb_fpregs.fp_reg[i].u64[1];
+		fpregs->fpr_vfp.vfp_regs[j++] =
+		pcb->pcb_fpregs.fp_reg[i].u64[1];
+		fpregs->fpr_vfp.vfp_regs[j++] =
+		pcb->pcb_fpregs.fp_reg[i].u64[0];
 #else
-		fpregs->fpr_vfp.vfp_regs[i] = pcb->pcb_fpregs.fp_reg[i].u64[0];
+		fpregs->fpr_vfp.vfp_regs[j++] =
+		pcb->pcb_fpregs.fp_reg[i].u64[0];
+		fpregs->fpr_vfp.vfp_regs[j++] =
+		pcb->pcb_fpregs.fp_reg[i].u64[1];
 #endif
 	}
 
@@ -224,7 +230,7 @@ netbsd32_process_write_fpregs(struct lwp
 {
 	struct proc * const p = l->l_proc;
 	struct pcb * const pcb = lwp_getpcb(l);
-	int i;
+	int i, j;
 
 	if ((p->p_flag & PK_32) == 0)
 		return EINVAL;
@@ -235,17 +241,18 @@ netbsd32_process_write_fpregs(struct lwp
 	pcb->pcb_fpregs.fpsr = fpregs->fpr_vfp.vfp_fpscr & FPSR_BITS;
 	pcb->pcb_fpregs.fpcr = fpregs->fpr_vfp.vfp_fpscr & FPCR_BITS;
 
-	CTASSERT(__arraycount(fpregs->fpr_vfp.vfp_regs) ==
-	__arraycount(pcb->pcb_fpregs.fp_reg) + 1);
-	for (i = 0; i < __arraycount(pcb->pcb_fpregs.fp_reg); i++) {
+	for (i = j = 0; i < 16; i++) {
 #ifdef __AARCH64EB__
-		pcb->pcb_fpregs.fp_reg[i].u64[0] = 0;
 		pcb->pcb_fpregs.fp_reg[i].u64[1] =
+		fpregs->fpr_vfp.vfp_regs[j++];
+		pcb->pcb_fpregs.fp_reg[i].u64[0] =
+		fpregs->fpr_vfp.vfp_regs[j++];
 #else
-		pcb->pcb_fpregs.fp_reg[i].u64[1] = 0;
 		pcb->pcb_fpregs.fp_reg[i].u64[0] =
+		fpregs->fpr_vfp.vfp_regs[j++];
+		pcb->pcb_fpregs.fp_reg[i].u64[1] =
+		fpregs->fpr_vfp.vfp_regs[j++];
 #endif
-		fpregs->fpr_vfp.vfp_regs[i];
 	}
 
 	return 0;
@@ -456,18 +463,21 @@ cpu_getmcontext32(struct lwp *l, mcontex
 	/* fpu context */
 	if (fpu_used_p(l)) {
 		const struct pcb * const pcb = lwp_getpcb(l);
-		int i;
+		int i, j;
 
 		fpu_save(l);
 
-		CTASSERT(__arraycount(mcp->__vfpregs.__vfp_fstmx) ==
-		__arraycount(pcb->pcb_fpregs.fp_reg));
-		for (i = 0; i < __arraycount(pcb->pcb_fpregs.fp_reg); i++) {
-			mcp->__vfpregs.__vfp_fstmx[i] =
+		for (i = j = 0; i < 16; i++) {
 #ifdef __AARCH64EB__
+			mcp->__vfpregs.__vfp_fstmx[j++] =
 			pcb->pcb_fpregs.fp_reg[i].u64[1];
+			mcp->__vfpregs.__vfp_fstmx[j++] =
+			pcb->pcb_fpregs.fp_reg[i].u64[0];
 #else
+			mcp->__vfpregs.__vfp_fstmx[j++] =
 			pcb->pcb_fpregs.fp_reg[i].u64[0];
+			mcp->__vfpregs.__vfp_fstmx[j++] =
+			pcb->pcb_fpregs.fp_reg[i].u64[1];
 #endif
 		}
 
@@ -489,7 +499,7 @@ cpu_setmcontext32(struct lwp *l, const m
 	struct trapframe * const tf = l->l_md.md_utf;
 	const __greg32_t * const gr = mcp->__gregs;
 	struct proc * const p = l->l_proc;
-	int error, i;
+	int error, i, j;
 
 	if (flags & _UC_CPU) {
 		error = cpu_mcontext32_validate(l, mcp);
@@ -519,17 +529,18 @@ cpu_setmcontext32(struct lwp *l, const m
 		struct pcb * const pcb = lwp_getpcb(l);
 		fpu_discard(l, true);
 
-		CTASSERT(__arraycount(mcp->__vfpregs.__vfp_fstmx) ==
-		__arraycount(pcb->pcb_fpregs.fp_reg));
-		for (i = 0; i < __arraycount(pcb->pcb_fpregs.fp_reg); i++) {
+		for (i = j = 0; i < 

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

2021-05-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May 17 15:50:35 UTC 2021

Modified Files:
src/sys/dev/pci [netbsd-9]: xhci_pci.c

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

sys/dev/pci/xhci_pci.c: revision 1.26

xhci_pci: avoid potential double free of interrupt handles

Found by Kouichi Hashikawa in PR 55855.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.21.4.1 src/sys/dev/pci/xhci_pci.c

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

Modified files:

Index: src/sys/dev/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.21 src/sys/dev/pci/xhci_pci.c:1.21.4.1
--- src/sys/dev/pci/xhci_pci.c:1.21	Wed Jan 23 06:56:19 2019
+++ src/sys/dev/pci/xhci_pci.c	Mon May 17 15:50:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.21 2019/01/23 06:56:19 msaitoh Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.21.4.1 2021/05/17 15:50:35 martin Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.21 2019/01/23 06:56:19 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.21.4.1 2021/05/17 15:50:35 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -213,7 +213,7 @@ xhci_pci_attach(device_t parent, device_
 	xhci_intr, sc, device_xname(sc->sc_dev));
 	if (psc->sc_ih == NULL) {
 		pci_intr_release(pc, psc->sc_pihp, 1);
-		psc->sc_ih = NULL;
+		psc->sc_pihp = NULL;
 		aprint_error_dev(self, "couldn't establish interrupt");
 		if (intrstr != NULL)
 			aprint_error(" at %s", intrstr);



CVS commit: [netbsd-9] src/sys/fs/ntfs

2021-05-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May 17 15:48:57 UTC 2021

Modified Files:
src/sys/fs/ntfs [netbsd-9]: ntfs_subr.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1272):

sys/fs/ntfs/ntfs_subr.c: revision 1.64

ntfs_loadntnode(): Use bread() when ntm_sysvn[NTFS_MFTINO] is NULL.

May happen when loading node 0 (MFT) during mount and some
attributes are stored in another ntnode.

PR kern/56160 (Mount ntfs usb disk)


To generate a diff of this commit:
cvs rdiff -u -r1.61.22.1 -r1.61.22.2 src/sys/fs/ntfs/ntfs_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/fs/ntfs/ntfs_subr.c
diff -u src/sys/fs/ntfs/ntfs_subr.c:1.61.22.1 src/sys/fs/ntfs/ntfs_subr.c:1.61.22.2
--- src/sys/fs/ntfs/ntfs_subr.c:1.61.22.1	Mon Oct 21 20:15:02 2019
+++ src/sys/fs/ntfs/ntfs_subr.c	Mon May 17 15:48:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ntfs_subr.c,v 1.61.22.1 2019/10/21 20:15:02 martin Exp $	*/
+/*	$NetBSD: ntfs_subr.c,v 1.61.22.2 2021/05/17 15:48:57 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko (sem...@freebsd.org)
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.61.22.1 2019/10/21 20:15:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.61.22.2 2021/05/17 15:48:57 martin Exp $");
 
 #include 
 #include 
@@ -267,7 +267,8 @@ ntfs_loadntnode(struct ntfsmount *ntmp, 
 
 	mfrp = malloc(ntfs_bntob(ntmp->ntm_bpmftrec), M_TEMP, M_WAITOK);
 
-	if (ip->i_number < NTFS_SYSNODESNUM) {
+	if (ip->i_number < NTFS_SYSNODESNUM ||
+	ntmp->ntm_sysvn[NTFS_MFTINO] == NULL) {
 		struct buf *bp;
 		daddr_t bn;
 		off_t boff;



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

2021-05-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May  9 07:09:27 UTC 2021

Modified Files:
src/sys/dev/pci [netbsd-9]: siisata_pci.c

Log Message:
Pull up following revision(s) (requested by dolecek in ticket #1270):

sys/dev/pci/siisata_pci.c: revision 1.21

disable MSI for SiI3124 - interrupts don't seem to work on this old board
when MSI is enabled, maybe because it's behind a PCI bridge

PR kern/55115 by John D. Baker


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.20.4.1 src/sys/dev/pci/siisata_pci.c

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

Modified files:

Index: src/sys/dev/pci/siisata_pci.c
diff -u src/sys/dev/pci/siisata_pci.c:1.20 src/sys/dev/pci/siisata_pci.c:1.20.4.1
--- src/sys/dev/pci/siisata_pci.c:1.20	Thu Oct 25 21:03:19 2018
+++ src/sys/dev/pci/siisata_pci.c	Sun May  9 07:09:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata_pci.c,v 1.20 2018/10/25 21:03:19 jdolecek Exp $ */
+/* $NetBSD: siisata_pci.c,v 1.20.4.1 2021/05/09 07:09:27 martin Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -51,7 +51,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: siisata_pci.c,v 1.20 2018/10/25 21:03:19 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siisata_pci.c,v 1.20.4.1 2021/05/09 07:09:27 martin Exp $");
 
 #include 
 #include 
@@ -82,14 +82,22 @@ struct siisata_pci_board {
 	pci_product_id_t	spb_prod;
 	uint16_t		spb_port;
 	uint16_t		spb_chip;
+	uint8_t			sbp_flags;
 };
 
+#define SIISATA_BROKEN_MSI		0x01
+
 static const struct siisata_pci_board siisata_pci_boards[] = {
 	{
 		.spb_vend = PCI_VENDOR_CMDTECH,
 		.spb_prod = PCI_PRODUCT_CMDTECH_3124,
 		.spb_port = 4,
 		.spb_chip = 3124,
+		/*
+		 * SiI3124 seems to be PCI/PCI-X chip behind PCI-e bridge,
+		 * claims MSI support but interrups don't work with MSI on.
+		 */
+		.sbp_flags = SIISATA_BROKEN_MSI,
 	},
 	{
 		.spb_vend = PCI_VENDOR_CMDTECH,
@@ -157,6 +165,9 @@ siisata_pci_attach(device_t parent, devi
 	bus_size_t grsize, prsize;
 	char intrbuf[PCI_INTRSTR_LEN];
 
+	spbp = siisata_pci_lookup(pa);
+	KASSERT(spbp != NULL);
+
 	sc->sc_atac.atac_dev = self;
 
 	psc->sc_pc = pa->pa_pc;
@@ -210,8 +221,19 @@ siisata_pci_attach(device_t parent, devi
 	else
 		sc->sc_dmat = pa->pa_dmat;
 
+	int counts[PCI_INTR_TYPE_SIZE] = {
+ 		[PCI_INTR_TYPE_INTX] = 1,
+ 		[PCI_INTR_TYPE_MSI] = 1,
+ 		[PCI_INTR_TYPE_MSIX] = 1,
+ 	};
+	int max_type = PCI_INTR_TYPE_MSIX;
+
+	if (spbp->sbp_flags & SIISATA_BROKEN_MSI) {
+		max_type = PCI_INTR_TYPE_INTX;
+	}
+
 	/* map interrupt */
-	if (pci_intr_alloc(pa, >sc_pihp, NULL, 0) != 0) {
+	if (pci_intr_alloc(pa, >sc_pihp, counts, max_type) != 0) {
 		bus_space_unmap(sc->sc_grt, sc->sc_grh, grsize);
 		bus_space_unmap(sc->sc_prt, sc->sc_prh, prsize);
 		aprint_error_dev(self, "couldn't map interrupt\n");
@@ -235,8 +257,6 @@ siisata_pci_attach(device_t parent, devi
 		intrstr ? intrstr : "unknown interrupt");
 
 	/* fill in number of ports on this device */
-	spbp = siisata_pci_lookup(pa);
-	KASSERT(spbp != NULL);
 	sc->sc_atac.atac_nchannels = spbp->spb_port;
 
 	/* set the necessary bits in case the firmware didn't */



CVS commit: [netbsd-9] src/sys/dev/audio

2021-05-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  5 17:01:41 UTC 2021

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1268):

sys/dev/audio/audio.c: revision 1.95

audio: Only score hardware formats by channel count at count<=2

Scoring by channel count makes sense when you are using hardware that
supports mono and stereo formats. However, if your hardware also supports
surround formats, defaulting to those might be confusing. So, don't
prefer them.

Problem reported and fix tested by tcmart14 with a 2015 model Macbook Pro.


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

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.21 src/sys/dev/audio/audio.c:1.28.2.22
--- src/sys/dev/audio/audio.c:1.28.2.21	Mon Mar  1 16:00:08 2021
+++ src/sys/dev/audio/audio.c	Wed May  5 17:01:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.21 2021/03/01 16:00:08 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.22 2021/05/05 17:01:41 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.21 2021/03/01 16:00:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.22 2021/05/05 17:01:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -6566,7 +6566,10 @@ audio_hw_probe(struct audio_softc *sc, a
 		query.fmt.precision == AUDIO_INTERNAL_BITS) {
 			score += 0x10;
 		}
-		score += query.fmt.channels;
+
+		/* Do not prefer surround formats */
+		if (query.fmt.channels <= 2)
+			score += query.fmt.channels;
 
 		if (score < cand_score) {
 			DPRINTF(1, "fmt[%d] skip; score 0x%x < 0x%x\n", i,



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

2021-05-03 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon May  3 09:12:50 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: kern_exec.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #1265):
sys/kern/kern_exec.c: revision 1.505 via patch
Fix copy in handling of POSIX_SPAWN_RESETIDS in posix_spawn(3)


To generate a diff of this commit:
cvs rdiff -u -r1.478.2.1 -r1.478.2.2 src/sys/kern/kern_exec.c

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

Modified files:

Index: src/sys/kern/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.478.2.1 src/sys/kern/kern_exec.c:1.478.2.2
--- src/sys/kern/kern_exec.c:1.478.2.1	Tue Oct 15 18:32:13 2019
+++ src/sys/kern/kern_exec.c	Mon May  3 09:12:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.478.2.1 2019/10/15 18:32:13 martin Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.478.2.2 2021/05/03 09:12:50 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.478.2.1 2019/10/15 18:32:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.478.2.2 2021/05/03 09:12:50 bouyer Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -2124,7 +2124,7 @@ spawn_return(void *arg)
 
 		/* Reset user ID's */
 		if (spawn_data->sed_attrs->sa_flags & POSIX_SPAWN_RESETIDS) {
-			error = do_setresuid(l, -1,
+			error = do_setresgid(l, -1,
 			 kauth_cred_getgid(l->l_cred), -1,
 			 ID_E_EQ_R | ID_E_EQ_S);
 			if (error)



CVS commit: [netbsd-9] src/sys/miscfs/fdesc

2021-05-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May  3 09:03:22 UTC 2021

Modified Files:
src/sys/miscfs/fdesc [netbsd-9]: fdesc_vnops.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1267):

sys/miscfs/fdesc/fdesc_vnops.c: revision 1.135

Make sure fdesc_lookup() never returns VNON vnodes.
Should fix PR kern/56130 (fdescfs create nodes with wrong major number)


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.130.4.1 src/sys/miscfs/fdesc/fdesc_vnops.c

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

Modified files:

Index: src/sys/miscfs/fdesc/fdesc_vnops.c
diff -u src/sys/miscfs/fdesc/fdesc_vnops.c:1.130 src/sys/miscfs/fdesc/fdesc_vnops.c:1.130.4.1
--- src/sys/miscfs/fdesc/fdesc_vnops.c:1.130	Mon Sep  3 16:29:35 2018
+++ src/sys/miscfs/fdesc/fdesc_vnops.c	Mon May  3 09:03:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vnops.c,v 1.130 2018/09/03 16:29:35 riastradh Exp $	*/
+/*	$NetBSD: fdesc_vnops.c,v 1.130.4.1 2021/05/03 09:03:22 martin Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.130 2018/09/03 16:29:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.130.4.1 2021/05/03 09:03:22 martin Exp $");
 
 #include 
 #include 
@@ -295,9 +295,20 @@ bad:
 good:
 	KASSERT(ix != -1);
 	error = vcache_get(dvp->v_mount, , sizeof(ix), vpp);
-	if (error == 0 && ix == FD_CTTY)
+	if (error)
+		return error;
+
+	/*
+	 * Prevent returning VNON nodes.
+	 * Operation fdesc_inactive() will reset the type to VNON.
+	 */
+	if (ix == FD_CTTY)
 		(*vpp)->v_type = VCHR;
-	return error;
+	else if (ix >= FD_DESC)
+		(*vpp)->v_type = VREG;
+	KASSERT((*vpp)->v_type != VNON);
+
+	return 0;
 }
 
 int



CVS commit: [netbsd-9] src/sys/arch/mac68k/mac68k

2021-04-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 28 09:46:39 UTC 2021

Modified Files:
src/sys/arch/mac68k/mac68k [netbsd-9]: machdep.c

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

sys/arch/mac68k/mac68k/machdep.c: revision 1.361
sys/arch/mac68k/mac68k/machdep.c: revision 1.362

Make mac68k_set_io_offsets() a little bit cleaner:
- Via1Base is always ``base'' for all supported models.
- Set sccA and SCSIBase for each model of MACH_CLASSQ class.
- Some style fixes.

No functional changes intended.

Change sccA address for Quadra 800 from base + 0xc000 to 0xc020.

The H/W partially decodes its address, and sccA is available at
offsets 0xc000, 0xc020,  The functionality is same, but Mac
toolbox ROM routines use 0xc020, and QEMU for Quadra 800 only
supports this address.


To generate a diff of this commit:
cvs rdiff -u -r1.353.2.2 -r1.353.2.3 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/machdep.c
diff -u src/sys/arch/mac68k/mac68k/machdep.c:1.353.2.2 src/sys/arch/mac68k/mac68k/machdep.c:1.353.2.3
--- src/sys/arch/mac68k/mac68k/machdep.c:1.353.2.2	Tue Apr 27 10:31:17 2021
+++ src/sys/arch/mac68k/mac68k/machdep.c	Wed Apr 28 09:46:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.353.2.2 2021/04/27 10:31:17 martin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.353.2.3 2021/04/28 09:46:39 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.353.2.2 2021/04/27 10:31:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.353.2.3 2021/04/28 09:46:39 martin Exp $");
 
 #include "opt_adb.h"
 #include "opt_copy_symtab.h"
@@ -2109,24 +2109,33 @@ void
 mac68k_set_io_offsets(vaddr_t base)
 {
 
+	Via1Base = (volatile u_char *)base;
+	Via2Base = Via1Base + 0x2000 * VIA2;
 	switch (current_mac_model->class) {
 	case MACH_CLASSQ:
-		Via1Base = (volatile u_char *)base;
-
-		/* The following two may be overridden. */
-		sccA = (volatile u_char *)base + 0xc000;
-		SCSIBase = base + 0xf000;
-
 		switch (current_mac_model->machineid) {
 		case MACH_MACQ900:
 		case MACH_MACQ950:
-			mac68k_machine.scsi96_2 = 1;
 			sccA = (volatile u_char *)base + 0xc020;
+			SCSIBase = base + 0xf000;
+			mac68k_machine.scsi96_2 = 1;
 			iop_init(0);	/* For console */
 			break;
+		case MACH_MACQ800:
+			/*
+			 * The H/W partially decode address for sccA; it is
+			 * available at offsets 0xc000, 0xc020,  Here,
+			 * we choose 0xc020, where Mac toolbox ROM uses.
+			 */
+			sccA = (volatile u_char *)base + 0xc020;
+			SCSIBase = base + 0x1;
+			break;
 		case MACH_MACQ700:
+			sccA = (volatile u_char *)base + 0xc000;
+			SCSIBase = base + 0xf000;
 			break;
 		default:
+			sccA = (volatile u_char *)base + 0xc000;
 			SCSIBase = base + 0x1;
 			break;
 		}
@@ -2137,7 +2146,6 @@ mac68k_set_io_offsets(vaddr_t base)
 		 * machines.  This seems to be common on many of the
 		 * Quadra-type machines.
 		 */
-		Via1Base = (volatile u_char *)base;
 		sccA = (volatile u_char *)base + 0xc020;
 		SCSIBase = base + 0x1;
 		break;
@@ -2146,12 +2154,10 @@ mac68k_set_io_offsets(vaddr_t base)
 		 * Here's a queer bird... it seems to be a cross between
 		 * the two different Quadra classes.
 		 */
-		Via1Base = (volatile u_char *) base;
-		sccA = (volatile u_char *) base + 0xc020;
+		sccA = (volatile u_char *)base + 0xc020;
 		SCSIBase = base;
 		break;
 	case MACH_CLASSAV:
-		Via1Base = (volatile u_char *)base;
 		sccA = (volatile u_char *)base + 0x4000;
 		SCSIBase = base + 0x18000;
 		PSCBase = (volatile u_char *)base + 0x31000;
@@ -2163,8 +2169,7 @@ mac68k_set_io_offsets(vaddr_t base)
 	case MACH_CLASSIIsi:
 	case MACH_CLASSIIvx:
 	case MACH_CLASSLC:
-		Via1Base = (volatile u_char *)base;
-		sccA = (volatile u_char *) base + 0x4000;
+		sccA = (volatile u_char *)base + 0x4000;
 		SCSIBase = base;
 		break;
 	case MACH_CLASSIIfx:
@@ -2173,7 +2178,6 @@ mac68k_set_io_offsets(vaddr_t base)
 		 * the serial port in `compatible' mode (set in
 		 * the Serial Switch control panel before booting).
 		 */
-		Via1Base = (volatile u_char *)base;
 		sccA = (volatile u_char *)base + 0x4020;
 		SCSIBase = base;
 		iop_init(0);	/* For console */
@@ -2184,7 +2188,6 @@ mac68k_set_io_offsets(vaddr_t base)
 		current_mac_model->class);
 		break;
 	}
-	Via2Base = Via1Base + 0x2000 * VIA2;
 }
 
 #if GRAYBARS



CVS commit: [netbsd-9] src/sys/arch/mac68k

2021-04-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 27 10:31:18 UTC 2021

Modified Files:
src/sys/arch/mac68k/conf [netbsd-9]: GENERIC files.mac68k
src/sys/arch/mac68k/mac68k [netbsd-9]: machdep.c

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

sys/arch/mac68k/mac68k/machdep.c: revision 1.360
sys/arch/mac68k/conf/GENERIC: revision 1.234
sys/arch/mac68k/conf/files.mac68k: revision 1.131

Add MAC68K_MEMSIZE option to hard-code memory size in MB, instead of
that given by Booter. Work around Booter bug by which max memory is
restricted to 255MB.


To generate a diff of this commit:
cvs rdiff -u -r1.228 -r1.228.2.1 src/sys/arch/mac68k/conf/GENERIC
cvs rdiff -u -r1.129 -r1.129.2.1 src/sys/arch/mac68k/conf/files.mac68k
cvs rdiff -u -r1.353.2.1 -r1.353.2.2 src/sys/arch/mac68k/mac68k/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/mac68k/conf/GENERIC
diff -u src/sys/arch/mac68k/conf/GENERIC:1.228 src/sys/arch/mac68k/conf/GENERIC:1.228.2.1
--- src/sys/arch/mac68k/conf/GENERIC:1.228	Fri Apr 26 21:40:31 2019
+++ src/sys/arch/mac68k/conf/GENERIC	Tue Apr 27 10:31:17 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.228 2019/04/26 21:40:31 sevan Exp $
+# $NetBSD: GENERIC,v 1.228.2.1 2021/04/27 10:31:17 martin Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include 	"arch/mac68k/conf/std.mac68k"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.228 $"
+#ident 		"GENERIC-$Revision: 1.228.2.1 $"
 
 makeoptions	COPTS="-O2 -fno-reorder-blocks"	# see share/mk/sys.mk
 
@@ -41,6 +41,10 @@ options 	FPU_EMULATE
 # You need to set the total memory in the MacOS Booter.
 #options 	DJMEMCMAX
 
+# Use hard-coded memory size in MB, instead of parameter given by Booter.
+# Workaround for Booter bug by which max memory is restricted to 255MB.
+#options 	MAC68K_MEMSIZE=256
+
 # Standard system options
 
 options 	INSECURE	# disable kernel security levels

Index: src/sys/arch/mac68k/conf/files.mac68k
diff -u src/sys/arch/mac68k/conf/files.mac68k:1.129 src/sys/arch/mac68k/conf/files.mac68k:1.129.2.1
--- src/sys/arch/mac68k/conf/files.mac68k:1.129	Fri Jul 26 10:48:44 2019
+++ src/sys/arch/mac68k/conf/files.mac68k	Tue Apr 27 10:31:17 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.mac68k,v 1.129 2019/07/26 10:48:44 rin Exp $
+#	$NetBSD: files.mac68k,v 1.129.2.1 2021/04/27 10:31:17 martin Exp $
 
 # mac68k-specific configuration info
 
@@ -10,6 +10,8 @@ defflag	opt_grf_compat.h	GRF_COMPAT
 
 defflag	opt_wsdisplay_compat.h	WSDISPLAY_COMPAT_ITEFONT
 
+defparam opt_mac68k.h		MAC68K_MEMSIZE
+
 # maxpartitions must be first item in files.${ARCH}.newconf
 maxpartitions 8
 

Index: src/sys/arch/mac68k/mac68k/machdep.c
diff -u src/sys/arch/mac68k/mac68k/machdep.c:1.353.2.1 src/sys/arch/mac68k/mac68k/machdep.c:1.353.2.2
--- src/sys/arch/mac68k/mac68k/machdep.c:1.353.2.1	Sun Aug 18 10:00:41 2019
+++ src/sys/arch/mac68k/mac68k/machdep.c	Tue Apr 27 10:31:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.353.2.1 2019/08/18 10:00:41 martin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.353.2.2 2021/04/27 10:31:17 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -74,13 +74,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.353.2.1 2019/08/18 10:00:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.353.2.2 2021/04/27 10:31:17 martin Exp $");
 
 #include "opt_adb.h"
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
 #include "opt_ddbparam.h"
 #include "opt_kgdb.h"
+#include "opt_mac68k.h"
 #include "opt_modular.h"
 #include "opt_compat_netbsd.h"
 #include "akbd.h"
@@ -902,7 +903,11 @@ getenvvars(u_long flag, char *buf)
 	 */
 	mac68k_machine.machineid = machineid = getenv("MACHINEID");
 	mac68k_machine.mach_processor = getenv("PROCESSOR");
+#ifndef MAC68K_MEMSIZE
 	mac68k_machine.mach_memsize = getenv("MEMSIZE");
+#else
+	mac68k_machine.mach_memsize = MAC68K_MEMSIZE;
+#endif
 	mac68k_machine.do_graybars = getenv("GRAYBARS");
 	mac68k_machine.serial_boot_echo = getenv("SERIALECHO");
 	mac68k_machine.serial_console = getenv("SERIALCONSOLE");



CVS commit: [netbsd-9] src/sys/arch/mac68k/mac68k

2021-04-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 27 10:27:31 UTC 2021

Modified Files:
src/sys/arch/mac68k/mac68k [netbsd-9]: locore.s

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

sys/arch/mac68k/mac68k/locore.s: revision 1.174

Fix DJMEMCMAX option for Quadra/Centris 650/800.
- Use jeq instead of jra for conditional branch.
- Use cmpl instead of cmp (= cmpw) for int variables.

Now, my Quadra 800 recognizes full 520MB memory!


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.171.4.1 src/sys/arch/mac68k/mac68k/locore.s

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

Modified files:

Index: src/sys/arch/mac68k/mac68k/locore.s
diff -u src/sys/arch/mac68k/mac68k/locore.s:1.171 src/sys/arch/mac68k/mac68k/locore.s:1.171.4.1
--- src/sys/arch/mac68k/mac68k/locore.s:1.171	Wed Dec 19 13:57:48 2018
+++ src/sys/arch/mac68k/mac68k/locore.s	Tue Apr 27 10:27:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.171 2018/12/19 13:57:48 maxv Exp $	*/
+/*	$NetBSD: locore.s,v 1.171.4.1 2021/04/27 10:27:30 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -275,16 +275,16 @@ Lstart3:
 
 #if defined(DJMEMCMAX)
 	movl	%a3,%sp@-
-	cmp	#MACH_MACC610,_C_LABEL(machineid)
-	jra	Ldjmemc610
-	cmp	#MACH_MACQ610,_C_LABEL(machineid)
-	jra	Ldjmemc610
-	cmp	#MACH_MACC650,_C_LABEL(machineid)
-	jra	Ldjmemccfg
-	cmp	#MACH_MACQ650,_C_LABEL(machineid)
-	jra	Ldjmemccfg
-	cmp	#MACH_MACQ800,_C_LABEL(machineid)
-	jra	Ldjmemccfg
+	cmpl	#MACH_MACC610,_C_LABEL(machineid)
+	jeq	Ldjmemc610
+	cmpl	#MACH_MACQ610,_C_LABEL(machineid)
+	jeq	Ldjmemc610
+	cmpl	#MACH_MACC650,_C_LABEL(machineid)
+	jeq	Ldjmemccfg
+	cmpl	#MACH_MACQ650,_C_LABEL(machineid)
+	jeq	Ldjmemccfg
+	cmpl	#MACH_MACQ800,_C_LABEL(machineid)
+	jeq	Ldjmemccfg
 
 	jra	Lnodjmemc




CVS commit: [netbsd-9] src/sys/arch/arm

2021-04-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr 25 11:13:03 UTC 2021

Modified Files:
src/sys/arch/arm/dts [netbsd-9]: sun50i-h5.dtsi
src/sys/arch/arm/sunxi [netbsd-9]: sun8i_crypto.c sun8i_h3_ccu.c

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

sys/arch/arm/sunxi/sun8i_h3_ccu.c: revision 1.18 (patch)
sys/arch/arm/sunxi/sun8i_crypto.c: revision 1.24 (patch)
sys/arch/arm/dts/sun50i-h5.dtsi: revision 1.2 (patch)

arm/sunxi: Wire up sun8icrypto(4) on Allwinner H5.

Tested on NanoPi Neo PLUS2.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.8.1 src/sys/arch/arm/dts/sun50i-h5.dtsi
cvs rdiff -u -r1.14.2.2 -r1.14.2.3 src/sys/arch/arm/sunxi/sun8i_crypto.c
cvs rdiff -u -r1.16 -r1.16.4.1 src/sys/arch/arm/sunxi/sun8i_h3_ccu.c

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

Modified files:

Index: src/sys/arch/arm/dts/sun50i-h5.dtsi
diff -u src/sys/arch/arm/dts/sun50i-h5.dtsi:1.1 src/sys/arch/arm/dts/sun50i-h5.dtsi:1.1.8.1
--- src/sys/arch/arm/dts/sun50i-h5.dtsi:1.1	Sun Jan 28 18:31:15 2018
+++ src/sys/arch/arm/dts/sun50i-h5.dtsi	Sun Apr 25 11:13:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i-h5.dtsi,v 1.1 2018/01/28 18:31:15 jmcneill Exp $ */
+/* $NetBSD: sun50i-h5.dtsi,v 1.1.8.1 2021/04/25 11:13:03 martin Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,6 +28,19 @@
 
 #include "sun8i-h3.dtsi"
 
+/ {
+	soc {
+		crypto: crypto@1c15000 {
+			compatible = "allwinner,sun50i-h5-crypto";
+			reg = <0x01c15000 0x1000>;
+			interrupts = ;
+			clocks = < CLK_BUS_CE>, < CLK_CE>;
+			clock-names = "bus", "mod";
+			resets = < RST_BUS_CE>;
+		};
+	};
+};
+
  {
 	compatible = "allwinner,sun50i-h5-ts";
 };

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.14.2.2 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.14.2.3
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.14.2.2	Mon May 18 18:45:40 2020
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Sun Apr 25 11:13:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.14.2.2 2020/05/18 18:45:40 martin Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.14.2.3 2021/04/25 11:13:03 martin Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.14.2.2 2020/05/18 18:45:40 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.14.2.3 2021/04/25 11:13:03 martin Exp $");
 
 #include 
 #include 
@@ -209,6 +209,7 @@ CFATTACH_DECL_NEW(sun8i_crypto, sizeof(s
 
 static const struct of_compat_data compat_data[] = {
 	{"allwinner,sun50i-a64-crypto", 0},
+	{"allwinner,sun50i-h5-crypto", 0},
 	{NULL}
 };
 

Index: src/sys/arch/arm/sunxi/sun8i_h3_ccu.c
diff -u src/sys/arch/arm/sunxi/sun8i_h3_ccu.c:1.16 src/sys/arch/arm/sunxi/sun8i_h3_ccu.c:1.16.4.1
--- src/sys/arch/arm/sunxi/sun8i_h3_ccu.c:1.16	Thu Jan 31 01:49:28 2019
+++ src/sys/arch/arm/sunxi/sun8i_h3_ccu.c	Sun Apr 25 11:13:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_h3_ccu.c,v 1.16 2019/01/31 01:49:28 jmcneill Exp $ */
+/* $NetBSD: sun8i_h3_ccu.c,v 1.16.4.1 2021/04/25 11:13:03 martin Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_h3_ccu.c,v 1.16 2019/01/31 01:49:28 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_h3_ccu.c,v 1.16.4.1 2021/04/25 11:13:03 martin Exp $");
 
 #include 
 #include 
@@ -60,6 +60,7 @@ __KERNEL_RCSID(1, "$NetBSD: sun8i_h3_ccu
 #define	SDMMC0_CLK_REG		0x088
 #define	SDMMC1_CLK_REG		0x08c
 #define	SDMMC2_CLK_REG		0x090
+#define	CE_CLK_REG		0x09c
 #define	SPI0_CLK_REG		0x0a0
 #define	SPI1_CLK_REG		0x0a4
 #define	USBPHY_CFG_REG		0x0cc
@@ -154,6 +155,7 @@ static const char *ahb1_parents[] = { "l
 static const char *ahb2_parents[] = { "ahb1", "pll_periph0" };
 static const char *apb1_parents[] = { "ahb1" };
 static const char *apb2_parents[] = { "losc", "hosc", "pll_periph0" };
+static const char *ce_parents[] = { "hosc", "pll_periph0_2x", "pll_periph1_2x" };
 static const char *mod_parents[] = { "hosc", "pll_periph0", "pll_periph1" };
 static const char *ths_parents[] = { "hosc" };
 static const char *de_parents[] = { "pll_periph0_2x", "pll_de" };
@@ -329,6 +331,14 @@ static struct sunxi_ccu_clk sun8i_h3_ccu
 	0,			/* enable */
 	SUNXI_CCU_NM_POWER_OF_TWO),
 
+	SUNXI_CCU_NM(H3_CLK_CE, "ce", ce_parents,
+	CE_CLK_REG,		/* reg */
+	__BITS(17,16),	/* n */
+	__BITS(3,0),	/* m */
+	__BITS(25,24),	/* sel */
+	__BIT(31),		/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN),
+
 	SUNXI_CCU_DIV_GATE(H3_CLK_THS, "ths", ths_parents,
 	THS_CLK_REG,	/* reg */
 	__BITS(1,0),	/* div */
@@ -400,6 +410,8 @@ static struct sunxi_ccu_clk sun8i_h3_ccu
 	__BIT(31),		/* enable */
 	0),
 
+	SUNXI_CCU_GATE(H3_CLK_BUS_CE, "bus-ce", "ahb1",
+	BUS_CLK_GATING_REG0, 5),
 	SUNXI_CCU_GATE(H3_CLK_BUS_DMA, "bus-dma", 

CVS commit: [netbsd-9] src/sys/arch/sparc/conf

2021-04-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 21 18:11:06 UTC 2021

Modified Files:
src/sys/arch/sparc/conf [netbsd-9]: GENERIC

Log Message:
Apply patch, requested by tsutsui in ticket #1249:

sys/arch/sparc/conf/GENERIC (apply patch)

PR 56077: remove DIAGNOSTIC from sparc kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.267.2.1 src/sys/arch/sparc/conf/GENERIC

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

Modified files:

Index: src/sys/arch/sparc/conf/GENERIC
diff -u src/sys/arch/sparc/conf/GENERIC:1.267 src/sys/arch/sparc/conf/GENERIC:1.267.2.1
--- src/sys/arch/sparc/conf/GENERIC:1.267	Wed May  8 13:40:16 2019
+++ src/sys/arch/sparc/conf/GENERIC	Wed Apr 21 18:11:06 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.267 2019/05/08 13:40:16 isaki Exp $
+# $NetBSD: GENERIC,v 1.267.2.1 2021/04/21 18:11:06 martin Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include 	"arch/sparc/conf/std.sparc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.267 $"
+#ident 		"GENERIC-$Revision: 1.267.2.1 $"
 
 maxusers	32
 
@@ -125,7 +125,7 @@ options 	DDB_HISTORY_SIZE=100	# enable h
 ## Adds code to the kernel that does internal consistency checks, and will
 ## cause the kernel to panic if corruption of internal data structures
 ## is detected.
-options 	DIAGNOSTIC	# extra kernel sanity checking
+#options 	DIAGNOSTIC	# extra kernel sanity checking
 
 ## Enable (possibly expensive) debugging code that may also display messages
 ## on the system console



CVS commit: [netbsd-9] src/sys/arch/hp300/dev

2021-04-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 21 17:59:48 UTC 2021

Modified Files:
src/sys/arch/hp300/dev [netbsd-9]: diofb.c topcat.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1248):

sys/arch/hp300/dev/topcat.c: revision 1.5
sys/arch/hp300/dev/diofb.c: revision 1.5

Fix two problems on old topcat(4) framebuffers found on HP332/340.

- Fix panic on monochrome framebuffers. They don't have palette registers.
  The problem was reported from Anders Gustafsson and also Andrew Gillham
  back in 2013:
   https://mail-index.netbsd.org/port-hp300/2013/09/27/msg86.html
   https://mail-index.netbsd.org/port-hp300/2013/09/28/msg87.html

- Fix incorrect framebuffer width of 98542/98544 framebuffers on HP332.
  Reported from Andrew Gillham (98542) as above and Chris Hanson (98543):
   https://mail-index.netbsd.org/port-hp300/2013/09/27/msg83.html
   https://mail-index.netbsd.org/port-hp300/2020/05/01/msg000164.html

Worth to pullup to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.34.1 src/sys/arch/hp300/dev/diofb.c
cvs rdiff -u -r1.4 -r1.4.64.1 src/sys/arch/hp300/dev/topcat.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/hp300/dev/diofb.c
diff -u src/sys/arch/hp300/dev/diofb.c:1.4 src/sys/arch/hp300/dev/diofb.c:1.4.34.1
--- src/sys/arch/hp300/dev/diofb.c:1.4	Mon Mar 24 19:42:58 2014
+++ src/sys/arch/hp300/dev/diofb.c	Wed Apr 21 17:59:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: diofb.c,v 1.4 2014/03/24 19:42:58 christos Exp $	*/
+/*	$NetBSD: diofb.c,v 1.4.34.1 2021/04/21 17:59:47 martin Exp $	*/
 /*	$OpenBSD: diofb.c,v 1.18 2010/12/26 15:40:59 miod Exp $	*/
 
 /*
@@ -146,6 +146,15 @@ diofb_fbinquire(struct diofb *fb, int sc
 	if (fb->dheight > fb->fbheight)
 		fb->dheight = fb->fbheight;
 
+	/*
+	 * Some displays, such as the HP332 and HP340 internal video
+	 * appear to return a display width of 1024 instead of 512.
+	 */
+	if (fbr->num_planes == 1 || fbr->num_planes == 4) {
+		if (fb->dwidth == 1024 && fb->dheight == 400)
+			fb->dwidth = 512;
+	}
+
 	fb->planes = fbr->num_planes;
 	if (fb->planes > 8)
 		fb->planes = 8;

Index: src/sys/arch/hp300/dev/topcat.c
diff -u src/sys/arch/hp300/dev/topcat.c:1.4 src/sys/arch/hp300/dev/topcat.c:1.4.64.1
--- src/sys/arch/hp300/dev/topcat.c:1.4	Fri Feb 18 19:15:43 2011
+++ src/sys/arch/hp300/dev/topcat.c	Wed Apr 21 17:59:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: topcat.c,v 1.4 2011/02/18 19:15:43 tsutsui Exp $	*/
+/*	$NetBSD: topcat.c,v 1.4.64.1 2021/04/21 17:59:47 martin Exp $	*/
 /*	$OpenBSD: topcat.c,v 1.15 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -274,7 +274,10 @@ topcat_end_attach(struct topcat_softc *s
 	case GID_TOPCAT:
 		switch (sc->sc_fb->planes) {
 		case 1:
-			fbname = "HP98544 topcat";
+			if (sc->sc_fb->dheight == 400)
+fbname = "HP98542 topcat";
+			else
+fbname = "HP98544 topcat";
 			break;
 		case 4:
 			if (sc->sc_fb->dheight == 400)
@@ -413,8 +416,12 @@ topcat_ioctl(void *v, void *vs, u_long c
 		*(u_int *)data = fb->ri.ri_stride;
 		return 0;
 	case WSDISPLAYIO_GETCMAP:
+		if (fb->planemask == 1)
+			return EPASSTHROUGH;
 		return diofb_getcmap(fb, (struct wsdisplay_cmap *)data);
 	case WSDISPLAYIO_PUTCMAP:
+		if (fb->planemask == 1)
+			return EPASSTHROUGH;
 		return topcat_setcmap(fb, (struct wsdisplay_cmap *)data);
 	case WSDISPLAYIO_GVIDEO:
 	case WSDISPLAYIO_SVIDEO:
@@ -429,6 +436,10 @@ topcat_setcolor(struct diofb *fb, u_int 
 {
 	volatile struct tcboxfb *tc = (struct tcboxfb *)fb->regkva;
 
+	/* No color map registers on monochrome framebuffers. */
+	if (fb->planemask == 1)
+		return;
+
 	if (tc->regs.fbid != GID_TOPCAT) {
 		tccm_waitbusy(tc);
 		tc->plane_mask = 0xff;



CVS commit: [netbsd-9] src/sys/arch/zaurus/dev

2021-04-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 21 17:51:34 UTC 2021

Modified Files:
src/sys/arch/zaurus/dev [netbsd-9]: w100lcd.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1247):

sys/arch/zaurus/dev/w100lcd.c: revision 1.3

Make LCD BrightnessUp/BrightnessDown work on C7x0/860.

Patch from steleto:
 https://gist.github.com/steleto/10f62a074bff0c188fcc10c14ef40b5a

and also confirmed by me on SL-C700.

Worth to pullup to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.56.1 src/sys/arch/zaurus/dev/w100lcd.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/zaurus/dev/w100lcd.c
diff -u src/sys/arch/zaurus/dev/w100lcd.c:1.2 src/sys/arch/zaurus/dev/w100lcd.c:1.2.56.1
--- src/sys/arch/zaurus/dev/w100lcd.c:1.2	Fri Feb 10 11:25:42 2012
+++ src/sys/arch/zaurus/dev/w100lcd.c	Wed Apr 21 17:51:34 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: w100lcd.c,v 1.2 2012/02/10 11:25:42 tsutsui Exp $ */
+/* $NetBSD: w100lcd.c,v 1.2.56.1 2021/04/21 17:51:34 martin Exp $ */
 /*
  * Copyright (c) 2002, 2003  Genetec Corporation.  All rights reserved.
  * Written by Hiroyuki Bessho for Genetec Corporation.
@@ -39,7 +39,9 @@
  * LCD on/off switch and backlight brightness are done in lcdctl.c.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: w100lcd.c,v 1.2 2012/02/10 11:25:42 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: w100lcd.c,v 1.2.56.1 2021/04/21 17:51:34 martin Exp $");
+
+#include "lcdctl.h"
 
 #include 
 #include 
@@ -58,6 +60,9 @@ __KERNEL_RCSID(0, "$NetBSD: w100lcd.c,v 
 
 #include 
 #include 
+#if NLCDCTL > 0
+#include 
+#endif
 
 /*
  * wsdisplay glue



CVS commit: [netbsd-9] src/sys/dev/audio

2021-04-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr  6 17:44:29 UTC 2021

Modified Files:
src/sys/dev/audio [netbsd-9]: audiobell.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #1241):

sys/dev/audio/audiobell.c: revision 1.4

Fix and improve the buffer length calculation to avoid zero length
even if blk_ms is small.

This fixes PR kern/56059.


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

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

Modified files:

Index: src/sys/dev/audio/audiobell.c
diff -u src/sys/dev/audio/audiobell.c:1.3 src/sys/dev/audio/audiobell.c:1.3.2.1
--- src/sys/dev/audio/audiobell.c:1.3	Wed Jun 26 06:57:45 2019
+++ src/sys/dev/audio/audiobell.c	Tue Apr  6 17:44:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiobell.c,v 1.3 2019/06/26 06:57:45 isaki Exp $	*/
+/*	$NetBSD: audiobell.c,v 1.3.2.1 2021/04/06 17:44:29 martin Exp $	*/
 
 /*
  * Copyright (c) 1999 Richard Earnshaw
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audiobell.c,v 1.3 2019/06/26 06:57:45 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audiobell.c,v 1.3.2.1 2021/04/06 17:44:29 martin Exp $");
 
 #include 
 #include 
@@ -81,6 +81,13 @@ static const int32_t sinewave[] = {
 #undef A
 
 /*
+ * The minimum and the maximum buffer sizes must be a multiple of 32
+ * (32 = countof(sinewave) * sizeof(uint16_t)).
+ */
+#define MINBUFSIZE	(1024)
+#define MAXBUFSIZE	(4096)
+
+/*
  * dev is a device_t for the audio device to use.
  * pitch is the pitch of the bell in Hz,
  * period is the length in ms,
@@ -102,7 +109,7 @@ audiobell(void *dev, u_int pitch, u_int 
 	u_int remainbytes;
 	u_int wave1count;
 	u_int wave1bytes;
-	u_int blkbytes;
+	u_int bufbytes;
 	u_int len;
 	u_int step;
 	u_int offset;
@@ -111,6 +118,10 @@ audiobell(void *dev, u_int pitch, u_int 
 
 	KASSERT(volume <= 100);
 
+	/* Playing for 0msec does nothing. */
+	if (period == 0)
+		return;
+
 	/* The audio system isn't built for polling. */
 	if (poll)
 		return;
@@ -158,16 +169,23 @@ audiobell(void *dev, u_int pitch, u_int 
 	remainbytes = remaincount * sizeof(int16_t);
 	wave1bytes = wave1count * sizeof(int16_t);
 
-	blkbytes = ptrack->usrbuf_blksize;
-	blkbytes = rounddown(blkbytes, wave1bytes);
-	blkbytes = uimin(blkbytes, remainbytes);
-	buf = malloc(blkbytes, M_TEMP, M_WAITOK);
+	/* Based on 3*usrbuf_blksize, but not too small or too large */
+	bufbytes = ptrack->usrbuf_blksize * NBLKHW;
+	if (bufbytes < MINBUFSIZE)
+		bufbytes = MINBUFSIZE;
+	else if (bufbytes > MAXBUFSIZE)
+		bufbytes = MAXBUFSIZE;
+	else
+		bufbytes = roundup(bufbytes, wave1bytes);
+	bufbytes = uimin(bufbytes, remainbytes);
+	KASSERT(bufbytes != 0);
+	buf = malloc(bufbytes, M_TEMP, M_WAITOK);
 	if (buf == NULL)
 		goto out;
 
 	/* Generate sinewave with specified volume */
 	j = offset;
-	for (i = 0; i < blkbytes / sizeof(int16_t); i++) {
+	for (i = 0; i < bufbytes / sizeof(int16_t); i++) {
 		/* XXX audio already has track volume feature though #if 0 */
 		buf[i] = AUDIO_SCALEDOWN(sinewave[j] * (int)volume, 16);
 		j += step;
@@ -177,7 +195,7 @@ audiobell(void *dev, u_int pitch, u_int 
 	/* Write while paused to avoid inserting silence. */
 	ptrack->is_pause = true;
 	for (; remainbytes > 0; remainbytes -= len) {
-		len = uimin(remainbytes, blkbytes);
+		len = uimin(remainbytes, bufbytes);
 		aiov.iov_base = (void *)buf;
 		aiov.iov_len = len;
 		auio.uio_iov = 



CVS commit: [netbsd-9] src/sys/arch/sparc/sparc

2021-03-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Mar 31 13:51:05 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc [netbsd-9]: trap.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1240):

sys/arch/sparc/sparc/trap.c: revision 1.199

PR port-sparc/55573: remove kernel message about disabled coprocessor
instructions - it is triggered by userland trying to detect availability
of sparcv9 VIS instructions.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.198.4.1 src/sys/arch/sparc/sparc/trap.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/sparc/sparc/trap.c
diff -u src/sys/arch/sparc/sparc/trap.c:1.198 src/sys/arch/sparc/sparc/trap.c:1.198.4.1
--- src/sys/arch/sparc/sparc/trap.c:1.198	Sat Apr  6 03:06:27 2019
+++ src/sys/arch/sparc/sparc/trap.c	Wed Mar 31 13:51:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.198 2019/04/06 03:06:27 thorpej Exp $ */
+/*	$NetBSD: trap.c,v 1.198.4.1 2021/03/31 13:51:04 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.198 2019/04/06 03:06:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.198.4.1 2021/03/31 13:51:04 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_sunos.h"
@@ -606,7 +606,6 @@ trap(unsigned type, int psr, int pc, str
 		break;
 
 	case T_CPDISABLED:
-		uprintf("coprocessor instruction\n");	/* XXX */
 		sig = SIGILL;
 		KSI_INIT_TRAP();
 		ksi.ksi_trap = type;



CVS commit: [netbsd-9] src/sys/arch/sparc/dev

2021-03-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Mar 31 13:45:54 UTC 2021

Modified Files:
src/sys/arch/sparc/dev [netbsd-9]: audioamd.c

Log Message:
Apply patch, requested by tsutsui in ticket #1239:

sys/arch/sparc/dev/audioamd.c   (apply patch)

Fix for PR 56078 (different solution applied to -current): fix wrong
lock usage.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.2.1 src/sys/arch/sparc/dev/audioamd.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/sparc/dev/audioamd.c
diff -u src/sys/arch/sparc/dev/audioamd.c:1.29 src/sys/arch/sparc/dev/audioamd.c:1.29.2.1
--- src/sys/arch/sparc/dev/audioamd.c:1.29	Wed May  8 13:40:16 2019
+++ src/sys/arch/sparc/dev/audioamd.c	Wed Mar 31 13:45:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audioamd.c,v 1.29 2019/05/08 13:40:16 isaki Exp $	*/
+/*	$NetBSD: audioamd.c,v 1.29.2.1 2021/03/31 13:45:54 martin Exp $	*/
 /*	NetBSD: am7930_sparc.c,v 1.44 1999/03/14 22:29:00 jonathan Exp 	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audioamd.c,v 1.29 2019/05/08 13:40:16 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audioamd.c,v 1.29.2.1 2021/03/31 13:45:54 martin Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -461,7 +461,7 @@ am7930swintr(void *sc0)
 
 	au = >sc_au;
 
-	mutex_spin_enter(>sc_am7930.sc_lock);
+	mutex_spin_enter(>sc_am7930.sc_intr_lock);
 	if (au->au_rdata > au->au_rend && sc->sc_rintr != NULL) {
 		(*sc->sc_rintr)(sc->sc_rarg);
 	}
@@ -469,7 +469,7 @@ am7930swintr(void *sc0)
 	if (pint)
 		(*sc->sc_pintr)(sc->sc_parg);
 
-	mutex_spin_exit(>sc_am7930.sc_lock);
+	mutex_spin_exit(>sc_am7930.sc_intr_lock);
 }
 
 



CVS commit: [netbsd-9] src/sys/arch/arm/cortex

2021-03-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Mar 31 13:41:01 UTC 2021

Modified Files:
src/sys/arch/arm/cortex [netbsd-9]: gic.c

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

sys/arch/arm/cortex/gic.c: revision 1.47

Only target the boot cpu for real with SPI interrupts.  I tried to do
this back in 2014, but somehow I missed a spot.

This is a quick-and-dirty fix for the USB stack which expects transfer
completions to be in-order.  If interrupts happen across the CPUs then
this isn't guaranteed (yet).

kern/55243 panic at usb_transfer_complete() on raspberry pi 4


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.4.1 src/sys/arch/arm/cortex/gic.c

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

Modified files:

Index: src/sys/arch/arm/cortex/gic.c
diff -u src/sys/arch/arm/cortex/gic.c:1.38 src/sys/arch/arm/cortex/gic.c:1.38.4.1
--- src/sys/arch/arm/cortex/gic.c:1.38	Fri Nov 16 23:25:09 2018
+++ src/sys/arch/arm/cortex/gic.c	Wed Mar 31 13:41:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gic.c,v 1.38 2018/11/16 23:25:09 jmcneill Exp $	*/
+/*	$NetBSD: gic.c,v 1.38.4.1 2021/03/31 13:41:01 martin Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.38 2018/11/16 23:25:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.38.4.1 2021/03/31 13:41:01 martin Exp $");
 
 #include 
 #include 
@@ -504,7 +504,11 @@ armgic_cpu_init_targets(struct armgic_so
 		if (is != NULL && is->is_mpsafe) {
 			const u_int byte_shift = 8 * (irq & 3);
 			uint32_t targets = gicd_read(sc, targets_reg);
+#if 0
 			targets |= sc->sc_mptargets << byte_shift;
+#else
+			targets |= sc->sc_bptargets << byte_shift;
+#endif
 			gicd_write(sc, targets_reg, targets);
 		}
 	}



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

2021-03-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 27 13:02:00 UTC 2021

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

Log Message:
regen for ticket #1236 (BELKIN F5D7050E fix)


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

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

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.760.4.7 src/sys/dev/usb/usbdevs.h:1.760.4.8
--- src/sys/dev/usb/usbdevs.h:1.760.4.7	Thu Feb  4 19:23:59 2021
+++ src/sys/dev/usb/usbdevs.h	Sat Mar 27 13:01:58 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.760.4.7 2021/02/04 19:23:59 martin Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.760.4.8 2021/03/27 13:01:58 martin Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.770.4.7 2021/02/04 19:23:10 martin Exp
+ *	NetBSD: usbdevs,v 1.770.4.8 2021/03/27 13:00:45 martin Exp
  */
 
 /*-
@@ -1086,7 +1086,7 @@
 #define	USB_PRODUCT_BELKIN_F5D7051	0x7051		/* F5D7051 54g USB Network Adapter */
 #define	USB_PRODUCT_BELKIN_F5D7050A	0x705a		/* F5D705A 54g USB Network Adapter */
 #define	USB_PRODUCT_BELKIN_F5D7050C	0x705c		/* F5D705C 54g USB Network Adapter */
-#define	USB_PRODUCT_BELKIN_F5D7050E	0x705c		/* F5D705E 54g USB Network Adapter */
+#define	USB_PRODUCT_BELKIN_F5D7050E	0x705e		/* F5D705E 54g USB Network Adapter */
 #define	USB_PRODUCT_BELKIN_RT2870_1	0x8053		/* RT2870 */
 #define	USB_PRODUCT_BELKIN_RT2870_2	0x805c		/* RT2870 */
 #define	USB_PRODUCT_BELKIN_F5D8053V3	0x815c		/* F5D8053 v3 */
Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.760.4.7 src/sys/dev/usb/usbdevs_data.h:1.760.4.8
--- src/sys/dev/usb/usbdevs_data.h:1.760.4.7	Thu Feb  4 19:23:59 2021
+++ src/sys/dev/usb/usbdevs_data.h	Sat Mar 27 13:01:58 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.760.4.7 2021/02/04 19:23:59 martin Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.760.4.8 2021/03/27 13:01:58 martin Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.770.4.7 2021/02/04 19:23:10 martin Exp
+ *	NetBSD: usbdevs,v 1.770.4.8 2021/03/27 13:00:45 martin Exp
  */
 
 /*-



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

2021-03-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 27 13:00:45 UTC 2021

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

Log Message:
Pull up following revision(s) (requested by nia in ticket #1236):

sys/dev/usb/usbdevs: revision 1.793

correct usb device id for BELKIN F5D7050E

matches freebsd / openbsd (sources of urtw driver), various online
sources

PR kern/56056


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

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

Modified files:

Index: src/sys/dev/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.770.4.7 src/sys/dev/usb/usbdevs:1.770.4.8
--- src/sys/dev/usb/usbdevs:1.770.4.7	Thu Feb  4 19:23:10 2021
+++ src/sys/dev/usb/usbdevs	Sat Mar 27 13:00:45 2021
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.770.4.7 2021/02/04 19:23:10 martin Exp $
+$NetBSD: usbdevs,v 1.770.4.8 2021/03/27 13:00:45 martin Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1079,7 +1079,7 @@ product BELKIN F5D7050		0x7050	F5D7050 5
 product BELKIN F5D7051		0x7051	F5D7051 54g USB Network Adapter
 product BELKIN F5D7050A		0x705a	F5D705A 54g USB Network Adapter
 product BELKIN F5D7050C		0x705c	F5D705C 54g USB Network Adapter
-product BELKIN F5D7050E		0x705c	F5D705E 54g USB Network Adapter
+product BELKIN F5D7050E		0x705e	F5D705E 54g USB Network Adapter
 product BELKIN RT2870_1		0x8053	RT2870
 product BELKIN RT2870_2		0x805c	RT2870
 product BELKIN F5D8053V3	0x815c	F5D8053 v3



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

2021-03-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar 22 18:20:38 UTC 2021

Modified Files:
src/sys/dev/usb [netbsd-9]: if_urtwn.c

Log Message:
Pull up following revision(s) (requested by nat in ticket #1234),
all via patch:

sys/dev/usb/if_urtwn.c: revision 1.93
sys/dev/usb/if_urtwn.c: revision 1.95
sys/dev/usb/if_urtwn.c: revision 1.96

if_urtwn.c: Plug a few leaks
Can be a cause of PR/55968

Also free assocated mbufs.

OppsRemove irrelavent debug code and don't free_m before IFQ_DEQUEUE().
Identified and reported by Patrick Welche and remedy found by Martin Husemann.


To generate a diff of this commit:
cvs rdiff -u -r1.71.2.4 -r1.71.2.5 src/sys/dev/usb/if_urtwn.c

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

Modified files:

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.71.2.4 src/sys/dev/usb/if_urtwn.c:1.71.2.5
--- src/sys/dev/usb/if_urtwn.c:1.71.2.4	Thu Feb  4 19:23:10 2021
+++ src/sys/dev/usb/if_urtwn.c	Mon Mar 22 18:20:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.71.2.4 2021/02/04 19:23:10 martin Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.71.2.5 2021/03/22 18:20:38 martin Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.71.2.4 2021/02/04 19:23:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.71.2.5 2021/03/22 18:20:38 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2563,6 +2563,17 @@ urtwn_rxeof(struct usbd_xfer *xfer, void
 }
 
 static void
+urtwn_put_tx_data(struct urtwn_softc *sc, struct urtwn_tx_data *data)
+{
+	size_t pidx = data->pidx;
+
+	mutex_enter(>sc_tx_mtx);
+	/* Put this Tx buffer back to our free list. */
+	TAILQ_INSERT_TAIL(>tx_free_list[pidx], data, next);
+	mutex_exit(>sc_tx_mtx);
+}
+
+static void
 urtwn_txeof(struct usbd_xfer *xfer, void *priv, usbd_status status)
 {
 	struct urtwn_tx_data *data = priv;
@@ -2574,10 +2585,7 @@ urtwn_txeof(struct usbd_xfer *xfer, void
 	DPRINTFN(DBG_FN|DBG_TX, ("%s: %s: status=%d\n",
 	device_xname(sc->sc_dev), __func__, status));
 
-	mutex_enter(>sc_tx_mtx);
-	/* Put this Tx buffer back to our free list. */
-	TAILQ_INSERT_TAIL(>tx_free_list[pidx], data, next);
-	mutex_exit(>sc_tx_mtx);
+	urtwn_put_tx_data(sc, data);
 
 	s = splnet();
 	sc->tx_timer = 0;
@@ -2626,8 +2634,11 @@ urtwn_tx(struct urtwn_softc *sc, struct 
 
 	if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
 		k = ieee80211_crypto_encap(ic, ni, m);
-		if (k == NULL)
+		if (k == NULL) {
+			urtwn_put_tx_data(sc, data);
+			m_free(m);
 			return ENOBUFS;
+		}
 
 		/* packet header may have moved, reset our local pointer */
 		wh = mtod(m, struct ieee80211_frame *);
@@ -2890,14 +2901,17 @@ urtwn_start(struct ifnet *ifp)
 		(m = m_pullup(m, sizeof(*eh))) == NULL) {
 			printf("ERROR6\n");
 			ifp->if_oerrors++;
+			urtwn_put_tx_data(sc, data);
+			m_freem(m);
 			continue;
 		}
 		eh = mtod(m, struct ether_header *);
 		ni = ieee80211_find_txnode(ic, eh->ether_dhost);
 		if (ni == NULL) {
-			m_freem(m);
 			printf("ERROR5\n");
 			ifp->if_oerrors++;
+			urtwn_put_tx_data(sc, data);
+			m_freem(m);
 			continue;
 		}
 
@@ -2907,6 +2921,8 @@ urtwn_start(struct ifnet *ifp)
 			ieee80211_free_node(ni);
 			printf("ERROR4\n");
 			ifp->if_oerrors++;
+			urtwn_put_tx_data(sc, data);
+			m_freem(m);
 			continue;
 		}
  sendit:



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

2021-03-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar 22 18:06:17 UTC 2021

Modified Files:
src/sys/net [netbsd-9]: if_l2tp.h

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #1233):

sys/net/if_l2tp.h: revision 1.10

Fix l2tp(4) ioctl type. Pointed out by yamaguchi@n.o, thanks.
XXX pullup-[89]


To generate a diff of this commit:
cvs rdiff -u -r1.6.4.1 -r1.6.4.2 src/sys/net/if_l2tp.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/net/if_l2tp.h
diff -u src/sys/net/if_l2tp.h:1.6.4.1 src/sys/net/if_l2tp.h:1.6.4.2
--- src/sys/net/if_l2tp.h:1.6.4.1	Tue Sep 24 03:10:35 2019
+++ src/sys/net/if_l2tp.h	Mon Mar 22 18:06:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_l2tp.h,v 1.6.4.1 2019/09/24 03:10:35 martin Exp $	*/
+/*	$NetBSD: if_l2tp.h,v 1.6.4.2 2021/03/22 18:06:17 martin Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -44,11 +44,11 @@
 #include 
 #include 
 
-#define	SIOCSL2TPSESSION	_IOW('i', 151, struct l2tp_req)
-#define	SIOCDL2TPSESSION	_IOW('i', 152, struct l2tp_req)
-#define	SIOCSL2TPCOOKIE		_IOW('i', 153, struct l2tp_req)
-#define	SIOCDL2TPCOOKIE		_IOW('i', 154, struct l2tp_req)
-#define	SIOCSL2TPSTATE		_IOW('i', 155, struct l2tp_req)
+#define	SIOCSL2TPSESSION	_IOW('i', 151, struct ifreq)
+#define	SIOCDL2TPSESSION	_IOW('i', 152, struct ifreq)
+#define	SIOCSL2TPCOOKIE		_IOW('i', 153, struct ifreq)
+#define	SIOCDL2TPCOOKIE		_IOW('i', 154, struct ifreq)
+#define	SIOCSL2TPSTATE		_IOW('i', 155, struct ifreq)
 #define	SIOCGL2TP		SIOCGIFGENERIC
 
 struct l2tp_req {



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

2021-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar  9 15:54:32 UTC 2021

Modified Files:
src/sys/netinet [netbsd-9]: in_var.h tcp_subr.c tcp_timer.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1229):

sys/netinet/tcp_subr.c: revision 1.286
sys/netinet/tcp_timer.c: revision 1.96
sys/netinet/in_var.h: revision 1.102
sys/netinet/in_var.h: revision 1.99

Don't increment the iss sequence on each connection because it exposes
information (Amit Klein)

Add some randomness to the iss offset

Use a random IPv4 ID because the shuffling algorithm used before could expose
information (Amit Klein)

mv  include to the kernel portion


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.97.4.1 src/sys/netinet/in_var.h
cvs rdiff -u -r1.282.4.2 -r1.282.4.3 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.95 -r1.95.6.1 src/sys/netinet/tcp_timer.c

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

Modified files:

Index: src/sys/netinet/in_var.h
diff -u src/sys/netinet/in_var.h:1.97 src/sys/netinet/in_var.h:1.97.4.1
--- src/sys/netinet/in_var.h:1.97	Thu Nov 29 09:51:20 2018
+++ src/sys/netinet/in_var.h	Tue Mar  9 15:54:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_var.h,v 1.97 2018/11/29 09:51:20 ozaki-r Exp $	*/
+/*	$NetBSD: in_var.h,v 1.97.4.1 2021/03/09 15:54:32 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -374,6 +374,7 @@ struct in_multi {
 #ifdef _KERNEL
 
 #include 
+#include 
 
 extern pktqueue_t *ip_pktq;
 
@@ -461,7 +462,8 @@ ip_newid_range(const struct in_ifaddr *i
 
 	if (ip_do_randomid) {
 		/* XXX ignore num */
-		return ip_randomid(ip_ids, ia ? ia->ia_idsalt : 0);
+		id = (uint16_t)cprng_fast32();
+		return id ? id : 1;
 	}
 
 	/* Never allow an IP ID of 0 (detect wrap). */

Index: src/sys/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.282.4.2 src/sys/netinet/tcp_subr.c:1.282.4.3
--- src/sys/netinet/tcp_subr.c:1.282.4.2	Sun Mar  7 19:04:31 2021
+++ src/sys/netinet/tcp_subr.c	Tue Mar  9 15:54:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_subr.c,v 1.282.4.2 2021/03/07 19:04:31 martin Exp $	*/
+/*	$NetBSD: tcp_subr.c,v 1.282.4.3 2021/03/09 15:54:32 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.282.4.2 2021/03/07 19:04:31 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.282.4.3 2021/03/09 15:54:32 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2220,7 +2220,6 @@ tcp_new_iss1(void *laddr, void *faddr, u
 		 * XXX Use `addin'?
 		 * XXX TCP_ISSINCR too large to use?
 		 */
-		tcp_iss_seq += TCP_ISSINCR;
 #ifdef TCPISS_DEBUG
 		printf("ISS hash 0x%08x, ", tcp_iss);
 #endif
@@ -2256,7 +2255,6 @@ tcp_new_iss1(void *laddr, void *faddr, u
 		} else {
 			tcp_iss &= TCP_ISS_RANDOM_MASK;
 			tcp_iss += tcp_iss_seq;
-			tcp_iss_seq += TCP_ISSINCR;
 #ifdef TCPISS_DEBUG
 			printf("ISS %08x\n", tcp_iss);
 #endif

Index: src/sys/netinet/tcp_timer.c
diff -u src/sys/netinet/tcp_timer.c:1.95 src/sys/netinet/tcp_timer.c:1.95.6.1
--- src/sys/netinet/tcp_timer.c:1.95	Thu May  3 07:13:48 2018
+++ src/sys/netinet/tcp_timer.c	Tue Mar  9 15:54:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_timer.c,v 1.95 2018/05/03 07:13:48 maxv Exp $	*/
+/*	$NetBSD: tcp_timer.c,v 1.95.6.1 2021/03/09 15:54:32 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.95 2018/05/03 07:13:48 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.95.6.1 2021/03/09 15:54:32 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -111,6 +111,7 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -257,7 +258,7 @@ tcp_slowtimo_work(struct work *wk, void 
 {
 
 	mutex_enter(softnet_lock);
-	tcp_iss_seq += TCP_ISSINCR;			/* increment iss */
+	tcp_iss_seq += TCP_ISSINCR + (TCP_ISS_RANDOM_MASK & cprng_fast32());
 	tcp_now++;	/* for timestamps */
 	mutex_exit(softnet_lock);
 



CVS commit: [netbsd-9] src/sys/dev/ic

2021-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar  9 15:47:07 UTC 2021

Modified Files:
src/sys/dev/ic [netbsd-9]: mb89352.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1228):

sys/dev/ic/mb89352.c: revision 1.58

Fix a possible race condition in spc_msgin() in NO_MANUAL_XFER case.

To avoid the race, check SSTS and INTS after XFR command as
spc_pio_datain() does.

Reported from isaki@, observed on nono emulator.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.57.4.1 src/sys/dev/ic/mb89352.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/mb89352.c
diff -u src/sys/dev/ic/mb89352.c:1.57 src/sys/dev/ic/mb89352.c:1.57.4.1
--- src/sys/dev/ic/mb89352.c:1.57	Mon Sep  3 16:29:31 2018
+++ src/sys/dev/ic/mb89352.c	Tue Mar  9 15:47:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mb89352.c,v 1.57 2018/09/03 16:29:31 riastradh Exp $	*/
+/*	$NetBSD: mb89352.c,v 1.57.4.1 2021/03/09 15:47:07 martin Exp $	*/
 /*	NecBSD: mb89352.c,v 1.4 1998/03/14 07:31:20 kmatsuda Exp	*/
 
 /*-
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mb89352.c,v 1.57 2018/09/03 16:29:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mb89352.c,v 1.57.4.1 2021/03/09 15:47:07 martin Exp $");
 
 #ifdef DDB
 #define	integrate
@@ -932,6 +932,7 @@ nextbyte:
 	 */
 	for (;;) {
 #ifdef NO_MANUAL_XFER /* XXX */
+		uint8_t intstat;
 		if (bus_space_read_1(iot, ioh, INTS) != 0) {
 			/*
 			 * Target left MESSAGE IN, probably because it
@@ -960,12 +961,18 @@ nextbyte:
 #else
 		bus_space_write_1(iot, ioh, SCMD, SCMD_XFR | SCMD_PROG_XFR);
 #endif
+		intstat = 0;
 		for (;;) {
 			if ((bus_space_read_1(iot, ioh, SSTS) &
 			SSTS_DREG_EMPTY) == 0)
 break;
-			if (bus_space_read_1(iot, ioh, INTS) != 0)
+			/*
+			 * We have to read INTS before checking SSTS to avoid
+			 * race between SSTS_DREG_EMPTY and INTS_CMD_DONE.
+			 */
+			if (intstat != 0)
 goto out;
+			intstat = bus_space_read_1(iot, ioh, INTS);
 		}
 		msg = bus_space_read_1(iot, ioh, DREG);
 #else



CVS commit: [netbsd-9] src/sys

2021-03-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  7 19:04:31 UTC 2021

Modified Files:
src/sys/netinet [netbsd-9]: ip6.h ip_input.c tcp_subr.c
src/sys/netinet6 [netbsd-9]: ip6_id.c ip6_var.h

Log Message:
Pull up following revision(s) (requested by christos in ticket #1226):

sys/netinet6/ip6_id.c: revision 1.19-1.21
sys/netinet6/ip6_var.h: revision 1.88
sys/netinet/ip_input.c: revision 1.400
sys/netinet/tcp_subr.c: revision 1.285
sys/netinet/ip6.h: revision 1.30

netinet: Enable random IP fragment ids by default (from riastradh)

netinet: Enable RFC 1948 pseudorandom TCP ISS selection by default.
(from riastradh)

netinet6: Mark randomid unused.

Will make merging and bisection easier if anything goes wrong with
flow label or fragment id randomization changes.
(from riastradh)

netinet/netinet6: Add necessary includes to make these standalone.
(from riastradh)

Replace randomid() by cprng_fast32()


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.25.6.1 src/sys/netinet/ip6.h
cvs rdiff -u -r1.389.2.2 -r1.389.2.3 src/sys/netinet/ip_input.c
cvs rdiff -u -r1.282.4.1 -r1.282.4.2 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.18 -r1.18.22.1 src/sys/netinet6/ip6_id.c
cvs rdiff -u -r1.82 -r1.82.2.1 src/sys/netinet6/ip6_var.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/netinet/ip6.h
diff -u src/sys/netinet/ip6.h:1.25 src/sys/netinet/ip6.h:1.25.6.1
--- src/sys/netinet/ip6.h:1.25	Fri May 18 18:52:17 2018
+++ src/sys/netinet/ip6.h	Sun Mar  7 19:04:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6.h,v 1.25 2018/05/18 18:52:17 maxv Exp $	*/
+/*	$NetBSD: ip6.h,v 1.25.6.1 2021/03/07 19:04:31 martin Exp $	*/
 /*	$KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $	*/
 
 /*
@@ -64,6 +64,11 @@
 #ifndef _NETINET_IP6_H_
 #define _NETINET_IP6_H_
 
+#include 
+#include 
+
+#include 
+
 /*
  * Definition for internet protocol version 6.
  * RFC 2460

Index: src/sys/netinet/ip_input.c
diff -u src/sys/netinet/ip_input.c:1.389.2.2 src/sys/netinet/ip_input.c:1.389.2.3
--- src/sys/netinet/ip_input.c:1.389.2.2	Tue Sep 24 03:10:35 2019
+++ src/sys/netinet/ip_input.c	Sun Mar  7 19:04:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.389.2.2 2019/09/24 03:10:35 martin Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.389.2.3 2021/03/07 19:04:31 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.389.2.2 2019/09/24 03:10:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.389.2.3 2021/03/07 19:04:31 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -168,7 +168,7 @@ int ip_directedbcast = 0;
 int ip_allowsrcrt = 0;
 int ip_mtudisc = 1;
 int ip_mtudisc_timeout = IPMTUDISCTIMEOUT;
-int ip_do_randomid = 0;
+int ip_do_randomid = 1;
 
 /*
  * XXX - Setting ip_checkinterface mostly implements the receive side of

Index: src/sys/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.282.4.1 src/sys/netinet/tcp_subr.c:1.282.4.2
--- src/sys/netinet/tcp_subr.c:1.282.4.1	Tue Sep 10 16:19:00 2019
+++ src/sys/netinet/tcp_subr.c	Sun Mar  7 19:04:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_subr.c,v 1.282.4.1 2019/09/10 16:19:00 martin Exp $	*/
+/*	$NetBSD: tcp_subr.c,v 1.282.4.2 2021/03/07 19:04:31 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.282.4.1 2019/09/10 16:19:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.282.4.2 2021/03/07 19:04:31 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -163,7 +163,7 @@ int 	tcp_mssdflt = TCP_MSS;
 int	tcp_minmss = TCP_MINMSS;
 int 	tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
 int	tcp_do_rfc1323 = 1;	/* window scaling / timestamps (obsolete) */
-int	tcp_do_rfc1948 = 0;	/* ISS by cryptographic hash */
+int	tcp_do_rfc1948 = 1;	/* ISS by cryptographic hash */
 int	tcp_do_sack = 1;	/* selective acknowledgement */
 int	tcp_do_win_scale = 1;	/* RFC1323 window scaling */
 int	tcp_do_timestamps = 1;	/* RFC1323 timestamps */

Index: src/sys/netinet6/ip6_id.c
diff -u src/sys/netinet6/ip6_id.c:1.18 src/sys/netinet6/ip6_id.c:1.18.22.1
--- src/sys/netinet6/ip6_id.c:1.18	Fri Aug  7 08:11:33 2015
+++ src/sys/netinet6/ip6_id.c	Sun Mar  7 19:04:31 2021
@@ -1,9 +1,7 @@
-/*	$NetBSD: ip6_id.c,v 1.18 2015/08/07 08:11:33 ozaki-r Exp $	*/
-/*	$KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $	*/
-/*	$OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $	*/
+/*	$NetBSD: ip6_id.c,v 1.18.22.1 2021/03/07 19:04:31 martin Exp $	*/
 
-/*
- * Copyright (C) 2003 WIDE Project.
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,241 +12,38 @@
  * 2. Redistributions in binary form must reproduce the 

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

2021-03-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  7 18:43:25 UTC 2021

Modified Files:
src/sys/dev/usb [netbsd-9]: uaudio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #1225):

sys/dev/usb/uaudio.c: revision 1.169

Fix my copy-and-paste bug in rev1.160.

This fixes recording sample dropout.


To generate a diff of this commit:
cvs rdiff -u -r1.161.2.1 -r1.161.2.2 src/sys/dev/usb/uaudio.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/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.161.2.1 src/sys/dev/usb/uaudio.c:1.161.2.2
--- src/sys/dev/usb/uaudio.c:1.161.2.1	Tue Nov 19 12:56:48 2019
+++ src/sys/dev/usb/uaudio.c	Sun Mar  7 18:43:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.161.2.1 2019/11/19 12:56:48 martin Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.161.2.2 2021/03/07 18:43:25 martin Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.161.2.1 2019/11/19 12:56:48 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.161.2.2 2021/03/07 18:43:25 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -3003,7 +3003,8 @@ uaudio_set_format(void *addr, int setmod
 		raltidx = audio_indexof_format(sc->sc_formats, sc->sc_nformats,
 		AUMODE_RECORD, rec);
 		/* Transfer should have halted */
-		uaudio_chan_init(>sc_recchan, raltidx, rec, 0);
+		uaudio_chan_init(>sc_recchan, raltidx, rec,
+		UGETW(sc->sc_alts[raltidx].edesc->wMaxPacketSize));
 	}
 
 	if ((setmode & AUMODE_PLAY) && sc->sc_playchan.altidx != -1) {



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

2021-03-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar  5 13:48:27 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: kern_subr.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1222):

sys/kern/kern_subr.c: revision 1.229

Restore missing message for RB_ASKNAME.
Cleanups.


To generate a diff of this commit:
cvs rdiff -u -r1.223.4.1 -r1.223.4.2 src/sys/kern/kern_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/kern_subr.c
diff -u src/sys/kern/kern_subr.c:1.223.4.1 src/sys/kern/kern_subr.c:1.223.4.2
--- src/sys/kern/kern_subr.c:1.223.4.1	Tue Sep 17 19:45:03 2019
+++ src/sys/kern/kern_subr.c	Fri Mar  5 13:48:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_subr.c,v 1.223.4.1 2019/09/17 19:45:03 martin Exp $	*/
+/*	$NetBSD: kern_subr.c,v 1.223.4.2 2021/03/05 13:48:27 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.223.4.1 2019/09/17 19:45:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.223.4.2 2021/03/05 13:48:27 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -442,8 +442,20 @@ setroot_ask(device_t bootdv, int bootpar
 		}
 	}
 
+	switch (device_class(rootdv)) {
+	case DV_IFNET:
+	case DV_DISK:
+		aprint_normal("root on %s", device_xname(rootdv));
+		if (DEV_USES_PARTITIONS(rootdv))
+			aprint_normal("%c", (int)DISKPART(rootdev) + 'a');
+		break;
+	default:
+		printf("can't determine root device\n");
+		return;
+	}
+
 	root_device = rootdv;
-	setroot_dump(root_device, dumpdv);
+	setroot_dump(rootdv, dumpdv);
 }
 
 /*



CVS commit: [netbsd-9] src/sys/dev/audio

2021-03-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  1 16:00:08 UTC 2021

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #1219):

sys/dev/audio/audio.c: revision 1.89
sys/dev/audio/audio.c: revision 1.90
sys/dev/audio/audio.c: revision 1.91

Change the lock conditions to call audio_unlink().

This can remove a different copy of audio_exlock_enter() in audio_unlink()
and can use normal one.  Also, in audiodetach(), this can set the exlock
at more natual order (before calling audio_unlink()).

No noticeable functional changes are intended.
Thanks for comments, riastradh@.

Protect also audioopen() and audiobellopen() from audiodetach() with
psref(9), as well as others(audioread, audiowrite, etc..).
- Rename audio_file_enter to audio_sc_acquire_fromfile, audio_file_exit
  to audio_sc_release, for clarify.  These are the reference counter for
  this sc.
- Introduce audio_sc_acquire_foropen for audio{,bell}open.
- audio_open needs to examine sc_dying again before inserting it into
  sc_files, in order to keep sc_files consistency.

The race between audiodetach and audioopen is pointed out by riastradh@.
Thank you for many advices.

Add missing curlwp_bindx() corresponding to curlwp_bind().
Pointed out by riastradh@.


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

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.20 src/sys/dev/audio/audio.c:1.28.2.21
--- src/sys/dev/audio/audio.c:1.28.2.20	Sun Feb 28 07:07:38 2021
+++ src/sys/dev/audio/audio.c	Mon Mar  1 16:00:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.20 2021/02/28 07:07:38 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.21 2021/03/01 16:00:08 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.20 2021/02/28 07:07:38 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.21 2021/03/01 16:00:08 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -524,8 +524,10 @@ static int audio_exlock_mutex_enter(stru
 static void audio_exlock_mutex_exit(struct audio_softc *);
 static int audio_exlock_enter(struct audio_softc *);
 static void audio_exlock_exit(struct audio_softc *);
-static struct audio_softc *audio_file_enter(audio_file_t *, struct psref *);
-static void audio_file_exit(struct audio_softc *, struct psref *);
+static void audio_sc_acquire_foropen(struct audio_softc *, struct psref *);
+static struct audio_softc *audio_sc_acquire_fromfile(audio_file_t *,
+	struct psref *);
+static void audio_sc_release(struct audio_softc *, struct psref *);
 static int audio_track_waitio(struct audio_softc *, audio_track_t *);
 
 static int audioclose(struct file *);
@@ -1295,7 +1297,10 @@ audiodetach(device_t self, int flags)
 	if (error)
 		return error;
 
-	/* delete sysctl nodes */
+	/*
+	 * This waits currently running sysctls to finish if exists.
+	 * After this, no more new sysctls will come.
+	 */
 	sysctl_teardown(>sc_log);
 
 	mutex_enter(sc->sc_lock);
@@ -1327,9 +1332,10 @@ audiodetach(device_t self, int flags)
 	 * that hold sc, and any new calls with files that were for sc will
 	 * fail.  Thus, we now have exclusive access to the softc.
 	 */
+	sc->sc_exlock = 1;
 
 	/*
-	 * Nuke all open instances.
+	 * Clean up all open instances.
 	 * Here, we no longer need any locks to traverse sc_files.
 	 */
 	while ((file = SLIST_FIRST(>sc_files)) != NULL) {
@@ -1352,7 +1358,6 @@ audiodetach(device_t self, int flags)
 	pmf_device_deregister(self);
 
 	/* Free resources */
-	sc->sc_exlock = 1;
 	if (sc->sc_pmixer) {
 		audio_mixer_destroy(sc, sc->sc_pmixer);
 		kmem_free(sc->sc_pmixer, sizeof(*sc->sc_pmixer));
@@ -1524,18 +1529,41 @@ audio_exlock_exit(struct audio_softc *sc
 }
 
 /*
- * Acquire sc from file, and increment the psref count.
+ * Increment reference counter for this sc.
+ * This is intended to be used for open.
+ */
+void
+audio_sc_acquire_foropen(struct audio_softc *sc, struct psref *refp)
+{
+	int s;
+
+	/* Block audiodetach while we acquire a reference */
+	s = pserialize_read_enter();
+
+	/*
+	 * We don't examine sc_dying here.  However, all open methods
+	 * call audio_exlock_enter() right after this, so we can examine
+	 * sc_dying in it.
+	 */
+
+	/* Acquire a reference */
+	psref_acquire(refp, >sc_psref, audio_psref_class);
+
+	/* Now sc won't go away until we drop the reference count */
+	pserialize_read_exit(s);
+}
+
+/*
+ * Get sc from file, and increment reference counter for this sc.
+ * This is intended to be used for methods other than open.
  * If successful, returns sc.  Otherwise returns NULL.
  */
 struct audio_softc *
-audio_file_enter(audio_file_t *file, struct psref *refp)

CVS commit: [netbsd-9] src/sys/dev/audio

2021-02-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Feb 28 07:07:38 UTC 2021

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #1218):

sys/dev/audio/audio.c: revision 1.84

Fix a return value of audiopoll().
fo_poll is expected to return revents rather than errno on error.


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

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.19 src/sys/dev/audio/audio.c:1.28.2.20
--- src/sys/dev/audio/audio.c:1.28.2.19	Sun Feb 28 07:05:14 2021
+++ src/sys/dev/audio/audio.c	Sun Feb 28 07:07:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.19 2021/02/28 07:05:14 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.20 2021/02/28 07:07:38 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.19 2021/02/28 07:05:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.20 2021/02/28 07:07:38 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1885,7 +1885,7 @@ audiopoll(struct file *fp, int events)
 
 	sc = audio_file_enter(file, _ref);
 	if (sc == NULL)
-		return EIO;
+		return POLLERR;
 
 	switch (AUDIODEV(dev)) {
 	case SOUND_DEVICE:



CVS commit: [netbsd-9] src/sys/dev/audio

2021-02-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Feb 28 07:05:14 UTC 2021

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #1217):

sys/dev/audio/audio.c: revision 1.46
sys/dev/audio/audio.c: revision 1.82
sys/dev/audio/audio.c: revision 1.85
sys/dev/audio/audio.c: revision 1.87
sys/dev/audio/audio.c: revision 1.88

Change two aprint_error_dev() to device_printf() (and improve messages).
This is also called from other than boot.

Add missing newline.

Revise comments.

Change (harmless) zero-length debug messages.
sys/modules is compiled with -Wzero-length-format and this
makes sys/modules compilable even if AUDIO_DEBUG is defined.

Improve error messages.
- prefix MD device name if it's considered to be related to the MD driver.
- revise some messages.


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

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.18 src/sys/dev/audio/audio.c:1.28.2.19
--- src/sys/dev/audio/audio.c:1.28.2.18	Sat Dec 19 13:54:56 2020
+++ src/sys/dev/audio/audio.c	Sun Feb 28 07:05:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.18 2020/12/19 13:54:56 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.19 2021/02/28 07:05:14 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.18 2020/12/19 13:54:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.19 2021/02/28 07:05:14 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -518,6 +518,8 @@ static void audio_mixer_restore(struct a
 static void audio_softintr_rd(void *);
 static void audio_softintr_wr(void *);
 
+static void audio_printf(struct audio_softc *, const char *, ...)
+	__printflike(2, 3);
 static int audio_exlock_mutex_enter(struct audio_softc *);
 static void audio_exlock_mutex_exit(struct audio_softc *);
 static int audio_exlock_enter(struct audio_softc *);
@@ -965,19 +967,20 @@ audioattach(device_t parent, device_t se
 		perror = audio_hw_probe(sc, , AUMODE_PLAY);
 		rerror = audio_hw_probe(sc, , AUMODE_RECORD);
 		if (perror && rerror) {
-			aprint_error_dev(self, "audio_hw_probe failed, "
-			"perror = %d, rerror = %d\n", perror, rerror);
+			aprint_error_dev(self,
+			"audio_hw_probe failed: perror=%d, rerror=%d\n",
+			perror, rerror);
 			goto bad;
 		}
 		if (perror) {
 			mode &= ~AUMODE_PLAY;
-			aprint_error_dev(self, "audio_hw_probe failed with "
-			"%d, playback disabled\n", perror);
+			aprint_error_dev(self, "audio_hw_probe failed: "
+			"errno=%d, playback disabled\n", perror);
 		}
 		if (rerror) {
 			mode &= ~AUMODE_RECORD;
-			aprint_error_dev(self, "audio_hw_probe failed with "
-			"%d, capture disabled\n", rerror);
+			aprint_error_dev(self, "audio_hw_probe failed: "
+			"errno=%d, capture disabled\n", rerror);
 		}
 	} else {
 		/*
@@ -987,8 +990,8 @@ audioattach(device_t parent, device_t se
 		audio_format2_t *fmt = has_playback ?  : 
 		error = audio_hw_probe(sc, fmt, mode);
 		if (error) {
-			aprint_error_dev(self, "audio_hw_probe failed, "
-			"error = %d\n", error);
+			aprint_error_dev(self,
+			"audio_hw_probe failed: errno=%d\n", error);
 			goto bad;
 		}
 		if (has_playback && has_capture)
@@ -999,8 +1002,8 @@ audioattach(device_t parent, device_t se
 	/* hw_probe() also validates [pr]hwfmt.  */
 	error = audio_hw_set_format(sc, mode, , , , );
 	if (error) {
-		aprint_error_dev(self, "audio_hw_set_format failed, "
-		"error = %d\n", error);
+		aprint_error_dev(self,
+		"audio_hw_set_format failed: errno=%d\n", error);
 		goto bad;
 	}
 
@@ -1010,8 +1013,8 @@ audioattach(device_t parent, device_t se
 	 */
 	error = audio_mixers_init(sc, mode, , , , );
 	if (sc->sc_pmixer == NULL && sc->sc_rmixer == NULL) {
-		aprint_error_dev(self, "audio_mixers_init failed, "
-		"error = %d\n", error);
+		aprint_error_dev(self,
+		"audio_mixers_init failed: errno=%d\n", error);
 		goto bad;
 	}
 
@@ -1429,6 +1432,22 @@ audio_attach_mi(const struct audio_hw_if
 }
 
 /*
+ * audio_printf() outputs fmt... with the audio device name and MD device
+ * name prefixed.  If the message is considered to be related to the MD
+ * driver, use this one instead of device_printf().
+ */
+static void
+audio_printf(struct audio_softc *sc, const char *fmt, ...)
+{
+	va_list ap;
+
+	printf("%s(%s): ", device_xname(sc->sc_dev), device_xname(sc->hw_dev));
+	va_start(ap, fmt);
+	vprintf(fmt, ap);
+	va_end(ap);
+}
+
+/*
  * Enter critical section and also keep sc_lock.
  * If successful, returns 0 with sc_lock held.  Otherwise returns errno.
  * Must be called without sc_lock held.
@@ -1574,7 +1593,7 @@ 

CVS commit: [netbsd-9] src/sys/arch/hppa/gsc

2021-02-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Feb 28 07:01:01 UTC 2021

Modified Files:
src/sys/arch/hppa/gsc [netbsd-9]: harmony.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #1216):
sys/arch/hppa/gsc/harmony.c: revision 1.8
sys/arch/hppa/gsc/harmony.c: revision 1.9
sys/arch/hppa/gsc/harmony.c: revision 1.10

Fix locking against myself.
trigger_output will be called with sc_intr_lock held.

>From source code review, not tested.

Fix my mistakes in rev1.6.
- I had to merge the channel bit and the speed bits.
  Reported by macallan@.
- I also fix my indent, while I'm here.

Simplify harmony_speed_bits().
It no longer needs to write back the speed value.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/arch/hppa/gsc/harmony.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/hppa/gsc/harmony.c
diff -u src/sys/arch/hppa/gsc/harmony.c:1.7 src/sys/arch/hppa/gsc/harmony.c:1.7.2.1
--- src/sys/arch/hppa/gsc/harmony.c:1.7	Sat Jun  8 08:02:37 2019
+++ src/sys/arch/hppa/gsc/harmony.c	Sun Feb 28 07:01:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: harmony.c,v 1.7 2019/06/08 08:02:37 isaki Exp $	*/
+/*	$NetBSD: harmony.c,v 1.7.2.1 2021/02/28 07:01:01 martin Exp $	*/
 
 /*	$OpenBSD: harmony.c,v 1.23 2004/02/13 21:28:19 mickey Exp $	*/
 
@@ -165,7 +165,7 @@ CFATTACH_DECL_NEW(harmony, sizeof(struct
 int harmony_intr(void *);
 void harmony_intr_enable(struct harmony_softc *);
 void harmony_intr_disable(struct harmony_softc *);
-uint32_t harmony_speed_bits(struct harmony_softc *, u_int *);
+uint32_t harmony_speed_bits(struct harmony_softc *, u_int);
 int harmony_set_gainctl(struct harmony_softc *);
 void harmony_reset_codec(struct harmony_softc *);
 void harmony_start_cp(struct harmony_softc *, int);
@@ -437,11 +437,10 @@ harmony_query_format(void *vsc, audio_fo
 int
 harmony_set_format(void *vsc, int setmode,
 const audio_params_t *play, const audio_params_t *rec,
-	audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
+audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
 	struct harmony_softc *sc;
 	uint32_t bits;
-	int rate;
 
 	sc = vsc;
 
@@ -464,10 +463,8 @@ harmony_set_format(void *vsc, int setmod
 		bits |= CNTL_OLB;
 
 	bits |= CNTL_CHANS_STEREO;
-
-	/* XXX modify harmony_speed_bits() not to rewrite rate */
-	rate = play->sample_rate;
-	sc->sc_cntlbits |= harmony_speed_bits(sc, );
+	bits |= harmony_speed_bits(sc, play->sample_rate);
+	sc->sc_cntlbits = bits;
 	sc->sc_need_commit = 1;
 
 	return 0;
@@ -1004,8 +1001,6 @@ harmony_trigger_output(void *vsc, void *
 		return EINVAL;
 	}
 
-	mutex_spin_enter(>sc_intr_lock);
-
 	c->c_intr = intr;
 	c->c_intrarg = intrarg;
 	c->c_blksz = blksize;
@@ -1020,8 +1015,6 @@ harmony_trigger_output(void *vsc, void *
 	harmony_start_cp(sc, 0);
 	harmony_intr_enable(sc);
 
-	mutex_spin_exit(>sc_intr_lock);
-
 	return 0;
 }
 
@@ -1164,39 +1157,17 @@ static const struct speed_struct {
 };
 
 uint32_t
-harmony_speed_bits(struct harmony_softc *sc, u_int *speedp)
+harmony_speed_bits(struct harmony_softc *sc, u_int speed)
 {
-	int i, n, selected;
-
-	selected = -1;
-	n = sizeof(harmony_speeds) / sizeof(harmony_speeds[0]);
+	int i;
 
-	if ((*speedp) <= harmony_speeds[0].speed)
-		selected = 0;
-	else if ((*speedp) >= harmony_speeds[n - 1].speed)
-		selected = n - 1;
-	else {
-		for (i = 1; selected == -1 && i < n; i++) {
-			if ((*speedp) == harmony_speeds[i].speed)
-selected = i;
-			else if ((*speedp) < harmony_speeds[i].speed) {
-int diff1, diff2;
-
-diff1 = (*speedp) - harmony_speeds[i - 1].speed;
-diff2 = harmony_speeds[i].speed - (*speedp);
-if (diff1 < diff2)
-	selected = i - 1;
-else
-	selected = i;
-			}
+	for (i = 0; i < __arraycount(harmony_speeds); i++) {
+		if (speed == harmony_speeds[i].speed) {
+			return harmony_speeds[i].bits;
 		}
 	}
-
-	if (selected == -1)
-		selected = 2;
-
-	*speedp = harmony_speeds[selected].speed;
-	return harmony_speeds[selected].bits;
+	/* If this happens, harmony_formats[] is wrong */
+	panic("speed %u not supported", speed);
 }
 
 int



CVS commit: [netbsd-9] src/sys/arch/m68k/m68k

2021-02-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 25 09:36:27 UTC 2021

Modified Files:
src/sys/arch/m68k/m68k [netbsd-9]: reenter_syscall.s

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1214):

sys/arch/m68k/m68k/reenter_syscall.s: revision 1.5
sys/arch/m68k/m68k/reenter_syscall.s: revision 1.6
sys/arch/m68k/m68k/reenter_syscall.s: revision 1.7

Replace magic numbers with proper macros prepared in assym.h.

No binary changes.

Note this is a preparation for a possible fix of PR port-m68k/55990.

Consistently use motorola style.  No binary changes.
Seems missed in rev 1.3:
 https://mail-index.netbsd.org/source-changes/2013/08/01/msg046378.html

Plug kernel stack leaks in reenter_syscall() for setcontext(2).
This fixes long standing kernel crashes (MMU fault, address error,
and silent freeze by a double bus fault etc. seen for ~10 years)
caused by kernel stack overflow, especially on x68k and sun3 running
Xorg based servers.  See PR/55990 for more details.

"This change seems perfectly reasonable" from thorpej@ and
jklos@ also reported this also solved freeze of his mac68k system
with 10 megabyes of memory.

Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.34.1 src/sys/arch/m68k/m68k/reenter_syscall.s

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

Modified files:

Index: src/sys/arch/m68k/m68k/reenter_syscall.s
diff -u src/sys/arch/m68k/m68k/reenter_syscall.s:1.4 src/sys/arch/m68k/m68k/reenter_syscall.s:1.4.34.1
--- src/sys/arch/m68k/m68k/reenter_syscall.s:1.4	Sat Sep  7 19:06:29 2013
+++ src/sys/arch/m68k/m68k/reenter_syscall.s	Thu Feb 25 09:36:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: reenter_syscall.s,v 1.4 2013/09/07 19:06:29 chs Exp $	*/
+/*	$NetBSD: reenter_syscall.s,v 1.4.34.1 2021/02/25 09:36:27 martin Exp $	*/
 
 /*
  * Written by ITOH Yasufumi.
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include "assym.h"
 
 /*
  * void reenter_syscall(struct frame *fp, int stkadj)
@@ -38,18 +39,31 @@ ENTRY_NOPROFILE(reenter_syscall)
 .Lcpfr:	movel	(%a0)+,(%a1)+
 	dbra	%d0,.Lcpfr
 
-	movew	%d1,%sp@(16*4+2)	| set stack adjust count
+	movew	%d1,FR_ADJ(%sp)		| set stack adjust count
 	movel	(%sp),-(%sp)		| push syscall no (original d0 value)
 	jbsr	_C_LABEL(syscall)	| re-enter syscall()
 	addql	#4,%sp			| pop syscall no
 #ifdef DEBUG
-	tstw	%sp@(16*4+2)		| stack adjust must be zero
+	tstw	FR_ADJ(%sp)		| stack adjust must be zero
 	jeq	.Ladjzero
 	PANIC("reenter_syscall")
 .Ladjzero:
 #endif
-	moveal	%sp@(15*4),%a0		| grab and restore
+	moveal	FR_SP(%sp),%a0		| grab and restore
 	movel	%a0,%usp		|   user SP
+	movw	FR_ADJ(%sp),%d0		| need to adjust stack?
+	jne	.Ladjstk		| yes, go to it
 	moveml	(%sp)+,#0x7FFF		| restore user registers
 	addql	#8,%sp			| pop SP and stack adjust
 	jra	_ASM_LABEL(rei)		| rte
+.Ladjstk:
+	lea	FR_HW(%sp),%a1		| pointer to HW frame
+	addql	#8,%a1			| source pointer
+	movl	%a1,%a0			| source
+	addw	%d0,%a0			|  + hole size = dest pointer
+	movl	-(%a1),-(%a0)		| copy
+	movl	-(%a1),-(%a0)		|  8 bytes
+	movl	%a0,FR_SP(%sp)		| new SSP
+	moveml	(%sp)+,#0x7FFF		| restore user register
+	movl	(%sp),%sp		| and do real RTE
+	jra	_ASM_LABEL(rei)		| rte



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

2021-02-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 24 08:05:08 UTC 2021

Modified Files:
src/sys/arch/xen/xen [netbsd-9]: xennetback_xenbus.c

Log Message:
Apply patch, requested by jdolecek in ticket 1213:

Do not panic Dom0 when hypervisor grant_table_op(GNTTABOP_copy) fails
in xennet(4) backend driver, that can be triggered by malicious or buggy
DomU via bad grant reference.

Part of fixes for XSA-362.


To generate a diff of this commit:
cvs rdiff -u -r1.75.4.1 -r1.75.4.2 src/sys/arch/xen/xen/xennetback_xenbus.c

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

Modified files:

Index: src/sys/arch/xen/xen/xennetback_xenbus.c
diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.75.4.1 src/sys/arch/xen/xen/xennetback_xenbus.c:1.75.4.2
--- src/sys/arch/xen/xen/xennetback_xenbus.c:1.75.4.1	Tue Feb 23 18:50:21 2021
+++ src/sys/arch/xen/xen/xennetback_xenbus.c	Wed Feb 24 08:05:08 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: xennetback_xenbus.c,v 1.75.4.1 2021/02/23 18:50:21 martin Exp $  */
+/*  $NetBSD: xennetback_xenbus.c,v 1.75.4.2 2021/02/24 08:05:08 martin Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.75.4.1 2021/02/23 18:50:21 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.75.4.2 2021/02/24 08:05:08 martin Exp $");
 
 #include "opt_xen.h"
 
@@ -1041,15 +1041,19 @@ xennetback_ifsoftstart_copy(void *arg)
 			bpf_mtap(ifp, m, BPF_D_OUT);
 		}
 		if (i != 0) {
-			if (HYPERVISOR_grant_table_op(GNTTABOP_copy,
-			xstart_gop_copy, i) != 0) {
-panic("%s: GNTTABOP_copy failed",
-ifp->if_xname);
+			int result;
+
+			result = HYPERVISOR_grant_table_op(GNTTABOP_copy,
+			xstart_gop_copy, i);
+			if (result != 0) {
+printf("%s: GNTTABOP_copy failed %d",
+ifp->if_xname, result);
 			}
 
 			for (j = 0; j < i; j++) {
-if (xstart_gop_copy[j].status != GNTST_okay) {
-	printf("%s GNTTABOP_copy[%d] %d\n",
+if (result < 0 || (result > 0 && j >= result)
+|| xstart_gop_copy[j].status != GNTST_okay){
+	printf("%s GNTTABOP_copy[%d] st %d\n",
 	ifp->if_xname,
 	j, xstart_gop_copy[j].status);
 	printf("%s: req_prod %u req_cons "



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

2021-02-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 23 18:50:21 UTC 2021

Modified Files:
src/sys/arch/xen/xen [netbsd-9]: xennetback_xenbus.c

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #1211):

sys/arch/xen/xen/xennetback_xenbus.c: revision 1.92 (via patch)

remove support for legacy rx-flip mode for xennet(4)/xvif(4), making
rx-copy (first shipped in NetBSD 6.0 in 2012) the only supported
mode

this is mostly to simplify maintenance and future development
rx-flip is not supported by Linux Dom0/DomU, and NetBSD Dom0/DomU
defaults to rx-copy for over 8 years now too, so there is little
need to keep the support for compatibility

besides compatibility there is no other reason to keep rx-flip -
page transfer is generally slower than copy due to necessary MMU/TLB
manipulation, especially on MP systems


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.75.4.1 src/sys/arch/xen/xen/xennetback_xenbus.c

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

Modified files:

Index: src/sys/arch/xen/xen/xennetback_xenbus.c
diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.75 src/sys/arch/xen/xen/xennetback_xenbus.c:1.75.4.1
--- src/sys/arch/xen/xen/xennetback_xenbus.c:1.75	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/xen/xen/xennetback_xenbus.c	Tue Feb 23 18:50:21 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: xennetback_xenbus.c,v 1.75 2019/03/09 08:42:25 maxv Exp $  */
+/*  $NetBSD: xennetback_xenbus.c,v 1.75.4.1 2021/02/23 18:50:21 martin Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.75 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.75.4.1 2021/02/23 18:50:21 martin Exp $");
 
 #include "opt_xen.h"
 
@@ -129,7 +129,6 @@ struct xnetback_instance {
void xvifattach(int);
 static int  xennetback_ifioctl(struct ifnet *, u_long, void *);
 static void xennetback_ifstart(struct ifnet *);
-static void xennetback_ifsoftstart_transfer(void *);
 static void xennetback_ifsoftstart_copy(void *);
 static void xennetback_ifwatchdog(struct ifnet *);
 static int  xennetback_ifinit(struct ifnet *);
@@ -160,35 +159,10 @@ static struct xenbus_backend_driver xvif
  */
 #define NB_XMIT_PAGES_BATCH 64
 
-/*
- * We will transfer a mapped page to the remote domain, and remap another
- * page in place immediately. For this we keep a list of pages available.
- * When the list is empty, we ask the hypervisor to give us
- * NB_XMIT_PAGES_BATCH pages back.
- */
-static unsigned long mcl_pages[NB_XMIT_PAGES_BATCH]; /* our physical pages */
-int mcl_pages_alloc; /* current index in mcl_pages */
-static int  xennetback_get_mcl_page(paddr_t *);
-static void xennetback_get_new_mcl_pages(void);
-
-/*
- * If we can't transfer the mbuf directly, we have to copy it to a page which
- * will be transferred to the remote domain. We use a pool_cache for this.
- */
-pool_cache_t xmit_pages_cache;
-
 /* arrays used in xennetback_ifstart(), too large to allocate on stack */
 /* XXXSMP */
-static mmu_update_t xstart_mmu[NB_XMIT_PAGES_BATCH];
-static multicall_entry_t xstart_mcl[NB_XMIT_PAGES_BATCH + 1];
-static gnttab_transfer_t xstart_gop_transfer[NB_XMIT_PAGES_BATCH];
 static gnttab_copy_t xstart_gop_copy[NB_XMIT_PAGES_BATCH];
 static struct mbuf *mbufs_sent[NB_XMIT_PAGES_BATCH];
-static struct _pages_pool_free {
-	vaddr_t va;
-	paddr_t pa;
-} pages_pool_free[NB_XMIT_PAGES_BATCH];
-
 
 static inline void
 xni_pkt_unmap(struct xni_pkt *pkt, vaddr_t pkt_va)
@@ -200,31 +174,11 @@ xni_pkt_unmap(struct xni_pkt *pkt, vaddr
 void
 xvifattach(int n)
 {
-	int i;
-	struct pglist mlist;
-	struct vm_page *pg;
-
 	XENPRINTF(("xennetback_init\n"));
 
-	/*
-	 * steal some non-managed pages to the VM system, to replace
-	 * mbuf cluster or xmit_pages_pool pages given to foreign domains.
-	 */
-	if (uvm_pglistalloc(PAGE_SIZE * NB_XMIT_PAGES_BATCH, 0, 0x,
-	0, 0, , NB_XMIT_PAGES_BATCH, 0) != 0)
-		panic("xennetback_init: uvm_pglistalloc");
-	for (i = 0, pg = mlist.tqh_first; pg != NULL;
-	pg = pg->pageq.queue.tqe_next, i++)
-		mcl_pages[i] = xpmap_ptom(VM_PAGE_TO_PHYS(pg)) >> PAGE_SHIFT;
-	if (i != NB_XMIT_PAGES_BATCH)
-		panic("xennetback_init: %d mcl pages", i);
-	mcl_pages_alloc = NB_XMIT_PAGES_BATCH - 1;
-
 	/* initialise pools */
 	pool_init(_pkt_pool, sizeof(struct xni_pkt), 0, 0, 0,
 	"xnbpkt", NULL, IPL_VM);
-	xmit_pages_cache = pool_cache_init(PAGE_SIZE, 0, 0, 0, "xnbxm", NULL,
-	IPL_VM, NULL, NULL, NULL);
 
 	SLIST_INIT(_instances);
 	mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE);
@@ -342,14 +296,6 @@ xennetback_xenbus_create(struct xenbus_d
 			xbusd->xbusd_path, err);
 			goto abort_xbt;
 		}
-		err = xenbus_printf(xbt, xbusd->xbusd_path,
-		"feature-rx-flip", "%d", 1);
-		if (err) {
-			aprint_error_ifnet(ifp,
-			"failed to write %s/feature-rx-flip: 

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

2021-02-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 23 11:02:12 UTC 2021

Modified Files:
src/sys/arch/xen/x86 [netbsd-9]: xen_shm_machdep.c

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #1210):

sys/arch/xen/x86/xen_shm_machdep.c: revision 1.17 (via patch)

in xen_shm_map(), make sure to unmap any successfully mapped pages
before returning failure if there is partial failure
fix detection of partial failure - GNTTABOP_map_grant_ref can actually re=
turn

zero for partial failure, so we need to always check all the entries
to detect it

previously, kernel triggered panic() for partial failure, leading to
Dom0 page fault later; since the mapping failure can be triggered by
malicious DomU via bad grant reference, it's important to expect
the calls to fail, and handle it gracefully without crashing Dom0

part of fixes for XSA-362


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.4.1 src/sys/arch/xen/x86/xen_shm_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/xen/x86/xen_shm_machdep.c
diff -u src/sys/arch/xen/x86/xen_shm_machdep.c:1.13 src/sys/arch/xen/x86/xen_shm_machdep.c:1.13.4.1
--- src/sys/arch/xen/x86/xen_shm_machdep.c:1.13	Sun Jan 27 02:08:39 2019
+++ src/sys/arch/xen/x86/xen_shm_machdep.c	Tue Feb 23 11:02:12 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: xen_shm_machdep.c,v 1.13 2019/01/27 02:08:39 pgoyette Exp $  */
+/*  $NetBSD: xen_shm_machdep.c,v 1.13.4.1 2021/02/23 11:02:12 martin Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_shm_machdep.c,v 1.13 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_shm_machdep.c,v 1.13.4.1 2021/02/23 11:02:12 martin Exp $");
 
 #include 
 #include 
@@ -123,6 +123,7 @@ xen_shm_map(int nentries, int domid, gra
 	vmem_addr_t new_va_pg;
 	vaddr_t new_va;
 	int ret, i, s;
+	int orig_nentries = nentries;
 
 #ifdef DIAGNOSTIC
 	if (nentries > XENSHM_MAX_PAGES_PER_REQUEST) {
@@ -172,16 +173,71 @@ xen_shm_map(int nentries, int domid, gra
 	}
 
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, op, nentries);
-	if (__predict_false(ret)) {
-		panic("xen_shm_map: HYPERVISOR_grant_table_op failed");
+	if (__predict_false(ret < 0)) {
+#ifdef DIAGNOSTIC
+		printf("%s: HYPERVISOR_grant_table_op failed %d\n", __func__,
+		ret);
+#endif
+		goto bad;
+	}
+
+	/*
+	 * If ret is positive, it means there was an error in processing,
+	 * and only first ret entries were actually handled. If it's zero,
+	 * it only means all entries were processed, but there could still
+	 * be failure.
+	 */
+	if (__predict_false(ret > 0 && ret < nentries)) {
+		nentries = ret;
 	}
 
 	for (i = 0; i < nentries; i++) {
-		if (__predict_false(op[i].status))
-			return op[i].status;
+		if (__predict_false(op[i].status)) {
+#ifdef DIAGNOSTIC
+			printf("%s: op[%d] bad status %d gref %u\n", __func__,
+			i, op[i].status, grefp[i]);
+#endif
+			ret = 1;
+			continue;
+		}
 		handlep[i] = op[i].handle;
 	}
 
+	if (__predict_false(ret > 0)) {
+		int uncnt = 0;
+		gnttab_unmap_grant_ref_t unop[XENSHM_MAX_PAGES_PER_REQUEST];
+
+		/*
+		 * When returning error, make sure the successfully mapped
+		 * entries are unmapped before returning the error.
+		 * xen_shm_unmap() can't be used, it assumes
+		 * linear consecutive space.
+		 */
+		for (i = uncnt = 0; i < nentries; i++) {
+			if (op[i].status == 0) {
+unop[uncnt].host_addr = new_va + i * PAGE_SIZE;
+unop[uncnt].dev_bus_addr = 0;
+unop[uncnt].handle = handlep[i];
+uncnt++;
+			}
+		}
+		if (uncnt > 0) {
+			ret = HYPERVISOR_grant_table_op(
+			GNTTABOP_unmap_grant_ref, unop, uncnt);
+			if (ret != 0) {
+panic("%s: unmap on error recovery failed"
+" %d", __func__, ret);
+			}
+		}
+#ifdef DIAGNOSTIC
+		printf("%s: HYPERVISOR_grant_table_op bad entry\n",
+		__func__);
+#endif
+bad:
+		vmem_free(xen_shm_arena, new_va_pg, orig_nentries);
+		return EINVAL;
+	}
+
 	*vap = new_va;
 	return 0;
 }



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

2021-02-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Feb 19 17:47:13 UTC 2021

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: intr.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #1209):

sys/arch/x86/x86/intr.c: revision 1.154 (via patch)

Fix x86's pci_intr_disestablish clean up routine.  Pointed out by t-kusaba@IIJ, 
thanks.

Fix panic on x86 by the following code.


sc_ih = pci_intr_establish_xname(sc_pc, ...);
pci_intr_disestablish(sc_pc, sc_ih);
sc_ih = pci_intr_establish(sc_pc, ...);


ena(4) do such processing when ifconfig down/up.

XXX pullup-8,9


To generate a diff of this commit:
cvs rdiff -u -r1.146.2.1 -r1.146.2.2 src/sys/arch/x86/x86/intr.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/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.146.2.1 src/sys/arch/x86/x86/intr.c:1.146.2.2
--- src/sys/arch/x86/x86/intr.c:1.146.2.1	Mon Nov 11 17:20:00 2019
+++ src/sys/arch/x86/x86/intr.c	Fri Feb 19 17:47:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.146.2.1 2019/11/11 17:20:00 martin Exp $	*/
+/*	$NetBSD: intr.c,v 1.146.2.2 2021/02/19 17:47:13 martin Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.146.2.1 2019/11/11 17:20:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.146.2.2 2021/02/19 17:47:13 martin Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -704,6 +704,9 @@ intr_source_free(struct cpu_info *ci, in
 	ci->ci_isources[slot] = NULL;
 	if (pic != _pic)
 		idt_vec_free(idtvec);
+
+	isp->is_recurse = NULL;
+	isp->is_resume = NULL;
 }
 
 #ifdef MULTIPROCESSOR
@@ -1042,12 +1045,12 @@ intr_disestablish_xcall(void *arg1, void
 	else
 		(*pic->pic_hwunmask)(pic, ih->ih_pin);
 
-	/* Re-enable interrupts. */
-	x86_write_psl(psl);
-
 	/* If the source is free we can drop it now. */
 	intr_source_free(ci, ih->ih_slot, pic, idtvec);
 
+	/* Re-enable interrupts. */
+	x86_write_psl(psl);
+
 	DPRINTF(("%s: remove slot %d (pic %s pin %d vec %d)\n",
 	device_xname(ci->ci_dev), ih->ih_slot, pic->pic_name,
 	ih->ih_pin, idtvec));



CVS commit: [netbsd-9] src/sys/dev/raidframe

2021-02-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 17 09:34:20 UTC 2021

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_reconstruct.c

Log Message:
Pull up following revision(s) (requested by oster in ticket #1206):

sys/dev/raidframe/rf_reconstruct.c: revision 1.125

Fix a long long-standing off-by-one error in computing lastPSID.

SUsPerPU is only really supported for a value of 1, and since the
first PSID is 0, the last will be numStripe-1.  Also update the
setting of pending_writes to reflect the change to lastPSID.

Needs pullups to -8 and -9.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.122.4.1 src/sys/dev/raidframe/rf_reconstruct.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/raidframe/rf_reconstruct.c
diff -u src/sys/dev/raidframe/rf_reconstruct.c:1.122 src/sys/dev/raidframe/rf_reconstruct.c:1.122.4.1
--- src/sys/dev/raidframe/rf_reconstruct.c:1.122	Sat Feb  9 03:34:00 2019
+++ src/sys/dev/raidframe/rf_reconstruct.c	Wed Feb 17 09:34:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_reconstruct.c,v 1.122 2019/02/09 03:34:00 christos Exp $	*/
+/*	$NetBSD: rf_reconstruct.c,v 1.122.4.1 2021/02/17 09:34:20 martin Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  /
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.122 2019/02/09 03:34:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.122.4.1 2021/02/17 09:34:20 martin Exp $");
 
 #include 
 #include 
@@ -616,7 +616,7 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 	mapPtr = raidPtr->reconControl->reconMap;
 
 	incPSID = RF_RECONMAP_SIZE;
-	lastPSID = raidPtr->Layout.numStripe / raidPtr->Layout.SUsPerPU;
+	lastPSID = raidPtr->Layout.numStripe / raidPtr->Layout.SUsPerPU - 1;
 	RUsPerPU = raidPtr->Layout.SUsPerPU / raidPtr->Layout.SUsPerRU;
 	recon_error = 0;
 	write_error = 0;
@@ -631,7 +631,7 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 		raidPtr->reconControl->lastPSID = lastPSID;
 
 	if (pending_writes > lastPSID)
-		pending_writes = lastPSID;
+		pending_writes = lastPSID + 1;
 
 	/* start the actual reconstruction */
 
@@ -796,7 +796,6 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 			pending_writes = lastPSID - prev;
 			raidPtr->reconControl->lastPSID = lastPSID;
 		}
-		
 		/* back down curPSID to get ready for the next round... */
 		for (i = 0; i < raidPtr->numCol; i++) {
 			if (i != col) {



CVS commit: [netbsd-9] src/sys/arch/x68k/x68k

2021-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 11 13:02:05 UTC 2021

Modified Files:
src/sys/arch/x68k/x68k [netbsd-9]: machdep.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1205):

sys/arch/x68k/x68k/machdep.c: revision 1.204

Restore fixes for PR/51663 lost in r1.195 (uvm_hotplug(9) merge).

The kernel crashdump and savecore(8) on NetBSD/x68k have been broken
(even without EXTNEDED_MEMORY) since NetBSD 8.0. Oops.

Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.200.4.1 src/sys/arch/x68k/x68k/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/x68k/x68k/machdep.c
diff -u src/sys/arch/x68k/x68k/machdep.c:1.200 src/sys/arch/x68k/x68k/machdep.c:1.200.4.1
--- src/sys/arch/x68k/x68k/machdep.c:1.200	Thu Apr  4 04:31:01 2019
+++ src/sys/arch/x68k/x68k/machdep.c	Thu Feb 11 13:02:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.200 2019/04/04 04:31:01 isaki Exp $	*/
+/*	$NetBSD: machdep.c,v 1.200.4.1 2021/02/11 13:02:04 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.200 2019/04/04 04:31:01 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.200.4.1 2021/02/11 13:02:04 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -568,7 +568,10 @@ cpu_init_kcore_hdr(void)
 {
 	cpu_kcore_hdr_t *h = _kcore_hdr;
 	struct m68k_kcore_hdr *m = >un._m68k;
-	uvm_physseg_t i;
+	psize_t size;
+#ifdef EXTENDED_MEMORY
+	int i, seg;
+#endif
 
 	memset(_kcore_hdr, 0, sizeof(cpu_kcore_hdr));
 
@@ -617,25 +620,20 @@ cpu_init_kcore_hdr(void)
 	/*
 	 * X68k has multiple RAM segments on some models.
 	 */
-	m->ram_segs[0].start = lowram;
-	m->ram_segs[0].size = mem_size - lowram;
-
-	i = uvm_physseg_get_first();
-	
-for (uvm_physseg_get_next(i); uvm_physseg_valid_p(i); i = uvm_physseg_get_next(i)) {
-		if (uvm_physseg_valid_p(i) == false)
-			break;
-
-		const paddr_t startpfn = uvm_physseg_get_start(i);
-		const paddr_t endpfn = uvm_physseg_get_end(i);
-
-		KASSERT(startpfn != -1 && endpfn != -1);
-
-		m->ram_segs[i].start = 
-		ctob(startpfn);
-		m->ram_segs[i].size  =			
-		ctob(endpfn - startpfn);
+	size = phys_basemem_seg.end - phys_basemem_seg.start;
+	m->ram_segs[0].start = phys_basemem_seg.start;
+	m->ram_segs[0].size  = size;
+#ifdef EXTENDED_MEMORY
+	seg = 1;
+	for (i = 0; i < EXTMEM_SEGS; i++) {
+		size = phys_extmem_seg[i].end - phys_extmem_seg[i].start;
+		if (size == 0)
+			continue;
+		m->ram_segs[seg].start = phys_extmem_seg[i].start;
+		m->ram_segs[seg].size  = size;
+		seg++;
 	}
+#endif
 }
 
 /*



CVS commit: [netbsd-9] src/sys/fs/msdosfs

2021-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 11 12:58:29 UTC 2021

Modified Files:
src/sys/fs/msdosfs [netbsd-9]: msdosfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by ryoon in ticket #1204):

sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.136

Enable to mount Raspberry Pi Pico's USB mass storage partition
Fix PR kern/55985.

O.k. by thorpej@.
Pull-up to netbsd-8 and netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.130.4.1 src/sys/fs/msdosfs/msdosfs_vfsops.c

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

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.130 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.130.4.1
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.130	Mon Sep  3 16:29:34 2018
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Thu Feb 11 12:58:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.130 2018/09/03 16:29:34 riastradh Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.130.4.1 2021/02/11 12:58:29 martin Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.130 2018/09/03 16:29:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.130.4.1 2021/02/11 12:58:29 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -518,6 +518,13 @@ msdosfs_mountfs(struct vnode *devvp, str
 	b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB;
 	b710 = (struct byte_bpb710 *)bsp->bs710.bsBPB;
 
+#if 0
+	/*
+	 * Some FAT partition, for example Raspberry Pi Pico's
+	 * USB mass storage, does not have exptected BOOTSIGs.
+	 * According to FreeBSD's comment, some PC-9800/9821
+	 * FAT floppy disks have similar problems.
+	 */
 	if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
 		if (bsp->bs50.bsBootSectSig0 != BOOTSIG0
 		|| bsp->bs50.bsBootSectSig1 != BOOTSIG1) {
@@ -528,6 +535,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 			goto error_exit;
 		}
 	}
+#endif
 
 	pmp = malloc(sizeof(*pmp), M_MSDOSFSMNT, M_WAITOK|M_ZERO);
 	pmp->pm_mountp = mp;



CVS commit: [netbsd-9] src/sys/dev/scsipi

2021-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 11 12:53:28 UTC 2021

Modified Files:
src/sys/dev/scsipi [netbsd-9]: cd.c sd.c

Log Message:
Pull up following revision(s) (requested by ryoon in ticket #1203):

sys/dev/scsipi/cd.c: revision 1.350
sys/dev/scsipi/sd.c: revision 1.331

PR 55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()


To generate a diff of this commit:
cvs rdiff -u -r1.342.4.1 -r1.342.4.2 src/sys/dev/scsipi/cd.c
cvs rdiff -u -r1.327.4.1 -r1.327.4.2 src/sys/dev/scsipi/sd.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/scsipi/cd.c
diff -u src/sys/dev/scsipi/cd.c:1.342.4.1 src/sys/dev/scsipi/cd.c:1.342.4.2
--- src/sys/dev/scsipi/cd.c:1.342.4.1	Thu Apr  2 19:15:35 2020
+++ src/sys/dev/scsipi/cd.c	Thu Feb 11 12:53:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.342.4.1 2020/04/02 19:15:35 martin Exp $	*/
+/*	$NetBSD: cd.c,v 1.342.4.2 2021/02/11 12:53:28 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.342.4.1 2020/04/02 19:15:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.342.4.2 2021/02/11 12:53:28 martin Exp $");
 
 #include 
 #include 
@@ -1378,7 +1378,7 @@ cdioctl(dev_t dev, u_long cmd, void *add
 		XS_CTL_IGNORE_NOT_READY | XS_CTL_IGNORE_MEDIA_CHANGE));
 	case DIOCEJECT:
 		if (*(int *)addr == 0) {
-			int pmask = 1 << part;
+			int pmask = __BIT(part);
 			/*
 			 * Don't force eject: check that we are the only
 			 * partition open. If so, unlock it.

Index: src/sys/dev/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.327.4.1 src/sys/dev/scsipi/sd.c:1.327.4.2
--- src/sys/dev/scsipi/sd.c:1.327.4.1	Sat Mar 21 15:52:09 2020
+++ src/sys/dev/scsipi/sd.c	Thu Feb 11 12:53:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.327.4.1 2020/03/21 15:52:09 martin Exp $	*/
+/*	$NetBSD: sd.c,v 1.327.4.2 2021/02/11 12:53:28 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.327.4.1 2020/03/21 15:52:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.327.4.2 2021/02/11 12:53:28 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -954,11 +954,12 @@ sdioctl(dev_t dev, u_long cmd, void *add
 		if ((periph->periph_flags & PERIPH_REMOVABLE) == 0)
 			return (ENOTTY);
 		if (*(int *)addr == 0) {
+			int pmask = __BIT(part);
 			/*
 			 * Don't force eject: check that we are the only
 			 * partition open. If so, unlock it.
 			 */
-			if (DK_BUSY(dksc, part) == 0) {
+			if (DK_BUSY(dksc, pmask) == 0) {
 error = scsipi_prevent(periph, SPAMR_ALLOW,
 XS_CTL_IGNORE_NOT_READY);
 if (error)



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

2021-02-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Feb  7 16:42:41 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: kern_event.c

Log Message:
Apply additional patch, requested by jdolecek in ticket #1191:

sys/kern/kern_event.c   1.110-1.115 (via patch)

Fix merge botch for the EV_ONESHOT branch.


To generate a diff of this commit:
cvs rdiff -u -r1.104.4.1 -r1.104.4.2 src/sys/kern/kern_event.c

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

Modified files:

Index: src/sys/kern/kern_event.c
diff -u src/sys/kern/kern_event.c:1.104.4.1 src/sys/kern/kern_event.c:1.104.4.2
--- src/sys/kern/kern_event.c:1.104.4.1	Thu Feb  4 16:57:25 2021
+++ src/sys/kern/kern_event.c	Sun Feb  7 16:42:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_event.c,v 1.104.4.1 2021/02/04 16:57:25 martin Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.104.4.2 2021/02/07 16:42:41 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.104.4.1 2021/02/04 16:57:25 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.104.4.2 2021/02/07 16:42:41 martin Exp $");
 
 #include 
 #include 
@@ -1399,9 +1399,11 @@ relock:
 		/* XXXAD should be got from f_event if !oneshot. */
 		*kevp++ = kn->kn_kevent;
 		nkev++;
+		influx = 1;
 		if (kn->kn_flags & EV_ONESHOT) {
 			/* delete ONESHOT events after retrieval */
 			kn->kn_status &= ~KN_BUSY;
+			kq->kq_count--;
 			mutex_spin_exit(>kq_lock);
 			knote_detach(kn, fdp, true);
 			mutex_enter(>fd_lock);



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

2021-02-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb  4 19:24:01 UTC 2021

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

Log Message:
regen (for ticket #1197)


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

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

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.760.4.6 src/sys/dev/usb/usbdevs.h:1.760.4.7
--- src/sys/dev/usb/usbdevs.h:1.760.4.6	Wed Apr 29 13:54:48 2020
+++ src/sys/dev/usb/usbdevs.h	Thu Feb  4 19:23:59 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.760.4.6 2020/04/29 13:54:48 martin Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.760.4.7 2021/02/04 19:23:59 martin Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.770.4.6 2020/04/29 13:53:51 martin Exp
+ *	NetBSD: usbdevs,v 1.770.4.7 2021/02/04 19:23:10 martin Exp
  */
 
 /*-
@@ -3391,7 +3391,9 @@
 
 /* TP-Link products */
 #define	USB_PRODUCT_TPLINK_RTL8192CU	0x0100		/* RTL8192CU */
-#define	USB_PRODUCT_TPLINK_RTL8192EU	0x0109		/* RTL8192EU */
+#define	USB_PRODUCT_TPLINK_WN821NV5	0x0107		/* TL-WN821N v5 */
+#define	USB_PRODUCT_TPLINK_WN822NV4	0x0108		/* TL-WN822N v4 */
+#define	USB_PRODUCT_TPLINK_WN823NV2	0x0109		/* TL-WN823N v2 */
 #define	USB_PRODUCT_TPLINK_RTL8188EU	0x010c		/* RTL8188EU */
 
 /* Trek Technology products */
Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.760.4.6 src/sys/dev/usb/usbdevs_data.h:1.760.4.7
--- src/sys/dev/usb/usbdevs_data.h:1.760.4.6	Wed Apr 29 13:54:48 2020
+++ src/sys/dev/usb/usbdevs_data.h	Thu Feb  4 19:23:59 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.760.4.6 2020/04/29 13:54:48 martin Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.760.4.7 2021/02/04 19:23:59 martin Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.770.4.6 2020/04/29 13:53:51 martin Exp
+ *	NetBSD: usbdevs,v 1.770.4.7 2021/02/04 19:23:10 martin Exp
  */
 
 /*-
@@ -4644,64 +4644,68 @@ static const uint16_t usb_products[] = {
 	8669, 6484, 5028, 5798, 0,
 	USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8192CU, 
 	5207, 0,
-	USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8192EU, 
-	17050, 0,
+	USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_WN821NV5, 
+	19515, 19525, 0,
+	USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_WN822NV4, 
+	19528, 18404, 0,
+	USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_WN823NV2, 
+	19538, 7496, 0,
 	USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8188EU, 
 	5217, 0,
 	USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE, 
-	19515, 0,
+	19548, 0,
 	USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE_8MB, 
-	19515, 19526, 0,
+	19548, 19559, 0,
 	USB_VENDOR_TRENDNET, USB_PRODUCT_TRENDNET_RTL8192CU, 
 	5207, 0,
 	USB_VENDOR_TRENDNET, USB_PRODUCT_TRENDNET_RTL8188CU, 
 	5227, 0,
 	USB_VENDOR_TRIPPLITE, USB_PRODUCT_TRIPPLITE_U209, 
-	19530, 6908, 4932, 0,
+	19563, 6908, 4932, 0,
 	USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_UPS, 
 	3179, 3185, 480, 0,
 	USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_SMARTLCD, 
-	19535, 480, 0,
+	19568, 480, 0,
 	USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_AVR550U, 
-	3179, 3185, 19544, 0,
+	3179, 3185, 19577, 0,
 	USB_VENDOR_TRUMPION, USB_PRODUCT_TRUMPION_T33521, 
-	19552, 19560, 0,
+	19585, 19593, 0,
 	USB_VENDOR_TRUMPION, USB_PRODUCT_TRUMPION_XXX1100, 
-	15921, 19568, 0,
+	15921, 19601, 0,
 	USB_VENDOR_TSUNAMI, USB_PRODUCT_TSUNAMI_SM2000, 
-	19573, 0,
+	19606, 0,
 	USB_VENDOR_TWINMOS, USB_PRODUCT_TWINMOS_G240, 
-	19581, 0,
+	19614, 0,
 	USB_VENDOR_ULTIMA, USB_PRODUCT_ULTIMA_1200UBPLUS, 
 	11239, 14841, 11129, 7209, 0,
 	USB_VENDOR_ULTIMA, USB_PRODUCT_ULTIMA_T14BR, 
-	19586, 19592, 6818, 0,
+	19619, 19625, 6818, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1236U, 
-	19598, 5714, 19604, 0,
+	19631, 5714, 19637, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1220U, 
-	19598, 19612, 19604, 0,
+	19631, 19645, 19637, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2000U, 
-	19598, 19618, 19604, 0,
+	19631, 19651, 19637, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA3400, 
-	19598, 19624, 19604, 0,
+	19631, 19657, 19637, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2100U, 
-	19598, 19629, 19604, 0,
+	19631, 19662, 19637, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2200U, 
-	19598, 19635, 19604, 0,
+	19631, 19668, 19637, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UB_A, 
-	19641, 0,
+	19674, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UB, 
-	19653, 0,
+	19686, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UBC1, 
-	   

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

2021-02-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb  4 19:23:10 UTC 2021

Modified Files:
src/sys/dev/usb [netbsd-9]: if_urtwn.c usbdevs

Log Message:
Pull up following revision(s) (requested by nia in ticket #1197):

sys/dev/usb/if_urtwn.c: revision 1.89,1.90
sys/dev/usb/usbdevs: revision 1.788,1.789

urtwn(4): add TPLINK WN821N to the list of USB device ids
reported by kfmut on the unitedbsd forums.

add another TPLINK RTL8192EU variant
to avoid confusion use TP-Link's names for these variants, matching
FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.71.2.3 -r1.71.2.4 src/sys/dev/usb/if_urtwn.c
cvs rdiff -u -r1.770.4.6 -r1.770.4.7 src/sys/dev/usb/usbdevs

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

Modified files:

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.71.2.3 src/sys/dev/usb/if_urtwn.c:1.71.2.4
--- src/sys/dev/usb/if_urtwn.c:1.71.2.3	Fri Apr 24 17:28:21 2020
+++ src/sys/dev/usb/if_urtwn.c	Thu Feb  4 19:23:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.71.2.3 2020/04/24 17:28:21 martin Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.71.2.4 2021/02/04 19:23:10 martin Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.71.2.3 2020/04/24 17:28:21 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.71.2.4 2021/02/04 19:23:10 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -199,7 +199,9 @@ static const struct urtwn_dev {
 	/* URTWN_RTL8192EU */
 	URTWN_RTL8192EU_DEV(DLINK,	DWA131E),
 	URTWN_RTL8192EU_DEV(REALTEK,	RTL8192EU),
-	URTWN_RTL8192EU_DEV(TPLINK,	RTL8192EU),
+	URTWN_RTL8192EU_DEV(TPLINK,	WN821NV5),
+	URTWN_RTL8192EU_DEV(TPLINK,	WN822NV4),
+	URTWN_RTL8192EU_DEV(TPLINK,	WN823NV2),
 };
 #undef URTWN_DEV
 #undef URTWN_RTL8188E_DEV

Index: src/sys/dev/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.770.4.6 src/sys/dev/usb/usbdevs:1.770.4.7
--- src/sys/dev/usb/usbdevs:1.770.4.6	Wed Apr 29 13:53:51 2020
+++ src/sys/dev/usb/usbdevs	Thu Feb  4 19:23:10 2021
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.770.4.6 2020/04/29 13:53:51 martin Exp $
+$NetBSD: usbdevs,v 1.770.4.7 2021/02/04 19:23:10 martin Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -3384,7 +3384,9 @@ product TOSHIBA HSDPA_MODEM_EU870DT1	0x1
 
 /* TP-Link products */
 product TPLINK RTL8192CU	0x0100	RTL8192CU
-product TPLINK RTL8192EU	0x0109	RTL8192EU
+product	TPLINK WN821NV5		0x0107	TL-WN821N v5
+product	TPLINK WN822NV4		0x0108	TL-WN822N v4
+product	TPLINK WN823NV2		0x0109	TL-WN823N v2
 product TPLINK RTL8188EU	0x010c	RTL8188EU
 
 /* Trek Technology products */



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

2021-02-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb  4 19:16:02 UTC 2021

Modified Files:
src/sys/dev/usb [netbsd-9]: uhid.c uhidev.c uhidev.h

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

sys/dev/usb/uhid.c: revision 1.115
sys/dev/usb/uhidev.h: revision 1.21
sys/dev/usb/uhidev.c: revision 1.79
(all via patch)

usb: Overhaul uhid(4) and uhidev(4) locking.

- uhidev API rules:
  1. Call uhidev_open when you want exclusive use of a report id.
 After it succeeds, you will get interrupts.
  2. Call uhidev_close when done with exclusive use of a report id.
 After it returns, you will no longer get interrupts.
 => uhidev_open/close do not nest.
  3. uhidev_write no longer requires the caller to have exclusive
 access -- if there is a write in progress, it will block
 interruptibly until done.  This way drivers for individual
 report ids need not work separately to coordinate their writes.
  4. You must uhidev_stop to abort any pending writes on the same
 report id.  (uhidev_stop no longer does anything else -- to
 ensure no more interrupts, just use uhidev_close.)
- Fix uhidev_open/close locking -- uhidev now has an interruptible
  config lock held only on first open and last close by any report id
  in the device, to serialize the transition between zero and nonzero
  numbers of references which requires opening/closing pipes and
  allocating/freeing buffers.
- Make /dev/uhidN selnotify(POLLHUP) when the device is yanked.
- Factor uhid device lookup and reference counting and dying
  detection and so on into uhid_enter/exit.
- Nix struct uhid_softc::sc_access_lock.  This served no purpose but
  to confuse me when trying to understand the logic of this beast
  (and to ensure uhidev_write exclusion, but it was uninterruptible,
  which is wrong for something that implements userland operations,
  and didn't actually work because uhidev_write did nothing to
  coordinate between different report ids).
- Fix locking in select/poll.
- Use atomics to manage UHID_IMMED to keep it simple.  (sc_lock would
  be fine too but it makes the code more verbose.)
- Omit needless UHID_ASLP -- cv_broadcast already has this
  micro-optimization.

With these changes, my Pinebook survives

for i in `jot 100`; do
echo '###' $i
for j in `jot 16`; do
usbhidctl -rf /dev/uhid$j >/dev/null &
done
wait
done

while plugging and unplugging uhid(4) devices (U2F keys), and the U2F
keys still work as U2F keys.

ok nick, mrg

XXX pullup-9
XXX pullup-8?

Note on ABI and pullups: This changes the layout of struct
uhidev_softc, but with the sole exception of ucycom(4) -- which at
the moment is completely broken and unusable -- the only members that
USB HID drivers use are sc_udev and sc_iface, which haven't changed.
The layout of struct uhidev, which is allocated by each USB HID
driver in its own softc structure, is unchanged.


To generate a diff of this commit:
cvs rdiff -u -r1.108.2.2 -r1.108.2.3 src/sys/dev/usb/uhid.c
cvs rdiff -u -r1.75 -r1.75.2.1 src/sys/dev/usb/uhidev.c
cvs rdiff -u -r1.20 -r1.20.4.1 src/sys/dev/usb/uhidev.h

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

Modified files:

Index: src/sys/dev/usb/uhid.c
diff -u src/sys/dev/usb/uhid.c:1.108.2.2 src/sys/dev/usb/uhid.c:1.108.2.3
--- src/sys/dev/usb/uhid.c:1.108.2.2	Wed Jul 15 14:09:04 2020
+++ src/sys/dev/usb/uhid.c	Thu Feb  4 19:16:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhid.c,v 1.108.2.2 2020/07/15 14:09:04 martin Exp $	*/
+/*	$NetBSD: uhid.c,v 1.108.2.3 2021/02/04 19:16:01 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.108.2.2 2020/07/15 14:09:04 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.108.2.3 2021/02/04 19:16:01 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -43,21 +43,24 @@ __KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.1
 #endif
 
 #include 
-#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
+#include 
 #include 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
-#include 
 
 #include 
 #include 
@@ -84,8 +87,7 @@ int	uhiddebug = 0;
 struct uhid_softc {
 	struct uhidev sc_hdev;
 
-	kmutex_t sc_access_lock; /* serialises syscall accesses */
-	kmutex_t sc_lock;	/* protects refcnt, others */
+	kmutex_t sc_lock;
 	kcondvar_t sc_cv;
 	kcondvar_t sc_detach_cv;
 
@@ -99,12 +101,12 @@ struct uhid_softc {
 	struct selinfo sc_rsel;
 	proc_t *sc_async;	/* process that wants SIGIO */
 	void *sc_sih;
-	u_char sc_state;	/* driver state */
-#define	UHID_ASLP	0x01	/* waiting for device data */
+	volatile uint32_t sc_state;	/* driver state */
 

CVS commit: [netbsd-9] src/sys/miscfs/procfs

2021-02-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb  4 17:20:45 UTC 2021

Modified Files:
src/sys/miscfs/procfs [netbsd-9]: procfs_vfsops.c

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

sys/miscfs/procfs/procfs_vfsops.c: revision 1.110

Fix procfs environ node.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.101.4.1 src/sys/miscfs/procfs/procfs_vfsops.c

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

Modified files:

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.101 src/sys/miscfs/procfs/procfs_vfsops.c:1.101.4.1
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.101	Sat Mar 30 23:28:30 2019
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Thu Feb  4 17:20:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.101 2019/03/30 23:28:30 christos Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.101.4.1 2021/02/04 17:20:45 martin Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.101 2019/03/30 23:28:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.101.4.1 2021/02/04 17:20:45 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -388,6 +388,7 @@ procfs_loadvnode(struct mount *mp, struc
 	case PFSmap:		/* /proc/N/map = -r */
 	case PFSmaps:		/* /proc/N/maps = -r */
 	case PFSauxv:		/* /proc/N/auxv = -r */
+	case PFSenviron:	/* /proc/N/environ = -r */
 		pfs->pfs_mode = S_IRUSR;
 		vp->v_type = VREG;
 		break;
@@ -395,7 +396,6 @@ procfs_loadvnode(struct mount *mp, struc
 	case PFSstatus:		/* /proc/N/status = -r--r--r-- */
 	case PFSstat:		/* /proc/N/stat = -r--r--r-- */
 	case PFScmdline:	/* /proc/N/cmdline = -r--r--r-- */
-	case PFSenviron:	/* /proc/N/environ = -r--r--r-- */
 	case PFSemul:		/* /proc/N/emul = -r--r--r-- */
 	case PFSmeminfo:	/* /proc/meminfo = -r--r--r-- */
 	case PFScpustat:	/* /proc/stat = -r--r--r-- */



CVS commit: [netbsd-9] src/sys/dev/hyperv

2021-02-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb  4 17:04:14 UTC 2021

Modified Files:
src/sys/dev/hyperv [netbsd-9]: hvkbd.c if_hvn.c vmbus.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #1192):

sys/dev/hyperv/if_hvn.c: revision 1.20 (via patch)
sys/dev/hyperv/hvkbd.c: revision 1.7 (via patch)
sys/dev/hyperv/vmbus.c: revision 1.12 (via patch)

hvkbd(4): Don't wait forever.
vmbus(4): Don't wait forever.
hvn(4): Don't wait forever.


To generate a diff of this commit:
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/dev/hyperv/hvkbd.c
cvs rdiff -u -r1.4.2.6 -r1.4.2.7 src/sys/dev/hyperv/if_hvn.c
cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/sys/dev/hyperv/vmbus.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/hyperv/hvkbd.c
diff -u src/sys/dev/hyperv/hvkbd.c:1.2.2.2 src/sys/dev/hyperv/hvkbd.c:1.2.2.3
--- src/sys/dev/hyperv/hvkbd.c:1.2.2.2	Sun Nov 24 08:13:07 2019
+++ src/sys/dev/hyperv/hvkbd.c	Thu Feb  4 17:04:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hvkbd.c,v 1.2.2.2 2019/11/24 08:13:07 martin Exp $	*/
+/*	$NetBSD: hvkbd.c,v 1.2.2.3 2021/02/04 17:04:14 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017 Microsoft Corp.
@@ -36,7 +36,7 @@
 #endif /* _KERNEL_OPT */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.2.2.2 2019/11/24 08:13:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.2.2.3 2021/02/04 17:04:14 martin Exp $");
 
 #include 
 #include 
@@ -365,7 +365,8 @@ hvkbd_connect(struct hvkbd_softc *sc)
 			hvkbd_intr(sc);
 			splx(s);
 		} else
-			tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", mstohz(1));
+			tsleep(sc, PRIBIO | PCATCH, "hvkbdcon",
+			uimax(1, mstohz(1)));
 	} while (--timo > 0 && sc->sc_connected == 0);
 
 	if (timo == 0 && sc->sc_connected == 0) {

Index: src/sys/dev/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.4.2.6 src/sys/dev/hyperv/if_hvn.c:1.4.2.7
--- src/sys/dev/hyperv/if_hvn.c:1.4.2.6	Fri Dec 11 15:43:16 2020
+++ src/sys/dev/hyperv/if_hvn.c	Thu Feb  4 17:04:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.4.2.6 2020/12/11 15:43:16 martin Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.4.2.7 2021/02/04 17:04:14 martin Exp $	*/
 /*	$OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.4.2.6 2020/12/11 15:43:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.4.2.7 2021/02/04 17:04:14 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1054,7 +1054,8 @@ hvn_nvs_cmd(struct hvn_softc *sc, void *
 			if (cold)
 delay(1000);
 			else
-tsleep(cmd, PRIBIO, "nvsout", mstohz(1));
+tsleep(cmd, PRIBIO, "nvsout",
+uimax(1, mstohz(1)));
 		} else if (rv) {
 			DPRINTF("%s: NVSP operation %u send error %d\n",
 			device_xname(sc->sc_dev), hdr->nvs_type, rv);
@@ -1079,7 +1080,7 @@ hvn_nvs_cmd(struct hvn_softc *sc, void *
 			splx(s);
 		} else
 			tsleep(sc->sc_nvsrsp, PRIBIO | PCATCH, "nvscmd",
-			mstohz(1));
+			uimax(1, mstohz(1)));
 	} while (--timo > 0 && sc->sc_nvsdone != 1);
 
 	if (timo == 0 && sc->sc_nvsdone != 1) {
@@ -1377,7 +1378,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru
 			if (cold)
 delay(1000);
 			else
-tsleep(rc, PRIBIO, "rndisout", mstohz(1));
+tsleep(rc, PRIBIO, "rndisout",
+uimax(1, mstohz(1)));
 		} else if (rv) {
 			DPRINTF("%s: RNDIS operation %u send error %d\n",
 			device_xname(sc->sc_dev), hdr->rm_type, rv);
@@ -1402,7 +1404,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru
 			hvn_nvs_intr(sc);
 			splx(s);
 		} else
-			tsleep(rc, PRIBIO | PCATCH, "rndiscmd", mstohz(1));
+			tsleep(rc, PRIBIO | PCATCH, "rndiscmd",
+			uimax(1, mstohz(1)));
 	} while (--timo > 0 && rc->rc_done != 1);
 
 	bus_dmamap_sync(sc->sc_dmat, rc->rc_dmap, 0, PAGE_SIZE,

Index: src/sys/dev/hyperv/vmbus.c
diff -u src/sys/dev/hyperv/vmbus.c:1.4.2.1 src/sys/dev/hyperv/vmbus.c:1.4.2.2
--- src/sys/dev/hyperv/vmbus.c:1.4.2.1	Sun Nov 24 08:13:07 2019
+++ src/sys/dev/hyperv/vmbus.c	Thu Feb  4 17:04:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbus.c,v 1.4.2.1 2019/11/24 08:13:07 martin Exp $	*/
+/*	$NetBSD: vmbus.c,v 1.4.2.2 2021/02/04 17:04:14 martin Exp $	*/
 /*	$OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.4.2.1 2019/11/24 08:13:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.4.2.2 2021/02/04 17:04:14 martin Exp $");
 
 #include 
 #include 
@@ -604,7 +604,8 @@ vmbus_start(struct vmbus_softc *sc, stru
 			hyperv_intr();
 			splx(s);
 		} else
-			tsleep(wchan, PRIBIO, wchan, mstohz(delays[i]));
+			tsleep(wchan, PRIBIO, wchan,
+			uimax(1, mstohz(delays[i] / 1000)));
 	}
 	if (status != HYPERCALL_STATUS_SUCCESS) {
 		device_printf(sc->sc_dev,
@@ -667,7 +668,7 @@ vmbus_wait(struct vmbus_softc *sc,
 			splx(s);
 		} else
 			tsleep(wchan, PRIBIO, wmsg ? wmsg : 

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

2021-02-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb  4 16:57:25 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: kern_event.c

Log Message:
Pullup the following (requested by jdolecek in ticket #1191):

sys/kern/kern_event.c   r1.110-1.115 (via patch)

fix a race in kqueue_scan() - when multiple threads check the same
kqueue, it could happen other thread seen empty kqueue while kevent
was being checked for re-firing and re-queued

make sure to keep retrying if there are outstanding kevents even
if no kevent is found on first pass through the queue, and only
kq_count when actually completely done with the kevent

PR kern/50094 by Christof Meerwal

Also fixes timer latency in Go, as reported in
https://github.com/golang/go/issues/42515 by Michael Pratt


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.104.4.1 src/sys/kern/kern_event.c

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

Modified files:

Index: src/sys/kern/kern_event.c
diff -u src/sys/kern/kern_event.c:1.104 src/sys/kern/kern_event.c:1.104.4.1
--- src/sys/kern/kern_event.c:1.104	Tue Nov 13 06:58:14 2018
+++ src/sys/kern/kern_event.c	Thu Feb  4 16:57:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_event.c,v 1.104 2018/11/13 06:58:14 maxv Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.104.4.1 2021/02/04 16:57:25 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.104 2018/11/13 06:58:14 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.104.4.1 2021/02/04 16:57:25 martin Exp $");
 
 #include 
 #include 
@@ -166,6 +166,8 @@ static int	kq_calloutmax = (4 * 1024);
 
 extern const struct filterops sig_filtops;
 
+#define KQ_FLUX_WAKEUP(kq)	cv_broadcast(>kq_cv)
+
 /*
  * Table for for all system-defined filters.
  * These should be listed in the numeric order of the EVFILT_* defines.
@@ -1226,7 +1228,10 @@ kqueue_check(const char *func, size_t li
 			}
 			count++;
 			if (count > kq->kq_count) {
-goto bad;
+panic("%s,%zu: kq=%p kq->kq_count(%d) != "
+"count(%d), nmarker=%d",
+				func, line, kq, kq->kq_count, count,
+nmarker);
 			}
 		} else {
 			nmarker++;
@@ -1240,11 +1245,6 @@ kqueue_check(const char *func, size_t li
 #endif
 		}
 	}
-	if (kq->kq_count != count) {
-bad:
-		panic("%s,%zu: kq=%p kq->kq_count(%d) != count(%d), nmarker=%d",
-		func, line, kq, kq->kq_count, count, nmarker);
-	}
 }
 #define kq_check(a) kqueue_check(__func__, __LINE__, (a))
 #else /* defined(DEBUG) */
@@ -1268,7 +1268,7 @@ kqueue_scan(file_t *fp, size_t maxevents
 	struct timespec	ats, sleepts;
 	struct knote	*kn, *marker, morker;
 	size_t		count, nkev, nevents;
-	int		timeout, error, rv;
+	int		timeout, error, rv, influx;
 	filedesc_t	*fdp;
 
 	fdp = curlwp->l_fd;
@@ -1317,119 +1317,140 @@ kqueue_scan(file_t *fp, size_t maxevents
 			}
 		}
 		mutex_spin_exit(>kq_lock);
-	} else {
-		/* mark end of knote list */
-		TAILQ_INSERT_TAIL(>kq_head, marker, kn_tqe);
+		goto done;
+	}
 
-		/*
-		 * Acquire the fdp->fd_lock interlock to avoid races with
-		 * file creation/destruction from other threads.
-		 */
-		mutex_spin_exit(>kq_lock);
-		mutex_enter(>fd_lock);
-		mutex_spin_enter(>kq_lock);
+	/* mark end of knote list */
+	TAILQ_INSERT_TAIL(>kq_head, marker, kn_tqe);
+	influx = 0;
 
-		while (count != 0) {
-			kn = TAILQ_FIRST(>kq_head);	/* get next knote */
-			while ((kn->kn_status & KN_MARKER) != 0) {
-if (kn == marker) {
-	/* it's our marker, stop */
-	TAILQ_REMOVE(>kq_head, kn, kn_tqe);
-	if (count < maxevents || (tsp != NULL &&
-	(timeout = gettimeleft(,
-	)) <= 0))
-		goto done;
-	mutex_exit(>fd_lock);
-	goto retry;
-}
-/* someone else's marker. */
-kn = TAILQ_NEXT(kn, kn_tqe);
+	/*
+	 * Acquire the fdp->fd_lock interlock to avoid races with
+	 * file creation/destruction from other threads.
+	 */
+relock:
+	mutex_spin_exit(>kq_lock);
+	mutex_enter(>fd_lock);
+	mutex_spin_enter(>kq_lock);
+
+	while (count != 0) {
+		kn = TAILQ_FIRST(>kq_head);	/* get next knote */
+
+		if ((kn->kn_status & KN_MARKER) != 0 && kn != marker) {
+			if (influx) {
+influx = 0;
+KQ_FLUX_WAKEUP(kq);
 			}
-			kq_check(kq);
+			mutex_exit(>fd_lock);
+			(void)cv_wait(>kq_cv, >kq_lock);
+			goto relock;
+		}
+
+		TAILQ_REMOVE(>kq_head, kn, kn_tqe);
+		if (kn == marker) {
+			/* it's our marker, stop */
+			KQ_FLUX_WAKEUP(kq);
+			if (count == maxevents) {
+mutex_exit(>fd_lock);
+goto retry;
+			}
+			break;
+		}
+		KASSERT((kn->kn_status & KN_BUSY) == 0);
+
+		kq_check(kq);
+		kn->kn_status &= ~KN_QUEUED;
+		kn->kn_status |= KN_BUSY;
+		kq_check(kq);
+		if (kn->kn_status & KN_DISABLED) {
+			kn->kn_status &= ~KN_BUSY;
 			kq->kq_count--;
-			TAILQ_REMOVE(>kq_head, kn, kn_tqe);
-			kn->kn_status &= ~KN_QUEUED;
-			kn->kn_status |= KN_BUSY;
-			kq_check(kq);
-			if 

CVS commit: [netbsd-9] src/sys/arch/arm/broadcom

2021-01-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 25 14:14:23 UTC 2021

Modified Files:
src/sys/arch/arm/broadcom [netbsd-9]: bcm2835_vcaudio.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1188):

sys/arch/arm/broadcom/bcm2835_vcaudio.c: revision 1.16

vcaudio: don't advertise CAPTURE when all functions return EINVAL


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.2.1 src/sys/arch/arm/broadcom/bcm2835_vcaudio.c

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

Modified files:

Index: src/sys/arch/arm/broadcom/bcm2835_vcaudio.c
diff -u src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.14 src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.14.2.1
--- src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.14	Wed May  8 13:40:14 2019
+++ src/sys/arch/arm/broadcom/bcm2835_vcaudio.c	Mon Jan 25 14:14:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_vcaudio.c,v 1.14 2019/05/08 13:40:14 isaki Exp $ */
+/* $NetBSD: bcm2835_vcaudio.c,v 1.14.2.1 2021/01/25 14:14:23 martin Exp $ */
 
 /*-
  * Copyright (c) 2013 Jared D. McNeill 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_vcaudio.c,v 1.14 2019/05/08 13:40:14 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_vcaudio.c,v 1.14.2.1 2021/01/25 14:14:23 martin Exp $");
 
 #include 
 #include 
@@ -159,7 +159,6 @@ static int	vcaudio_set_format(void *, in
 const audio_params_t *, const audio_params_t *,
 audio_filter_reg_t *, audio_filter_reg_t *);
 static int	vcaudio_halt_output(void *);
-static int	vcaudio_halt_input(void *);
 static int	vcaudio_set_port(void *, mixer_ctrl_t *);
 static int	vcaudio_get_port(void *, mixer_ctrl_t *);
 static int	vcaudio_query_devinfo(void *, mixer_devinfo_t *);
@@ -171,8 +170,6 @@ static int	vcaudio_round_blocksize(void 
 
 static int	vcaudio_trigger_output(void *, void *, void *, int,
 void (*)(void *), void *, const audio_params_t *);
-static int	vcaudio_trigger_input(void *, void *, void *, int,
-void (*)(void *), void *, const audio_params_t *);
 
 static void	vcaudio_get_locks(void *, kmutex_t **, kmutex_t **);
 
@@ -182,7 +179,6 @@ static const struct audio_hw_if vcaudio_
 	.query_format = vcaudio_query_format,
 	.set_format = vcaudio_set_format,
 	.halt_output = vcaudio_halt_output,
-	.halt_input = vcaudio_halt_input,
 	.getdev = vcaudio_getdev,
 	.set_port = vcaudio_set_port,
 	.get_port = vcaudio_get_port,
@@ -190,7 +186,6 @@ static const struct audio_hw_if vcaudio_
 	.get_props = vcaudio_get_props,
 	.round_blocksize = vcaudio_round_blocksize,
 	.trigger_output = vcaudio_trigger_output,
-	.trigger_input = vcaudio_trigger_input,
 	.get_locks = vcaudio_get_locks,
 };
 
@@ -615,12 +610,6 @@ vcaudio_halt_output(void *priv)
 }
 
 static int
-vcaudio_halt_input(void *priv)
-{
-	return EINVAL;
-}
-
-static int
 vcaudio_set_volume(struct vcaudio_softc *sc, enum vcaudio_dest dest,
 int hwvol)
 {
@@ -805,7 +794,7 @@ vcaudio_getdev(void *priv, struct audio_
 static int
 vcaudio_get_props(void *priv)
 {
-	return AUDIO_PROP_PLAYBACK|AUDIO_PROP_CAPTURE|AUDIO_PROP_INDEPENDENT;
+	return AUDIO_PROP_PLAYBACK;
 }
 
 static int
@@ -840,13 +829,6 @@ vcaudio_trigger_output(void *priv, void 
 	return 0;
 }
 
-static int
-vcaudio_trigger_input(void *priv, void *start, void *end, int blksize,
-void (*intr)(void *), void *intrarg, const audio_params_t *params)
-{
-	return EINVAL;
-}
-
 static void
 vcaudio_get_locks(void *priv, kmutex_t **intr, kmutex_t **thread)
 {



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

2021-01-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 25 14:12:50 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: kern_threadpool.c

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

sys/kern/kern_threadpool.c: revision 1.23

threadpool(9): Fix synchronization between cancel and dispatch.
- threadpool_cancel_job_async tried to prevent
  threadpool_dispatcher_thread from taking the job by setting
  job->job_thread = NULL and then removing the job from the queue.
- But threadpool_cancel_job_async didn't notice job->job_thread is
  null until after it also removes the job from the queue =>
  double-remove, *boom*.

The solution is to teach threadpool_dispatcher_thread to wait until
it has acquired the job lock to test whether job->job_thread is still
valid before it decides to remove the job from the queue.

Fixes PR kern/55948.

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.6.1 src/sys/kern/kern_threadpool.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_threadpool.c
diff -u src/sys/kern/kern_threadpool.c:1.15 src/sys/kern/kern_threadpool.c:1.15.6.1
--- src/sys/kern/kern_threadpool.c:1.15	Thu Jan 17 10:18:52 2019
+++ src/sys/kern/kern_threadpool.c	Mon Jan 25 14:12:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_threadpool.c,v 1.15 2019/01/17 10:18:52 hannken Exp $	*/
+/*	$NetBSD: kern_threadpool.c,v 1.15.6.1 2021/01/25 14:12:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 2014, 2018 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_threadpool.c,v 1.15 2019/01/17 10:18:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_threadpool.c,v 1.15.6.1 2021/01/25 14:12:50 martin Exp $");
 
 #include 
 #include 
@@ -947,7 +947,7 @@ threadpool_overseer_thread(void *arg)
 
 		/* There are idle threads, so try giving one a job.  */
 		struct threadpool_job *const job = TAILQ_FIRST(>tp_jobs);
-		TAILQ_REMOVE(>tp_jobs, job, job_entry);
+
 		/*
 		 * Take an extra reference on the job temporarily so that
 		 * it won't disappear on us while we have both locks dropped.
@@ -959,6 +959,7 @@ threadpool_overseer_thread(void *arg)
 		/* If the job was cancelled, we'll no longer be its thread.  */
 		if (__predict_true(job->job_thread == overseer)) {
 			mutex_spin_enter(>tp_lock);
+			TAILQ_REMOVE(>tp_jobs, job, job_entry);
 			if (__predict_false(
 TAILQ_EMPTY(>tp_idle_threads))) {
 /*



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

2021-01-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jan 23 13:01:10 UTC 2021

Modified Files:
src/sys/dev/pci [netbsd-9]: if_ena.c

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

sys/dev/pci/if_ena.c: revision 1.27

PR kern/55942: destroyed ena(4) evcnts cause panic

Fix event counter teardown code. From KUSABA Takeshi


To generate a diff of this commit:
cvs rdiff -u -r1.15.2.3 -r1.15.2.4 src/sys/dev/pci/if_ena.c

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

Modified files:

Index: src/sys/dev/pci/if_ena.c
diff -u src/sys/dev/pci/if_ena.c:1.15.2.3 src/sys/dev/pci/if_ena.c:1.15.2.4
--- src/sys/dev/pci/if_ena.c:1.15.2.3	Wed Aug  5 14:59:41 2020
+++ src/sys/dev/pci/if_ena.c	Sat Jan 23 13:01:10 2021
@@ -36,7 +36,7 @@
 #if 0
 __FBSDID("$FreeBSD: head/sys/dev/ena/ena.c 333456 2018-05-10 09:37:54Z mw $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.15.2.3 2020/08/05 14:59:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.15.2.4 2021/01/23 13:01:10 martin Exp $");
 
 #include 
 #include 
@@ -470,18 +470,20 @@ ena_alloc_counters_hwstats(struct ena_hw
 	+ sizeof(st->rx_drops) == sizeof(*st));
 }
 static inline void
-ena_free_counters(struct evcnt *begin, int size)
+ena_free_counters(struct evcnt *begin, int size, int offset)
 {
 	struct evcnt *end = (struct evcnt *)((char *)begin + size);
+	begin = (struct evcnt *)((char *)begin + offset);
 
 	for (; begin < end; ++begin)
 		counter_u64_free(*begin);
 }
 
 static inline void
-ena_reset_counters(struct evcnt *begin, int size)
+ena_reset_counters(struct evcnt *begin, int size, int offset)
 {
 	struct evcnt *end = (struct evcnt *)((char *)begin + size);
+	begin = (struct evcnt *)((char *)begin + offset);
 
 	for (; begin < end; ++begin)
 		counter_u64_zero(*begin);
@@ -566,9 +568,9 @@ ena_free_io_ring_resources(struct ena_ad
 	struct ena_ring *rxr = >rx_ring[qid];
 
 	ena_free_counters((struct evcnt *)>tx_stats,
-	sizeof(txr->tx_stats));
+	sizeof(txr->tx_stats), offsetof(struct ena_stats_tx, cnt));
 	ena_free_counters((struct evcnt *)>rx_stats,
-	sizeof(rxr->rx_stats));
+	sizeof(rxr->rx_stats), offsetof(struct ena_stats_rx, cnt));
 
 	ENA_RING_MTX_LOCK(txr);
 	drbr_free(txr->br, M_DEVBUF);
@@ -670,7 +672,8 @@ ena_setup_tx_resources(struct ena_adapte
 
 	/* Reset TX statistics. */
 	ena_reset_counters((struct evcnt *)_ring->tx_stats,
-	sizeof(tx_ring->tx_stats));
+	sizeof(tx_ring->tx_stats),
+	offsetof(struct ena_stats_tx, cnt));
 
 	tx_ring->next_to_use = 0;
 	tx_ring->next_to_clean = 0;
@@ -867,7 +870,8 @@ ena_setup_rx_resources(struct ena_adapte
 
 	/* Reset RX statistics. */
 	ena_reset_counters((struct evcnt *)_ring->rx_stats,
-	sizeof(rx_ring->rx_stats));
+	sizeof(rx_ring->rx_stats),
+	offsetof(struct ena_stats_rx, cnt));
 
 	rx_ring->next_to_clean = 0;
 	rx_ring->next_to_use = 0;
@@ -2210,7 +2214,8 @@ ena_up_complete(struct ena_adapter *adap
 
 	ena_refill_all_rx_bufs(adapter);
 	ena_reset_counters((struct evcnt *)>hw_stats,
-	sizeof(adapter->hw_stats));
+	sizeof(adapter->hw_stats),
+	offsetof(struct ena_hw_stats, rx_packets));
 
 	return (0);
 }
@@ -3905,9 +3910,11 @@ ena_detach(device_t pdev, int flags)
 	ena_free_all_io_rings_resources(adapter);
 
 	ena_free_counters((struct evcnt *)>hw_stats,
-	sizeof(struct ena_hw_stats));
+	sizeof(struct ena_hw_stats),
+	offsetof(struct ena_hw_stats, rx_packets));
 	ena_free_counters((struct evcnt *)>dev_stats,
-	sizeof(struct ena_stats_dev));
+	sizeof(struct ena_stats_dev),
+offsetof(struct ena_stats_dev, wd_expired));
 
 	if (likely(adapter->rss_support))
 		ena_com_rss_destroy(ena_dev);



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

2021-01-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jan  3 12:51:33 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: init_main.c

Log Message:
Apply patch, requested by khorben in ticket #1177 (issue solved differently
in -current):

sys/kern/init_main.c(apply patch)

PR kern/55906: create the aiodone workqueue before running mountroothooks.


To generate a diff of this commit:
cvs rdiff -u -r1.504.2.1 -r1.504.2.2 src/sys/kern/init_main.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/init_main.c
diff -u src/sys/kern/init_main.c:1.504.2.1 src/sys/kern/init_main.c:1.504.2.2
--- src/sys/kern/init_main.c:1.504.2.1	Sat Nov 14 15:36:11 2020
+++ src/sys/kern/init_main.c	Sun Jan  3 12:51:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.504.2.1 2020/11/14 15:36:11 martin Exp $	*/
+/*	$NetBSD: init_main.c,v 1.504.2.2 2021/01/03 12:51:33 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.504.2.1 2020/11/14 15:36:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.504.2.2 2021/01/03 12:51:33 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -668,6 +668,11 @@ main(void)
 	cpu_rootconf();
 	cpu_dumpconf();
 
+	/* Create the aiodone daemon kernel thread. */
+	if (workqueue_create(_queue, "aiodoned",
+	uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE))
+		panic("fork aiodoned");
+
 	/* Mount the root file system. */
 	do {
 		domountroothook(root_device);
@@ -736,11 +741,6 @@ main(void)
 	NULL, NULL, "ioflush"))
 		panic("fork syncer");
 
-	/* Create the aiodone daemon kernel thread. */
-	if (workqueue_create(_queue, "aiodoned",
-	uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE))
-		panic("fork aiodoned");
-
 	/* Wait for final configure threads to complete. */
 	config_finalize_mountroot();
 



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

2021-01-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jan  2 10:23:46 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: core_elf32.c

Log Message:
Additionally pull up following revision(s) (requested by rin in ticket #1173):

sys/kern/core_elf32.c: revision 1.67

Use  instead of ,
which is not intended for standalone use.

Compile tested for all ports with their own COMPAT_NETBSD32 codes:
aarch64, amd64, arm, mips64, sparc64, and algor64.

Should fix build failure for mips64 in netbsd-9, where netbsd32.h is not
included by other header files.


To generate a diff of this commit:
cvs rdiff -u -r1.58.4.1 -r1.58.4.2 src/sys/kern/core_elf32.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/core_elf32.c
diff -u src/sys/kern/core_elf32.c:1.58.4.1 src/sys/kern/core_elf32.c:1.58.4.2
--- src/sys/kern/core_elf32.c:1.58.4.1	Fri Jan  1 13:04:08 2021
+++ src/sys/kern/core_elf32.c	Sat Jan  2 10:23:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: core_elf32.c,v 1.58.4.1 2021/01/01 13:04:08 martin Exp $	*/
+/*	$NetBSD: core_elf32.c,v 1.58.4.2 2021/01/02 10:23:46 martin Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.58.4.1 2021/01/01 13:04:08 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.58.4.2 2021/01/02 10:23:46 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_coredump.h"
@@ -68,7 +68,7 @@ __KERNEL_RCSID(1, "$NetBSD: core_elf32.c
 #ifdef COREDUMP
 
 #ifdef COMPAT_NETBSD32
-#include 
+#include 
 #endif
 
 struct writesegs_state {



CVS commit: [netbsd-9] src/sys/ufs/ufs

2021-01-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan  1 13:17:08 UTC 2021

Modified Files:
src/sys/ufs/ufs [netbsd-9]: ufs_quota1.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1176):

sys/ufs/ufs/ufs_quota1.c: revision 1.23

Avoid potentially accessing an array with an index out of range.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.22.1 src/sys/ufs/ufs/ufs_quota1.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.22 src/sys/ufs/ufs/ufs_quota1.c:1.22.22.1
--- src/sys/ufs/ufs/ufs_quota1.c:1.22	Mon Jun 20 00:52:04 2016
+++ src/sys/ufs/ufs/ufs_quota1.c	Fri Jan  1 13:17:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $	*/
+/*	$NetBSD: ufs_quota1.c,v 1.22.22.1 2021/01/01 13:17:08 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22.22.1 2021/01/01 13:17:08 martin Exp $");
 
 #include 
 #include 
@@ -311,6 +311,9 @@ quota1_handle_cmd_quotaon(struct lwp *l,
 	struct pathbuf *pb;
 	struct nameidata nd;
 
+	if (type < 0 || type >= MAXQUOTAS)
+		return EINVAL;
+
 	if (ump->um_flags & UFS_QUOTA2) {
 		uprintf("%s: quotas v2 already enabled\n",
 		mp->mnt_stat.f_mntonname);
@@ -421,6 +424,9 @@ quota1_handle_cmd_quotaoff(struct lwp *l
 	kauth_cred_t cred;
 	int i, error;
 
+	if (type < 0 || type >= MAXQUOTAS)
+		return EINVAL;
+
 	mutex_enter();
 	while ((ump->umq1_qflags[type] & (QTF_CLOSING | QTF_OPENING)) != 0)
 		cv_wait(, );



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

2021-01-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan  1 13:14:29 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: trap.c

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

sys/arch/aarch64/aarch64/trap.c: revision 1.28,1.31,1.32 (patch)

- add support conditionally execution for A32 instruction emulation
- separated the processing of ARM and THUMB emul clearly. do not confuse the 
Thumb-32bit instruction with the ARM instruction.
- use far_el1 instead of tf_pc to return correct fault address when instruction 
emulation


To generate a diff of this commit:
cvs rdiff -u -r1.17.4.4 -r1.17.4.5 src/sys/arch/aarch64/aarch64/trap.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/trap.c
diff -u src/sys/arch/aarch64/aarch64/trap.c:1.17.4.4 src/sys/arch/aarch64/aarch64/trap.c:1.17.4.5
--- src/sys/arch/aarch64/aarch64/trap.c:1.17.4.4	Fri Jan  1 12:58:35 2021
+++ src/sys/arch/aarch64/aarch64/trap.c	Fri Jan  1 13:14:29 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.17.4.4 2021/01/01 12:58:35 martin Exp $ */
+/* $NetBSD: trap.c,v 1.17.4.5 2021/01/01 13:14:29 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.17.4.4 2021/01/01 12:58:35 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.17.4.5 2021/01/01 13:14:29 martin Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -88,6 +88,12 @@ dtrace_trap_func_t		dtrace_trap_func = N
 int (*dtrace_invop_jump_addr)(struct trapframe *);
 #endif
 
+enum emul_arm_result {
+	EMUL_ARM_SUCCESS = 0,
+	EMUL_ARM_UNKNOWN,
+	EMUL_ARM_FAULT,
+};
+
 const char * const trap_names[] = {
 	[ESR_EC_UNKNOWN]	= "Unknown Reason (Illegal Instruction)",
 	[ESR_EC_SERROR]		= "SError Interrupt",
@@ -356,15 +362,15 @@ interrupt(struct trapframe *tf)
 #define THUMB_32BIT(hi) (((hi) & 0xe000) == 0xe000 && ((hi) & 0x1800))
 
 static int
-fetch_arm_insn(struct trapframe *tf, uint32_t *insn)
+fetch_arm_insn(uint64_t pc, uint64_t spsr, uint32_t *insn)
 {
 
 	/* THUMB? */
-	if (tf->tf_spsr & SPSR_A32_T) {
-		uint16_t *pc = (uint16_t *)(tf->tf_pc & ~1UL); /* XXX */
+	if (spsr & SPSR_A32_T) {
+		uint16_t *p = (uint16_t *)(pc & ~1UL); /* XXX */
 		uint16_t hi, lo;
 
-		if (ufetch_16(pc, ))
+		if (ufetch_16(p, ))
 			return -1;
 
 		if (!THUMB_32BIT(hi)) {
@@ -374,93 +380,139 @@ fetch_arm_insn(struct trapframe *tf, uin
 		}
 
 		/* 32-bit Thumb instruction */
-		if (ufetch_16(pc + 1, ))
+		if (ufetch_16(p + 1, ))
 			return -1;
 
 		*insn = ((uint32_t)hi << 16) | lo;
 		return 4;
 	}
 
-	if (ufetch_32((uint32_t *)tf->tf_pc, insn))
+	if (ufetch_32((uint32_t *)pc, insn))
 		return -1;
 
 	return 4;
 }
 
-enum emul_arm_result {
-	EMUL_ARM_SUCCESS = 0,
-	EMUL_ARM_UNKNOWN,
-	EMUL_ARM_FAULT,
-};
+static bool
+arm_cond_match(uint32_t insn, uint64_t spsr)
+{
+	bool invert = (insn >> 28) & 1;
+	bool match;
+
+	switch (insn >> 29) {
+	case 0:	/* EQ or NE */
+		match = spsr & SPSR_Z;
+		break;
+	case 1:	/* CS/HI or CC/LO */
+		match = spsr & SPSR_C;
+		break;
+	case 2:	/* MI or PL */
+		match = spsr & SPSR_N;
+		break;
+	case 3:	/* VS or VC */
+		match = spsr & SPSR_V;
+		break;
+	case 4:	/* HI or LS */
+		match = ((spsr & (SPSR_C | SPSR_Z)) == SPSR_C);
+		break;
+	case 5:	/* GE or LT */
+		match = (!(spsr & SPSR_N) == !(spsr & SPSR_V));
+		break;
+	case 6:	/* GT or LE */
+		match = !(spsr & SPSR_Z) &&
+		(!(spsr & SPSR_N) == !(spsr & SPSR_V));
+		break;
+	case 7:	/* AL */
+		match = true;
+		break;
+	}
+	return (!match != !invert);
+}
+
+static enum emul_arm_result
+emul_thumb_insn(struct trapframe *tf, uint32_t insn, int insn_size)
+{
+	/* T32-16bit or 32bit instructions */
+	switch (insn_size) {
+	case 2:
+		/* Breakpoint used by GDB */
+		if (insn == 0xdefe) {
+			do_trapsignal(curlwp, SIGTRAP, TRAP_BRKPT,
+			(void *)tf->tf_pc, 0);
+			return EMUL_ARM_SUCCESS;
+		}
+		/* XXX: some T32 IT instruction deprecated should be emulated */
+		break;
+	case 4:
+		break;
+	default:
+		return EMUL_ARM_FAULT;
+	}
+	return EMUL_ARM_UNKNOWN;
+}
 
 static enum emul_arm_result
 emul_arm_insn(struct trapframe *tf)
 {
-	struct lwp * const l = curlwp;
 	uint32_t insn;
 	int insn_size;
 
-	insn_size = fetch_arm_insn(tf, );
+	insn_size = fetch_arm_insn(tf->tf_pc, tf->tf_spsr, );
+	tf->tf_far = reg_far_el1_read();
 
-	switch (insn_size) {
-	case 2:
-		/* T32-16bit instruction */
-
-		/*
-		 * Breakpoint used by GDB.
-		 */
-		if (insn == 0xdefe)
-			goto trap;
+	if (tf->tf_spsr & SPSR_A32_T)
+		return emul_thumb_insn(tf, insn, insn_size);
+	if (insn_size != 4)
+		return EMUL_ARM_FAULT;
 
-		/* XXX: some T32 IT instruction deprecated should be emulated */
-		break;
-	case 4:
-		/* T32-32bit instruction, or A32 instruction */
+	/* Breakpoint used by GDB */
+	if (insn == 0xe611 || insn == 0xe7ffdefe) {
+		

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

2021-01-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan  1 13:06:39 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: vm_machdep.c

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

sys/arch/aarch64/aarch64/vm_machdep.c: revision 1.9 (patch)

Fix clone(2) for COMPAT_NETBSD32.
(1) Set r13 (sp for arm32 processes) appropriately when stack is
 specified to fork1().
(2) For arm32 processes, align stack to 8-byte boundary, instead of
 16-byte for native aarch64 processes, to match our 32-bit ABI:
https://nxr.netbsd.org/xref/src/sys/arch/arm/arm32/vm_machdep.c#150

Note that sp alignment checking is disabled in aarch32 mode, and
this works fine with AARCH64_EL0_STACK_ALIGNMENT_CHECK option.

OK ryo


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.4.1 src/sys/arch/aarch64/aarch64/vm_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/aarch64/aarch64/vm_machdep.c
diff -u src/sys/arch/aarch64/aarch64/vm_machdep.c:1.5 src/sys/arch/aarch64/aarch64/vm_machdep.c:1.5.4.1
--- src/sys/arch/aarch64/aarch64/vm_machdep.c:1.5	Thu Dec 27 09:55:27 2018
+++ src/sys/arch/aarch64/aarch64/vm_machdep.c	Fri Jan  1 13:06:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.5 2018/12/27 09:55:27 mrg Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.5.4.1 2021/01/01 13:06:39 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -29,8 +29,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_compat_netbsd32.h"
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.5 2018/12/27 09:55:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.5.4.1 2021/01/01 13:06:39 martin Exp $");
 
 #include 
 #include 
@@ -116,11 +118,19 @@ cpu_lwp_fork(struct lwp *l1, struct lwp 
 	*utf = *l1->l_md.md_utf;
 
 	/*
-	 * If specified, give the child a different stack
-	 * (make sure it's 16-byte aligned).
+	 * If specified, give the child a different stack (make sure it's
+	 * 16- or 8-byte aligned for 64- or 32-bit processes, respectively).
 	 */
-	if (stack != NULL)
-		utf->tf_sp = ((vaddr_t)(stack) + stacksize) & -16;
+	if (stack != NULL) {
+		utf->tf_sp = (vaddr_t)(stack) + stacksize;
+#ifdef COMPAT_NETBSD32
+		if (__predict_false(l2->l_proc->p_flag & PK_32)) {
+			utf->tf_sp &= -8;
+			utf->tf_reg[13] = utf->tf_sp;
+		} else
+#endif
+			utf->tf_sp &= -16;
+	}
 
 	/* build a new switchframe */
 	struct trapframe * const ktf = utf - 1;



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

2021-01-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan  1 13:04:08 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: core_elf32.c

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

sys/kern/core_elf32.c: revision 1.65 (patch)

Use correct note types for register storage in 32-bit core files for
architecture on which 64- and 32-bit ABIs use different values for
PT_GET{,FP}REGS, i.e., aarch64{,eb}.

Now, 32-bit GDB works fine for core files generated by aarch64{,eb}
kernel.

Should be no functional changes for ports other than aarch64{,eb}.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.58.4.1 src/sys/kern/core_elf32.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/core_elf32.c
diff -u src/sys/kern/core_elf32.c:1.58 src/sys/kern/core_elf32.c:1.58.4.1
--- src/sys/kern/core_elf32.c:1.58	Tue Jan 22 03:44:44 2019
+++ src/sys/kern/core_elf32.c	Fri Jan  1 13:04:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: core_elf32.c,v 1.58 2019/01/22 03:44:44 kamil Exp $	*/
+/*	$NetBSD: core_elf32.c,v 1.58.4.1 2021/01/01 13:04:08 martin Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.58 2019/01/22 03:44:44 kamil Exp $");
+__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.58.4.1 2021/01/01 13:04:08 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_coredump.h"
@@ -67,6 +67,10 @@ __KERNEL_RCSID(1, "$NetBSD: core_elf32.c
 
 #ifdef COREDUMP
 
+#ifdef COMPAT_NETBSD32
+#include 
+#endif
+
 struct writesegs_state {
 	Elf_Phdr *psections;
 	proc_t   *p;
@@ -489,8 +493,13 @@ ELFNAMEEND(coredump_note)(struct lwp *l,
 	if (error)
 		return (error);
 
-	ELFNAMEEND(coredump_savenote)(ns, PT_GETREGS, name, ,
-	sizeof(intreg));
+	ELFNAMEEND(coredump_savenote)(ns,
+#if ELFSIZE == 32 && defined(PT32_GETREGS)
+	PT32_GETREGS,
+#else
+	PT_GETREGS,
+#endif
+	name, , sizeof(intreg));
 
 #ifdef PT_GETFPREGS
 	freglen = sizeof(freg);
@@ -498,7 +507,13 @@ ELFNAMEEND(coredump_note)(struct lwp *l,
 	if (error)
 		return (error);
 
-	ELFNAMEEND(coredump_savenote)(ns, PT_GETFPREGS, name, , freglen);
+	ELFNAMEEND(coredump_savenote)(ns,
+#  if ELFSIZE == 32 && defined(PT32_GETFPREGS)
+	PT32_GETFPREGS,
+#  else
+	PT_GETFPREGS,
+#  endif
+	name, , freglen);
 #endif
 	/* XXX Add hook for machdep per-LWP notes. */
 	return (0);



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

2021-01-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan  1 12:58:36 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: netbsd32_machdep.c trap.c
src/sys/arch/aarch64/include [netbsd-9]: netbsd32_machdep.h ptrace.h

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

sys/arch/aarch64/aarch64/trap.c: revision 1.30
sys/arch/aarch64/include/ptrace.h: revision 1.10
sys/arch/aarch64/include/netbsd32_machdep.h: revision 1.4 (patch)
sys/arch/aarch64/aarch64/netbsd32_machdep.c: revision 1.14
sys/arch/aarch64/aarch64/netbsd32_machdep.c: revision 1.15

Add support of ptrace(2) for COMPAT_NETBSD32.

Now, GDB for arm32 is usable for debugging 32bit applications.
OK ryo@

For rev 1.14 and before, netbsd32_process_write_regs() returns EINVAL
if non-modifiable bits are set in CPSR.
Instead, mask out non-modifiable bits and make this function success
regardless of value in CPSR. New behavior matches that of arm:
https://nxr.netbsd.org/xref/src/sys/arch/arm/arm/process_machdep.c#187

This fixes lib/libc/sys/t_ptrace_wait*:access_regs6 tests, in which
register contents retrieved by PT_GETREGS are set back by PT_SETREGS.

No new regression is observed in full ATF run.

OK ryo


To generate a diff of this commit:
cvs rdiff -u -r1.7.2.1 -r1.7.2.2 \
src/sys/arch/aarch64/aarch64/netbsd32_machdep.c
cvs rdiff -u -r1.17.4.3 -r1.17.4.4 src/sys/arch/aarch64/aarch64/trap.c
cvs rdiff -u -r1.2 -r1.2.4.1 src/sys/arch/aarch64/include/netbsd32_machdep.h
cvs rdiff -u -r1.9 -r1.9.2.1 src/sys/arch/aarch64/include/ptrace.h

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/netbsd32_machdep.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.7.2.1 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.7.2.2
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.7.2.1	Sat May  2 16:26:04 2020
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep.c	Fri Jan  1 12:58:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.7.2.1 2020/05/02 16:26:04 martin Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.7.2.2 2021/01/01 12:58:35 martin Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.7.2.1 2020/05/02 16:26:04 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.7.2.2 2021/01/01 12:58:35 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mac
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -93,6 +94,30 @@ netbsd32_setregs(struct lwp *l, struct e
 		tf->tf_spsr |= SPSR_A32_T;
 }
 
+int
+netbsd32_ptrace_translate_request(int req)
+{
+
+	switch (req) {
+	case 0 ... PT_FIRSTMACH - 1:
+		return req;
+	case PT32_GETREGS:
+		return PT_GETREGS;
+	case PT32_SETREGS:
+		return PT_SETREGS;
+	case PT32_GETFPREGS:
+		return PT_GETFPREGS;
+	case PT32_SETFPREGS:
+		return PT_SETFPREGS;
+	/* not implemented for arm32 */
+	case PT32_STEP:
+	case PT32_SETSTEP:
+	case PT32_CLEARSTEP:
+	default:
+		return -1;
+	}
+}
+
 /* aarch32 fpscr register is assigned to two registers fpsr/fpcr on aarch64 */
 #define FPSR_BITS			\
 	(FPSR_N32|FPSR_Z32|FPSR_C32|FPSR_V32|FPSR_QC|			\
@@ -101,7 +126,7 @@ netbsd32_setregs(struct lwp *l, struct e
 	(FPCR_AHP|FPCR_DN|FPCR_FZ|FPCR_RMODE|FPCR_STRIDE|FPCR_LEN|	\
 	 FPCR_IDE|FPCR_IXE|FPCR_UFE|FPCR_OFE|FPCR_DZE|FPCR_IOE)
 
-static int
+int
 netbsd32_process_read_regs(struct lwp *l, struct reg32 *regs)
 {
 	struct proc * const p = l->l_proc;
@@ -125,7 +150,7 @@ netbsd32_process_read_regs(struct lwp *l
 	return 0;
 }
 
-static int
+int
 netbsd32_process_read_fpregs(struct lwp *l, struct fpreg32 *fpregs,
 size_t *lenp)
 {
@@ -165,6 +190,68 @@ netbsd32_process_read_fpregs(struct lwp 
 }
 
 int
+netbsd32_process_write_regs(struct lwp *l, const struct reg32 *regs)
+{
+	struct proc * const p = l->l_proc;
+	struct trapframe *tf = l->l_md.md_utf;
+	int i;
+
+	if ((p->p_flag & PK_32) == 0)
+		return EINVAL;
+
+	if (regs->r_pc >= VM_MAXUSER_ADDRESS32 ||
+	regs->r_sp >= VM_MAXUSER_ADDRESS32)
+		return EINVAL;
+
+	for (i = 0; i < 13; i++)
+		tf->tf_reg[i] = regs->r[i];	/* r0-r12 */
+	tf->tf_reg[13] = regs->r_sp;		/* r13 = sp */
+	tf->tf_reg[14] = regs->r_lr;		/* r14 = lr */
+	tf->tf_pc = regs->r_pc;			/* r15 = pc */
+	tf->tf_spsr &= ~(SPSR_NZCV | SPSR_A32_T);
+	tf->tf_spsr |= regs->r_cpsr & (SPSR_NZCV | SPSR_A32_T);
+
+	/* THUMB CODE? */
+	if (regs->r_pc & 1)
+		tf->tf_spsr |= SPSR_A32_T;
+
+	return 0;
+}
+
+int
+netbsd32_process_write_fpregs(struct lwp *l, const struct fpreg32 *fpregs,
+size_t len)
+{
+	struct proc * const p = l->l_proc;
+	struct pcb * const pcb = lwp_getpcb(l);
+	int i;
+
+	if ((p->p_flag & PK_32) == 0)
+		return EINVAL;
+
+	KASSERT(len <= sizeof(*fpregs));
+	fpu_discard(l, true);		// 

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

2021-01-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan  1 12:54:08 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: pmap.c

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

sys/arch/aarch64/aarch64/pmap.c: revision 1.82
sys/arch/aarch64/aarch64/pmap.c: revision 1.83

pmap_procwr(): sync icache even if p != curproc. This fixes applications
like GDB for arm32, that rewrite text of other process.

Thanks to ryo@ for discussion.

Use tlen for temporary length variable instead of l, which is usually
used for struct lwp *.
No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.41.2.7 -r1.41.2.8 src/sys/arch/aarch64/aarch64/pmap.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.7 src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.8
--- src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.7	Fri Jan  1 12:38:49 2021
+++ src/sys/arch/aarch64/aarch64/pmap.c	Fri Jan  1 12:54:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.41.2.7 2021/01/01 12:38:49 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.41.2.8 2021/01/01 12:54:07 martin Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.41.2.7 2021/01/01 12:38:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.41.2.8 2021/01/01 12:54:07 martin Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -879,12 +879,26 @@ pmap_icache_sync_range(pmap_t pm, vaddr_
  *
  */
 void
-pmap_procwr(struct proc *p, vaddr_t va, int len)
+pmap_procwr(struct proc *p, vaddr_t sva, int len)
 {
 
-	/* We only need to do anything if it is the current process. */
-	if (p == curproc)
-		cpu_icache_sync_range(va, len);
+	if (__predict_true(p == curproc))
+		cpu_icache_sync_range(sva, len);
+	else {
+		struct pmap *pm = p->p_vmspace->vm_map.pmap;
+		paddr_t pa;
+		vaddr_t va, eva;
+		int tlen;
+
+		for (va = sva; len > 0; va = eva, len -= tlen) {
+			eva = uimin(va + len, trunc_page(va + PAGE_SIZE));
+			tlen = eva - va;
+			if (!pmap_extract(pm, va, ))
+continue;
+			va = AARCH64_PA_TO_KVA(pa);
+			cpu_icache_sync_range(va, tlen);
+		}
+	}
 }
 
 static pt_entry_t



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

2021-01-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan  1 12:38:50 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: cpufunc.c pmap.c

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

sys/arch/aarch64/aarch64/cpufunc.c: revision 1.22 (patch)
sys/arch/aarch64/aarch64/cpufunc.c: revision 1.23 (patch)
sys/arch/aarch64/aarch64/pmap.c: revision 1.81

Set uvmexp.ncolors appropriately, which is required for some CPU
models with VIPT icache.

Otherwise, alias in virtual address results in inconsistent results,
at least for applications that rewrite text of other process, e.g.,
GDB for arm32.

Also, this hopefully fixes other unexpected failures due to alias.
Confirmed that there's no observable regression in performance;
difference in ``time make -j8'' for GENERIC64 kernel on BCM2837
with and without setting uvmexp.ncolors is within 0.1%.

Thanks to ryo@ for discussion.

Fix uvmexp.ncolors for some big.LITTLE configuration; it is uncertain
which CPU is used as primary, and as a result, secondary CPUs can
require larger number of colors.

In order to solve this problem, update uvmexp.ncolors via
uvm_page_recolor(9) when secondary CPUs are attached, as done for
other ports like x86.

Pointed out by jmcneill@, and discussed on port-arm@:
http://mail-index.netbsd.org/port-arm/2020/07/03/msg006837.html
Tested and OK'd by ryo@.

Fix previous; add missing  include.


To generate a diff of this commit:
cvs rdiff -u -r1.5.4.1 -r1.5.4.2 src/sys/arch/aarch64/aarch64/cpufunc.c
cvs rdiff -u -r1.41.2.6 -r1.41.2.7 src/sys/arch/aarch64/aarch64/pmap.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpufunc.c
diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.5.4.1 src/sys/arch/aarch64/aarch64/cpufunc.c:1.5.4.2
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.5.4.1	Sun Sep 22 12:27:22 2019
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Fri Jan  1 12:38:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.5.4.1 2019/09/22 12:27:22 martin Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.5.4.2 2021/01/01 12:38:49 martin Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -29,12 +29,15 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.5.4.1 2019/09/22 12:27:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.5.4.2 2021/01/01 12:38:49 martin Exp $");
 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 
@@ -91,6 +94,7 @@ void
 aarch64_getcacheinfo(void)
 {
 	uint32_t clidr, ctr;
+	u_int vindexsize;
 	int level, cachetype;
 	struct aarch64_cache_info *cinfo;
 
@@ -201,14 +205,20 @@ aarch64_getcacheinfo(void)
 	((cinfo[0].cacheable == CACHE_CACHEABLE_ICACHE) ||
 	 (cinfo[0].cacheable == CACHE_CACHEABLE_IDCACHE))) {
 
-		aarch64_cache_vindexsize =
+		vindexsize =
 		cinfo[0].icache.cache_size /
 		cinfo[0].icache.cache_ways;
 
-		KASSERT(aarch64_cache_vindexsize != 0);
-		aarch64_cache_prefer_mask = aarch64_cache_vindexsize - 1;
+		KASSERT(vindexsize != 0);
 	} else {
-		aarch64_cache_vindexsize = 0;
+		vindexsize = 0;
+	}
+
+	if (vindexsize > aarch64_cache_vindexsize) {
+		aarch64_cache_vindexsize = vindexsize;
+		aarch64_cache_prefer_mask = vindexsize - 1;
+		if (uvm.page_init_done)
+			uvm_page_recolor(vindexsize / PAGE_SIZE);
 	}
 }
 

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.6 src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.7
--- src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.6	Tue Jun 30 18:39:37 2020
+++ src/sys/arch/aarch64/aarch64/pmap.c	Fri Jan  1 12:38:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.41.2.6 2020/06/30 18:39:37 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.41.2.7 2021/01/01 12:38:49 martin Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.41.2.6 2020/06/30 18:39:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.41.2.7 2021/01/01 12:38:49 martin Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -418,10 +418,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	UVMHIST_FUNC(__func__);
 	UVMHIST_CALLED(pmaphist);
 
-#if 0
-	/* uvmexp.ncolors = icachesize / icacheways / PAGE_SIZE; */
 	uvmexp.ncolors = aarch64_cache_vindexsize / PAGE_SIZE;
-#endif
 
 	/* devmap already uses last of va? */
 	if ((virtual_devmap_addr != 0) && (virtual_devmap_addr < vend))



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

2021-01-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan  1 12:31:19 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: trap.c

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

sys/arch/aarch64/aarch64/trap.c: revision 1.21
sys/arch/aarch64/aarch64/trap.c: revision 1.26

PR port-arm/54702
Add support for earmv6hf binaries on COMPAT_NETBSD32 for aarch64:
- Emulate ARMv6 instructions with cache operations register (c7), that
   are deprecated since ARMv7, and disabled on ARMv8 with LP64 kernel.

Many thanks to ryo@ for helping me to add support of Thumb-mode,
as well as providing exhaustive test cases:
   https://github.com/ryo/mcr_test/

We've confirmed:
- Emulation works in Thumb-mode.
- T32 16-bit length illegal instruction results in SIGILL, even if
   it is located nearby a boundary b/w mapped and unmapped pages.
- T32 32-bit instruction results in SIGSEGV if it is located across
   a boundary b/w mapped and unmapped pages.

When emulating obsoleted arm32 instructions, use ufetch(9) rather than
dereference tf_pc directly to retrieve an instruction.
Even if tf_pc is valid when processor decodes the instruction, someone
can unmap its page before tf_pc is read in the exception handler.
Now, SIGSEGV is delivered correctly to the process in this case, rather
than kernel panic.

Pointed out by maxv.

Discussed with ryo and skrll.


To generate a diff of this commit:
cvs rdiff -u -r1.17.4.2 -r1.17.4.3 src/sys/arch/aarch64/aarch64/trap.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/trap.c
diff -u src/sys/arch/aarch64/aarch64/trap.c:1.17.4.2 src/sys/arch/aarch64/aarch64/trap.c:1.17.4.3
--- src/sys/arch/aarch64/aarch64/trap.c:1.17.4.2	Mon Dec  9 15:19:31 2019
+++ src/sys/arch/aarch64/aarch64/trap.c	Fri Jan  1 12:31:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.17.4.2 2019/12/09 15:19:31 martin Exp $ */
+/* $NetBSD: trap.c,v 1.17.4.3 2021/01/01 12:31:19 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.17.4.2 2019/12/09 15:19:31 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.17.4.3 2021/01/01 12:31:19 martin Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -348,6 +348,111 @@ interrupt(struct trapframe *tf)
 	cpu_dosoftints();
 }
 
+#ifdef COMPAT_NETBSD32
+
+/*
+ * 32-bit length Thumb instruction. See ARMv7 DDI0406A A6.3.
+ */
+#define THUMB_32BIT(hi) (((hi) & 0xe000) == 0xe000 && ((hi) & 0x1800))
+
+static int
+fetch_arm_insn(struct trapframe *tf, uint32_t *insn)
+{
+
+	/* THUMB? */
+	if (tf->tf_spsr & SPSR_A32_T) {
+		uint16_t *pc = (uint16_t *)(tf->tf_pc & ~1UL); /* XXX */
+		uint16_t hi, lo;
+
+		if (ufetch_16(pc, ))
+			return -1;
+
+		if (!THUMB_32BIT(hi)) {
+			/* 16-bit Thumb instruction */
+			*insn = hi;
+			return 2;
+		}
+
+		/* 32-bit Thumb instruction */
+		if (ufetch_16(pc + 1, ))
+			return -1;
+
+		*insn = ((uint32_t)hi << 16) | lo;
+		return 4;
+	}
+
+	if (ufetch_32((uint32_t *)tf->tf_pc, insn))
+		return -1;
+
+	return 4;
+}
+
+enum emul_arm_result {
+	EMUL_ARM_SUCCESS = 0,
+	EMUL_ARM_UNKNOWN,
+	EMUL_ARM_FAULT,
+};
+
+static enum emul_arm_result
+emul_arm_insn(struct trapframe *tf)
+{
+	uint32_t insn;
+	int insn_size;
+
+	insn_size = fetch_arm_insn(tf, );
+
+	switch (insn_size) {
+	case 2:
+		/* T32-16bit instruction */
+
+		/* XXX: some T32 IT instruction deprecated should be emulated */
+		break;
+	case 4:
+		/* T32-32bit instruction, or A32 instruction */
+
+		/*
+		 * Emulate ARMv6 instructions with cache operations
+		 * register (c7), that can be used in user mode.
+		 */
+		switch (insn & 0x0fff0fff) {
+		case 0x0e070f95:
+			/*
+			 * mcr p15, 0, , c7, c5, 4
+			 * (flush prefetch buffer)
+			 */
+			__asm __volatile("isb sy" ::: "memory");
+			goto emulated;
+		case 0x0e070f9a:
+			/*
+			 * mcr p15, 0, , c7, c10, 4
+			 * (data synchronization barrier)
+			 */
+			__asm __volatile("dsb sy" ::: "memory");
+			goto emulated;
+		case 0x0e070fba:
+			/*
+			 * mcr p15, 0, , c7, c10, 5
+			 * (data memory barrier)
+			 */
+			__asm __volatile("dmb sy" ::: "memory");
+			goto emulated;
+		default:
+			break;
+		}
+		break;
+	default:
+		return EMUL_ARM_FAULT;
+	}
+
+	/* unknown, or unsupported instruction */
+	return EMUL_ARM_UNKNOWN;
+
+ emulated:
+	tf->tf_pc += insn_size;
+	return EMUL_ARM_SUCCESS;
+}
+#endif /* COMPAT_NETBSD32 */
+
 void
 trap_el0_32sync(struct trapframe *tf)
 {
@@ -395,11 +500,26 @@ trap_el0_32sync(struct trapframe *tf)
 		userret(l);
 		break;
 
+	case ESR_EC_UNKNOWN:
+		switch (emul_arm_insn(tf)) {
+		case EMUL_ARM_SUCCESS:
+			break;
+		case EMUL_ARM_UNKNOWN:
+			goto unknown;
+		case EMUL_ARM_FAULT:
+			do_trapsignal(l, SIGSEGV, SEGV_MAPERR,
+			(void *)tf->tf_pc, esr);
+			break;
+		}
+		userret(l);
+		break;
+
 	case 

CVS commit: [netbsd-9] src/sys

2020-12-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Dec 30 15:12:38 UTC 2020

Modified Files:
src/sys/arch/arm/nvidia [netbsd-9]: tegra_ahcisata.c
src/sys/dev/ata [netbsd-9]: satareg.h
src/sys/dev/ic [netbsd-9]: ahcisata_core.c ahcisatavar.h

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

sys/dev/ic/ahcisata_core.c: revision 1.84
sys/dev/ic/ahcisata_core.c: revision 1.85
sys/dev/ic/ahcisata_core.c: revision 1.88
sys/dev/ic/ahcisata_core.c: revision 1.89
sys/arch/arm/nvidia/tegra_ahcisata.c: revision 1.13
sys/dev/ic/ahcisatavar.h: revision 1.26
sys/dev/ic/ahcisata_core.c: revision 1.90
sys/dev/ic/ahcisata_core.c: revision 1.91
sys/dev/ic/ahcisata_core.c: revision 1.92
sys/dev/ata/satareg.h: revision 1.6

ahci_exec_fis: wait for the correct amount of time when AT_WAIT is set

Retry clearing WDCTL_RST a few times before giving up. Makes SATA work in
Solidrun Honeycomb LX2K.

AHCI 1.3.1 specification says that it is good practice for system software
to 'zero-out' the memory allocated and referenced by PxCLB and PxFB.

ahci_intr: use ffs in the port bitmask instead of looping over all 32 bits

AHCI 1.3.1 section 5.5.3 "Processing Completed Commands" says that we
should clear PxIS before IS.IPS.

Add G3 and DevSleep definitions. This changes the mask used by
SControl_IPM_NONE from 0x3 to 0x7.

Make sure to ack IS after PxIS when polling and when using multiple MSI-X
messages.

Remove the AHCI_QUIRK_SKIP_RESET quirk now that the underlying issue is
fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.4.1 src/sys/arch/arm/nvidia/tegra_ahcisata.c
cvs rdiff -u -r1.5 -r1.5.94.1 src/sys/dev/ata/satareg.h
cvs rdiff -u -r1.75.4.3 -r1.75.4.4 src/sys/dev/ic/ahcisata_core.c
cvs rdiff -u -r1.22.4.1 -r1.22.4.2 src/sys/dev/ic/ahcisatavar.h

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

Modified files:

Index: src/sys/arch/arm/nvidia/tegra_ahcisata.c
diff -u src/sys/arch/arm/nvidia/tegra_ahcisata.c:1.12 src/sys/arch/arm/nvidia/tegra_ahcisata.c:1.12.4.1
--- src/sys/arch/arm/nvidia/tegra_ahcisata.c:1.12	Fri Dec 14 12:29:22 2018
+++ src/sys/arch/arm/nvidia/tegra_ahcisata.c	Wed Dec 30 15:12:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_ahcisata.c,v 1.12 2018/12/14 12:29:22 skrll Exp $ */
+/* $NetBSD: tegra_ahcisata.c,v 1.12.4.1 2020/12/30 15:12:38 martin Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_ahcisata.c,v 1.12 2018/12/14 12:29:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_ahcisata.c,v 1.12.4.1 2020/12/30 15:12:38 martin Exp $");
 
 #include 
 #include 
@@ -202,7 +202,6 @@ tegra_ahcisata_attach(device_t parent, d
 		aprint_error(": couldn't map ahci registers: %d\n", error);
 		return;
 	}
-	sc->sc.sc_ahci_quirks = AHCI_QUIRK_SKIP_RESET;
 
 	aprint_naive("\n");
 	aprint_normal(": SATA\n");

Index: src/sys/dev/ata/satareg.h
diff -u src/sys/dev/ata/satareg.h:1.5 src/sys/dev/ata/satareg.h:1.5.94.1
--- src/sys/dev/ata/satareg.h:1.5	Mon Apr 28 20:23:47 2008
+++ src/sys/dev/ata/satareg.h	Wed Dec 30 15:12:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: satareg.h,v 1.5 2008/04/28 20:23:47 martin Exp $	*/
+/*	$NetBSD: satareg.h,v 1.5.94.1 2020/12/30 15:12:38 martin Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -65,6 +65,7 @@
 #define	SStatus_SPD_NONE	(0x0 << 4)	/* no negotiated speed */
 #define	SStatus_SPD_G1		(0x1 << 4)	/* Generation 1 (1.5Gb/s) */
 #define	SStatus_SPD_G2		(0x2 << 4)	/* Generation 2 (3.0Gb/s) */
+#define	SStatus_SPD_G3		(0x3 << 4)	/* Generation 3 (6.0Gb/s) */
 #define	SStatus_SPD_mask	(0xf << 4)
 #define	SStatus_SPD_shift	4
 	/*
@@ -75,6 +76,7 @@
 #define	SStatus_IPM_ACTIVE	(0x1 << 8)	/* ACTIVE state */
 #define	SStatus_IPM_PARTIAL	(0x2 << 8)	/* PARTIAL pm state */
 #define	SStatus_IPM_SLUMBER	(0x6 << 8)	/* SLUMBER pm state */
+#define	SStatus_IPM_DEVSLEEP	(0x8 << 8)	/* DevSleep pm state */
 #define	SStatus_IPM_mask	(0xf << 8)
 #define	SStatus_IPM_shift	8
 
@@ -130,6 +132,7 @@
 #define	SControl_SPD_ANY	(0x0 << 4)	/* No restrictions */
 #define	SControl_SPD_G1		(0x1 << 4)	/* Generation 1 (1.5Gb/s) */
 #define	SControl_SPD_G2		(0x2 << 4)	/* Generation 2 (3.0Gb/s) */
+#define	SControl_SPD_G3		(0x3 << 4)	/* Generation 3 (6.0Gb/s) */
 	/*
 	 * The IPM field represents the enabled interface power management
 	 * states that can be invoked via the Serial ATA interface power
@@ -138,7 +141,8 @@
 #define	SControl_IPM_ANY	(0x0 << 8)	/* No restrictions */
 #define	SControl_IPM_NOPARTIAL	(0x1 << 8)	/* PARTIAL disabled */
 #define	SControl_IPM_NOSLUMBER	(0x2 << 8)	/* SLUMBER disabled */
-#define	SControl_IPM_NONE	(0x3 << 8)	/* No power management */
+#define	SControl_IPM_NODEVSLEEP	(0x4 << 8)	/* DevSleep disabled */
+#define	SControl_IPM_NONE	(0x7 << 8)	/* No power management */
 	/*
 	 * The SPM 

CVS commit: [netbsd-9] src/sys/dev/hdaudio

2020-12-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec 28 20:21:55 UTC 2020

Modified Files:
src/sys/dev/hdaudio [netbsd-9]: hdaudio.c

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

sys/dev/hdaudio/hdaudio.c: revision 1.13

If the Subordinate Node Count returns 0 nodes, complain and return instead
of trying to kmem_zalloc 0 bytes later on.


To generate a diff of this commit:
cvs rdiff -u -r1.9.2.1 -r1.9.2.2 src/sys/dev/hdaudio/hdaudio.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/hdaudio/hdaudio.c
diff -u src/sys/dev/hdaudio/hdaudio.c:1.9.2.1 src/sys/dev/hdaudio/hdaudio.c:1.9.2.2
--- src/sys/dev/hdaudio/hdaudio.c:1.9.2.1	Mon Dec 28 20:18:09 2020
+++ src/sys/dev/hdaudio/hdaudio.c	Mon Dec 28 20:21:54 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio.c,v 1.9.2.1 2020/12/28 20:18:09 martin Exp $ */
+/* $NetBSD: hdaudio.c,v 1.9.2.2 2020/12/28 20:21:54 martin Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd 
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.9.2.1 2020/12/28 20:18:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.9.2.2 2020/12/28 20:21:54 martin Exp $");
 
 #include 
 #include 
@@ -713,6 +713,7 @@ hdaudio_attach_fg(struct hdaudio_functio
 static void
 hdaudio_codec_attach(struct hdaudio_codec *co)
 {
+	struct hdaudio_softc *sc = co->co_host;
 	struct hdaudio_function_group *fg;
 	uint32_t vid, snc, fgrp;
 	int starting_node, num_nodes, nid;
@@ -729,7 +730,6 @@ hdaudio_codec_attach(struct hdaudio_code
 		return;
 
 #ifdef HDAUDIO_DEBUG
-	struct hdaudio_softc *sc = co->co_host;
 	uint32_t rid = hdaudio_command(co, 0, CORB_GET_PARAMETER,
 	COP_REVISION_ID);
 	hda_print(sc, "Codec%02X: %04X:%04X HDA %d.%d rev %d stepping %d\n",
@@ -740,6 +740,16 @@ hdaudio_codec_attach(struct hdaudio_code
 	starting_node = (snc >> 16) & 0xff;
 	num_nodes = snc & 0xff;
 
+	/*
+	 * If the total number of nodes is 0, there's nothing we can do.
+	 * This shouldn't happen, so complain about it.
+	 */
+	if (num_nodes == 0) {
+		hda_error(sc, "Codec%02X: No subordinate nodes found (%08x)\n",
+		co->co_addr, snc);
+		return;
+	}
+
 	co->co_nfg = num_nodes;
 	co->co_fg = kmem_zalloc(co->co_nfg * sizeof(*co->co_fg), KM_SLEEP);
 



CVS commit: [netbsd-9] src/sys/dev/hdaudio

2020-12-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec 28 20:18:09 UTC 2020

Modified Files:
src/sys/dev/hdaudio [netbsd-9]: hdaudio.c

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

sys/dev/hdaudio/hdaudio.c: revision 1.12

Initialize DMA memory when allocating it. Should fix PR# 51734 (hdaudio
"RIRB timeout" on boot).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.2.1 src/sys/dev/hdaudio/hdaudio.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/hdaudio/hdaudio.c
diff -u src/sys/dev/hdaudio/hdaudio.c:1.9 src/sys/dev/hdaudio/hdaudio.c:1.9.2.1
--- src/sys/dev/hdaudio/hdaudio.c:1.9	Fri Jul 26 11:13:46 2019
+++ src/sys/dev/hdaudio/hdaudio.c	Mon Dec 28 20:18:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio.c,v 1.9 2019/07/26 11:13:46 jmcneill Exp $ */
+/* $NetBSD: hdaudio.c,v 1.9.2.1 2020/12/28 20:18:09 martin Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd 
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.9 2019/07/26 11:13:46 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.9.2.1 2020/12/28 20:18:09 martin Exp $");
 
 #include 
 #include 
@@ -194,6 +194,10 @@ hdaudio_dma_alloc(struct hdaudio_softc *
 	if (err)
 		goto destroy;
 
+	memset(dma->dma_addr, 0, dma->dma_size);
+	bus_dmamap_sync(sc->sc_dmat, dma->dma_map, 0, dma->dma_size,
+	BUS_DMASYNC_PREWRITE);
+
 	dma->dma_valid = true;
 	return 0;
 



CVS commit: [netbsd-9] src/sys

2020-12-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec 28 20:10:04 UTC 2020

Modified Files:
src/sys/arch/hp300/dev [netbsd-9]: sti_sgc.c
src/sys/dev/ic [netbsd-9]: sti.c stivar.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1162):

sys/dev/ic/stivar.h: revision 1.11
sys/dev/ic/sti.c: revision 1.23
sys/dev/ic/sti.c: revision 1.24
sys/dev/ic/sti.c: revision 1.25
sys/arch/hp300/dev/sti_sgc.c: revision 1.4

Pull the latest OpenBSD sti(4) changes for bitmap framebuffer support.
- bitmap and colormap ops based on old HP ngle X11 driver:
  http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/dev/ic/sti.c#rev1.76
  > Work-in-progress support for non-accelerated X11 on *some* sti(4)
  > frame buffers; based upon the old HP ngle X11 driver.
  > Currently limited to CRX (720/735/750), Timber (710, old 715),
  > Artist (712, 715) and EG (B-series), however the
  > colormap isn't set up correctly on Timber and EG yet.
  >
  > Joint work with Artem Falcon, now in good enough shape to be worked further
  > in the tree.
- misc other cosmetic changes to reduce diffs
No particular comments on port-hp300@ and port-hppa@:
 https://mail-index.netbsd.org/port-hp300/2020/12/19/msg000184.html
 https://mail-index.netbsd.org/port-hp300/2020/12/20/msg000185.html

The MD hp300 attachment for SGC CRX (A1659-66001) will be committed
separately.

Add bitmap access ops support for SGC CRX (A1659-66001) framebuffer.
Also modify existing 425e EVRX attachment to use updated MI sti(4) ops
more efficiently.

The Xorg server and mlterm-wscons (that support wsdisplay bitmap) work
fine on SGC hp425t.

No particular comments on port-hp300@ and port-hppa@:
 https://mail-index.netbsd.org/port-hp300/2020/12/19/msg000184.html
 https://mail-index.netbsd.org/port-hp300/2020/12/20/msg000185.html

Special thanks to Miod Vallat again, for contributing the SGC CRX
framebuffer with the SGC connector and flexible cable for HP9000/425t.

He also contributed DIO-II "Hyperion" monochrome framebuffer and
1 plane grayscale SGC GRX (A1924-66001), and I've confirmed hyper(4)
just works even with Xorg server.  I will try GRX as the next project.

Handle WSSCREEN_REVERSE properly.  Based on OpenBSD's sti(4).

Also remove WSSCREEN_UNDERLINE from capabilities that is not handled
by sti(4) ROM routines.

Tested on HP9000/425t with CRX.

Ignore WSDISPLAYIO_PUTCMAP in WSDISPLAYIO_MODE_EMUL, i.e. text mode.

The hardware palette settings are handled by the STI ROM in STI_TEXTMODE
and changing cmap could cause mangled text colors at least on CRX on 425t.

Updating CMAP in EMUL mode isn't expected anyway.

Fixes "red or invisible text" after exiting mlterm-wscons on A1659 CRX.


To generate a diff of this commit:
cvs rdiff -u -r1.2.34.1 -r1.2.34.2 src/sys/arch/hp300/dev/sti_sgc.c
cvs rdiff -u -r1.19.12.1 -r1.19.12.2 src/sys/dev/ic/sti.c
cvs rdiff -u -r1.9.34.1 -r1.9.34.2 src/sys/dev/ic/stivar.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/hp300/dev/sti_sgc.c
diff -u src/sys/arch/hp300/dev/sti_sgc.c:1.2.34.1 src/sys/arch/hp300/dev/sti_sgc.c:1.2.34.2
--- src/sys/arch/hp300/dev/sti_sgc.c:1.2.34.1	Mon May 18 17:52:22 2020
+++ src/sys/arch/hp300/dev/sti_sgc.c	Mon Dec 28 20:10:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti_sgc.c,v 1.2.34.1 2020/05/18 17:52:22 martin Exp $	*/
+/*	$NetBSD: sti_sgc.c,v 1.2.34.2 2020/12/28 20:10:04 martin Exp $	*/
 /*	$OpenBSD: sti_sgc.c,v 1.14 2007/05/26 00:36:03 krw Exp $	*/
 
 /*
@@ -27,7 +27,7 @@
  *
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.2.34.1 2020/05/18 17:52:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.2.34.2 2020/12/28 20:10:04 martin Exp $");
 
 #include 
 #include 
@@ -49,33 +49,40 @@ struct sti_sgc_softc {
 	struct sti_softc sc_sti;
 
 	paddr_t sc_bitmap;
-	bus_space_tag_t sc_bst;
-	bus_space_handle_t sc_ramdach;
 };
 
 /*
  * 425e EVRX specific hardware
  */
-#define STI_EVRX_RAMDACOFFSET	0x06
-#define STI_EVRX_RAMDACSIZE	0x000800
+/*
+ * EVRX RAMDAC (Bt458) is found at offset 0x06 from SGC bus PA and 
+ * offset 0x04 length 0x1c is mapped in MI sti via ROM region 2
+ */
+#define STI_EVRX_REGNO2OFFSET	0x02
 #define STI_EVRX_FBOFFSET	0x20
 
-#define EVRX_BT458_ADDR		(0x200 + 2)
-#define EVRX_BT458_CMAP		(0x204 + 2)
-#define EVRX_BT458_CTRL		(0x208 + 2)
-#define EVRX_BT458_OMAP		(0x20C + 2)
+#define EVRX_BT458_ADDR		(STI_EVRX_REGNO2OFFSET + 0x200 + 2)
+#define EVRX_BT458_CMAP		(STI_EVRX_REGNO2OFFSET + 0x204 + 2)
+#define EVRX_BT458_CTRL		(STI_EVRX_REGNO2OFFSET + 0x208 + 2)
+#define EVRX_BT458_OMAP		(STI_EVRX_REGNO2OFFSET + 0x20C + 2)
 
 /* from HP-UX /usr/lib/libddevrx.a */
-#define EVRX_MAGIC00		0x600
-#define EVRX_MAGIC04		0x604
-#define EVRX_MAGIC08		0x608
-#define EVRX_MAGIC0C		0x60c
-#define EVRX_MAGIC10		0x610
+#define EVRX_MAGIC00		(STI_EVRX_REGNO2OFFSET + 0x600)
+#define 

CVS commit: [netbsd-9] src/sys/arch/hp300/dev

2020-12-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec 28 20:02:30 UTC 2020

Modified Files:
src/sys/arch/hp300/dev [netbsd-9]: dnkbd.c hil_intio.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1161):

sys/arch/hp300/dev/dnkbd.c: revision 1.11
sys/arch/hp300/dev/hil_intio.c: revision 1.4

Fix a longstanding bug in hilkbd (and dnkbd) console attachment.
cn_tab->cn_dev is initialized in wsdisplay_emul_attach()
(but not in wsdiaplay_cnattach()) so it cannot be used
when hil(4) is attached before wsdisplay(4) is attached.

Instead, use exported wsdisplay_cnputc() that is actually
set in early wsdisplay_cnattach().

Now we can use ddb and RB_ASKNAME via HIL keyboard console.

Should be pulleld up to netbsd-8 and netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.18.1 src/sys/arch/hp300/dev/dnkbd.c
cvs rdiff -u -r1.3 -r1.3.64.1 src/sys/arch/hp300/dev/hil_intio.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/hp300/dev/dnkbd.c
diff -u src/sys/arch/hp300/dev/dnkbd.c:1.10 src/sys/arch/hp300/dev/dnkbd.c:1.10.18.1
--- src/sys/arch/hp300/dev/dnkbd.c:1.10	Sat Apr  8 17:04:56 2017
+++ src/sys/arch/hp300/dev/dnkbd.c	Mon Dec 28 20:02:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dnkbd.c,v 1.10 2017/04/08 17:04:56 tsutsui Exp $	*/
+/*	$NetBSD: dnkbd.c,v 1.10.18.1 2020/12/28 20:02:30 martin Exp $	*/
 /*	$OpenBSD: dnkbd.c,v 1.17 2009/07/23 21:05:56 blambert Exp $	*/
 
 /*
@@ -69,6 +69,9 @@
 
 #include "opt_wsdisplay_compat.h"
 
+#include "wsdisplay.h"
+#include "wsmouse.h"
+
 #include 
 #include 
 #include 
@@ -87,7 +90,9 @@
 #include 
 #include 
 #include 
-#include "wsmouse.h"
+#if NWSDISPLAY > 0
+#include 
+#endif
 #if NWSMOUSE > 0
 #include 
 #endif
@@ -354,7 +359,8 @@ dnkbd_attach_subdevices(struct dnkbd_sof
 	 * plugged), unless the console keyboard has been claimed already
 	 * (i.e. late hotplug with hil keyboard plugged first).
 	 */
-	if (major(cn_tab->cn_dev) == devsw_name2chr("wsdisplay", NULL, 0)) {
+#if NWSDISPLAY > 0
+	if (cn_tab->cn_putc == wsdisplay_cnputc) {
 #if NHILKBD > 0
 		if (hil_is_console == -1) {
 			ka.console = 1;
@@ -365,7 +371,10 @@ dnkbd_attach_subdevices(struct dnkbd_sof
 		ka.console = 1;
 #endif
 	} else
+#endif
+	{
 		ka.console = 0;
+	}
 
 	ka.keymap = _keymapdata;
 	ka.accessops = _accessops;

Index: src/sys/arch/hp300/dev/hil_intio.c
diff -u src/sys/arch/hp300/dev/hil_intio.c:1.3 src/sys/arch/hp300/dev/hil_intio.c:1.3.64.1
--- src/sys/arch/hp300/dev/hil_intio.c:1.3	Sat Feb 19 05:36:49 2011
+++ src/sys/arch/hp300/dev/hil_intio.c	Mon Dec 28 20:02:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hil_intio.c,v 1.3 2011/02/19 05:36:49 tsutsui Exp $	*/
+/*	$NetBSD: hil_intio.c,v 1.3.64.1 2020/12/28 20:02:30 martin Exp $	*/
 /*	$OpenBSD: hil_intio.c,v 1.8 2007/01/06 20:10:57 miod Exp $	*/
 
 /*
@@ -28,6 +28,8 @@
  *
  */
 
+#include "wsdisplay.h"
+
 #include 
 #include 
 #include 
@@ -38,6 +40,9 @@
 #include 
 
 #include 
+#if NWSDISPLAY > 0
+#include 
+#endif
 
 #include 
 
@@ -88,8 +93,12 @@ hil_intio_attach(device_t parent, device
 	/*
 	 * Check that the configured console device is a wsdisplay.
 	 */
-	if (major(cn_tab->cn_dev) != devsw_name2chr("wsdisplay", NULL, 0))
+#if NWSDISPLAY > 0
+	if (cn_tab->cn_putc != wsdisplay_cnputc)
+#endif
+	{
 		hil_is_console = 0;
+	}
 
 	hil_attach(sc, _is_console);
 	intr_establish(hil_intr, sc, ia->ia_ipl, IPL_TTY);



CVS commit: [netbsd-9] src/sys

2020-12-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Dec 23 12:34:38 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-9]: ehci.c ohci.c uhci.c xhci.c
src/sys/external/bsd/dwc2 [netbsd-9]: dwc2.c

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

sys/dev/usb/ohci.c: revision 1.314
sys/external/bsd/dwc2/dwc2.c: revision 1.75
sys/dev/usb/ehci.c: revision 1.284
sys/dev/usb/uhci.c: revision 1.305
sys/dev/usb/xhci.c: revision 1.136

usb: Omit bogus assertions about struct usbd_pipe::up_intrxfer.

These assertions were only valid for pipes at UE_IN_DIR, UE_INTERRUPT
endpoints created with usbd_open_pipe_intr, which uses up_intrxfer to
pass the struct usbd_xfer object to usbd_close_pipe to free later.

In contrast, for pipes at UE_OUT_DIR, UE_INTERRUPT endpoints,
up_intrxfer is never initialized, so the assertion cannot be right.
In principle we might even have more than one outstanding interrupt
transfer at a time, rendering the point of the assertion moot anyway.

Found by interrupting a uhidev write to a u2f device.

ok nick


To generate a diff of this commit:
cvs rdiff -u -r1.267.2.3 -r1.267.2.4 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.289.4.6 -r1.289.4.7 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.288.4.2 -r1.288.4.3 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.107.2.6 -r1.107.2.7 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.59.4.3 -r1.59.4.4 src/sys/external/bsd/dwc2/dwc2.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.267.2.3 src/sys/dev/usb/ehci.c:1.267.2.4
--- src/sys/dev/usb/ehci.c:1.267.2.3	Sun Mar  1 12:35:16 2020
+++ src/sys/dev/usb/ehci.c	Wed Dec 23 12:34:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.267.2.3 2020/03/01 12:35:16 martin Exp $ */
+/*	$NetBSD: ehci.c,v 1.267.2.4 2020/12/23 12:34:38 martin Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.267.2.3 2020/03/01 12:35:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.267.2.4 2020/12/23 12:34:38 martin Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -4132,7 +4132,6 @@ ehci_device_intr_abort(struct usbd_xfer 
 	EHCIHIST_FUNC(); EHCIHIST_CALLED();
 
 	DPRINTF("xfer=%#jx", (uintptr_t)xfer, 0, 0, 0);
-	KASSERT(xfer->ux_pipe->up_intrxfer == xfer);
 
 	/*
 	 * XXX - abort_xfer uses ehci_sync_hc, which syncs via the advance

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.289.4.6 src/sys/dev/usb/ohci.c:1.289.4.7
--- src/sys/dev/usb/ohci.c:1.289.4.6	Sat Dec 12 20:29:11 2020
+++ src/sys/dev/usb/ohci.c	Wed Dec 23 12:34:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.289.4.6 2020/12/12 20:29:11 martin Exp $	*/
+/*	$NetBSD: ohci.c,v 1.289.4.7 2020/12/23 12:34:38 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.289.4.6 2020/12/12 20:29:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.289.4.7 2020/12/23 12:34:38 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -3356,7 +3356,6 @@ ohci_device_intr_abort(struct usbd_xfer 
 	ohci_softc_t *sc __diagused = OHCI_XFER2SC(xfer);
 
 	KASSERT(mutex_owned(>sc_lock));
-	KASSERT(xfer->ux_pipe->up_intrxfer == xfer);
 
 	usbd_xfer_abort(xfer);
 }

Index: src/sys/dev/usb/uhci.c
diff -u src/sys/dev/usb/uhci.c:1.288.4.2 src/sys/dev/usb/uhci.c:1.288.4.3
--- src/sys/dev/usb/uhci.c:1.288.4.2	Sun Mar  1 12:35:16 2020
+++ src/sys/dev/usb/uhci.c	Wed Dec 23 12:34:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhci.c,v 1.288.4.2 2020/03/01 12:35:16 martin Exp $	*/
+/*	$NetBSD: uhci.c,v 1.288.4.3 2020/12/23 12:34:38 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.288.4.2 2020/03/01 12:35:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.288.4.3 2020/12/23 12:34:38 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2817,7 +2817,6 @@ uhci_device_intr_abort(struct usbd_xfer 
 	uhci_softc_t *sc __diagused = UHCI_XFER2SC(xfer);
 
 	KASSERT(mutex_owned(>sc_lock));
-	KASSERT(xfer->ux_pipe->up_intrxfer == xfer);
 
 	UHCIHIST_FUNC(); UHCIHIST_CALLED();
 	DPRINTF("xfer=%#jx", (uintptr_t)xfer, 0, 0, 0);

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.107.2.6 src/sys/dev/usb/xhci.c:1.107.2.7
--- src/sys/dev/usb/xhci.c:1.107.2.6	Mon May 25 15:31:45 2020
+++ src/sys/dev/usb/xhci.c	Wed Dec 23 12:34:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.107.2.6 2020/05/25 15:31:45 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.107.2.7 2020/12/23 12:34:38 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.6 2020/05/25 15:31:45 

CVS commit: [netbsd-9] src/sys/dev/audio

2020-12-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 19 13:54:56 UTC 2020

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #1158):

sys/dev/audio/audio.c: revision 1.83

Avoid a dead lock in audiodetach, since rev 1.63.
audio_unlink() must be called without exlock held (and
audio_mixer_destroy() must be called with exlock held).

This makes unplugging during playing/recording work (again).

Reported by Julian Coleman on current-users:
 http://mail-index.netbsd.org/current-users/2020/12/10/msg040050.html


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

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.17 src/sys/dev/audio/audio.c:1.28.2.18
--- src/sys/dev/audio/audio.c:1.28.2.17	Sat Dec 19 13:48:27 2020
+++ src/sys/dev/audio/audio.c	Sat Dec 19 13:54:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.17 2020/12/19 13:48:27 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.18 2020/12/19 13:54:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.17 2020/12/19 13:48:27 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.18 2020/12/19 13:54:56 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1324,7 +1324,6 @@ audiodetach(device_t self, int flags)
 	 * that hold sc, and any new calls with files that were for sc will
 	 * fail.  Thus, we now have exclusive access to the softc.
 	 */
-	sc->sc_exlock = 1;
 
 	/*
 	 * Nuke all open instances.
@@ -1350,6 +1349,7 @@ audiodetach(device_t self, int flags)
 	pmf_device_deregister(self);
 
 	/* Free resources */
+	sc->sc_exlock = 1;
 	if (sc->sc_pmixer) {
 		audio_mixer_destroy(sc, sc->sc_pmixer);
 		kmem_free(sc->sc_pmixer, sizeof(*sc->sc_pmixer));



CVS commit: [netbsd-9] src/sys/dev/audio

2020-12-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 19 13:48:27 UTC 2020

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #1156):

sys/dev/audio/audio.c: revision 1.80
sys/dev/audio/audio.c: revision 1.81

Fix that audio_open() didn't halt the recording mixer correctly
if fd_allocfile() failed, since rev 1.65.

Will fix PR kern/55848.

 -

Rewrite error handling on audio_open().
This also fixes a few resource leaks on error case.


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

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.16 src/sys/dev/audio/audio.c:1.28.2.17
--- src/sys/dev/audio/audio.c:1.28.2.16	Sun Jun  7 19:04:00 2020
+++ src/sys/dev/audio/audio.c	Sat Dec 19 13:48:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.16 2020/06/07 19:04:00 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.17 2020/12/19 13:48:27 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.16 2020/06/07 19:04:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.17 2020/12/19 13:48:27 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -2075,6 +2075,9 @@ audio_open(dev_t dev, struct audio_softc
 	audio_file_t *af;
 	audio_ring_t *hwbuf;
 	bool fullduplex;
+	bool cred_held;
+	bool hw_opened;
+	bool rmixer_started;
 	int fd;
 	int error;
 
@@ -2085,6 +2088,11 @@ audio_open(dev_t dev, struct audio_softc
 	ISDEVSOUND(dev) ? "sound" : "audio",
 	flags, sc->sc_popens, sc->sc_ropens);
 
+	fp = NULL;
+	cred_held = false;
+	hw_opened = false;
+	rmixer_started = false;
+
 	af = kmem_zalloc(sizeof(audio_file_t), KM_SLEEP);
 	af->sc = sc;
 	af->dev = dev;
@@ -2094,7 +2102,7 @@ audio_open(dev_t dev, struct audio_softc
 		af->mode |= AUMODE_RECORD;
 	if (af->mode == 0) {
 		error = ENXIO;
-		goto bad1;
+		goto bad;
 	}
 
 	fullduplex = (sc->sc_props & AUDIO_PROP_FULLDUPLEX);
@@ -2110,7 +2118,7 @@ audio_open(dev_t dev, struct audio_softc
 			if (sc->sc_ropens != 0) {
 TRACE(1, "record track already exists");
 error = ENODEV;
-goto bad1;
+goto bad;
 			}
 			/* Play takes precedence */
 			af->mode &= ~AUMODE_RECORD;
@@ -2119,7 +2127,7 @@ audio_open(dev_t dev, struct audio_softc
 			if (sc->sc_popens != 0) {
 TRACE(1, "play track already exists");
 error = ENODEV;
-goto bad1;
+goto bad;
 			}
 		}
 	}
@@ -2166,13 +2174,14 @@ audio_open(dev_t dev, struct audio_softc
 	}
 	error = audio_file_setinfo(sc, af, );
 	if (error)
-		goto bad2;
+		goto bad;
 
 	if (sc->sc_popens + sc->sc_ropens == 0) {
 		/* First open */
 
 		sc->sc_cred = kauth_cred_get();
 		kauth_cred_hold(sc->sc_cred);
+		cred_held = true;
 
 		if (sc->hw_if->open) {
 			int hwflags;
@@ -2205,8 +2214,16 @@ audio_open(dev_t dev, struct audio_softc
 			mutex_exit(sc->sc_intr_lock);
 			mutex_exit(sc->sc_lock);
 			if (error)
-goto bad2;
+goto bad;
 		}
+		/*
+		 * Regardless of whether we called hw_if->open (whether
+		 * hw_if->open exists) or not, we move to the Opened phase
+		 * here.  Therefore from this point, we have to call
+		 * hw_if->close (if exists) whenever abort.
+		 * Note that both of hw_if->{open,close} are optional.
+		 */
+		hw_opened = true;
 
 		/*
 		 * Set speaker mode when a half duplex.
@@ -2226,14 +2243,14 @@ audio_open(dev_t dev, struct audio_softc
 mutex_exit(sc->sc_intr_lock);
 mutex_exit(sc->sc_lock);
 if (error)
-	goto bad3;
+	goto bad;
 			}
 		}
 	} else if (sc->sc_multiuser == false) {
 		uid_t euid = kauth_cred_geteuid(kauth_cred_get());
 		if (euid != 0 && euid != kauth_cred_geteuid(sc->sc_cred)) {
 			error = EPERM;
-			goto bad2;
+			goto bad;
 		}
 	}
 
@@ -2250,7 +2267,7 @@ audio_open(dev_t dev, struct audio_softc
 			mutex_exit(sc->sc_intr_lock);
 			mutex_exit(sc->sc_lock);
 			if (error)
-goto bad3;
+goto bad;
 		}
 	}
 	/*
@@ -2269,18 +2286,24 @@ audio_open(dev_t dev, struct audio_softc
 			mutex_exit(sc->sc_intr_lock);
 			mutex_exit(sc->sc_lock);
 			if (error)
-goto bad3;
+goto bad;
 		}
 
 		mutex_enter(sc->sc_lock);
 		audio_rmixer_start(sc);
 		mutex_exit(sc->sc_lock);
+		rmixer_started = true;
 	}
 
-	if (bellfile == NULL) {
+	if (bellfile) {
+		*bellfile = af;
+	} else {
 		error = fd_allocfile(, );
 		if (error)
-			goto bad3;
+			goto bad;
+
+		error = fd_clone(fp, fd, flags, _fileops, af);
+		KASSERTMSG(error == EMOVEFD, "error=%d", error);
 	}
 
 	/*
@@ -2297,22 +2320,21 @@ audio_open(dev_t dev, struct audio_softc
 	mutex_exit(sc->sc_intr_lock);
 	mutex_exit(sc->sc_lock);
 
-	if (bellfile) {
-		*bellfile = af;
-	} else {
-		error = fd_clone(fp, fd, flags, _fileops, af);
-		KASSERTMSG(error == EMOVEFD, 

CVS commit: [netbsd-9] src/sys/arch/hp300/conf

2020-12-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec 14 17:29:35 UTC 2020

Modified Files:
src/sys/arch/hp300/conf [netbsd-9]: INSTALL RAMDISK

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1152):

sys/arch/hp300/conf/RAMDISK: revision 1.16
sys/arch/hp300/conf/INSTALL: revision 1.66

Remove options (NVNODE, NBUF, and BUFPAGES) for small RAM machines.

These options make extracting binary sets much slower even on miniroot.

Instead, use "options BUFCACHE=5" (use 5% of memory for buffercache) and
also specify "-fno-unwind-tables" for COPTS to shrink INSTALL kernel.

Worth to pullup to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.64.4.1 src/sys/arch/hp300/conf/INSTALL
cvs rdiff -u -r1.15 -r1.15.22.1 src/sys/arch/hp300/conf/RAMDISK

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/hp300/conf/INSTALL
diff -u src/sys/arch/hp300/conf/INSTALL:1.64 src/sys/arch/hp300/conf/INSTALL:1.64.4.1
--- src/sys/arch/hp300/conf/INSTALL:1.64	Thu Mar 14 16:59:09 2019
+++ src/sys/arch/hp300/conf/INSTALL	Mon Dec 14 17:29:35 2020
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.64 2019/03/14 16:59:09 thorpej Exp $
+# $NetBSD: INSTALL,v 1.64.4.1 2020/12/14 17:29:35 martin Exp $
 #
 # INSTALL machine description file
 #
@@ -10,10 +10,11 @@ include 	"arch/hp300/conf/std.hp300"
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
 # optimise for smaller kernels
-makeoptions 	COPTS="-Os"
-options 	NVNODE=50
-options 	NBUF=16
-options 	BUFPAGES=16
+makeoptions 	COPTS="-Os -fno-unwind-tables"
+#options 	NVNODE=50
+#options 	NBUF=16
+#options 	BUFPAGES=16
+options 	BUFCACHE=5
 options 	NFS_V2_ONLY
 options 	NFS_DEFAULT_NIOTHREADS=1
 options 	USERCONF		# userconf(4) support

Index: src/sys/arch/hp300/conf/RAMDISK
diff -u src/sys/arch/hp300/conf/RAMDISK:1.15 src/sys/arch/hp300/conf/RAMDISK:1.15.22.1
--- src/sys/arch/hp300/conf/RAMDISK:1.15	Tue Dec 29 14:51:38 2015
+++ src/sys/arch/hp300/conf/RAMDISK	Mon Dec 14 17:29:35 2020
@@ -1,4 +1,4 @@
-# $NetBSD: RAMDISK,v 1.15 2015/12/29 14:51:38 christos Exp $
+# $NetBSD: RAMDISK,v 1.15.22.1 2020/12/14 17:29:35 martin Exp $
 #
 # RAMDISK machine description file
 #
@@ -7,11 +7,6 @@
 
 include 	"arch/hp300/conf/INSTALL"
 
-# These options for small RAM machines makes extracting binaries much slower.
-no options	NVNODE
-no options	NBUF
-no options	BUFPAGES
-
 # Enable the hooks used for initializing the root memory-disk.
 options 	MEMORY_DISK_HOOKS
 options 	MEMORY_DISK_IS_ROOT		# force root on memory disk



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

2020-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 12 20:29:11 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-9]: ohci.c ohcivar.h

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

sys/dev/usb/ohci.c: revision 1.311
sys/dev/usb/ohci.c: revision 1.312
sys/dev/usb/ohcivar.h: revision 1.62

Restructure the abort code for TD based transfers (ctrl, bulk, intr).

In PR kern/22646 some TDs can be on the done queue when the abort start
and, if this is the case, they need to processed after the WDH interrupt.
Instead of waiting for WDH we release TDs that have been touched by the
HC and replace them with new ones.  Once WDH happens the floating TDs
will be returned to the free list.

Also addresses the issue seen in PR kern/55835

Thanks to both Andreas Gustafsson and Edgar Fu=C3=9F for testing.  Apologi=
es to
Andreas Gustafsson for not committing this to HEAD for 4y6m.w

Remove leading space that crept in in the last change


To generate a diff of this commit:
cvs rdiff -u -r1.289.4.5 -r1.289.4.6 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.60 -r1.60.6.1 src/sys/dev/usb/ohcivar.h

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

Modified files:

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.289.4.5 src/sys/dev/usb/ohci.c:1.289.4.6
--- src/sys/dev/usb/ohci.c:1.289.4.5	Sun Mar  1 12:35:16 2020
+++ src/sys/dev/usb/ohci.c	Sat Dec 12 20:29:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.289.4.5 2020/03/01 12:35:16 martin Exp $	*/
+/*	$NetBSD: ohci.c,v 1.289.4.6 2020/12/12 20:29:11 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.289.4.5 2020/03/01 12:35:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.289.4.6 2020/12/12 20:29:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -389,6 +389,7 @@ ohci_detach(struct ohci_softc *sc, int f
 	if (sc->sc_hcca != NULL)
 		usb_freemem(>sc_bus, >sc_hccadma);
 	pool_cache_destroy(sc->sc_xferpool);
+	cv_destroy(>sc_abort_cv);
 
 	return rv;
 }
@@ -491,6 +492,7 @@ ohci_alloc_std(ohci_softc_t *sc)
 	memset(>td, 0, sizeof(ohci_td_t));
 	std->nexttd = NULL;
 	std->xfer = NULL;
+	std->held = NULL;
 
 	return std;
 }
@@ -538,14 +540,17 @@ ohci_alloc_std_chain(ohci_softc_t *sc, s
 
 	DPRINTFN(8, "xfer %#jx nstd %jd", (uintptr_t)xfer, nstd, 0, 0);
 
-	for (size_t j = 0; j < ox->ox_nstd;) {
+	for (size_t j = 0; j < ox->ox_nstd; j++) {
 		ohci_soft_td_t *cur = ohci_alloc_std(sc);
 		if (cur == NULL)
 			goto nomem;
 
-		ox->ox_stds[j++] = cur;
+		ox->ox_stds[j] = cur;
+		cur->held = >ox_stds[j];
 		cur->xfer = xfer;
 		cur->flags = 0;
+		DPRINTFN(10, "xfer=%#jx new std=%#jx held at %#jx", (uintptr_t)ox,
+		(uintptr_t)cur, (uintptr_t)cur->held, 0);
 	}
 
 	return 0;
@@ -796,6 +801,9 @@ ohci_init(ohci_softc_t *sc)
 	for (i = 0; i < OHCI_HASH_SIZE; i++)
 		LIST_INIT(>sc_hash_itds[i]);
 
+	TAILQ_INIT(>sc_abortingxfers);
+	cv_init(>sc_abort_cv, "ohciabt");
+
 	sc->sc_xferpool = pool_cache_init(sizeof(struct ohci_xfer), 0, 0, 0,
 	"ohcixfer", NULL, IPL_USB, NULL, NULL, NULL);
 
@@ -1319,6 +1327,21 @@ ohci_intr1(ohci_softc_t *sc)
 		 */
 		usb_schedsoftintr(>sc_bus);
 	}
+	if (eintrs & OHCI_SF) {
+		struct ohci_xfer *ox, *tmp;
+		TAILQ_FOREACH_SAFE(ox, >sc_abortingxfers, ox_abnext, tmp) {
+			DPRINTFN(10, "SF %#jx xfer %#jx", (uintptr_t)sc,
+			(uintptr_t)ox, 0, 0);
+			ox->ox_abintrs &= ~OHCI_SF;
+			KASSERT(ox->ox_abintrs == 0);
+			TAILQ_REMOVE(>sc_abortingxfers, ox, ox_abnext);
+		}
+		cv_broadcast(>sc_abort_cv);
+
+		KASSERT(TAILQ_EMPTY(>sc_abortingxfers));
+		DPRINTFN(10, "end SOF %#jx", (uintptr_t)sc, 0, 0, 0);
+		/* Don't remove OHIC_SF from eintrs so it is blocked below */
+	}
 	if (eintrs & OHCI_RD) {
 		DPRINTFN(5, "resume detect sc=%#jx", (uintptr_t)sc, 0, 0, 0);
 		printf("%s: resume detect\n", device_xname(sc->sc_dev));
@@ -1395,12 +1418,22 @@ ohci_softintr(void *v)
 	struct ohci_pipe *opipe;
 	int len, cc;
 	int i, j, actlen, iframes, uedir;
-	ohci_physaddr_t done;
+	ohci_physaddr_t done = 0;
 
 	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock));
 
 	OHCIHIST_FUNC(); OHCIHIST_CALLED();
 
+	/*
+	 * Only read hccadone if WDH is set - we might get here from places
+	 * other than an interrupt
+	 */
+	if (!(OREAD4(sc, OHCI_INTERRUPT_STATUS) & OHCI_WDH)) {
+		DPRINTFN(10, "no WDH %#jx", (uintptr_t)sc, 0, 0, 0);
+		return;
+	}
+
+	DPRINTFN(10, "WDH %#jx", (uintptr_t)sc, 0, 0, 0);
 	usb_syncmem(>sc_hccadma, offsetof(struct ohci_hcca, hcca_done_head),
 	sizeof(sc->sc_hcca->hcca_done_head),
 	BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
@@ -1453,11 +1486,19 @@ ohci_softintr(void *v)
 	DPRINTFN(10, "--- TD dump end ---", 0, 0, 0, 0);
 
 	for (std = sdone; std; std = stdnext) {
-		xfer = std->xfer;
 		stdnext = std->dnext;
-		DPRINTFN(10, "std=%#jx xfer=%#jx 

CVS commit: [netbsd-9] src/sys/dev/fdt

2020-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 12 13:03:47 UTC 2020

Modified Files:
src/sys/dev/fdt [netbsd-9]: pwm_backlight.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1149):

sys/dev/fdt/pwm_backlight.c: revision 1.7

save the new current level when set by the user.

stops PBP display from going back to default brightness after
dpms, etc.

ok jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.4.10.1 -r1.4.10.2 src/sys/dev/fdt/pwm_backlight.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/fdt/pwm_backlight.c
diff -u src/sys/dev/fdt/pwm_backlight.c:1.4.10.1 src/sys/dev/fdt/pwm_backlight.c:1.4.10.2
--- src/sys/dev/fdt/pwm_backlight.c:1.4.10.1	Tue Jan 21 10:39:58 2020
+++ src/sys/dev/fdt/pwm_backlight.c	Sat Dec 12 13:03:46 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pwm_backlight.c,v 1.4.10.1 2020/01/21 10:39:58 martin Exp $ */
+/* $NetBSD: pwm_backlight.c,v 1.4.10.2 2020/12/12 13:03:46 martin Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pwm_backlight.c,v 1.4.10.1 2020/01/21 10:39:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pwm_backlight.c,v 1.4.10.2 2020/12/12 13:03:46 martin Exp $");
 
 #include 
 #include 
@@ -60,7 +60,7 @@ static void	pwm_backlight_attach(device_
 
 static void	pwm_backlight_sysctl_init(struct pwm_backlight_softc *);
 static void	pwm_backlight_pmf_init(struct pwm_backlight_softc *);
-static void	pwm_backlight_set(struct pwm_backlight_softc *, u_int);
+static void	pwm_backlight_set(struct pwm_backlight_softc *, u_int, bool);
 static u_int	pwm_backlight_get(struct pwm_backlight_softc *);
 
 static const char *compatible[] = {
@@ -129,7 +129,7 @@ pwm_backlight_attach(device_t parent, de
 
 	if (of_getprop_uint32(phandle, "default-brightness-level", _level) == 0) {
 		/* set the default level now */
-		pwm_backlight_set(sc, default_level);
+		pwm_backlight_set(sc, default_level, true);
 	}
 
 	sc->sc_curlevel = pwm_backlight_get(sc);
@@ -139,7 +139,7 @@ pwm_backlight_attach(device_t parent, de
 }
 
 static void
-pwm_backlight_set(struct pwm_backlight_softc *sc, u_int index)
+pwm_backlight_set(struct pwm_backlight_softc *sc, u_int index, bool set_cur)
 {
 	struct pwm_config conf;
 
@@ -153,6 +153,9 @@ pwm_backlight_set(struct pwm_backlight_s
 	conf.duty_cycle = (conf.period * sc->sc_levels[index]) / sc->sc_levels[sc->sc_nlevels - 1];
 	pwm_set_config(sc->sc_pwm, );
 	pwm_enable(sc->sc_pwm);
+
+	if (set_cur)
+		sc->sc_curlevel = index;
 }
 
 static u_int
@@ -193,7 +196,7 @@ pwm_backlight_sysctl_helper(SYSCTLFN_ARG
 
 	for (n = 0; n < sc->sc_nlevels; n++) {
 		if (sc->sc_levels[n] == level) {
-			pwm_backlight_set(sc, n);
+			pwm_backlight_set(sc, n, true);
 			return 0;
 		}
 	}
@@ -255,7 +258,7 @@ pwm_backlight_enable(struct pwm_backligh
 	if (sc->sc_pin)
 		fdtbus_gpio_write(sc->sc_pin, enable);
 	else
-		pwm_backlight_set(sc, enable ? sc->sc_curlevel : 0);
+		pwm_backlight_set(sc, enable ? sc->sc_curlevel : 0, false);
 }
 
 static void
@@ -303,7 +306,7 @@ pwm_backlight_display_brightness_up(devi
 
 	n = pwm_backlight_get(sc);
 	if (n < sc->sc_nlevels - 1)
-		pwm_backlight_set(sc, n + 1);
+		pwm_backlight_set(sc, n + 1, true);
 }
 
 static void
@@ -314,7 +317,7 @@ pwm_backlight_display_brightness_down(de
 
 	n = pwm_backlight_get(sc);
 	if (n > 0)
-		pwm_backlight_set(sc, n - 1);
+		pwm_backlight_set(sc, n - 1, true);
 }
 
 static void



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

2020-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 12 12:56:40 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-9]: ucom.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1147):

sys/dev/usb/ucom.c: revision 1.128

properly wait for refcounts to drain.
fixes panic at detach that jmnceill saw.

XXX: pullup-[89].


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.125.2.1 src/sys/dev/usb/ucom.c

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

Modified files:

Index: src/sys/dev/usb/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.125 src/sys/dev/usb/ucom.c:1.125.2.1
--- src/sys/dev/usb/ucom.c:1.125	Thu May  9 02:43:35 2019
+++ src/sys/dev/usb/ucom.c	Sat Dec 12 12:56:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.125 2019/05/09 02:43:35 mrg Exp $	*/
+/*	$NetBSD: ucom.c,v 1.125.2.1 2020/12/12 12:56:40 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.125 2019/05/09 02:43:35 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.125.2.1 2020/12/12 12:56:40 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -434,7 +434,7 @@ ucom_detach(device_t self, int flags)
 	}
 
 	sc->sc_refcnt--;
-	while (sc->sc_refcnt > 0) {
+	while (sc->sc_refcnt >= 0) {
 		/* Wake up anyone waiting */
 		if (tp != NULL) {
 			mutex_spin_enter(_lock);



  1   2   3   4   5   6   >