CVS commit: src/sys/dev/pci

2020-01-15 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Jan 16 07:19:47 UTC 2020

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

Log Message:
Fix wrong usage of PCI_PRODUCT(), ixl(4)


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

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

Modified files:

Index: src/sys/dev/pci/if_ixl.c
diff -u src/sys/dev/pci/if_ixl.c:1.22 src/sys/dev/pci/if_ixl.c:1.23
--- src/sys/dev/pci/if_ixl.c:1.22	Thu Jan 16 07:16:04 2020
+++ src/sys/dev/pci/if_ixl.c	Thu Jan 16 07:19:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ixl.c,v 1.22 2020/01/16 07:16:04 yamaguchi Exp $	*/
+/*	$NetBSD: if_ixl.c,v 1.23 2020/01/16 07:19:47 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2013-2015, Intel Corporation
@@ -1050,7 +1050,7 @@ ixl_attach(device_t parent, device_t sel
 	struct ixl_softc *sc;
 	struct pci_attach_args *pa = aux;
 	struct ifnet *ifp;
-	pcireg_t memtype, reg;
+	pcireg_t memtype;
 	uint32_t firstq, port, ari, func;
 	uint64_t phy_types = 0;
 	char xnamebuf[32];
@@ -1065,8 +1065,7 @@ ixl_attach(device_t parent, device_t sel
 	pa->pa_dmat64 : pa->pa_dmat;
 	sc->sc_aq_regs = _pf_aq_regs;
 
-	reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
-	sc->sc_mac_type = ixl_mactype(PCI_PRODUCT(reg));
+	sc->sc_mac_type = ixl_mactype(PCI_PRODUCT(pa->pa_id));
 
 	memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, IXL_PCIREG);
 	if (pci_mapreg_map(pa, IXL_PCIREG, memtype, 0,



CVS commit: src/sys/dev/dm

2020-01-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Jan 16 07:18:08 UTC 2020

Modified Files:
src/sys/dev/dm: device-mapper.c

Log Message:
dm(8) doesn't cause problems on suspend, don't block it.

Tested by Matthias Petermann, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/dev/dm/device-mapper.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/dm/device-mapper.c
diff -u src/sys/dev/dm/device-mapper.c:1.59 src/sys/dev/dm/device-mapper.c:1.60
--- src/sys/dev/dm/device-mapper.c:1.59	Sun Dec 22 13:16:09 2019
+++ src/sys/dev/dm/device-mapper.c	Thu Jan 16 07:18:08 2020
@@ -1,4 +1,4 @@
-/*$NetBSD: device-mapper.c,v 1.59 2019/12/22 13:16:09 tkusumi Exp $ */
+/*$NetBSD: device-mapper.c,v 1.60 2020/01/16 07:18:08 maya Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -245,6 +245,9 @@ dm_match(device_t parent, cfdata_t match
 static void
 dm_attach(device_t parent, device_t self, void *aux)
 {
+
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
 }
 
 /*
@@ -259,6 +262,8 @@ dm_detach(device_t self, int flags)
 {
 	dm_dev_t *dmv;
 
+	pmf_device_deregister(self);
+
 	/* Detach device from global device list */
 	if ((dmv = dm_dev_detach(self)) == NULL)
 		return ENOENT;



CVS commit: src/sys/dev/pci

2020-01-15 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Jan 16 07:16:04 UTC 2020

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

Log Message:
Fix ixl(4) not to assign interrupts to cpu #0
if ncpu > queue pairs


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

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

Modified files:

Index: src/sys/dev/pci/if_ixl.c
diff -u src/sys/dev/pci/if_ixl.c:1.21 src/sys/dev/pci/if_ixl.c:1.22
--- src/sys/dev/pci/if_ixl.c:1.21	Thu Jan 16 07:11:50 2020
+++ src/sys/dev/pci/if_ixl.c	Thu Jan 16 07:16:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ixl.c,v 1.21 2020/01/16 07:11:50 yamaguchi Exp $	*/
+/*	$NetBSD: if_ixl.c,v 1.22 2020/01/16 07:16:04 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2013-2015, Intel Corporation
@@ -807,7 +807,6 @@ static int	ixl_ifflags_cb(struct etherco
 static int	ixl_setup_interrupts(struct ixl_softc *);
 static int	ixl_establish_intx(struct ixl_softc *);
 static int	ixl_establish_msix(struct ixl_softc *);
-static void	ixl_set_affinity_msix(struct ixl_softc *);
 static void	ixl_enable_queue_intr(struct ixl_softc *,
 		struct ixl_queue_pair *);
 static void	ixl_disable_queue_intr(struct ixl_softc *,
@@ -5297,12 +5296,16 @@ static int
 ixl_establish_msix(struct ixl_softc *sc)
 {
 	pci_chipset_tag_t pc = sc->sc_pa.pa_pc;
+	kcpuset_t *affinity;
 	unsigned int vector = 0;
 	unsigned int i;
+	int affinity_to, r;
 	char xnamebuf[32];
 	char intrbuf[PCI_INTRSTR_LEN];
 	char const *intrstr;
 
+	kcpuset_create(, false);
+
 	/* the "other" intr is mapped to vector 0 */
 	vector = 0;
 	intrstr = pci_intr_string(pc, sc->sc_ihp[vector],
@@ -5317,10 +5320,23 @@ ixl_establish_msix(struct ixl_softc *sc)
 		"unable to establish interrupt at %s\n", intrstr);
 		goto fail;
 	}
+
+	aprint_normal_dev(sc->sc_dev, "other interrupt at %s", intrstr);
+
+	affinity_to = ncpu > (int)sc->sc_nqueue_pairs_max ? 1 : 0;
+	affinity_to = (affinity_to + sc->sc_nqueue_pairs_max) % ncpu;
+
+	kcpuset_zero(affinity);
+	kcpuset_set(affinity, affinity_to);
+	r = interrupt_distribute(sc->sc_ihs[vector], affinity, NULL);
+	if (r == 0) {
+		aprint_normal(", affinity to %u", affinity_to);
+	}
+	aprint_normal("\n");
 	vector++;
-	aprint_normal_dev(sc->sc_dev, "interrupt at %s\n", intrstr);
 
 	sc->sc_msix_vector_queue = vector;
+	affinity_to = ncpu > (int)sc->sc_nqueue_pairs_max ? 1 : 0;
 
 	for (i = 0; i < sc->sc_nqueue_pairs_max; i++) {
 		intrstr = pci_intr_string(pc, sc->sc_ihp[vector],
@@ -5337,11 +5353,23 @@ ixl_establish_msix(struct ixl_softc *sc)
 			"unable to establish interrupt at %s\n", intrstr);
 			goto fail;
 		}
-		vector++;
+
 		aprint_normal_dev(sc->sc_dev,
-		"interrupt at %s\n", intrstr);
+		"for TXRX%d interrupt at %s",i , intrstr);
+
+		kcpuset_zero(affinity);
+		kcpuset_set(affinity, affinity_to);
+		r = interrupt_distribute(sc->sc_ihs[vector], affinity, NULL);
+		if (r == 0) {
+			aprint_normal(", affinity to %u", affinity_to);
+			affinity_to = (affinity_to + 1) % ncpu;
+		}
+		aprint_normal("\n");
+		vector++;
 	}
 
+	kcpuset_destroy(affinity);
+
 	return 0;
 fail:
 	for (i = 0; i < vector; i++) {
@@ -5350,67 +5378,12 @@ fail:
 
 	sc->sc_msix_vector_queue = 0;
 	sc->sc_msix_vector_queue = 0;
+	kcpuset_destroy(affinity);
 
 	return -1;
 }
 
 static void
-ixl_set_affinity_msix(struct ixl_softc *sc)
-{
-	kcpuset_t *affinity;
-	pci_chipset_tag_t pc = sc->sc_pa.pa_pc;
-	int affinity_to, r;
-	unsigned int i, vector;
-	char intrbuf[PCI_INTRSTR_LEN];
-	char const *intrstr;
-
-	affinity_to = 0;
-	kcpuset_create(, false);
-
-	vector = sc->sc_msix_vector_queue;
-
-	for (i = 0; i < sc->sc_nqueue_pairs_max; i++) {
-		affinity_to = i % ncpu;
-
-		kcpuset_zero(affinity);
-		kcpuset_set(affinity, affinity_to);
-
-		intrstr = pci_intr_string(pc, sc->sc_ihp[vector + i],
-		intrbuf, sizeof(intrbuf));
-		r = interrupt_distribute(sc->sc_ihs[vector + i],
-		affinity, NULL);
-		if (r == 0) {
-			aprint_normal_dev(sc->sc_dev,
-			"for TXRX%u interrupting at %s affinity to %u\n",
-			i, intrstr, affinity_to);
-		} else {
-			aprint_normal_dev(sc->sc_dev,
-			"for TXRX%u interrupting at %s\n",
-			i, intrstr);
-		}
-	}
-
-	vector = 0; /* vector 0 means "other" interrupt */
-	affinity_to = (affinity_to + 1) % ncpu;
-	kcpuset_zero(affinity);
-	kcpuset_set(affinity, affinity_to);
-
-	intrstr = pci_intr_string(pc, sc->sc_ihp[vector],
-	intrbuf, sizeof(intrbuf));
-	r = interrupt_distribute(sc->sc_ihs[vector], affinity, NULL);
-	if (r == 0) {
-		aprint_normal_dev(sc->sc_dev,
-		"for other interrupting at %s affinity to %u\n",
-		intrstr, affinity_to);
-	} else {
-		aprint_normal_dev(sc->sc_dev,
-		"for other interrupting at %s", intrstr);
-	}
-
-	kcpuset_destroy(affinity);
-}
-
-static void
 ixl_config_queue_intr(struct ixl_softc *sc)
 {
 	unsigned int i, vector;
@@ -5538,8 +5511,6 @@ ixl_setup_interrupts(struct ixl_softc *s
 			if (error) {
 

CVS commit: src/sys/dev/pci

2020-01-15 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Jan 16 07:11:50 UTC 2020

Modified Files:
src/sys/dev/pci: files.pci if_ixl.c

Log Message:
Use def{flag,param} for parameters in ixl(4)


To generate a diff of this commit:
cvs rdiff -u -r1.419 -r1.420 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/if_ixl.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/files.pci
diff -u src/sys/dev/pci/files.pci:1.419 src/sys/dev/pci/files.pci:1.420
--- src/sys/dev/pci/files.pci:1.419	Wed Jan  1 10:11:21 2020
+++ src/sys/dev/pci/files.pci	Thu Jan 16 07:11:50 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.419 2020/01/01 10:11:21 ryo Exp $
+#	$NetBSD: files.pci,v 1.420 2020/01/16 07:11:50 yamaguchi Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -1185,3 +1185,6 @@ file	dev/pci/qat/qat_d15xx.c		qat
 device	ixl: ether, ifnet, arp
 attach	ixl at pci
 file	dev/pci/if_ixl.c	ixl
+defflag	opt_if_ixl.h	IXL_DEBUG
+defparam opt_if_ixl.h	IXL_STATS_INTERVAL_MSEC
+			IXL_QUEUE_NUM

Index: src/sys/dev/pci/if_ixl.c
diff -u src/sys/dev/pci/if_ixl.c:1.20 src/sys/dev/pci/if_ixl.c:1.21
--- src/sys/dev/pci/if_ixl.c:1.20	Wed Jan 15 08:25:01 2020
+++ src/sys/dev/pci/if_ixl.c	Thu Jan 16 07:11:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ixl.c,v 1.20 2020/01/15 08:25:01 yamaguchi Exp $	*/
+/*	$NetBSD: if_ixl.c,v 1.21 2020/01/16 07:11:50 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2013-2015, Intel Corporation
@@ -77,6 +77,7 @@
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
+#include "opt_if_ixl.h"
 #endif
 
 #include 



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

2020-01-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 16 06:34:24 UTC 2020

Modified Files:
src/sys/arch/arm/arm: arm_cpu_topology.c

Log Message:
make the topology support empty on non-SMP enabled kernels.
reduces kernel sizes and also fixes the builds.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/arm/arm_cpu_topology.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/arm/arm_cpu_topology.c
diff -u src/sys/arch/arm/arm/arm_cpu_topology.c:1.1 src/sys/arch/arm/arm/arm_cpu_topology.c:1.2
--- src/sys/arch/arm/arm/arm_cpu_topology.c:1.1	Wed Jan 15 08:34:04 2020
+++ src/sys/arch/arm/arm/arm_cpu_topology.c	Thu Jan 16 06:34:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm_cpu_topology.c,v 1.1 2020/01/15 08:34:04 mrg Exp $	*/
+/*	$NetBSD: arm_cpu_topology.c,v 1.2 2020/01/16 06:34:24 mrg Exp $	*/
 
 /*
  * Copyright (c) 2020 Matthew R. Green
@@ -28,10 +28,12 @@
  * SUCH DAMAGE.
  */
 
+/* CPU topology support for ARMv7 and ARMv8 systems.  */
+
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arm_cpu_topology.c,v 1.1 2020/01/15 08:34:04 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_cpu_topology.c,v 1.2 2020/01/16 06:34:24 mrg Exp $");
 
 #include 
 #include 
@@ -40,12 +42,14 @@ __KERNEL_RCSID(0, "$NetBSD: arm_cpu_topo
 
 #include 
 #include 
+#include 
 
 #include 
 
 void
 arm_cpu_topology_set(struct cpu_info * const ci, uint64_t mpidr, bool slow)
 {
+#ifdef MULTIPROCESSOR
 	uint pkgid, coreid, smtid, numaid = 0;
 
 	if (mpidr & MPIDR_MT) {
@@ -58,6 +62,7 @@ arm_cpu_topology_set(struct cpu_info * c
 		smtid = 0;
 	}
 	cpu_topology_set(ci, pkgid, coreid, smtid, numaid, slow);
+#endif /* MULTIPROCESSOR */
 }
 
 void
@@ -66,7 +71,6 @@ arm_cpu_do_topology(struct cpu_info *con
 #ifdef MULTIPROCESSOR
 	struct cpu_info *ci;
 	CPU_INFO_ITERATOR cii;
-#endif /* MULTIPROCESSOR */
 	prop_dictionary_t dict;
 	uint32_t capacity_dmips_mhz = 0;
 	static uint32_t best_cap = 0;
@@ -87,7 +91,6 @@ arm_cpu_do_topology(struct cpu_info *con
 	arm_cpu_topology_set(newci, arm_cpu_mpidr(newci),
 	newci->ci_capacity_dmips_mhz < best_cap);
 
-#ifdef MULTIPROCESSOR
 	/*
 	 * Using saved largest capacity, refresh previous topology info.
 	 * It's supposed to be OK to re-set topology.



CVS commit: src/usr.sbin/sysinst

2020-01-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 15 19:37:42 UTC 2020

Modified Files:
src/usr.sbin/sysinst: label.c

Log Message:
Avoid using the global "pm" variable in utility functions - during
extended partitioning they may point to a different device.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/sysinst/label.c

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

Modified files:

Index: src/usr.sbin/sysinst/label.c
diff -u src/usr.sbin/sysinst/label.c:1.18 src/usr.sbin/sysinst/label.c:1.19
--- src/usr.sbin/sysinst/label.c:1.18	Thu Jan  9 13:22:30 2020
+++ src/usr.sbin/sysinst/label.c	Wed Jan 15 19:37:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: label.c,v 1.18 2020/01/09 13:22:30 martin Exp $	*/
+/*	$NetBSD: label.c,v 1.19 2020/01/15 19:37:41 martin Exp $	*/
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: label.c,v 1.18 2020/01/09 13:22:30 martin Exp $");
+__RCSID("$NetBSD: label.c,v 1.19 2020/01/15 19:37:41 martin Exp $");
 #endif
 
 #include 
@@ -1983,14 +1983,16 @@ getpartoff(struct disk_partitions *parts
 			i = min;
 			localsizemult = 1;
 		} else {
-			i = parse_disk_pos(isize, , pm->dlcylsize, NULL);
+			i = parse_disk_pos(isize, , 
+			parts->pscheme->get_cylinder_size(parts), NULL);
 			if (i < 0) {
 errmsg = msg_string(MSG_invalid_sector_number);
 continue;
 			}
 		}
 		/* round to cylinder size if localsizemult != 1 */
-		i = NUMSEC(i, localsizemult, pm->dlcylsize);
+		int cylsize = parts->pscheme->get_cylinder_size(parts);
+		i = NUMSEC(i, localsizemult, cylsize);
 		/* Adjust to start of slice if needed */
 		if ((i < min && (min - i) < localsizemult) ||
 		(i > min && (i - min) < localsizemult)) {
@@ -2014,10 +2016,11 @@ getpartsize(struct disk_partitions *part
 	char dsize[24], isize[24], max_size[24], maxpartc, valid_parts[4],
 	*label_msg, *prompt, *head, *hint, *tail;
 	const char *errmsg = NULL;
-	daddr_t i, partend, localsizemult, max, max_r, dflt_r;
+	daddr_t i, partend, diskend, localsizemult, max, max_r, dflt_r;
 	struct disk_part_info info;
 	part_id partn;
 
+	diskend = parts->disk_start + parts->disk_size;
 	max = parts->pscheme->max_free_space_at(parts, partstart);
 
 	/* We need to keep both the unrounded and rounded (_r) max and dflt */
@@ -2092,7 +2095,7 @@ getpartsize(struct disk_partitions *part
 			max_r = max;
 		} else {
 			i = parse_disk_pos(isize, ,
-			pm->dlcylsize, NULL);
+			parts->pscheme->get_cylinder_size(parts), NULL);
 			if (localsizemult != sizemult)
 max_r = max;
 		}
@@ -2107,18 +2110,19 @@ getpartsize(struct disk_partitions *part
 		 * partend is aligned to a cylinder if localsizemult
 		 * is not 1 sector
 		 */
+		int cylsize = parts->pscheme->get_cylinder_size(parts);
 		partend = NUMSEC((partstart + i*localsizemult) / localsizemult,
-		localsizemult, pm->dlcylsize);
+		localsizemult, cylsize);
 		/* Align to end-of-disk or end-of-slice if close enough */
-		if (partend > (pm->dlsize - sizemult)
-		&& partend < (pm->dlsize + sizemult))
-			partend = pm->dlsize;
+		if (partend > (diskend - sizemult)
+		&& partend < (diskend + sizemult))
+			partend = diskend;
 		if (partend > (partstart + max - sizemult)
 		&& partend < (partstart + max + sizemult))
 			partend = partstart + max;
 		/* sanity checks */
-		if (partend > (partstart + pm->dlsize)) {
-			partend = pm->dlsize;
+		if (partend > diskend) {
+			partend = diskend;
 			errmsg = msg_string(MSG_endoutsidedisk);
 			continue;
 		}
@@ -2161,19 +2165,19 @@ parse_disk_pos(
 		if (*cp == 'G' || *cp == 'g') {
 			if (mult_found)
 return -1;
-			*localsizemult = GIG / pm->sectorsize;
+			*localsizemult = GIG / 512;
 			goto next;
 		}
 		if (*cp == 'M' || *cp == 'm') {
 			if (mult_found)
 return -1;
-			*localsizemult = MEG / pm->sectorsize;
+			*localsizemult = MEG / 512;
 			goto next;
 		}
 		if (*cp == 'c' || *cp == 'C') {
 			if (mult_found)
 return -1;
-			*localsizemult = pm->dlcylsize;
+			*localsizemult = cyl_size;
 			goto next;
 		}
 		if (*cp == 's' || *cp == 'S') {



CVS commit: src/usr.sbin/sysinst

2020-01-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 15 19:36:31 UTC 2020

Modified Files:
src/usr.sbin/sysinst: disklabel.c gpt.c mbr.c partitions.h

Log Message:
Add a method to query the partitioning schemes "internal idea" of a
cylinder size - whatever that means in the real world.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/sysinst/disklabel.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/sysinst/gpt.c
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/sysinst/mbr.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/sysinst/partitions.h

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

Modified files:

Index: src/usr.sbin/sysinst/disklabel.c
diff -u src/usr.sbin/sysinst/disklabel.c:1.29 src/usr.sbin/sysinst/disklabel.c:1.30
--- src/usr.sbin/sysinst/disklabel.c:1.29	Fri Jan 10 10:47:35 2020
+++ src/usr.sbin/sysinst/disklabel.c	Wed Jan 15 19:36:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: disklabel.c,v 1.29 2020/01/10 10:47:35 martin Exp $	*/
+/*	$NetBSD: disklabel.c,v 1.30 2020/01/15 19:36:30 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -114,6 +114,15 @@ disklabel_change_geom(struct disk_partit
 	return true;
 }
 
+static size_t
+disklabel_cylinder_size(const struct disk_partitions *arg)
+{
+	const struct disklabel_disk_partitions *parts =
+	(const struct disklabel_disk_partitions*)arg;
+
+	return parts->l.d_secpercyl;
+}
+
 static struct disk_partitions *
 disklabel_parts_new(const char *dev, daddr_t start, daddr_t len,
 daddr_t total_size, bool is_boot_drive, struct disk_partitions *parent)
@@ -1213,6 +1222,7 @@ disklabel_parts = {
 	.read_from_disk = disklabel_parts_read,
 	.create_new_for_disk = disklabel_parts_new,
 	.change_disk_geom = disklabel_change_geom,
+	.get_cylinder_size = disklabel_cylinder_size,
 	.find_by_name = disklabel_find_by_name,
 	.get_disk_pack_name = disklabel_get_disk_pack_name,
 	.set_disk_pack_name = disklabel_set_disk_pack_name,

Index: src/usr.sbin/sysinst/gpt.c
diff -u src/usr.sbin/sysinst/gpt.c:1.14 src/usr.sbin/sysinst/gpt.c:1.15
--- src/usr.sbin/sysinst/gpt.c:1.14	Thu Jan  9 13:22:30 2020
+++ src/usr.sbin/sysinst/gpt.c	Wed Jan 15 19:36:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt.c,v 1.14 2020/01/09 13:22:30 martin Exp $	*/
+/*	$NetBSD: gpt.c,v 1.15 2020/01/15 19:36:30 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -439,6 +439,12 @@ gpt_read_from_disk(const char *dev, dadd
 	return >dp;
 }
 
+static size_t
+gpt_cyl_size(const struct disk_partitions *arg)
+{
+	return MEG / 512;
+}
+
 static struct disk_partitions *
 gpt_create_new(const char *disk, daddr_t start, daddr_t len, daddr_t total,
 bool is_boot_drive, struct disk_partitions *parent)
@@ -1777,6 +1783,7 @@ gpt_parts = {
 	.create_unknown_part_type = gpt_create_unknown_part_type,
 	.get_part_alignment = gpt_get_part_alignment,
 	.read_from_disk = gpt_read_from_disk,
+	.get_cylinder_size = gpt_cyl_size,
 	.create_new_for_disk = gpt_create_new,
 	.have_boot_support = gpt_have_boot_support,
 	.find_by_name = gpt_find_by_name,

Index: src/usr.sbin/sysinst/mbr.c
diff -u src/usr.sbin/sysinst/mbr.c:1.26 src/usr.sbin/sysinst/mbr.c:1.27
--- src/usr.sbin/sysinst/mbr.c:1.26	Tue Jan 14 19:28:31 2020
+++ src/usr.sbin/sysinst/mbr.c	Wed Jan 15 19:36:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbr.c,v 1.26 2020/01/14 19:28:31 martin Exp $ */
+/*	$NetBSD: mbr.c,v 1.27 2020/01/15 19:36:30 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -2409,6 +2409,15 @@ mbr_guess_geom(struct disk_partitions *a
 	return 0;
 }
 
+static size_t
+mbr_get_cylinder(const struct disk_partitions *arg)
+{
+	const struct mbr_disk_partitions *parts =
+	(const struct mbr_disk_partitions*)arg;
+
+	return parts->geo_cyl;
+}
+
 static daddr_t
 mbr_max_part_size(const struct disk_partitions *arg, daddr_t fp_start)
 {
@@ -3026,6 +3035,7 @@ mbr_parts = {
 	.read_from_disk = mbr_read_from_disk,
 	.create_new_for_disk = mbr_create_new,
 	.guess_disk_geom = mbr_guess_geom,
+	.get_cylinder_size = mbr_get_cylinder,
 	.change_disk_geom = mbr_change_disk_geom,
 	.get_part_device = mbr_get_part_device,
 	.max_free_space_at = mbr_max_part_size,

Index: src/usr.sbin/sysinst/partitions.h
diff -u src/usr.sbin/sysinst/partitions.h:1.13 src/usr.sbin/sysinst/partitions.h:1.14
--- src/usr.sbin/sysinst/partitions.h:1.13	Thu Jan  9 13:22:30 2020
+++ src/usr.sbin/sysinst/partitions.h	Wed Jan 15 19:36:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: partitions.h,v 1.13 2020/01/09 13:22:30 martin Exp $	*/
+/*	$NetBSD: partitions.h,v 1.14 2020/01/15 19:36:30 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -457,6 +457,12 @@ struct disk_partitioning_scheme {
 	int *cyl, int *head, int *sec);
 
 	/*
+	 * Return a "cylinder size" (in number of blocks) - whatever that
+	 * means to a particular partitioning scheme.
+	 */
+	size_t (*get_cylinder_size)(const struct disk_partitions *);
+
+	/*
 	 * Optional: 

CVS commit: src/usr.sbin/sysinst

2020-01-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 15 19:08:24 UTC 2020

Modified Files:
src/usr.sbin/sysinst: partman.c

Log Message:
Fix handling of inner/outer partitions (e.g. MBR and disklabel) in
extended partitioning:
 - when editing a disk with such a schme, offer both partitions in two
   steps
 - when commiting changes save the inner partitions after the outer ones


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/sysinst/partman.c

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

Modified files:

Index: src/usr.sbin/sysinst/partman.c
diff -u src/usr.sbin/sysinst/partman.c:1.47 src/usr.sbin/sysinst/partman.c:1.48
--- src/usr.sbin/sysinst/partman.c:1.47	Fri Jan 10 12:55:14 2020
+++ src/usr.sbin/sysinst/partman.c	Wed Jan 15 19:08:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: partman.c,v 1.47 2020/01/10 12:55:14 martin Exp $ */
+/*	$NetBSD: partman.c,v 1.48 2020/01/15 19:08:24 martin Exp $ */
 
 /*
  * Copyright 2012 Eugene Lozovoy
@@ -2650,6 +2650,7 @@ pm_commit(menudesc *m, void *arg)
 {
 	int retcode;
 	struct pm_devs *pm_i;
+	struct disk_partitions *secondary;
 
 	pm_retvalue = -1;
 	SLIST_FOREACH(pm_i, _head, l) {
@@ -2665,6 +2666,20 @@ pm_commit(menudesc *m, void *arg)
 pm_i->diskdev);
 			return -1;
 		}
+		if (pm_i->parts->pscheme->secondary_scheme != NULL) {
+			secondary = pm_i->parts->pscheme->
+			secondary_partitions(pm_i->parts, -1, false);
+			if (secondary != NULL) {
+if (!secondary->pscheme->write_to_disk(
+secondary)) {
+	if (logfp)
+		fprintf(logfp, 
+		"partitining error %s\n",
+		pm_i->diskdev);
+	return -1;
+}
+			}
+		}
 	}
 
 	/* Call all functions that may create new devices */
@@ -3232,20 +3247,29 @@ pm_edit_partitions(struct part_entry *pe
 {
 	struct pm_devs *my_pm = pm_from_pe(pe);
 	struct partition_usage_set pset = { 0 };
+	struct disk_partitions *parts;
 
 	if (!my_pm)
 		return;
 
 	if (!pm_force_parts(my_pm))
 		return;
+	parts = my_pm->parts;
 
 	clear();
 	refresh();
 
-	usage_set_from_parts(, my_pm->parts);
+	if (my_pm->parts->pscheme->secondary_scheme != NULL) {
+		if (!edit_outer_parts(my_pm->parts))
+			goto done;
+		parts = get_inner_parts(parts);
+	}
+
+	usage_set_from_parts(, parts);
 	edit_and_check_label(my_pm, , false);
 	free_usage_set();
 
+done:
 	pm_partusage(my_pm, -1, -1);
 	my_pm->unsaved = true;
 	pm_retvalue = 1;



CVS commit: src/sys/arch

2020-01-15 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan 15 18:47:23 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: locore.S
src/sys/arch/i386/i386: locore.S

Log Message:
Back out the cpu_switchto() workaround now that it's no longer needed.


To generate a diff of this commit:
cvs rdiff -u -r1.199 -r1.200 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.176 -r1.177 src/sys/arch/i386/i386/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/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.199 src/sys/arch/amd64/amd64/locore.S:1.200
--- src/sys/arch/amd64/amd64/locore.S:1.199	Mon Jan 13 11:40:15 2020
+++ src/sys/arch/amd64/amd64/locore.S	Wed Jan 15 18:47:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.199 2020/01/13 11:40:15 ad Exp $	*/
+/*	$NetBSD: locore.S,v 1.200 2020/01/15 18:47:23 ad Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1079,14 +1079,10 @@ ENTRY(cpu_switchto)
 	movq	%rdi,%r13	/* oldlwp */
 	movq	%rsi,%r12	/* newlwp */
 
-	testq	%r13,%r13	/* oldlwp = NULL ? */
-	jz	.Lskip_save
-
 	/* Save old context. */
 	movq	L_PCB(%r13),%rax
 	movq	%rsp,PCB_RSP(%rax)
 	movq	%rbp,PCB_RBP(%rax)
-.Lskip_save:
 
 	/* Switch to newlwp's stack. */
 	movq	L_PCB(%r12),%r14

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.176 src/sys/arch/i386/i386/locore.S:1.177
--- src/sys/arch/i386/i386/locore.S:1.176	Mon Jan 13 12:03:41 2020
+++ src/sys/arch/i386/i386/locore.S	Wed Jan 15 18:47:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.176 2020/01/13 12:03:41 ad Exp $	*/
+/*	$NetBSD: locore.S,v 1.177 2020/01/15 18:47:23 ad Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.176 2020/01/13 12:03:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.177 2020/01/15 18:47:23 ad Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1316,14 +1316,10 @@ ENTRY(cpu_switchto)
 	movl	20(%esp),%edi		/* newlwp */
 	movl	24(%esp),%edx		/* returning */
 
-	testl	%esi,%esi		/* oldlwp = NULL ? */
-	jz	skip_save
-
 	/* Save old context. */
 	movl	L_PCB(%esi),%eax
 	movl	%esp,PCB_ESP(%eax)
 	movl	%ebp,PCB_EBP(%eax)
-skip_save:
 
 	/* Switch to newlwp's stack. */
 	movl	L_PCB(%edi),%ebx



CVS commit: src/sys/sys

2020-01-15 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan 15 18:45:57 UTC 2020

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

Log Message:
NetBSD 9.99.38 - VM system changes


To generate a diff of this commit:
cvs rdiff -u -r1.640 -r1.641 src/sys/sys/param.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/param.h
diff -u src/sys/sys/param.h:1.640 src/sys/sys/param.h:1.641
--- src/sys/sys/param.h:1.640	Sun Jan 12 21:37:15 2020
+++ src/sys/sys/param.h	Wed Jan 15 18:45:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.640 2020/01/12 21:37:15 ad Exp $	*/
+/*	$NetBSD: param.h,v 1.641 2020/01/15 18:45:57 ad Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999003700	/* NetBSD 9.99.37 */
+#define	__NetBSD_Version__	999003800	/* NetBSD 9.99.38 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/usr.bin/vmstat

2020-01-15 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan 15 17:56:46 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
vmstat -s: report new stats:

0 per-cpu stats one synced
 7246 per-cpu stats all synced
 4092 anon pages possibly dirty
 8881 anon pages dirty
0 anon pages clean
   68 file pages possibly dirty
0 file pages dirty
  2367889 file pages clean


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/usr.bin/vmstat/vmstat.c

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

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.234 src/usr.bin/vmstat/vmstat.c:1.235
--- src/usr.bin/vmstat/vmstat.c:1.234	Wed Jan  8 11:58:02 2020
+++ src/usr.bin/vmstat/vmstat.c	Wed Jan 15 17:56:46 2020
@@ -1,7 +1,8 @@
-/* $NetBSD: vmstat.c,v 1.234 2020/01/08 11:58:02 ad Exp $ */
+/* $NetBSD: vmstat.c,v 1.235 2020/01/15 17:56:46 ad Exp $ */
 
 /*-
- * Copyright (c) 1998, 2000, 2001, 2007, 2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
+ * The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation by:
@@ -70,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.234 2020/01/08 11:58:02 ad Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.235 2020/01/15 17:56:46 ad Exp $");
 #endif
 #endif /* not lint */
 
@@ -1089,6 +1090,14 @@ dosum(void)
 	(void)printf("%9" PRIu64 " pages found busy by daemon\n", uvmexp.pdbusy);
 	(void)printf("%9" PRIu64 " total pending pageouts\n", uvmexp.pdpending);
 	(void)printf("%9" PRIu64 " pages deactivated\n", uvmexp.pddeact);
+	(void)printf("%9" PRIu64 " per-cpu stats one synced\n", uvmexp.countsyncone);
+	(void)printf("%9" PRIu64 " per-cpu stats all synced\n", uvmexp.countsyncall);
+	(void)printf("%9" PRIu64 " anon pages possibly dirty\n", uvmexp.anonunknown);
+	(void)printf("%9" PRIu64 " anon pages dirty\n", uvmexp.anondirty);
+	(void)printf("%9" PRIu64 " anon pages clean\n", uvmexp.anonclean);
+	(void)printf("%9" PRIu64 " file pages possibly dirty\n", uvmexp.fileunknown);
+	(void)printf("%9" PRIu64 " file pages dirty\n", uvmexp.filedirty);
+	(void)printf("%9" PRIu64 " file pages clean\n", uvmexp.fileclean);
 
 	if (active_kernel) {
 		ssize = sizeof(nch_stats);



CVS commit: src

2020-01-15 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan 15 17:55:45 UTC 2020

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
src/sys/external/bsd/drm2/dist/drm: drm_gem.c
src/sys/external/bsd/drm2/dist/drm/i915: i915_gem.c i915_gem_fence.c
src/sys/external/bsd/drm2/include/linux: mm.h
src/sys/miscfs/genfs: genfs_io.c genfs_node.h
src/sys/nfs: nfs_bio.c
src/sys/rump/librump/rumpkern: Makefile.rumpkern vm.c
src/sys/rump/librump/rumpvfs: vm_vfs.c
src/sys/sys: cpu_data.h
src/sys/ufs/lfs: lfs_pages.c lfs_segment.c lfs_vfsops.c ulfs_inode.c
src/sys/ufs/ufs: ufs_inode.c
src/sys/uvm: files.uvm uvm_anon.c uvm_aobj.c uvm_bio.c uvm_extern.h
uvm_fault.c uvm_loan.c uvm_meter.c uvm_object.c uvm_object.h
uvm_page.c uvm_page.h uvm_page_array.c uvm_pager.c uvm_pdaemon.c
uvm_vnode.c
Added Files:
src/sys/uvm: uvm_page_status.c

Log Message:
Merge from yamt-pagecache (after much testing):

- Reduce unnecessary page scan in putpages esp. when an object has a ton of
  pages cached but only a few of them are dirty.

- Reduce the number of pmap operations by tracking page dirtiness more
  precisely in uvm layer.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/drm2/dist/drm/drm_gem.c
cvs rdiff -u -r1.54 -r1.55 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_fence.c
cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/include/linux/mm.h
cvs rdiff -u -r1.83 -r1.84 src/sys/miscfs/genfs/genfs_io.c
cvs rdiff -u -r1.22 -r1.23 src/sys/miscfs/genfs/genfs_node.h
cvs rdiff -u -r1.192 -r1.193 src/sys/nfs/nfs_bio.c
cvs rdiff -u -r1.181 -r1.182 src/sys/rump/librump/rumpkern/Makefile.rumpkern
cvs rdiff -u -r1.182 -r1.183 src/sys/rump/librump/rumpkern/vm.c
cvs rdiff -u -r1.35 -r1.36 src/sys/rump/librump/rumpvfs/vm_vfs.c
cvs rdiff -u -r1.48 -r1.49 src/sys/sys/cpu_data.h
cvs rdiff -u -r1.19 -r1.20 src/sys/ufs/lfs/lfs_pages.c
cvs rdiff -u -r1.280 -r1.281 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.367 -r1.368 src/sys/ufs/lfs/lfs_vfsops.c
cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/lfs/ulfs_inode.c
cvs rdiff -u -r1.107 -r1.108 src/sys/ufs/ufs/ufs_inode.c
cvs rdiff -u -r1.32 -r1.33 src/sys/uvm/files.uvm
cvs rdiff -u -r1.70 -r1.71 src/sys/uvm/uvm_anon.c
cvs rdiff -u -r1.133 -r1.134 src/sys/uvm/uvm_aobj.c
cvs rdiff -u -r1.102 -r1.103 src/sys/uvm/uvm_bio.c
cvs rdiff -u -r1.218 -r1.219 src/sys/uvm/uvm_extern.h
cvs rdiff -u -r1.214 -r1.215 src/sys/uvm/uvm_fault.c
cvs rdiff -u -r1.93 -r1.94 src/sys/uvm/uvm_loan.c
cvs rdiff -u -r1.73 -r1.74 src/sys/uvm/uvm_meter.c
cvs rdiff -u -r1.19 -r1.20 src/sys/uvm/uvm_object.c
cvs rdiff -u -r1.35 -r1.36 src/sys/uvm/uvm_object.h
cvs rdiff -u -r1.223 -r1.224 src/sys/uvm/uvm_page.c
cvs rdiff -u -r1.95 -r1.96 src/sys/uvm/uvm_page.h
cvs rdiff -u -r1.2 -r1.3 src/sys/uvm/uvm_page_array.c
cvs rdiff -u -r0 -r1.2 src/sys/uvm/uvm_page_status.c
cvs rdiff -u -r1.119 -r1.120 src/sys/uvm/uvm_pager.c
cvs rdiff -u -r1.122 -r1.123 src/sys/uvm/uvm_pdaemon.c
cvs rdiff -u -r1.104 -r1.105 src/sys/uvm/uvm_vnode.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.54 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.55
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.54	Fri Dec 13 20:10:21 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Wed Jan 15 17:55:43 2020
@@ -746,7 +746,8 @@ mappedread(vnode_t *vp, int nbytes, uio_
 		pp = NULL;
 		npages = 1;
 		mutex_enter(mtx);
-		found = uvn_findpages(uobj, start, , , UFP_NOALLOC);
+		found = uvn_findpages(uobj, start, , , NULL,
+		UFP_NOALLOC);
 		mutex_exit(mtx);
 
 		/* XXXNETBSD shouldn't access userspace with the page busy */
@@ -792,7 +793,8 @@ update_pages(vnode_t *vp, int64_t start,
 
 		pp = NULL;
 		npages = 1;
-		found = uvn_findpages(uobj, start, , , UFP_NOALLOC);
+		found = uvn_findpages(uobj, start, , , NULL,
+		UFP_NOALLOC);
 		if (found) {
 			mutex_exit(mtx);
 
@@ -5976,7 +5978,7 @@ zfs_netbsd_getpages(void *v)
 	}
 	npages = 1;
 	pg = NULL;
-	uvn_findpages(uobj, offset, , , UFP_ALL);
+	uvn_findpages(uobj, offset, , , NULL, UFP_ALL);
 
 	if (pg->flags & PG_FAKE) {
 		mutex_exit(mtx);
@@ -6224,7 +6226,7 @@ zfs_netbsd_setsize(vnode_t *vp, off_t si
 	mutex_enter(mtx);
 	count = 1;
 	pg = NULL;
-	if (uvn_findpages(uobj, tsize, , , UFP_NOALLOC)) {
+	if (uvn_findpages(uobj, tsize, , , NULL, UFP_NOALLOC)) {
 		va = zfs_map_page(pg, S_WRITE);
 		pgoff = size - tsize;
 		memset(va + pgoff, 0, PAGESIZE - pgoff);

Index: 

CVS commit: src/usr.sbin/fstyp

2020-01-15 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Wed Jan 15 15:32:05 UTC 2020

Modified Files:
src/usr.sbin/fstyp: hammer2.c

Log Message:
fstyp: Remove redundant best_i check in HAMMER2

https://reviews.freebsd.org/D23159
taken-from: DragonFlyBSD originally from FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/hammer2.c

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

Modified files:

Index: src/usr.sbin/fstyp/hammer2.c
diff -u src/usr.sbin/fstyp/hammer2.c:1.3 src/usr.sbin/fstyp/hammer2.c:1.4
--- src/usr.sbin/fstyp/hammer2.c:1.3	Sat Jan  4 03:43:18 2020
+++ src/usr.sbin/fstyp/hammer2.c	Wed Jan 15 15:32:05 2020
@@ -1,4 +1,4 @@
-/*$NetBSD: hammer2.c,v 1.3 2020/01/04 03:43:18 tkusumi Exp $  */
+/*$NetBSD: hammer2.c,v 1.4 2020/01/15 15:32:05 tkusumi Exp $  */
 
 /*-
  * Copyright (c) 2017-2019 The DragonFly Project
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.3 2020/01/04 03:43:18 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.4 2020/01/15 15:32:05 tkusumi Exp $");
 
 #include 
 #include 
@@ -225,10 +225,6 @@ read_label(FILE *fp, char *label, size_t
 			best = broot;
 		}
 	}
-	if (best_i == -1) {
-		warnx("failed to find best zone");
-		goto fail;
-	}
 
 	bref = [best_i]->voldata.sroot_blockset.blockref[0];
 	if (bref->type != HAMMER2_BREF_TYPE_INODE) {



CVS commit: src/usr.sbin/fstyp

2020-01-15 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Wed Jan 15 15:30:46 UTC 2020

Modified Files:
src/usr.sbin/fstyp: hammer.c

Log Message:
fstyp: Use strlcpy(3) for HAMMER1

https://reviews.freebsd.org/D23159
taken-from: DragonFlyBSD originally from FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/fstyp/hammer.c

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

Modified files:

Index: src/usr.sbin/fstyp/hammer.c
diff -u src/usr.sbin/fstyp/hammer.c:1.2 src/usr.sbin/fstyp/hammer.c:1.3
--- src/usr.sbin/fstyp/hammer.c:1.2	Fri Jan  3 08:19:14 2020
+++ src/usr.sbin/fstyp/hammer.c	Wed Jan 15 15:30:46 2020
@@ -1,4 +1,4 @@
-/*$NetBSD: hammer.c,v 1.2 2020/01/03 08:19:14 tkusumi Exp $  */
+/*$NetBSD: hammer.c,v 1.3 2020/01/15 15:30:46 tkusumi Exp $  */
 
 /*-
  * Copyright (c) 2016-2019 The DragonFly Project
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.2 2020/01/03 08:19:14 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.3 2020/01/15 15:30:46 tkusumi Exp $");
 
 #include 
 #include 
@@ -72,7 +72,7 @@ test_ondisk(const hammer_volume_ondisk_t
 		assert(count != 0);
 		memcpy(, >vol_fsid, sizeof(fsid));
 		memcpy(, >vol_fstype, sizeof(fstype));
-		strncpy(label, ondisk->vol_label, sizeof(label));
+		strlcpy(label, ondisk->vol_label, sizeof(label));
 	} else {
 		if (ondisk->vol_count != count)
 			return (5);
@@ -80,7 +80,7 @@ test_ondisk(const hammer_volume_ondisk_t
 			return (6);
 		if (memcmp(>vol_fstype, , sizeof(fstype)))
 			return (7);
-		if (strncmp(ondisk->vol_label, label, sizeof(label)))
+		if (strcmp(ondisk->vol_label, label))
 			return (8);
 	}
 



CVS commit: src/sys/arch/x86

2020-01-15 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan 15 13:22:04 UTC 2020

Modified Files:
src/sys/arch/x86/include: cpu.h
src/sys/arch/x86/x86: x86_tlb.c

Log Message:
Push the INVLPG limit for shootdowns up to 16 (for UBC).


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/x86/x86_tlb.c

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

Modified files:

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.116 src/sys/arch/x86/include/cpu.h:1.117
--- src/sys/arch/x86/include/cpu.h:1.116	Mon Dec 30 23:32:29 2019
+++ src/sys/arch/x86/include/cpu.h	Wed Jan 15 13:22:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.116 2019/12/30 23:32:29 thorpej Exp $	*/
+/*	$NetBSD: cpu.h,v 1.117 2020/01/15 13:22:03 ad Exp $	*/
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -127,7 +127,7 @@ struct cpu_info {
 	int ci_curldt;		/* current LDT descriptor */
 	int ci_nintrhand;	/* number of H/W interrupt handlers */
 	uint64_t ci_scratch;
-	uintptr_t ci_pmap_data[64 / sizeof(uintptr_t)];
+	uintptr_t ci_pmap_data[128 / sizeof(uintptr_t)];
 	struct kcpuset *ci_tlb_cpuset;
 
 	int ci_kfpu_spl;

Index: src/sys/arch/x86/x86/x86_tlb.c
diff -u src/sys/arch/x86/x86/x86_tlb.c:1.14 src/sys/arch/x86/x86/x86_tlb.c:1.15
--- src/sys/arch/x86/x86/x86_tlb.c:1.14	Sun Jan 12 13:01:11 2020
+++ src/sys/arch/x86/x86/x86_tlb.c	Wed Jan 15 13:22:03 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: x86_tlb.c,v 1.14 2020/01/12 13:01:11 ad Exp $	*/
+/*	$NetBSD: x86_tlb.c,v 1.15 2020/01/15 13:22:03 ad Exp $	*/
 
 /*-
- * Copyright (c) 2008-2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008-2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.14 2020/01/12 13:01:11 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.15 2020/01/15 13:22:03 ad Exp $");
 
 #include 
 #include 
@@ -66,26 +66,42 @@ __KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 
  * until the request is completed.  This keeps the cache line in the shared
  * state, and bus traffic to a minimum.
  *
- * On i386 the packet is 32 bytes in size.  On amd64 it's 60 bytes.
+ * In order to make maximal use of the available space, control fields are
+ * overlaid into the lower 12 bits of the first 4 virtual addresses.  This
+ * is very ugly, but it counts.
+ *
+ * On i386 the packet is 64 bytes in size.  On amd64 it's 128 bytes.  This
+ * is sized in concert with UBC_WINSIZE, otherwise excessive shootdown
+ * interrupts could be isssued.
  */
+
+#define	TP_MAXVA	16		/* for individual mappings */
+#define	TP_ALLVA	PAGE_MASK	/* special: shoot all mappings */
+
 typedef struct {
-	uintptr_t		tp_va[7];
-	uint8_t			tp_count;
-	uint8_t			tp_userpmap;
-	uint8_t			tp_global;
-	uint8_t			tp_done;
+	uintptr_t		tp_store[TP_MAXVA];
 } pmap_tlb_packet_t;
 
-/*
- * No more than N separate invlpg.
- *
- * Statistically, a value of 7 is big enough to cover the requested number
- * of pages in ~ 95% of the TLB shootdowns we are getting. We therefore rarely
- * reach the limit, and increasing it can actually reduce the performance due
- * to the high cost of invlpg.
- */
-#define	TP_MAXVA		7	/* for individual mappings */
-#define	TP_ALLVA		255	/* special: shoot all mappings */
+#define	TP_COUNT	0
+#define	TP_USERPMAP	1
+#define	TP_GLOBAL	2
+#define	TP_DONE		3
+
+#define	TP_GET_COUNT(tp)	((tp)->tp_store[TP_COUNT] & PAGE_MASK)
+#define	TP_GET_USERPMAP(tp)	((tp)->tp_store[TP_USERPMAP] & 1)
+#define	TP_GET_GLOBAL(tp)	((tp)->tp_store[TP_GLOBAL] & 1)
+#define	TP_GET_DONE(tp)		((tp)->tp_store[TP_DONE] & 1)
+#define	TP_GET_VA(tp, i)	((tp)->tp_store[(i)] & ~PAGE_MASK)
+
+#define	TP_INC_COUNT(tp)	((tp)->tp_store[TP_COUNT]++)
+#define	TP_SET_ALLVA(tp)	((tp)->tp_store[TP_COUNT] |= TP_ALLVA)
+#define	TP_SET_VA(tp, c, va)	((tp)->tp_store[(c)] |= ((va) & ~PAGE_MASK))
+
+#define	TP_SET_USERPMAP(tp)	((tp)->tp_store[TP_USERPMAP] |= 1)
+#define	TP_SET_GLOBAL(tp)	((tp)->tp_store[TP_GLOBAL] |= 1)
+#define	TP_SET_DONE(tp)		((tp)->tp_store[TP_DONE] |= 1)
+
+#define	TP_CLEAR(tp)		memset(__UNVOLATILE(tp), 0, sizeof(*(tp)));
 
 /*
  * TLB shootdown state.
@@ -125,8 +141,6 @@ void
 pmap_tlb_init(void)
 {
 
-	KASSERT(__arraycount(pmap_tlb_packet->tp_va) >= TP_MAXVA);
-
 	evcnt_attach_dynamic(_tlb_evcnt, EVCNT_TYPE_INTR,
 	NULL, "TLB", "shootdown");
 
@@ -195,11 +209,11 @@ pmap_tlbstat_count(struct pmap *pm, vadd
 static inline void
 pmap_tlb_invalidate(volatile pmap_tlb_packet_t *tp)
 {
-	int i = tp->tp_count;
+	int i = TP_GET_COUNT(tp);
 
 	/* Find out what we need to invalidate. */
 	if (i == TP_ALLVA) {
-		if (tp->tp_global) {
+		if (TP_GET_GLOBAL(tp) != 0) {
 			/* Invalidating all TLB entries. */
 			tlbflushg();
 		} else {
@@ -210,7 +224,8 @@ 

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

2020-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jan 15 11:36:48 UTC 2020

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

Log Message:
Add imxi2c


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

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

Modified files:

Index: src/sys/arch/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.132 src/sys/arch/evbarm/conf/GENERIC64:1.133
--- src/sys/arch/evbarm/conf/GENERIC64:1.132	Wed Jan 15 01:09:57 2020
+++ src/sys/arch/evbarm/conf/GENERIC64	Wed Jan 15 11:36:48 2020
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.132 2020/01/15 01:09:57 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.133 2020/01/15 11:36:48 jmcneill Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -381,6 +381,7 @@ options 	I2C_MAX_ADDR=0xfff
 bsciic*		at fdt?			# Broadcom BCM283x Serial Control
 dwiic*		at fdt?			# Designware I2C
 dwiic*		at acpi?
+imxi2c*		at fdt? pass 4		# IMX I2C
 rkiic*		at fdt? pass 4		# Rockchip I2C
 sunxirsb*	at fdt?	pass 4		# Allwinner RSB
 sunxitwi*	at fdt?			# Allwinner TWI



CVS commit: src/sys/arch/arm/imx/fdt

2020-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jan 15 11:36:34 UTC 2020

Modified Files:
src/sys/arch/arm/imx/fdt: imx8mq_ccm.c

Log Message:
Add i2c clocks


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx8mq_ccm.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/imx/fdt/imx8mq_ccm.c
diff -u src/sys/arch/arm/imx/fdt/imx8mq_ccm.c:1.1 src/sys/arch/arm/imx/fdt/imx8mq_ccm.c:1.2
--- src/sys/arch/arm/imx/fdt/imx8mq_ccm.c:1.1	Wed Jan 15 01:09:56 2020
+++ src/sys/arch/arm/imx/fdt/imx8mq_ccm.c	Wed Jan 15 11:36:34 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: imx8mq_ccm.c,v 1.1 2020/01/15 01:09:56 jmcneill Exp $ */
+/* $NetBSD: imx8mq_ccm.c,v 1.2 2020/01/15 11:36:34 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: imx8mq_ccm.c,v 1.1 2020/01/15 01:09:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx8mq_ccm.c,v 1.2 2020/01/15 11:36:34 jmcneill Exp $");
 
 #include 
 #include 
@@ -72,6 +72,9 @@ static const char *usb_bus_p[] = {
 static const char *usb_core_phy_p[] = {
 	"osc_25m", "sys1_pll_100m", "sys1_pll_40m", "sys2_pll_100m", "sys2_pll_200m", "clk_ext2", "clk_ext3", "audio_pll2_out"
 };
+static const char *i2c_p[] = {
+	"osc_25m", "sys1_pll_160m", "sys2_pll_50m", "sys3_pll_out", "audio_pll1_out", "video_pll1_out", "audio_pll2_out", "sys1_pll_133m"
+};
 
 CFATTACH_DECL_NEW(imx8mq_ccm, sizeof(struct imx_ccm_softc),
 	imx8mq_ccm_match, imx8mq_ccm_attach, NULL, NULL);
@@ -161,6 +164,16 @@ static struct imx_ccm_clk imx8mq_ccm_clk
 	IMX_ROOT_GATE(CLK_USB2_CTRL_ROOT, "usb2_ctrl_root_clk", "usb_bus", 0x44e0),
 	IMX_ROOT_GATE(CLK_USB1_PHY_ROOT, "usb1_phy_root_clk", "usb_phy_ref", 0x44f0),
 	IMX_ROOT_GATE(CLK_USB2_PHY_ROOT, "usb2_phy_root_clk", "usb_phy_ref", 0x4500),
+
+	IMX_COMPOSITE(CLK_I2C1, "i2c1", i2c_p, 0xad00, 0),
+	IMX_COMPOSITE(CLK_I2C2, "i2c2", i2c_p, 0xad80, 0),
+	IMX_COMPOSITE(CLK_I2C3, "i2c3", i2c_p, 0xae00, 0),
+	IMX_COMPOSITE(CLK_I2C4, "i2c4", i2c_p, 0xae80, 0),
+
+	IMX_ROOT_GATE(CLK_I2C1_ROOT, "i2c1_root_clk", "i2c1", 0x4170),
+	IMX_ROOT_GATE(CLK_I2C2_ROOT, "i2c2_root_clk", "i2c2", 0x4180),
+	IMX_ROOT_GATE(CLK_I2C3_ROOT, "i2c3_root_clk", "i2c3", 0x4190),
+	IMX_ROOT_GATE(CLK_I2C4_ROOT, "i2c4_root_clk", "i2c4", 0x41a0),
 };
 
 static int



CVS commit: src/sys/arch/arm/imx/fdt

2020-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jan 15 11:35:58 UTC 2020

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_i2c.c

Log Message:
Match the more generic fsl,imx21-i2c compat string


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/fdt/imx6_i2c.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/imx/fdt/imx6_i2c.c
diff -u src/sys/arch/arm/imx/fdt/imx6_i2c.c:1.2 src/sys/arch/arm/imx/fdt/imx6_i2c.c:1.3
--- src/sys/arch/arm/imx/fdt/imx6_i2c.c:1.2	Mon Aug  5 12:21:00 2019
+++ src/sys/arch/arm/imx/fdt/imx6_i2c.c	Wed Jan 15 11:35:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_i2c.c,v 1.2 2019/08/05 12:21:00 hkenken Exp $	*/
+/*	$NetBSD: imx6_i2c.c,v 1.3 2020/01/15 11:35:58 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_i2c.c,v 1.2 2019/08/05 12:21:00 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_i2c.c,v 1.3 2020/01/15 11:35:58 jmcneill Exp $");
 
 #include 
 
@@ -36,7 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: imx6_i2c.c,v
 int
 imxi2c_match(device_t parent, cfdata_t cf, void *aux)
 {
-	const char * const compatible[] = { "fsl,imx6q-i2c", NULL };
+	const char * const compatible[] = { "fsl,imx21-i2c", NULL };
 	struct fdt_attach_args * const faa = aux;
 
 	return of_match_compatible(faa->faa_phandle, compatible);



CVS commit: src/common/lib/libc/arch/x86_64/string

2020-01-15 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan 15 10:56:49 UTC 2020

Modified Files:
src/common/lib/libc/arch/x86_64/string: bcmp.S memcmp.S

Log Message:
Rewrite bcmp() & memcmp() to not use REP CMPS.  Seems about 5-10x faster for
small strings on modern hardware.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/x86_64/string/bcmp.S \
src/common/lib/libc/arch/x86_64/string/memcmp.S

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

Modified files:

Index: src/common/lib/libc/arch/x86_64/string/bcmp.S
diff -u src/common/lib/libc/arch/x86_64/string/bcmp.S:1.3 src/common/lib/libc/arch/x86_64/string/bcmp.S:1.4
--- src/common/lib/libc/arch/x86_64/string/bcmp.S:1.3	Sat Mar 22 19:16:34 2014
+++ src/common/lib/libc/arch/x86_64/string/bcmp.S	Wed Jan 15 10:56:49 2020
@@ -1,24 +1,67 @@
+/*	$NetBSD: bcmp.S,v 1.4 2020/01/15 10:56:49 ad Exp $	*/
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #include 
 
 #if defined(LIBC_SCCS)
-	RCSID("$NetBSD: bcmp.S,v 1.3 2014/03/22 19:16:34 jakllsch Exp $")
+	RCSID("$NetBSD: bcmp.S,v 1.4 2020/01/15 10:56:49 ad Exp $")
 #endif
 
 ENTRY(bcmp)
-	xorl	%eax,%eax		/* clear return value */
-
-	movq	%rdx,%rcx		/* compare by words */
-	shrq	$3,%rcx
-	repe
-	cmpsq
-	jne	L1
-
-	movq	%rdx,%rcx		/* compare remainder by bytes */
-	andq	$7,%rcx
-	repe
-	cmpsb
-	je	L2
-
-L1:	incl	%eax
-L2:	ret
+	movq	%rdx, %rcx	/* compare by longs, equality only */
+	shrq	$3, %rcx
+	jz	2f
+1:
+	movq	(%rdi), %rax
+	cmpq	%rax, (%rsi)
+	jne	5f
+	decq	%rcx
+	leaq	8(%rdi), %rdi
+	leaq	8(%rsi), %rsi
+	jnz	1b
+2:
+	andl	$7, %edx
+	jz	4f
+3:
+	movb	(%rdi), %al	/* compare by chars, equality only */
+	cmpb	%al, (%rsi)
+	jne	5f
+	decl	%edx
+	leaq	1(%rdi), %rdi
+	leaq	1(%rsi), %rsi
+	jnz	3b
+4:
+	xorl	%eax, %eax
+	ret
+5:
+	movl	$1, %eax
+	ret
 END(bcmp)
Index: src/common/lib/libc/arch/x86_64/string/memcmp.S
diff -u src/common/lib/libc/arch/x86_64/string/memcmp.S:1.3 src/common/lib/libc/arch/x86_64/string/memcmp.S:1.4
--- src/common/lib/libc/arch/x86_64/string/memcmp.S:1.3	Sat Mar 22 19:16:34 2014
+++ src/common/lib/libc/arch/x86_64/string/memcmp.S	Wed Jan 15 10:56:49 2020
@@ -1,3 +1,34 @@
+/*	$NetBSD: memcmp.S,v 1.4 2020/01/15 10:56:49 ad Exp $	*/
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * 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 

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

2020-01-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jan 15 10:25:47 UTC 2020

Modified Files:
src/sys/arch/evbarm/netwalker: netwalker_lcd.c netwalker_spi.c
netwalker_usb.c

Log Message:
Fix build


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/evbarm/netwalker/netwalker_lcd.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/netwalker/netwalker_spi.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/evbarm/netwalker/netwalker_usb.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/evbarm/netwalker/netwalker_lcd.c
diff -u src/sys/arch/evbarm/netwalker/netwalker_lcd.c:1.6 src/sys/arch/evbarm/netwalker/netwalker_lcd.c:1.7
--- src/sys/arch/evbarm/netwalker/netwalker_lcd.c:1.6	Wed Jul 24 12:33:18 2019
+++ src/sys/arch/evbarm/netwalker/netwalker_lcd.c	Wed Jan 15 10:25:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netwalker_lcd.c,v 1.6 2019/07/24 12:33:18 hkenken Exp $	*/
+/*	$NetBSD: netwalker_lcd.c,v 1.7 2020/01/15 10:25:47 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2011, 2012 Genetec corp. All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netwalker_lcd.c,v 1.6 2019/07/24 12:33:18 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netwalker_lcd.c,v 1.7 2020/01/15 10:25:47 skrll Exp $");
 
 #include "opt_imx51_ipuv3.h"
 #include "opt_netwalker_lcd.h"
@@ -143,17 +143,17 @@ void lcd_attach( device_t parent, device
 	}
 
 	/* LCD power on */
-	gpio_set_direction(GPIO_NO(4, 9), GPIO_PIN_OUTPUT);
-	gpio_set_direction(GPIO_NO(4, 10), GPIO_PIN_OUTPUT);
-	gpio_set_direction(GPIO_NO(3, 3), GPIO_PIN_OUTPUT);
+	imxgpio_set_direction(GPIO_NO(4, 9), GPIO_PIN_OUTPUT);
+	imxgpio_set_direction(GPIO_NO(4, 10), GPIO_PIN_OUTPUT);
+	imxgpio_set_direction(GPIO_NO(3, 3), GPIO_PIN_OUTPUT);
 
-	gpio_data_write(GPIO_NO(3, 3), GPIO_PIN_HIGH);
-	gpio_data_write(GPIO_NO(4, 9), GPIO_PIN_HIGH);
+	imxgpio_data_write(GPIO_NO(3, 3), GPIO_PIN_HIGH);
+	imxgpio_data_write(GPIO_NO(4, 9), GPIO_PIN_HIGH);
 	delay(180 * 1000);
-	gpio_data_write(GPIO_NO(4, 10), GPIO_PIN_HIGH);
+	imxgpio_data_write(GPIO_NO(4, 10), GPIO_PIN_HIGH);
 
-	gpio_set_direction(GPIO_NO(2, 13), GPIO_PIN_OUTPUT);
-	gpio_data_write(GPIO_NO(2, 13), GPIO_PIN_HIGH);
+	imxgpio_set_direction(GPIO_NO(2, 13), GPIO_PIN_OUTPUT);
+	imxgpio_data_write(GPIO_NO(2, 13), GPIO_PIN_HIGH);
 
 	imx51_ipuv3_attach_sub(sc, aux, _panel);
 

Index: src/sys/arch/evbarm/netwalker/netwalker_spi.c
diff -u src/sys/arch/evbarm/netwalker/netwalker_spi.c:1.3 src/sys/arch/evbarm/netwalker/netwalker_spi.c:1.4
--- src/sys/arch/evbarm/netwalker/netwalker_spi.c:1.3	Mon Aug 19 11:41:36 2019
+++ src/sys/arch/evbarm/netwalker/netwalker_spi.c	Wed Jan 15 10:25:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netwalker_spi.c,v 1.3 2019/08/19 11:41:36 hkenken Exp $	*/
+/*	$NetBSD: netwalker_spi.c,v 1.4 2020/01/15 10:25:47 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2009  Genetec Corporation.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netwalker_spi.c,v 1.3 2019/08/19 11:41:36 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netwalker_spi.c,v 1.4 2020/01/15 10:25:47 skrll Exp $");
 
 #include "opt_imxspi.h"
 
@@ -61,16 +61,16 @@ imxspi_cs_enable(void *arg, int slave)
 {
 	switch (slave) {
 	case 0:
-		gpio_data_write(GPIO_NO(4, 24), GPIO_PIN_LOW);
-		gpio_set_direction(GPIO_NO(4, 24), GPIO_PIN_OUTPUT);
+		imxgpio_data_write(GPIO_NO(4, 24), GPIO_PIN_LOW);
+		imxgpio_set_direction(GPIO_NO(4, 24), GPIO_PIN_OUTPUT);
 		break;
 	case 1:
-		gpio_data_write(GPIO_NO(4, 25), GPIO_PIN_LOW);
-		gpio_set_direction(GPIO_NO(4, 25), GPIO_PIN_OUTPUT);
+		imxgpio_data_write(GPIO_NO(4, 25), GPIO_PIN_LOW);
+		imxgpio_set_direction(GPIO_NO(4, 25), GPIO_PIN_OUTPUT);
 		break;
 	case 2:
-		gpio_data_write(GPIO_NO(3, 0), GPIO_PIN_LOW);
-		gpio_set_direction(GPIO_NO(3, 0), GPIO_PIN_OUTPUT);
+		imxgpio_data_write(GPIO_NO(3, 0), GPIO_PIN_LOW);
+		imxgpio_set_direction(GPIO_NO(3, 0), GPIO_PIN_OUTPUT);
 		break;
 	}
 
@@ -82,16 +82,16 @@ imxspi_cs_disable(void *arg, int slave)
 {
 	switch (slave) {
 	case 0:
-		gpio_data_write(GPIO_NO(4, 24), GPIO_PIN_HIGH);
-		gpio_set_direction(GPIO_NO(4, 24), GPIO_PIN_INPUT);
+		imxgpio_data_write(GPIO_NO(4, 24), GPIO_PIN_HIGH);
+		imxgpio_set_direction(GPIO_NO(4, 24), GPIO_PIN_INPUT);
 		break;
 	case 1:
-		gpio_data_write(GPIO_NO(4, 25), GPIO_PIN_HIGH);
-		gpio_set_direction(GPIO_NO(4, 25), GPIO_PIN_INPUT);
+		imxgpio_data_write(GPIO_NO(4, 25), GPIO_PIN_HIGH);
+		imxgpio_set_direction(GPIO_NO(4, 25), GPIO_PIN_INPUT);
 		break;
 	case 2:
-		gpio_data_write(GPIO_NO(3, 0), GPIO_PIN_HIGH);
-		gpio_set_direction(GPIO_NO(3, 0), GPIO_PIN_INPUT);
+		imxgpio_data_write(GPIO_NO(3, 0), GPIO_PIN_HIGH);
+		imxgpio_set_direction(GPIO_NO(3, 0), GPIO_PIN_INPUT);
 		break;
 	}
 
@@ -129,21 +129,21 @@ imxspi_attach(device_t parent, device_t 
 	switch (device_unit(self)) {
 	case 0:
 		/* CS 0 GPIO setting */
-		gpio_data_write(GPIO_NO(4, 24), 

CVS commit: src/doc

2020-01-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan 15 09:21:21 UTC 2020

Modified Files:
src/doc: CHANGES

Log Message:
add a note about arm* cpu topology support.


To generate a diff of this commit:
cvs rdiff -u -r1.2633 -r1.2634 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2633 src/doc/CHANGES:1.2634
--- src/doc/CHANGES:1.2633	Wed Jan 15 01:11:05 2020
+++ src/doc/CHANGES	Wed Jan 15 09:21:21 2020
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2633 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2634 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -95,3 +95,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	dhcpcd(8): Import dhcpcd-8.1.5 [roy 20200103]
 	tmux(1): Imported 3.0a. [christos 20200106]
 	evbarm: Add support for NXP i.MX 8M family SoCs. [jmcneill 20200114]
+	arm: Add support for cpu topology for ARMv7 and ARMv7 CPUs.
+		[mrg 20201114]



CVS commit: src/sys/arch

2020-01-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan 15 08:34:04 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c cpufunc.c locore.S
src/sys/arch/aarch64/conf: files.aarch64
src/sys/arch/aarch64/include: cpu.h cpufunc.h
src/sys/arch/arm/arm32: cpu.c
src/sys/arch/arm/conf: files.arm
src/sys/arch/arm/include: cpu.h
Added Files:
src/sys/arch/arm/arm: arm_cpu_topology.c
src/sys/arch/arm/include: cpu_topology.h

Log Message:
port the arm64 cpu topology setup for big.little to arm.

rename arm64 cpu_do_topology() to arm_cpu_do_topology() and
call it from both arm cpu_attach().

replace both aarch64_set_topology() inline code in arm
cpu_attach() with new arm_cpu_do_topology(), which is called
by the arm64 locore as well (possibly not needed, which would
allow it to become static.)

not yet tested on a real big.little armv7 system.  tested
on rockpro64 and pinebook pro.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/aarch64/aarch64/cpufunc.c
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/aarch64/include/cpu.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/include/cpufunc.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/arm/arm_cpu_topology.c
cvs rdiff -u -r1.139 -r1.140 src/sys/arch/arm/arm32/cpu.c
cvs rdiff -u -r1.149 -r1.150 src/sys/arch/arm/conf/files.arm
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/arm/include/cpu.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/include/cpu_topology.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.33 src/sys/arch/aarch64/aarch64/cpu.c:1.34
--- src/sys/arch/aarch64/aarch64/cpu.c:1.33	Sun Jan 12 09:29:18 2020
+++ src/sys/arch/aarch64/aarch64/cpu.c	Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.33 2020/01/12 09:29:18 mrg Exp $ */
+/* $NetBSD: cpu.c,v 1.34 2020/01/15 08:34:04 mrg Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.33 2020/01/12 09:29:18 mrg Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.34 2020/01/15 08:34:04 mrg Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -48,6 +48,7 @@ __KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.33
 #include 
 #include 
 
+#include 
 #ifdef FDT
 #include 
 #endif
@@ -65,7 +66,6 @@ static void cpu_identify1(device_t self,
 static void cpu_identify2(device_t self, struct cpu_info *);
 static void cpu_setup_id(struct cpu_info *);
 static void cpu_setup_sysctl(device_t, struct cpu_info *);
-static void cpu_do_topology(struct cpu_info *);
 
 #ifdef MULTIPROCESSOR
 uint64_t cpu_mpidr[MAXCPUS];
@@ -145,7 +145,7 @@ cpu_attach(device_t dv, cpuid_t id)
 	ci->ci_dev = dv;
 	dv->dv_private = ci;
 
-	cpu_do_topology(ci);
+	arm_cpu_do_topology(ci);
 	cpu_identify(ci->ci_dev, ci);
 
 #ifdef MULTIPROCESSOR
@@ -498,43 +498,6 @@ cpu_setup_sysctl(device_t dv, struct cpu
 		   CTL_CREATE, CTL_EOL);
 }
 
-static void
-cpu_do_topology(struct cpu_info *newci)
-{
-	struct cpu_info *ci;
-	CPU_INFO_ITERATOR cii;
-	prop_dictionary_t dict;
-	uint32_t capacity_dmips_mhz;
-	static uint32_t best_cap = 0;
-
-	dict = device_properties(newci->ci_dev);
-	if (prop_dictionary_get_uint32(dict, "capacity_dmips_mhz",
-	_dmips_mhz)) {
-		newci->ci_capacity_dmips_mhz = capacity_dmips_mhz;
-	} else {
-		newci->ci_capacity_dmips_mhz = 0;
-	}
-
-	if (newci->ci_capacity_dmips_mhz > best_cap)
-		best_cap = newci->ci_capacity_dmips_mhz;
-
-	/*
-	 * CPU_INFO_FOREACH() doesn't work for this CPU until mi_cpu_attach()
-	 * is called and ncpu is bumped, so call it directly here.
-	 */
-	aarch64_set_topology(newci, newci->ci_id.ac_mpidr,
-	newci->ci_capacity_dmips_mhz < best_cap);
-
-	/*
-	 * Using saved largest capacity, refresh previous topology info.
-	 * It's supposed to be OK to re-set topology.
-	 */
-	for (CPU_INFO_FOREACH(cii, ci)) {
-		aarch64_set_topology(ci, ci->ci_id.ac_mpidr,
-		ci->ci_capacity_dmips_mhz < best_cap);
-	}
-}
-
 #ifdef MULTIPROCESSOR
 void
 cpu_boot_secondary_processors(void)

Index: src/sys/arch/aarch64/aarch64/cpufunc.c
diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.14 src/sys/arch/aarch64/aarch64/cpufunc.c:1.15
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.14	Sun Jan 12 09:29:18 2020
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.14 2020/01/12 09:29:18 mrg Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.15 2020/01/15 08:34:04 mrg Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -29,7 +29,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.14 2020/01/12 09:29:18 mrg Exp $");
+__KERNEL_RCSID(0, 

CVS commit: src/sys/dev/pci

2020-01-15 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Jan 15 08:25:02 UTC 2020

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

Log Message:
Fix typo (s/txr_opackets/txr_obytes/)

pointed out by ryo@n.o, thanks.


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

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

Modified files:

Index: src/sys/dev/pci/if_ixl.c
diff -u src/sys/dev/pci/if_ixl.c:1.19 src/sys/dev/pci/if_ixl.c:1.20
--- src/sys/dev/pci/if_ixl.c:1.19	Thu Jan  9 08:54:05 2020
+++ src/sys/dev/pci/if_ixl.c	Wed Jan 15 08:25:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ixl.c,v 1.19 2020/01/09 08:54:05 yamaguchi Exp $	*/
+/*	$NetBSD: if_ixl.c,v 1.20 2020/01/15 08:25:01 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2013-2015, Intel Corporation
@@ -1787,11 +1787,11 @@ ixl_ioctl(struct ifnet *ifp, u_long cmd,
 
 			mutex_enter(>txr_lock);
 			ifp->if_opackets += txr->txr_opackets;
-			ifp->if_obytes += txr->txr_opackets;
+			ifp->if_obytes += txr->txr_obytes;
 			ifp->if_omcasts += txr->txr_omcasts;
 			if (cmd == SIOCZIFDATA) {
 txr->txr_opackets = 0;
-txr->txr_opackets = 0;
+txr->txr_obytes = 0;
 txr->txr_omcasts = 0;
 			}
 			mutex_exit(>txr_lock);



CVS commit: src/sys/dev/usb

2020-01-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jan 15 08:21:00 UTC 2020

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

Log Message:
If malloc fails in zyd_node_alloc then return NULL.  From nick-nhusb


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/usb/if_zyd.c

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

Modified files:

Index: src/sys/dev/usb/if_zyd.c
diff -u src/sys/dev/usb/if_zyd.c:1.54 src/sys/dev/usb/if_zyd.c:1.55
--- src/sys/dev/usb/if_zyd.c:1.54	Wed Jan 15 08:20:13 2020
+++ src/sys/dev/usb/if_zyd.c	Wed Jan 15 08:21:00 2020
@@ -1,5 +1,5 @@
 /*	$OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $	*/
-/*	$NetBSD: if_zyd.c,v 1.54 2020/01/15 08:20:13 skrll Exp $	*/
+/*	$NetBSD: if_zyd.c,v 1.55 2020/01/15 08:21:00 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2006 by Damien Bergamini 
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.54 2020/01/15 08:20:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.55 2020/01/15 08:21:00 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -662,8 +662,7 @@ zyd_node_alloc(struct ieee80211_node_tab
 	struct zyd_node *zn;
 
 	zn = malloc(sizeof(struct zyd_node), M_80211_NODE, M_NOWAIT | M_ZERO);
-
-	return >ni;
+	return zn ? >ni : NULL;
 }
 
 Static int



CVS commit: src/sys/dev/usb

2020-01-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jan 15 08:20:13 UTC 2020

Modified Files:
src/sys/dev/usb: if_otus.c if_otusvar.h if_upgt.c if_upgtvar.h
if_urtwn.c if_urtwnvar.h if_zyd.c if_zydreg.h

Log Message:
Use modern interfaces and kill tsleep/wakeup.  From nick-nhusb branch.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/usb/if_otus.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/usb/if_otusvar.h \
src/sys/dev/usb/if_zydreg.h
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/usb/if_upgt.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/if_upgtvar.h
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/usb/if_urtwn.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/usb/if_urtwnvar.h
cvs rdiff -u -r1.53 -r1.54 src/sys/dev/usb/if_zyd.c

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

Modified files:

Index: src/sys/dev/usb/if_otus.c
diff -u src/sys/dev/usb/if_otus.c:1.39 src/sys/dev/usb/if_otus.c:1.40
--- src/sys/dev/usb/if_otus.c:1.39	Sat Sep 14 12:37:34 2019
+++ src/sys/dev/usb/if_otus.c	Wed Jan 15 08:20:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_otus.c,v 1.39 2019/09/14 12:37:34 maxv Exp $	*/
+/*	$NetBSD: if_otus.c,v 1.40 2020/01/15 08:20:13 skrll Exp $	*/
 /*	$OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.39 2019/09/14 12:37:34 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.40 2020/01/15 08:20:13 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -630,6 +630,8 @@ otus_attach(device_t parent, device_t se
 	aprint_normal_dev(sc->sc_dev, "%s\n", devinfop);
 	usbd_devinfo_free(devinfop);
 
+	cv_init(>sc_task_cv, "otustsk");
+	cv_init(>sc_cmd_cv, "otuscmd");
 	mutex_init(>sc_cmd_mtx,   MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(>sc_task_mtx,  MUTEX_DEFAULT, IPL_NET);
 	mutex_init(>sc_tx_mtx,MUTEX_DEFAULT, IPL_NONE);
@@ -678,8 +680,10 @@ otus_wait_async(struct otus_softc *sc)
 
 	DPRINTFN(DBG_FN, sc, "\n");
 
+	mutex_spin_enter(>sc_task_mtx);
 	while (sc->sc_cmdq.queued > 0)
-		tsleep(>sc_cmdq, 0, "sc_cmdq", 0);
+		cv_wait(>sc_task_cv, >sc_task_mtx);
+	mutex_spin_exit(>sc_task_mtx);
 }
 
 Static int
@@ -720,6 +724,9 @@ otus_detach(device_t self, int flags)
 	mutex_destroy(>sc_tx_mtx);
 	mutex_destroy(>sc_task_mtx);
 	mutex_destroy(>sc_cmd_mtx);
+	cv_destroy(>sc_task_cv);
+	cv_destroy(>sc_cmd_cv);
+
 	return 0;
 }
 
@@ -1242,34 +1249,29 @@ otus_task(void *arg)
 	struct otus_softc *sc;
 	struct otus_host_cmd_ring *ring;
 	struct otus_host_cmd *cmd;
-	int s;
 
 	sc = arg;
 
 	DPRINTFN(DBG_FN, sc, "\n");
 
 	/* Process host commands. */
-	s = splusb();
 	mutex_spin_enter(>sc_task_mtx);
 	ring = >sc_cmdq;
 	while (ring->next != ring->cur) {
 		cmd = >cmd[ring->next];
 		mutex_spin_exit(>sc_task_mtx);
-		splx(s);
 
 		/* Callback. */
 		DPRINTFN(DBG_CMD, sc, "cb=%p queued=%d\n", cmd->cb,
 		ring->queued);
 		cmd->cb(sc, cmd->data);
 
-		s = splusb();
 		mutex_spin_enter(>sc_task_mtx);
 		ring->queued--;
 		ring->next = (ring->next + 1) % OTUS_HOST_CMD_RING_COUNT;
 	}
+	cv_signal(>sc_task_cv);
 	mutex_spin_exit(>sc_task_mtx);
-	wakeup(ring);
-	splx(s);
 }
 
 Static void
@@ -1278,12 +1280,10 @@ otus_do_async(struct otus_softc *sc, voi
 {
 	struct otus_host_cmd_ring *ring;
 	struct otus_host_cmd *cmd;
-	int s;
+	bool sched = false;
 
 	DPRINTFN(DBG_FN, sc, "cb=%p\n", cb);
 
-
-	s = splusb();
 	mutex_spin_enter(>sc_task_mtx);
 	ring = >sc_cmdq;
 	cmd = >cmd[ring->cur];
@@ -1294,13 +1294,12 @@ otus_do_async(struct otus_softc *sc, voi
 
 	/* If there is no pending command already, schedule a task. */
 	if (++ring->queued == 1) {
-		mutex_spin_exit(>sc_task_mtx);
-		usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER);
+		sched = true;
 	}
-	else
-		mutex_spin_exit(>sc_task_mtx);
-	wakeup(ring);
-	splx(s);
+	cv_signal(>sc_task_cv);
+	mutex_spin_exit(>sc_task_mtx);
+	if (sched)
+		usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER);
 }
 
 Static int
@@ -1401,7 +1400,7 @@ otus_cmd(struct otus_softc *sc, uint8_t 
 {
 	struct otus_tx_cmd *cmd;
 	struct ar_cmd_hdr *hdr;
-	int s, xferlen, error;
+	int xferlen, error;
 
 	DPRINTFN(DBG_FN, sc, "\n");
 
@@ -1427,14 +1426,12 @@ otus_cmd(struct otus_softc *sc, uint8_t 
 	DPRINTFN(DBG_CMD, sc, "sending command code=0x%02x len=%d token=%d\n",
 	code, ilen, hdr->token);
 
-	s = splusb();
 	cmd->odata = odata;
 	cmd->done = 0;
 	usbd_setup_xfer(cmd->xfer, cmd, cmd->buf, xferlen,
 	USBD_FORCE_SHORT_XFER, OTUS_CMD_TIMEOUT, NULL);
 	error = usbd_sync_transfer(cmd->xfer);
 	if (error != 0) {
-		splx(s);
 		mutex_exit(>sc_cmd_mtx);
 #if defined(DIAGNOSTIC) || defined(OTUS_DEBUG)	/* XXX: kill some noise */
 		aprint_error_dev(sc->sc_dev,
@@ -1444,9 +1441,8 @@ otus_cmd(struct otus_softc *sc, uint8_t 
 		return EIO;
 	}
 	if (!cmd->done)
-		error = tsleep(cmd, PCATCH, "otuscmd", hz);
+		error = cv_timedwait_sig(>sc_cmd_cv, >sc_cmd_mtx, hz);
 	cmd->odata = NULL;	/* In case answer 

CVS commit: src/sys/dev/usb

2020-01-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jan 15 08:13:20 UTC 2020

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

Log Message:
Trailing whitespace


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

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

Modified files:

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.78 src/sys/dev/usb/if_urtwn.c:1.79
--- src/sys/dev/usb/if_urtwn.c:1.78	Fri Dec 13 14:10:32 2019
+++ src/sys/dev/usb/if_urtwn.c	Wed Jan 15 08:13:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.78 2019/12/13 14:10:32 maxv Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.79 2020/01/15 08:13:20 skrll Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.78 2019/12/13 14:10:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.79 2020/01/15 08:13:20 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -856,7 +856,7 @@ urtwn_task(void *arg)
 	int s;
 
 	URTWNHIST_FUNC(); URTWNHIST_CALLED();
-	if (ic->ic_state == IEEE80211_S_RUN && 
+	if (ic->ic_state == IEEE80211_S_RUN &&
 	(ic->ic_opmode == IEEE80211_M_HOSTAP ||
 	ic->ic_opmode == IEEE80211_M_IBSS)) {
 



CVS commit: src/sys/dev/usb

2020-01-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jan 15 08:02:53 UTC 2020

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

Log Message:
Use a define instead of a magic constant.  NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/usb/if_axen.c

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

Modified files:

Index: src/sys/dev/usb/if_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.68 src/sys/dev/usb/if_axen.c:1.69
--- src/sys/dev/usb/if_axen.c:1.68	Tue Jan  7 06:42:26 2020
+++ src/sys/dev/usb/if_axen.c	Wed Jan 15 08:02:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axen.c,v 1.68 2020/01/07 06:42:26 maxv Exp $	*/
+/*	$NetBSD: if_axen.c,v 1.69 2020/01/15 08:02:53 skrll Exp $	*/
 /*	$OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.68 2020/01/07 06:42:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.69 2020/01/15 08:02:53 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -846,7 +846,7 @@ axen_rx_loop(struct usbnet *un, struct u
 			goto nextpkt;
 		}
 
-		usbnet_enqueue(un, buf + 2, pkt_len - 6,
+		usbnet_enqueue(un, buf + ETHER_ALIGN, pkt_len - 6,
 			   axen_csum_flags_rx(ifp, pkt_hdr), 0, 0);
 
 nextpkt: