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/macppc/dev

2019-11-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Nov 23 05:13:11 UTC 2019

Modified Files:
src/sys/arch/macppc/dev: psoc.c

Log Message:
don't invalidate sensors every time we fail to read fan speeds


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/psoc.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/macppc/dev/psoc.c
diff -u src/sys/arch/macppc/dev/psoc.c:1.2 src/sys/arch/macppc/dev/psoc.c:1.3
--- src/sys/arch/macppc/dev/psoc.c:1.2	Fri Nov 22 05:16:54 2019
+++ src/sys/arch/macppc/dev/psoc.c	Sat Nov 23 05:13:11 2019
@@ -1,7 +1,7 @@
- /* $NetBSD: psoc.c,v 1.2 2019/11/22 05:16:54 macallan Exp $ */
+ /* $NetBSD: psoc.c,v 1.3 2019/11/23 05:13:11 macallan Exp $ */
 
 /*-
- * Copyright (c) 2018 Michael Lorenz
+ * Copyright (c) 2019 Michael Lorenz
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.2 2019/11/22 05:16:54 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.3 2019/11/23 05:13:11 macallan Exp $");
 
 #include 
 #include 
@@ -159,7 +159,7 @@ psoc_sensors_refresh(struct sysmon_envsy
 {
 	struct psoc_softc *sc = sme->sme_cookie;
 	uint8_t cmd = 6;
-	uint8_t buf[0x28], *bptr;
+	uint8_t buf[0x28];
 	int error = 1, data;
 
 	if ( edata->private < 0x20) {
@@ -183,26 +183,24 @@ psoc_sensors_refresh(struct sysmon_envsy
 			psoc_dump(sc);
 #endif
 	} else {
-		cmd = 0x20;
+		cmd = edata->private;
 		iic_acquire_bus(sc->sc_i2c, 0);
 		error = iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP,
-			sc->sc_addr, , 1, buf, 12, 0);
+			sc->sc_addr, , 1, buf, 3, 0);
 		iic_release_bus(sc->sc_i2c, 0);
 		if (error) return;
-		if (edata->private >= 0x20) {
-			bptr = [edata->private - 0x20];
-			switch (bptr[0] & 0xf0) {
-case 0x50:
-	data = bptr[edata->private - 0x20];
-	edata->value_cur = ((bptr[2] & 0x3f) << 6) | (bptr[1] & 0x3f);
-	break;
-case 0x60:
-	edata->value_cur = 0;
-	break;
-default:
-	error = -1;
-			}	
-		}
+		switch (buf[0] & 0xf0) {
+			case 0x50:
+data = buf[edata->private - 0x20];
+edata->value_cur = ((buf[2] & 0x3f) << 6) |
+		(buf[1] & 0x3f);
+break;
+			case 0x60:
+edata->value_cur = 0;
+break;
+			default:
+error = 0;
+		}	
 	}
 	if (error) {
 		edata->state = ENVSYS_SINVALID;



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

2019-11-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Nov 23 05:13:11 UTC 2019

Modified Files:
src/sys/arch/macppc/dev: psoc.c

Log Message:
don't invalidate sensors every time we fail to read fan speeds


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

2019-11-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov 22 05:16:54 UTC 2019

Modified Files:
src/sys/arch/macppc/dev: psoc.c

Log Message:
report fan speeds
disclaimer:
this is guesswork obtained from watching temperatures, listening to fan noise
and staring at register dumps. Use with caution.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/psoc.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/macppc/dev/psoc.c
diff -u src/sys/arch/macppc/dev/psoc.c:1.1 src/sys/arch/macppc/dev/psoc.c:1.2
--- src/sys/arch/macppc/dev/psoc.c:1.1	Fri Nov  1 17:51:56 2019
+++ src/sys/arch/macppc/dev/psoc.c	Fri Nov 22 05:16:54 2019
@@ -1,4 +1,4 @@
- /* $NetBSD: psoc.c,v 1.1 2019/11/01 17:51:56 macallan Exp $ */
+ /* $NetBSD: psoc.c,v 1.2 2019/11/22 05:16:54 macallan Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -30,15 +30,19 @@
  * fan controller found in 1GHz TiBook
  *
  * register values from OF:
- * fan1 - 0x20 ( status ), 0x31 ( data)
+ * fan1 - 0x20 ( status ), 0x31 ( data )
  * fan2 - 0x26 ( status ), 0x45 ( data )
- * fan3 - 0x59
+ * fan status byte 0:
+ * 0x5* - fan is running, 0x6* - fan stopped
+ * byte 1: unknown, 0x80 seems always set, lower bits seem to fluctuate
+ * byte 2: lower 6 bit seem to indicate speed
+ * fan speed may be lower 6 bit of byte 2 and lower 6 of byte 1 
  * temperature sensors start at 6, two bytes each, first appears to be
  * the temperature in degrees Celsius
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.1 2019/11/01 17:51:56 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.2 2019/11/22 05:16:54 macallan Exp $");
 
 #include 
 #include 
@@ -71,6 +75,8 @@ static void	psoc_attach(device_t, device
 
 static void	psoc_sensors_refresh(struct sysmon_envsys *, envsys_data_t *);
 
+static void	psoc_dump(struct psoc_softc *);
+
 CFATTACH_DECL_NEW(psoc, sizeof(struct psoc_softc),
 psoc_match, psoc_attach, NULL, NULL);
 
@@ -98,7 +104,7 @@ psoc_attach(device_t parent, device_t se
 	struct i2c_attach_args *ia = aux;
 	char path[256];
 	envsys_data_t *s;
-	int error, ih, r;
+	int error, ih, r, i;
 
 	sc->sc_dev = self;
 	sc->sc_i2c = ia->ia_tag;
@@ -122,19 +128,8 @@ psoc_attach(device_t parent, device_t se
 	sc->sc_sme->sme_refresh = psoc_sensors_refresh;
 	sc->sc_nsensors = 0;
 
-	int i, j;
-	uint8_t data, cmd;
-	for (i = 0; i < 0x7f; i+= 8) {
-		printf("%02x:", i);
-		for (j = 0; j < 8; j++) {
-			cmd = i + j;
-			data = 0;
-			iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP,
-			sc->sc_addr, , 1, , 1, 0);
-			printf(" %02x", data);
-		}
-		printf("\n");
-	}
+	psoc_dump(sc);
+
 	for (i = 0; i < 4; i++) {
 		r = i * 2 + 6;
 		s = >sc_sensors[sc->sc_nsensors];
@@ -145,8 +140,8 @@ psoc_attach(device_t parent, device_t se
 		sysmon_envsys_sensor_attach(sc->sc_sme, s);
 		sc->sc_nsensors++;
 	}
-#if 0
-	for (r = 0x31; r < 0x50; r += 0x14) {
+
+	for (r = 0x20; r < 0x2b; r += 0x06) {
 		s = >sc_sensors[sc->sc_nsensors];
 		s->state = ENVSYS_SINVALID;
 		s->units = ENVSYS_SFANRPM;
@@ -155,7 +150,7 @@ psoc_attach(device_t parent, device_t se
 		sysmon_envsys_sensor_attach(sc->sc_sme, s);
 		sc->sc_nsensors++;
 	}
-#endif
+
 	sysmon_envsys_register(sc->sc_sme);
 }
 
@@ -164,8 +159,8 @@ psoc_sensors_refresh(struct sysmon_envsy
 {
 	struct psoc_softc *sc = sme->sme_cookie;
 	uint8_t cmd = 6;
-	uint8_t buf[0x28];
-	int error = 1, data, i;
+	uint8_t buf[0x28], *bptr;
+	int error = 1, data;
 
 	if ( edata->private < 0x20) {
 		cmd = 0;
@@ -183,19 +178,30 @@ psoc_sensors_refresh(struct sysmon_envsy
 			/* Celsius -> microkelvin */
 			edata->value_cur = ((int)data * 100) + 27315;
 		}
+#ifdef PSOC_DEBUG
+		if (edata->private == 6)
+			psoc_dump(sc);
+#endif
 	} else {
-		cmd = 0x31;
+		cmd = 0x20;
 		iic_acquire_bus(sc->sc_i2c, 0);
 		error = iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP,
-			sc->sc_addr, , 1, buf, 0x28, 0);
+			sc->sc_addr, , 1, buf, 12, 0);
 		iic_release_bus(sc->sc_i2c, 0);
 		if (error) return;
-		if (edata->private > 0) {
-			data = buf[edata->private - 0x20];
-			edata->value_cur = data;
-			for (i = 0; i < 14; i++)
-printf(" %02x", buf[edata->private - 0x31 + i]);
-			printf("\n");
+		if (edata->private >= 0x20) {
+			bptr = [edata->private - 0x20];
+			switch (bptr[0] & 0xf0) {
+case 0x50:
+	data = bptr[edata->private - 0x20];
+	edata->value_cur = ((bptr[2] & 0x3f) << 6) | (bptr[1] & 0x3f);
+	break;
+case 0x60:
+	edata->value_cur = 0;
+	break;
+default:
+	error = -1;
+			}	
 		}
 	}
 	if (error) {
@@ -204,3 +210,21 @@ psoc_sensors_refresh(struct sysmon_envsy
 		edata->state = ENVSYS_SVALID;
 	}
 }
+
+static void
+ps

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

2019-11-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov 22 05:16:54 UTC 2019

Modified Files:
src/sys/arch/macppc/dev: psoc.c

Log Message:
report fan speeds
disclaimer:
this is guesswork obtained from watching temperatures, listening to fan noise
and staring at register dumps. Use with caution.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/psoc.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/sgimips/gio

2019-11-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Nov 21 22:05:09 UTC 2019

Modified Files:
src/sys/arch/sgimips/gio: gio.c

Log Message:
ga_iot = 0 -> normal_memt
now a Challenge S should work again
from George Harvey


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/sgimips/gio/gio.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/sgimips/gio/gio.c
diff -u src/sys/arch/sgimips/gio/gio.c:1.35 src/sys/arch/sgimips/gio/gio.c:1.36
--- src/sys/arch/sgimips/gio/gio.c:1.35	Wed Jul 20 22:16:37 2016
+++ src/sys/arch/sgimips/gio/gio.c	Thu Nov 21 22:05:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: gio.c,v 1.35 2016/07/20 22:16:37 macallan Exp $	*/
+/*	$NetBSD: gio.c,v 1.36 2019/11/21 22:05:09 macallan Exp $	*/
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gio.c,v 1.35 2016/07/20 22:16:37 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gio.c,v 1.36 2019/11/21 22:05:09 macallan Exp $");
 
 #include "opt_ddb.h"
 
@@ -329,7 +329,7 @@ gio_search(device_t parent, cfdata_t cf,
 
 		ga->ga_slot = cf->cf_loc[GIOCF_SLOT];
 		ga->ga_addr = cf->cf_loc[GIOCF_ADDR];
-		ga->ga_iot = 0;
+		ga->ga_iot = normal_memt;
 		ga->ga_ioh = MIPS_PHYS_TO_KSEG1(ga->ga_addr);
 
 		if (config_match(parent, cf, ga) > 0)



CVS commit: src/sys/arch/sgimips/gio

2019-11-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Nov 21 22:05:09 UTC 2019

Modified Files:
src/sys/arch/sgimips/gio: gio.c

Log Message:
ga_iot = 0 -> normal_memt
now a Challenge S should work again
from George Harvey


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/sgimips/gio/gio.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.



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/arch/powerpc/powerpc

2019-11-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Nov 16 00:16:56 UTC 2019

Modified Files:
src/sys/arch/powerpc/powerpc: openfirm.c

Log Message:
fix pasto - don't limit OF_finddevice() to 32 characters
now this works again


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/powerpc/powerpc/openfirm.c

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

Modified files:

Index: src/sys/arch/powerpc/powerpc/openfirm.c
diff -u src/sys/arch/powerpc/powerpc/openfirm.c:1.28 src/sys/arch/powerpc/powerpc/openfirm.c:1.29
--- src/sys/arch/powerpc/powerpc/openfirm.c:1.28	Fri Nov 15 23:41:47 2019
+++ src/sys/arch/powerpc/powerpc/openfirm.c	Sat Nov 16 00:16:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: openfirm.c,v 1.28 2019/11/15 23:41:47 macallan Exp $	*/
+/*	$NetBSD: openfirm.c,v 1.29 2019/11/16 00:16:55 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.28 2019/11/15 23:41:47 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.29 2019/11/16 00:16:55 macallan Exp $");
 
 #include 
 #include 
@@ -278,7 +278,7 @@ OF_finddevice(const char *name)
 	};
 
 	ofw_stack();
-	strncpy(OF_buf, name, 32);
+	strncpy(OF_buf, name, NBPG);
 	args.device = OF_buf;
 	if (openfirmware() == -1)
 		return -1;



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

2019-11-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov 15 23:43:13 UTC 2019

Modified Files:
src/sys/arch/powerpc/oea: ofw_subr.S

Log Message:
bump OF_buf(fer) since we may put extra parameters in there


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/oea/ofw_subr.S

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

Modified files:

Index: src/sys/arch/powerpc/oea/ofw_subr.S
diff -u src/sys/arch/powerpc/oea/ofw_subr.S:1.10 src/sys/arch/powerpc/oea/ofw_subr.S:1.11
--- src/sys/arch/powerpc/oea/ofw_subr.S:1.10	Wed Jul 27 22:04:23 2011
+++ src/sys/arch/powerpc/oea/ofw_subr.S	Fri Nov 15 23:43:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.S,v 1.10 2011/07/27 22:04:23 macallan Exp $	*/
+/*	$NetBSD: ofw_subr.S,v 1.11 2019/11/15 23:43:12 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -39,7 +39,7 @@
 	.local	OF_buffer
 
 	.lcomm	firmstk,NBPG,16
-	.lcomm	OF_buffer,NBPG,4
+	.lcomm	OF_buffer,NBPG + 36,4
 	.comm	openfirmware_entry,4,4	/* openfirmware entry point */
 	.lcomm	ofwsrsave,64,4		/* openfirmware SR savearea */
 	.comm	ofwmsr,20,4		/* msr & sprg[0-3] used in OF */



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

2019-11-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov 15 23:43:13 UTC 2019

Modified Files:
src/sys/arch/powerpc/oea: ofw_subr.S

Log Message:
bump OF_buf(fer) since we may put extra parameters in there


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/oea/ofw_subr.S

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



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

2019-11-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov 15 23:41:47 UTC 2019

Modified Files:
src/sys/arch/powerpc/powerpc: openfirm.c

Log Message:
stuff name parameters into OF_buf before calling OF
now things like ofctl work on my TiBook with FIRMWORKSBUGS


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/powerpc/powerpc/openfirm.c

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



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

2019-11-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov 15 23:41:47 UTC 2019

Modified Files:
src/sys/arch/powerpc/powerpc: openfirm.c

Log Message:
stuff name parameters into OF_buf before calling OF
now things like ofctl work on my TiBook with FIRMWORKSBUGS


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/powerpc/powerpc/openfirm.c

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

Modified files:

Index: src/sys/arch/powerpc/powerpc/openfirm.c
diff -u src/sys/arch/powerpc/powerpc/openfirm.c:1.27 src/sys/arch/powerpc/powerpc/openfirm.c:1.28
--- src/sys/arch/powerpc/powerpc/openfirm.c:1.27	Tue Jan  8 07:46:11 2019
+++ src/sys/arch/powerpc/powerpc/openfirm.c	Fri Nov 15 23:41:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: openfirm.c,v 1.27 2019/01/08 07:46:11 mrg Exp $	*/
+/*	$NetBSD: openfirm.c,v 1.28 2019/11/15 23:41:47 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.27 2019/01/08 07:46:11 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.28 2019/11/15 23:41:47 macallan Exp $");
 
 #include 
 #include 
@@ -159,8 +159,9 @@ OF_getproplen(int handle, const char *pr
 	};
 
 	ofw_stack();
+	strncpy(OF_buf, prop, 32);
 	args.phandle = handle;
-	args.prop = prop;
+	args.prop = OF_buf;
 	if (openfirmware() == -1)
 		return -1;
 	return args.proplen;
@@ -187,16 +188,17 @@ OF_getprop(int handle, const char *prop,
 	ofw_stack();
 	if (buflen > PAGE_SIZE)
 		return -1;
+	strncpy(OF_buf, prop, 32);
 	args.phandle = handle;
-	args.prop = prop;
-	args.buf = OF_buf;
+	args.prop = OF_buf;
+	args.buf = _buf[33];
 	args.buflen = buflen;
 	if (openfirmware() == -1)
 		return -1;
 	if (args.size > buflen)
 		args.size = buflen;
 	if (args.size > 0)
-		ofbcopy(OF_buf, buf, args.size);
+		ofbcopy(_buf[33], buf, args.size);
 	return args.size;
 }
 
@@ -250,12 +252,13 @@ OF_nextprop(int handle, const char *prop
 	};
 
 	ofw_stack();
+	strncpy(OF_buf, prop, 32);
 	args.phandle = handle;
-	args.prop = prop;
-	args.buf = OF_buf;
+	args.prop = OF_buf;
+	args.buf = _buf[33];
 	if (openfirmware() == -1)
 		return -1;
-	strncpy(nextprop, OF_buf, 32);
+	strncpy(nextprop, _buf[33], 32);
 	return args.flag;
 }
 
@@ -275,7 +278,8 @@ OF_finddevice(const char *name)
 	};
 
 	ofw_stack();
-	args.device = name;
+	strncpy(OF_buf, name, 32);
+	args.device = OF_buf;
 	if (openfirmware() == -1)
 		return -1;
 	return args.phandle;



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

2019-11-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Nov 12 17:27:59 UTC 2019

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5_11_2

Log Message:
add missing usb at ehci
thanks Romain Dolbeau for noticing


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/conf/POWERMAC_G5_11_2

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/macppc/conf/POWERMAC_G5_11_2
diff -u src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.13 src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.14
--- src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.13	Wed Aug  1 20:04:12 2018
+++ src/sys/arch/macppc/conf/POWERMAC_G5_11_2	Tue Nov 12 17:27:59 2019
@@ -143,6 +143,7 @@ ohci*	at pci? dev ? function ?	# USB Ope
 ehci*	at pci? dev ? function ?	# USB Enhanced Host Controller
 
 usb*	at ohci?	# USB bus support
+usb*	at ehci?	# USB bus support
 uhub*	at usb?		# USB Hubs
 uhub*	at uhub? port ?
 uhidev*	at uhub? port ? configuration ? interface ?	# USB HID device



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

2019-11-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Nov 12 17:27:59 UTC 2019

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5_11_2

Log Message:
add missing usb at ehci
thanks Romain Dolbeau for noticing


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/conf/POWERMAC_G5_11_2

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.



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/arch/macppc/conf

2019-11-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov  1 17:55:12 UTC 2019

Modified Files:
src/sys/arch/macppc/conf: GENERIC

Log Message:
add psoc driver


To generate a diff of this commit:
cvs rdiff -u -r1.357 -r1.358 src/sys/arch/macppc/conf/GENERIC

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



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

2019-11-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov  1 17:55:12 UTC 2019

Modified Files:
src/sys/arch/macppc/conf: GENERIC

Log Message:
add psoc driver


To generate a diff of this commit:
cvs rdiff -u -r1.357 -r1.358 src/sys/arch/macppc/conf/GENERIC

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

Modified files:

Index: src/sys/arch/macppc/conf/GENERIC
diff -u src/sys/arch/macppc/conf/GENERIC:1.357 src/sys/arch/macppc/conf/GENERIC:1.358
--- src/sys/arch/macppc/conf/GENERIC:1.357	Mon Sep 16 07:11:08 2019
+++ src/sys/arch/macppc/conf/GENERIC	Fri Nov  1 17:55:12 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.357 2019/09/16 07:11:08 macallan Exp $
+# $NetBSD: GENERIC,v 1.358 2019/11/01 17:55:12 macallan Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/macppc/conf/std.macppc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.357 $"
+#ident 		"GENERIC-$Revision: 1.358 $"
 
 maxusers	32
 
@@ -373,6 +373,7 @@ iic*	at ki2c?
 dbcool* 	at iic?		# dbCool thermal monitor & fan control
 deq* 		at iic?		# mixer/equalizer, used by snapper
 admtemp* 	at iic?		# temperature sensor found in Mini, G5
+psoc* 		at iic?		# fan controller found in TiBooks
 videopll*	at iic?		# for valkyriefb
 sgsmix* 	at iic?		# Additional mixer found in beige G3
 # use with awacs.



CVS commit: src/sys/arch/macppc

2019-11-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov  1 17:51:56 UTC 2019

Modified Files:
src/sys/arch/macppc/conf: files.macppc
Added Files:
src/sys/arch/macppc/dev: psoc.c

Log Message:
the beginning of a driver for the 'Psoc' fan controller found in my 1GHz
TiBook. So far it does:
- initialize the fan controller via OF
- report temperatures to envsys
there is no documentation, only guesswork from looking at OF methods

With this my TiBook doesn't seem to overheat anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r0 -r1.1 src/sys/arch/macppc/dev/psoc.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/macppc

2019-11-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov  1 17:51:56 UTC 2019

Modified Files:
src/sys/arch/macppc/conf: files.macppc
Added Files:
src/sys/arch/macppc/dev: psoc.c

Log Message:
the beginning of a driver for the 'Psoc' fan controller found in my 1GHz
TiBook. So far it does:
- initialize the fan controller via OF
- report temperatures to envsys
there is no documentation, only guesswork from looking at OF methods

With this my TiBook doesn't seem to overheat anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r0 -r1.1 src/sys/arch/macppc/dev/psoc.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/macppc/conf/files.macppc
diff -u src/sys/arch/macppc/conf/files.macppc:1.111 src/sys/arch/macppc/conf/files.macppc:1.112
--- src/sys/arch/macppc/conf/files.macppc:1.111	Wed May  8 13:40:15 2019
+++ src/sys/arch/macppc/conf/files.macppc	Fri Nov  1 17:51:56 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.macppc,v 1.111 2019/05/08 13:40:15 isaki Exp $
+#	$NetBSD: files.macppc,v 1.112 2019/11/01 17:51:56 macallan Exp $
 #
 # macppc-specific configuration info
 
@@ -312,3 +312,9 @@ defflag opt_valkyriefb.h VALKYRIEFB_DEBU
 device platinumfb: wsemuldisplaydev, rasops8, vcons, videomode
 attach platinumfb at mainbus
 file arch/macppc/dev/platinumfb.c			platinumfb
+
+# 'Psoc' fan controller found in (some?) TiBooks
+device	psoc: sysmon_envsys
+attach	psoc at iic
+file	arch/macppc/dev/psoc.cpsoc
+

Added files:

Index: src/sys/arch/macppc/dev/psoc.c
diff -u /dev/null src/sys/arch/macppc/dev/psoc.c:1.1
--- /dev/null	Fri Nov  1 17:51:56 2019
+++ src/sys/arch/macppc/dev/psoc.c	Fri Nov  1 17:51:56 2019
@@ -0,0 +1,206 @@
+ /* $NetBSD: psoc.c,v 1.1 2019/11/01 17:51:56 macallan Exp $ */
+
+/*-
+ * Copyright (c) 2018 Michael Lorenz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * fan controller found in 1GHz TiBook
+ *
+ * register values from OF:
+ * fan1 - 0x20 ( status ), 0x31 ( data)
+ * fan2 - 0x26 ( status ), 0x45 ( data )
+ * fan3 - 0x59
+ * temperature sensors start at 6, two bytes each, first appears to be
+ * the temperature in degrees Celsius
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.1 2019/11/01 17:51:56 macallan Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+
+struct psoc_softc {
+	device_t	sc_dev;
+	i2c_tag_t	sc_i2c;
+	i2c_addr_t	sc_addr;
+	int		sc_node;
+
+	struct sysmon_envsys *sc_sme;
+	envsys_data_t	sc_sensors[7];
+	int		sc_nsensors;
+	uint8_t		sc_temp[16];
+	time_t		sc_last;
+};
+
+static int	psoc_match(device_t, cfdata_t, void *);
+static void	psoc_attach(device_t, device_t, void *);
+
+static void	psoc_sensors_refresh(struct sysmon_envsys *, envsys_data_t *);
+
+CFATTACH_DECL_NEW(psoc, sizeof(struct psoc_softc),
+psoc_match, psoc_attach, NULL, NULL);
+
+static const struct device_compatible_entry compat_data[] = {
+	{ "Psoc",		0 },
+	{ NULL,			0 }
+};
+
+static int
+psoc_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct i2c_attach_args *ia = aux;
+	int match_result;
+
+	if (iic_use_direct_match(ia, match, compat_data, _result))
+		return match_result;
+
+	return 0;
+}
+
+static void
+psoc_attach(device_t parent, device_t self, void *aux)
+{
+	struct psoc_softc *sc = device_private(self);
+	struct i2c_attach_args *ia = aux;
+	char path[256];
+	envsys_data_t *s;
+	int error, ih, r;
+
+	sc->sc_dev = self;
+	sc->sc_i2c = ia->ia_tag;
+	sc->sc_addr = ia->ia_addr;
+	sc->sc_n

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/powerpc/oea

2019-10-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Oct 25 17:17:30 UTC 2019

Modified Files:
src/sys/arch/powerpc/oea: cpu_subr.c

Log Message:
register the IPI before spinning up CPUs, and make sure to do it exactly once
with this, and previous commits, G5s with four CPUs work
tested by Romain Dolbeau


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/powerpc/oea/cpu_subr.c

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

Modified files:

Index: src/sys/arch/powerpc/oea/cpu_subr.c
diff -u src/sys/arch/powerpc/oea/cpu_subr.c:1.101 src/sys/arch/powerpc/oea/cpu_subr.c:1.102
--- src/sys/arch/powerpc/oea/cpu_subr.c:1.101	Fri Sep 20 21:27:29 2019
+++ src/sys/arch/powerpc/oea/cpu_subr.c	Fri Oct 25 17:17:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_subr.c,v 1.101 2019/09/20 21:27:29 macallan Exp $	*/
+/*	$NetBSD: cpu_subr.c,v 1.102 2019/10/25 17:17:30 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2001 Matt Thomas.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.101 2019/09/20 21:27:29 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.102 2019/10/25 17:17:30 macallan Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_ppccache.h"
@@ -452,6 +452,12 @@ cpu_attach_common(device_t self, int id)
 	ci->ci_dev = self;
 	ci->ci_idlespin = cpu_idlespin;
 
+#ifdef MULTIPROCESSOR
+	/* Register IPI Interrupt */
+	if ((ipiops.ppc_establish_ipi) && (id == 0))
+		ipiops.ppc_establish_ipi(IST_LEVEL, IPL_HIGH, NULL);
+#endif
+
 	pvr = mfpvr();
 	vers = (pvr >> 16) & 0x;
 
@@ -1408,10 +1414,6 @@ cpu_spinup(device_t self, struct cpu_inf
 		return -1;
 	}
 
-	/* Register IPI Interrupt */
-	if (ipiops.ppc_establish_ipi)
-		ipiops.ppc_establish_ipi(IST_LEVEL, IPL_HIGH, NULL);
-
 	return 0;
 }
 



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

2019-10-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Oct 25 17:17:30 UTC 2019

Modified Files:
src/sys/arch/powerpc/oea: cpu_subr.c

Log Message:
register the IPI before spinning up CPUs, and make sure to do it exactly once
with this, and previous commits, G5s with four CPUs work
tested by Romain Dolbeau


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/powerpc/oea/cpu_subr.c

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



CVS commit: src/sys/arch/macppc/macppc

2019-10-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Oct 24 23:06:25 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: mainbus.c

Log Message:
if we have a /cpus node, use it to find and attach all CPUs.
Now we find all CPUs on a 4x G5.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/macppc/macppc/mainbus.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/macppc/macppc/mainbus.c
diff -u src/sys/arch/macppc/macppc/mainbus.c:1.21 src/sys/arch/macppc/macppc/mainbus.c:1.22
--- src/sys/arch/macppc/macppc/mainbus.c:1.21	Sun Jun  5 17:03:16 2011
+++ src/sys/arch/macppc/macppc/mainbus.c	Thu Oct 24 23:06:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.21 2011/06/05 17:03:16 matt Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.22 2019/10/24 23:06:25 macallan Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.21 2011/06/05 17:03:16 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.22 2019/10/24 23:06:25 macallan Exp $");
 
 #include 
 #include 
@@ -67,17 +67,29 @@ mainbus_attach(device_t parent, device_t
 {
 	struct ofbus_attach_args oba;
 	struct confargs ca;
-	int node, i;
+	int node, cpus, i;
 	u_int32_t reg[4];
 	char name[32];
 
 	printf("\n");
 
-	for (i = 0; i < 2; i++) {
-		ca.ca_name = "cpu";
-		ca.ca_reg = reg;
-		reg[0] = i;
-		config_found(self, , NULL);
+	cpus = OF_finddevice("/cpus");
+	if (cpus != 0) {
+		node = OF_child(cpus);
+		while (node != 0) {
+			ca.ca_name = "cpu";
+			ca.ca_reg = reg;
+			ca.ca_nreg = OF_getprop(node, "reg", reg, sizeof(reg));
+			config_found(self, , NULL);
+			node = OF_peer(node);
+		}			
+	} else {
+		for (i = 0; i < 2; i++) {
+			ca.ca_name = "cpu";
+			ca.ca_reg = reg;
+			reg[0] = i;
+			config_found(self, , NULL);
+		}
 	}
 
 	pic_finish_setup();



CVS commit: src/sys/arch/macppc/macppc

2019-10-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Oct 24 23:06:25 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: mainbus.c

Log Message:
if we have a /cpus node, use it to find and attach all CPUs.
Now we find all CPUs on a 4x G5.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/macppc/macppc/mainbus.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/macppc/include

2019-10-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Oct 24 23:04:46 UTC 2019

Modified Files:
src/sys/arch/macppc/include: cpu.h

Log Message:
bump CPU_MAXNUM to 4, hardware exists and is being asked about on port-macppc@


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/macppc/include/cpu.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/macppc/include

2019-10-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Oct 24 23:04:46 UTC 2019

Modified Files:
src/sys/arch/macppc/include: cpu.h

Log Message:
bump CPU_MAXNUM to 4, hardware exists and is being asked about on port-macppc@


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/macppc/include/cpu.h

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

Modified files:

Index: src/sys/arch/macppc/include/cpu.h
diff -u src/sys/arch/macppc/include/cpu.h:1.20 src/sys/arch/macppc/include/cpu.h:1.21
--- src/sys/arch/macppc/include/cpu.h:1.20	Fri Mar 16 22:08:53 2018
+++ src/sys/arch/macppc/include/cpu.h	Thu Oct 24 23:04:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.20 2018/03/16 22:08:53 macallan Exp $	*/
+/*	$NetBSD: cpu.h,v 1.21 2019/10/24 23:04:46 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995-1997 Wolfgang Solfrank.
@@ -34,7 +34,7 @@
 #define	_MACPPC_CPU_H_
 
 #if defined(_KERNEL) && !defined(_MODULE)
-#define	CPU_MAXNUM	2
+#define	CPU_MAXNUM	4
 extern char bootpath[];
 int get_cpuid(int, uint8_t *);
 #endif /* _KERNEL */



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

2019-10-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Oct 24 23:03:35 UTC 2019

Modified Files:
src/sys/arch/powerpc/include: intr.h

Log Message:
bump NIRQ to 256 since we're going to use vectors above 128


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/include/intr.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/powerpc/include

2019-10-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Oct 24 23:03:35 UTC 2019

Modified Files:
src/sys/arch/powerpc/include: intr.h

Log Message:
bump NIRQ to 256 since we're going to use vectors above 128


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/include/intr.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/powerpc/include/intr.h
diff -u src/sys/arch/powerpc/include/intr.h:1.13 src/sys/arch/powerpc/include/intr.h:1.14
--- src/sys/arch/powerpc/include/intr.h:1.13	Thu Apr 19 21:50:07 2018
+++ src/sys/arch/powerpc/include/intr.h	Thu Oct 24 23:03:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.13 2018/04/19 21:50:07 christos Exp $ */
+/*	$NetBSD: intr.h,v 1.14 2019/10/24 23:03:35 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -28,7 +28,7 @@
 
 #ifndef _LOCORE
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.h,v 1.13 2018/04/19 21:50:07 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.h,v 1.14 2019/10/24 23:03:35 macallan Exp $");
 #endif
 
 #ifndef _POWERPC_INTR_MACHDEP_H_
@@ -105,7 +105,7 @@ extern imask_t imask[];
 
 #define NVIRQ		(sizeof(imask_t)*8)	/* 32 virtual IRQs */
 #ifndef NIRQ
-#define NIRQ		128	/* up to 128 HW IRQs */
+#define NIRQ		256	/* up to 256 HW IRQs */
 #endif
 
 #define HWIRQ_MAX   (NVIRQ - 1)



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/arch/macppc/macppc

2019-10-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Oct 11 21:56:55 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
don't zero the MSR when building with options FIRMWORKSBUGS
with this a FIRMWORKSBUGS kernel boots on my TiBook
first step to address PR2231


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/macppc/macppc/locore.S

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

Modified files:

Index: src/sys/arch/macppc/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.73 src/sys/arch/macppc/macppc/locore.S:1.74
--- src/sys/arch/macppc/macppc/locore.S:1.73	Sun Jul 15 05:16:43 2018
+++ src/sys/arch/macppc/macppc/locore.S	Fri Oct 11 21:56:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.73 2018/07/15 05:16:43 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.74 2019/10/11 21:56:55 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -87,7 +87,9 @@ __start:
 	bl	_C_LABEL(cpu_model_init)	/* init oeacpufeat */
 
 	li	0,0
+#ifndef FIRMWORKSBUGS
 	mtmsr	0			/* Disable FPU/MMU/exceptions */
+#endif
 #if defined(PMAP_OEA64_BRIDGE)
 	mfmsr	0			/* Clear SF and ISF bits */
 	clrldi	0,0,3



CVS commit: src/sys/arch/macppc/macppc

2019-10-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Oct 11 21:56:55 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
don't zero the MSR when building with options FIRMWORKSBUGS
with this a FIRMWORKSBUGS kernel boots on my TiBook
first step to address PR2231


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/macppc/macppc/locore.S

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/i2c

2019-09-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Sep 29 05:35:29 UTC 2019

Modified Files:
src/sys/dev/i2c: ds1307.c

Log Message:
appease -Werror=stack-protector by avoiding variable sized arrays
Now this builds and works on sparc64


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/i2c/ds1307.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/i2c

2019-09-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Sep 29 05:35:29 UTC 2019

Modified Files:
src/sys/dev/i2c: ds1307.c

Log Message:
appease -Werror=stack-protector by avoiding variable sized arrays
Now this builds and works on sparc64


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/i2c/ds1307.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/i2c/ds1307.c
diff -u src/sys/dev/i2c/ds1307.c:1.32 src/sys/dev/i2c/ds1307.c:1.33
--- src/sys/dev/i2c/ds1307.c:1.32	Sun Sep 29 05:28:21 2019
+++ src/sys/dev/i2c/ds1307.c	Sun Sep 29 05:35:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ds1307.c,v 1.32 2019/09/29 05:28:21 macallan Exp $	*/
+/*	$NetBSD: ds1307.c,v 1.33 2019/09/29 05:35:29 macallan Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.32 2019/09/29 05:28:21 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.33 2019/09/29 05:35:29 macallan Exp $");
 
 #include 
 #include 
@@ -775,8 +775,9 @@ static int
 dsrtc_clock_write_timeval(struct dsrtc_softc *sc, time_t t)
 {
 	const struct dsrtc_model * const dm = >sc_model;
-	size_t buflen = dm->dm_rtc_size + 2; 
-	uint8_t buf[buflen];
+	size_t buflen = dm->dm_rtc_size + 2;
+	/* XXX: the biggest dm_rtc_size we have now is 7, so we should be ok */ 
+	uint8_t buf[16];
 	int error;
 
 	KASSERT((dm->dm_flags & DSRTC_FLAG_CLOCK_HOLD) == 0);



CVS commit: src/sys/dev/i2c

2019-09-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Sep 29 05:28:21 UTC 2019

Modified Files:
src/sys/dev/i2c: ds1307.c

Log Message:
add another matchstring for the ds1307 found in Sun Fire V210 ( and probably
V240 )


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/i2c/ds1307.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/i2c/ds1307.c
diff -u src/sys/dev/i2c/ds1307.c:1.31 src/sys/dev/i2c/ds1307.c:1.32
--- src/sys/dev/i2c/ds1307.c:1.31	Thu Dec 20 21:36:53 2018
+++ src/sys/dev/i2c/ds1307.c	Sun Sep 29 05:28:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ds1307.c,v 1.31 2018/12/20 21:36:53 macallan Exp $	*/
+/*	$NetBSD: ds1307.c,v 1.32 2019/09/29 05:28:21 macallan Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.31 2018/12/20 21:36:53 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.32 2019/09/29 05:28:21 macallan Exp $");
 
 #include 
 #include 
@@ -159,6 +159,7 @@ static const struct dsrtc_model mcp7940_
 static const struct device_compatible_entry compat_data[] = {
 	{ "dallas,ds1307",		(uintptr_t)_model },
 	{ "maxim,ds1307",		(uintptr_t)_model },
+	{ "i2c-ds1307",			(uintptr_t)_model },
 
 	{ "dallas,ds1339",		(uintptr_t)_model },
 	{ "maxim,ds1339",		(uintptr_t)_model },



CVS commit: src/sys/dev/i2c

2019-09-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Sep 29 05:28:21 UTC 2019

Modified Files:
src/sys/dev/i2c: ds1307.c

Log Message:
add another matchstring for the ds1307 found in Sun Fire V210 ( and probably
V240 )


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/i2c/ds1307.c

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



CVS commit: src/sys/dev/pci

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;
 }



  1   2   3   4   5   >