Re: CVS commit: src/sys/kern

2020-05-06 Thread Michael van Elst
On Wed, May 06, 2020 at 12:39:21PM +0200, Kamil Rytarowski wrote:

Hi Kamil,

> If I revert the pipe(2) changes on top of NetBSD-current, the test is no
> longer racy again.

I tried 9.99.60 with and without my bugfix. The test always failed
after some time with exactly that error.

If the change really had an effect, there would be a use-after-free bug
somewhere else.


Greetings,
-- 
    Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


CVS commit: src/sys/arch/aarch64

2019-11-21 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Nov 22 05:21:19 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c cpufunc.c locore.S
src/sys/arch/aarch64/include: cpufunc.h

Log Message:
Make cache operations available early.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/aarch64/cpufunc.c
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/include/cpufunc.h

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



CVS commit: src/sys/arch/aarch64

2019-11-21 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Nov 22 05:21:19 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c cpufunc.c locore.S
src/sys/arch/aarch64/include: cpufunc.h

Log Message:
Make cache operations available early.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/aarch64/cpufunc.c
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/include/cpufunc.h

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.25 src/sys/arch/aarch64/aarch64/cpu.c:1.26
--- src/sys/arch/aarch64/aarch64/cpu.c:1.25	Sun Oct 20 14:03:51 2019
+++ src/sys/arch/aarch64/aarch64/cpu.c	Fri Nov 22 05:21:19 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.25 2019/10/20 14:03:51 jmcneill Exp $ */
+/* $NetBSD: cpu.c,v 1.26 2019/11/22 05:21:19 mlelstv Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.25 2019/10/20 14:03:51 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.26 2019/11/22 05:21:19 mlelstv Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -102,7 +102,6 @@ cpu_attach(device_t dv, cpuid_t id)
 {
 	struct cpu_info *ci;
 	const int unit = device_unit(dv);
-	uint64_t mpidr;
 
 	if (unit == 0) {
 		ci = curcpu();
@@ -142,19 +141,11 @@ cpu_attach(device_t dv, cpuid_t id)
 #endif /* MULTIPROCESSOR */
 	}
 
-	mpidr = ci->ci_id.ac_mpidr;
-	if (mpidr & MPIDR_MT) {
-		ci->ci_smt_id = __SHIFTOUT(mpidr, MPIDR_AFF0);
-		ci->ci_core_id = __SHIFTOUT(mpidr, MPIDR_AFF1);
-		ci->ci_package_id = __SHIFTOUT(mpidr, MPIDR_AFF2);
-	} else {
-		ci->ci_core_id = __SHIFTOUT(mpidr, MPIDR_AFF0);
-		ci->ci_package_id = __SHIFTOUT(mpidr, MPIDR_AFF1);
-	}
-
 	ci->ci_dev = dv;
 	dv->dv_private = ci;
 
+	aarch64_gettopology(ci, ci->ci_id.ac_mpidr);
+
 	cpu_identify(ci->ci_dev, ci);
 #ifdef MULTIPROCESSOR
 	if (unit != 0) {
@@ -167,7 +158,10 @@ cpu_attach(device_t dv, cpuid_t id)
 	fpu_attach(ci);
 
 	cpu_identify1(dv, ci);
-	aarch64_getcacheinfo();
+#if 0
+	/* already done in locore */
+	aarch64_getcacheinfo(unit); 
+#endif
 	aarch64_printcacheinfo(dv);
 	cpu_identify2(dv, ci);
 
@@ -539,7 +533,7 @@ cpu_hatch(struct cpu_info *ci)
 	fpu_attach(ci);
 
 	cpu_identify1(ci->ci_dev, ci);
-	aarch64_getcacheinfo();
+	aarch64_getcacheinfo(device_unit(ci->ci_dev));
 	aarch64_printcacheinfo(ci->ci_dev);
 	cpu_identify2(ci->ci_dev, ci);
 

Index: src/sys/arch/aarch64/aarch64/cpufunc.c
diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.7 src/sys/arch/aarch64/aarch64/cpufunc.c:1.8
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.7	Tue Oct  1 18:00:07 2019
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Fri Nov 22 05:21:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.7 2019/10/01 18:00:07 chs Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.8 2019/11/22 05:21:19 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -29,7 +29,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.7 2019/10/01 18:00:07 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.8 2019/11/22 05:21:19 mlelstv Exp $");
 
 #include 
 #include 
@@ -49,6 +49,7 @@ u_int aarch64_cache_prefer_mask;
 /* cache info per cluster. the same cluster has the same cache configuration? */
 #define MAXCPUPACKAGES	MAXCPUS		/* maximum of ci->ci_package_id */
 static struct aarch64_cache_info *aarch64_cacheinfo[MAXCPUPACKAGES];
+static struct aarch64_cache_info aarch64_cacheinfo0;
 
 
 static void
@@ -88,27 +89,46 @@ extract_cacheunit(int level, bool insn, 
 }
 
 void
-aarch64_getcacheinfo(void)
+aarch64_gettopology(struct cpu_info * const ci, uint64_t mpidr)
 {
+
+	if (mpidr & MPIDR_MT) {
+		ci->ci_smt_id = __SHIFTOUT(mpidr, MPIDR_AFF0);
+		ci->ci_core_id = __SHIFTOUT(mpidr, MPIDR_AFF1);
+		ci->ci_package_id = __SHIFTOUT(mpidr, MPIDR_AFF2);
+	} else {
+		ci->ci_core_id = __SHIFTOUT(mpidr, MPIDR_AFF0);
+		ci->ci_package_id = __SHIFTOUT(mpidr, MPIDR_AFF1);
+	}
+}
+
+void
+aarch64_getcacheinfo(int unit)
+{
+	struct cpu_info * const ci = curcpu();
 	uint32_t clidr, ctr;
 	int level, cachetype;
-	struct aarch64_cache_info *cinfo;
+	struct aarch64_cache_info *cinfo = NULL;
 
 	if (cputype == 0)
 		cputype = aarch64_cpuid();
 
 	/* already extract about this cluster? */
-	KASSERT(curcpu()->ci_package_id < MAXCPUPACKAGES);
-	cinfo = aarch64_cacheinfo[curcpu()->ci_package_id];
+	KASSERT(ci->ci_package_id < MAXCPUPACKAGES);
+	cinfo = aarch64_cacheinfo[ci->ci_package_id];
 	if (cinfo != NULL) {
-		curcpu()->ci_cacheinfo = cinfo;
+		ci->ci_cacheinfo = cinfo;
 		return;
 	}
 
-	cinfo = aarch64_cacheinfo[curcpu()->ci_package_id] =
-	kmem_zalloc(sizeof(struct aarch64_cache_info) * MAX_CACHE_LEVEL,
-	KM_SLEEP);
-	curcpu()->ci_cacheinfo = cinfo;
+	/* 

CVS commit: src/sys/netinet

2019-11-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 17 08:21:25 UTC 2019

Modified Files:
src/sys/netinet: tcp_output.c

Log Message:
Don't allow zero sized segments that will panic the stack.
Reported-by: syzbot+5542516fa4afe7a10...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/sys/netinet/tcp_output.c

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



CVS commit: src/sys/netinet

2019-11-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 17 08:21:25 UTC 2019

Modified Files:
src/sys/netinet: tcp_output.c

Log Message:
Don't allow zero sized segments that will panic the stack.
Reported-by: syzbot+5542516fa4afe7a10...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/sys/netinet/tcp_output.c

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

Modified files:

Index: src/sys/netinet/tcp_output.c
diff -u src/sys/netinet/tcp_output.c:1.211 src/sys/netinet/tcp_output.c:1.212
--- src/sys/netinet/tcp_output.c:1.211	Mon Feb 25 10:49:16 2019
+++ src/sys/netinet/tcp_output.c	Sun Nov 17 08:21:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_output.c,v 1.211 2019/02/25 10:49:16 maxv Exp $	*/
+/*	$NetBSD: tcp_output.c,v 1.212 2019/11/17 08:21:25 mlelstv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -135,7 +135,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.211 2019/02/25 10:49:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.212 2019/11/17 08:21:25 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -252,6 +252,7 @@ tcp_segsize(struct tcpcb *tp, int *txseg
 		break;
 #endif
 	default:
+		hdrlen = 1; /* prevent zero sized segments */
 		goto out;
 	}
 
@@ -386,6 +387,13 @@ tcp_segsize(struct tcpcb *tp, int *txseg
 		*txsegsizep = uimin(so->so_snd.sb_hiwat >> 1, *txsegsizep);
 	}
 
+	/*
+	 * A segment must at least store header + options
+	 */
+	if (*txsegsizep < hdrlen + optlen) {
+		return EMSGSIZE;
+	}
+
 	if (*txsegsizep != tp->t_segsz) {
 		/*
 		 * If the new segment size is larger, we don't want to



CVS commit: src/share/man/man9

2019-11-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 16 22:09:56 UTC 2019

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

Log Message:
Document new functions vn_bdev_open and vn_bdev_openpath.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/share/man/man9/vnsubr.9

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

Modified files:

Index: src/share/man/man9/vnsubr.9
diff -u src/share/man/man9/vnsubr.9:1.45 src/share/man/man9/vnsubr.9:1.46
--- src/share/man/man9/vnsubr.9:1.45	Thu Jan  5 09:54:03 2017
+++ src/share/man/man9/vnsubr.9	Sat Nov 16 22:09:56 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: vnsubr.9,v 1.45 2017/01/05 09:54:03 wiz Exp $
+.\" $NetBSD: vnsubr.9,v 1.46 2019/11/16 22:09:56 mlelstv Exp $
 .\"
 .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -41,6 +41,8 @@
 .Nm vn_marktext ,
 .Nm vn_rdwr ,
 .Nm vn_open ,
+.Nm vn_bdev_open ,
+.Nm vn_bdev_openpath ,
 .Nm vn_stat ,
 .Nm vn_writechk
 .Nd high-level convenience functions for vnode operations
@@ -65,6 +67,10 @@
 .Ft int
 .Fn vn_open "struct nameidata *ndp" "int fmode" "int cmode"
 .Ft int
+.Fn vn_bdev_open "dev_t dev" "struct vnode **vpp" "struct lwp *l"
+.Ft int
+.Fn vn_bdev_openpath "struct pathbuf *pb" "struct vnode **vpp" "struct lwp *l"
+.Ft int
 .Fo vn_rdwr
 .Fa "enum uio_rw rw" "struct vnode *vp" "void *base"
 .Fa "int len" "off_t offset" "enum uio_seg segflg" "int ioflg"
@@ -173,6 +179,20 @@ or
 vnode operations.
 If the operation is successful zero is returned and the vnode is locked,
 otherwise an appropriate error code is returned.
+.It Fn vn_bdev_open "dev" "vpp" "l"
+Opens a block device by its device number for reading and writing, and
+stores the vnode pointer into
+.Fa *vpp .
+The argument
+.Fa l
+is the calling process. The vnode can be closed and freed with
+.Fa vn_close .
+.It Fn vn_bdev_openpath "pb" "vpp" "l"
+Works like
+.Fn vn_bdev_open
+but looks up a filesystem path
+.Fa pb
+to determine the device ID.
 .It Fn vn_rdwr "rw" "vp" "base" "len" "offset" "segflg" "ioflg" "cred" "aresid" "l"
 Common code to package up an I/O request on a vnode into a uio and
 then perform the I/O.



CVS commit: src/share/man/man9

2019-11-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 16 22:09:56 UTC 2019

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

Log Message:
Document new functions vn_bdev_open and vn_bdev_openpath.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/share/man/man9/vnsubr.9

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



CVS commit: src/sys/dev/bluetooth

2019-11-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 16 22:06:50 UTC 2019

Modified Files:
src/sys/dev/bluetooth: bth5.c

Log Message:
Don't wait in interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/bluetooth/bth5.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/bluetooth/bth5.c
diff -u src/sys/dev/bluetooth/bth5.c:1.5 src/sys/dev/bluetooth/bth5.c:1.6
--- src/sys/dev/bluetooth/bth5.c:1.5	Sun Sep  3 23:11:19 2017
+++ src/sys/dev/bluetooth/bth5.c	Sat Nov 16 22:06:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bth5.c,v 1.5 2017/09/03 23:11:19 nat Exp $	*/
+/*	$NetBSD: bth5.c,v 1.6 2019/11/16 22:06:49 mlelstv Exp $	*/
 /*
  * Copyright (c) 2017 Nathanial Sloss 
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.5 2017/09/03 23:11:19 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.6 2019/11/16 22:06:49 mlelstv Exp $");
 
 #include 
 #include 
@@ -1230,7 +1230,7 @@ bth5_tx_reliable_pkt(struct bth5_softc *
 #endif
 
 	sc->sc_seq_winspace--;
-	_retrans = m_copym(m, 0, M_COPYALL, M_WAIT);
+	_retrans = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
 	if (_retrans == NULL) {
 		aprint_error_dev(sc->sc_dev, "out of memory\n");
 		goto out;
@@ -1488,7 +1488,12 @@ bth5_start_le(struct bth5_softc *sc)
 	if (!sc->sc_le_muzzled) {
 		struct mbuf *m;
 
-		m = m_gethdr(M_WAIT, MT_DATA);
+		m = m_gethdr(M_DONTWAIT, MT_DATA);
+		if (m == NULL) {
+			aprint_error_dev(sc->sc_dev,
+			"le-packet transmit out of memory\n");
+			return ENOMEM;
+		}
 		m->m_pkthdr.len = m->m_len = 0;
 		m_copyback(m, 0, sizeof(sync), sync);
 		if (!bth5_tx_unreliable_pkt(sc, m, BTH5_CHANNEL_LE)) {



CVS commit: src/sys/dev/bluetooth

2019-11-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 16 22:06:50 UTC 2019

Modified Files:
src/sys/dev/bluetooth: bth5.c

Log Message:
Don't wait in interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/bluetooth/bth5.c

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



CVS commit: src/sys/dev/fdt

2019-11-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 16 21:53:38 UTC 2019

Modified Files:
src/sys/dev/fdt: fdt_intr.c

Log Message:
be more verbose about errors.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/fdt/fdt_intr.c

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



CVS commit: src/sys/dev/fdt

2019-11-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 16 21:53:38 UTC 2019

Modified Files:
src/sys/dev/fdt: fdt_intr.c

Log Message:
be more verbose about errors.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/fdt/fdt_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/dev/fdt/fdt_intr.c
diff -u src/sys/dev/fdt/fdt_intr.c:1.22 src/sys/dev/fdt/fdt_intr.c:1.23
--- src/sys/dev/fdt/fdt_intr.c:1.22	Fri Jun 14 11:08:18 2019
+++ src/sys/dev/fdt/fdt_intr.c	Sat Nov 16 21:53:38 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_intr.c,v 1.22 2019/06/14 11:08:18 hkenken Exp $ */
+/* $NetBSD: fdt_intr.c,v 1.23 2019/11/16 21:53:38 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.22 2019/06/14 11:08:18 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.23 2019/11/16 21:53:38 mlelstv Exp $");
 
 #include 
 #include 
@@ -138,8 +138,10 @@ fdtbus_intr_establish(int phandle, u_int
 	int ihandle;
 
 	specifier = get_specifier_by_index(phandle, index, );
-	if (specifier == NULL)
+	if (specifier == NULL) {
+		printf("%s: handle not found %u@%x\n",__func__,index,phandle);
 		return NULL;
+	}
 
 	return fdtbus_intr_establish_raw(ihandle, specifier, ipl,
 	flags, func, arg);
@@ -168,8 +170,10 @@ fdtbus_intr_establish_raw(int ihandle, c
 	void *ih;
 
 	ic = fdtbus_get_interrupt_controller(ihandle);
-	if (ic == NULL)
+	if (ic == NULL) {
+		printf("%s: ihandle %d is not a controller\n",__func__,ihandle);
 		return NULL;
+	}
 
 	ih = ic->ic_funcs->establish(ic->ic_dev, __UNCONST(specifier),
 	ipl, flags, func, arg);



CVS commit: src/sys

2019-11-09 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 10 06:47:30 UTC 2019

Modified Files:
src/sys/kern: vfs_vnops.c
src/sys/sys: vnode.h

Log Message:
Add functions to open devices by device number or path.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.282 -r1.283 src/sys/sys/vnode.h

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



CVS commit: src/sys

2019-11-09 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 10 06:47:30 UTC 2019

Modified Files:
src/sys/kern: vfs_vnops.c
src/sys/sys: vnode.h

Log Message:
Add functions to open devices by device number or path.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.282 -r1.283 src/sys/sys/vnode.h

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

Modified files:

Index: src/sys/kern/vfs_vnops.c
diff -u src/sys/kern/vfs_vnops.c:1.201 src/sys/kern/vfs_vnops.c:1.202
--- src/sys/kern/vfs_vnops.c:1.201	Sun Sep 15 20:24:25 2019
+++ src/sys/kern/vfs_vnops.c	Sun Nov 10 06:47:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnops.c,v 1.201 2019/09/15 20:24:25 christos Exp $	*/
+/*	$NetBSD: vfs_vnops.c,v 1.202 2019/11/10 06:47:30 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.201 2019/09/15 20:24:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.202 2019/11/10 06:47:30 mlelstv Exp $");
 
 #include "veriexec.h"
 
@@ -1189,3 +1189,56 @@ vn_fifo_bypass(void *v)
 
 	return VOCALL(fifo_vnodeop_p, ap->a_desc->vdesc_offset, v);
 }
+
+/*
+ * Open block device by device number
+ */
+int
+vn_bdev_open(dev_t dev, struct vnode **vpp, struct lwp *l)
+{
+	int error;
+
+	if ((error = bdevvp(dev, vpp)) != 0)
+		return error;
+
+	if ((error = VOP_OPEN(*vpp, FREAD | FWRITE, l->l_cred)) != 0) {
+		vrele(*vpp);
+		return error;
+	}
+	mutex_enter((*vpp)->v_interlock);
+	(*vpp)->v_writecount++;
+	mutex_exit((*vpp)->v_interlock);
+
+	return 0;
+}
+
+/*
+ * Lookup the provided name in the filesystem.  If the file exists,
+ * is a valid block device, and isn't being used by anyone else,
+ * set *vpp to the file's vnode.
+ */
+int
+vn_bdev_openpath(struct pathbuf *pb, struct vnode **vpp, struct lwp *l)
+{
+	struct nameidata nd;
+	struct vnode *vp;
+	dev_t dev;
+	enum vtype vt;
+	int error;
+
+	NDINIT(, LOOKUP, FOLLOW, pb);
+	if ((error = vn_open(, FREAD | FWRITE, 0)) != 0)
+		return error;
+
+	vp = nd.ni_vp;
+	dev = vp->v_rdev;
+	vt = vp->v_type;
+
+	VOP_UNLOCK(vp);
+	(void) vn_close(vp, FREAD | FWRITE, l->l_cred);
+
+	if (vt != VBLK)
+		return ENOTBLK;
+
+	return vn_bdev_open(dev, vpp, l);
+}

Index: src/sys/sys/vnode.h
diff -u src/sys/sys/vnode.h:1.282 src/sys/sys/vnode.h:1.283
--- src/sys/sys/vnode.h:1.282	Thu Sep 26 20:57:19 2019
+++ src/sys/sys/vnode.h	Sun Nov 10 06:47:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnode.h,v 1.282 2019/09/26 20:57:19 christos Exp $	*/
+/*	$NetBSD: vnode.h,v 1.283 2019/11/10 06:47:30 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -490,6 +490,7 @@ struct vop_generic_args {
 struct file;
 struct filedesc;
 struct nameidata;
+struct pathbuf;
 struct proc;
 struct stat;
 struct uio;
@@ -550,6 +551,9 @@ int	vn_extattr_set(struct vnode *, int, 
 int	vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *);
 void	vn_ra_allocctx(struct vnode *);
 int	vn_fifo_bypass(void *);
+int	vn_bdev_open(dev_t, struct vnode **, struct lwp *);
+int	vn_bdev_openpath(struct pathbuf *pb, struct vnode **, struct lwp *);
+
 
 #ifdef DIAGNOSTIC
 static __inline bool



CVS commit: src/sys/dev

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:37:52 UTC 2019

Modified Files:
src/sys/dev/ic: bwfm.c bwfmreg.h bwfmvar.h
src/sys/dev/sdmmc: if_bwfm_sdio.c

Log Message:
More code from OpenBSD
no need to splnet() when enqueing packets
explicit structure padding
make internal functions static

also prepare for GPIO interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/bwfm.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/bwfmreg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/bwfmvar.h
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/sdmmc/if_bwfm_sdio.c

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



CVS commit: src/sys/dev

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:37:52 UTC 2019

Modified Files:
src/sys/dev/ic: bwfm.c bwfmreg.h bwfmvar.h
src/sys/dev/sdmmc: if_bwfm_sdio.c

Log Message:
More code from OpenBSD
no need to splnet() when enqueing packets
explicit structure padding
make internal functions static

also prepare for GPIO interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/bwfm.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/bwfmreg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/bwfmvar.h
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/sdmmc/if_bwfm_sdio.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/bwfm.c
diff -u src/sys/dev/ic/bwfm.c:1.17 src/sys/dev/ic/bwfm.c:1.18
--- src/sys/dev/ic/bwfm.c:1.17	Thu Oct  3 14:42:20 2019
+++ src/sys/dev/ic/bwfm.c	Mon Oct 28 06:37:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.17 2019/10/03 14:42:20 jmcneill Exp $ */
+/* $NetBSD: bwfm.c,v 1.18 2019/10/28 06:37:51 mlelstv Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -345,6 +345,7 @@ bwfm_init(struct ifnet *ifp)
 	struct ieee80211com *ic = >sc_ic;
 	uint8_t evmask[BWFM_EVENT_MASK_LEN];
 	struct bwfm_join_pref_params join_pref[2];
+	int pm;
 
 	if (bwfm_fwvar_var_set_int(sc, "mpc", 1)) {
 		printf("%s: could not set mpc\n", DEVNAME(sc));
@@ -370,10 +371,31 @@ bwfm_init(struct ifnet *ifp)
 
 #define	ENABLE_EVENT(e)		evmask[(e) / 8] |= 1 << ((e) % 8)
 	/* Events used to drive the state machine */
-	ENABLE_EVENT(BWFM_E_ASSOC);
-	ENABLE_EVENT(BWFM_E_ESCAN_RESULT);
-	ENABLE_EVENT(BWFM_E_SET_SSID);
-	ENABLE_EVENT(BWFM_E_LINK);
+	switch (ic->ic_opmode) {
+	case IEEE80211_M_STA:
+		ENABLE_EVENT(BWFM_E_IF);
+		ENABLE_EVENT(BWFM_E_LINK);
+		ENABLE_EVENT(BWFM_E_AUTH);
+		ENABLE_EVENT(BWFM_E_ASSOC);
+		ENABLE_EVENT(BWFM_E_DEAUTH);
+		ENABLE_EVENT(BWFM_E_DISASSOC);
+		ENABLE_EVENT(BWFM_E_SET_SSID);
+		ENABLE_EVENT(BWFM_E_ESCAN_RESULT);
+		break;
+#ifndef IEEE80211_STA_ONLY
+	case IEEE80211_M_HOSTAP:
+		ENABLE_EVENT(BWFM_E_AUTH_IND);
+		ENABLE_EVENT(BWFM_E_ASSOC_IND);
+		ENABLE_EVENT(BWFM_E_REASSOC_IND);
+		ENABLE_EVENT(BWFM_E_DEAUTH_IND);
+		ENABLE_EVENT(BWFM_E_DISASSOC_IND);
+		ENABLE_EVENT(BWFM_E_ESCAN_RESULT);
+		ENABLE_EVENT(BWFM_E_ESCAN_RESULT);
+		break;
+#endif
+	default:
+		break;
+	}
 #undef	ENABLE_EVENT
 
 #ifdef BWFM_DEBUG
@@ -401,7 +423,16 @@ bwfm_init(struct ifnet *ifp)
 		return EIO;
 	}
 
-	if (bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_PM, 2)) {
+/*
+ * Use CAM (constantly awake) when we are running as AP
+ * otherwise use fast power saving.
+ */
+	pm = BWFM_PM_FAST_PS;
+#ifndef IEEE80211_STA_ONLY
+	if (ic->ic_opmode == IEEE80211_M_HOSTAP)
+		pm = BWFM_PM_CAM;
+#endif
+	if (bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_PM, pm)) {
 		printf("%s: could not set power\n", DEVNAME(sc));
 		return EIO;
 	}
@@ -448,15 +479,25 @@ bwfm_stop(struct ifnet *ifp, int disable
 {
 	struct bwfm_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = >sc_ic;
+	struct bwfm_join_params join;
 
 	sc->sc_tx_timer = 0;
 	ifp->if_timer = 0;
 	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
 
+	memset(, 0, sizeof(join));
+	bwfm_fwvar_cmd_set_data(sc, BWFM_C_SET_SSID, , sizeof(join));
 	bwfm_fwvar_cmd_set_int(sc, BWFM_C_DOWN, 1);
 	bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_PM, 0);
+	bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_AP, 0);
+	bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_INFRA, 0);
+	bwfm_fwvar_cmd_set_int(sc, BWFM_C_UP, 1);
+	bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_PM, BWFM_PM_FAST_PS);
 
 	ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
+
+	if (sc->sc_bus_ops->bs_stop)
+		sc->sc_bus_ops->bs_stop(sc);
 }
 
 void
@@ -606,7 +647,7 @@ bwfm_key_set_cb(struct bwfm_softc *sc, s
 	wsec_key.len = htole32(wk->wk_keylen);
 	memcpy(wsec_key.data, wk->wk_key, sizeof(wsec_key.data));
 	if (!ext_key)
-		wsec_key.flags = htole32(BWFM_PRIMARY_KEY);
+		wsec_key.flags = htole32(BWFM_WSEC_PRIMARY_KEY);
 
 	switch (wk->wk_cipher->ic_cipher) {
 	case IEEE80211_CIPHER_WEP:
@@ -670,7 +711,7 @@ bwfm_key_delete_cb(struct bwfm_softc *sc
 
 	memset(_key, 0, sizeof(wsec_key));
 	wsec_key.index = htole32(wk->wk_keyix);
-	wsec_key.flags = htole32(BWFM_PRIMARY_KEY);
+	wsec_key.flags = htole32(BWFM_WSEC_PRIMARY_KEY);
 
 	if (bwfm_fwvar_var_set_data(sc, "wsec_key", _key, sizeof(wsec_key)))
 		return;
@@ -1452,10 +1493,10 @@ bwfm_proto_bcdc_query_dcmd(struct bwfm_s
 {
 	struct bwfm_proto_bcdc_dcmd *dcmd;
 	size_t size = sizeof(dcmd->hdr) + *len;
-	static int reqid = 0;
+	int reqid;
 	int ret = 1;
 
-	reqid++;
+	reqid = sc->sc_bcdc_reqid++;
 
 	dcmd = kmem_zalloc(sizeof(*dcmd), KM_SLEEP);
 	if (*len > sizeof(dcmd->buf))
@@ -1512,10 +1553,9 @@ bwfm_proto_bcdc_set_dcmd(struct bwfm_sof
 {
 	struct bwfm_proto_bcdc_dcmd *dcmd;
 	size_t size = sizeof(dcmd->hdr) + len;
-	int reqid = 0;
-	int ret = 1;
+	int ret = 1, reqid;
 
-	reqid++;
+	

CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:31:39 UTC 2019

Modified Files:
src/sys/dev/sdmmc: ld_sdmmc.c sdmmc_cis.c sdmmc_mem.c sdmmcdevs

Log Message:
Whitespace police


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/sdmmc/ld_sdmmc.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/sdmmc_cis.c
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/sdmmc/sdmmc_mem.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmcdevs

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

Modified files:

Index: src/sys/dev/sdmmc/ld_sdmmc.c
diff -u src/sys/dev/sdmmc/ld_sdmmc.c:1.36 src/sys/dev/sdmmc/ld_sdmmc.c:1.37
--- src/sys/dev/sdmmc/ld_sdmmc.c:1.36	Tue Mar 19 07:08:43 2019
+++ src/sys/dev/sdmmc/ld_sdmmc.c	Mon Oct 28 06:31:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_sdmmc.c,v 1.36 2019/03/19 07:08:43 mlelstv Exp $	*/
+/*	$NetBSD: ld_sdmmc.c,v 1.37 2019/10/28 06:31:39 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.36 2019/03/19 07:08:43 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.37 2019/10/28 06:31:39 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -460,7 +460,7 @@ MODULE(MODULE_CLASS_DRIVER, ld_sdmmc, "l
  */
 #undef  CFDRIVER_DECL
 #define CFDRIVER_DECL(name, class, attr)
-#include "ioconf.c"
+#include "ioconf.c"
 #endif
 
 static int
@@ -474,13 +474,13 @@ ld_sdmmc_modcmd(modcmd_t cmd, void *opaq
 	static struct cfdriver * const no_cfdriver_vec[] = { NULL };
 #endif
 	int error = 0;
- 
+
 #ifdef _MODULE
 	switch (cmd) {
 	case MODULE_CMD_INIT:
 		error = config_init_component(no_cfdriver_vec,
 		cfattach_ioconf_ld_sdmmc, cfdata_ioconf_ld_sdmmc);
-	break;
+		break;
 	case MODULE_CMD_FINI:
 		error = config_fini_component(no_cfdriver_vec,
 		cfattach_ioconf_ld_sdmmc, cfdata_ioconf_ld_sdmmc);

Index: src/sys/dev/sdmmc/sdmmc_cis.c
diff -u src/sys/dev/sdmmc/sdmmc_cis.c:1.7 src/sys/dev/sdmmc/sdmmc_cis.c:1.8
--- src/sys/dev/sdmmc/sdmmc_cis.c:1.7	Tue Sep 24 04:56:54 2019
+++ src/sys/dev/sdmmc/sdmmc_cis.c	Mon Oct 28 06:31:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_cis.c,v 1.7 2019/09/24 04:56:54 mlelstv Exp $	*/
+/*	$NetBSD: sdmmc_cis.c,v 1.8 2019/10/28 06:31:39 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc_cis.c,v 1.1 2006/06/01 21:53:41 uwe Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Routines to decode the Card Information Structure of SD I/O cards */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.7 2019/09/24 04:56:54 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.8 2019/10/28 06:31:39 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -202,7 +202,7 @@ sdmmc_read_cis(struct sdmmc_function *sf
 		}
 
 #ifdef SDMMCCISDEBUG
-		{ 
+		{
 			int i;
 
 			/* print the tuple */
@@ -317,7 +317,7 @@ sdmmc_check_cis_quirks(struct sdmmc_func
 	if (sf->cis.manufacturer == SDMMC_VENDOR_SPECTEC &&
 	sf->cis.product == SDMMC_PRODUCT_SPECTEC_SDW820) {
 		/* This card lacks the VERS_1 tuple. */
-		static const char cis1_info[] = 
+		static const char cis1_info[] =
 		"Spectec\0SDIO WLAN Card\0SDW-820\0\0";
 
 		sf->cis.cis1_major = 0x01;

Index: src/sys/dev/sdmmc/sdmmc_mem.c
diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.69 src/sys/dev/sdmmc/sdmmc_mem.c:1.70
--- src/sys/dev/sdmmc/sdmmc_mem.c:1.69	Mon Oct 28 06:16:46 2019
+++ src/sys/dev/sdmmc/sdmmc_mem.c	Mon Oct 28 06:31:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_mem.c,v 1.69 2019/10/28 06:16:46 mlelstv Exp $	*/
+/*	$NetBSD: sdmmc_mem.c,v 1.70 2019/10/28 06:31:39 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $	*/
 
 /*
@@ -45,7 +45,7 @@
 /* Routines for SD/MMC memory cards. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.69 2019/10/28 06:16:46 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.70 2019/10/28 06:31:39 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -771,7 +771,7 @@ sdmmc_mem_execute_tuning(struct sdmmc_so
 			break;
 		case 208000:
 			timing = SDMMC_TIMING_UHS_SDR104;
-			break; 
+			break;
 		default:
 			return 0;
 		}

Index: src/sys/dev/sdmmc/sdmmcdevs
diff -u src/sys/dev/sdmmc/sdmmcdevs:1.6 src/sys/dev/sdmmc/sdmmcdevs:1.7
--- src/sys/dev/sdmmc/sdmmcdevs:1.6	Sat Aug 24 11:24:00 2019
+++ src/sys/dev/sdmmc/sdmmcdevs	Mon Oct 28 06:31:39 2019
@@ -1,4 +1,4 @@
-	$NetBSD: sdmmcdevs,v 1.6 2019/08/24 11:24:00 mlelstv Exp $
+	$NetBSD: sdmmcdevs,v 1.7 2019/10/28 06:31:39 mlelstv Exp $
 /*	$OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $	*/
 
 /*
@@ -40,13 +40,13 @@ vendor ABOCOM			0x13d1	AboCom Systems, I
 /* AboCom Systems, Inc. */
 product ABOCOM SDW11G		0xac02	SDW11G
 
-/* Atheros */ 
+/* Atheros */
 product ATHEROS AR6001_8	0x0108	AR6001
 product ATHEROS AR6001_9	0x0109	AR6001
 product ATHEROS AR6001_a	0x010a	AR6001
 product ATHEROS AR6001_b	0x010b	AR6001
 
-/* Broadcom */ 
+/* Broadcom */
 product BROADCOM BCM4324	0x4324	

CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:32:11 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmcdevs.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmcdevs.h

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



CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:31:39 UTC 2019

Modified Files:
src/sys/dev/sdmmc: ld_sdmmc.c sdmmc_cis.c sdmmc_mem.c sdmmcdevs

Log Message:
Whitespace police


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/sdmmc/ld_sdmmc.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/sdmmc_cis.c
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/sdmmc/sdmmc_mem.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmcdevs

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



CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:32:11 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmcdevs.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmcdevs.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/sdmmc/sdmmcdevs.h
diff -u src/sys/dev/sdmmc/sdmmcdevs.h:1.6 src/sys/dev/sdmmc/sdmmcdevs.h:1.7
--- src/sys/dev/sdmmc/sdmmcdevs.h:1.6	Sat Aug 24 11:24:17 2019
+++ src/sys/dev/sdmmc/sdmmcdevs.h	Mon Oct 28 06:32:10 2019
@@ -1,10 +1,10 @@
-/*	$NetBSD: sdmmcdevs.h,v 1.6 2019/08/24 11:24:17 mlelstv Exp $	*/
+/*	$NetBSD: sdmmcdevs.h,v 1.7 2019/10/28 06:32:10 mlelstv Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *		NetBSD: sdmmcdevs,v 1.6 2019/08/24 11:24:00 mlelstv Exp 
+ *		NetBSD: sdmmcdevs,v 1.7 2019/10/28 06:31:39 mlelstv Exp 
  */
 /*	$OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $	*/
 
@@ -48,7 +48,7 @@
 #define	SDMMC_CIS_ABOCOM_SDW11G	{ NULL, NULL, NULL, NULL }
 #define	SDMMC_PRODUCT_ABOCOM_SDW11G	0xac02
 
-/* Atheros */ 
+/* Atheros */
 #define	SDMMC_CIS_ATHEROS_AR6001_8	{ NULL, NULL, NULL, NULL }
 #define	SDMMC_PRODUCT_ATHEROS_AR6001_8	0x0108
 #define	SDMMC_CIS_ATHEROS_AR6001_9	{ NULL, NULL, NULL, NULL }
@@ -58,7 +58,7 @@
 #define	SDMMC_CIS_ATHEROS_AR6001_b	{ NULL, NULL, NULL, NULL }
 #define	SDMMC_PRODUCT_ATHEROS_AR6001_b	0x010b
 
-/* Broadcom */ 
+/* Broadcom */
 #define	SDMMC_CIS_BROADCOM_BCM4324	{ NULL, NULL, NULL, NULL }
 #define	SDMMC_PRODUCT_BROADCOM_BCM4324	0x4324
 #define	SDMMC_CIS_BROADCOM_BCM4329	{ NULL, NULL, NULL, NULL }



CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:26:19 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmc_ioreg.h

Log Message:
Missing commit for sdio abort function.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/sdmmc_ioreg.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/sdmmc/sdmmc_ioreg.h
diff -u src/sys/dev/sdmmc/sdmmc_ioreg.h:1.4 src/sys/dev/sdmmc/sdmmc_ioreg.h:1.5
--- src/sys/dev/sdmmc/sdmmc_ioreg.h:1.4	Sun Sep  1 05:45:42 2019
+++ src/sys/dev/sdmmc/sdmmc_ioreg.h	Mon Oct 28 06:26:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_ioreg.h,v 1.4 2019/09/01 05:45:42 mlelstv Exp $	*/
+/*	$NetBSD: sdmmc_ioreg.h,v 1.5 2019/10/28 06:26:19 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc_ioreg.h,v 1.4 2007/06/02 01:48:37 uwe Exp $	*/
 
 /*
@@ -88,6 +88,7 @@
 #define SD_IO_CCCR_FN_INTPENDING	0x05
 #define SD_IO_CCCR_CTL			0x06
 #define  CCCR_CTL_RES			(1<<3)
+#define  CCCR_CTL_AS(x)			((x) & 0x7)
 #define SD_IO_CCCR_BUS_WIDTH		0x07
 #define  CCCR_BUS_WIDTH_4		(2<<0)
 #define  CCCR_BUS_WIDTH_1		(0<<0)



CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:26:19 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmc_ioreg.h

Log Message:
Missing commit for sdio abort function.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/sdmmc_ioreg.h

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



CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:20:01 UTC 2019

Modified Files:
src/sys/dev/sdmmc: if_bwfm_sdio.c sdmmc_io.c sdmmcvar.h

Log Message:
Simplyfy sdmmc_io_set_blocklen function signature by dropping the
extra softc pointer. Aligns with OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/if_bwfm_sdio.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/sdmmc/sdmmc_io.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/sdmmc/sdmmcvar.h

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



CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:20:01 UTC 2019

Modified Files:
src/sys/dev/sdmmc: if_bwfm_sdio.c sdmmc_io.c sdmmcvar.h

Log Message:
Simplyfy sdmmc_io_set_blocklen function signature by dropping the
extra softc pointer. Aligns with OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/if_bwfm_sdio.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/sdmmc/sdmmc_io.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/sdmmc/sdmmcvar.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/sdmmc/if_bwfm_sdio.c
diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.7 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.8
--- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.7	Sun Oct 27 21:39:50 2019
+++ src/sys/dev/sdmmc/if_bwfm_sdio.c	Mon Oct 28 06:20:01 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bwfm_sdio.c,v 1.7 2019/10/27 21:39:50 bad Exp $ */
+/* $NetBSD: if_bwfm_sdio.c,v 1.8 2019/10/28 06:20:01 mlelstv Exp $ */
 /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -293,8 +293,8 @@ bwfm_sdio_attach(device_t parent, device
 		sc->sc_sf[sf->number] = sf;
 	}
 
-	sdmmc_io_set_blocklen(sc->sc_sf[1]->sc, sc->sc_sf[1], 64);
-	sdmmc_io_set_blocklen(sc->sc_sf[2]->sc, sc->sc_sf[2], 512);
+	sdmmc_io_set_blocklen(sc->sc_sf[1], 64);
+	sdmmc_io_set_blocklen(sc->sc_sf[2], 512);
 
 	/* Enable Function 1. */
 	if (sdmmc_io_function_enable(sc->sc_sf[1]) != 0) {

Index: src/sys/dev/sdmmc/sdmmc_io.c
diff -u src/sys/dev/sdmmc/sdmmc_io.c:1.17 src/sys/dev/sdmmc/sdmmc_io.c:1.18
--- src/sys/dev/sdmmc/sdmmc_io.c:1.17	Mon Oct 28 06:16:46 2019
+++ src/sys/dev/sdmmc/sdmmc_io.c	Mon Oct 28 06:20:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_io.c,v 1.17 2019/10/28 06:16:46 mlelstv Exp $	*/
+/*	$NetBSD: sdmmc_io.c,v 1.18 2019/10/28 06:20:01 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Routines for SD I/O cards. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.17 2019/10/28 06:16:46 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.18 2019/10/28 06:20:01 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -825,9 +825,10 @@ sdmmc_intr_task(void *arg)
 }
 
 int
-sdmmc_io_set_blocklen(struct sdmmc_softc *sc, struct sdmmc_function *sf,
+sdmmc_io_set_blocklen(struct sdmmc_function *sf,
  int blklen)
 {
+	struct sdmmc_softc *sc = sf->sc;
 	struct sdmmc_function *sf0 = sc->sc_fn0;
 	int error = EINVAL;
 

Index: src/sys/dev/sdmmc/sdmmcvar.h
diff -u src/sys/dev/sdmmc/sdmmcvar.h:1.33 src/sys/dev/sdmmc/sdmmcvar.h:1.34
--- src/sys/dev/sdmmc/sdmmcvar.h:1.33	Mon Oct 28 06:16:46 2019
+++ src/sys/dev/sdmmc/sdmmcvar.h	Mon Oct 28 06:20:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmcvar.h,v 1.33 2019/10/28 06:16:46 mlelstv Exp $	*/
+/*	$NetBSD: sdmmcvar.h,v 1.34 2019/10/28 06:20:01 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmcvar.h,v 1.13 2009/01/09 10:55:22 jsg Exp $	*/
 
 /*
@@ -359,8 +359,7 @@ void	sdmmc_dump_data(const char *, void 
 int	sdmmc_io_enable(struct sdmmc_softc *);
 void	sdmmc_io_scan(struct sdmmc_softc *);
 int	sdmmc_io_init(struct sdmmc_softc *, struct sdmmc_function *);
-int	sdmmc_io_set_blocklen(struct sdmmc_softc *, struct sdmmc_function *,
-	int);
+int	sdmmc_io_set_blocklen(struct sdmmc_function *, int);
 uint8_t sdmmc_io_read_1(struct sdmmc_function *, int);
 uint16_t sdmmc_io_read_2(struct sdmmc_function *, int);
 uint32_t sdmmc_io_read_4(struct sdmmc_function *, int);



CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:16:46 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmc.c sdmmc_io.c sdmmc_mem.c sdmmcvar.h

Log Message:
Add and use sdmmc_pause to avoid long-term busy waits.
Add sdio abort function.
Additional error messages.
Print parameters for SDIO devices.
Minor cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/sdmmc/sdmmc.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sdmmc/sdmmc_io.c
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/sdmmc/sdmmc_mem.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/sdmmc/sdmmcvar.h

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



CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:16:46 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmc.c sdmmc_io.c sdmmc_mem.c sdmmcvar.h

Log Message:
Add and use sdmmc_pause to avoid long-term busy waits.
Add sdio abort function.
Additional error messages.
Print parameters for SDIO devices.
Minor cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/sdmmc/sdmmc.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sdmmc/sdmmc_io.c
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/sdmmc/sdmmc_mem.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/sdmmc/sdmmcvar.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/sdmmc/sdmmc.c
diff -u src/sys/dev/sdmmc/sdmmc.c:1.38 src/sys/dev/sdmmc/sdmmc.c:1.39
--- src/sys/dev/sdmmc/sdmmc.c:1.38	Wed Oct 23 05:20:52 2019
+++ src/sys/dev/sdmmc/sdmmc.c	Mon Oct 28 06:16:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc.c,v 1.38 2019/10/23 05:20:52 hkenken Exp $	*/
+/*	$NetBSD: sdmmc.c,v 1.39 2019/10/28 06:16:46 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc.c,v 1.18 2009/01/09 10:58:38 jsg Exp $	*/
 
 /*
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.38 2019/10/23 05:20:52 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.39 2019/10/28 06:16:46 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -568,7 +568,7 @@ sdmmc_enable(struct sdmmc_softc *sc)
 	}
 
 	/* XXX wait for card to power up */
-	sdmmc_delay(10);
+	sdmmc_pause(10, NULL);
 
 	if (!ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) {
 		/* Initialize SD I/O card function(s). */
@@ -790,6 +790,17 @@ sdmmc_delay(u_int usecs)
 	delay(usecs);
 }
 
+void
+sdmmc_pause(u_int usecs, kmutex_t *lock)
+{
+	unsigned ticks = mstohz(usecs/1000);
+
+	if (cold || ticks < 1)
+		delay(usecs);
+	else
+		kpause("sdmmcdelay", false, ticks, lock);
+}
+
 int
 sdmmc_app_command(struct sdmmc_softc *sc, struct sdmmc_function *sf, struct sdmmc_command *cmd)
 {
@@ -910,7 +921,7 @@ sdmmc_set_relative_addr(struct sdmmc_sof
 	/* Don't lock */
 
 	if (ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) {
-		aprint_error_dev(sc->sc_dev,
+		device_printf(sc->sc_dev,
 			"sdmmc_set_relative_addr: SMC_CAPS_SPI_MODE set");
 		return EIO;
 	}
@@ -943,7 +954,7 @@ sdmmc_select_card(struct sdmmc_softc *sc
 	/* Don't lock */
 
 	if (ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) {
-		aprint_error_dev(sc->sc_dev,
+		device_printf(sc->sc_dev,
 			"sdmmc_select_card: SMC_CAPS_SPI_MODE set");
 		return EIO;
 	}
@@ -962,6 +973,11 @@ sdmmc_select_card(struct sdmmc_softc *sc
 	if (error == 0 || sf == NULL)
 		sc->sc_card = sf;
 
+	if (error) {
+		device_printf(sc->sc_dev,
+			"sdmmc_select_card: error %d", error);
+	}
+
 	return error;
 }
 

Index: src/sys/dev/sdmmc/sdmmc_io.c
diff -u src/sys/dev/sdmmc/sdmmc_io.c:1.16 src/sys/dev/sdmmc/sdmmc_io.c:1.17
--- src/sys/dev/sdmmc/sdmmc_io.c:1.16	Mon Sep  2 11:09:42 2019
+++ src/sys/dev/sdmmc/sdmmc_io.c	Mon Oct 28 06:16:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_io.c,v 1.16 2019/09/02 11:09:42 jmcneill Exp $	*/
+/*	$NetBSD: sdmmc_io.c,v 1.17 2019/10/28 06:16:46 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Routines for SD I/O cards. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.16 2019/09/02 11:09:42 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.17 2019/10/28 06:16:46 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -230,7 +230,7 @@ sdmmc_io_init(struct sdmmc_softc *sc, st
 			sf->csd.tran_speed = 5;	/* 50MHz */
 
 			/* Wait 400KHz x 8 clock */
-			delay(1);
+			sdmmc_delay(20);
 		}
 		if (sc->sc_busclk > sf->csd.tran_speed)
 			sc->sc_busclk = sf->csd.tran_speed;
@@ -240,6 +240,15 @@ sdmmc_io_init(struct sdmmc_softc *sc, st
 		if (error)
 			aprint_error_dev(sc->sc_dev,
 			"can't change bus clock\n");
+
+		aprint_normal_dev(sc->sc_dev, "%u-bit width,", sf->width);
+		if ((sc->sc_busclk / 1000) != 0)
+			aprint_normal(" %u.%03u MHz\n",
+			sc->sc_busclk / 1000, sc->sc_busclk % 1000);
+		else
+			aprint_normal(" %u KHz\n", sc->sc_busclk % 1000);
+
+
 	} else {
 		reg = sdmmc_io_read_1(sf0, SD_IO_FBR(sf->number) + 0x000);
 		sf->interface = FBR_STD_FUNC_IF_CODE(reg);
@@ -357,7 +366,15 @@ sdmmc_io_rw_direct(struct sdmmc_softc *s
 	cmd.c_flags = SCF_CMD_AC | SCF_RSP_R5;
 
 	error = sdmmc_mmc_command(sc, );
-	*datap = SD_R5_DATA(cmd.c_resp);
+	if (error == 0)
+		*datap = SD_R5_DATA(cmd.c_resp);
+
+	if (error) {
+		device_printf(sc->sc_dev,
+		"direct I/O error %d, r=%d p=%p %s\n",
+		error, reg, datap,
+		ISSET(arg, SD_ARG_CMD53_WRITE) ? "write" : "read");
+	}
 
 	return error;
 }
@@ -404,6 +421,13 @@ sdmmc_io_rw_extended(struct sdmmc_softc 
 
 	error = sdmmc_mmc_command(sc, );
 
+	if (error) {
+		device_printf(sc->sc_dev,
+		"extended I/O error %d, r=%d p=%p l=%d %s\n",
+		error, reg, datap, datalen,
+		ISSET(arg, SD_ARG_CMD53_WRITE) 

CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:00:14 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdhc.c

Log Message:
Skip setting power when the voltage doesn't change.
Also increase some timeouts.


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

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

Modified files:

Index: src/sys/dev/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.104 src/sys/dev/sdmmc/sdhc.c:1.105
--- src/sys/dev/sdmmc/sdhc.c:1.104	Wed Oct 23 05:20:52 2019
+++ src/sys/dev/sdmmc/sdhc.c	Mon Oct 28 06:00:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc.c,v 1.104 2019/10/23 05:20:52 hkenken Exp $	*/
+/*	$NetBSD: sdhc.c,v 1.105 2019/10/28 06:00:14 mlelstv Exp $	*/
 /*	$OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.104 2019/10/23 05:20:52 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.105 2019/10/28 06:00:14 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -98,6 +98,8 @@ struct sdhc_host {
 	bus_dmamap_t		adma_map;
 	bus_dma_segment_t	adma_segs[1];
 	void			*adma2;
+
+	uint8_t			vdd;	/* last vdd setting */
 };
 
 #define HDEVNAME(hp)	(device_xname((hp)->sc->sc_dev))
@@ -156,10 +158,16 @@ hwrite2(struct sdhc_host *hp, bus_size_t
 	}
 }
 
+static void
+hwrite4(struct sdhc_host *hp, bus_size_t o, uint32_t val)
+{
+
+	bus_space_write_4(hp->iot, hp->ioh, o, val);
+}
+
 #define HWRITE1(hp, reg, val)		hwrite1(hp, reg, val)
 #define HWRITE2(hp, reg, val)		hwrite2(hp, reg, val)
-#define HWRITE4(hp, reg, val)		\
-	bus_space_write_4((hp)->iot, (hp)->ioh, (reg), (val))
+#define HWRITE4(hp, reg, val)		hwrite4(hp, reg, val)
 
 #define HCLR1(hp, reg, bits)		\
 	do if (bits) HWRITE1((hp), (reg), HREAD1((hp), (reg)) & ~(bits)); while (0)
@@ -788,6 +796,9 @@ sdhc_host_reset1(sdmmc_chipset_handle_t 
 		HWRITE2(hp, SDHC_NINTR_SIGNAL_EN, 0);
 	}
 
+	/* Let sdhc_bus_power restore power */
+	hp->vdd = 0;
+
 	/*
 	 * Reset the entire host controller and wait up to 100ms for
 	 * the controller to clear the reset bit.
@@ -902,6 +913,7 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc
 	int error = 0;
 	const uint32_t pcmask =
 	~(SDHC_BUS_POWER | (SDHC_VOLTAGE_MASK << SDHC_VOLTAGE_SHIFT));
+	uint32_t reg;
 
 	mutex_enter(>intr_lock);
 
@@ -909,8 +921,10 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc
 	 * Disable bus power before voltage change.
 	 */
 	if (!ISSET(hp->sc->sc_flags, SDHC_FLAG_32BIT_ACCESS)
-	&& !ISSET(hp->sc->sc_flags, SDHC_FLAG_NO_PWR0))
+	&& !ISSET(hp->sc->sc_flags, SDHC_FLAG_NO_PWR0)) {
+		hp->vdd = 0;
 		HWRITE1(hp, SDHC_POWER_CTL, 0);
+	}
 
 	/* If power is disabled, reset the host and return now. */
 	if (ocr == 0) {
@@ -935,6 +949,12 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc
 		goto out;
 	}
 
+	/*
+	 * Did voltage change ?
+	 */
+	if (vdd == hp->vdd)
+		goto out;
+
 	if (!ISSET(hp->sc->sc_flags, SDHC_FLAG_ENHANCED)) {
 		/*
 		 * Enable bus power.  Wait at least 1 ms (or 74 clocks) plus
@@ -945,13 +965,14 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc
 			HWRITE1(hp, SDHC_POWER_CTL,
 			(vdd << SDHC_VOLTAGE_SHIFT) | SDHC_BUS_POWER);
 		} else {
-			HWRITE1(hp, SDHC_POWER_CTL,
-			HREAD1(hp, SDHC_POWER_CTL) & pcmask);
+			reg = HREAD1(hp, SDHC_POWER_CTL) & pcmask;
+			HWRITE1(hp, SDHC_POWER_CTL, reg);
 			sdmmc_delay(1);
-			HWRITE1(hp, SDHC_POWER_CTL,
-			(vdd << SDHC_VOLTAGE_SHIFT));
+			reg |= (vdd << SDHC_VOLTAGE_SHIFT);
+			HWRITE1(hp, SDHC_POWER_CTL, reg);
 			sdmmc_delay(1);
-			HSET1(hp, SDHC_POWER_CTL, SDHC_BUS_POWER);
+			reg |= SDHC_BUS_POWER;
+			HWRITE1(hp, SDHC_POWER_CTL, reg);
 			sdmmc_delay(1);
 		}
 
@@ -966,6 +987,9 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc
 		}
 	}
 
+	/* power successfully changed */
+	hp->vdd = vdd;
+
 out:
 	mutex_exit(>intr_lock);
 
@@ -1522,7 +1546,7 @@ sdhc_wait_state(struct sdhc_host *hp, ui
 	uint32_t state;
 	int timeout;
 
-	for (timeout = 1; timeout > 0; timeout--) {
+	for (timeout = 10; timeout > 0; timeout--) {
 		if (((state = HREAD4(hp, SDHC_PRESENT_STATE)) & mask) == value)
 			return 0;
 		sdmmc_delay(10);
@@ -1587,7 +1611,7 @@ sdhc_exec_command(sdmmc_chipset_handle_t
 	 * is marked done for any other reason.
 	 */
 	probing = (cmd->c_flags & SCF_TOUT_OK) != 0;
-	if (!sdhc_wait_intr(hp, SDHC_COMMAND_COMPLETE, SDHC_COMMAND_TIMEOUT, probing)) {
+	if (!sdhc_wait_intr(hp, SDHC_COMMAND_COMPLETE, SDHC_COMMAND_TIMEOUT*3, probing)) {
 		DPRINTF(1,("%s: timeout for command\n", __func__));
 		sdmmc_delay(50);
 		cmd->c_error = ETIMEDOUT;



CVS commit: src/sys/dev/sdmmc

2019-10-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Oct 28 06:00:14 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdhc.c

Log Message:
Skip setting power when the voltage doesn't change.
Also increase some timeouts.


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

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



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

2019-10-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct 12 09:46:18 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_gpio.c

Log Message:
off by one


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/broadcom/bcm2835_gpio.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_gpio.c
diff -u src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.15 src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.16
--- src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.15	Thu Oct  3 11:24:27 2019
+++ src/sys/arch/arm/broadcom/bcm2835_gpio.c	Sat Oct 12 09:46:18 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_gpio.c,v 1.15 2019/10/03 11:24:27 mlelstv Exp $	*/
+/*	$NetBSD: bcm2835_gpio.c,v 1.16 2019/10/12 09:46:18 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2013, 2014, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.15 2019/10/03 11:24:27 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.16 2019/10/12 09:46:18 mlelstv Exp $");
 
 /*
  * Driver for BCM2835 GPIO
@@ -221,7 +221,7 @@ bcm283x_pinctrl_set_config(device_t dev,
 	for (int i = 0; i < npins; i++) {
 		const u_int pin = be32toh(pins[i]);
 
-		if (pin > sc->sc_maxpins)
+		if (pin >= sc->sc_maxpins)
 			continue;
 		if (pull) {
 			const int value = be32toh(pull[npull == 1 ? 0 : i]);



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

2019-10-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct 12 09:46:18 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_gpio.c

Log Message:
off by one


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/broadcom/bcm2835_gpio.c

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



CVS commit: src/sys/dev/microcode/run

2019-10-09 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Oct  9 19:58:51 UTC 2019

Modified Files:
src/sys/dev/microcode/run: run-rt2870 run-rt3071

Log Message:
Update firmware from version 0.17 to 0.33.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/microcode/run/run-rt2870 \
src/sys/dev/microcode/run/run-rt3071

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/microcode/run/run-rt2870
Binary files are different
Index: src/sys/dev/microcode/run/run-rt3071
Binary files are different



CVS commit: src/sys/dev/microcode/run

2019-10-09 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Oct  9 19:58:51 UTC 2019

Modified Files:
src/sys/dev/microcode/run: run-rt2870 run-rt3071

Log Message:
Update firmware from version 0.17 to 0.33.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/microcode/run/run-rt2870 \
src/sys/dev/microcode/run/run-rt3071

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



CVS commit: src/sys/dev/usb

2019-10-08 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Oct  8 07:30:58 UTC 2019

Modified Files:
src/sys/dev/usb: if_run.c if_runvar.h

Log Message:
Merge more changes from FreeBSD/OpenBSD. My two run(4) devices now work
again.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/usb/if_run.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/if_runvar.h

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



CVS commit: src/sys/dev/usb

2019-10-08 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Oct  8 07:30:58 UTC 2019

Modified Files:
src/sys/dev/usb: if_run.c if_runvar.h

Log Message:
Merge more changes from FreeBSD/OpenBSD. My two run(4) devices now work
again.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/usb/if_run.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/if_runvar.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/if_run.c
diff -u src/sys/dev/usb/if_run.c:1.32 src/sys/dev/usb/if_run.c:1.33
--- src/sys/dev/usb/if_run.c:1.32	Tue Jan 22 06:47:20 2019
+++ src/sys/dev/usb/if_run.c	Tue Oct  8 07:30:58 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_run.c,v 1.32 2019/01/22 06:47:20 skrll Exp $	*/
+/*	$NetBSD: if_run.c,v 1.33 2019/10/08 07:30:58 mlelstv Exp $	*/
 /*	$OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $	*/
 
 /*-
@@ -18,12 +18,12 @@
  */
 
 /*-
- * Ralink Technology RT2700U/RT2800U/RT3000U chipset driver.
+ * Ralink Technology RT2700U/RT2800U/RT3000U/RT3900E chipset driver.
  * http://www.ralinktech.com/
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.32 2019/01/22 06:47:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.33 2019/10/08 07:30:58 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -122,6 +122,8 @@ static const struct usb_devno run_devs[]
 	USB_ID(ASUSTEK,		RT2870_5),
 	USB_ID(ASUSTEK,		RT3070),
 	USB_ID(ASUSTEK,		RT3070_1),
+	USB_ID(ASUSTEK,		USBN53),
+	USB_ID(ASUSTEK,		USBN66),
 	USB_ID(ASUSTEK2,	USBN11),
 	USB_ID(AZUREWAVE,	RT2870_1),
 	USB_ID(AZUREWAVE,	RT2870_2),
@@ -138,6 +140,7 @@ static const struct usb_devno run_devs[]
 	USB_ID(BELKIN,		F7D1101V2),
 	USB_ID(BELKIN,		RT2870_1),
 	USB_ID(BELKIN,		RT2870_2),
+	USB_ID(BELKIN,		RTL8192CU_2),
 	USB_ID(BEWAN,		RT3070),
 	USB_ID(CISCOLINKSYS,	AE1000),
 	USB_ID(CISCOLINKSYS,	AM10),
@@ -162,6 +165,10 @@ static const struct usb_devno run_devs[]
 	USB_ID(CYBERTAN,	RT2870),
 	USB_ID(DLINK,		RT2870),
 	USB_ID(DLINK,		RT3072),
+	USB_ID(DLINK,		DWA127),
+	USB_ID(DLINK,		DWA140B3),
+	USB_ID(DLINK,		DWA160B2),
+	USB_ID(DLINK,		DWA162),
 	USB_ID(DLINK2,		DWA130),
 	USB_ID(DLINK2,		RT2870_1),
 	USB_ID(DLINK2,		RT2870_2),
@@ -203,6 +210,9 @@ static const struct usb_devno run_devs[]
 	USB_ID(LINKSYS4,	WUSB600N),
 	USB_ID(LINKSYS4,	WUSB600NV2),
 	USB_ID(LOGITEC,		LANW300NU2),
+	USB_ID(LOGITEC,		LANW300NU2S),
+	USB_ID(LOGITEC,		LAN_W300ANU2),
+	USB_ID(LOGITEC,		LAN_W450ANU2E),
 	USB_ID(LOGITEC,		RT2870_1),
 	USB_ID(LOGITEC,		RT2870_2),
 	USB_ID(LOGITEC,		RT2870_3),
@@ -257,6 +267,7 @@ static const struct usb_devno run_devs[]
 	USB_ID(RALINK,		RT3072),
 	USB_ID(RALINK,		RT3370),
 	USB_ID(RALINK,		RT3572),
+	USB_ID(RALINK,		RT3573),
 	USB_ID(RALINK,		RT5370),
 	USB_ID(RALINK,		RT5572),
 	USB_ID(RALINK,		RT8070),
@@ -276,9 +287,11 @@ static const struct usb_devno run_devs[]
 	USB_ID(SITECOMEU,	RT2870_2),
 	USB_ID(SITECOMEU,	RT2870_3),
 	USB_ID(SITECOMEU,	RT3070_1),
+	USB_ID(SITECOMEU,	RT3070_3),
 	USB_ID(SITECOMEU,	RT3072_3),
 	USB_ID(SITECOMEU,	RT3072_4),
 	USB_ID(SITECOMEU,	RT3072_5),
+	USB_ID(SITECOMEU,	RT3072_6),
 	USB_ID(SITECOMEU,	WL302),
 	USB_ID(SITECOMEU,	WL315),
 	USB_ID(SITECOMEU,	WL321),
@@ -352,7 +365,7 @@ static int		run_rt3070_rf_write(struct r
 static int		run_bbp_read(struct run_softc *, uint8_t, uint8_t *);
 static int		run_bbp_write(struct run_softc *, uint8_t, uint8_t);
 static int		run_mcu_cmd(struct run_softc *, uint8_t, uint16_t);
-static const char *	run_get_rf(int);
+static const char *	run_get_rf(uint16_t);
 static void		run_rt3593_get_txpower(struct run_softc *);
 static void		run_get_txpower(struct run_softc *);
 static int		run_read_eeprom(struct run_softc *);
@@ -850,6 +863,11 @@ run_alloc_tx_ring(struct run_softc *sc, 
 {
 	struct run_tx_ring *txq = >txq[qid];
 	int i, error;
+	uint16_t txwisize;
+
+	txwisize = sizeof(struct rt2860_txwi);
+	if (sc->mac_ver == 0x5592)
+		txwisize += sizeof(uint32_t);
 
 	txq->cur = txq->queued = 0;
 
@@ -870,8 +888,7 @@ run_alloc_tx_ring(struct run_softc *sc, 
 
 		data->buf = usbd_get_buffer(data->xfer);
 		/* zeroize the TXD + TXWI part */
-		memset(data->buf, 0, sizeof(struct rt2870_txd) +
-		sizeof(struct rt2860_txwi));
+		memset(data->buf, 0, sizeof(struct rt2870_txd) + txwisize);
 	}
 	if (error != 0)
 fail:		run_free_tx_ring(sc, qid);
@@ -942,7 +959,9 @@ run_load_microcode(struct run_softc *sc)
 		return error;
 
 	usbd_delay_ms(sc->sc_udev, 10);
+	run_write(sc, RT2860_H2M_BBPAGENT, 0);
 	run_write(sc, RT2860_H2M_MAILBOX, 0);
+	run_write(sc, RT2860_H2M_INTSRC, 0);
 	if ((error = run_mcu_cmd(sc, RT2860_MCU_CMD_RFRESET, 0)) != 0)
 		return error;
 
@@ -1106,6 +1125,7 @@ run_efuse_read(struct run_softc *sc, uin
 	if ((error = run_read(sc, reg, )) != 0)
 		return error;
 
+	tmp >>= (8 * (addr & 0x3));
 	*val = (addr & 1) ? tmp >> 16 : tmp & 0x;
 	return 0;
 }
@@ -1315,7 +1335,7 @@ b4inc(uint32_t b32, int8_t delta)
 }
 
 static const 

CVS commit: src/sys/sys

2019-10-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Oct  6 07:15:34 UTC 2019

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

Log Message:
Use multiple cache lines for fd_dfdfile elements when necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/sys/filedesc.h

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

Modified files:

Index: src/sys/sys/filedesc.h
diff -u src/sys/sys/filedesc.h:1.64 src/sys/sys/filedesc.h:1.65
--- src/sys/sys/filedesc.h:1.64	Tue Dec 26 08:30:58 2017
+++ src/sys/sys/filedesc.h	Sun Oct  6 07:15:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: filedesc.h,v 1.64 2017/12/26 08:30:58 kamil Exp $	*/
+/*	$NetBSD: filedesc.h,v 1.65 2019/10/06 07:15:34 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -112,6 +112,8 @@ typedef struct fdfile {
 	kcondvar_t	ff_closing;	/* d: notifier for close */
 } fdfile_t;
 
+#define FDFILE_SIZE ((sizeof(fdfile_t)+CACHE_LINE_SIZE-1)/CACHE_LINE_SIZE*CACHE_LINE_SIZE)
+
 /* Reference count */
 #define	FR_CLOSING	(0x8000)	/* closing: must interlock */
 #define	FR_MASK		(~FR_CLOSING)	/* reference count */
@@ -132,7 +134,7 @@ typedef struct filedesc {
 	 * Built-in fdfile_t records first, since they have strict
 	 * alignment requirements.
 	 */
-	uint8_t		fd_dfdfile[NDFDFILE][CACHE_LINE_SIZE];
+	uint8_t		fd_dfdfile[NDFDFILE][FDFILE_SIZE];
 	/*
 	 * All of the remaining fields are locked by fd_lock.
 	 */



CVS commit: src/sys/sys

2019-10-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Oct  6 07:15:34 UTC 2019

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

Log Message:
Use multiple cache lines for fd_dfdfile elements when necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/sys/filedesc.h

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



CVS commit: src/sys/dev

2019-10-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Oct  6 06:10:44 UTC 2019

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

Log Message:
Don't attach disks with sector sizes we cannot handle.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/ld.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/ld.c
diff -u src/sys/dev/ld.c:1.106 src/sys/dev/ld.c:1.107
--- src/sys/dev/ld.c:1.106	Tue Mar 19 07:01:14 2019
+++ src/sys/dev/ld.c	Sun Oct  6 06:10:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld.c,v 1.106 2019/03/19 07:01:14 mlelstv Exp $	*/
+/*	$NetBSD: ld.c,v 1.107 2019/10/06 06:10:44 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.106 2019/03/19 07:01:14 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.107 2019/10/06 06:10:44 mlelstv Exp $");
 
 #include 
 #include 
@@ -135,6 +135,12 @@ ldattach(struct ld_softc *sc, const char
 		return;
 	}
 
+	/* don't attach a disk that we cannot handle */
+	if (sc->sc_secsize < DEV_BSIZE) {
+		sc->sc_flags &= ~LDF_ENABLED;
+		return;
+	}
+
 	/* Initialise dk and disk structure. */
 	dk_init(dksc, self, DKTYPE_LD);
 	disk_init(>sc_dkdev, dksc->sc_xname, );



CVS commit: src/sys/dev

2019-10-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Oct  6 06:10:44 UTC 2019

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

Log Message:
Don't attach disks with sector sizes we cannot handle.


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

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



CVS commit: src/sys

2019-10-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Oct  6 05:48:00 UTC 2019

Modified Files:
src/sys/miscfs/genfs: genfs_io.c
src/sys/uvm: uvm_swap.c

Log Message:
Defer to synchronous I/O before the aiodone work queue exists.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/miscfs/genfs/genfs_io.c
cvs rdiff -u -r1.180 -r1.181 src/sys/uvm/uvm_swap.c

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

Modified files:

Index: src/sys/miscfs/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.75 src/sys/miscfs/genfs/genfs_io.c:1.76
--- src/sys/miscfs/genfs/genfs_io.c:1.75	Thu Jul 11 16:59:14 2019
+++ src/sys/miscfs/genfs/genfs_io.c	Sun Oct  6 05:48:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.75 2019/07/11 16:59:14 maxv Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.76 2019/10/06 05:48:00 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.75 2019/07/11 16:59:14 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.76 2019/10/06 05:48:00 mlelstv Exp $");
 
 #include 
 #include 
@@ -561,6 +561,9 @@ genfs_getpages_read(struct vnode *vp, st
 	if (kva == 0)
 		return EBUSY;
 
+	if (uvm.aiodone_queue == NULL)
+		async = 0;
+
 	mbp = getiobuf(vp, true);
 	mbp->b_bufsize = totalbytes;
 	mbp->b_data = (void *)kva;
@@ -1377,6 +1380,7 @@ genfs_gop_write(struct vnode *vp, struct
 	UVMPAGER_MAPIN_WRITE | UVMPAGER_MAPIN_WAITOK);
 	len = npages << PAGE_SHIFT;
 
+	KASSERT(uvm.aiodone_queue != NULL);
 	error = genfs_do_io(vp, off, kva, len, flags, UIO_WRITE,
 			uvm_aio_biodone);
 
@@ -1400,6 +1404,7 @@ genfs_gop_write_rwmap(struct vnode *vp, 
 	UVMPAGER_MAPIN_READ | UVMPAGER_MAPIN_WAITOK);
 	len = npages << PAGE_SHIFT;
 
+	KASSERT(uvm.aiodone_queue != NULL);
 	error = genfs_do_io(vp, off, kva, len, flags, UIO_WRITE,
 			uvm_aio_biodone);
 

Index: src/sys/uvm/uvm_swap.c
diff -u src/sys/uvm/uvm_swap.c:1.180 src/sys/uvm/uvm_swap.c:1.181
--- src/sys/uvm/uvm_swap.c:1.180	Sun Jan 27 05:22:19 2019
+++ src/sys/uvm/uvm_swap.c	Sun Oct  6 05:48:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_swap.c,v 1.180 2019/01/27 05:22:19 kre Exp $	*/
+/*	$NetBSD: uvm_swap.c,v 1.181 2019/10/06 05:48:00 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.180 2019/01/27 05:22:19 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.181 2019/10/06 05:48:00 mlelstv Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_compat_netbsd.h"
@@ -1778,6 +1778,10 @@ uvm_swap_io(struct vm_page **pps, int st
 	write = (flags & B_READ) == 0;
 	async = (flags & B_ASYNC) != 0;
 
+	/* XXX swap io make take place before the aiodone queue exists */
+	if (uvm.aiodone_queue == NULL)
+		async = 0;
+
 	/*
 	 * allocate a buf for the i/o.
 	 */
@@ -1832,6 +1836,7 @@ uvm_swap_io(struct vm_page **pps, int st
 	 */
 
 	if (async) {
+		KASSERT(uvm.aiodone_queue != NULL);
 		bp->b_iodone = uvm_aio_biodone;
 		UVMHIST_LOG(pdhist, "doing async!", 0, 0, 0, 0);
 		if (curlwp == uvm.pagedaemon_lwp)



CVS commit: src/sys

2019-10-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Oct  6 05:48:00 UTC 2019

Modified Files:
src/sys/miscfs/genfs: genfs_io.c
src/sys/uvm: uvm_swap.c

Log Message:
Defer to synchronous I/O before the aiodone work queue exists.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/miscfs/genfs/genfs_io.c
cvs rdiff -u -r1.180 -r1.181 src/sys/uvm/uvm_swap.c

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



CVS commit: src/distrib/utils/embedded/files

2019-10-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct  5 09:25:11 UTC 2019

Modified Files:
src/distrib/utils/embedded/files: creds_msdos

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/distrib/utils/embedded/files/creds_msdos

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

Modified files:

Index: src/distrib/utils/embedded/files/creds_msdos
diff -u src/distrib/utils/embedded/files/creds_msdos:1.3 src/distrib/utils/embedded/files/creds_msdos:1.4
--- src/distrib/utils/embedded/files/creds_msdos:1.3	Wed Jun 12 03:06:48 2019
+++ src/distrib/utils/embedded/files/creds_msdos	Sat Oct  5 09:25:11 2019
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: creds_msdos,v 1.3 2019/06/12 03:06:48 mrg Exp $
+# $NetBSD: creds_msdos,v 1.4 2019/10/05 09:25:11 mlelstv Exp $
 #
 # Copyright (c) 2019 Matthew R. Green
 # All rights reserved.
@@ -135,7 +135,7 @@ creds_msdos_start()
 	local fstab_file=/etc/fstab
 
 	if [ -z "${creds_msdos_partition}" ]; then
-		echo "Not looking for credientials on msdos"
+		echo "Not looking for credentials on msdos"
 		return
 	fi
 	while read junk1 mp fstype junk2; do



CVS commit: src/distrib/utils/embedded/files

2019-10-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct  5 09:25:11 UTC 2019

Modified Files:
src/distrib/utils/embedded/files: creds_msdos

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/distrib/utils/embedded/files/creds_msdos

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



CVS commit: src/sys/dev

2019-10-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct  5 05:28:44 UTC 2019

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

Log Message:
Bail when dkdriver hasn't been initialized. This can happen when
attachment failed or when it hasn't finished yet.


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

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

Modified files:

Index: src/sys/dev/dksubr.c
diff -u src/sys/dev/dksubr.c:1.109 src/sys/dev/dksubr.c:1.110
--- src/sys/dev/dksubr.c:1.109	Fri Jun 28 14:56:46 2019
+++ src/sys/dev/dksubr.c	Sat Oct  5 05:28:44 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.109 2019/06/28 14:56:46 jmcneill Exp $ */
+/* $NetBSD: dksubr.c,v 1.110 2019/10/05 05:28:44 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.109 2019/06/28 14:56:46 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.110 2019/10/05 05:28:44 mlelstv Exp $");
 
 #include 
 #include 
@@ -147,6 +147,12 @@ dk_open(struct dk_softc *dksc, dev_t dev
 		goto done;
 	}
 
+	/* If no dkdriver attached, bail */
+	if (dkd == NULL) {
+		ret = ENXIO;
+		goto done;
+	}
+
 	/*
 	 * initialize driver for the first opener
 	 */



CVS commit: src/sys/dev

2019-10-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct  5 05:28:44 UTC 2019

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

Log Message:
Bail when dkdriver hasn't been initialized. This can happen when
attachment failed or when it hasn't finished yet.


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

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



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

2019-10-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Oct  3 11:24:27 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_gpio.c

Log Message:
remove debug printfs, add more compat strings.


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

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



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

2019-10-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Oct  3 11:24:27 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_gpio.c

Log Message:
remove debug printfs, add more compat strings.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/broadcom/bcm2835_gpio.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_gpio.c
diff -u src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.14 src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.15
--- src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.14	Tue Oct  1 23:32:52 2019
+++ src/sys/arch/arm/broadcom/bcm2835_gpio.c	Thu Oct  3 11:24:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_gpio.c,v 1.14 2019/10/01 23:32:52 jmcneill Exp $	*/
+/*	$NetBSD: bcm2835_gpio.c,v 1.15 2019/10/03 11:24:27 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2013, 2014, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.14 2019/10/01 23:32:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.15 2019/10/03 11:24:27 mlelstv Exp $");
 
 /*
  * Driver for BCM2835 GPIO
@@ -241,7 +241,12 @@ bcm283x_pinctrl_set_config(device_t dev,
 static int
 bcmgpio_match(device_t parent, cfdata_t cf, void *aux)
 {
-	const char * const compatible[] = { "brcm,bcm2835-gpio", NULL };
+	const char * const compatible[] = {
+		"brcm,bcm2835-gpio",
+		"brcm,bcm2838-gpio",
+		"brcm,bcm2711-gpio",
+		NULL
+	};
 	struct fdt_attach_args * const faa = aux;
 
 	return of_match_compatible(faa->faa_phandle, compatible);
@@ -815,7 +820,6 @@ bcm283x_pin_setpull(const struct bcmgpio
 		mask = 1 << (pin % BCM2835_GPIO_GPPUD_PINS_PER_REGISTER);
 		regid = (pin / BCM2835_GPIO_GPPUD_PINS_PER_REGISTER);
 
-printf("2835: pin=%u, pud=%u, regid=%u, mask=%08x\n",pin,pud,regid,mask);
 		bus_space_write_4(sc->sc_iot, sc->sc_ioh,
 		BCM2835_GPIO_GPPUD, pud);
 		delay(1);
@@ -841,7 +845,6 @@ printf("2835: pin=%u, pud=%u, regid=%u, 
 			pud = BCM2838_GPIO_GPPUD_PULLOFF;
 			break;
 		}
-printf("2838: pin=%u, pud=%u, regid=%u, mask=%08x\n",pin,pud,regid,mask);
 
 		reg = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
 		BCM2838_GPIO_GPPUPPDN(regid));



CVS commit: src/sys/dev/sdmmc

2019-10-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Oct  3 10:53:34 UTC 2019

Modified Files:
src/sys/dev/sdmmc: if_bwfm_sdio.h

Log Message:
More register definitions.


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

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



CVS commit: src/sys/dev/sdmmc

2019-10-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Oct  3 10:53:34 UTC 2019

Modified Files:
src/sys/dev/sdmmc: if_bwfm_sdio.h

Log Message:
More register definitions.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/sdmmc/if_bwfm_sdio.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/sdmmc/if_bwfm_sdio.h
diff -u src/sys/dev/sdmmc/if_bwfm_sdio.h:1.1 src/sys/dev/sdmmc/if_bwfm_sdio.h:1.2
--- src/sys/dev/sdmmc/if_bwfm_sdio.h:1.1	Sun Sep  1 05:51:45 2019
+++ src/sys/dev/sdmmc/if_bwfm_sdio.h	Thu Oct  3 10:53:34 2019
@@ -41,6 +41,11 @@
 #define BWFM_SDIO_FUNC1_SBADDRLOW		0x1000A
 #define BWFM_SDIO_FUNC1_SBADDRMID		0x1000B
 #define BWFM_SDIO_FUNC1_SBADDRHIGH		0x1000C
+#define BWFM_SDIO_FUNC1_FRAMECTRL		0x1000D
+#define  BWFM_SDIO_FUNC1_FRAMECTRL_RF_TERM		(1 << 0)
+#define  BWFM_SDIO_FUNC1_FRAMECTRL_WF_TERM		(1 << 1)
+#define  BWFM_SDIO_FUNC1_FRAMECTRL_CRC4WOOS		(1 << 2)
+#define  BWFM_SDIO_FUNC1_FRAMECTRL_ABORTALL		(1 << 3)
 #define BWFM_SDIO_FUNC1_CHIPCLKCSR		0x1000E
 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_FORCE_ALP			0x01
 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_FORCE_HT			0x02
@@ -65,6 +70,11 @@
 		(BWFM_SDIO_FUNC1_CHIPCLKCSR_ALPAV(regval) && \
 		 (alponly ? 1 : BWFM_SDIO_FUNC1_CHIPCLKCSR_HTAV(regval)))
 #define BWFM_SDIO_FUNC1_SDIOPULLUP		0x1000F
+#define BWFM_SDIO_FUNC1_WFRAMEBCLO		0x10019
+#define BWFM_SDIO_FUNC1_WFRAMEBCHI		0x1001A
+#define BWFM_SDIO_FUNC1_RFRAMEBCLO		0x1001B
+#define BWFM_SDIO_FUNC1_RFRAMEBCHI		0x1001C
+#define BWFM_SDIO_FUNC1_MESBUSYCTRL		0x1001D
 #define BWFM_SDIO_FUNC1_WAKEUPCTRL		0x1001E
 #define  BWFM_SDIO_FUNC1_WAKEUPCTRL_HTWAIT		(1 << 1)
 #define BWFM_SDIO_FUNC1_SLEEPCSR		0x1001F



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

2019-10-02 Thread Michael van Elst
On Wed, Oct 02, 2019 at 03:44:21AM +, Constantine A. Murenin wrote:
> I'm getting a page fault trap after this patch, at netbsd:dk_open(), in
> VirtualBox 6.0.12 r133076 with an empty NVME controller.


There is a bug in dk_open when attachment didn't complete yet or failed.
I'm about to fix that.

I expect that is the same, but please provide the details.


-- 
    Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


CVS commit: src/sys/dev/ic

2019-10-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Oct  1 10:59:50 UTC 2019

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

Log Message:
Don't attach an ld device if the format descriptor is unsupported/unused.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/ld_nvme.c

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



CVS commit: src/sys/dev/ic

2019-10-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Oct  1 10:59:50 UTC 2019

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

Log Message:
Don't attach an ld device if the format descriptor is unsupported/unused.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/ld_nvme.c

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

Modified files:

Index: src/sys/dev/ic/ld_nvme.c
diff -u src/sys/dev/ic/ld_nvme.c:1.22 src/sys/dev/ic/ld_nvme.c:1.23
--- src/sys/dev/ic/ld_nvme.c:1.22	Fri Apr 26 14:28:40 2019
+++ src/sys/dev/ic/ld_nvme.c	Tue Oct  1 10:59:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.22 2019/04/26 14:28:40 mlelstv Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.23 2019/10/01 10:59:49 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22 2019/04/26 14:28:40 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.23 2019/10/01 10:59:49 mlelstv Exp $");
 
 #include 
 #include 
@@ -105,6 +105,19 @@ ld_nvme_attach(device_t parent, device_t
 	KASSERT(ns);
 	f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
 
+	/*
+	 * NVME1.0e 6.11 Identify command
+	 *
+	 * LBADS values smaller than 9 are not supported, a value
+	 * of zero means that the format is not used.
+	 */
+	if (f->lbads < 9) {
+		if (f->lbads > 0)
+			aprint_error_dev(self,
+			"unsupported logical data size %u\n", f->lbads);
+		return;
+	}
+
 	ld->sc_secsize = 1 << f->lbads;
 	ld->sc_secperunit = ns->ident->nsze;
 	ld->sc_maxxfer = naa->naa_maxphys;



CVS commit: src/sys/dev/pci

2019-09-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 28 10:47:09 UTC 2019

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

Log Message:
Fix typo, remove debug printf.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/sdhc_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/sdhc_pci.c
diff -u src/sys/dev/pci/sdhc_pci.c:1.14 src/sys/dev/pci/sdhc_pci.c:1.15
--- src/sys/dev/pci/sdhc_pci.c:1.14	Thu Apr 27 10:01:54 2017
+++ src/sys/dev/pci/sdhc_pci.c	Sat Sep 28 10:47:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc_pci.c,v 1.14 2017/04/27 10:01:54 msaitoh Exp $	*/
+/*	$NetBSD: sdhc_pci.c,v 1.15 2019/09/28 10:47:09 mlelstv Exp $	*/
 /*	$OpenBSD: sdhc_pci.c,v 1.7 2007/10/30 18:13:45 chl Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v 1.14 2017/04/27 10:01:54 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v 1.15 2019/09/28 10:47:09 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -436,12 +436,11 @@ sdhc_pci_quirk_ricoh_lower_freq_hack(str
 
 	/*
 	 * Some SD/MMC cards don't work with the default base
-	 * clock frequency of 200MHz.  Lower it to 50Hz.
+	 * clock frequency of 200MHz.  Lower it to 50MHz.
 	 */
 	sdhc_pci_conf_write(pa, SDHC_PCI_BASE_FREQ_KEY, 0x01);
 	sdhc_pci_conf_write(pa, SDHC_PCI_BASE_FREQ, 50);
 	sdhc_pci_conf_write(pa, SDHC_PCI_BASE_FREQ_KEY, 0x00);
-printf("quirked\n");
 }
 
 static void



CVS commit: src/sys/dev/pci

2019-09-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 28 10:47:09 UTC 2019

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

Log Message:
Fix typo, remove debug printf.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/sdhc_pci.c

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



CVS commit: src/sys/compat/netbsd32

2019-09-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 28 08:21:08 UTC 2019

Modified Files:
src/sys/compat/netbsd32: netbsd32_socket.c

Log Message:
signed/unsigned comparison.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/compat/netbsd32/netbsd32_socket.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/netbsd32/netbsd32_socket.c
diff -u src/sys/compat/netbsd32/netbsd32_socket.c:1.52 src/sys/compat/netbsd32/netbsd32_socket.c:1.53
--- src/sys/compat/netbsd32/netbsd32_socket.c:1.52	Fri Sep 27 08:17:11 2019
+++ src/sys/compat/netbsd32/netbsd32_socket.c	Sat Sep 28 08:21:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_socket.c,v 1.52 2019/09/27 08:17:11 mlelstv Exp $	*/
+/*	$NetBSD: netbsd32_socket.c,v 1.53 2019/09/28 08:21:08 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.52 2019/09/27 08:17:11 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.53 2019/09/28 08:21:08 mlelstv Exp $");
 
 #include 
 #include 
@@ -418,7 +418,7 @@ copyin32_msg_control(struct lwp *l, stru
 			size_t nclen;
 
 			nclen = cidx + cspace;
-			if (nclen >= PAGE_SIZE) {
+			if (nclen >= (size_t)PAGE_SIZE) {
 error = EINVAL;
 goto failure;
 			}



CVS commit: src/sys/compat/netbsd32

2019-09-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 28 08:21:08 UTC 2019

Modified Files:
src/sys/compat/netbsd32: netbsd32_socket.c

Log Message:
signed/unsigned comparison.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/compat/netbsd32/netbsd32_socket.c

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



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

2019-09-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 28 07:24:52 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_gpio.c bcm2835_gpioreg.h

Log Message:
Handle BCM2838 (bcm2711) SoC pecularities.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/broadcom/bcm2835_gpio.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/broadcom/bcm2835_gpioreg.h

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



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

2019-09-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 28 07:24:52 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_gpio.c bcm2835_gpioreg.h

Log Message:
Handle BCM2838 (bcm2711) SoC pecularities.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/broadcom/bcm2835_gpio.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/broadcom/bcm2835_gpioreg.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/broadcom/bcm2835_gpio.c
diff -u src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.12 src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.13
--- src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.12	Fri May 10 08:28:50 2019
+++ src/sys/arch/arm/broadcom/bcm2835_gpio.c	Sat Sep 28 07:24:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_gpio.c,v 1.12 2019/05/10 08:28:50 skrll Exp $	*/
+/*	$NetBSD: bcm2835_gpio.c,v 1.13 2019/09/28 07:24:52 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2013, 2014, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.12 2019/05/10 08:28:50 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.13 2019/09/28 07:24:52 mlelstv Exp $");
 
 /*
  * Driver for BCM2835 GPIO
@@ -65,7 +65,9 @@ int bcm2835gpiodebug = 3;
 #define DPRINTF(l, x)
 #endif
 
-#define	BCMGPIO_MAXPINS	54
+#define BCM2835_GPIO_MAXPINS 54
+#define BCM2838_GPIO_MAXPINS 58
+#define	BCMGPIO_MAXPINS	BCM2838_GPIO_MAXPINS
 
 struct bcmgpio_eint {
 	 int			(*eint_func)(void *);
@@ -101,6 +103,9 @@ struct bcmgpio_softc {
 
 	/* For interrupt support. */
 	struct bcmgpio_bank	sc_banks[BCMGPIO_NBANKS];
+
+	bool			sc_is2835;	/* for pullup on 2711 */
+	u_int			sc_maxpins;
 };
 
 struct bcmgpio_pin {
@@ -216,7 +221,7 @@ bcm283x_pinctrl_set_config(device_t dev,
 	for (int i = 0; i < npins; i++) {
 		const u_int pin = be32toh(pins[i]);
 
-		if (pin > BCMGPIO_MAXPINS)
+		if (pin > sc->sc_maxpins)
 			continue;
 		if (pull) {
 			const int value = be32toh(pull[npull == 1 ? 0 : i]);
@@ -254,6 +259,7 @@ bcmgpio_attach(device_t parent, device_t
 	int error;
 	int pin;
 	int bank;
+	uint32_t reg;
 
 	const int phandle = faa->faa_phandle;
 	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
@@ -263,19 +269,25 @@ bcmgpio_attach(device_t parent, device_t
 
 	sc->sc_dev = self;
 
-	aprint_naive("\n");
-	aprint_normal(": GPIO controller\n");
-
 	sc->sc_iot = faa->faa_bst;
 	error = bus_space_map(sc->sc_iot, addr, size, 0, >sc_ioh);
 	if (error) {
-		aprint_error_dev(self, "couldn't map registers\n");
+		aprint_error_dev(self, ": couldn't map registers\n");
 		return;
 	}
 
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM);
 
-	for (pin = 0; pin < BCMGPIO_MAXPINS; pin++) {
+	/* BCM2835, BCM2836, BCM2837 return 'gpio' in this unused register */
+	reg = bus_space_read_4(sc->sc_iot, sc->sc_ioh, BCM2838_GPIO_GPPUPPDN(3));
+	sc->sc_is2835 = reg == 0x6770696f;
+	sc->sc_maxpins = sc->sc_is2835 ? BCM2835_GPIO_MAXPINS
+	   : BCM2838_GPIO_MAXPINS;
+
+	aprint_naive("\n");
+	aprint_normal(": GPIO controller %s\n", sc->sc_is2835 ? "2835" : "2838");
+
+	for (pin = 0; pin < sc->sc_maxpins; pin++) {
 		sc->sc_gpio_pins[pin].pin_num = pin;
 		/*
 		 * find out pins still available for GPIO
@@ -329,13 +341,13 @@ bcmgpio_attach(device_t parent, device_t
 			aprint_normal_dev(self,
 			"pins %d..%d interrupting on %s\n",
 			bank * 32,
-			MIN((bank * 32) + 31, BCMGPIO_MAXPINS),
+			MIN((bank * 32) + 31, sc->sc_maxpins),
 			intrstr);
 		} else {
 			aprint_error_dev(self,
 			"failed to establish interrupt for pins %d..%d\n",
 			bank * 32,
-			MIN((bank * 32) + 31, BCMGPIO_MAXPINS));
+			MIN((bank * 32) + 31, sc->sc_maxpins));
 		}
 	}
 
@@ -364,7 +376,7 @@ bcmgpio_attach(device_t parent, device_t
 
 	gba.gba_gc = >sc_gpio_gc;
 	gba.gba_pins = >sc_gpio_pins[0];
-	gba.gba_npins = BCMGPIO_MAXPINS;
+	gba.gba_npins = sc->sc_maxpins;
 	(void) config_found_ia(self, "gpiobus", , gpiobus_print);
 }
 
@@ -657,8 +669,9 @@ bcmgpio_gpio_intr_disestablish(void *vsc
 static bool
 bcmgpio_gpio_intrstr(void *vsc, int pin, int irqmode, char *buf, size_t buflen)
 {
+	struct bcmgpio_softc * const sc = vsc;
 
-	if (pin < 0 || pin >= BCMGPIO_MAXPINS)
+	if (pin < 0 || pin >= sc->sc_maxpins)
 		return (false);
 
 	snprintf(buf, buflen, "GPIO %d", pin);
@@ -797,15 +810,48 @@ bcm283x_pin_setpull(const struct bcmgpio
 
 	KASSERT(mutex_owned(>sc_lock));
 
-	const u_int mask = 1 << (pin % BCM2835_GPIO_GPPUD_PINS_PER_REGISTER);
-	const u_int regid = (pin / BCM2835_GPIO_GPPUD_PINS_PER_REGISTER);
+	u_int mask, regid;
+	uint32_t reg;
 
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_GPIO_GPPUD, pud);
-	delay(1);
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_GPIO_GPPUDCLK(regid), mask);
-	delay(1);
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_GPIO_GPPUD, 0);
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_GPIO_GPPUDCLK(regid), 0);
+	

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

2019-09-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Sep 27 08:57:12 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: mk.beagle

Log Message:
BEAGLE* kernel expects NetBSD bootargs (command line, no FDT).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/evbarm/conf/mk.beagle

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



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

2019-09-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Sep 27 08:57:12 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: mk.beagle

Log Message:
BEAGLE* kernel expects NetBSD bootargs (command line, no FDT).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/evbarm/conf/mk.beagle

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

Modified files:

Index: src/sys/arch/evbarm/conf/mk.beagle
diff -u src/sys/arch/evbarm/conf/mk.beagle:1.12 src/sys/arch/evbarm/conf/mk.beagle:1.13
--- src/sys/arch/evbarm/conf/mk.beagle:1.12	Sat May 18 08:49:23 2019
+++ src/sys/arch/evbarm/conf/mk.beagle	Fri Sep 27 08:57:12 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: mk.beagle,v 1.12 2019/05/18 08:49:23 skrll Exp $
+#	$NetBSD: mk.beagle,v 1.13 2019/09/27 08:57:12 mlelstv Exp $
 .if ${KERNEL_BUILD:T:MPANDA*} != ""
 CPPFLAGS+=		-mcpu=cortex-a9
 .elif ${KERNEL_BUILD:T:MOMAP5*} != ""
@@ -13,7 +13,7 @@ SYSTEM_FIRST_SFILE=	${ARM}/arm/armv6_sta
 
 _OSRELEASE!=		${HOST_SH} $S/conf/osrelease.sh
 
-MKUBOOTIMAGEARGS=	-A arm -T kernel -O linux
+MKUBOOTIMAGEARGS=	-A arm -T kernel -O netbsd
 MKUBOOTIMAGEARGS+=	-a $(LOADADDRESS) -e $(LOADADDRESS)
 MKUBOOTIMAGEARGS+=	-n "NetBSD/$(BOARDTYPE) ${_OSRELEASE}"
 MKUBOOTIMAGEARGS_NONE=	${MKUBOOTIMAGEARGS} -C none



CVS commit: src/sys/compat/netbsd32

2019-09-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Sep 27 08:17:12 UTC 2019

Modified Files:
src/sys/compat/netbsd32: netbsd32_socket.c

Log Message:
Ensure failure if resid goes negative.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/compat/netbsd32/netbsd32_socket.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/netbsd32/netbsd32_socket.c
diff -u src/sys/compat/netbsd32/netbsd32_socket.c:1.51 src/sys/compat/netbsd32/netbsd32_socket.c:1.52
--- src/sys/compat/netbsd32/netbsd32_socket.c:1.51	Fri Sep 27 08:12:01 2019
+++ src/sys/compat/netbsd32/netbsd32_socket.c	Fri Sep 27 08:17:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_socket.c,v 1.51 2019/09/27 08:12:01 mlelstv Exp $	*/
+/*	$NetBSD: netbsd32_socket.c,v 1.52 2019/09/27 08:17:11 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.51 2019/09/27 08:12:01 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.52 2019/09/27 08:17:11 mlelstv Exp $");
 
 #include 
 #include 
@@ -403,7 +403,8 @@ copyin32_msg_control(struct lwp *l, stru
 		/*
 		 * Sanity check the control message length.
 		 */
-		if (cmsg32.cmsg_len > (size_t)resid ||
+		if (resid < 0 ||
+		cmsg32.cmsg_len > (size_t)resid ||
 		cmsg32.cmsg_len < sizeof(cmsg32)) {
 			error = EINVAL;
 			goto failure;



CVS commit: src/sys/compat/netbsd32

2019-09-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Sep 27 08:17:12 UTC 2019

Modified Files:
src/sys/compat/netbsd32: netbsd32_socket.c

Log Message:
Ensure failure if resid goes negative.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/compat/netbsd32/netbsd32_socket.c

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



CVS commit: src/sys/compat/netbsd32

2019-09-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Sep 27 08:12:01 UTC 2019

Modified Files:
src/sys/compat/netbsd32: netbsd32_socket.c

Log Message:
signed/unsigned mismatch.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/compat/netbsd32/netbsd32_socket.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/netbsd32/netbsd32_socket.c
diff -u src/sys/compat/netbsd32/netbsd32_socket.c:1.50 src/sys/compat/netbsd32/netbsd32_socket.c:1.51
--- src/sys/compat/netbsd32/netbsd32_socket.c:1.50	Thu Sep 26 01:32:09 2019
+++ src/sys/compat/netbsd32/netbsd32_socket.c	Fri Sep 27 08:12:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_socket.c,v 1.50 2019/09/26 01:32:09 christos Exp $	*/
+/*	$NetBSD: netbsd32_socket.c,v 1.51 2019/09/27 08:12:01 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.50 2019/09/26 01:32:09 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.51 2019/09/27 08:12:01 mlelstv Exp $");
 
 #include 
 #include 
@@ -403,7 +403,7 @@ copyin32_msg_control(struct lwp *l, stru
 		/*
 		 * Sanity check the control message length.
 		 */
-		if (cmsg32.cmsg_len > resid ||
+		if (cmsg32.cmsg_len > (size_t)resid ||
 		cmsg32.cmsg_len < sizeof(cmsg32)) {
 			error = EINVAL;
 			goto failure;



CVS commit: src/sys/compat/netbsd32

2019-09-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Sep 27 08:12:01 UTC 2019

Modified Files:
src/sys/compat/netbsd32: netbsd32_socket.c

Log Message:
signed/unsigned mismatch.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/compat/netbsd32/netbsd32_socket.c

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



CVS commit: src/bin/ksh

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 11:01:09 UTC 2019

Modified Files:
src/bin/ksh: eval.c lex.c

Log Message:
Fix FALLTHROUGH comments.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/bin/ksh/eval.c
cvs rdiff -u -r1.23 -r1.24 src/bin/ksh/lex.c

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

Modified files:

Index: src/bin/ksh/eval.c
diff -u src/bin/ksh/eval.c:1.25 src/bin/ksh/eval.c:1.26
--- src/bin/ksh/eval.c:1.25	Tue Jun 12 14:13:55 2018
+++ src/bin/ksh/eval.c	Thu Sep 26 11:01:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.c,v 1.25 2018/06/12 14:13:55 kamil Exp $	*/
+/*	$NetBSD: eval.c,v 1.26 2019/09/26 11:01:09 mlelstv Exp $	*/
 
 /*
  * Expansion - quoting, separation, substitution, globbing
@@ -6,7 +6,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: eval.c,v 1.25 2018/06/12 14:13:55 kamil Exp $");
+__RCSID("$NetBSD: eval.c,v 1.26 2019/09/26 11:01:09 mlelstv Exp $");
 #endif
 
 #include 
@@ -493,6 +493,7 @@ expand(cp, wp, f)
 		  case XARGSEP:
 			type = XARG;
 			quote = 1;
+			/* FALLTHROUGH */
 		  case XARG:
 			if ((c = *x.str++) == '\0') {
 /* force null words to be created so

Index: src/bin/ksh/lex.c
diff -u src/bin/ksh/lex.c:1.23 src/bin/ksh/lex.c:1.24
--- src/bin/ksh/lex.c:1.23	Tue May  8 16:37:59 2018
+++ src/bin/ksh/lex.c	Thu Sep 26 11:01:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lex.c,v 1.23 2018/05/08 16:37:59 kamil Exp $	*/
+/*	$NetBSD: lex.c,v 1.24 2019/09/26 11:01:09 mlelstv Exp $	*/
 
 /*
  * lexical analysis and source input
@@ -6,7 +6,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: lex.c,v 1.23 2018/05/08 16:37:59 kamil Exp $");
+__RCSID("$NetBSD: lex.c,v 1.24 2019/09/26 11:01:09 mlelstv Exp $");
 #endif
 
 
@@ -254,7 +254,7 @@ yylex(cf)
 		*wp++ = QCHAR, *wp++ = c;
 		break;
 	}
-	/* FALLTROUGH */
+	/* FALLTHROUGH */
   default:
 	Xcheck(ws, wp);
 	if (c) { /* trailing \ is lost */



CVS commit: src/bin/ksh

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 11:01:09 UTC 2019

Modified Files:
src/bin/ksh: eval.c lex.c

Log Message:
Fix FALLTHROUGH comments.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/bin/ksh/eval.c
cvs rdiff -u -r1.23 -r1.24 src/bin/ksh/lex.c

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



CVS commit: src/sbin/raidctl

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 10:47:30 UTC 2019

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

Log Message:
Need MIN in userland. Also some more signed/unsigned clashes.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sbin/raidctl/raidctl.c

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

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.70 src/sbin/raidctl/raidctl.c:1.71
--- src/sbin/raidctl/raidctl.c:1.70	Thu Sep 26 10:33:30 2019
+++ src/sbin/raidctl/raidctl.c	Thu Sep 26 10:47:30 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.70 2019/09/26 10:33:30 mlelstv Exp $   */
+/*  $NetBSD: raidctl.c,v 1.71 2019/09/26 10:47:30 mlelstv Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.70 2019/09/26 10:33:30 mlelstv Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.71 2019/09/26 10:47:30 mlelstv Exp $");
 #endif
 
 
@@ -442,7 +442,7 @@ rf_get_device_status(int fd)
 		   device_status(device_config.devs[i].status));
 	}
 
-	nspares = uimin(device_config.nspares,
+	nspares = MIN(device_config.nspares,
 	__arraycount(device_config.spares));
 
 	if (nspares > 0) {
@@ -607,7 +607,7 @@ rf_output_configuration(int fd, const ch
 {
 	RF_DeviceConfig_t device_config;
 	void *cfg_ptr;
-	int i;
+	int i, nspares;
 	RF_ComponentLabel_t component_label;
 	void *label_ptr;
 	int component_num;
@@ -619,6 +619,9 @@ rf_output_configuration(int fd, const ch
 	printf("\n");
 	do_ioctl(fd, RAIDFRAME_GET_INFO, _ptr, "RAIDFRAME_GET_INFO");
 
+	nspares = MIN(device_config.nspares,
+	__arraycount(device_config.spares));
+	
 	/*
 	 * After NetBSD 9, convert this to not output the numRow's value,
 	 * which is no longer required or ever used.
@@ -635,9 +638,9 @@ rf_output_configuration(int fd, const ch
 		rf_output_devname(device_config.devs[i].devname));
 	printf("\n");
 
-	if (device_config.nspares > 0) {
+	if (nspares > 0) {
 		printf("START spare\n");
-		for(i=0; i < device_config.nspares; i++)
+		for(i=0; i < nspares; i++)
 			printf("%s\n", device_config.spares[i].devname);
 		printf("\n");
 	}
@@ -679,7 +682,7 @@ get_component_number(int fd, char *compo
 {
 	RF_DeviceConfig_t device_config;
 	void *cfg_ptr;
-	int i;
+	int i, nspares;
 	int found;
 
 	*component_number = -1;
@@ -690,6 +693,9 @@ get_component_number(int fd, char *compo
 		 "RAIDFRAME_GET_INFO");
 
 	*num_columns = device_config.cols;
+
+	nspares = MIN(device_config.nspares,
+	__arraycount(device_config.spares));
 	
 	found = 0;
 	for(i=0; i < device_config.ndevs; i++) {
@@ -700,7 +706,7 @@ get_component_number(int fd, char *compo
 		}
 	}
 	if (!found) { /* maybe it's a spare? */
-		for(i=0; i < device_config.nspares; i++) {
+		for(i=0; i < nspares; i++) {
 			if (strncmp(component_name, 
 device_config.spares[i].devname,
 PATH_MAX)==0) {



CVS commit: src/sbin/raidctl

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 10:47:30 UTC 2019

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

Log Message:
Need MIN in userland. Also some more signed/unsigned clashes.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sbin/raidctl/raidctl.c

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



CVS commit: src/sbin/raidctl

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 10:33:30 UTC 2019

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

Log Message:
nspares is now unsigned. Validate and use as positive integer.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/raidctl/raidctl.c

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



CVS commit: src/sbin/raidctl

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 10:33:30 UTC 2019

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

Log Message:
nspares is now unsigned. Validate and use as positive integer.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/raidctl/raidctl.c

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

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.69 src/sbin/raidctl/raidctl.c:1.70
--- src/sbin/raidctl/raidctl.c:1.69	Wed Feb  6 22:38:10 2019
+++ src/sbin/raidctl/raidctl.c	Thu Sep 26 10:33:30 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.69 2019/02/06 22:38:10 oster Exp $   */
+/*  $NetBSD: raidctl.c,v 1.70 2019/09/26 10:33:30 mlelstv Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.69 2019/02/06 22:38:10 oster Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.70 2019/09/26 10:33:30 mlelstv Exp $");
 #endif
 
 
@@ -430,7 +430,7 @@ rf_get_device_status(int fd)
 	RF_DeviceConfig_t device_config;
 	void *cfg_ptr;
 	int is_clean;
-	int i;
+	int i, nspares;
 
 	cfg_ptr = _config;
 
@@ -441,9 +441,13 @@ rf_get_device_status(int fd)
 		printf("%20s: %s\n", device_config.devs[i].devname, 
 		   device_status(device_config.devs[i].status));
 	}
-	if (device_config.nspares > 0) {
+
+	nspares = uimin(device_config.nspares,
+	__arraycount(device_config.spares));
+
+	if (nspares > 0) {
 		printf("Spares:\n");
-		for(i=0; i < device_config.nspares; i++) {
+		for(i=0; i < nspares; i++) {
 			printf("%20s: %s\n",
 			   device_config.spares[i].devname, 
 			   device_status(device_config.spares[i].status));
@@ -461,8 +465,8 @@ rf_get_device_status(int fd)
 		}
 	}
 
-	if (device_config.nspares > 0) {
-		for(i=0; i < device_config.nspares; i++) {
+	if (nspares > 0) {
+		for(i=0; i < nspares; i++) {
 			if ((device_config.spares[i].status == 
 			 rf_ds_optimal) ||
 			(device_config.spares[i].status == 



CVS commit: src/sys/dev/sdmmc

2019-09-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Sep 25 16:21:14 UTC 2019

Modified Files:
src/sys/dev/sdmmc: if_bwfm_sdio.c

Log Message:
Use correct function to verify if a task has been queued. Avoids race
that can corrupt the task queue.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/if_bwfm_sdio.c

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

Modified files:

Index: src/sys/dev/sdmmc/if_bwfm_sdio.c
diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.5 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.6
--- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.5	Fri Sep 13 11:21:03 2019
+++ src/sys/dev/sdmmc/if_bwfm_sdio.c	Wed Sep 25 16:21:14 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bwfm_sdio.c,v 1.5 2019/09/13 11:21:03 mlelstv Exp $ */
+/* $NetBSD: if_bwfm_sdio.c,v 1.6 2019/09/25 16:21:14 mlelstv Exp $ */
 /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -1267,10 +1267,9 @@ bwfm_sdio_intr(void *v)
 DPRINTF(("%s: sdio_intr\n", DEVNAME(sc)));
 
 	mutex_enter(>sc_intr_lock);
-	if (!sc->sc_task_queued) {
-		sc->sc_task_queued = true;
+	if (!sdmmc_task_pending(>sc_task))
 		sdmmc_add_task(sc->sc_sf[1]->sc, >sc_task);
-	}
+	sc->sc_task_queued = true;
 	mutex_exit(>sc_intr_lock);
 	return 1;
 }



CVS commit: src/sys/dev/sdmmc

2019-09-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Sep 25 16:21:14 UTC 2019

Modified Files:
src/sys/dev/sdmmc: if_bwfm_sdio.c

Log Message:
Use correct function to verify if a task has been queued. Avoids race
that can corrupt the task queue.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/if_bwfm_sdio.c

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



CVS commit: src/sys/dev/sdmmc

2019-09-23 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Sep 24 04:56:54 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmc_cis.c

Log Message:
Remove debug printf.


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

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

Modified files:

Index: src/sys/dev/sdmmc/sdmmc_cis.c
diff -u src/sys/dev/sdmmc/sdmmc_cis.c:1.6 src/sys/dev/sdmmc/sdmmc_cis.c:1.7
--- src/sys/dev/sdmmc/sdmmc_cis.c:1.6	Sun Sep  1 05:45:42 2019
+++ src/sys/dev/sdmmc/sdmmc_cis.c	Tue Sep 24 04:56:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_cis.c,v 1.6 2019/09/01 05:45:42 mlelstv Exp $	*/
+/*	$NetBSD: sdmmc_cis.c,v 1.7 2019/09/24 04:56:54 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc_cis.c,v 1.1 2006/06/01 21:53:41 uwe Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Routines to decode the Card Information Structure of SD I/O cards */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.6 2019/09/01 05:45:42 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.7 2019/09/24 04:56:54 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -130,7 +130,6 @@ decode_funce_function(struct sdmmc_funct
 	max_blk_size = sdmmc_io_read_1(sf0, reg + 11);
 	max_blk_size |= sdmmc_io_read_1(sf0, reg + 12) << 8;
 
-device_printf(dev, "MAX_BLK_SIZE%d = %d\n", sf->number, max_blk_size);
 	DPRINTF(("CISTPL_FUNCE: MAX_BLK_SIZE=0x%x\n", max_blk_size));
 }
 



CVS commit: src/sys/dev/sdmmc

2019-09-23 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Sep 24 04:56:54 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmc_cis.c

Log Message:
Remove debug printf.


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

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



CVS commit: src/distrib/sets/lists/man

2019-09-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Sep 16 08:31:05 UTC 2019

Modified Files:
src/distrib/sets/lists/man: mi

Log Message:
Include mount_zfs man pages only for MKZFS builds.


To generate a diff of this commit:
cvs rdiff -u -r1.1652 -r1.1653 src/distrib/sets/lists/man/mi

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



CVS commit: src/sys/kern

2019-09-14 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 14 15:06:33 UTC 2019

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

Log Message:
Fix build.


To generate a diff of this commit:
cvs rdiff -u -r1.282 -r1.283 src/sys/kern/uipc_socket.c

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

Modified files:

Index: src/sys/kern/uipc_socket.c
diff -u src/sys/kern/uipc_socket.c:1.282 src/sys/kern/uipc_socket.c:1.283
--- src/sys/kern/uipc_socket.c:1.282	Sat Sep 14 14:09:54 2019
+++ src/sys/kern/uipc_socket.c	Sat Sep 14 15:06:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket.c,v 1.282 2019/09/14 14:09:54 christos Exp $	*/
+/*	$NetBSD: uipc_socket.c,v 1.283 2019/09/14 15:06:33 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.282 2019/09/14 14:09:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.283 2019/09/14 15:06:33 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1229,7 +1229,7 @@ restart:
 			u_short *e;
 			if (m != NULL)
 goto dontblock;
-			*e = so->so_error ? >so_error : >so_rerror;
+			e = so->so_error ? >so_error : >so_rerror;
 			error = *e;
 			if ((flags & MSG_PEEK) == 0)
 *e = 0;



CVS commit: src/sys/kern

2019-09-14 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 14 15:06:33 UTC 2019

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

Log Message:
Fix build.


To generate a diff of this commit:
cvs rdiff -u -r1.282 -r1.283 src/sys/kern/uipc_socket.c

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



CVS commit: src/sys/dev/sdmmc

2019-09-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Sep 13 11:21:03 UTC 2019

Modified Files:
src/sys/dev/sdmmc: if_bwfm_sdio.c

Log Message:
Don't pass empty mbufs to the network stack.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/if_bwfm_sdio.c

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



CVS commit: src/sys/dev/sdmmc

2019-09-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Sep 13 11:21:03 UTC 2019

Modified Files:
src/sys/dev/sdmmc: if_bwfm_sdio.c

Log Message:
Don't pass empty mbufs to the network stack.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/if_bwfm_sdio.c

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

Modified files:

Index: src/sys/dev/sdmmc/if_bwfm_sdio.c
diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.4 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.5
--- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.4	Sun Sep  1 05:51:45 2019
+++ src/sys/dev/sdmmc/if_bwfm_sdio.c	Fri Sep 13 11:21:03 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bwfm_sdio.c,v 1.4 2019/09/01 05:51:45 mlelstv Exp $ */
+/* $NetBSD: if_bwfm_sdio.c,v 1.5 2019/09/13 11:21:03 mlelstv Exp $ */
 /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -1614,6 +1614,11 @@ bwfm_sdio_rx_frames(struct bwfm_sdio_sof
 break;
 			}
 			m_adj(m, hoff);
+			/* don't pass empty packet to stack */
+			if (m->m_len == 0) {
+m_freem(m);
+break;
+			}
 			bwfm_rx(>sc_sc, m);
 			nextlen = swhdr->nextlen << 4;
 			break;
@@ -1752,6 +1757,11 @@ bwfm_sdio_rx_glom(struct bwfm_sdio_softc
 break;
 			}
 			m_adj(m, hoff);
+			/* don't pass empty packet to stack */
+			if (m->m_len == 0) {
+m_freem(m);
+break;
+			}
 			bwfm_rx(>sc_sc, m);
 			break;
 		case BWFM_SDIO_SWHDR_CHANNEL_GLOM:



CVS commit: src/lib/libkvm

2019-09-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 12 10:18:50 UTC 2019

Modified Files:
src/lib/libkvm: kvm_aarch64.c

Log Message:
Need register defines that were moved to armreg.h


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libkvm/kvm_aarch64.c

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

Modified files:

Index: src/lib/libkvm/kvm_aarch64.c
diff -u src/lib/libkvm/kvm_aarch64.c:1.8 src/lib/libkvm/kvm_aarch64.c:1.9
--- src/lib/libkvm/kvm_aarch64.c:1.8	Wed Dec 19 11:02:21 2018
+++ src/lib/libkvm/kvm_aarch64.c	Thu Sep 12 10:18:50 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm_aarch64.c,v 1.8 2018/12/19 11:02:21 mrg Exp $ */
+/* $NetBSD: kvm_aarch64.c,v 1.9 2019/09/12 10:18:50 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2014, 2018 The NetBSD Foundation, Inc.
@@ -39,6 +39,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -48,7 +49,7 @@
 
 #include "kvm_private.h"
 
-__RCSID("$NetBSD: kvm_aarch64.c,v 1.8 2018/12/19 11:02:21 mrg Exp $");
+__RCSID("$NetBSD: kvm_aarch64.c,v 1.9 2019/09/12 10:18:50 mlelstv Exp $");
 
 /*ARGSUSED*/
 void



CVS commit: src/lib/libkvm

2019-09-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 12 10:18:50 UTC 2019

Modified Files:
src/lib/libkvm: kvm_aarch64.c

Log Message:
Need register defines that were moved to armreg.h


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libkvm/kvm_aarch64.c

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



CVS commit: src/sys/sys

2019-09-08 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  8 11:53:23 UTC 2019

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

Log Message:
Fix libkvm build.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/sys/signalvar.h

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

Modified files:

Index: src/sys/sys/signalvar.h
diff -u src/sys/sys/signalvar.h:1.94 src/sys/sys/signalvar.h:1.95
--- src/sys/sys/signalvar.h:1.94	Sun Sep  8 07:00:20 2019
+++ src/sys/sys/signalvar.h	Sun Sep  8 11:53:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: signalvar.h,v 1.94 2019/09/08 07:00:20 maxv Exp $	*/
+/*	$NetBSD: signalvar.h,v 1.95 2019/09/08 11:53:23 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -39,6 +39,10 @@
 #include 
 #include 
 
+#ifndef _KERNEL
+#include  /* Required for memset(3) and memcpy(3) prototypes */
+#endif /* _KERNEL */
+
 /*
  * Kernel signal definitions and data structures,
  * not exported to user programs.



CVS commit: src/sys/sys

2019-09-08 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  8 11:53:23 UTC 2019

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

Log Message:
Fix libkvm build.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/sys/signalvar.h

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



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

2019-09-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Sep  4 05:10:38 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: files.bcm2835

Log Message:
RNG200 attachment


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/arm/broadcom/files.bcm2835

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



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

2019-09-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Sep  4 05:10:38 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: files.bcm2835

Log Message:
RNG200 attachment


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/arm/broadcom/files.bcm2835

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/files.bcm2835
diff -u src/sys/arch/arm/broadcom/files.bcm2835:1.34 src/sys/arch/arm/broadcom/files.bcm2835:1.35
--- src/sys/arch/arm/broadcom/files.bcm2835:1.34	Sat Jun 22 07:58:55 2019
+++ src/sys/arch/arm/broadcom/files.bcm2835	Wed Sep  4 05:10:38 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.bcm2835,v 1.34 2019/06/22 07:58:55 skrll Exp $
+#	$NetBSD: files.bcm2835,v 1.35 2019/09/04 05:10:38 mlelstv Exp $
 #
 # Configuration info for Broadcom BCM2835 ARM Peripherals
 #
@@ -34,6 +34,12 @@ device	bcmrng
 attach bcmrng at fdt with bcmrng_fdt
 file	arch/arm/broadcom/bcm2835_rng.c		bcmrng
 
+# Random number generator (BCM2835_RNG_BASE (!))
+device	bcm2838rng
+attach bcm2838rng at fdt with bcm2838rng_fdt
+file	arch/arm/broadcom/bcm2838_rng.c		bcm2838rng
+file	dev/ic/rng200.cbcm2838rng
+
 # AUX
 device	bcmaux
 attach	bcmaux at fdt with bcmaux_fdt



CVS commit: src/sys/dev/ic

2019-09-02 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Sep  2 07:25:48 UTC 2019

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

Log Message:
tagging work queue as MPSAFE was premature. Revert.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/bwfm.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/bwfm.c
diff -u src/sys/dev/ic/bwfm.c:1.15 src/sys/dev/ic/bwfm.c:1.16
--- src/sys/dev/ic/bwfm.c:1.15	Sun Sep  1 05:40:39 2019
+++ src/sys/dev/ic/bwfm.c	Mon Sep  2 07:25:48 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.15 2019/09/01 05:40:39 mlelstv Exp $ */
+/* $NetBSD: bwfm.c,v 1.16 2019/09/02 07:25:48 mlelstv Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -143,7 +143,7 @@ bwfm_attach(struct bwfm_softc *sc)
 	int i, j, error;
 
 	error = workqueue_create(>sc_taskq, DEVNAME(sc),
-	bwfm_task, sc, PRI_NONE, IPL_NET, WQ_MPSAFE);
+	bwfm_task, sc, PRI_NONE, IPL_NET, 0);
 	if (error != 0) {
 		printf("%s: could not create workqueue\n", DEVNAME(sc));
 		return;



CVS commit: src/sys/dev/ic

2019-09-02 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Sep  2 07:25:48 UTC 2019

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

Log Message:
tagging work queue as MPSAFE was premature. Revert.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/bwfm.c

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



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

2019-09-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 17:27:22 UTC 2019

Added Files:
src/sys/arch/arm/broadcom: bcm2838_rng.c

Log Message:
Attachment for RNG200


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/broadcom/bcm2838_rng.c

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

Added files:

Index: src/sys/arch/arm/broadcom/bcm2838_rng.c
diff -u /dev/null src/sys/arch/arm/broadcom/bcm2838_rng.c:1.1
--- /dev/null	Sun Sep  1 17:27:22 2019
+++ src/sys/arch/arm/broadcom/bcm2838_rng.c	Sun Sep  1 17:27:22 2019
@@ -0,0 +1,92 @@
+/*	$NetBSD: bcm2838_rng.c,v 1.1 2019/09/01 17:27:22 mlelstv Exp $ */
+
+/*-
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared D. McNeill
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: bcm2838_rng.c,v 1.1 2019/09/01 17:27:22 mlelstv Exp $");
+
+#include 
+#include 
+
+#include 
+#include 
+
+struct bcm2838rng_softc {
+	device_t		sc_dev;
+	struct rng200_softc	sc_rng200;
+};
+
+static int bcm2838rng_match(device_t, cfdata_t, void *);
+static void bcm2838rng_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(bcm2838rng_fdt, sizeof(struct bcm2838rng_softc),
+bcm2838rng_match, bcm2838rng_attach, NULL, NULL);
+
+/* ARGSUSED */
+static int
+bcm2838rng_match(device_t parent, cfdata_t match, void *aux)
+{
+	const char * const compatible[] = { "brcm,bcm2838-rng200", NULL };
+	struct fdt_attach_args * const faa = aux;
+
+	return of_match_compatible(faa->faa_phandle, compatible);
+}
+
+static void
+bcm2838rng_attach(device_t parent, device_t self, void *aux)
+{
+	struct bcm2838rng_softc *sc = device_private(self);
+	struct fdt_attach_args * const faa = aux;
+	bus_addr_t addr;
+	bus_size_t size;
+	bus_space_handle_t bsh;
+	int error;
+
+	sc->sc_dev = self;
+
+	error = fdtbus_get_reg(faa->faa_phandle, 0, , );
+	if (error) {
+		aprint_error_dev(sc->sc_dev, ": couldn't get registers\n");
+		return;
+	}
+
+	if (bus_space_map(faa->faa_bst, addr, size, 0, )) {
+		aprint_error_dev(sc->sc_dev, ": unable to map device\n");
+		return;
+	}
+
+	aprint_naive("\n");
+	aprint_normal(": Hardware RNG\n");
+
+	sc->sc_rng200.sc_bst = faa->faa_bst;
+	sc->sc_rng200.sc_bsh = bsh;
+	sc->sc_rng200.sc_name = device_xname(sc->sc_dev);
+	rng200_attach(>sc_rng200);
+}



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

2019-09-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 17:27:22 UTC 2019

Added Files:
src/sys/arch/arm/broadcom: bcm2838_rng.c

Log Message:
Attachment for RNG200


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/broadcom/bcm2838_rng.c

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



CVS commit: src/sys/dev/ic

2019-09-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 14:44:14 UTC 2019

Added Files:
src/sys/dev/ic: rng200.c rng200reg.h rng200var.h

Log Message:
Driver for Broadcom RNG200 hardware random generator


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/rng200.c src/sys/dev/ic/rng200reg.h \
src/sys/dev/ic/rng200var.h

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

Added files:

Index: src/sys/dev/ic/rng200.c
diff -u /dev/null src/sys/dev/ic/rng200.c:1.1
--- /dev/null	Sun Sep  1 14:44:14 2019
+++ src/sys/dev/ic/rng200.c	Sun Sep  1 14:44:14 2019
@@ -0,0 +1,125 @@
+/*	$NetBSD: rng200.c,v 1.1 2019/09/01 14:44:14 mlelstv Exp $	*/
+
+/*
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Michael van Elst
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Driver for the Broadcom iProc RNG200
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define READ4(sc, r) \
+	bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (r))
+
+#define WRITE4(sc, r, v) \
+	bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (r), (v))
+
+static void
+rng200_reset(struct rng200_softc *sc)
+{
+	uint32_t ctl, rng, rbg;
+
+	/* Disable RBG */
+	ctl = READ4(sc, RNG200_CONTROL);
+	ctl &= ~RNG200_RBG_MASK;
+	WRITE4(sc, RNG200_CONTROL, ctl);
+
+	/* Clear interrupts */
+	WRITE4(sc, RNG200_STATUS, 0x);
+
+	/* Reset RNG and RBG */
+	rbg = READ4(sc, RNG200_RBG_RESET);
+	rng = READ4(sc, RNG200_RNG_RESET);
+	WRITE4(sc, RNG200_RBG_RESET, rbg | RBG_RESET);
+	WRITE4(sc, RNG200_RNG_RESET, rng | RNG_RESET);
+	WRITE4(sc, RNG200_RNG_RESET, rng);
+	WRITE4(sc, RNG200_RBG_RESET, rbg);
+
+	/* Enable RBG */
+	WRITE4(sc, RNG200_CONTROL, ctl | RNG200_RBG_ENABLE);
+}
+
+static void
+rng200_get(size_t bytes_wanted, void *priv)
+{
+	struct rng200_softc * const sc = priv;
+	uint32_t w, data;
+	unsigned count;
+
+	mutex_spin_enter(>sc_lock);
+	while (bytes_wanted) {
+
+		w = READ4(sc, RNG200_STATUS);
+		if ((w & (RNG200_MASTER_FAIL | RNG200_NIST_FAIL)) != 0)
+			rng200_reset(sc);
+
+		w = READ4(sc, RNG200_COUNT);
+		count = __SHIFTOUT(w, RNG200_COUNT_MASK);
+
+		if (count == 0)
+			break;
+
+		data = READ4(sc, RNG200_DATA);
+		rnd_add_data_sync(>sc_rndsource, ,
+		sizeof(data), sizeof(data) * NBBY);
+		bytes_wanted -= MIN(bytes_wanted, sizeof(data));
+	}
+	explicit_memset(, 0, sizeof(data));
+	mutex_spin_exit(>sc_lock);
+}
+
+void
+rng200_attach(struct rng200_softc *sc)
+{
+
+	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM);
+
+	rndsource_setcb(>sc_rndsource, rng200_get, sc);
+	rnd_attach_source(>sc_rndsource, sc->sc_name,
+		RND_TYPE_RNG, RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
+
+	rng200_get(RND_POOLBITS / NBBY, sc);
+}
+
+void
+rng200_detach(struct rng200_softc *sc)
+{
+
+	rnd_detach_source(>sc_rndsource);
+	mutex_destroy(>sc_lock);
+}
+
Index: src/sys/dev/ic/rng200reg.h
diff -u /dev/null src/sys/dev/ic/rng200reg.h:1.1
--- /dev/null	Sun Sep  1 14:44:14 2019
+++ src/sys/dev/ic/rng200reg.h	Sun Sep  1 14:44:14 2019
@@ -0,0 +1,54 @@
+/*	$NetBSD: rng200reg.h,v 1.1 2019/09/01 14:44:14 mlelstv Exp $	*/
+
+/*
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Michael van Elst
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must reta

CVS commit: src/sys/dev/ic

2019-09-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 14:44:14 UTC 2019

Added Files:
src/sys/dev/ic: rng200.c rng200reg.h rng200var.h

Log Message:
Driver for Broadcom RNG200 hardware random generator


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/rng200.c src/sys/dev/ic/rng200reg.h \
src/sys/dev/ic/rng200var.h

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



CVS commit: src/sys/dev/sdmmc

2019-08-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 05:51:45 UTC 2019

Modified Files:
src/sys/dev/sdmmc: if_bwfm_sdio.c
Added Files:
src/sys/dev/sdmmc: if_bwfm_sdio.h

Log Message:
>From OpenBSD:
- All the missing pieces (firmware load, chip setup, protocol handling)
TX queue and interrupt handling via sdmmc_task.
Fix locking.
Fix packet parsing.
Add parser for original firmware config files.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/sdmmc/if_bwfm_sdio.c
cvs rdiff -u -r0 -r1.1 src/sys/dev/sdmmc/if_bwfm_sdio.h

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



CVS commit: src/sys/dev/sdmmc

2019-08-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 05:51:45 UTC 2019

Modified Files:
src/sys/dev/sdmmc: if_bwfm_sdio.c
Added Files:
src/sys/dev/sdmmc: if_bwfm_sdio.h

Log Message:
>From OpenBSD:
- All the missing pieces (firmware load, chip setup, protocol handling)
TX queue and interrupt handling via sdmmc_task.
Fix locking.
Fix packet parsing.
Add parser for original firmware config files.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/sdmmc/if_bwfm_sdio.c
cvs rdiff -u -r0 -r1.1 src/sys/dev/sdmmc/if_bwfm_sdio.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/sdmmc/if_bwfm_sdio.c
diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.3 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.4
--- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.3	Fri May 11 07:41:11 2018
+++ src/sys/dev/sdmmc/if_bwfm_sdio.c	Sun Sep  1 05:51:45 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bwfm_sdio.c,v 1.3 2018/05/11 07:41:11 maya Exp $ */
+/* $NetBSD: if_bwfm_sdio.c,v 1.4 2019/09/01 05:51:45 mlelstv Exp $ */
 /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -20,14 +20,13 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -37,20 +36,16 @@
 
 #include 
 
+#include 
+
 #include 
 
+#include 
 #include 
 
 #include 
 #include 
-
-#define BWFM_SDIO_CCCR_BRCM_CARDCAP			0xf0
-#define  BWFM_SDIO_CCCR_BRCM_CARDCAP_CMD14_SUPPORT	0x02
-#define  BWFM_SDIO_CCCR_BRCM_CARDCAP_CMD14_EXT		0x04
-#define  BWFM_SDIO_CCCR_BRCM_CARDCAP_CMD_NODEC		0x08
-#define BWFM_SDIO_CCCR_BRCM_CARDCTRL			0xf1
-#define  BWFM_SDIO_CCCR_BRCM_CARDCTRL_WLANRESET		0x02
-#define BWFM_SDIO_CCCR_BRCM_SEPINT			0xf2
+#include 
 
 #ifdef BWFM_DEBUG
 #define DPRINTF(x)	do { if (bwfm_debug > 0) printf x; } while (0)
@@ -63,34 +58,122 @@ static int bwfm_debug = 2;
 
 #define DEVNAME(sc)	device_xname((sc)->sc_sc.sc_dev)
 
+enum bwfm_sdio_clkstate {
+	CLK_NONE,
+	CLK_SDONLY,
+	CLK_PENDING,
+	CLK_AVAIL
+};
+
 struct bwfm_sdio_softc {
-	struct bwfm_softc	  sc_sc;
+	struct bwfm_softc	sc_sc;
+	kmutex_t		sc_lock;
+	kmutex_t		sc_intr_lock;
+
+	bool			sc_bwfm_attached;
+
 	struct sdmmc_function	**sc_sf;
-	uint32_t		  sc_bar0;
+	size_t			sc_sf_size;
+
+	uint32_t		sc_bar0;
+	enum bwfm_sdio_clkstate	sc_clkstate;
+	bool			sc_sr_enabled;
+	bool			sc_alp_only;
+	bool			sc_sleeping;
+
+	struct sdmmc_task	sc_task;
+	bool			sc_task_queued;
+
+	uint8_t			sc_tx_seq;
+	uint8_t			sc_tx_max_seq;
+	int			sc_tx_count;
+	MBUFQ_HEAD()		sc_tx_queue;
+
+	struct mbuf		*sc_rxctl_queue;
+	kcondvar_t		sc_rxctl_cv;
+
+	void			*sc_ih;
+	struct bwfm_core	*sc_cc;
+
+	char			*sc_bounce_buf;
+	size_t			sc_bounce_size;
+
+	uint32_t		sc_console_addr;
+	char			*sc_console_buf;
+	size_t			sc_console_buf_size;
+	uint32_t		sc_console_readidx;
 };
 
-int		 bwfm_sdio_match(device_t, cfdata_t, void *);
-void		 bwfm_sdio_attach(device_t, struct device *, void *);
-int		 bwfm_sdio_detach(device_t, int);
-
-void		 bwfm_sdio_backplane(struct bwfm_sdio_softc *, uint32_t);
-uint8_t		 bwfm_sdio_read_1(struct bwfm_sdio_softc *, uint32_t);
-uint32_t	 bwfm_sdio_read_4(struct bwfm_sdio_softc *, uint32_t);
-void		 bwfm_sdio_write_1(struct bwfm_sdio_softc *, uint32_t,
+int		bwfm_sdio_match(device_t, cfdata_t, void *);
+void		bwfm_sdio_attach(device_t, struct device *, void *);
+int		bwfm_sdio_detach(device_t, int);
+void		bwfm_sdio_attachhook(device_t);
+
+void		bwfm_sdio_backplane(struct bwfm_sdio_softc *, uint32_t);
+uint8_t		bwfm_sdio_read_1(struct bwfm_sdio_softc *, uint32_t);
+uint32_t	bwfm_sdio_read_4(struct bwfm_sdio_softc *, uint32_t);
+void		bwfm_sdio_write_1(struct bwfm_sdio_softc *, uint32_t,
 		 uint8_t);
-void		 bwfm_sdio_write_4(struct bwfm_sdio_softc *, uint32_t,
+void		bwfm_sdio_write_4(struct bwfm_sdio_softc *, uint32_t,
+		 uint32_t);
+
+uint32_t	bwfm_sdio_dev_read(struct bwfm_sdio_softc *, uint32_t);
+void		bwfm_sdio_dev_write(struct bwfm_sdio_softc *, uint32_t,
 		 uint32_t);
 
-uint32_t	 bwfm_sdio_buscore_read(struct bwfm_softc *, uint32_t);
-void		 bwfm_sdio_buscore_write(struct bwfm_softc *, uint32_t,
+uint32_t	bwfm_sdio_buscore_read(struct bwfm_softc *, uint32_t);
+void		bwfm_sdio_buscore_write(struct bwfm_softc *, uint32_t,
 		 uint32_t);
-int		 bwfm_sdio_buscore_prepare(struct bwfm_softc *);
-void		 bwfm_sdio_buscore_activate(struct bwfm_softc *, uint32_t);
+int		bwfm_sdio_buscore_prepare(struct bwfm_softc *);
+void		bwfm_sdio_buscore_activate(struct bwfm_softc *, uint32_t);
 
-int		 bwfm_sdio_txcheck(struct bwfm_softc *);
-int		 bwfm_sdio_txdata(struct bwfm_softc *, struct mbuf *);
-int		 bwfm_sdio_txctl(struct bwfm_softc *, char *, size_t);
-int		 bwfm_sdio_rxctl(struct bwfm_softc *, char *, size_t *);
+int		bwfm_sdio_buf_read(struct bwfm_sdio_softc *,
+		struct sdmmc_function *, uint32_t, 

CVS commit: src/sys/dev/sdmmc

2019-08-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 05:45:42 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmc.c sdmmc_cis.c sdmmc_io.c sdmmc_ioreg.h
sdmmcvar.h

Log Message:
>From OpenBSD:
- support block length per function
- add functions to read/write regions
Decode (but not use) SDIO tuple in CIS.
Fix locking.
Add more SDIO defines (partially from version 3.0).


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/sdmmc/sdmmc.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmc_cis.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sdmmc/sdmmc_io.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/sdmmc/sdmmc_ioreg.h
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/sdmmc/sdmmcvar.h

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



CVS commit: src/sys/dev/sdmmc

2019-08-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 05:45:42 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmc.c sdmmc_cis.c sdmmc_io.c sdmmc_ioreg.h
sdmmcvar.h

Log Message:
>From OpenBSD:
- support block length per function
- add functions to read/write regions
Decode (but not use) SDIO tuple in CIS.
Fix locking.
Add more SDIO defines (partially from version 3.0).


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/sdmmc/sdmmc.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmc_cis.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sdmmc/sdmmc_io.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/sdmmc/sdmmc_ioreg.h
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/sdmmc/sdmmcvar.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/sdmmc/sdmmc.c
diff -u src/sys/dev/sdmmc/sdmmc.c:1.36 src/sys/dev/sdmmc/sdmmc.c:1.37
--- src/sys/dev/sdmmc/sdmmc.c:1.36	Tue Nov  6 16:01:38 2018
+++ src/sys/dev/sdmmc/sdmmc.c	Sun Sep  1 05:45:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc.c,v 1.36 2018/11/06 16:01:38 jmcneill Exp $	*/
+/*	$NetBSD: sdmmc.c,v 1.37 2019/09/01 05:45:42 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc.c,v 1.18 2009/01/09 10:58:38 jsg Exp $	*/
 
 /*
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.36 2018/11/06 16:01:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.37 2019/09/01 05:45:42 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -656,6 +656,7 @@ sdmmc_function_alloc(struct sdmmc_softc 
 	sf->cis.product = SDMMC_PRODUCT_INVALID;
 	sf->cis.function = SDMMC_FUNCTION_INVALID;
 	sf->width = 1;
+	sf->blklen = sdmmc_chip_host_maxblklen(sc->sc_sct, sc->sc_sch);
 
 	if (ISSET(sc->sc_flags, SMF_MEM_MODE) &&
 	ISSET(sc->sc_caps, SMC_CAPS_DMA) &&

Index: src/sys/dev/sdmmc/sdmmc_cis.c
diff -u src/sys/dev/sdmmc/sdmmc_cis.c:1.5 src/sys/dev/sdmmc/sdmmc_cis.c:1.6
--- src/sys/dev/sdmmc/sdmmc_cis.c:1.5	Sun Jan 28 14:34:06 2018
+++ src/sys/dev/sdmmc/sdmmc_cis.c	Sun Sep  1 05:45:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_cis.c,v 1.5 2018/01/28 14:34:06 jmcneill Exp $	*/
+/*	$NetBSD: sdmmc_cis.c,v 1.6 2019/09/01 05:45:42 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc_cis.c,v 1.1 2006/06/01 21:53:41 uwe Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Routines to decode the Card Information Structure of SD I/O cards */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.5 2018/01/28 14:34:06 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.6 2019/09/01 05:45:42 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -130,6 +130,7 @@ decode_funce_function(struct sdmmc_funct
 	max_blk_size = sdmmc_io_read_1(sf0, reg + 11);
 	max_blk_size |= sdmmc_io_read_1(sf0, reg + 12) << 8;
 
+device_printf(dev, "MAX_BLK_SIZE%d = %d\n", sf->number, max_blk_size);
 	DPRINTF(("CISTPL_FUNCE: MAX_BLK_SIZE=0x%x\n", max_blk_size));
 }
 
@@ -259,6 +260,11 @@ sdmmc_read_cis(struct sdmmc_function *sf
 			reg += tpllen;
 			break;
 
+		case PCMCIA_CISTPL_SDIO:
+			aprint_normal_dev(dev, "SDIO function\n");
+			reg += tpllen;
+			break;
+
 		default:
 			/*
 			 * Tuple codes between 80h-8Fh are vendor unique.

Index: src/sys/dev/sdmmc/sdmmc_io.c
diff -u src/sys/dev/sdmmc/sdmmc_io.c:1.14 src/sys/dev/sdmmc/sdmmc_io.c:1.15
--- src/sys/dev/sdmmc/sdmmc_io.c:1.14	Sun Oct 14 17:37:40 2018
+++ src/sys/dev/sdmmc/sdmmc_io.c	Sun Sep  1 05:45:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_io.c,v 1.14 2018/10/14 17:37:40 jdolecek Exp $	*/
+/*	$NetBSD: sdmmc_io.c,v 1.15 2019/09/01 05:45:42 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Routines for SD I/O cards. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.14 2018/10/14 17:37:40 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.15 2019/09/01 05:45:42 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -194,6 +194,8 @@ sdmmc_io_init(struct sdmmc_softc *sc, st
 
 	SDMMC_LOCK(sc);
 
+	sf->blklen = sdmmc_chip_host_maxblklen(sc->sc_sct, sc->sc_sch);
+
 	if (sf->number == 0) {
 		reg = sdmmc_io_read_1(sf, SD_IO_CCCR_CAPABILITY);
 		if (!(reg & CCCR_CAPS_LSC) || (reg & CCCR_CAPS_4BLS)) {
@@ -395,8 +397,8 @@ sdmmc_io_rw_extended(struct sdmmc_softc 
 	cmd.c_flags = SCF_CMD_AC | SCF_RSP_R5;
 	cmd.c_data = datap;
 	cmd.c_datalen = datalen;
-	cmd.c_blklen = MIN(datalen,
-	sdmmc_chip_host_maxblklen(sc->sc_sct,sc->sc_sch));
+	cmd.c_blklen = MIN(datalen, sf->blklen);
+
 	if (!ISSET(arg, SD_ARG_CMD53_WRITE))
 		cmd.c_flags |= SCF_CMD_READ;
 
@@ -476,21 +478,26 @@ int
 sdmmc_io_read_multi_1(struct sdmmc_function *sf, int reg, u_char *data,
 int datalen)
 {
-	int error;
+	int blocks, bytes, error = 0;
 
 	/* Don't lock */
 
-	while (datalen > SD_ARG_CMD53_LENGTH_MAX) {
+	while (datalen >= sf->blklen) {
+		//blocks = imin(datalen / sf->blklen,
+		//  SD_ARG_CMD53_LENGTH_MAX);
+		blocks = 1;
+		bytes = blocks * sf->blklen;
 		

CVS commit: src/sys/dev/ic

2019-08-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 05:40:40 UTC 2019

Modified Files:
src/sys/dev/ic: bwfm.c bwfmreg.h bwfmvar.h

Log Message:
>From OpenBSD:
- move event handling to workqueue
- check for save/restore capability
Tag work queue as MPsafe and increase length.
Juse use bpf_mtap(), the 802.11 encapsulation is handled by firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/bwfm.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/bwfmreg.h src/sys/dev/ic/bwfmvar.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/ic/bwfm.c
diff -u src/sys/dev/ic/bwfm.c:1.14 src/sys/dev/ic/bwfm.c:1.15
--- src/sys/dev/ic/bwfm.c:1.14	Sun Sep  2 19:46:53 2018
+++ src/sys/dev/ic/bwfm.c	Sun Sep  1 05:40:39 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.14 2018/09/02 19:46:53 maya Exp $ */
+/* $NetBSD: bwfm.c,v 1.15 2019/09/01 05:40:39 mlelstv Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -114,7 +114,8 @@ void	 bwfm_scan(struct bwfm_softc *);
 void	 bwfm_connect(struct bwfm_softc *);
 
 void	 bwfm_rx(struct bwfm_softc *, struct mbuf *);
-void	 bwfm_rx_event(struct bwfm_softc *, char *, size_t);
+void	 bwfm_rx_event(struct bwfm_softc *, struct mbuf *);
+void	 bwfm_rx_event_cb(struct bwfm_softc *, struct mbuf *);
 void	 bwfm_scan_node(struct bwfm_softc *, struct bwfm_bss_info *, size_t);
 
 uint8_t bwfm_2ghz_channels[] = {
@@ -142,7 +143,7 @@ bwfm_attach(struct bwfm_softc *sc)
 	int i, j, error;
 
 	error = workqueue_create(>sc_taskq, DEVNAME(sc),
-	bwfm_task, sc, PRI_NONE, IPL_NET, 0);
+	bwfm_task, sc, PRI_NONE, IPL_NET, WQ_MPSAFE);
 	if (error != 0) {
 		printf("%s: could not create workqueue\n", DEVNAME(sc));
 		return;
@@ -304,9 +305,6 @@ bwfm_start(struct ifnet *ifp)
 	/* TODO: return if no link? */
 
 	for (;;) {
-		struct ieee80211_node *ni;
-		struct ether_header *eh;
-
 		/* Discard management packets (fw handles this for us) */
 		IF_DEQUEUE(>ic_mgtq, m);
 		if (m != NULL) {
@@ -323,36 +321,19 @@ bwfm_start(struct ifnet *ifp)
 		if (m == NULL)
 			break;
 
-		eh = mtod(m, struct ether_header *);
-		ni = ieee80211_find_txnode(ic, eh->ether_dhost);
-		if (ni == NULL) {
-			ifp->if_oerrors++;
-			m_freem(m);
-			continue;
-		}
-
-		if (ieee80211_classify(ic, m, ni) != 0) {
-			ifp->if_oerrors++;
-			m_freem(m);
-			ieee80211_free_node(ni);
-			continue;
-		}
-
 		error = sc->sc_bus_ops->bs_txdata(sc, );
 		if (error == ENOBUFS) {
 			IF_PREPEND(>if_snd, m);
 			ifp->if_flags |= IFF_OACTIVE;
 			break;
 		}
-
 		if (error != 0) {
 			ifp->if_oerrors++;
 			m_freem(m);
-			if (ni != NULL)
-ieee80211_free_node(ni);
-		} else {
-			bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT);
+			continue;
 		}
+
+		bpf_mtap(ifp, m, BPF_D_OUT);
 	}
 }
 
@@ -770,6 +751,9 @@ bwfm_task(struct work *wk, void *arg)
 	case BWFM_TASK_KEY_DELETE:
 		bwfm_key_delete_cb(sc, >t_key);
 		break;
+	case BWFM_TASK_RX_EVENT:
+		bwfm_rx_event_cb(sc, t->t_mbuf);
+		break;
 	default:
 		panic("bwfm: unknown task command %d", t->t_cmd);
 	}
@@ -1261,6 +1245,52 @@ bwfm_chip_cm3_set_passive(struct bwfm_so
 	}
 }
 
+int
+bwfm_chip_sr_capable(struct bwfm_softc *sc)
+{
+	struct bwfm_core *core;
+	uint32_t reg;
+
+	if (sc->sc_chip.ch_pmurev < 17)
+		return 0;
+
+	switch (sc->sc_chip.ch_chip) {
+	case BRCM_CC_4345_CHIP_ID:
+	case BRCM_CC_4354_CHIP_ID:
+	case BRCM_CC_4356_CHIP_ID:
+		core = bwfm_chip_get_pmu(sc);
+		sc->sc_buscore_ops->bc_write(sc, core->co_base +
+		BWFM_CHIP_REG_CHIPCONTROL_ADDR, 3);
+		reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+		BWFM_CHIP_REG_CHIPCONTROL_DATA);
+		return (reg & (1 << 2)) != 0;
+	case BRCM_CC_43241_CHIP_ID:
+	case BRCM_CC_4335_CHIP_ID:
+	case BRCM_CC_4339_CHIP_ID:
+		core = bwfm_chip_get_pmu(sc);
+		sc->sc_buscore_ops->bc_write(sc, core->co_base +
+		BWFM_CHIP_REG_CHIPCONTROL_ADDR, 3);
+		reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+		BWFM_CHIP_REG_CHIPCONTROL_DATA);
+		return reg != 0;
+	case BRCM_CC_43430_CHIP_ID:
+		core = bwfm_chip_get_core(sc, BWFM_AGENT_CORE_CHIPCOMMON);
+		reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+		BWFM_CHIP_REG_SR_CONTROL1);
+		return reg != 0;
+	default:
+		core = bwfm_chip_get_pmu(sc);
+		reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+		BWFM_CHIP_REG_PMUCAPABILITIES_EXT);
+		if ((reg & BWFM_CHIP_REG_PMUCAPABILITIES_SR_SUPP) == 0)
+			return 0;
+		reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+		BWFM_CHIP_REG_RETENTION_CTL);
+		return (reg & (BWFM_CHIP_REG_RETENTION_CTL_MACPHY_DIS |
+		   BWFM_CHIP_REG_RETENTION_CTL_LOGIC_DIS)) == 0;
+	}
+}
+
 /* RAM size helpers */
 void
 bwfm_chip_socram_ramsize(struct bwfm_softc *sc, struct bwfm_core *core)
@@ -1455,8 +1485,6 @@ bwfm_proto_bcdc_query_dcmd(struct bwfm_s
 	}
 
 	if (buf) {
-		if (size > *len)
-			size = *len;
 		if (size 

CVS commit: src/sys/dev/ic

2019-08-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 05:40:40 UTC 2019

Modified Files:
src/sys/dev/ic: bwfm.c bwfmreg.h bwfmvar.h

Log Message:
>From OpenBSD:
- move event handling to workqueue
- check for save/restore capability
Tag work queue as MPsafe and increase length.
Juse use bpf_mtap(), the 802.11 encapsulation is handled by firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/bwfm.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/bwfmreg.h src/sys/dev/ic/bwfmvar.h

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



CVS commit: src/sys/dev/pcmcia

2019-08-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 00:36:52 UTC 2019

Modified Files:
src/sys/dev/pcmcia: pcmciareg.h

Log Message:
add PCMCIA_CISTPL_SDIO definition.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pcmcia/pcmciareg.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/pcmcia/pcmciareg.h
diff -u src/sys/dev/pcmcia/pcmciareg.h:1.10 src/sys/dev/pcmcia/pcmciareg.h:1.11
--- src/sys/dev/pcmcia/pcmciareg.h:1.10	Sun Dec 11 12:23:23 2005
+++ src/sys/dev/pcmcia/pcmciareg.h	Sun Sep  1 00:36:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcmciareg.h,v 1.10 2005/12/11 12:23:23 christos Exp $	*/
+/*	$NetBSD: pcmciareg.h,v 1.11 2019/09/01 00:36:52 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
@@ -202,6 +202,7 @@
 
 /* #define	PCMCIA_CISTPL_RESERVED		0x80-0x8F */
 #define	PCMCIA_CISTPL_SPCL			0x90
+#define	PCMCIA_CISTPL_SDIO			0x91
 /* #define	PCMCIA_CISTPL_RESERVED		0x90-0xFE */
 
 /*



CVS commit: src/sys/dev/pcmcia

2019-08-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 00:36:52 UTC 2019

Modified Files:
src/sys/dev/pcmcia: pcmciareg.h

Log Message:
add PCMCIA_CISTPL_SDIO definition.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pcmcia/pcmciareg.h

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



CVS commit: src/sys/dev/sdmmc

2019-08-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Aug 24 11:24:17 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmcdevs.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs.h

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



CVS commit: src/sys/dev/sdmmc

2019-08-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Aug 24 11:24:17 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmcdevs.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs.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/sdmmc/sdmmcdevs.h
diff -u src/sys/dev/sdmmc/sdmmcdevs.h:1.5 src/sys/dev/sdmmc/sdmmcdevs.h:1.6
--- src/sys/dev/sdmmc/sdmmcdevs.h:1.5	Sun Aug 18 14:32:34 2019
+++ src/sys/dev/sdmmc/sdmmcdevs.h	Sat Aug 24 11:24:17 2019
@@ -1,10 +1,10 @@
-/*	$NetBSD: sdmmcdevs.h,v 1.5 2019/08/18 14:32:34 mlelstv Exp $	*/
+/*	$NetBSD: sdmmcdevs.h,v 1.6 2019/08/24 11:24:17 mlelstv Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *		NetBSD: sdmmcdevs,v 1.5 2019/08/18 14:32:04 mlelstv Exp 
+ *		NetBSD: sdmmcdevs,v 1.6 2019/08/24 11:24:00 mlelstv Exp 
  */
 /*	$OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $	*/
 
@@ -31,8 +31,8 @@
 #define	SDMMC_VENDOR_TOSHIBA	0x0098	/* Toshiba */
 #define	SDMMC_VENDOR_SOCKETCOM	0x0104	/* Socket Communications, Inc. */
 #define	SDMMC_VENDOR_REALTEK	0x024c	/* Realtek */
-#define	SDMMC_VENDOR_BROADCOM	0x0270	/* Broadcom */
 #define	SDMMC_VENDOR_ATHEROS	0x0271	/* Atheros */
+#define	SDMMC_VENDOR_BROADCOM	0x02d0	/* Broadcom */
 #define	SDMMC_VENDOR_SYCHIP	0x02db	/* SyChip Inc. */
 #define	SDMMC_VENDOR_SPECTEC	0x02fe	/* Spectec Computer Co., Ltd */
 #define	SDMMC_VENDOR_MEDIATEK	0x037a	/* MediaTek Inc. */



CVS commit: src/sys/dev/sdmmc

2019-08-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Aug 24 11:24:00 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmcdevs

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs

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

Modified files:

Index: src/sys/dev/sdmmc/sdmmcdevs
diff -u src/sys/dev/sdmmc/sdmmcdevs:1.5 src/sys/dev/sdmmc/sdmmcdevs:1.6
--- src/sys/dev/sdmmc/sdmmcdevs:1.5	Sun Aug 18 14:32:04 2019
+++ src/sys/dev/sdmmc/sdmmcdevs	Sat Aug 24 11:24:00 2019
@@ -1,4 +1,4 @@
-	$NetBSD: sdmmcdevs,v 1.5 2019/08/18 14:32:04 mlelstv Exp $
+	$NetBSD: sdmmcdevs,v 1.6 2019/08/24 11:24:00 mlelstv Exp $
 /*	$OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $	*/
 
 /*
@@ -24,8 +24,8 @@ vendor CGUYS			0x0092	C-guys, Inc.
 vendor TOSHIBA			0x0098	Toshiba
 vendor SOCKETCOM		0x0104	Socket Communications, Inc.
 vendor REALTEK			0x024c	Realtek
-vendor BROADCOM			0x0270	Broadcom
 vendor ATHEROS			0x0271	Atheros
+vendor BROADCOM			0x02d0	Broadcom
 vendor SYCHIP			0x02db	SyChip Inc.
 vendor SPECTEC			0x02fe	Spectec Computer Co., Ltd
 vendor MEDIATEK			0x037a	MediaTek Inc.



  1   2   3   >