CVS commit: src/sys/dev/mii

2018-06-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jun 19 05:14:36 UTC 2018

Modified Files:
src/sys/dev/mii: miidevs.h miidevs_data.h

Log Message:
 Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/mii/miidevs_data.h

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

Modified files:

Index: src/sys/dev/mii/miidevs.h
diff -u src/sys/dev/mii/miidevs.h:1.131 src/sys/dev/mii/miidevs.h:1.132
--- src/sys/dev/mii/miidevs.h:1.131	Wed Jun 13 23:25:41 2018
+++ src/sys/dev/mii/miidevs.h	Tue Jun 19 05:14:36 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs.h,v 1.131 2018/06/13 23:25:41 jdolecek Exp $	*/
+/*	$NetBSD: miidevs.h,v 1.132 2018/06/19 05:14:36 msaitoh Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.128 2018/06/13 23:25:25 jdolecek Exp
+ *	NetBSD: miidevs,v 1.129 2018/06/19 05:14:16 msaitoh Exp
  */
 
 /*-
@@ -400,7 +400,7 @@
 #define	MII_MODEL_xxMARVELL_I347	0x001c
 #define	MII_STR_xxMARVELL_I347	"Intel I347-AT4 Gigabit PHY"
 #define	MII_MODEL_xxMARVELL_E1512	0x001d
-#define	MII_STR_xxMARVELL_E1512	"Marvell 88E1512 Gigabit PHY"
+#define	MII_STR_xxMARVELL_E1512	"Marvell 88E151[0248] Gigabit PHY"
 #define	MII_MODEL_xxMARVELL_E1340M	0x001f
 #define	MII_STR_xxMARVELL_E1340M	"Marvell 88E1340 Gigabit PHY"
 #define	MII_MODEL_xxMARVELL_E1116	0x0021

Index: src/sys/dev/mii/miidevs_data.h
diff -u src/sys/dev/mii/miidevs_data.h:1.119 src/sys/dev/mii/miidevs_data.h:1.120
--- src/sys/dev/mii/miidevs_data.h:1.119	Wed Jun 13 23:25:41 2018
+++ src/sys/dev/mii/miidevs_data.h	Tue Jun 19 05:14:36 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs_data.h,v 1.119 2018/06/13 23:25:41 jdolecek Exp $	*/
+/*	$NetBSD: miidevs_data.h,v 1.120 2018/06/19 05:14:36 msaitoh Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.128 2018/06/13 23:25:25 jdolecek Exp
+ *	NetBSD: miidevs,v 1.129 2018/06/19 05:14:16 msaitoh Exp
  */
 
 /*-



CVS commit: src/sys/dev/mii

2018-06-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jun 19 05:14:16 UTC 2018

Modified Files:
src/sys/dev/mii: miidevs

Log Message:
 All of 88E151[0248]'s model number is 0x001d.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/dev/mii/miidevs

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/mii/miidevs
diff -u src/sys/dev/mii/miidevs:1.128 src/sys/dev/mii/miidevs:1.129
--- src/sys/dev/mii/miidevs:1.128	Wed Jun 13 23:25:25 2018
+++ src/sys/dev/mii/miidevs	Tue Jun 19 05:14:16 2018
@@ -1,4 +1,4 @@
-$NetBSD: miidevs,v 1.128 2018/06/13 23:25:25 jdolecek Exp $
+$NetBSD: miidevs,v 1.129 2018/06/19 05:14:16 msaitoh Exp $
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -269,7 +269,7 @@ model xxMARVELL E		0x000c Marvell 88
 model xxMARVELL E1145		0x000d Marvell 88E1145 Quad Gigabit PHY
 model xxMARVELL E6060		0x0010 Marvell 88E6060 6-Port 10/100 Fast Ethernet Switch
 model xxMARVELL I347		0x001c Intel I347-AT4 Gigabit PHY
-model xxMARVELL E1512		0x001d Marvell 88E1512 Gigabit PHY
+model xxMARVELL E1512		0x001d Marvell 88E151[0248] Gigabit PHY
 model xxMARVELL E1340M		0x001f Marvell 88E1340 Gigabit PHY
 model xxMARVELL E1116		0x0021 Marvell 88E1116 Gigabit PHY
 model xxMARVELL E1118		0x0022 Marvell 88E1118 Gigabit PHY



CVS commit: src/sys/kern

2018-06-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jun 19 04:10:51 UTC 2018

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

Log Message:
Sigh, fix another stupid mistake in previous that squeaked by because,
again, I booted the wrong test kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/sys/kern/subr_autoconf.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/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.259 src/sys/kern/subr_autoconf.c:1.260
--- src/sys/kern/subr_autoconf.c:1.259	Mon Jun 18 16:31:42 2018
+++ src/sys/kern/subr_autoconf.c	Tue Jun 19 04:10:51 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.259 2018/06/18 16:31:42 thorpej Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.260 2018/06/19 04:10:51 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.259 2018/06/18 16:31:42 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.260 2018/06/19 04:10:51 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -2286,12 +2286,13 @@ device_compatible_entry_matches(const st
 {
 	const char **cpp = DEVICE_COMPAT_ENTRY_GET_STRINGS(dce);
 
-	if (cpp == NULL)
+	if (dce == NULL || cpp == NULL)
 		return false;
 	
-	while (*cpp != NULL)
-		if (strcmp(*cpp++, compatible) == 0)
+	for (; *cpp != NULL; cpp++) {
+		if (strcmp(*cpp, compatible) == 0)
 			return true;
+	}
 
 	return false;
 }



CVS commit: src/sys/dev/i2c

2018-06-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jun 19 02:08:12 UTC 2018

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

Log Message:
Use the device_compatible_entry mechanism rather than of_compat_data;
all of the OF / FDT data we need is already in the i2c_attach_args.


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

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

Modified files:

Index: src/sys/dev/i2c/axppmic.c
diff -u src/sys/dev/i2c/axppmic.c:1.11 src/sys/dev/i2c/axppmic.c:1.12
--- src/sys/dev/i2c/axppmic.c:1.11	Sat Jun 16 21:22:13 2018
+++ src/sys/dev/i2c/axppmic.c	Tue Jun 19 02:08:12 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.11 2018/06/16 21:22:13 thorpej Exp $ */
+/* $NetBSD: axppmic.c,v 1.12 2018/06/19 02:08:12 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2014-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.11 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.12 2018/06/19 02:08:12 thorpej Exp $");
 
 #include 
 #include 
@@ -264,6 +264,7 @@ struct axpreg_attach_args {
 	i2c_addr_t	reg_addr;
 };
 
+static const char *axp803_compatstrings[] = { "x-powers,axp803", NULL };
 static const struct axppmic_config axp803_config = {
 	.name = "AXP803",
 	.controls = axp803_ctrls,
@@ -282,6 +283,8 @@ static const struct axppmic_config axp80
 	.chargestirq = AXPPMIC_IRQ(4, __BITS(1,0)),	
 };
 
+static const char *axp805_compatstrings[] = { "x-powers,axp805",
+	  "x-powers,axp806", NULL };
 static const struct axppmic_config axp805_config = {
 	.name = "AXP805/806",
 	.controls = axp805_ctrls,
@@ -290,11 +293,10 @@ static const struct axppmic_config axp80
 	.poklirq = AXPPMIC_IRQ(2, __BIT(0)),
 };
 
-static const struct of_compat_data compat_data[] = {
-	{ "x-powers,axp803",	(uintptr_t)&axp803_config },
-	{ "x-powers,axp805",	(uintptr_t)&axp805_config },
-	{ "x-powers,axp806",	(uintptr_t)&axp805_config },
-	{ NULL }
+static const struct device_compatible_entry axppmic_compat_data[] = {
+	DEVICE_COMPAT_ENTRY_WITH_DATA(axp803_compatstrings, &axp803_config),
+	DEVICE_COMPAT_ENTRY_WITH_DATA(axp805_compatstrings, &axp805_config),
+	DEVICE_COMPAT_TERMINATOR
 };
 
 static int
@@ -678,22 +680,10 @@ static int
 axppmic_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
+	int match_result;
 
-	/* XXXJRT Gross. */
-	if (ia->ia_name != NULL) {
-		if (ia->ia_cookie) {
-			int match_result =
-			of_match_compat_data(ia->ia_cookie, compat_data);
-			if (match_result) {
-match_result = match_result - 1 +
-I2C_MATCH_DIRECT_COMPATIBLE;
-match_result = MIN(match_result,
-I2C_MATCH_DIRECT_COMPATIBLE_MAX);
-			}
-			return match_result;
-		} else
-			return 0;
-	}
+	if (iic_use_direct_match(ia, match, axppmic_compat_data, &match_result))
+		return match_result;
 
 	/* This device is direct-config only. */
 
@@ -704,6 +694,7 @@ static void
 axppmic_attach(device_t parent, device_t self, void *aux)
 {
 	struct axppmic_softc *sc = device_private(self);
+	const struct device_compatible_entry *dce;
 	const struct axppmic_config *c;
 	struct axpreg_attach_args aaa;
 	struct i2c_attach_args *ia = aux;
@@ -711,7 +702,9 @@ axppmic_attach(device_t parent, device_t
 	uint32_t irq_mask;
 	void *ih;
 
-	c = (void *)of_search_compatible(ia->ia_cookie, compat_data)->data;
+	dce = iic_compatible_match(ia, axppmic_compat_data, NULL);
+	KASSERT(dce != NULL);
+	c = DEVICE_COMPAT_ENTRY_GET_PTR(dce);
 
 	sc->sc_dev = self;
 	sc->sc_i2c = ia->ia_tag;



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

2018-06-18 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jun 19 01:24:17 UTC 2018

Modified Files:
src/sys/arch/arm/rockchip: rk_cru_composite.c

Log Message:
rk_cru_composite_set_rate: allow selection of parent clocks in different
domains


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/rockchip/rk_cru_composite.c

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

Modified files:

Index: src/sys/arch/arm/rockchip/rk_cru_composite.c
diff -u src/sys/arch/arm/rockchip/rk_cru_composite.c:1.2 src/sys/arch/arm/rockchip/rk_cru_composite.c:1.3
--- src/sys/arch/arm/rockchip/rk_cru_composite.c:1.2	Sun Jun 17 14:48:15 2018
+++ src/sys/arch/arm/rockchip/rk_cru_composite.c	Tue Jun 19 01:24:17 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_cru_composite.c,v 1.2 2018/06/17 14:48:15 jmcneill Exp $ */
+/* $NetBSD: rk_cru_composite.c,v 1.3 2018/06/19 01:24:17 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_cru_composite.c,v 1.2 2018/06/17 14:48:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_cru_composite.c,v 1.3 2018/06/19 01:24:17 jmcneill Exp $");
 
 #include 
 #include 
@@ -36,6 +36,8 @@ __KERNEL_RCSID(0, "$NetBSD: rk_cru_compo
 
 #include 
 
+#include 
+
 int
 rk_cru_composite_enable(struct rk_cru_softc *sc, struct rk_cru_clk *clk,
 int enable)
@@ -85,7 +87,8 @@ rk_cru_composite_set_rate(struct rk_cru_
 {
 	struct rk_cru_composite *composite = &clk->u.composite;
 	u_int best_div, best_mux, best_diff;
-	struct rk_cru_clk *clk_parent;
+	struct rk_cru_clk *rclk_parent;
+	struct clk *clk_parent;
 
 	KASSERT(clk->type == RK_CRU_COMPOSITE);
 
@@ -93,10 +96,15 @@ rk_cru_composite_set_rate(struct rk_cru_
 	best_mux = 0;
 	best_diff = INT_MAX;
 	for (u_int mux = 0; mux < composite->nparents; mux++) {
-		clk_parent = rk_cru_clock_find(sc, composite->parents[mux]);
+		rclk_parent = rk_cru_clock_find(sc, composite->parents[mux]);
+		if (rclk_parent != NULL)
+			clk_parent = &rclk_parent->base;
+		else
+			clk_parent = fdtbus_clock_byname(composite->parents[mux]);
 		if (clk_parent == NULL)
 			continue;
-		const u_int prate = clk_get_rate(&clk_parent->base);
+
+		const u_int prate = clk_get_rate(clk_parent);
 		if (prate == 0)
 			continue;
 



CVS commit: src/sys/dev/ic

2018-06-18 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jun 18 23:50:35 UTC 2018

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

Log Message:
Write MAC address high register before low register. Apparently the
hardware updates the filter when the low register is written.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/ic/dwc_gmac.c

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

Modified files:

Index: src/sys/dev/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.48 src/sys/dev/ic/dwc_gmac.c:1.49
--- src/sys/dev/ic/dwc_gmac.c:1.48	Mon Jun 18 22:57:18 2018
+++ src/sys/dev/ic/dwc_gmac.c	Mon Jun 18 23:50:35 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.48 2018/06/18 22:57:18 jmcneill Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.49 2018/06/18 23:50:35 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.48 2018/06/18 22:57:18 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.49 2018/06/18 23:50:35 jmcneill Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -317,13 +317,13 @@ static void
 dwc_gmac_write_hwaddr(struct dwc_gmac_softc *sc,
 uint8_t enaddr[ETHER_ADDR_LEN])
 {
-	uint32_t lo, hi;
+	uint32_t hi, lo;
 
+	hi = enaddr[4] | (enaddr[5] << 8);
 	lo = enaddr[0] | (enaddr[1] << 8) | (enaddr[2] << 16)
 	| (enaddr[3] << 24);
-	hi = enaddr[4] | (enaddr[5] << 8);
-	bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_MAC_ADDR0LO, lo);
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_MAC_ADDR0HI, hi);
+	bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_MAC_ADDR0LO, lo);
 }
 
 static int



CVS commit: src/share/man/man9

2018-06-18 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jun 18 23:40:14 UTC 2018

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

Log Message:
The whole point of my recent addition of the specificdata(9) man page
was so it could be cross-referenced here.  So, add the xref.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/share/man/man9/module.9

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

Modified files:

Index: src/share/man/man9/module.9
diff -u src/share/man/man9/module.9:1.48 src/share/man/man9/module.9:1.49
--- src/share/man/man9/module.9:1.48	Fri Jun 15 22:40:33 2018
+++ src/share/man/man9/module.9	Mon Jun 18 23:40:14 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: module.9,v 1.48 2018/06/15 22:40:33 pgoyette Exp $
+.\"	$NetBSD: module.9,v 1.49 2018/06/18 23:40:14 pgoyette Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd June 16, 2018
+.Dd June 19, 2018
 .Dt MODULE 9
 .Os
 .Sh NAME
@@ -591,6 +591,7 @@ is for finding modules passed in by the 
 .Sh SEE ALSO
 .Xr modctl 2 ,
 .Xr module 7 ,
+.Xr specificdata 9 ,
 .Xr intro 9lua
 .Sh HISTORY
 The kernel module subsystem first appeared in



CVS commit: src/sys/dev/ic

2018-06-18 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jun 18 22:57:18 UTC 2018

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

Log Message:
Clear IFF_RUNNING | IFF_OACTIVE when stopping interface.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/ic/dwc_gmac.c

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

Modified files:

Index: src/sys/dev/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.47 src/sys/dev/ic/dwc_gmac.c:1.48
--- src/sys/dev/ic/dwc_gmac.c:1.47	Sun Jun 17 13:12:25 2018
+++ src/sys/dev/ic/dwc_gmac.c	Mon Jun 18 22:57:18 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.47 2018/06/17 13:12:25 jmcneill Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.48 2018/06/18 22:57:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.47 2018/06/17 13:12:25 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.48 2018/06/18 22:57:18 jmcneill Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -926,6 +926,8 @@ dwc_gmac_stop_locked(struct ifnet *ifp, 
 	mii_down(&sc->sc_mii);
 	dwc_gmac_reset_tx_ring(sc, &sc->sc_txq);
 	dwc_gmac_reset_rx_ring(sc, &sc->sc_rxq);
+
+	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
 }
 
 /*



CVS commit: src/sys/arch/x86/x86

2018-06-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jun 18 20:20:27 UTC 2018

Modified Files:
src/sys/arch/x86/x86: fpu.c

Log Message:
Add more KASSERTs, see if they help PR/53383.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/x86/x86/fpu.c

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

Modified files:

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.37 src/sys/arch/x86/x86/fpu.c:1.38
--- src/sys/arch/x86/x86/fpu.c:1.37	Sun Jun 17 06:03:40 2018
+++ src/sys/arch/x86/x86/fpu.c	Mon Jun 18 20:20:27 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.37 2018/06/17 06:03:40 maxv Exp $	*/
+/*	$NetBSD: fpu.c,v 1.38 2018/06/18 20:20:27 maxv Exp $	*/
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.37 2018/06/17 06:03:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.38 2018/06/18 20:20:27 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -628,6 +628,7 @@ fpu_save_area_clear(struct lwp *l, unsig
 	fpusave_lwp(l, false);
 	fpu_save = process_fpframe(l);
 	pcb = lwp_getpcb(l);
+	KASSERT(pcb->pcb_fpcpu == NULL);
 
 	if (i386_use_fxsave) {
 		memset(&fpu_save->sv_xmm, 0, x86_fpu_save_size);
@@ -654,6 +655,7 @@ fpu_save_area_clear(struct lwp *l, unsig
 	 * CPU.
 	 */
 	if (x86_fpu_eager) {
+		KASSERT(l == curlwp);
 		fpu_eagerswitch(NULL, l);
 	}
 }
@@ -693,6 +695,8 @@ fpu_save_area_fork(struct pcb *pcb2, con
 
 	if (extra > 0)
 		memcpy(pcb2 + 1, pcb1 + 1, extra);
+
+	KASSERT(pcb2->pcb_fpcpu == NULL);
 }
 
 /* -- */



CVS commit: src/usr.bin/patch

2018-06-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 18 18:33:31 UTC 2018

Modified Files:
src/usr.bin/patch: inp.c pch.c util.c util.h

Log Message:
Keep things portable (requested by joerg) by not depending on reallocarr
and instead doing the overflow check ourselves.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/patch/inp.c
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/patch/pch.c
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/patch/util.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/patch/util.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.bin/patch/inp.c
diff -u src/usr.bin/patch/inp.c:1.25 src/usr.bin/patch/inp.c:1.26
--- src/usr.bin/patch/inp.c:1.25	Fri Jun 15 20:40:14 2018
+++ src/usr.bin/patch/inp.c	Mon Jun 18 14:33:31 2018
@@ -1,7 +1,7 @@
 /*
  * $OpenBSD: inp.c,v 1.34 2006/03/11 19:41:30 otto Exp $
  * $DragonFly: src/usr.bin/patch/inp.c,v 1.6 2007/09/29 23:11:10 swildner Exp $
- * $NetBSD: inp.c,v 1.25 2018/06/16 00:40:14 christos Exp $
+ * $NetBSD: inp.c,v 1.26 2018/06/18 18:33:31 christos Exp $
  */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: inp.c,v 1.25 2018/06/16 00:40:14 christos Exp $");
+__RCSID("$NetBSD: inp.c,v 1.26 2018/06/18 18:33:31 christos Exp $");
 
 #include 
 #include 
@@ -118,11 +118,12 @@ scan_input(const char *filename)
 static bool
 reallocate_lines(size_t *lines_allocated)
 {
+	char	**p;
 	size_t	new_size;
 
 	new_size = *lines_allocated * 3 / 2;
-	int res = reallocarr(&i_ptr, new_size + 2,  sizeof(char *));
-	if (res != 0) {	/* shucks, it was a near thing */
+	p = pch_realloc(i_ptr, new_size + 2,  sizeof(char *));
+	if (p == NULL) {	/* shucks, it was a near thing */
 		munmap(i_womp, i_size);
 		i_womp = NULL;
 		free(i_ptr);
@@ -131,6 +132,7 @@ reallocate_lines(size_t *lines_allocated
 		return false;
 	}
 	*lines_allocated = new_size;
+	i_ptr = p;
 	return true;
 }
 

Index: src/usr.bin/patch/pch.c
diff -u src/usr.bin/patch/pch.c:1.29 src/usr.bin/patch/pch.c:1.30
--- src/usr.bin/patch/pch.c:1.29	Thu Apr  5 14:50:10 2018
+++ src/usr.bin/patch/pch.c	Mon Jun 18 14:33:31 2018
@@ -1,7 +1,7 @@
 /*
  * $OpenBSD: pch.c,v 1.37 2007/09/02 15:19:33 deraadt Exp $
  * $DragonFly: src/usr.bin/patch/pch.c,v 1.6 2008/08/10 23:35:40 joerg Exp $
- * $NetBSD: pch.c,v 1.29 2018/04/05 18:50:10 christos Exp $
+ * $NetBSD: pch.c,v 1.30 2018/06/18 18:33:31 christos Exp $
  */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: pch.c,v 1.29 2018/04/05 18:50:10 christos Exp $");
+__RCSID("$NetBSD: pch.c,v 1.30 2018/06/18 18:33:31 christos Exp $");
 
 #include 
 #include 
@@ -156,15 +156,15 @@ grow_hunkmax(void)
 	if (p_line == NULL || p_len == NULL || p_char == NULL)
 		fatal("Internal memory allocation error\n");
 
-	new_p_line = realloc(p_line, new_hunkmax * sizeof(char *));
+	new_p_line = pch_realloc(p_line, new_hunkmax, sizeof(char *));
 	if (new_p_line == NULL)
 		free(p_line);
 
-	new_p_len = realloc(p_len, new_hunkmax * sizeof(short));
+	new_p_len = pch_realloc(p_len, new_hunkmax, sizeof(short));
 	if (new_p_len == NULL)
 		free(p_len);
 
-	new_p_char = realloc(p_char, new_hunkmax * sizeof(char));
+	new_p_char = pch_realloc(p_char, new_hunkmax, sizeof(char));
 	if (new_p_char == NULL)
 		free(p_char);
 

Index: src/usr.bin/patch/util.c
diff -u src/usr.bin/patch/util.c:1.27 src/usr.bin/patch/util.c:1.28
--- src/usr.bin/patch/util.c:1.27	Sat Nov  7 13:11:21 2015
+++ src/usr.bin/patch/util.c	Mon Jun 18 14:33:31 2018
@@ -1,7 +1,7 @@
 /*
  * $OpenBSD: util.c,v 1.32 2006/03/11 19:41:30 otto Exp $
  * $DragonFly: src/usr.bin/patch/util.c,v 1.9 2007/09/29 23:11:10 swildner Exp $
- * $NetBSD: util.c,v 1.27 2015/11/07 18:11:21 joerg Exp $
+ * $NetBSD: util.c,v 1.28 2018/06/18 18:33:31 christos Exp $
  */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: util.c,v 1.27 2015/11/07 18:11:21 joerg Exp $");
+__RCSID("$NetBSD: util.c,v 1.28 2018/06/18 18:33:31 christos Exp $");
 
 #include 
 #include 
@@ -435,3 +435,13 @@ my_exit(int status)
 	unlink(TMPPATNAME);
 	exit(status);
 }
+
+void *
+pch_realloc(void *ptr, size_t number, size_t size)
+{
+	if (number > SIZE_MAX / size) {
+		errno = EOVERFLOW;
+		return NULL;
+	}
+	return realloc(ptr, number * size);
+}

Index: src/usr.bin/patch/util.h
diff -u src/usr.bin/patch/util.h:1.12 src/usr.bin/patch/util.h:1.13
--- src/usr.bin/patch/util.h:1.12	Tue Sep  6 14:25:14 2011
+++ src/usr.bin/patch/util.h	Mon Jun 18 14:33:31 2018
@@ -1,7 +1,7 @@
 /*
  * $OpenBSD: util.h,v 1.15 2005/06/20 07:14:06 otto Exp $
  * $DragonFly: src/usr.bin/patch/util.h,v 1.2 2007/09/29 23:11:10 swildner Exp $
- * $NetBSD: util.h,v 1.12 2011/09/06 18:25:14 joerg Exp $
+ * $NetBSD: util.h,v 1.13 2018/06/18 18:33:31 christos Exp $
  */
 
 /*
@@ -45,6 +45,7 @@ void		ignore_signals(void);
 void		makedirs(const char *, bool);
 void		version(void) __dead;
 void		my_exit(int) __dead;
+void		*pch_realloc(void *, size_t, size_t)

CVS commit: src/sys

2018-06-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jun 18 17:07:07 UTC 2018

Modified Files:
src/sys/arch/macppc/dev: deq.c smusat.c
src/sys/arch/sparc64/dev: pcf8591_envctrl.c
src/sys/dev/i2c: adadc.c adm1021.c adm1026.c as3722.c at24cxx.c
axp20x.c axp22x.c dbcool.c ds1307.c dstemp.c fcu.c i2c.c i2cvar.h
ihidev.c lm75.c lm87.c max77620.c pcf8563.c sy8106a.c tcagpio.c
tcakp.c titemp.c tsl256x.c

Log Message:
- Rename iic_compat_match() to iic_compatible_match() and change it
  to use the new device_compatible_match() routine.  A pointer to
  the matching device_compatible_entry is returned if a match is
  found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
  direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
  simplify model selection.

(I'm coming for you next, of_compat_data...)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/macppc/dev/deq.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/macppc/dev/smusat.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc64/dev/pcf8591_envctrl.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/adadc.c src/sys/dev/i2c/axp22x.c \
src/sys/dev/i2c/fcu.c src/sys/dev/i2c/max77620.c \
src/sys/dev/i2c/tsl256x.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/i2c/adm1021.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/adm1026.c src/sys/dev/i2c/ihidev.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/i2c/as3722.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/i2c/at24cxx.c src/sys/dev/i2c/ds1307.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/i2c/axp20x.c
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/i2c/dbcool.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/dstemp.c src/sys/dev/i2c/sy8106a.c \
src/sys/dev/i2c/tcagpio.c
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/i2c/i2c.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/i2c/i2cvar.h
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/i2c/lm75.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/lm87.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/i2c/pcf8563.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/tcakp.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/titemp.c

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

Modified files:

Index: src/sys/arch/macppc/dev/deq.c
diff -u src/sys/arch/macppc/dev/deq.c:1.14 src/sys/arch/macppc/dev/deq.c:1.15
--- src/sys/arch/macppc/dev/deq.c:1.14	Sat Jun 16 21:22:13 2018
+++ src/sys/arch/macppc/dev/deq.c	Mon Jun 18 17:07:07 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: deq.c,v 1.14 2018/06/16 21:22:13 thorpej Exp $	*/
+/*	$NetBSD: deq.c,v 1.15 2018/06/18 17:07:07 thorpej Exp $	*/
 
 /*-
  * Copyright (C) 2005 Michael Lorenz
@@ -32,7 +32,7 @@
  */
  
 #include 
-__KERNEL_RCSID(0, "$NetBSD: deq.c,v 1.14 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: deq.c,v 1.15 2018/06/18 17:07:07 thorpej Exp $");
 
 #include 
 #include 
@@ -61,13 +61,18 @@ static const char * deq_compats[] = {
 	NULL
 };
 
+static const struct device_compatible_entry deq_compat_data[] = {
+	DEVICE_COMPAT_ENTRY(deq_compats),
+	DEVICE_COMPAT_TERMINATOR
+};
+
 int
 deq_match(device_t parent, struct cfdata *cf, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
 	int match_result;
 
-	if (iic_use_direct_match(ia, cf, deq_compats, &match_result))
+	if (iic_use_direct_match(ia, cf, deq_compat_data, &match_result))
 		return match_result;
 
 	/* This driver is direct-config only. */

Index: src/sys/arch/macppc/dev/smusat.c
diff -u src/sys/arch/macppc/dev/smusat.c:1.4 src/sys/arch/macppc/dev/smusat.c:1.5
--- src/sys/arch/macppc/dev/smusat.c:1.4	Sat Jun 16 21:22:13 2018
+++ src/sys/arch/macppc/dev/smusat.c	Mon Jun 18 17:07:07 2018
@@ -111,13 +111,18 @@ static const char * smusat_compats[] = {
 	NULL
 };
 
+static const struct device_compatible_entry smusat_compat_data[] = {
+	DEVICE_COMPAT_ENTRY(smusat_compats),
+	DEVICE_COMPAT_TERMINATOR
+};
+
 static int
 smusat_match(device_t parent, struct cfdata *cf, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
 	int match_result;
 
-	if (iic_use_direct_match(ia, cf, smusat_compats, &match_result))
+	if (iic_use_direct_match(ia, cf, smusat_compat_data, &match_result))
 		return match_result;
 
 	if (ia->ia_addr == 0x58)

Index: src/sys/arch/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.7 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.8
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.7	Sat Jun 16 21:22:13 2018
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Mon Jun 18 17:07:07 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.7 2018/06/16 21:22:13 thorpej Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.8 2018/06/18 17:07:07 thorpej Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.7 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envc

CVS commit: src/sys/kern

2018-06-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jun 18 16:31:42 UTC 2018

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

Log Message:
Fix a silly mistake in device_compatible_entry_matches() that I made
while re-factoring this from a prior version.

(I booted the wrong kernel when testing, oops.)


To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/sys/kern/subr_autoconf.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/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.258 src/sys/kern/subr_autoconf.c:1.259
--- src/sys/kern/subr_autoconf.c:1.258	Mon Jun 18 15:36:54 2018
+++ src/sys/kern/subr_autoconf.c	Mon Jun 18 16:31:42 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.258 2018/06/18 15:36:54 thorpej Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.259 2018/06/18 16:31:42 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.258 2018/06/18 15:36:54 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.259 2018/06/18 16:31:42 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -2290,7 +2290,7 @@ device_compatible_entry_matches(const st
 		return false;
 	
 	while (*cpp != NULL)
-		if (strcmp(*cpp, compatible) == 0)
+		if (strcmp(*cpp++, compatible) == 0)
 			return true;
 
 	return false;



CVS commit: [netbsd-8] src/doc

2018-06-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 18 15:44:05 UTC 2018

Modified Files:
src/doc [netbsd-8]: CHANGES-8.0

Log Message:
Tickets #882, #883, #884, #885 and #886


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.211 -r1.1.2.212 src/doc/CHANGES-8.0

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-8.0
diff -u src/doc/CHANGES-8.0:1.1.2.211 src/doc/CHANGES-8.0:1.1.2.212
--- src/doc/CHANGES-8.0:1.1.2.211	Thu Jun 14 20:11:02 2018
+++ src/doc/CHANGES-8.0	Mon Jun 18 15:44:05 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.211 2018/06/14 20:11:02 martin Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.212 2018/06/18 15:44:05 martin Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -13922,3 +13922,32 @@ share/mk/bsd.sys.mk1.280, 1.281
 	[christos, ticket #881]
 
 
+usr.sbin/ofctl/ofctl.81.6,1.7 (patch)
+
+	Merge single-letter options. Use more markup.
+	Document -l, -r, and -w.
+	[sevan, ticket #882]
+
+sys/arch/arm/arm/psci.c1.2
+sys/arch/arm/fdt/psci_fdt.c			1.5
+
+	Use correct value for PSCI 0.2+ PSCI_CPU_ON.
+	Fix PSCI 0.1 detection.
+	[jakllsch, ticket #883]
+
+sys/arch/powerpc/powerpc/trap.c			1.154
+
+	Fix emulation of the mtmsr instruction.
+	[uwe, ticket #884]
+
+sys/dev/ic/dwc_gmac.c1.47
+
+	Avoid calling bus_dmamap_sync with len=0.
+	[jmcneill, ticket #885]
+
+share/mk/bsd.sys.mk1.282
+
+	The compat build plays games with MAKEOBJDIR and unsets
+	MAKEOBJDIRPREFIX. Keep using our standard NETBSDOBJDIR if it was set.
+	[christos, ticket #886]
+



CVS commit: [netbsd-8] src/share/mk

2018-06-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 18 15:42:29 UTC 2018

Modified Files:
src/share/mk [netbsd-8]: bsd.sys.mk

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

share/mk/bsd.sys.mk: revision 1.282

The compat build plays games with MAKEOBJDIR and unsets MAKEOBJDIRPREFIX.
Keep using our standard NETBSDOBJDIR if it was set.


To generate a diff of this commit:
cvs rdiff -u -r1.271.4.2 -r1.271.4.3 src/share/mk/bsd.sys.mk

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

Modified files:

Index: src/share/mk/bsd.sys.mk
diff -u src/share/mk/bsd.sys.mk:1.271.4.2 src/share/mk/bsd.sys.mk:1.271.4.3
--- src/share/mk/bsd.sys.mk:1.271.4.2	Thu Jun 14 20:08:36 2018
+++ src/share/mk/bsd.sys.mk	Mon Jun 18 15:42:29 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.sys.mk,v 1.271.4.2 2018/06/14 20:08:36 martin Exp $
+#	$NetBSD: bsd.sys.mk,v 1.271.4.3 2018/06/18 15:42:29 martin Exp $
 #
 # Build definitions used for NetBSD source tree builds.
 
@@ -31,6 +31,9 @@ REPROFLAGS+=	-fdebug-prefix-map=\$$NETBS
 REPROFLAGS+=	-fdebug-prefix-map=\$$X11SRCDIR=/usr/xsrc
 .if defined(MAKEOBJDIRPREFIX)
 NETBSDOBJDIR=	${MAKEOBJDIRPREFIX}${NETBSDSRCDIR}
+.endif
+
+.if defined(NETBSDOBJDIR)
 .export NETBSDOBJDIR
 REPROFLAGS+=	-fdebug-prefix-map=\$$NETBSDOBJDIR=/usr/obj
 .endif



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

2018-06-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 18 15:39:49 UTC 2018

Modified Files:
src/sys/dev/ic [netbsd-8]: dwc_gmac.c

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

sys/dev/ic/dwc_gmac.c: revision 1.47

Avoid calling bus_dmamap_sync with len=0


To generate a diff of this commit:
cvs rdiff -u -r1.40.6.3 -r1.40.6.4 src/sys/dev/ic/dwc_gmac.c

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

Modified files:

Index: src/sys/dev/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.40.6.3 src/sys/dev/ic/dwc_gmac.c:1.40.6.4
--- src/sys/dev/ic/dwc_gmac.c:1.40.6.3	Sat Jan 13 04:44:29 2018
+++ src/sys/dev/ic/dwc_gmac.c	Mon Jun 18 15:39:49 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.40.6.3 2018/01/13 04:44:29 snj Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.40.6.4 2018/06/18 15:39:49 martin Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.40.6.3 2018/01/13 04:44:29 snj Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.40.6.4 2018/06/18 15:39:49 martin Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -636,11 +636,13 @@ dwc_gmac_txdesc_sync(struct dwc_gmac_sof
 	TX_DESC_OFFSET(start),
 	TX_DESC_OFFSET(AWGE_TX_RING_COUNT)-TX_DESC_OFFSET(start),
 	ops);
-	/* sync from start of ring to 'end' */
-	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
-	TX_DESC_OFFSET(0),
-	TX_DESC_OFFSET(end)-TX_DESC_OFFSET(0),
-	ops);
+	if (TX_DESC_OFFSET(end) - TX_DESC_OFFSET(0) > 0) {
+		/* sync from start of ring to 'end' */
+		bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
+		TX_DESC_OFFSET(0),
+		TX_DESC_OFFSET(end)-TX_DESC_OFFSET(0),
+		ops);
+	}
 }
 
 static void



CVS commit: [netbsd-8] src/sys/arch/powerpc/powerpc

2018-06-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 18 15:37:46 UTC 2018

Modified Files:
src/sys/arch/powerpc/powerpc [netbsd-8]: trap.c

Log Message:
Pull up following revision(s) (requested by uwe in ticket #884):

sys/arch/powerpc/powerpc/trap.c: revision 1.154

In mtmsr emulation ignore PSL_VEC we set in mfmsr emulation just
above, as it freaks out PSL_USEROK_P().  This is also congruent with
how we handle PSL_FP.

PR port-macppc/53360


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.153.6.1 src/sys/arch/powerpc/powerpc/trap.c

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

Modified files:

Index: src/sys/arch/powerpc/powerpc/trap.c
diff -u src/sys/arch/powerpc/powerpc/trap.c:1.153 src/sys/arch/powerpc/powerpc/trap.c:1.153.6.1
--- src/sys/arch/powerpc/powerpc/trap.c:1.153	Thu Mar 16 16:13:20 2017
+++ src/sys/arch/powerpc/powerpc/trap.c	Mon Jun 18 15:37:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.153 2017/03/16 16:13:20 chs Exp $	*/
+/*	$NetBSD: trap.c,v 1.153.6.1 2018/06/18 15:37:46 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.153 2017/03/16 16:13:20 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.153.6.1 2018/06/18 15:37:46 martin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -1062,6 +1062,9 @@ emulated_opcode(struct lwp *l, struct tr
 		 * user code isn't allowed to change it.
 		 */
 		msr &= ~PSL_FP;
+#ifdef ALTIVEC
+		msr &= ~PSL_VEC;
+#endif
 
 		/*
 		 * Don't let the user muck with bits he's not allowed to.



CVS commit: src/sys

2018-06-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jun 18 15:36:54 UTC 2018

Modified Files:
src/sys/kern: subr_autoconf.c
src/sys/sys: device.h

Log Message:
Add device_compatible_match(), a generalized routine for weighted
matching of device_compatible_entry data to a device's "compatible"
strings.


To generate a diff of this commit:
cvs rdiff -u -r1.257 -r1.258 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.152 -r1.153 src/sys/sys/device.h

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

Modified files:

Index: src/sys/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.257 src/sys/kern/subr_autoconf.c:1.258
--- src/sys/kern/subr_autoconf.c:1.257	Sun Mar  4 07:12:18 2018
+++ src/sys/kern/subr_autoconf.c	Mon Jun 18 15:36:54 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.257 2018/03/04 07:12:18 mlelstv Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.258 2018/06/18 15:36:54 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.257 2018/03/04 07:12:18 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.258 2018/06/18 15:36:54 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -2275,6 +2275,69 @@ device_find_by_driver_unit(const char *n
 }
 
 /*
+ * device_compatible_entry_matches:
+ *
+ *	Helper function to determine if a device_compatible_entry
+ *	contains a match for the specified "compatible" string.
+ */
+static bool
+device_compatible_entry_matches(const struct device_compatible_entry *dce,
+const char *compatible)
+{
+	const char **cpp = DEVICE_COMPAT_ENTRY_GET_STRINGS(dce);
+
+	if (cpp == NULL)
+		return false;
+	
+	while (*cpp != NULL)
+		if (strcmp(*cpp, compatible) == 0)
+			return true;
+
+	return false;
+}
+
+/*
+ * device_compatible_match:
+ *
+ *	Match a driver's "compatible" data against a device's
+ *	"compatible" strings.  If a match is found, we return
+ *	the matching device_compatible_entry, along with a
+ *	matching weight.
+ */
+const struct device_compatible_entry *
+device_compatible_match(const char **device_compats, int ndevice_compats,
+			const struct device_compatible_entry *driver_compats,
+			int *match_weightp)
+{
+	const struct device_compatible_entry *dce = NULL;
+	int i, match_weight;
+
+	if (ndevice_compats == 0 || device_compats == NULL ||
+	driver_compats == NULL)
+		return NULL;
+	
+	/*
+	 * We take the first match because we start with the most-specific
+	 * device compatible string.
+	 */
+	for (i = 0, match_weight = ndevice_compats - 1;
+	 i < ndevice_compats;
+	 i++, match_weight--) {
+		for (dce = driver_compats;
+		 DEVICE_COMPAT_ENTRY_IS_TERMINATOR(dce) == false; dce++) {
+			if (device_compatible_entry_matches(dce,
+			 device_compats[i])) {
+KASSERT(match_weight >= 0);
+if (match_weightp)
+	*match_weightp = match_weight;
+return dce;
+			}
+		}
+	}
+	return NULL;
+}
+
+/*
  * Power management related functions.
  */
 

Index: src/sys/sys/device.h
diff -u src/sys/sys/device.h:1.152 src/sys/sys/device.h:1.153
--- src/sys/sys/device.h:1.152	Sun Jun 17 15:06:27 2018
+++ src/sys/sys/device.h	Mon Jun 18 15:36:54 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.152 2018/06/17 15:06:27 thorpej Exp $ */
+/* $NetBSD: device.h,v 1.153 2018/06/18 15:36:54 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -552,6 +552,11 @@ bool		device_is_a(device_t, const char *
 device_t	device_find_by_xname(const char *);
 device_t	device_find_by_driver_unit(const char *, int);
 
+const struct device_compatible_entry *
+		device_compatible_match(const char **, int,
+	const struct device_compatible_entry *,
+	int *);
+
 bool		device_pmf_is_registered(device_t);
 
 bool		device_pmf_driver_suspend(device_t, const pmf_qual_t *);



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

2018-06-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 18 15:34:34 UTC 2018

Modified Files:
src/sys/arch/arm/arm [netbsd-8]: psci.c
src/sys/arch/arm/fdt [netbsd-8]: psci_fdt.c

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

sys/arch/arm/fdt/psci_fdt.c: revision 1.5
sys/arch/arm/arm/psci.c: revision 1.2

Use correct value for PSCI 0.2+ PSCI_CPU_ON.

Fix PSCI 0.1 detection.


To generate a diff of this commit:
cvs rdiff -u -r1.1.4.2 -r1.1.4.3 src/sys/arch/arm/arm/psci.c
cvs rdiff -u -r1.1.4.2 -r1.1.4.3 src/sys/arch/arm/fdt/psci_fdt.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/psci.c
diff -u src/sys/arch/arm/arm/psci.c:1.1.4.2 src/sys/arch/arm/arm/psci.c:1.1.4.3
--- src/sys/arch/arm/arm/psci.c:1.1.4.2	Tue Jul 18 19:13:08 2017
+++ src/sys/arch/arm/arm/psci.c	Mon Jun 18 15:34:34 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: psci.c,v 1.1.4.2 2017/07/18 19:13:08 snj Exp $ */
+/* $NetBSD: psci.c,v 1.1.4.3 2018/06/18 15:34:34 martin Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_diagnostic.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.1.4.2 2017/07/18 19:13:08 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.1.4.3 2018/06/18 15:34:34 martin Exp $");
 
 #include 
 #include 
@@ -43,9 +43,9 @@ __KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.1
 #define	PSCI_SYSTEM_OFF		0x8408
 #define	PSCI_SYSTEM_RESET	0x8409
 #if defined(__aarch64__)
-#define	PSCI_CPU_ON		0xc402
+#define	PSCI_CPU_ON		0xc403
 #else
-#define	PSCI_CPU_ON		0x8402
+#define	PSCI_CPU_ON		0x8403
 #endif
 
 static psci_fn psci_call_fn;

Index: src/sys/arch/arm/fdt/psci_fdt.c
diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.1.4.2 src/sys/arch/arm/fdt/psci_fdt.c:1.1.4.3
--- src/sys/arch/arm/fdt/psci_fdt.c:1.1.4.2	Tue Jul 18 19:13:08 2017
+++ src/sys/arch/arm/fdt/psci_fdt.c	Mon Jun 18 15:34:34 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: psci_fdt.c,v 1.1.4.2 2017/07/18 19:13:08 snj Exp $ */
+/* $NetBSD: psci_fdt.c,v 1.1.4.3 2018/06/18 15:34:34 martin Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.1.4.2 2017/07/18 19:13:08 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.1.4.3 2018/06/18 15:34:34 martin Exp $");
 
 #include 
 #include 
@@ -102,8 +102,7 @@ psci_fdt_init(const int phandle)
 		return EINVAL;
 	}
 
-	const char * const compat_0_1[] = { "arm,psci", NULL };
-	if (of_match_compatible(phandle, compat_0_1)) {
+	if (of_match_compatible(phandle, compatible) == 1) {
 		psci_clearfunc();
 		if (of_getprop_uint32(phandle, "cpu_on", &val) == 0)
 			psci_setfunc(PSCI_FUNC_CPU_ON, val);



CVS commit: [netbsd-8] src/usr.sbin/ofctl

2018-06-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 18 15:31:49 UTC 2018

Modified Files:
src/usr.sbin/ofctl [netbsd-8]: ofctl.8

Log Message:
Pull up following revision(s) (requested by sevan in ticket #882):

usr.sbin/ofctl/ofctl.8: revision 1.6
usr.sbin/ofctl/ofctl.8: revision 1.7

Merge single-letter options. Use more markup.

Document -l, -r, and -w, based on input by jmcneill@

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.52.1 src/usr.sbin/ofctl/ofctl.8

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/ofctl/ofctl.8
diff -u src/usr.sbin/ofctl/ofctl.8:1.4 src/usr.sbin/ofctl/ofctl.8:1.4.52.1
--- src/usr.sbin/ofctl/ofctl.8:1.4	Thu Sep 25 22:44:51 2008
+++ src/usr.sbin/ofctl/ofctl.8	Mon Jun 18 15:31:49 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ofctl.8,v 1.4 2008/09/25 22:44:51 reed Exp $
+.\"	$NetBSD: ofctl.8,v 1.4.52.1 2018/06/18 15:31:49 martin Exp $
 .\"
 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 29, 2006
+.Dd June 18, 2018
 .Dt OFCTL 8
 .Os
 .Sh NAME
@@ -35,8 +35,10 @@
 .Nd display the OpenPROM or OpenFirmware device tree
 .Sh SYNOPSIS
 .Nm
-.Op Fl p
+.Op Fl lp
 .Op Fl f Ar file
+.Op Fl r Ar propfile
+.Op Fl w Ar propfile
 .Op Ar node
 .Sh DESCRIPTION
 .Nm
@@ -54,7 +56,7 @@ When given the name of a specific node,
 will display that node and its child nodes.
 .Pp
 The options are as follows:
-.Bl -tag -offset indent -width 8n
+.Bl -tag -offset indent -width 12n
 .It Fl f Ar file
 On systems with OpenPROM, use
 .Ar file
@@ -64,14 +66,29 @@ On systems with OpenFirmware, use
 .Ar file
 instead of the default
 .Pa /dev/openfirm .
+.It Fl l
+Dump a partial tree starting from
+.Ar node .
 .It Fl p
 Display each node's properties.
+.It Fl r Ar propfile
+Instead of reading from the openprom or openfirm device,
+use the proplib file
+.Ar propfile
+as input.
+See also
+.Fl w .
+.It Fl w Ar propfile
+Write the device tree to the proplib file
+.Ar propfile .
+See also
+.Fl r .
 .El
 .Sh FILES
 .Bl -tag -width "/dev/openprom "
-.It /dev/openprom
+.It Pa /dev/openprom
 The openprom device on systems with OpenPROM.
-.It /dev/openfirm
+.It Pa /dev/openfirm
 The openfirm device on systems with OpenFirmware.
 .El
 .Sh SEE ALSO



CVS commit: src/bin/ed

2018-06-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 18 14:56:24 UTC 2018

Modified Files:
src/bin/ed: main.c

Log Message:
Prevent shell execution also in the 'r ! dobad' case, pointed out by
Martijn van Duren, thanks!

XXX: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/bin/ed/main.c

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

Modified files:

Index: src/bin/ed/main.c
diff -u src/bin/ed/main.c:1.29 src/bin/ed/main.c:1.30
--- src/bin/ed/main.c:1.29	Thu Apr  5 14:44:57 2018
+++ src/bin/ed/main.c	Mon Jun 18 10:56:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.29 2018/04/05 18:44:57 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.30 2018/06/18 14:56:24 christos Exp $	*/
 
 /* main.c: This file contains the main control and user-interface routines
for the ed line editor. */
@@ -39,7 +39,7 @@ __COPYRIGHT(
 #if 0
 static char *rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp";
 #else
-__RCSID("$NetBSD: main.c,v 1.29 2018/04/05 18:44:57 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.30 2018/06/18 14:56:24 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -865,14 +865,11 @@ exec_command(void)
 		printf("%ld\n", addr_cnt ? second_addr : addr_last);
 		break;
 	case '!':
-		if (secure) {
-			seterrmsg("'!' not allowed");
-			return ERR;
-		}
 		if (addr_cnt > 0) {
 			seterrmsg("unexpected address");
 			return ERR;
-		} else if ((sflags = get_shell_command()) < 0)
+		}
+		if ((sflags = get_shell_command()) < 0)
 			return ERR;
 		GET_COMMAND_SUFFIX();
 		if (sflags) printf("%s\n", shcmd + 1);
@@ -994,7 +991,7 @@ get_shell_command(void)
 	int i = 0;
 	int j = 0;
 
-	if (red) {
+	if (red || secure) {
 		seterrmsg("shell access restricted");
 		return ERR;
 	} else if ((s = ibufp = get_extended_line(&j, 1)) == NULL)



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

2018-06-18 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jun 18 13:05:20 UTC 2018

Modified Files:
src/sys/arch/evbarm/include: bootconfig.h

Log Message:
Pull in opt_bootconfig.h for DRAM_BLOCKS


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/evbarm/include/bootconfig.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/evbarm/include/bootconfig.h
diff -u src/sys/arch/evbarm/include/bootconfig.h:1.9 src/sys/arch/evbarm/include/bootconfig.h:1.10
--- src/sys/arch/evbarm/include/bootconfig.h:1.9	Sun Apr  1 04:35:04 2018
+++ src/sys/arch/evbarm/include/bootconfig.h	Mon Jun 18 13:05:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootconfig.h,v 1.9 2018/04/01 04:35:04 ryo Exp $	*/
+/*	$NetBSD: bootconfig.h,v 1.10 2018/06/18 13:05:20 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1994 Mark Brinicombe.
@@ -41,6 +41,7 @@
 
 #ifdef _KERNEL_OPT
 #include "opt_machdep.h"
+#include "opt_bootconfig.h"
 #endif
 
 #include 



CVS commit: src/sys/dev/i2c

2018-06-18 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Jun 18 12:42:29 UTC 2018

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

Log Message:
Bail early if gttwsi_send_start() fails in gttwsi_initiate_xfer() to
avoid unexpected state error message later (on Allwinner H5).


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

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

Modified files:

Index: src/sys/dev/i2c/gttwsi_core.c
diff -u src/sys/dev/i2c/gttwsi_core.c:1.6 src/sys/dev/i2c/gttwsi_core.c:1.7
--- src/sys/dev/i2c/gttwsi_core.c:1.6	Tue Jun 12 13:18:48 2018
+++ src/sys/dev/i2c/gttwsi_core.c	Mon Jun 18 12:42:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: gttwsi_core.c,v 1.6 2018/06/12 13:18:48 thorpej Exp $	*/
+/*	$NetBSD: gttwsi_core.c,v 1.7 2018/06/18 12:42:29 jakllsch Exp $	*/
 /*
  * Copyright (c) 2008 Eiji Kawauchi.
  * All rights reserved.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gttwsi_core.c,v 1.6 2018/06/12 13:18:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gttwsi_core.c,v 1.7 2018/06/18 12:42:29 jakllsch Exp $");
 #include "locators.h"
 
 #include 
@@ -283,7 +283,9 @@ gttwsi_initiate_xfer(void *v, i2c_addr_t
 
 	KASSERT(sc->sc_inuse);
 
-	gttwsi_send_start(v, flags);
+	error = gttwsi_send_start(v, flags);
+	if (error)
+		return error;
 
 	read = (flags & I2C_F_READ) != 0;
 	if (read) {



CVS commit: src/sys/net

2018-06-18 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Jun 18 09:53:45 UTC 2018

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

Log Message:
Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/sys/net/if_pppoe.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_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.139 src/sys/net/if_pppoe.c:1.140
--- src/sys/net/if_pppoe.c:1.139	Mon Jun 18 09:49:05 2018
+++ src/sys/net/if_pppoe.c	Mon Jun 18 09:53:45 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.139 2018/06/18 09:49:05 yamaguchi Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.140 2018/06/18 09:53:45 yamaguchi Exp $ */
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.139 2018/06/18 09:49:05 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.140 2018/06/18 09:53:45 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -277,8 +277,11 @@ pppoedetach(void)
 {
 	int error = 0;
 
-	if (!LIST_EMPTY(&pppoe_softc_list))
+	rw_enter(&pppoe_softc_list_lock, RW_READER);
+	if (!LIST_EMPTY(&pppoe_softc_list)) {
+		rw_exit(&pppoe_softc_list_lock);
 		error = EBUSY;
+	}
 
 	if (error == 0) {
 		if_clone_detach(&pppoe_cloner);
@@ -338,9 +341,12 @@ pppoe_clone_create(struct if_clone *ifc,
 	sppp_attach(&sc->sc_sppp.pp_if);
 
 	bpf_attach(&sc->sc_sppp.pp_if, DLT_PPP_ETHER, 0);
+	rw_enter(&pppoe_softc_list_lock, RW_READER);
 	if (LIST_EMPTY(&pppoe_softc_list)) {
 		pfil_add_ihook(pppoe_ifattach_hook, NULL, PFIL_IFNET, if_pfil);
 	}
+	rw_exit(&pppoe_softc_list_lock);
+
 	if_register(&sc->sc_sppp.pp_if);
 
 	rw_init(&sc->sc_lock);
@@ -424,14 +430,18 @@ pppoe_find_softc_by_hunique(uint8_t *tok
 {
 	struct pppoe_softc *sc, *t;
 
-	if (LIST_EMPTY(&pppoe_softc_list))
+	rw_enter(&pppoe_softc_list_lock, RW_READER);
+	if (LIST_EMPTY(&pppoe_softc_list)) {
+		rw_exit(&pppoe_softc_list_lock);
 		return NULL;
+	}
 
-	if (len != sizeof sc)
+	if (len != sizeof sc) {
+		rw_exit(&pppoe_softc_list_lock);
 		return NULL;
+	}
 	memcpy(&t, token, len);
 
-	rw_enter(&pppoe_softc_list_lock, RW_READER);
 	LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
 		if (sc == t) {
 			PPPOE_LOCK(sc, lock);
@@ -703,9 +713,12 @@ breakbreak:;
 		 * got service name, concentrator name, and/or host unique.
 		 * ignore if we have no interfaces with IFF_PASSIVE|IFF_UP.
 		 */
-		if (LIST_EMPTY(&pppoe_softc_list))
-			goto done;
 		rw_enter(&pppoe_softc_list_lock, RW_READER);
+		if (LIST_EMPTY(&pppoe_softc_list)) {
+			rw_exit(&pppoe_softc_list_lock);
+			goto done;
+		}
+
 		LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
 			PPPOE_LOCK(sc, RW_WRITER);
 			if (!(sc->sc_sppp.pp_if.if_flags & IFF_UP)) {
@@ -768,8 +781,12 @@ breakbreak:;
 		m_put_rcvif_psref(rcvif, &psref);
 		if (sc == NULL) {
 			/* be quiet if there is not a single pppoe instance */
-			if (!LIST_EMPTY(&pppoe_softc_list))
-printf("pppoe: received PADR but could not find request for it\n");
+			rw_enter(&pppoe_softc_list_lock, RW_READER);
+			if (!LIST_EMPTY(&pppoe_softc_list)) {
+printf("pppoe: received PADR"
+" but could not find request for it\n");
+			}
+			rw_exit(&pppoe_softc_list_lock);
 			goto done;
 		}
 
@@ -818,8 +835,12 @@ breakbreak:;
 
 		if (sc == NULL) {
 			/* be quiet if there is not a single pppoe instance */
-			if (!LIST_EMPTY(&pppoe_softc_list))
-printf("pppoe: received PADO but could not find request for it\n");
+			rw_enter(&pppoe_softc_list_lock, RW_READER);
+			if (!LIST_EMPTY(&pppoe_softc_list)) {
+printf("pppoe: received PADO"
+" but could not find request for it\n");
+			}
+			rw_exit(&pppoe_softc_list_lock);
 			goto done;
 		}
 
@@ -959,9 +980,12 @@ pppoe_disc_input(struct mbuf *m)
 	/*
 	 * Avoid error messages if there is not a single PPPoE instance.
 	 */
+	rw_enter(&pppoe_softc_list_lock, RW_READER);
 	if (!LIST_EMPTY(&pppoe_softc_list)) {
+		rw_exit(&pppoe_softc_list_lock);
 		pppoe_dispatch_disc_pkt(m, 0);
 	} else {
+		rw_exit(&pppoe_softc_list_lock);
 		m_freem(m);
 	}
 }
@@ -993,9 +1017,12 @@ pppoe_data_input(struct mbuf *m)
 	/*
 	 * Avoid error messages if there is not a single PPPoE instance.
 	 */
+	rw_enter(&pppoe_softc_list_lock, RW_READER);
 	if (LIST_EMPTY(&pppoe_softc_list)) {
+		rw_exit(&pppoe_softc_list_lock);
 		goto drop;
 	}
+	rw_exit(&pppoe_softc_list_lock);
 
 	if (term_unknown) {
 		memcpy(shost, mtod(m, struct ether_header*)->ether_shost,



CVS commit: src/sys/net

2018-06-18 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Jun 18 09:49:05 UTC 2018

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

Log Message:
Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/sys/net/if_pppoe.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_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.138 src/sys/net/if_pppoe.c:1.139
--- src/sys/net/if_pppoe.c:1.138	Fri May 25 04:40:27 2018
+++ src/sys/net/if_pppoe.c	Mon Jun 18 09:49:05 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.138 2018/05/25 04:40:27 ozaki-r Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.139 2018/06/18 09:49:05 yamaguchi Exp $ */
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.138 2018/05/25 04:40:27 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.139 2018/06/18 09:49:05 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -518,15 +518,15 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, 
 	size_t ac_cookie_len;
 	uint8_t *relay_sid;
 	size_t relay_sid_len;
-#ifdef PPPOE_SERVER
 	uint8_t *hunique;
 	size_t hunique_len;
-#endif
 	struct pppoehdr *ph;
 	struct pppoetag *pt;
 	struct mbuf *n;
 	int noff, err, errortag;
 	struct ether_header *eh;
+	struct ifnet *rcvif;
+	struct psref psref;
 
 	/* as long as we don't know which instance */
 	strlcpy(devname, "pppoe", sizeof(devname));
@@ -545,10 +545,8 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, 
 	ac_cookie_len = 0;
 	relay_sid = NULL;
 	relay_sid_len = 0;
-#ifdef PPPOE_SERVER
 	hunique = NULL;
 	hunique_len = 0;
-#endif
 	session = 0;
 	if (m->m_pkthdr.len - off <= PPPOE_HEADERLEN) {
 		printf("pppoe: packet too short: %d\n", m->m_pkthdr.len);
@@ -601,8 +599,7 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, 
 		case PPPOE_TAG_SNAME:
 			break;	/* ignored */
 		case PPPOE_TAG_ACNAME:
-			error = NULL;
-			if (sc != NULL && len > 0) {
+			if (len > 0) {
 error = malloc(len + 1, M_TEMP, M_NOWAIT);
 if (error == NULL)
 	break;
@@ -616,40 +613,24 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, 
 }
 
 strlcpy(error, mtod(n, char*) + noff, len + 1);
-printf("%s: connected to %s\n", devname, error);
+printf("pppoe: connected to %s\n", error);
 free(error, M_TEMP);
 			}
 			break;	/* ignored */
-		case PPPOE_TAG_HUNIQUE: {
-			struct ifnet *rcvif;
-			struct psref psref;
+		case PPPOE_TAG_HUNIQUE:
+			if (hunique == NULL) {
+n = m_pulldown(m, off + sizeof(*pt), len,
+&noff);
+if (!n) {
+	m = NULL;
+	err_msg = "TAG HUNIQUE ERROR";
+	break;
+}
 
-			if (sc != NULL)
-break;
-			n = m_pulldown(m, off + sizeof(*pt), len, &noff);
-			if (!n) {
-m = NULL;
-err_msg = "TAG HUNIQUE ERROR";
-break;
-			}
-#ifdef PPPOE_SERVER
-			hunique = mtod(n, uint8_t *) + noff;
-			hunique_len = len;
-#endif
-			rcvif = m_get_rcvif_psref(m, &psref);
-			if (rcvif != NULL) {
-sc = pppoe_find_softc_by_hunique(
-	mtod(n, char *) + noff, len, rcvif,
-	RW_READER);
-			}
-			m_put_rcvif_psref(rcvif, &psref);
-			if (sc != NULL) {
-strlcpy(devname, sc->sc_sppp.pp_if.if_xname,
-sizeof(devname));
-PPPOE_UNLOCK(sc);
+hunique = mtod(n, uint8_t *) + noff;
+hunique_len = len;
 			}
 			break;
-		}
 		case PPPOE_TAG_ACCOOKIE:
 			if (ac_cookie == NULL) {
 n = m_pulldown(m, off + sizeof(*pt), len,
@@ -768,9 +749,6 @@ breakbreak:;
 #endif /* PPPOE_SERVER */
 	case PPPOE_CODE_PADR:
 #ifdef PPPOE_SERVER
-	{
-		struct ifnet *rcvif;
-		struct psref psref;
 		/*
 		 * get sc from ac_cookie if IFF_PASSIVE
 		 */
@@ -820,12 +798,24 @@ breakbreak:;
 
 		sc->sc_sppp.pp_up(&sc->sc_sppp);
 		break;
-	}
 #else
 		/* ignore, we are no access concentrator */
 		goto done;
 #endif /* PPPOE_SERVER */
 	case PPPOE_CODE_PADO:
+		rcvif = m_get_rcvif_psref(m, &psref);
+		if (__predict_false(rcvif == NULL))
+			goto done;
+
+		if (hunique != NULL) {
+			sc = pppoe_find_softc_by_hunique(hunique,
+			 hunique_len,
+			 rcvif,
+			 RW_WRITER);
+		}
+
+		m_put_rcvif_psref(rcvif, &psref);
+
 		if (sc == NULL) {
 			/* be quiet if there is not a single pppoe instance */
 			if (!LIST_EMPTY(&pppoe_softc_list))
@@ -833,8 +823,6 @@ breakbreak:;
 			goto done;
 		}
 
-		PPPOE_LOCK(sc, RW_W

CVS commit: src/sys/dev/mii

2018-06-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jun 18 09:12:17 UTC 2018

Modified Files:
src/sys/dev/mii: e1000phyreg.h makphy.c

Log Message:
- All of Marvell PHY's registers from addr 0x0 to 0xf conforms IEEE 802.3
 specification, so those register definitions are not required. Use mii.h's
 definitions. Note that E1000_ER_PAR_DETECT_FAULT should be 0x0010 instead of
 0x0100(typo).
- Restore code for BMCR_ISO which was removed in makphy.c rev. 1.44
- Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/mii/e1000phyreg.h
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/mii/makphy.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/mii/e1000phyreg.h
diff -u src/sys/dev/mii/e1000phyreg.h:1.1 src/sys/dev/mii/e1000phyreg.h:1.2
--- src/sys/dev/mii/e1000phyreg.h:1.1	Sat Jun 16 17:44:53 2018
+++ src/sys/dev/mii/e1000phyreg.h	Mon Jun 18 09:12:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: e1000phyreg.h,v 1.1 2018/06/16 17:44:53 jdolecek Exp $	*/
+/*	$NetBSD: e1000phyreg.h,v 1.2 2018/06/18 09:12:17 msaitoh Exp $	*/
 /* $FreeBSD: head/sys/dev/mii/e1000phyreg.h 326022 2017-11-20 19:36:21Z pfg $ */
 /*-
  * Principal Author: Parag Patel
@@ -73,147 +73,12 @@
 
 #define E1000_MAX_REG_ADDRESS		0x1F
 
-#define E1000_CR			0x00	/* control register */
-#define E1000_CR_SPEED_SELECT_MSB	0x0040
-#define E1000_CR_COLL_TEST_ENABLE	0x0080
-#define E1000_CR_FULL_DUPLEX		0x0100
-#define E1000_CR_RESTART_AUTO_NEG	0x0200
-#define E1000_CR_ISOLATE		0x0400
-#define E1000_CR_POWER_DOWN		0x0800
-#define E1000_CR_AUTO_NEG_ENABLE	0x1000
-#define E1000_CR_SPEED_SELECT_LSB	0x2000
-#define E1000_CR_LOOPBACK		0x4000
-#define E1000_CR_RESET			0x8000
-
-#define E1000_CR_SPEED_1000		0x0040
-#define E1000_CR_SPEED_100		0x2000
-#define E1000_CR_SPEED_10		0x
-
-#define E1000_SR			0x01	/* status register */
-#define E1000_SR_EXTENDED		0x0001
-#define E1000_SR_JABBER_DETECT		0x0002
-#define E1000_SR_LINK_STATUS		0x0004
-#define E1000_SR_AUTO_NEG		0x0008
-#define E1000_SR_REMOTE_FAULT		0x0010
-#define E1000_SR_AUTO_NEG_COMPLETE	0x0020
-#define E1000_SR_PREAMBLE_SUPPRESS	0x0040
-#define E1000_SR_EXTENDED_STATUS	0x0100
-#define E1000_SR_100T2			0x0200
-#define E1000_SR_100T2_FD		0x0400
-#define E1000_SR_10T			0x0800
-#define E1000_SR_10T_FD			0x1000
-#define E1000_SR_100TX			0x2000
-#define E1000_SR_100TX_FD		0x4000
-#define E1000_SR_100T4			0x8000
-
-#define E1000_ID1			0x02	/* ID register 1 */
-#define E1000_ID2			0x03	/* ID register 2 */
-#define E1000_ID_88E1000		0x01410C50
-#define E1000_ID_88E1000S		0x01410C40
-#define E1000_ID_88E1011		0x01410C20
-#define E1000_ID_MASK			0xFFF0
-
-#define E1000_AR			0x04	/* autonegotiation advertise reg */
-#define E1000_AR_SELECTOR_FIELD		0x0001
-#define E1000_AR_10T			0x0020
-#define E1000_AR_10T_FD			0x0040
-#define E1000_AR_100TX			0x0080
-#define E1000_AR_100TX_FD		0x0100
-#define E1000_AR_100T4			0x0200
-#define E1000_AR_PAUSE			0x0400
-#define E1000_AR_ASM_DIR		0x0800
-#define E1000_AR_REMOTE_FAULT		0x2000
-#define E1000_AR_NEXT_PAGE		0x8000
-#define E1000_AR_SPEED_MASK		0x01E0
-
-/* Autonegotiation register bits for fiber cards (Alaska Only!) */
-#define E1000_FA_1000X_FD		0x0020
-#define E1000_FA_1000X			0x0040
-#define E1000_FA_SYM_PAUSE		0x0080
-#define E1000_FA_ASYM_PAUSE		0x0100
-#define E1000_FA_FAULT1			0x1000
-#define E1000_FA_FAULT2			0x2000
-#define E1000_FA_NEXT_PAGE		0x8000
-
-#define E1000_LPAR			0x05	/* autoneg link partner abilities reg */
-#define E1000_LPAR_SELECTOR_FIELD	0x0001
-#define E1000_LPAR_10T			0x0020
-#define E1000_LPAR_10T_FD		0x0040
-#define E1000_LPAR_100TX		0x0080
-#define E1000_LPAR_100TX_FD		0x0100
-#define E1000_LPAR_100T4		0x0200
-#define E1000_LPAR_PAUSE		0x0400
-#define E1000_LPAR_ASM_DIR		0x0800
-#define E1000_LPAR_REMOTE_FAULT		0x2000
-#define E1000_LPAR_ACKNOWLEDGE		0x4000
-#define E1000_LPAR_NEXT_PAGE		0x8000
-
-/* autoneg link partner ability register bits for fiber cards (Alaska Only!) */
-#define E1000_FPAR_1000X_FD		0x0020
-#define E1000_FPAR_1000X		0x0040
-#define E1000_FPAR_SYM_PAUSE		0x0080
-#define E1000_FPAR_ASYM_PAUSE		0x0100
-#define E1000_FPAR_FAULT1		0x1000
-#define E1000_FPAR_FAULT2		0x2000
-#define E1000_FPAR_ACK			0x4000
-#define E1000_FPAR_NEXT_PAGE		0x8000
-
-#define E1000_ER			0x06	/* autoneg expansion reg */
-#define E1000_ER_LP_NWAY		0x0001
-#define E1000_ER_PAGE_RXD		0x0002
-#define E1000_ER_NEXT_PAGE		0x0004
-#define E1000_ER_LP_NEXT_PAGE		0x0008
-#define E1000_ER_PAR_DETECT_FAULT	0x0100
-
-#define E1000_NPTX			0x07	/* autoneg next page TX */
-#define E1000_NPTX_MSG_CODE_FIELD	0x0001
-#define E1000_NPTX_TOGGLE		0x0800
-#define E1000_NPTX_ACKNOWLDGE2		0x1000
-#define E1000_NPTX_MSG_PAGE		0x2000
-#define E1000_NPTX_NEXT_PAGE		0x8000
-
-#define E1000_RNPR			0x08	/* autoneg link-partner (?) next page */
-#define E1000_RNPR_MSG_CODE_FIELD	0x0001
-#define E1000_RNPR_TOGGLE		0x0800
-#define E1000_RNPR_A

CVS commit: src/sys/dev/mii

2018-06-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jun 18 09:11:03 UTC 2018

Modified Files:
src/sys/dev/mii: mii.h

Log Message:
- Rename ENP (Extended Next Page) to XNP.
- Add ANLPAR_XNP bit.
- Add definitions for RF1 and RF2 (for 1000BASE-X) .
- Rename MII_ANNP (Autonegotiation next page transmit) register to MII_ANNPT.
- Add bit definitions for MII_ANNPT and MII_ANLPRNP.
- Remove GTSR_LP_ASM_DIR bit. This is not described in the 802.3 spec now and
  no any NetBSD drivers use the definition.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/mii/mii.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/mii/mii.h
diff -u src/sys/dev/mii/mii.h:1.22 src/sys/dev/mii/mii.h:1.23
--- src/sys/dev/mii/mii.h:1.22	Wed Jun  7 03:21:31 2017
+++ src/sys/dev/mii/mii.h	Mon Jun 18 09:11:03 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mii.h,v 1.22 2017/06/07 03:21:31 msaitoh Exp $	*/
+/*	$NetBSD: mii.h,v 1.23 2018/06/18 09:11:03 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Manuel Bouyer.  All rights reserved.
@@ -111,7 +111,7 @@
 #define ANAR_NP		0x8000	/* Next page (ro) */
 #define	ANAR_ACK	0x4000	/* link partner abilities acknowledged (ro) */
 #define ANAR_RF		0x2000	/* remote fault (ro) */
-#define ANAR_ENP	0x1000	/* Extended Next Page */
+#define ANAR_XNP	0x1000	/* Extended Next Page */
 		/* Annex 28B.2 */
 #define	ANAR_FC		0x0400	/* local device supports PAUSE */
 #define ANAR_T4		0x0200	/* local device supports 100bT4 */
@@ -132,12 +132,21 @@
 #define	ANAR_X_PAUSE_SYM	(1 << 7)
 #define	ANAR_X_PAUSE_ASYM	(2 << 7)
 #define	ANAR_X_PAUSE_TOWARDS	(3 << 7)
+	/* 37.2.1.5 Remore Fault */
+#define	ANAR_X_RF1	0x1000
+#define	ANAR_X_RF2	0x2000
+#define ANAR_X_RF_MASK		(ANAR_X_RF1 | ANAR_X_RF2)
+#define ANAR_X_RF_NONE		(0 << 12)
+#define ANAR_X_RF_OFFLINE	(1 << 12)
+#define ANAR_X_RF_LINKFAIL	(2 << 12)
+#define ANAR_X_RF_ANEGERR	(3 << 12)
 
 #define	MII_ANLPAR	0x05	/* ANEG Link Partner Base Page abilities (rw)*/
 		/* section 28.2.4.1 and 37.2.6.1 */
 #define ANLPAR_NP	0x8000	/* Next page (ro) */
 #define	ANLPAR_ACK	0x4000	/* link partner accepted ACK (ro) */
 #define ANLPAR_RF	0x2000	/* remote fault (ro) */
+#define ANLPAR_XNP	0x1000	/* Extended Next Page */
 #define	ANLPAR_FC	0x0400	/* link partner supports PAUSE */
 #define ANLPAR_T4	0x0200	/* link partner supports 100bT4 */
 #define ANLPAR_TX_FD	0x0100	/* link partner supports 100bTx FD */
@@ -158,6 +167,14 @@
 #define	ANLPAR_X_PAUSE_SYM	(1 << 7)
 #define	ANLPAR_X_PAUSE_ASYM	(2 << 7)
 #define	ANLPAR_X_PAUSE_TOWARDS	(3 << 7)
+	/* 37.2.1.5 Remore Fault */
+#define	ANLPAR_X_RF1	0x1000
+#define	ANLPAR_X_RF2	0x2000
+#define	ANLPAR_X_RF_MASK	(ANLPAR_X_RF1 | ANLPAR_X_RF2)
+#define ANLPAR_X_RF_NONE	(0 << 12)
+#define ANLPAR_X_RF_OFFLINE	(1 << 12)
+#define ANLPAR_X_RF_LINKFAIL	(2 << 12)
+#define ANLPAR_X_RF_ANEGERR	(3 << 12)
 
 #define	MII_ANER	0x06	/* Autonegotiation expansion (ro) */
 		/* section 28.2.4.1 and 37.2.6.1 */
@@ -169,11 +186,36 @@
 #define ANER_PAGE_RX	0x0002	/* Page received */
 #define ANER_LPAN	0x0001	/* link partner autoneg-able */
 
-#define	MII_ANNP	0x07	/* Autonegotiation next page (rw) */
+#define	MII_ANNPT	0x07	/* Autonegotiation next page transmit (rw) */
 		/* section 28.2.4.1 and 37.2.6.1 */
+#define ANNPT_NP	0x8000	/* Next Page */
+#define ANNPT_MP	0x2000	/* Message Page */
+#define ANNPT_ACK2	0x1000	/* Acknowledge 2 */
+#define ANNPT_TOGGLE	0x0800	/* Toggle */
+#define ANNPT_MSGUNF_MASK 0x07ff /* Message(Annex28C)/Unformatted Code Field */
+
+/* Next Page Message Code used in ANNPT and ANLPRNP */
+#define ANNP_MSG_NULL		1/* Null Message */
+#define ANNP_MSG_1UP_TAF	2/* 1Up w/ Tech. Ability Field follows */
+#define ANNP_MSG_2UP_TAF	3/* 2Up w/ Tech. Ability Field follows */
+#define ANNP_MSG_1UP_BCRF	4/* 1Up w/ Bin. coded Remote Flt follows */
+#define ANNP_MSG_OUIDTMSG	5/* OUI tagged Message */
+#define ANNP_MSG_PHYIDTC	6/* PHY Identifier Tag Code */
+#define ANNP_MSG_TMC_100T2	7/* 100BASE-T2 Tech. Message Code */
+#define ANNP_MSG_TMC_1000T	8/* 1000BASE-T Tech. Message Code */
+#define ANNP_MSG_TMC_10G1G	9/* 10GBASE-T/1000BASE-T TMC: (XNP) */
+#define ANNP_MSG_TMC_EEE	10   /* EEE Technology Message Code */
+#define ANNP_MSG_OUIDTM_XNP	11   /* OUI tagged Message (XNP) */
+
 
 #define	MII_ANLPRNP	0x08	/* Autonegotiation link partner rx next page */
 		/* section 32.5.1 and 37.2.6.1 */
+#define ANLPRNP_NP	0x8000	/* Next Page */
+#define ANLPRNP_ACK	0x4000	/* Acknowledge */
+#define ANLPRNP_MP	0x2000	/* Message Page */
+#define ANLPRNP_ACK2	0x1000	/* Acknowledge 2 */
+#define ANLPRNP_TOGGLE	0x0800	/* Toggle */
+#define ANLPRNP_MSGUNF_MASK 0x07ff /* Message(Anx28C)/Unformatted Code Field */
 
 			/* This is also the 1000baseT control register */
 #define	MII_100T2CR	0x09	/* 100base-T2 control register */
@@ -192,7 +234,6 @@
 #define	GTSR_RRS	0x1000	/* remote rx status, 1 = ok */
 #define	GT