CVS commit: src/sys/dev/pci

2017-04-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 13 04:27:46 UTC 2017

Modified Files:
src/sys/dev/pci: if_bge.c if_bgereg.h

Log Message:
- Read chip ID correctly on BCM57782 and BCM57786.
- Add BXCM57766 A0 string.
- Add comment for BCM5776[56]'s workaround.


To generate a diff of this commit:
cvs rdiff -u -r1.304 -r1.305 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/pci/if_bgereg.h

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

Modified files:

Index: src/sys/dev/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.304 src/sys/dev/pci/if_bge.c:1.305
--- src/sys/dev/pci/if_bge.c:1.304	Wed Apr 12 06:22:16 2017
+++ src/sys/dev/pci/if_bge.c	Thu Apr 13 04:27:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.304 2017/04/12 06:22:16 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.305 2017/04/13 04:27:46 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.304 2017/04/12 06:22:16 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.305 2017/04/13 04:27:46 msaitoh Exp $");
 
 #include 
 #include 
@@ -743,6 +743,7 @@ static const struct bge_revision {
 	{ BGE_CHIPID_BCM5906_A2, "BCM5906 A2" },
 	{ BGE_CHIPID_BCM57765_A0, "BCM57765 A0" },
 	{ BGE_CHIPID_BCM57765_B0, "BCM57765 B0" },
+	{ BGE_CHIPID_BCM57766_A0, "BCM57766 A0" },
 	{ BGE_CHIPID_BCM57780_A0, "BCM57780 A0" },
 	{ BGE_CHIPID_BCM57780_A1, "BCM57780 A1" },
 
@@ -2319,6 +2320,11 @@ bge_chipinit(struct bge_softc *sc)
 			CSR_WRITE_4(sc, BGE_MODE_CTL, mode_ctl);
 		}
 		if (BGE_CHIPREV(sc->bge_chipid) != BGE_CHIPREV_57765_AX) {
+			/*
+			 * For the 57766 and non Ax versions of 57765, bootcode
+			 * needs to setup the PCIE Fast Training Sequence (FTS)
+			 * value to prevent transmit hangs.
+			 */
 			reg = CSR_READ_4(sc, BGE_CPMU_PADRNG_CTL);
 			CSR_WRITE_4(sc, BGE_CPMU_PADRNG_CTL,
 			reg | BGE_CPMU_PADRNG_CTL_RDIV2);
@@ -3266,7 +3272,9 @@ bge_chipid(const struct pci_attach_args 
 		case PCI_PRODUCT_BROADCOM_BCM57765:
 		case PCI_PRODUCT_BROADCOM_BCM57766:
 		case PCI_PRODUCT_BROADCOM_BCM57781:
+		case PCI_PRODUCT_BROADCOM_BCM57782:
 		case PCI_PRODUCT_BROADCOM_BCM57785:
+		case PCI_PRODUCT_BROADCOM_BCM57786:
 		case PCI_PRODUCT_BROADCOM_BCM57791:
 		case PCI_PRODUCT_BROADCOM_BCM57795:
 			id = pci_conf_read(pa->pa_pc, pa->pa_tag,
@@ -5518,6 +5526,8 @@ bge_init(struct ifnet *ifp)
 	}
 
 	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57780) {
+		pcireg_t aercap;
+
 		reg = CSR_READ_4(sc, BGE_PCIE_PWRMNG_THRESH);
 		reg = (reg & ~BGE_PCIE_PWRMNG_L1THRESH_MASK)
 		| BGE_PCIE_PWRMNG_L1THRESH_4MS
@@ -5529,7 +5539,11 @@ bge_init(struct ifnet *ifp)
 		| BGE_PCIE_EIDLE_DELAY_13CLK;
 		CSR_WRITE_4(sc, BGE_PCIE_EIDLE_DELAY, reg);
 
-		/* XXX clear correctable error count */
+		/* Clear correctable error */
+		if (pci_get_ext_capability(sc->sc_pc, sc->sc_pcitag,
+		PCI_EXTCAP_AER, , NULL) != 0)
+			pci_conf_write(sc->sc_pc, sc->sc_pcitag,
+			aercap + PCI_AER_COR_STATUS, 0x);
 
 		reg = CSR_READ_4(sc, BGE_PCIE_LINKCTL);
 		reg = (reg & ~BGE_PCIE_LINKCTL_L1_PLL_PDEN)

Index: src/sys/dev/pci/if_bgereg.h
diff -u src/sys/dev/pci/if_bgereg.h:1.92 src/sys/dev/pci/if_bgereg.h:1.93
--- src/sys/dev/pci/if_bgereg.h:1.92	Wed Apr 12 06:22:16 2017
+++ src/sys/dev/pci/if_bgereg.h	Thu Apr 13 04:27:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bgereg.h,v 1.92 2017/04/12 06:22:16 msaitoh Exp $	*/
+/*	$NetBSD: if_bgereg.h,v 1.93 2017/04/13 04:27:46 msaitoh Exp $	*/
 /*
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2001
@@ -349,6 +349,7 @@
 #define	BGE_CHIPID_BCM5720_A0		0x0572
 #define	BGE_CHIPID_BCM57765_A0		0x57785000
 #define	BGE_CHIPID_BCM57765_B0		0x57785100
+#define	BGE_CHIPID_BCM57766_A0		0x57766000
 
 /* shorthand one */
 #define BGE_ASICREV(x)			((x) >> 12)



CVS commit: src/sys/dev/pci

2017-04-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 13 04:04:14 UTC 2017

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

Log Message:
 Add Broadcom BCM577x5 SDMMC, Memstic and xD.


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

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

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1284 src/sys/dev/pci/pcidevs:1.1285
--- src/sys/dev/pci/pcidevs:1.1284	Fri Mar 31 09:27:30 2017
+++ src/sys/dev/pci/pcidevs	Thu Apr 13 04:04:13 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1284 2017/03/31 09:27:30 skrll Exp $
+$NetBSD: pcidevs,v 1.1285 2017/04/13 04:04:13 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1797,6 +1797,9 @@ product BROADCOM BCM57765	0x16b4	BCM5776
 product BROADCOM BCM57785	0x16b5	BCM57785 Integrated Gigabit Ethernet
 product BROADCOM BCM57795	0x16b6	BCM57795 10/100/1000 Ethernet
 product BROADCOM BCM57782	0x16b7	BCM57782 10/100/1000 Ethernet
+product BROADCOM SDMMC		0x16bc	BCM577x5 SDMMC
+product BROADCOM MS		0x16be	BCM577x5 Memstick
+product BROADCOM XD		0x16bf	BCM577x5 xD
 product BROADCOM BCM5702_ALT	0x16c6	BCM5702 10/100/1000 Ethernet
 product BROADCOM BCM5703_ALT	0x16c7	BCM5703 10/100/1000 Ethernet
 product BROADCOM BCM5781	0x16dd	BCM5781 Integrated Gigabit Ethernet



CVS commit: src/etc

2017-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 13 02:15:36 UTC 2017

Modified Files:
src/etc: rc.subr

Log Message:
remove env.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/etc/rc.subr

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

Modified files:

Index: src/etc/rc.subr
diff -u src/etc/rc.subr:1.99 src/etc/rc.subr:1.100
--- src/etc/rc.subr:1.99	Tue Mar 21 18:52:10 2017
+++ src/etc/rc.subr	Wed Apr 12 22:15:36 2017
@@ -1,4 +1,4 @@
-# $NetBSD: rc.subr,v 1.99 2017/03/21 22:52:10 christos Exp $
+# $NetBSD: rc.subr,v 1.100 2017/04/13 02:15:36 christos Exp $
 #
 # Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -674,14 +674,14 @@ EOF
 			echo "Starting ${name}."
 			if [ -n "$_chroot" ]; then
 _doit="\
-env $_env_clear_rc_vars $_env \
+$_env_clear_rc_vars $_env \
 ${_nice:+nice -n $_nice }\
 chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
 $_chroot $command $rc_flags $command_args"
 			else
 _doit="\
 ${_chdir:+cd $_chdir; }\
-env $_env_clear_rc_vars $_env \
+$_env_clear_rc_vars $_env \
 ${_nice:+nice -n $_nice }\
 $command $rc_flags $command_args"
 if [ -n "$_user" ]; then



CVS commit: src/sys/netipsec

2017-04-12 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Apr 13 01:32:57 UTC 2017

Modified Files:
src/sys/netipsec: xform_ah.c xform_esp.c

Log Message:
Fix that ah_algorithm_lookup and esp_algorithm_lookup don't handle some 
algorithms

Unrelated upper limit values, AH_ALG_MAX and ESP_ALG_MAX, prevented some
algorithms from being looked up.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.48 -r1.49 src/sys/netipsec/xform_esp.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/netipsec/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.45 src/sys/netipsec/xform_ah.c:1.46
--- src/sys/netipsec/xform_ah.c:1.45	Thu Apr  6 09:20:07 2017
+++ src/sys/netipsec/xform_ah.c	Thu Apr 13 01:32:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.45 2017/04/06 09:20:07 ozaki-r Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.46 2017/04/13 01:32:57 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.45 2017/04/06 09:20:07 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.46 2017/04/13 01:32:57 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -130,8 +130,7 @@ static int ah_output_cb(struct cryptop*)
 const struct auth_hash *
 ah_algorithm_lookup(int alg)
 {
-	if (alg >= AH_ALG_MAX)
-		return NULL;
+
 	switch (alg) {
 	case SADB_X_AALG_NULL:
 		return _hash_null;

Index: src/sys/netipsec/xform_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.48 src/sys/netipsec/xform_esp.c:1.49
--- src/sys/netipsec/xform_esp.c:1.48	Mon Apr 10 14:19:22 2017
+++ src/sys/netipsec/xform_esp.c	Thu Apr 13 01:32:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.48 2017/04/10 14:19:22 christos Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.49 2017/04/13 01:32:57 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.48 2017/04/10 14:19:22 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.49 2017/04/13 01:32:57 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -116,8 +116,7 @@ static int esp_output_cb(struct cryptop 
 const struct enc_xform *
 esp_algorithm_lookup(int alg)
 {
-	if (alg >= ESP_ALG_MAX)
-		return NULL;
+
 	switch (alg) {
 	case SADB_EALG_DESCBC:
 		return _xform_des;



CVS commit: src/sys/opencrypto

2017-04-12 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Apr 13 01:24:34 UTC 2017

Modified Files:
src/sys/opencrypto: cryptosoft.c

Log Message:
Fix usage of MD5Final/SHA1Final

Passing NULL as the digest parameter is wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/opencrypto/cryptosoft.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/opencrypto/cryptosoft.c
diff -u src/sys/opencrypto/cryptosoft.c:1.47 src/sys/opencrypto/cryptosoft.c:1.48
--- src/sys/opencrypto/cryptosoft.c:1.47	Thu Aug 20 14:40:19 2015
+++ src/sys/opencrypto/cryptosoft.c	Thu Apr 13 01:24:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptosoft.c,v 1.47 2015/08/20 14:40:19 christos Exp $ */
+/*	$NetBSD: cryptosoft.c,v 1.48 2017/04/13 01:24:34 ozaki-r Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptosoft.c,v 1.2.2.1 2002/11/21 23:34:23 sam Exp $	*/
 /*	$OpenBSD: cryptosoft.c,v 1.35 2002/04/26 08:43:50 deraadt Exp $	*/
 
@@ -24,7 +24,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.47 2015/08/20 14:40:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.48 2017/04/13 01:24:34 ozaki-r Exp $");
 
 #include 
 #include 
@@ -948,7 +948,9 @@ swcr_newsession(void *arg, u_int32_t *si
 			axf = _auth_hash_key_md5;
 			goto auth2common;
 
-		case CRYPTO_SHA1_KPDK:
+		case CRYPTO_SHA1_KPDK: {
+			unsigned char digest[SHA1_DIGEST_LENGTH];
+			CTASSERT(SHA1_DIGEST_LENGTH >= MD5_DIGEST_LENGTH);
 			axf = _auth_hash_key_sha1;
 		auth2common:
 			(*swd)->sw_ictx = malloc(axf->ctxsize,
@@ -971,9 +973,10 @@ swcr_newsession(void *arg, u_int32_t *si
 			axf->Init((*swd)->sw_ictx);
 			axf->Update((*swd)->sw_ictx, cri->cri_key,
 			cri->cri_klen / 8);
-			axf->Final(NULL, (*swd)->sw_ictx);
+			axf->Final(digest, (*swd)->sw_ictx);
 			(*swd)->sw_axf = axf;
 			break;
+		}
 
 		case CRYPTO_MD5:
 			axf = _auth_hash_md5;



CVS commit: src/crypto/dist/ipsec-tools/src/setkey

2017-04-12 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Apr 13 01:19:17 UTC 2017

Modified Files:
src/crypto/dist/ipsec-tools/src/setkey: parse.y

Log Message:
Fix parsing ah without a key


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/crypto/dist/ipsec-tools/src/setkey/parse.y

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

Modified files:

Index: src/crypto/dist/ipsec-tools/src/setkey/parse.y
diff -u src/crypto/dist/ipsec-tools/src/setkey/parse.y:1.17 src/crypto/dist/ipsec-tools/src/setkey/parse.y:1.18
--- src/crypto/dist/ipsec-tools/src/setkey/parse.y:1.17	Wed Sep 10 21:04:08 2014
+++ src/crypto/dist/ipsec-tools/src/setkey/parse.y	Thu Apr 13 01:19:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.y,v 1.17 2014/09/10 21:04:08 christos Exp $	*/
+/*	$NetBSD: parse.y,v 1.18 2017/04/13 01:19:17 ozaki-r Exp $	*/
 
 /*	$KAME: parse.y,v 1.81 2003/07/01 04:01:48 itojun Exp $	*/
 
@@ -497,7 +497,13 @@ auth_alg
 			p_alg_auth = $1;
 
 			p_key_auth_len = 0;
-			p_key_auth = NULL;
+			p_key_auth = "";
+			if (ipsec_check_keylen(SADB_EXT_SUPPORTED_AUTH,
+			p_alg_auth,
+			PFKEY_UNUNIT64(p_key_auth_len)) < 0) {
+yyerror(ipsec_strerror());
+return -1;
+			}
 		}
 	;
 



CVS commit: src/sys/net

2017-04-12 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Apr 13 00:47:33 UTC 2017

Modified Files:
src/sys/net: if_sl.c if_strip.c

Log Message:
if MGETHDR fails, don't try to copy to single mbuf and deref null.

reduce ifdefs.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/net/if_sl.c
cvs rdiff -u -r1.107 -r1.108 src/sys/net/if_strip.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/net/if_sl.c
diff -u src/sys/net/if_sl.c:1.127 src/sys/net/if_sl.c:1.128
--- src/sys/net/if_sl.c:1.127	Sun Oct  2 14:17:07 2016
+++ src/sys/net/if_sl.c	Thu Apr 13 00:47:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sl.c,v 1.127 2016/10/02 14:17:07 christos Exp $	*/
+/*	$NetBSD: if_sl.c,v 1.128 2017/04/13 00:47:33 maya Exp $	*/
 
 /*
  * Copyright (c) 1987, 1989, 1992, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.127 2016/10/02 14:17:07 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.128 2017/04/13 00:47:33 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -705,12 +705,9 @@ slintr(void *arg)
 {
 	struct sl_softc *sc = arg;
 	struct tty *tp = sc->sc_ttyp;
-	struct mbuf *m;
+	struct mbuf *m, *n;
 	int s, len;
 	u_char *pktstart;
-#ifdef INET
-	u_char c;
-#endif
 	u_char chdr[CHDR_LEN];
 
 	KASSERT(tp != NULL);
@@ -720,9 +717,6 @@ slintr(void *arg)
 	 */
 	mutex_enter(softnet_lock);
 	for (;;) {
-#ifdef INET
-		struct ip *ip;
-#endif
 		struct mbuf *m2;
 		struct mbuf *bpf_m;
 
@@ -774,6 +768,7 @@ slintr(void *arg)
 		} else
 			bpf_m = NULL;
 #ifdef INET
+		struct ip *ip;
 		if ((ip = mtod(m, struct ip *))->ip_p == IPPROTO_TCP) {
 			if (sc->sc_if.if_flags & SC_COMPRESS)
 *mtod(m, u_char *) |=
@@ -897,6 +892,7 @@ slintr(void *arg)
 			memcpy(chdr, pktstart, CHDR_LEN);
 		}
 #ifdef INET
+		u_char c;
 		if ((c = (*pktstart & 0xf0)) != (IPVERSION << 4)) {
 			if (c & 0x80)
 c = TYPE_COMPRESSED_TCP;
@@ -942,14 +938,13 @@ slintr(void *arg)
 		}
 		/*
 		 * If the packet will fit into a single
-		 * header mbuf, copy it into one, to save
-		 * memory.
+		 * header mbuf, try to copy it into one,
+		 * to save memory.
 		 */
-		if (m->m_pkthdr.len < MHLEN) {
-			struct mbuf *n;
+		if ((m->m_pkthdr.len < MHLEN) &&
+		(n = m_gethdr(M_DONTWAIT, MT_DATA))) {
 			int pktlen;
 
-			MGETHDR(n, M_DONTWAIT, MT_DATA);
 			pktlen = m->m_pkthdr.len;
 			M_MOVE_PKTHDR(n, m);
 			memcpy(mtod(n, void *), mtod(m, void *), pktlen);

Index: src/sys/net/if_strip.c
diff -u src/sys/net/if_strip.c:1.107 src/sys/net/if_strip.c:1.108
--- src/sys/net/if_strip.c:1.107	Sun Oct  2 14:17:07 2016
+++ src/sys/net/if_strip.c	Thu Apr 13 00:47:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_strip.c,v 1.107 2016/10/02 14:17:07 christos Exp $	*/
+/*	$NetBSD: if_strip.c,v 1.108 2017/04/13 00:47:33 maya Exp $	*/
 /*	from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $	*/
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.107 2016/10/02 14:17:07 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.108 2017/04/13 00:47:33 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1073,12 +1073,9 @@ stripintr(void *arg)
 {
 	struct strip_softc *sc = arg;
 	struct tty *tp = sc->sc_ttyp;
-	struct mbuf *m;
+	struct mbuf *m, *n;
 	int s, len;
 	u_char *pktstart;
-#ifdef INET
-	u_char c;
-#endif
 	u_char chdr[CHDR_LEN];
 
 	KASSERT(tp != NULL);
@@ -1088,9 +1085,6 @@ stripintr(void *arg)
 	 */
 	mutex_enter(softnet_lock);
 	for (;;) {
-#ifdef INET
-		struct ip *ip;
-#endif
 		struct mbuf *bpf_m;
 
 		/*
@@ -1143,6 +1137,7 @@ stripintr(void *arg)
 		} else
 			bpf_m = NULL;
 #ifdef INET
+		struct ip *ip;
 		if ((ip = mtod(m, struct ip *))->ip_p == IPPROTO_TCP) {
 			if (sc->sc_if.if_flags & SC_COMPRESS)
 *mtod(m, u_char *) |=
@@ -1189,6 +1184,7 @@ stripintr(void *arg)
 			memcpy(chdr, pktstart, CHDR_LEN);
 		}
 #ifdef INET
+		u_char c;
 		if ((c = (*pktstart & 0xf0)) != (IPVERSION << 4)) {
 			if (c & 0x80)
 c = TYPE_COMPRESSED_TCP;
@@ -1234,14 +1230,13 @@ stripintr(void *arg)
 		}
 		/*
 		 * If the packet will fit into a single
-		 * header mbuf, copy it into one, to save
-		 * memory.
+		 * header mbuf, try to copy it into one,
+		 * to save memory.
 		 */
-		if (m->m_pkthdr.len < MHLEN) {
-			struct mbuf *n;
+		if ((m->m_pkthdr.len < MHLEN) &&
+		(n = m_gethdr(M_DONTWAIT, MT_DATA))) {
 			int pktlen;
 
-			MGETHDR(n, M_DONTWAIT, MT_DATA);
 			pktlen = m->m_pkthdr.len;
 			M_MOVE_PKTHDR(n, m);
 			memcpy(mtod(n, void *), mtod(m, void *), pktlen);



CVS commit: src/sys/net

2017-04-12 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Apr 13 00:12:10 UTC 2017

Modified Files:
src/sys/net: if_l2tp.c

Log Message:
l2tp(4) support when hashinit() cannot allocate requried hash size.

pointed out by s-yamaguchi@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/net/if_l2tp.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/net/if_l2tp.c
diff -u src/sys/net/if_l2tp.c:1.8 src/sys/net/if_l2tp.c:1.9
--- src/sys/net/if_l2tp.c:1.8	Tue Apr  4 23:49:17 2017
+++ src/sys/net/if_l2tp.c	Thu Apr 13 00:12:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_l2tp.c,v 1.8 2017/04/04 23:49:17 knakahara Exp $	*/
+/*	$NetBSD: if_l2tp.c,v 1.9 2017/04/13 00:12:10 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.8 2017/04/04 23:49:17 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.9 2017/04/13 00:12:10 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -110,6 +110,7 @@ static struct {
 static struct {
 	kmutex_t lock;
 	struct pslist_head *lists;
+	u_long mask;
 } l2tp_hash __cacheline_aligned = {
 	.lists = NULL,
 };
@@ -140,7 +141,7 @@ static int	l2tp_set_tunnel(struct ifnet 
 		struct sockaddr *);
 static void	l2tp_delete_tunnel(struct ifnet *);
 
-static int	id_hash_func(uint32_t);
+static int	id_hash_func(uint32_t, u_long);
 
 static void	l2tp_variant_update(struct l2tp_softc *, struct l2tp_variant *);
 static int	l2tp_set_session(struct l2tp_softc *, uint32_t, uint32_t);
@@ -1002,24 +1003,22 @@ l2tp_delete_tunnel(struct ifnet *ifp)
 }
 
 static int
-id_hash_func(uint32_t id)
+id_hash_func(uint32_t id, u_long mask)
 {
 	uint32_t hash;
 
 	hash = (id >> 16) ^ id;
 	hash = (hash >> 4) ^ hash;
 
-	return hash & (L2TP_ID_HASH_SIZE - 1);
+	return hash & mask;
 }
 
 static void
 l2tp_hash_init(void)
 {
-	u_long mask;
 
 	l2tp_hash.lists = hashinit(L2TP_ID_HASH_SIZE, HASH_PSLIST, true,
-	);
-	KASSERT(mask == (L2TP_ID_HASH_SIZE - 1));
+	_hash.mask);
 }
 
 static int
@@ -1029,19 +1028,19 @@ l2tp_hash_fini(void)
 
 	mutex_enter(_hash.lock);
 
-	for (i = 0; i < L2TP_ID_HASH_SIZE; i++) {
+	for (i = 0; i < l2tp_hash.mask + 1; i++) {
 		if (PSLIST_WRITER_FIRST(_hash.lists[i], struct l2tp_softc,
 			l2tp_hash) != NULL) {
 			mutex_exit(_hash.lock);
 			return EBUSY;
 		}
 	}
-	for (i = 0; i < L2TP_ID_HASH_SIZE; i++)
+	for (i = 0; i < l2tp_hash.mask + 1; i++)
 		PSLIST_DESTROY(_hash.lists[i]);
 
 	mutex_exit(_hash.lock);
 
-	hashdone(l2tp_hash.lists, HASH_PSLIST, L2TP_ID_HASH_SIZE - 1);
+	hashdone(l2tp_hash.lists, HASH_PSLIST, l2tp_hash.mask);
 
 	return 0;
 }
@@ -1075,7 +1074,7 @@ l2tp_set_session(struct l2tp_softc *sc, 
 	l2tp_variant_update(sc, nvar);
 	mutex_exit(>l2tp_lock);
 
-	idx = id_hash_func(nvar->lv_my_sess_id);
+	idx = id_hash_func(nvar->lv_my_sess_id, l2tp_hash.mask);
 	if ((ifp->if_flags & IFF_DEBUG) != 0)
 		log(LOG_DEBUG, "%s: add hash entry: sess_id=%" PRIu32 ", idx=%" PRIu32 "\n",
 		sc->l2tp_ec.ec_if.if_xname, nvar->lv_my_sess_id, idx);
@@ -1124,7 +1123,7 @@ l2tp_lookup_session_ref(uint32_t id, str
 	int s;
 	struct l2tp_softc *sc;
 
-	idx = id_hash_func(id);
+	idx = id_hash_func(id, l2tp_hash.mask);
 
 	s = pserialize_read_enter();
 	PSLIST_READER_FOREACH(sc, _hash.lists[idx], struct l2tp_softc,



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

2017-04-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Apr 12 23:35:29 UTC 2017

Modified Files:
src/distrib/utils/embedded/conf: armv7.conf

Log Message:
ODROID-C1: Now that the MBR partition table contains an entry for the BSD
partition, the disklabel no longer conflicts with the ODROID-C1 bootloader.
Root partition changes from ld0e to ld0a.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/distrib/utils/embedded/conf/armv7.conf

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/conf/armv7.conf
diff -u src/distrib/utils/embedded/conf/armv7.conf:1.11 src/distrib/utils/embedded/conf/armv7.conf:1.12
--- src/distrib/utils/embedded/conf/armv7.conf:1.11	Mon Apr 10 22:25:36 2017
+++ src/distrib/utils/embedded/conf/armv7.conf	Wed Apr 12 23:35:29 2017
@@ -1,4 +1,4 @@
-# $NetBSD: armv7.conf,v 1.11 2017/04/10 22:25:36 jmcneill Exp $
+# $NetBSD: armv7.conf,v 1.12 2017/04/12 23:35:29 jmcneill Exp $
 # ARMv7 customization script used by mkimage
 #
 board=armv7
@@ -99,7 +99,7 @@ populate_amlogic() {
 	cat >> "${mnt}/boot/boot.ini" << EOF
 ODROIDC-UBOOT-CONFIG
 
-setenv bootargs "root=ld0f awge0.mac-address=\${ethaddr} console=${console}"
+setenv bootargs "root=ld0a awge0.mac-address=\${ethaddr} console=${console}"
 setenv bootcmd "fatload mmc 0:1 0x2100 ${odroidc1_kernelimg}; bootm 0x2100"
 run bootcmd
 EOF



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

2017-04-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Apr 12 23:32:11 UTC 2017

Modified Files:
src/distrib/utils/embedded/conf: evbarm.conf

Log Message:
Slightly reduce the size of the MSDOS partition from 124M to 92M. With
the larger size, installing the ODROID-C1 bootloader causes the fs to
become unreadable. Not sure why..


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/distrib/utils/embedded/conf/evbarm.conf

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/conf/evbarm.conf
diff -u src/distrib/utils/embedded/conf/evbarm.conf:1.25 src/distrib/utils/embedded/conf/evbarm.conf:1.26
--- src/distrib/utils/embedded/conf/evbarm.conf:1.25	Tue Apr 11 17:30:17 2017
+++ src/distrib/utils/embedded/conf/evbarm.conf	Wed Apr 12 23:32:11 2017
@@ -1,4 +1,4 @@
-# $NetBSD: evbarm.conf,v 1.25 2017/04/11 17:30:17 jmcneill Exp $
+# $NetBSD: evbarm.conf,v 1.26 2017/04/12 23:32:11 jmcneill Exp $
 # evbarm shared config
 #
 image=$HOME/${board}.img
@@ -8,7 +8,7 @@ MACHINE=evbarm
 swap=256
 extra=48		# spare space
 init=8
-boot=$((256 - ${init}))
+boot=$((192 - ${init}))
 ffsoffset=$(( (${init} + ${boot} + ${swap}) / 2 ))m
 
 size=0		# autocompute



CVS commit: [jdolecek-ncq] src/sys/dev/ata

2017-04-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Apr 12 22:28:20 UTC 2017

Modified Files:
src/sys/dev/ata [jdolecek-ncq]: wd.c

Log Message:
more MP


To generate a diff of this commit:
cvs rdiff -u -r1.428.2.1 -r1.428.2.2 src/sys/dev/ata/wd.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/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.428.2.1 src/sys/dev/ata/wd.c:1.428.2.2
--- src/sys/dev/ata/wd.c:1.428.2.1	Wed Apr 12 21:59:14 2017
+++ src/sys/dev/ata/wd.c	Wed Apr 12 22:28:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.428.2.1 2017/04/12 21:59:14 jdolecek Exp $ */
+/*	$NetBSD: wd.c,v 1.428.2.2 2017/04/12 22:28:20 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.1 2017/04/12 21:59:14 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.2 2017/04/12 22:28:20 jdolecek Exp $");
 
 #include "opt_ata.h"
 
@@ -294,7 +294,7 @@ wdattach(device_t parent, device_t self,
 	wd->sc_dev = self;
 
 	ATADEBUG_PRINT(("wdattach\n"), DEBUG_FUNCS | DEBUG_PROBE);
-	callout_init(>sc_restart_ch, 0);
+	callout_init(>sc_restart_ch, CALLOUT_MPSAFE);
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_BIO);
 	bufq_alloc(>sc_q, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK);
 #ifdef WD_SOFTBADSECT
@@ -794,14 +794,17 @@ void
 wddone(void *v)
 {
 	struct wd_softc *wd = device_private(v);
-	struct buf *bp = wd->sc_bp;
+	struct buf *bp;
 	const char *errmsg;
 	int do_perror = 0;
 
 	ATADEBUG_PRINT(("wddone %s\n", device_xname(wd->sc_dev)),
 	DEBUG_XFERS);
-	if (bp == NULL)
-		return;
+
+	mutex_enter(>sc_lock);
+	if ((bp = wd->sc_bp) == NULL)
+		goto out;
+
 	bp->b_resid = wd->sc_wdc_bio.bcount;
 	switch (wd->sc_wdc_bio.error) {
 	case ERR_DMA:
@@ -837,7 +840,7 @@ retry2:
 			wd->retries++;
 			callout_reset(>sc_restart_ch, RECOVERYTIME,
 			wdrestart, wd);
-			return;
+			goto out;
 		}
 
 #ifdef WD_SOFTBADSECT
@@ -893,6 +896,9 @@ noerror:	if ((wd->sc_wdc_bio.flags & ATA
 	KASSERT(wd->sc_bp != NULL);
 	wd->sc_bp = NULL;
 	wdstart(wd);
+
+out:
+	mutex_exit(>sc_lock);
 }
 
 void



CVS commit: [jdolecek-ncq] src/sys/dev/ata

2017-04-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Apr 12 21:59:14 UTC 2017

Modified Files:
src/sys/dev/ata [jdolecek-ncq]: wd.c wdvar.h

Log Message:
convert to mutex, mark MPSAFE


To generate a diff of this commit:
cvs rdiff -u -r1.428 -r1.428.2.1 src/sys/dev/ata/wd.c
cvs rdiff -u -r1.43 -r1.43.4.1 src/sys/dev/ata/wdvar.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/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.428 src/sys/dev/ata/wd.c:1.428.2.1
--- src/sys/dev/ata/wd.c:1.428	Sun Mar  5 23:07:12 2017
+++ src/sys/dev/ata/wd.c	Wed Apr 12 21:59:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.428 2017/03/05 23:07:12 mlelstv Exp $ */
+/*	$NetBSD: wd.c,v 1.428.2.1 2017/04/12 21:59:14 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428 2017/03/05 23:07:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.1 2017/04/12 21:59:14 jdolecek Exp $");
 
 #include "opt_ata.h"
 
@@ -150,7 +150,7 @@ const struct bdevsw wd_bdevsw = {
 	.d_dump = wddump,
 	.d_psize = wdsize,
 	.d_discard = wddiscard,
-	.d_flag = D_DISK
+	.d_flag = D_DISK | D_MPSAFE
 };
 
 const struct cdevsw wd_cdevsw = {
@@ -165,7 +165,7 @@ const struct cdevsw wd_cdevsw = {
 	.d_mmap = nommap,
 	.d_kqfilter = nokqfilter,
 	.d_discard = wddiscard,
-	.d_flag = D_DISK
+	.d_flag = D_DISK | D_MPSAFE
 };
 
 /*
@@ -181,11 +181,9 @@ struct wd_ioctl {
 	struct wd_softc *wi_softc;
 };
 
-LIST_HEAD(, wd_ioctl) wi_head;
-
 struct	wd_ioctl *wi_find(struct buf *);
 void	wi_free(struct wd_ioctl *);
-struct	wd_ioctl *wi_get(void);
+struct	wd_ioctl *wi_get(struct wd_softc *);
 void	wdioctlstrategy(struct buf *);
 
 void  wdgetdefaultlabel(struct wd_softc *, struct disklabel *);
@@ -297,10 +295,12 @@ wdattach(device_t parent, device_t self,
 
 	ATADEBUG_PRINT(("wdattach\n"), DEBUG_FUNCS | DEBUG_PROBE);
 	callout_init(>sc_restart_ch, 0);
+	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_BIO);
 	bufq_alloc(>sc_q, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK);
 #ifdef WD_SOFTBADSECT
 	SLIST_INIT(>sc_bslist);
 #endif
+	LIST_INIT(>wi_head);
 	wd->atabus = adev->adev_bustype;
 	wd->openings = adev->adev_openings;
 	wd->drvp = adev->adev_drv_data;
@@ -458,7 +458,7 @@ int
 wddetach(device_t self, int flags)
 {
 	struct wd_softc *sc = device_private(self);
-	int bmaj, cmaj, i, mn, rc, s;
+	int bmaj, cmaj, i, mn, rc;
 
 	if ((rc = disk_begindetach(>sc_dk, wdlastclose, self, flags)) != 0)
 		return rc;
@@ -477,7 +477,7 @@ wddetach(device_t self, int flags)
 	/* Delete all of our wedges. */
 	dkwedge_delall(>sc_dk);
 
-	s = splbio();
+	mutex_enter(>sc_lock);
 
 	/* Kill off any queued buffers. */
 	bufq_drain(sc->sc_q);
@@ -486,7 +486,7 @@ wddetach(device_t self, int flags)
 	if (flags & DETACH_POWEROFF)
 		wd_standby(sc, AT_POLL);
 
-	splx(s);
+	mutex_exit(>sc_lock);
 	bufq_free(sc->sc_q);
 
 	/* Detach disk. */
@@ -502,6 +502,7 @@ wddetach(device_t self, int flags)
 	}
 	sc->sc_bscount = 0;
 #endif
+	KASSERT(LIST_EMPTY(>wi_head));
 
 	pmf_device_deregister(self);
 
@@ -527,7 +528,6 @@ wdstrategy(struct buf *bp)
 	device_lookup_private(_cd, WDUNIT(bp->b_dev));
 	struct disklabel *lp = wd->sc_dk.dk_label;
 	daddr_t blkno;
-	int s;
 
 	ATADEBUG_PRINT(("wdstrategy (%s)\n", device_xname(wd->sc_dev)),
 	DEBUG_XFERS);
@@ -604,11 +604,11 @@ wdstrategy(struct buf *bp)
 #endif
 
 	/* Queue transfer on drive, activate drive and controller if idle. */
-	s = splbio();
+	mutex_enter(>sc_lock);
 	disk_wait(>sc_dk);
 	bufq_put(wd->sc_q, bp);
 	wdstart(wd);
-	splx(s);
+	mutex_exit(>sc_lock);
 	return;
 done:
 	/* Toss transfer; we're done early. */
@@ -651,9 +651,8 @@ static void
 wd_split_mod15_write(struct buf *bp)
 {
 	struct buf *obp = bp->b_private;
-	struct wd_softc *sc =
+	struct wd_softc *wd =
 	device_lookup_private(_cd, DISKUNIT(obp->b_dev));
-	int s;
 
 	if (__predict_false(bp->b_error != 0)) {
 		/*
@@ -681,26 +680,28 @@ wd_split_mod15_write(struct buf *bp)
 	bp->b_cflags = obp->b_cflags;
 	bp->b_data = (char *)bp->b_data + bp->b_bcount;
 	bp->b_blkno += (bp->b_bcount / DEV_BSIZE);
-	bp->b_rawblkno += (bp->b_bcount / sc->sc_blksize);
-	s = splbio();
-	wdstart1(sc, bp);
-	splx(s);
+	bp->b_rawblkno += (bp->b_bcount / wd->sc_blksize);
+	mutex_enter(>sc_lock);
+	wdstart1(wd, bp);
+	mutex_exit(>sc_lock);
 	return;
 
  done:
 	obp->b_error = bp->b_error;
 	obp->b_resid = bp->b_resid;
-	s = splbio();
+	mutex_enter(>sc_lock);
 	putiobuf(bp);
 	biodone(obp);
-	sc->openings++;
-	splx(s);
+	wd->openings++;
+	mutex_exit(>sc_lock);
 	/* wddone() will call wdstart() */
 }
 
 void
 wdstart1(struct wd_softc *wd, struct buf *bp)
 {
+	/* already locked */
+	KASSERT(mutex_owned(>sc_lock));
 
 	/*
 	 * Deal with the "split mod15 write" quirk.  We just divide the
@@ -716,7 +717,6 @@ wdstart1(struct wd_softc *wd, struct buf
 			((bp->b_bcount / 512) % 15) == 

CVS commit: src/sys/kern

2017-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 12 20:05:54 UTC 2017

Modified Files:
src/sys/kern: files.kern subr_kmem.c

Log Message:
use opt_kmem.h for the KMEM_ variables.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/files.kern
cvs rdiff -u -r1.62 -r1.63 src/sys/kern/subr_kmem.c

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

Modified files:

Index: src/sys/kern/files.kern
diff -u src/sys/kern/files.kern:1.13 src/sys/kern/files.kern:1.14
--- src/sys/kern/files.kern:1.13	Tue Nov  1 20:11:59 2016
+++ src/sys/kern/files.kern	Wed Apr 12 16:05:54 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.kern,v 1.13 2016/11/02 00:11:59 pgoyette Exp $
+#	$NetBSD: files.kern,v 1.14 2017/04/12 20:05:54 christos Exp $
 
 #
 # kernel sources
@@ -113,6 +113,11 @@ file	kern/subr_interrupt.c		kern
 file	kern/subr_iostat.c		kern
 file	kern/subr_ipi.c			kern
 file	kern/subr_kcpuset.c		kern
+defflag	opt_kmem.h			KMEM_GUARD
+	KMEM_POISON
+	KMEM_REDZONE
+	KMEM_SIZE
+defparam opt_kmem.h			KMEM_GUARD_DEPTH
 file	kern/subr_kmem.c		kern
 file	kern/subr_kobj.c		kern
 file	kern/subr_kobj_vfs.c		kern

Index: src/sys/kern/subr_kmem.c
diff -u src/sys/kern/subr_kmem.c:1.62 src/sys/kern/subr_kmem.c:1.63
--- src/sys/kern/subr_kmem.c:1.62	Sun Feb 28 19:34:17 2016
+++ src/sys/kern/subr_kmem.c	Wed Apr 12 16:05:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_kmem.c,v 1.62 2016/02/29 00:34:17 chs Exp $	*/
+/*	$NetBSD: subr_kmem.c,v 1.63 2017/04/12 20:05:54 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009-2015 The NetBSD Foundation, Inc.
@@ -100,7 +100,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.62 2016/02/29 00:34:17 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.63 2017/04/12 20:05:54 christos Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_kmem.h"
+#endif
 
 #include 
 #include 



CVS commit: src

2017-04-12 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Apr 12 18:18:00 UTC 2017

Modified Files:
src/sys/arch/aarch64/include: ptrace.h
src/sys/arch/alpha/include: ptrace.h
src/sys/arch/amd64/include: ptrace.h
src/sys/arch/arm/include: ptrace.h
src/sys/arch/hppa/include: ptrace.h
src/sys/arch/m68k/include: ptrace.h
src/sys/arch/mips/include: ptrace.h
src/sys/arch/sh3/include: ptrace.h
src/sys/arch/sparc/include: ptrace.h
src/sys/arch/vax/include: ptrace.h
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add new macro PTRACE_BREAKPOINT_ASM in  MD part

This macro ships with a MD-specific assembly instruction triggering
a software breakpoint.

Missing instruction for powerpc targets.

This code is used in ATF tests (lib/libc/sys/t_ptrace_wait).

Original patch by Nick Hudson, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/include/ptrace.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/alpha/include/ptrace.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amd64/include/ptrace.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/include/ptrace.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hppa/include/ptrace.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/m68k/include/ptrace.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/mips/include/ptrace.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sh3/include/ptrace.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/include/ptrace.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/vax/include/ptrace.h
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_ptrace_wait.c

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

Modified files:

Index: src/sys/arch/aarch64/include/ptrace.h
diff -u src/sys/arch/aarch64/include/ptrace.h:1.4 src/sys/arch/aarch64/include/ptrace.h:1.5
--- src/sys/arch/aarch64/include/ptrace.h:1.4	Fri Sep 25 16:05:17 2015
+++ src/sys/arch/aarch64/include/ptrace.h	Wed Apr 12 18:17:59 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.4 2015/09/25 16:05:17 christos Exp $ */
+/* $NetBSD: ptrace.h,v 1.5 2017/04/12 18:17:59 kamil Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -57,6 +57,7 @@
 #define PTRACE_REG_INTRV(r)	(r)->r_reg[0]
 
 #define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xd4, 0x20, 0x01, 0xa0 })
+#define PTRACE_BREAKPOINT_ASM	__asm __volatile(".word 0xa00120d4" ::: "memory")
 #define PTRACE_BREAKPOINT_SIZE	4
 
 #elif defined(__arm__)

Index: src/sys/arch/alpha/include/ptrace.h
diff -u src/sys/arch/alpha/include/ptrace.h:1.8 src/sys/arch/alpha/include/ptrace.h:1.9
--- src/sys/arch/alpha/include/ptrace.h:1.8	Fri Sep 25 16:05:17 2015
+++ src/sys/arch/alpha/include/ptrace.h	Wed Apr 12 18:17:59 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.8 2015/09/25 16:05:17 christos Exp $ */
+/* $NetBSD: ptrace.h,v 1.9 2017/04/12 18:17:59 kamil Exp $ */
 
 /*
  * Copyright (c) 1994 Christopher G. Demetriou
@@ -53,4 +53,5 @@
 #define PTRACE_REG_INTRV(r)	(r)->r_regs[R_V0]
 
 #define PTRACE_BREAKPOINT	((const uint8_t[]) { 0x80, 0x00, 0x00, 0x00 })
+#define PTRACE_BREAKPOINT_ASM	__asm __volatile("bpt" ::: "memory")
 #define PTRACE_BREAKPOINT_SIZE	4

Index: src/sys/arch/amd64/include/ptrace.h
diff -u src/sys/arch/amd64/include/ptrace.h:1.11 src/sys/arch/amd64/include/ptrace.h:1.12
--- src/sys/arch/amd64/include/ptrace.h:1.11	Sat Apr  8 00:25:49 2017
+++ src/sys/arch/amd64/include/ptrace.h	Wed Apr 12 18:17:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptrace.h,v 1.11 2017/04/08 00:25:49 kamil Exp $	*/
+/*	$NetBSD: ptrace.h,v 1.12 2017/04/12 18:17:59 kamil Exp $	*/
 
 /*
  * Copyright (c) 1993 Christopher G. Demetriou
@@ -64,6 +64,7 @@
 #define PTRACE_REG_INTRV(r)	(r)->regs[_REG_RAX]
 
 #define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xcc })
+#define PTRACE_BREAKPOINT_ASM	__asm __volatile ("int3" : : : "memory")
 #define PTRACE_BREAKPOINT_SIZE	1
 #define PTRACE_BREAKPOINT_ADJ	1
 

Index: src/sys/arch/arm/include/ptrace.h
diff -u src/sys/arch/arm/include/ptrace.h:1.10 src/sys/arch/arm/include/ptrace.h:1.11
--- src/sys/arch/arm/include/ptrace.h:1.10	Sat Apr  8 00:25:49 2017
+++ src/sys/arch/arm/include/ptrace.h	Wed Apr 12 18:17:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptrace.h,v 1.10 2017/04/08 00:25:49 kamil Exp $	*/
+/*	$NetBSD: ptrace.h,v 1.11 2017/04/12 18:17:59 kamil Exp $	*/
 
 /*
  * Copyright (c) 1995 Frank Lancaster
@@ -64,5 +64,7 @@
 #define PTRACE_REG_SP(_r)		(_r)->r_sp
 #define PTRACE_REG_INTRV(_r)		(_r)->r[0]
 
-#define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xe7, 0xff, 0xff, 0xff })
+#define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xe7, 0xff, 0xff, 0xfe })
+#define PTRACE_BREAKPOINT_INSN	0xe7fe
+#define PTRACE_BREAKPOINT_ASM	__asm __volatile (".word " ___STRING(PTRACE_BREAKPOINT_INSN) )
 #define PTRACE_BREAKPOINT_SIZE	4

Index: src/sys/arch/hppa/include/ptrace.h
diff -u src/sys/arch/hppa/include/ptrace.h:1.7 src/sys/arch/hppa/include/ptrace.h:1.8
--- src/sys/arch/hppa/include/ptrace.h:1.7	Sat Apr  8 00:25:49 

CVS commit: src/distrib

2017-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 12 17:29:49 UTC 2017

Modified Files:
src/distrib/amiga/floppies/inst-common: instbin.conf
src/distrib/atari/floppies/common: list.images
src/distrib/bebox/ramdisk: list
src/distrib/evbsh3/rom/ramdiskcommon: ramdiskbin.conf
src/distrib/sets: makesrctars
src/distrib/vax/inst-common: instbin.conf

Log Message:
more gnu directory removal.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/distrib/amiga/floppies/inst-common/instbin.conf
cvs rdiff -u -r1.11 -r1.12 src/distrib/atari/floppies/common/list.images
cvs rdiff -u -r1.2 -r1.3 src/distrib/bebox/ramdisk/list
cvs rdiff -u -r1.9 -r1.10 \
src/distrib/evbsh3/rom/ramdiskcommon/ramdiskbin.conf
cvs rdiff -u -r1.40 -r1.41 src/distrib/sets/makesrctars
cvs rdiff -u -r1.4 -r1.5 src/distrib/vax/inst-common/instbin.conf

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

Modified files:

Index: src/distrib/amiga/floppies/inst-common/instbin.conf
diff -u src/distrib/amiga/floppies/inst-common/instbin.conf:1.12 src/distrib/amiga/floppies/inst-common/instbin.conf:1.13
--- src/distrib/amiga/floppies/inst-common/instbin.conf:1.12	Sun Jul  3 19:11:32 2011
+++ src/distrib/amiga/floppies/inst-common/instbin.conf	Wed Apr 12 13:29:49 2017
@@ -1,9 +1,9 @@
-#	$NetBSD: instbin.conf,v 1.12 2011/07/03 23:11:32 tron Exp $
+#	$NetBSD: instbin.conf,v 1.13 2017/04/12 17:29:49 christos Exp $
 #
 # kcbin.conf - unified binary for the kc floppy
 #
 
-srcdirs bin sbin external/bsd/less/bin usr.bin usr.sbin gnu/usr.bin
+srcdirs bin sbin external/bsd/less/bin usr.bin usr.sbin
 
 progs gawk cat chmod chown chroot cp dd df disklabel ed expr fsck_ffs ftp 
 progs gzip ifconfig init less ln ls mkdir mknod mount mount_cd9660

Index: src/distrib/atari/floppies/common/list.images
diff -u src/distrib/atari/floppies/common/list.images:1.11 src/distrib/atari/floppies/common/list.images:1.12
--- src/distrib/atari/floppies/common/list.images:1.11	Fri Jan 29 19:52:11 2016
+++ src/distrib/atari/floppies/common/list.images	Wed Apr 12 13:29:49 2017
@@ -1,6 +1,6 @@
-#	$NetBSD: list.images,v 1.11 2016/01/30 00:52:11 tsutsui Exp $
+#	$NetBSD: list.images,v 1.12 2017/04/12 17:29:49 christos Exp $
 
-SRCDIRS	bin sbin usr.bin usr.sbin gnu/usr.bin sys/arch/atari/stand
+SRCDIRS	bin sbin usr.bin usr.sbin sys/arch/atari/stand
 LIBS	libhack.o -lprop -lrmt -lz -lutil -lcurses -lterminfo -ll -lm
 
 # init invokes the shell as -sh

Index: src/distrib/bebox/ramdisk/list
diff -u src/distrib/bebox/ramdisk/list:1.2 src/distrib/bebox/ramdisk/list:1.3
--- src/distrib/bebox/ramdisk/list:1.2	Fri Jan 14 05:26:30 2011
+++ src/distrib/bebox/ramdisk/list	Wed Apr 12 13:29:49 2017
@@ -1,6 +1,6 @@
-#	$NetBSD: list,v 1.2 2011/01/14 10:26:30 tsutsui Exp $
+#	$NetBSD: list,v 1.3 2017/04/12 17:29:49 christos Exp $
 
-SRCDIRS	bin sbin usr.bin usr.sbin gnu/usr.bin
+SRCDIRS	bin sbin usr.bin usr.sbin
 
 PROG	bin/cat
 PROG	bin/chmod

Index: src/distrib/evbsh3/rom/ramdiskcommon/ramdiskbin.conf
diff -u src/distrib/evbsh3/rom/ramdiskcommon/ramdiskbin.conf:1.9 src/distrib/evbsh3/rom/ramdiskcommon/ramdiskbin.conf:1.10
--- src/distrib/evbsh3/rom/ramdiskcommon/ramdiskbin.conf:1.9	Fri Sep 12 10:46:33 2014
+++ src/distrib/evbsh3/rom/ramdiskcommon/ramdiskbin.conf	Wed Apr 12 13:29:49 2017
@@ -1,6 +1,6 @@
-#	$NetBSD: ramdiskbin.conf,v 1.9 2014/09/12 14:46:33 roy Exp $
+#	$NetBSD: ramdiskbin.conf,v 1.10 2017/04/12 17:29:49 christos Exp $
 
-srcdirs bin sbin libexec usr.bin usr.sbin gnu/usr.bin
+srcdirs bin sbin libexec usr.bin usr.sbin
 
 # /bin
 progs cat chmod cp date dd df echo ed expr hostname kill ln ls mkdir mv
@@ -70,7 +70,6 @@ progs mtree pstat pwd_mkdb syslogd trace
 # progs arp
 ln chown chgrp
 
-# gnu/usr.bin
 progs sort
 
 ln sh -sh

Index: src/distrib/sets/makesrctars
diff -u src/distrib/sets/makesrctars:1.40 src/distrib/sets/makesrctars:1.41
--- src/distrib/sets/makesrctars:1.40	Thu Feb  5 02:52:49 2015
+++ src/distrib/sets/makesrctars	Wed Apr 12 13:29:49 2017
@@ -1,6 +1,6 @@
 #! /bin/sh
 #
-#	$NetBSD: makesrctars,v 1.40 2015/02/05 07:52:49 snj Exp $
+#	$NetBSD: makesrctars,v 1.41 2017/04/12 17:29:49 christos Exp $
 #
 # makesrctars srcdir setdir
 #	Create source tarballs in setdir from the source under srcdir.
@@ -115,9 +115,9 @@ fi
 srcprefix=usr/src
 export setdir MTREE PAX CKSUM GZIP PASSWD srcprefix
 
-makeset src . -v '^\.\/common|^\.\/external\/gpl2|^\.\/external\/gpl3|^\.\/gnu|^\.\/share|^\.\/sys|^\.\/usr\.bin\/config'
+makeset src . -v '^\.\/common|^\.\/external\/gpl2|^\.\/external\/gpl3|^\.\/share|^\.\/sys|^\.\/usr\.bin\/config'
 
-makeset gnusrc . -e '^\..type=dir|^\.\/gnu|^\.\/external.type=dir|^\.\/external\/gpl2|^\.\/external\/gpl3'
+makeset gnusrc . -e '^\..type=dir|^\.\/external.type=dir|^\.\/external\/gpl2|^\.\/external\/gpl3'
 
 makeset syssrc . -e 

CVS commit: src/usr.sbin/ldpd

2017-04-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Apr 12 17:02:51 UTC 2017

Modified Files:
src/usr.sbin/ldpd: socketops.c

Log Message:
Use RO_MSGFILTER.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/ldpd/socketops.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/ldpd/socketops.c
diff -u src/usr.sbin/ldpd/socketops.c:1.33 src/usr.sbin/ldpd/socketops.c:1.34
--- src/usr.sbin/ldpd/socketops.c:1.33	Wed Oct 30 08:41:57 2013
+++ src/usr.sbin/ldpd/socketops.c	Wed Apr 12 17:02:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: socketops.c,v 1.33 2013/10/30 08:41:57 mrg Exp $ */
+/* $NetBSD: socketops.c,v 1.34 2017/04/12 17:02:51 roy Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -817,6 +817,12 @@ the_big_loop(void)
 	struct pollfd	pfd[MAX_POLL_FDS];
 	struct hello_socket *hs;
 	nfds_t pollsum;
+#ifdef RO_MSGFILTER
+	unsigned char msgfilter[] = {
+		RTM_NEWADDR, RTM_DELADDR,
+		RTM_ADD, RTM_DELETE, RTM_CHANGE,
+	};
+#endif
 
 	assert(MAX_POLL_FDS > 5);
 
@@ -835,6 +841,10 @@ the_big_loop(void)
 	route_socket = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC);
 	setsockopt(route_socket, SOL_SOCKET, SO_USELOOPBACK, &(int){0},
 		sizeof(int));
+#ifdef RO_MSGFILTER
+	setsockopt(route_socket, PF_ROUTE, RO_MSGFILTER, ,
+		sizeof(msgfilter));
+#endif
 
 	sock_error = bind_current_routes();
 	if (sock_error != LDP_E_OK) {



CVS commit: src/usr.sbin/rarpd

2017-04-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Apr 12 16:57:14 UTC 2017

Modified Files:
src/usr.sbin/rarpd: mkarp.c

Log Message:
Use RO_MSGFILTER.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/rarpd/mkarp.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/rarpd/mkarp.c
diff -u src/usr.sbin/rarpd/mkarp.c:1.11 src/usr.sbin/rarpd/mkarp.c:1.12
--- src/usr.sbin/rarpd/mkarp.c:1.11	Mon Apr  4 07:37:08 2016
+++ src/usr.sbin/rarpd/mkarp.c	Wed Apr 12 16:57:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkarp.c,v 1.11 2016/04/04 07:37:08 ozaki-r Exp $ */
+/*	$NetBSD: mkarp.c,v 1.12 2017/04/12 16:57:14 roy Exp $ */
 
 /*
  * Copyright (c) 1984, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1984, 19
 #if 0
 static char sccsid[] = "@(#)arp.c	8.3 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: mkarp.c,v 1.11 2016/04/04 07:37:08 ozaki-r Exp $");
+__RCSID("$NetBSD: mkarp.c,v 1.12 2017/04/12 16:57:14 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -132,6 +132,10 @@ mkarp(u_char *haddr, u_int32_t ipaddr)
 	struct sockaddr_inarp sin_m;
 	struct sockaddr_dl sdl_m;
 
+#ifdef RO_MSGFILTER
+	unsigned char msgfilter[] = { RTM_GET, RTM_ADD };
+#endif
+
 	sin = _m;
 	rtm = &(m_rtmsg.m_rtm);
 
@@ -158,6 +162,11 @@ mkarp(u_char *haddr, u_int32_t ipaddr)
 	s = socket(PF_ROUTE, SOCK_RAW, 0);
 	if (s < 0)
 		err(1, "socket");
+#ifdef RO_MSGFILTER
+	if (setsockopt(s, PF_ROUTE, RO_MSGFILTER,
+	, sizeof(msgfilter)) < 0)
+		warn("RO_MSGFILTER");
+#endif
 
 	rtm->rtm_flags = 0;
 



CVS commit: src/crypto/dist/ipsec-tools/src/racoon

2017-04-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Apr 12 16:47:40 UTC 2017

Modified Files:
src/crypto/dist/ipsec-tools/src/racoon: grabmyaddr.c

Log Message:
Use RO_MSGFILTER.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 \
src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c

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

Modified files:

Index: src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c
diff -u src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c:1.34 src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c:1.35
--- src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c:1.34	Sat Jun 14 22:39:36 2014
+++ src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c	Wed Apr 12 16:47:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: grabmyaddr.c,v 1.34 2014/06/14 22:39:36 christos Exp $	*/
+/*	$NetBSD: grabmyaddr.c,v 1.35 2017/04/12 16:47:39 roy Exp $	*/
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  * Copyright (C) 2008 Timo Teras .
@@ -827,6 +827,9 @@ static int
 kernel_open_socket()
 {
 	int fd;
+#ifdef RO_MSGFILTER
+	unsigned char msgfilter[] = { RTM_NEWADDR, RTM_DELADDR };
+#endif
 
 	fd = socket(PF_ROUTE, SOCK_RAW, 0);
 	if (fd < 0) {
@@ -835,6 +838,13 @@ kernel_open_socket()
 			strerror(errno));
 		return -1;
 	}
+#ifdef RO_MSGFILTER
+	if (setsockopt(fd, PF_ROUTE, RO_MSGFILTER,
+	, sizeof(msgfilter)) < 0)
+		plog(LLV_WARNING, LOCATION, NULL,
+		 "setsockopt(RO_MSGFILER) failed: %s",
+		 strerror(errno));
+#endif
 	close_on_exec(fd);
 	if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1)
 		plog(LLV_WARNING, LOCATION, NULL,



CVS commit: src/sys/dev

2017-04-12 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Wed Apr 12 14:21:12 UTC 2017

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

Log Message:
Increase the priority of the mixing thread to improve performace under
load.

This should address PR kern/52098.


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

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

Modified files:

Index: src/sys/dev/audio.c
diff -u src/sys/dev/audio.c:1.322 src/sys/dev/audio.c:1.323
--- src/sys/dev/audio.c:1.322	Wed Apr 12 14:15:50 2017
+++ src/sys/dev/audio.c	Wed Apr 12 14:21:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.322 2017/04/12 14:15:50 nat Exp $	*/
+/*	$NetBSD: audio.c,v 1.323 2017/04/12 14:21:12 nat Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.322 2017/04/12 14:15:50 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.323 2017/04/12 14:21:12 nat Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -882,9 +882,9 @@ bad_rec:
 #ifdef AUDIO_PM_IDLE
 	callout_schedule(>sc_idle_counter, audio_idle_timeout * hz);
 #endif
-	kthread_create(PRI_NONE, KTHREAD_MPSAFE | KTHREAD_MUSTJOIN, NULL,
+	kthread_create(PRI_BIO, KTHREAD_MPSAFE | KTHREAD_MUSTJOIN, NULL,
 	audio_rec_thread, sc, >sc_recthread, "audiorec");
-	kthread_create(PRI_NONE, KTHREAD_MPSAFE | KTHREAD_MUSTJOIN, NULL,
+	kthread_create(PRI_BIO, KTHREAD_MPSAFE | KTHREAD_MUSTJOIN, NULL,
 	audio_play_thread, sc, >sc_playthread, "audiomix");
 	audiorescan(self, "audio", NULL);
 }



CVS commit: src/sys/dev

2017-04-12 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Wed Apr 12 14:15:51 UTC 2017

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

Log Message:
Insert silence into the mix ring if there is no audio (or audio cannot
keep up) from the channels.

Addresses PR kern/34647.


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

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

Modified files:

Index: src/sys/dev/audio.c
diff -u src/sys/dev/audio.c:1.321 src/sys/dev/audio.c:1.322
--- src/sys/dev/audio.c:1.321	Tue Apr 11 23:49:17 2017
+++ src/sys/dev/audio.c	Wed Apr 12 14:15:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.321 2017/04/11 23:49:17 nat Exp $	*/
+/*	$NetBSD: audio.c,v 1.322 2017/04/12 14:15:50 nat Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.321 2017/04/11 23:49:17 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.322 2017/04/12 14:15:50 nat Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -3789,9 +3789,13 @@ audio_mix(void *v)
 	if (sc->sc_saturate == true && sc->sc_opens > 1)
 		saturate_func(sc);
 
+	vc = SIMPLEQ_FIRST(>sc_audiochan)->vc;
 	cb = >sc_pr;
-	if (sc->sc_writeme == true)
-		cb->s.inp = audio_stream_add_inp(>s, cb->s.inp, blksize);
+	inp = cb->s.inp;
+	cc = blksize - (inp - cb->s.start) % blksize;
+	if (sc->sc_writeme == false)
+		audio_pint_silence(sc, cb, inp, cc, vc);
+	cb->s.inp = audio_stream_add_inp(>s, cb->s.inp, blksize);
 	mutex_exit(sc->sc_intr_lock);
 
 	kpreempt_disable();



CVS commit: src/sys/kern

2017-04-12 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 12 10:35:10 UTC 2017

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

Log Message:
Switch vfs_getvfs(), dounmount() and vfs_mountroot() to mountlist iterator.

Add a helper to retrieve a mount with "highest generation < arg" and
use it from vfs_unmount_forceone() and vfs_unmountall1().


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

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

Modified files:

Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.52 src/sys/kern/vfs_mount.c:1.53
--- src/sys/kern/vfs_mount.c:1.52	Tue Apr 11 07:46:37 2017
+++ src/sys/kern/vfs_mount.c	Wed Apr 12 10:35:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.52 2017/04/11 07:46:37 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.53 2017/04/12 10:35:10 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.52 2017/04/11 07:46:37 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.53 2017/04/12 10:35:10 hannken Exp $");
 
 #include 
 #include 
@@ -234,11 +234,9 @@ vfs_getnewfsid(struct mount *mp)
 		++xxxfs_mntid;
 	tfsid.__fsid_val[0] = makedev(mtype & 0xff, xxxfs_mntid);
 	tfsid.__fsid_val[1] = mtype;
-	if (!TAILQ_EMPTY()) {
-		while (vfs_getvfs()) {
-			tfsid.__fsid_val[0]++;
-			xxxfs_mntid++;
-		}
+	while (vfs_getvfs()) {
+		tfsid.__fsid_val[0]++;
+		xxxfs_mntid++;
 	}
 	mp->mnt_stat.f_fsidx.__fsid_val[0] = tfsid.__fsid_val[0];
 	mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
@@ -253,17 +251,18 @@ vfs_getnewfsid(struct mount *mp)
 struct mount *
 vfs_getvfs(fsid_t *fsid)
 {
+	mount_iterator_t *iter;
 	struct mount *mp;
 
-	mutex_enter(_lock);
-	TAILQ_FOREACH(mp, , mnt_list) {
+	mountlist_iterator_init();
+	while ((mp = mountlist_iterator_next(iter)) != NULL) {
 		if (mp->mnt_stat.f_fsidx.__fsid_val[0] == fsid->__fsid_val[0] &&
 		mp->mnt_stat.f_fsidx.__fsid_val[1] == fsid->__fsid_val[1]) {
-			mutex_exit(_lock);
-			return (mp);
+			mountlist_iterator_destroy(iter);
+			return mp;
 		}
 	}
-	mutex_exit(_lock);
+	mountlist_iterator_destroy(iter);
 	return NULL;
 }
 
@@ -832,6 +831,7 @@ err_unmounted:
 int
 dounmount(struct mount *mp, int flags, struct lwp *l)
 {
+	mount_iterator_t *iter;
 	struct mount *cmp;
 	vnode_t *coveredvp;
 	int error, async, used_syncer, used_extattr;
@@ -845,14 +845,14 @@ dounmount(struct mount *mp, int flags, s
 	/*
 	 * No unmount below layered mounts.
 	 */
-	mutex_enter(_lock);
-	TAILQ_FOREACH(cmp, , mnt_list) {
+	mountlist_iterator_init();
+	while ((cmp = mountlist_iterator_next(iter)) != NULL) {
 		if (cmp->mnt_lower == mp) {
-			mutex_exit(_lock);
+			mountlist_iterator_destroy(iter);
 			return EBUSY;
 		}
 	}
-	mutex_exit(_lock);
+	mountlist_iterator_destroy(iter);
 
 	/*
 	 * XXX Freeze syncer.  Must do this before locking the
@@ -983,38 +983,57 @@ vfs_unmount_print(struct mount *mp, cons
 	mp->mnt_stat.f_fstypename);
 }
 
-bool
-vfs_unmount_forceone(struct lwp *l)
+/*
+ * Return the mount with the highest generation less than "gen".
+ */
+static struct mount *
+vfs_unmount_next(uint64_t gen)
 {
+	mount_iterator_t *iter;
 	struct mount *mp, *nmp;
-	int error;
 
 	nmp = NULL;
 
-	TAILQ_FOREACH_REVERSE(mp, , mntlist, mnt_list) {
-		if (nmp == NULL || mp->mnt_gen > nmp->mnt_gen) {
+	mountlist_iterator_init();
+	while ((mp = mountlist_iterator_next(iter)) != NULL) {
+		if ((nmp == NULL || mp->mnt_gen > nmp->mnt_gen) && 
+		mp->mnt_gen < gen) {
+			if (nmp != NULL)
+vfs_destroy(nmp);
 			nmp = mp;
+			atomic_inc_uint(>mnt_refcnt);
 		}
 	}
-	if (nmp == NULL) {
+	mountlist_iterator_destroy(iter);
+
+	return nmp;
+}
+
+bool
+vfs_unmount_forceone(struct lwp *l)
+{
+	struct mount *mp;
+	int error;
+
+	mp = vfs_unmount_next(mountgen);
+	if (mp == NULL) {
 		return false;
 	}
 
 #ifdef DEBUG
 	printf("forcefully unmounting %s (%s)...\n",
-	nmp->mnt_stat.f_mntonname, nmp->mnt_stat.f_mntfromname);
+	mp->mnt_stat.f_mntonname, mp->mnt_stat.f_mntfromname);
 #endif
-	atomic_inc_uint(>mnt_refcnt);
-	if ((error = dounmount(nmp, MNT_FORCE, l)) == 0) {
-		vfs_unmount_print(nmp, "forcefully ");
+	if ((error = dounmount(mp, MNT_FORCE, l)) == 0) {
+		vfs_unmount_print(mp, "forcefully ");
 		return true;
 	} else {
-		vfs_destroy(nmp);
+		vfs_destroy(mp);
 	}
 
 #ifdef DEBUG
 	printf("forceful unmount of %s failed with error %d\n",
-	nmp->mnt_stat.f_mntonname, error);
+	mp->mnt_stat.f_mntonname, error);
 #endif
 
 	return false;
@@ -1023,17 +1042,23 @@ vfs_unmount_forceone(struct lwp *l)
 bool
 vfs_unmountall1(struct lwp *l, bool force, bool verbose)
 {
-	struct mount *mp, *nmp;
+	struct mount *mp;
 	bool any_error = false, progress = false;
+	uint64_t gen;
 	int error;
 
-	TAILQ_FOREACH_REVERSE_SAFE(mp, , mntlist, mnt_list, nmp) {
+	gen = mountgen;
+	for (;;) {
+		mp = 

CVS commit: src/sys/kern

2017-04-12 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 12 10:30:02 UTC 2017

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

Log Message:
Switch veriexec_dump() and veriexec_flush() to mountlist iterator.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/kern_veriexec.c

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

Modified files:

Index: src/sys/kern/kern_veriexec.c
diff -u src/sys/kern/kern_veriexec.c:1.11 src/sys/kern/kern_veriexec.c:1.12
--- src/sys/kern/kern_veriexec.c:1.11	Tue Aug  4 12:44:04 2015
+++ src/sys/kern/kern_veriexec.c	Wed Apr 12 10:30:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_veriexec.c,v 1.11 2015/08/04 12:44:04 maxv Exp $	*/
+/*	$NetBSD: kern_veriexec.c,v 1.12 2017/04/12 10:30:02 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2006 Elad Efrat 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.11 2015/08/04 12:44:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.12 2017/04/12 10:30:02 hannken Exp $");
 
 #include "opt_veriexec.h"
 
@@ -1363,20 +1363,15 @@ veriexec_file_dump(struct veriexec_file_
 int
 veriexec_dump(struct lwp *l, prop_array_t rarray)
 {
-	struct mount *mp, *nmp;
-
-	mutex_enter(_lock);
-	for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) {
-		/* If it fails, the file-system is [being] unmounted. */
-		if (vfs_busy(mp, ) != 0)
-			continue;
+	mount_iterator_t *iter;
+	struct mount *mp;
 
+	mountlist_iterator_init();
+	while ((mp = mountlist_iterator_next(iter)) != NULL) {
 		fileassoc_table_run(mp, veriexec_hook,
 		(fileassoc_cb_t)veriexec_file_dump, rarray);
-
-		vfs_unbusy(mp, false, );
 	}
-	mutex_exit(_lock);
+	mountlist_iterator_destroy(iter);
 
 	return (0);
 }
@@ -1384,24 +1379,19 @@ veriexec_dump(struct lwp *l, prop_array_
 int
 veriexec_flush(struct lwp *l)
 {
-	struct mount *mp, *nmp;
+	mount_iterator_t *iter;
+	struct mount *mp;
 	int error = 0;
 
-	mutex_enter(_lock);
-	for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) {
+	mountlist_iterator_init();
+	while ((mp = mountlist_iterator_next(iter)) != NULL) {
 		int lerror;
 
-		/* If it fails, the file-system is [being] unmounted. */
-		if (vfs_busy(mp, ) != 0)
-			continue;
-
 		lerror = veriexec_table_delete(l, mp);
 		if (lerror && lerror != ENOENT)
 			error = lerror;
-
-		vfs_unbusy(mp, false, );
 	}
-	mutex_exit(_lock);
+	mountlist_iterator_destroy(iter);
 
 	return (error);
 }



CVS commit: src/sys/kern

2017-04-12 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 12 10:28:39 UTC 2017

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

Log Message:
Switch do_sys_sync() and do_sys_getvfsstat() to mountlist iterator.


To generate a diff of this commit:
cvs rdiff -u -r1.509 -r1.510 src/sys/kern/vfs_syscalls.c

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

Modified files:

Index: src/sys/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.509 src/sys/kern/vfs_syscalls.c:1.510
--- src/sys/kern/vfs_syscalls.c:1.509	Tue Mar  7 11:54:16 2017
+++ src/sys/kern/vfs_syscalls.c	Wed Apr 12 10:28:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.509 2017/03/07 11:54:16 hannken Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.510 2017/04/12 10:28:39 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.509 2017/03/07 11:54:16 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.510 2017/04/12 10:28:39 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -641,14 +641,12 @@ struct ctldebug debug0 = { "syncprt", 
 void
 do_sys_sync(struct lwp *l)
 {
-	struct mount *mp, *nmp;
+	mount_iterator_t *iter;
+	struct mount *mp;
 	int asyncflag;
 
-	mutex_enter(_lock);
-	for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) {
-		if (vfs_busy(mp, )) {
-			continue;
-		}
+	mountlist_iterator_init();
+	while ((mp = mountlist_iterator_next(iter)) != NULL) {
 		fstrans_start(mp, FSTRANS_SHARED);
 		mutex_enter(>mnt_updating);
 		if ((mp->mnt_flag & MNT_RDONLY) == 0) {
@@ -660,9 +658,8 @@ do_sys_sync(struct lwp *l)
 		}
 		mutex_exit(>mnt_updating);
 		fstrans_done(mp);
-		vfs_unbusy(mp, false, );
 	}
-	mutex_exit(_lock);
+	mountlist_iterator_destroy(iter);
 #ifdef DEBUG
 	if (syncprt)
 		vfs_bufstats();
@@ -1251,39 +1248,32 @@ do_sys_getvfsstat(struct lwp *l, void *s
 register_t *retval)
 {
 	int root = 0;
+	mount_iterator_t *iter;
 	struct proc *p = l->l_proc;
-	struct mount *mp, *nmp;
+	struct mount *mp;
 	struct statvfs *sb;
 	size_t count, maxcount;
 	int error = 0;
 
 	sb = STATVFSBUF_GET();
 	maxcount = bufsize / entry_sz;
-	mutex_enter(_lock);
 	count = 0;
-	for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) {
-		if (vfs_busy(mp, )) {
-			continue;
-		}
+	mountlist_iterator_init();
+	while ((mp = mountlist_iterator_next(iter)) != NULL) {
 		if (sfsp && count < maxcount) {
 			error = dostatvfs(mp, sb, l, flags, 0);
 			if (error) {
-vfs_unbusy(mp, false, );
 error = 0;
 continue;
 			}
 			error = copyfn(sb, sfsp, entry_sz);
-			if (error) {
-vfs_unbusy(mp, false, NULL);
+			if (error)
 goto out;
-			}
 			sfsp = (char *)sfsp + entry_sz;
 			root |= strcmp(sb->f_mntonname, "/") == 0;
 		}
 		count++;
-		vfs_unbusy(mp, false, );
 	}
-	mutex_exit(_lock);
 
 	if (root == 0 && p->p_cwdi->cwdi_rdir) {
 		/*
@@ -1305,6 +1295,7 @@ do_sys_getvfsstat(struct lwp *l, void *s
 	else
 		*retval = count;
 out:
+	mountlist_iterator_destroy(iter);
 	STATVFSBUF_PUT(sb);
 	return error;
 }



CVS commit: src/sys/kern

2017-04-12 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 12 10:26:33 UTC 2017

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

Log Message:
Switch vfs_vnode_lock_print() and printlockedvnodes() to _mountlist_next().

Switch sched_sync() and sysctl_kern_vnode() to mountlist iterator.


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

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

Modified files:

Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.461 src/sys/kern/vfs_subr.c:1.462
--- src/sys/kern/vfs_subr.c:1.461	Fri Mar 31 08:38:14 2017
+++ src/sys/kern/vfs_subr.c	Wed Apr 12 10:26:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_subr.c,v 1.461 2017/03/31 08:38:14 msaitoh Exp $	*/
+/*	$NetBSD: vfs_subr.c,v 1.462 2017/04/12 10:26:33 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.461 2017/03/31 08:38:14 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.462 2017/04/12 10:26:33 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -759,9 +759,10 @@ lazy_sync_vnode(struct vnode *vp)
 void
 sched_sync(void *arg)
 {
+	mount_iterator_t *iter;
 	synclist_t *slp;
 	struct vnode *vp;
-	struct mount *mp, *nmp;
+	struct mount *mp;
 	time_t starttime;
 	bool synced;
 
@@ -773,23 +774,19 @@ sched_sync(void *arg)
 		/*
 		 * Sync mounts whose dirty time has expired.
 		 */
-		mutex_enter(_lock);
-		for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) {
+		mountlist_iterator_init();
+		while ((mp = mountlist_iterator_next(iter)) != NULL) {
 			if ((mp->mnt_iflag & IMNT_ONWORKLIST) == 0 ||
 			mp->mnt_synclist_slot != syncer_delayno) {
-nmp = TAILQ_NEXT(mp, mnt_list);
 continue;
 			}
 			mp->mnt_synclist_slot = sync_delay_slot(sync_delay(mp));
-			if (vfs_busy(mp, ))
-continue;
 			if (fstrans_start_nowait(mp, FSTRANS_SHARED) == 0) {
 VFS_SYNC(mp, MNT_LAZY, curlwp->l_cred);
 fstrans_done(mp);
 			}
-			vfs_unbusy(mp, false, );
 		}
-		mutex_exit(_lock);
+		mountlist_iterator_destroy(iter);
 
 		mutex_enter(_data_lock);
 
@@ -967,8 +964,9 @@ sysctl_kern_vnode(SYSCTLFN_ARGS)
 {
 	char *where = oldp;
 	size_t *sizep = oldlenp;
-	struct mount *mp, *nmp;
+	struct mount *mp;
 	vnode_t *vp, vbuf;
+	mount_iterator_t *iter;
 	struct vnode_iterator *marker;
 	char *bp = where;
 	char *ewhere;
@@ -988,17 +986,14 @@ sysctl_kern_vnode(SYSCTLFN_ARGS)
 	ewhere = where + *sizep;
 
 	sysctl_unlock();
-	mutex_enter(_lock);
-	for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) {
-		if (vfs_busy(mp, )) {
-			continue;
-		}
+	mountlist_iterator_init();
+	while ((mp = mountlist_iterator_next(iter)) != NULL) {
 		vfs_vnode_iterator_init(mp, );
 		while ((vp = vfs_vnode_iterator_next(marker, NULL, NULL))) {
 			if (bp + VPTRSZ + VNODESZ > ewhere) {
 vrele(vp);
 vfs_vnode_iterator_destroy(marker);
-vfs_unbusy(mp, false, NULL);
+mountlist_iterator_destroy(iter);
 sysctl_relock();
 *sizep = bp - where;
 return (ENOMEM);
@@ -1008,7 +1003,7 @@ sysctl_kern_vnode(SYSCTLFN_ARGS)
 			(error = copyout(, bp + VPTRSZ, VNODESZ))) {
 vrele(vp);
 vfs_vnode_iterator_destroy(marker);
-vfs_unbusy(mp, false, NULL);
+mountlist_iterator_destroy(iter);
 sysctl_relock();
 return (error);
 			}
@@ -1016,9 +1011,8 @@ sysctl_kern_vnode(SYSCTLFN_ARGS)
 			bp += VPTRSZ + VNODESZ;
 		}
 		vfs_vnode_iterator_destroy(marker);
-		vfs_unbusy(mp, false, );
 	}
-	mutex_exit(_lock);
+	mountlist_iterator_destroy(iter);
 	sysctl_relock();
 
 	*sizep = bp - where;
@@ -1549,7 +1543,7 @@ vfs_vnode_lock_print(void *vlock, int fu
 	struct mount *mp;
 	vnode_impl_t *vip;
 
-	TAILQ_FOREACH(mp, , mnt_list) {
+	for (mp = _mountlist_next(NULL); mp; mp = _mountlist_next(mp)) {
 		TAILQ_FOREACH(vip, >mnt_vnodelist, vi_mntvnodes) {
 			if (>vi_lock != vlock)
 continue;
@@ -1656,25 +1650,18 @@ void printlockedvnodes(void);
 void
 printlockedvnodes(void)
 {
-	struct mount *mp, *nmp;
+	struct mount *mp;
 	vnode_t *vp;
 	vnode_impl_t *vip;
 
 	printf("Locked vnodes\n");
-	mutex_enter(_lock);
-	for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) {
-		if (vfs_busy(mp, )) {
-			continue;
-		}
+	for (mp = _mountlist_next(NULL); mp; mp = _mountlist_next(mp)) {
 		TAILQ_FOREACH(vip, >mnt_vnodelist, vi_mntvnodes) {
 			vp = VIMPL_TO_VNODE(vip);
 			if (VOP_ISLOCKED(vp))
 vprint(NULL, vp);
 		}
-		mutex_enter(_lock);
-		vfs_unbusy(mp, false, );
 	}
-	mutex_exit(_lock);
 }
 
 #endif /* DDB || DEBUGPRINT */



CVS commit: src/sys/kern

2017-04-12 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 12 10:23:35 UTC 2017

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

Log Message:
Switch fstrans_dump() to _mountlist_next().


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/kern/vfs_trans.c

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

Modified files:

Index: src/sys/kern/vfs_trans.c
diff -u src/sys/kern/vfs_trans.c:1.40 src/sys/kern/vfs_trans.c:1.41
--- src/sys/kern/vfs_trans.c:1.40	Thu Mar 30 09:13:01 2017
+++ src/sys/kern/vfs_trans.c	Wed Apr 12 10:23:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_trans.c,v 1.40 2017/03/30 09:13:01 hannken Exp $	*/
+/*	$NetBSD: vfs_trans.c,v 1.41 2017/04/12 10:23:35 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.40 2017/03/30 09:13:01 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.41 2017/04/12 10:23:35 hannken Exp $");
 
 /*
  * File system transaction operations.
@@ -871,7 +871,7 @@ fstrans_dump(int full)
 fstrans_print_lwp(p, l, full == 1);
 
 	printf("Fstrans state by mount:\n");
-	TAILQ_FOREACH(mp, , mnt_list)
+	for (mp = _mountlist_next(NULL); mp; mp = _mountlist_next(mp))
 		fstrans_print_mount(mp, full == 1);
 }
 #endif /* defined(DDB) */



CVS commit: src/sys/miscfs/specfs

2017-04-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 12 06:43:56 UTC 2017

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Make the non-DIAGNOSTIC version compile


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/miscfs/specfs/spec_vnops.c

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

Modified files:

Index: src/sys/miscfs/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.170 src/sys/miscfs/specfs/spec_vnops.c:1.171
--- src/sys/miscfs/specfs/spec_vnops.c:1.170	Tue Apr 11 14:25:01 2017
+++ src/sys/miscfs/specfs/spec_vnops.c	Wed Apr 12 06:43:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.170 2017/04/11 14:25:01 riastradh Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.171 2017/04/12 06:43:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.170 2017/04/11 14:25:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.171 2017/04/12 06:43:56 martin Exp $");
 
 #include 
 #include 
@@ -1086,9 +1086,8 @@ spec_inactive(void *v)
 		struct vnode *a_vp;
 		struct bool *a_recycle;
 	} */ *ap = v;
-	struct vnode *vp = ap->a_vp;
 
-	KASSERT(vp->v_mount == dead_rootmount);
+	KASSERT(ap->a_vp->v_mount == dead_rootmount);
 	*ap->a_recycle = true;
 
 	return 0;



CVS commit: src/sys/dev/pci

2017-04-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Apr 12 06:22:17 UTC 2017

Modified Files:
src/sys/dev/pci: if_bge.c if_bgereg.h

Log Message:
 Add a workaround for BCM57780 to prevent device timeout. This change prevent
L1PM feature do wrongy. Tested with Dell latitude 2120.


To generate a diff of this commit:
cvs rdiff -u -r1.303 -r1.304 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/pci/if_bgereg.h

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

Modified files:

Index: src/sys/dev/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.303 src/sys/dev/pci/if_bge.c:1.304
--- src/sys/dev/pci/if_bge.c:1.303	Wed Apr 12 06:04:34 2017
+++ src/sys/dev/pci/if_bge.c	Wed Apr 12 06:22:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.303 2017/04/12 06:04:34 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.304 2017/04/12 06:22:16 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.303 2017/04/12 06:04:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.304 2017/04/12 06:22:16 msaitoh Exp $");
 
 #include 
 #include 
@@ -4257,6 +4257,13 @@ bge_reset(struct bge_softc *sc)
 	 */
 	bge_writemem_ind(sc, BGE_SRAM_FW_MB, BGE_SRAM_FW_MB_MAGIC);
 
+	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57780) {
+		val = CSR_READ_4(sc, BGE_PCIE_LINKCTL);
+		val = (val & ~BGE_PCIE_LINKCTL_L1_PLL_PDEN)
+		| BGE_PCIE_LINKCTL_L1_PLL_PDDIS;
+		CSR_WRITE_4(sc, BGE_PCIE_LINKCTL, val);
+	}
+
 	/* 5718 reset step 6, 57XX step 7 */
 	reset = BGE_MISCCFG_RESET_CORE_CLOCKS | BGE_32BITTIME_66MHZ;
 	/*
@@ -5510,6 +5517,26 @@ bge_init(struct ifnet *ifp)
 		CSR_WRITE_4(sc, BGE_CPMU_HST_ACC, reg);
 	}
 
+	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57780) {
+		reg = CSR_READ_4(sc, BGE_PCIE_PWRMNG_THRESH);
+		reg = (reg & ~BGE_PCIE_PWRMNG_L1THRESH_MASK)
+		| BGE_PCIE_PWRMNG_L1THRESH_4MS
+		| BGE_PCIE_PWRMNG_EXTASPMTMR_EN;
+		CSR_WRITE_4(sc, BGE_PCIE_PWRMNG_THRESH, reg);
+
+		reg = CSR_READ_4(sc, BGE_PCIE_EIDLE_DELAY);
+		reg = (reg & ~BGE_PCIE_EIDLE_DELAY_MASK)
+		| BGE_PCIE_EIDLE_DELAY_13CLK;
+		CSR_WRITE_4(sc, BGE_PCIE_EIDLE_DELAY, reg);
+
+		/* XXX clear correctable error count */
+
+		reg = CSR_READ_4(sc, BGE_PCIE_LINKCTL);
+		reg = (reg & ~BGE_PCIE_LINKCTL_L1_PLL_PDEN)
+		| BGE_PCIE_LINKCTL_L1_PLL_PDDIS;
+		CSR_WRITE_4(sc, BGE_PCIE_LINKCTL, reg);
+	}
+
 	bge_sig_post_reset(sc, BGE_RESET_START);
 
 	bge_chipinit(sc);

Index: src/sys/dev/pci/if_bgereg.h
diff -u src/sys/dev/pci/if_bgereg.h:1.91 src/sys/dev/pci/if_bgereg.h:1.92
--- src/sys/dev/pci/if_bgereg.h:1.91	Sun May 17 12:06:26 2015
+++ src/sys/dev/pci/if_bgereg.h	Wed Apr 12 06:22:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bgereg.h,v 1.91 2015/05/17 12:06:26 msaitoh Exp $	*/
+/*	$NetBSD: if_bgereg.h,v 1.92 2017/04/12 06:22:16 msaitoh Exp $	*/
 /*
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2001
@@ -1946,6 +1946,27 @@
 #define	BGE_TLP_DATA_FIFO_PROTECT	0x0200
 
 /*
+ * PCIe L1 config registers?
+ */
+#define	BGE_PCIE_PWRMNG_THRESH		0x7d28
+#define	BGE_PCIE_LINKCTL		0x7d54
+#define	BGE_PCIE_EIDLE_DELAY		0x7e70
+
+/* PCIe Power Management register */
+#define	BGE_PCIE_PWRMNG_L1THRESH_MASK	0xff00
+#define	BGE_PCIE_PWRMNG_L1THRESH_4MS	0xff00
+#define	BGE_PCIE_PWRMNG_EXTASPMTMR_EN	0x0100
+
+/* PCIe link control register */
+#define	BGE_PCIE_LINKCTL_L1_PLL_PDEN	0x0008
+#define	BGE_PCIE_LINKCTL_L1_PLL_PDDIS	0x0080
+
+/* PCIe Enhanced idle delay register */
+#define	BGE_PCIE_EIDLE_DELAY_MASK	0x001f
+#define	BGE_PCIE_EIDLE_DELAY_13CLK	0x000c
+
+
+/*
  * PHY Test Control Register
  * Applicable to BCM5721 and BCM5751 only
  */



CVS commit: src/sys/dev/pci

2017-04-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Apr 12 06:04:34 UTC 2017

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

Log Message:
 Fix a bug that BCM5785 write wrongly to the PCI config area.


To generate a diff of this commit:
cvs rdiff -u -r1.302 -r1.303 src/sys/dev/pci/if_bge.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_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.302 src/sys/dev/pci/if_bge.c:1.303
--- src/sys/dev/pci/if_bge.c:1.302	Wed Apr 12 05:59:43 2017
+++ src/sys/dev/pci/if_bge.c	Wed Apr 12 06:04:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.302 2017/04/12 05:59:43 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.303 2017/04/12 06:04:34 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.302 2017/04/12 05:59:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.303 2017/04/12 06:04:34 msaitoh Exp $");
 
 #include 
 #include 
@@ -3421,9 +3421,8 @@ bge_attach(device_t parent, device_t sel
 	sc->bge_chipid = bge_chipid(pa);
 	sc->bge_phy_addr = bge_phy_addr(sc);
 
-	if ((pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_PCIEXPRESS,
-	>bge_pciecap, NULL) != 0)
-	|| (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5785)) {
+	if (pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_PCIEXPRESS,
+	>bge_pciecap, NULL) != 0) {
 		/* PCIe */
 		sc->bge_flags |= BGEF_PCIE;
 		/* Extract supported maximum payload size. */
@@ -3436,6 +3435,9 @@ bge_attach(device_t parent, device_t sel
 		else
 			sc->bge_expmrq = 4096;
 		bge_set_max_readrq(sc);
+	} else if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5785) {
+		/* PCIe without PCIe cap */
+		sc->bge_flags |= BGEF_PCIE;
 	} else if ((pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_PCISTATE) &
 		BGE_PCISTATE_PCI_BUSMODE) == 0) {
 		/* PCI-X */



CVS commit: src/sys/dev/pci

2017-04-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Apr 12 05:59:44 UTC 2017

Modified Files:
src/sys/dev/pci: if_bge.c if_bgevar.h

Log Message:
 Add counters for spurious interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/if_bgevar.h

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

Modified files:

Index: src/sys/dev/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.301 src/sys/dev/pci/if_bge.c:1.302
--- src/sys/dev/pci/if_bge.c:1.301	Wed Apr 12 05:50:52 2017
+++ src/sys/dev/pci/if_bge.c	Wed Apr 12 05:59:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.301 2017/04/12 05:50:52 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.302 2017/04/12 05:59:43 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.301 2017/04/12 05:50:52 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.302 2017/04/12 05:59:43 msaitoh Exp $");
 
 #include 
 #include 
@@ -4073,6 +4073,10 @@ alloc_retry:
 	 */
 	evcnt_attach_dynamic(>bge_ev_intr, EVCNT_TYPE_INTR,
 	NULL, device_xname(sc->bge_dev), "intr");
+	evcnt_attach_dynamic(>bge_ev_intr_spurious, EVCNT_TYPE_INTR,
+	NULL, device_xname(sc->bge_dev), "intr_spurious");
+	evcnt_attach_dynamic(>bge_ev_intr_spurious2, EVCNT_TYPE_INTR,
+	NULL, device_xname(sc->bge_dev), "intr_spurious2");
 	evcnt_attach_dynamic(>bge_ev_tx_xoff, EVCNT_TYPE_MISC,
 	NULL, device_xname(sc->bge_dev), "tx_xoff");
 	evcnt_attach_dynamic(>bge_ev_tx_xon, EVCNT_TYPE_MISC,

Index: src/sys/dev/pci/if_bgevar.h
diff -u src/sys/dev/pci/if_bgevar.h:1.22 src/sys/dev/pci/if_bgevar.h:1.23
--- src/sys/dev/pci/if_bgevar.h:1.22	Wed Apr 12 05:50:52 2017
+++ src/sys/dev/pci/if_bgevar.h	Wed Apr 12 05:59:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bgevar.h,v 1.22 2017/04/12 05:50:52 msaitoh Exp $	*/
+/*	$NetBSD: if_bgevar.h,v 1.23 2017/04/12 05:59:43 msaitoh Exp $	*/
 /*
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2001
@@ -326,7 +326,7 @@ struct bge_softc {
 	 * Event counters.
 	 */
 	struct evcnt bge_ev_intr;	/* interrupts */
-	struct evcnt bge_ev_intr_spurious;  /* spurious intr. (taged status) */
+	struct evcnt bge_ev_intr_spurious;  /* spurious intr. (tagged status)*/
 	struct evcnt bge_ev_intr_spurious2; /* spurious interrupts */
 	struct evcnt bge_ev_tx_xoff;	/* send PAUSE(len>0) packets */
 	struct evcnt bge_ev_tx_xon;	/* send PAUSE(len=0) packets */