CVS commit: src/sys/dev/i2c

2018-06-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jun 17 01:08:15 UTC 2018

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

Log Message:
Oops, another one.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/am2315.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/am2315.c
diff -u src/sys/dev/i2c/am2315.c:1.4 src/sys/dev/i2c/am2315.c:1.5
--- src/sys/dev/i2c/am2315.c:1.4	Sun Jun 17 01:07:06 2018
+++ src/sys/dev/i2c/am2315.c	Sun Jun 17 01:08:15 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: am2315.c,v 1.4 2018/06/17 01:07:06 thorpej Exp $	*/
+/*	$NetBSD: am2315.c,v 1.5 2018/06/17 01:08:15 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2017 Brad Spencer 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: am2315.c,v 1.4 2018/06/17 01:07:06 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am2315.c,v 1.5 2018/06/17 01:08:15 thorpej Exp $");
 
 /*
  * Driver for the Aosong AM2315
@@ -171,7 +171,6 @@ static int
 am2315_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
-	int rv;
 	int match_result;
 
 	if (iic_use_direct_match(ia, match, NULL, _result))



CVS commit: src/sys/dev/i2c

2018-06-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jun 17 01:07:06 UTC 2018

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

Log Message:
Remove now-unused variable.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/am2315.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/am2315.c
diff -u src/sys/dev/i2c/am2315.c:1.3 src/sys/dev/i2c/am2315.c:1.4
--- src/sys/dev/i2c/am2315.c:1.3	Sat Jun 16 21:22:13 2018
+++ src/sys/dev/i2c/am2315.c	Sun Jun 17 01:07:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: am2315.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $	*/
+/*	$NetBSD: am2315.c,v 1.4 2018/06/17 01:07:06 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2017 Brad Spencer 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: am2315.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am2315.c,v 1.4 2018/06/17 01:07:06 thorpej Exp $");
 
 /*
  * Driver for the Aosong AM2315
@@ -172,7 +172,6 @@ am2315_match(device_t parent, cfdata_t m
 {
 	struct i2c_attach_args *ia = aux;
 	int rv;
-	const bool matchdebug = false;
 	int match_result;
 
 	if (iic_use_direct_match(ia, match, NULL, _result))



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

2018-06-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jun 17 00:33:06 UTC 2018

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

Log Message:
Enable gpio reset logic


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_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/arch/arm/rockchip/rk_gmac.c
diff -u src/sys/arch/arm/rockchip/rk_gmac.c:1.1 src/sys/arch/arm/rockchip/rk_gmac.c:1.2
--- src/sys/arch/arm/rockchip/rk_gmac.c:1.1	Sat Jun 16 00:19:04 2018
+++ src/sys/arch/arm/rockchip/rk_gmac.c	Sun Jun 17 00:33:05 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_gmac.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $ */
+/* $NetBSD: rk_gmac.c,v 1.2 2018/06/17 00:33:05 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: rk_gmac.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_gmac.c,v 1.2 2018/06/17 00:33:05 jmcneill Exp $");
 
 #include 
 #include 
@@ -79,11 +79,10 @@ struct rk_gmac_softc {
 static int
 rk_gmac_reset(const int phandle)
 {
-#if notyet
 	struct fdtbus_gpio_pin *pin_reset;
 	const u_int *reset_delay_us;
 	bool reset_active_low;
-	int len, val;
+	int len;
 
 	if (!of_hasprop(phandle, "snps,reset-gpio"))
 		return 0;
@@ -98,18 +97,12 @@ rk_gmac_reset(const int phandle)
 
 	reset_active_low = of_hasprop(phandle, "snps,reset-active-low");
 
-	val = reset_active_low ? 1 : 0;
-
-	fdtbus_gpio_write(pin_reset, val);
-	if (be32toh(reset_delay_us[0]) > 0)
-		delay(be32toh(reset_delay_us[0]));
-	fdtbus_gpio_write(pin_reset, !val);
-	if (be32toh(reset_delay_us[1]) > 0)
-		delay(be32toh(reset_delay_us[1]));
-	fdtbus_gpio_write(pin_reset, val);
-	if (be32toh(reset_delay_us[2]) > 0)
-		delay(be32toh(reset_delay_us[2]));
-#endif
+	fdtbus_gpio_write_raw(pin_reset, reset_active_low ? 1 : 0);
+	delay(be32toh(reset_delay_us[0]));
+	fdtbus_gpio_write_raw(pin_reset, reset_active_low ? 0 : 1);
+	delay(be32toh(reset_delay_us[1]));
+	fdtbus_gpio_write_raw(pin_reset, reset_active_low ? 1 : 0);
+	delay(be32toh(reset_delay_us[2]));
 
 	return 0;
 }



CVS commit: src/sys/dev/fdt

2018-06-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 16 23:44:26 UTC 2018

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

Log Message:
Match generic snps,dwc2 compat string


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/fdt/dwc2_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/dev/fdt/dwc2_fdt.c
diff -u src/sys/dev/fdt/dwc2_fdt.c:1.1 src/sys/dev/fdt/dwc2_fdt.c:1.2
--- src/sys/dev/fdt/dwc2_fdt.c:1.1	Sat Jun 16 00:19:04 2018
+++ src/sys/dev/fdt/dwc2_fdt.c	Sat Jun 16 23:44:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2_fdt.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $	*/
+/*	$NetBSD: dwc2_fdt.c,v 1.2 2018/06/16 23:44:26 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwc2_fdt.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2_fdt.c,v 1.2 2018/06/16 23:44:26 jmcneill Exp $");
 
 #include 
 #include 
@@ -76,8 +76,12 @@ static const struct dwc2_fdt_config dwc2
 	.params = dwc2_fdt_rockchip_params,
 };
 
+static const struct dwc2_fdt_config dwc2_fdt_generic_config = {
+};
+
 static const struct of_compat_data compat_data[] = {
 	{ "rockchip,rk3066-usb",	(uintptr_t)_fdt_rk3066_config },
+	{ "snps,dwc2",			(uintptr_t)_fdt_generic_config },
 	{ NULL }
 };
 



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

2018-06-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 16 23:14:47 UTC 2018

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

Log Message:
Replace register numbers with defines, fixing a bunch of typos in the process.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk3328_cru.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/rk3328_cru.c
diff -u src/sys/arch/arm/rockchip/rk3328_cru.c:1.1 src/sys/arch/arm/rockchip/rk3328_cru.c:1.2
--- src/sys/arch/arm/rockchip/rk3328_cru.c:1.1	Sat Jun 16 00:19:04 2018
+++ src/sys/arch/arm/rockchip/rk3328_cru.c	Sat Jun 16 23:14:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3328_cru.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $ */
+/* $NetBSD: rk3328_cru.c,v 1.2 2018/06/16 23:14:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3328_cru.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3328_cru.c,v 1.2 2018/06/16 23:14:47 jmcneill Exp $");
 
 #include 
 #include 
@@ -40,6 +40,14 @@ __KERNEL_RCSID(1, "$NetBSD: rk3328_cru.c
 #include 
 #include 
 
+#define	PLL_CON(n)	(0x + (n) * 4)
+#define	MISC_CON	0x0084	
+#define	CLKSEL_CON(n)	(0x0100 + (n) * 4)
+#define	CLKGATE_CON(n)	(0x0200 + (n) * 4)
+
+#define	GRF_SOC_CON4	0x0410
+#define	GRF_MAC_CON1	0x0904
+
 static int rk3328_cru_match(device_t, cfdata_t, void *);
 static void rk3328_cru_attach(device_t, device_t, void *);
 
@@ -126,9 +134,11 @@ static const struct rk_cru_arm_rate armc
 static const char * armclk_parents[] = { "apll", "gpll", "dpll", "npll" };
 static const char * aclk_bus_pre_parents[] = { "cpll", "gpll", "hdmiphy" };
 static const char * hclk_bus_pre_parents[] = { "aclk_bus_pre" };
-static const char * aclk_peri_pre_parents[] = { "cpll", "gpll", "hdmiphy" };
+static const char * pclk_bus_pre_parents[] = { "aclk_bus_pre" };
+static const char * aclk_peri_pre_parents[] = { "cpll", "gpll", "hdmiphy_peri" };
 static const char * mmc_parents[] = { "cpll", "gpll", "xin24m", "usb480m" };
 static const char * phclk_peri_parents[] = { "aclk_peri_pre" };
+static const char * mux_hdmiphy_parents[] = { "hdmi_phy", "xin24m" };
 static const char * mux_usb480m_parents[] = { "usb480m_phy", "xin24m" };
 static const char * mux_uart0_parents[] = { "clk_uart0_div", "clk_uart0_frac", "xin24m" };
 static const char * mux_uart1_parents[] = { "clk_uart1_div", "clk_uart1_frac", "xin24m" };
@@ -142,192 +152,197 @@ static const char * pclk_gmac_parents[] 
 
 static struct rk_cru_clk rk3328_cru_clks[] = {
 	RK_PLL(RK3328_PLL_APLL, "apll", "xin24m",
-	   0x,			/* con_base */
+	   PLL_CON(0),		/* con_base */
 	   0x80,			/* mode_reg */
 	   __BIT(0),		/* mode_mask */
 	   __BIT(4),		/* lock_mask */
 	   pll_frac_rates),
 	RK_PLL(RK3328_PLL_DPLL, "dpll", "xin24m",
-	   0x0020,			/* con_base */
+	   PLL_CON(8),		/* con_base */
 	   0x80,			/* mode_reg */
 	   __BIT(4),		/* mode_mask */
 	   __BIT(3),		/* lock_mask */
 	   pll_norates),
 	RK_PLL(RK3328_PLL_CPLL, "cpll", "xin24m",
-	   0x0040,			/* con_base */
+	   PLL_CON(16),		/* con_base */
 	   0x80,			/* mode_reg */
 	   __BIT(8),		/* mode_mask */
 	   __BIT(2),		/* lock_mask */
 	   pll_rates),
 	RK_PLL(RK3328_PLL_GPLL, "gpll", "xin24m",
-	   0x0060,			/* con_base */
+	   PLL_CON(24),		/* con_base */
 	   0x80,			/* mode_reg */
 	   __BIT(12),		/* mode_mask */
 	   __BIT(1),		/* lock_mask */
 	   pll_frac_rates),
 	RK_PLL(RK3328_PLL_NPLL, "npll", "xin24m",
-	   0x00a0,			/* con_base */
+	   PLL_CON(40),		/* con_base */
 	   0x80,			/* mode_reg */
 	   __BIT(1),		/* mode_mask */
 	   __BIT(0),		/* lock_mask */
 	   pll_rates),
 
 	RK_ARM(RK3328_ARMCLK, "armclk", armclk_parents,
-	   0x0100,			/* reg */
-	   __BITS(7,6), 3, 0,	/* mux_mask, mux_main, mux_alt */
+	   CLKSEL_CON(0),		/* reg */
+	   __BITS(7,6), 3, 1,	/* mux_mask, mux_main, mux_alt */
 	   __BITS(4,0),		/* div_mask */
 	   armclk_rates),
 
 	RK_COMPOSITE(RK3328_ACLK_BUS_PRE, "aclk_bus_pre", aclk_bus_pre_parents,
-		 0x0100,		/* muxdiv_reg */
+		 CLKSEL_CON(0),	/* muxdiv_reg */
 		 __BITS(14,13),	/* mux_mask */
 		 __BITS(12,8),	/* div_mask */
-		 0x0220,		/* gate_reg */
+		 CLKGATE_CON(8),	/* gate_reg */
 		 __BIT(0),		/* gate_mask */
 		 0),
 	RK_COMPOSITE(RK3328_HCLK_BUS_PRE, "hclk_bus_pre", hclk_bus_pre_parents,
-		 0x0104,		/* muxdiv_reg */
+		 CLKSEL_CON(1),	/* muxdiv_reg */
 		 0,			/* mux_mask */
 		 __BITS(9,8),	/* div_mask */
-		 0x0220,		/* gate_reg */
+		 CLKGATE_CON(8),	/* gate_reg */
 		 __BIT(1),		/* gate_mask */
 		 0),
-	RK_COMPOSITE(RK3328_PCLK_BUS_PRE, "pclk_bus_pre", hclk_bus_pre_parents,
-		 0x0104,		/* muxdiv_reg */

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

2018-06-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 16 23:13:29 UTC 2018

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

Log Message:
Remove unused defines


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_iomux.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_iomux.c
diff -u src/sys/arch/arm/rockchip/rk_iomux.c:1.1 src/sys/arch/arm/rockchip/rk_iomux.c:1.2
--- src/sys/arch/arm/rockchip/rk_iomux.c:1.1	Sat Jun 16 00:19:04 2018
+++ src/sys/arch/arm/rockchip/rk_iomux.c	Sat Jun 16 23:13:29 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_iomux.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $ */
+/* $NetBSD: rk_iomux.c,v 1.2 2018/06/16 23:13:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_iomux.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_iomux.c,v 1.2 2018/06/16 23:13:29 jmcneill Exp $");
 
 #include 
 #include 
@@ -40,11 +40,6 @@ __KERNEL_RCSID(0, "$NetBSD: rk_iomux.c,v
 
 #include 
 
-#define	GRF_GPIO_IOMUX_REG(_bank, _idx)	(0x + (_bank) * 0x10 + ((_idx) >> 3) * 4)
-#define	 GRF_GPIO_IOMUX_SEL(_idx)	(0x3 << (((_idx) & 7) * 2))
-#define	  GRF_GPIO_IOMUX_SEL_MASK	0x3
-#define	 GRF_GPIO_IOMUX_WRITE_EN(_idx)	(0x3 << (((_idx) & 7) * 2 + 16))
-
 #define	GRF_GPIO_P_REG(_bank, _idx)	(0x0100 + (_bank) * 0x10 + ((_idx) >> 3) * 4)
 #define	 GRF_GPIO_P_CTL(_idx)		(0x3 << (((_idx) & 7) * 2))
 #define	  GRF_GPIO_P_CTL_Z		0



CVS commit: src/sys/dev/i2c

2018-06-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jun 16 21:24:36 UTC 2018

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

Log Message:
More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
  all of the logic for direct-config matching.  If it returns true,
  the driver returns the match result (which may be 0).  If it returns
  false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
  lower-indexed "compatible" device property are more-specific matches,
  and return a better match quality accordingly.

XXX This driver is an odd-ball with respect to the hardware device.
See comments in the match routine.  Unclear how best to handle it.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/hytp14.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/hytp14.c
diff -u src/sys/dev/i2c/hytp14.c:1.7 src/sys/dev/i2c/hytp14.c:1.8
--- src/sys/dev/i2c/hytp14.c:1.7	Sun Jul  3 12:26:55 2016
+++ src/sys/dev/i2c/hytp14.c	Sat Jun 16 21:24:36 2018
@@ -37,7 +37,7 @@
  */ 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hytp14.c,v 1.7 2016/07/03 12:26:55 kardel Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hytp14.c,v 1.8 2018/06/16 21:24:36 thorpej Exp $");
 
 #include 
 #include 
@@ -98,19 +98,25 @@ static struct hytp14_sensor hytp14_senso
 static int
 hytp14_match(device_t parent, cfdata_t match, void *aux)
 {
-	struct i2c_attach_args *ia;
+	struct i2c_attach_args *ia = aux;
+	int match_result;
 
-	ia = aux;
+	if (iic_use_direct_match(ia, match, NULL, _result))
+		return match_result;
 
-	if (ia->ia_name) {
-		/* direct config - check name */
-		if (strcmp(ia->ia_name, "hythygtemp") == 0)
-			return 1;
-	} else {
-		/* indirect config - check for configured address */
-		if ((ia->ia_addr > 0) && (ia->ia_addr <= 0x7F))
-			return 1;
-	}
+	if (ia->ia_addr == 0x28)
+		return I2C_MATCH_ADDRESS_ONLY;
+	
+	/*
+	 * XXXJRT
+	 * This device is an odd-ball; the i2c address can be changed
+	 * at run-time using a command sequence documented in the
+	 * application note, but the timing is critical (within 10ms
+	 * after power-on of the device), and the device always starts
+	 * up at address 0x28.
+	 *
+	 * How should we handle this?
+	 */
 	return 0;
 }
 



CVS commit: src/sys/dev/i2c

2018-06-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jun 16 21:28:07 UTC 2018

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

Log Message:
More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
  all of the logic for direct-config matching.  If it returns true,
  the driver returns the match result (which may be 0).  If it returns
  false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
  lower-indexed "compatible" device property are more-specific matches,
  and return a better match quality accordingly.

In addition to the above:
- Add support for direct-config matching this driver based on
  "compatible" properties.
- Address-only matching is now done based on the specific addresses
  the requested model supports.
- "compatible" property can specify to the driver which model is to
  be used, so that using config "flags" directives aren't required
  in the direct-config case.

XXX More changes coming that require re-factoring some other code.


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

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

Modified files:

Index: src/sys/dev/i2c/ds1307.c
diff -u src/sys/dev/i2c/ds1307.c:1.25 src/sys/dev/i2c/ds1307.c:1.26
--- src/sys/dev/i2c/ds1307.c:1.25	Sat Oct 28 04:53:55 2017
+++ src/sys/dev/i2c/ds1307.c	Sat Jun 16 21:28:07 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ds1307.c,v 1.25 2017/10/28 04:53:55 riastradh Exp $	*/
+/*	$NetBSD: ds1307.c,v 1.26 2018/06/16 21:28:07 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.25 2017/10/28 04:53:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.26 2018/06/16 21:28:07 thorpej Exp $");
 
 #include 
 #include 
@@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1
 #include "ioconf.h"
 
 struct dsrtc_model {
+	const char **dm_compats;
+	const i2c_addr_t *dm_valid_addrs;
 	uint16_t dm_model;
 	uint8_t dm_ch_reg;
 	uint8_t dm_ch_value;
@@ -74,8 +76,23 @@ struct dsrtc_model {
 #define	DSRTC_FLAG_CLOCK_HOLD_REVERSED	0x20
 };
 
+static const char *ds1307_compats[] = { "dallas,ds1307", "maxim,ds1307", NULL };
+static const char *ds1339_compats[] = { "dallas,ds1339", "maxim,ds1339", NULL };
+static const char *ds1340_compats[] = { "dallas,ds1340", "maxim,ds1340", NULL };
+static const char *ds1672_compats[] = { "dallas,ds1672", "maxim,ds1672", NULL };
+static const char *ds3231_compats[] = { "dallas,ds3231", "maxim,ds3231", NULL };
+static const char *ds3232_compats[] = { "dallas,ds3232", "maxim,ds3232", NULL };
+
+/* XXX vendor prefix */
+static const char *mcp7940_compats[] = { "microchip,mcp7940", NULL };
+
+static const i2c_addr_t ds1307_valid_addrs[] = { DS1307_ADDR, 0 };
+static const i2c_addr_t mcp7940_valid_addrs[] = { MCP7940_ADDR, 0 };
+
 static const struct dsrtc_model dsrtc_models[] = {
 	{
+		.dm_compats = ds1307_compats,
+		.dm_valid_addrs = ds1307_valid_addrs,
 		.dm_model = 1307,
 		.dm_ch_reg = DS_SECONDS,
 		.dm_ch_value = DS1307_SECONDS_CH,
@@ -85,11 +102,15 @@ static const struct dsrtc_model dsrtc_mo
 		.dm_nvram_size = DS1307_NVRAM_SIZE,
 		.dm_flags = DSRTC_FLAG_BCD | DSRTC_FLAG_CLOCK_HOLD,
 	}, {
+		.dm_compats = ds1339_compats,
+		.dm_valid_addrs = ds1307_valid_addrs,
 		.dm_model = 1339,
 		.dm_rtc_start = DS1339_RTC_START,
 		.dm_rtc_size = DS1339_RTC_SIZE,
 		.dm_flags = DSRTC_FLAG_BCD,
 	}, {
+		.dm_compats = ds1340_compats,
+		.dm_valid_addrs = ds1307_valid_addrs,
 		.dm_model = 1340,
 		.dm_ch_reg = DS_SECONDS,
 		.dm_ch_value = DS1340_SECONDS_EOSC,
@@ -97,6 +118,8 @@ static const struct dsrtc_model dsrtc_mo
 		.dm_rtc_size = DS1340_RTC_SIZE,
 		.dm_flags = DSRTC_FLAG_BCD,
 	}, {
+		.dm_compats = ds1672_compats,
+		.dm_valid_addrs = ds1307_valid_addrs,
 		.dm_model = 1672,
 		.dm_rtc_start = DS1672_RTC_START,
 		.dm_rtc_size = DS1672_RTC_SIZE,
@@ -104,6 +127,8 @@ static const struct dsrtc_model dsrtc_mo
 		.dm_ch_value = DS1672_CONTROL_CH,
 		.dm_flags = 0,
 	}, {
+		.dm_compats = ds3231_compats,
+		.dm_valid_addrs = ds1307_valid_addrs,
 		.dm_model = 3231,
 		.dm_rtc_start = DS3232_RTC_START,
 		.dm_rtc_size = DS3232_RTC_SIZE,
@@ -114,6 +139,8 @@ static const struct dsrtc_model dsrtc_mo
 		 */
 		.dm_flags = DSRTC_FLAG_BCD | DSRTC_FLAG_TEMP,
 	}, {
+		.dm_compats = ds3232_compats,
+		.dm_valid_addrs = ds1307_valid_addrs,
 		.dm_model = 3232,
 		.dm_rtc_start = DS3232_RTC_START,
 		.dm_rtc_size = DS3232_RTC_SIZE,
@@ -122,6 +149,8 @@ static const struct dsrtc_model dsrtc_mo
 		.dm_flags = DSRTC_FLAG_BCD,
 	}, {
 		/* MCP7940 */
+		.dm_compats = mcp7940_compats,
+		.dm_valid_addrs = mcp7940_valid_addrs,
 		.dm_model = 7940,
 		.dm_rtc_start = DS1307_RTC_START,
 		.dm_rtc_size = DS1307_RTC_SIZE,
@@ 

CVS commit: src/sys

2018-06-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jun 16 21:22:14 UTC 2018

Modified Files:
src/sys/arch/evbmips/loongson/dev: stvii.c
src/sys/arch/hpcarm/dev: nbppcon.c
src/sys/arch/macppc/dev: deq.c smusat.c videopll.c
src/sys/arch/sparc64/dev: pcf8591_envctrl.c tda.c
src/sys/arch/zaurus/dev: ioexp.c wm8731_zaudio.c wm8750_zaudio.c
src/sys/dev/i2c: ac100.c act8846.c adadc.c adm1021.c adm1026.c am2315.c
as3722.c at24cxx.c axp20x.c axp22x.c axp809.c axppmic.c dbcool.c
ddc.c dstemp.c em3027.c fcu.c g760a.c i2c.c i2cvar.h ibmhawk.c
ihidev.c lm75.c lm87.c lm_i2c.c m41st84.c m41t00.c max6900.c
max77620.c mcp980x.c mpl115a.c pcf8563.c pcf8583.c r2025.c
rs5c372.c s390.c sdtemp.c sgsmix.c si70xx.c smscmon.c spdmem_i2c.c
sy8106a.c tcagpio.c tcakp.c titemp.c tps65217pmic.c tps65950.c
tsl256x.c w83795g.c x1226.c

Log Message:
More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
  all of the logic for direct-config matching.  If it returns true,
  the driver returns the match result (which may be 0).  If it returns
  false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
  lower-indexed "compatible" device property are more-specific matches,
  and return a better match quality accordingly.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbmips/loongson/dev/stvii.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hpcarm/dev/nbppcon.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/dev/deq.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/dev/smusat.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/videopll.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/pcf8591_envctrl.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/dev/tda.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/zaurus/dev/ioexp.c \
src/sys/arch/zaurus/dev/wm8731_zaudio.c \
src/sys/arch/zaurus/dev/wm8750_zaudio.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/ac100.c src/sys/dev/i2c/axp809.c \
src/sys/dev/i2c/dstemp.c src/sys/dev/i2c/em3027.c \
src/sys/dev/i2c/mpl115a.c src/sys/dev/i2c/sy8106a.c \
src/sys/dev/i2c/tcagpio.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/act8846.c src/sys/dev/i2c/g760a.c \
src/sys/dev/i2c/lm_i2c.c src/sys/dev/i2c/titemp.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/adadc.c src/sys/dev/i2c/axp22x.c \
src/sys/dev/i2c/fcu.c src/sys/dev/i2c/s390.c src/sys/dev/i2c/si70xx.c \
src/sys/dev/i2c/tsl256x.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/i2c/adm1021.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/adm1026.c src/sys/dev/i2c/am2315.c \
src/sys/dev/i2c/ihidev.c src/sys/dev/i2c/max77620.c \
src/sys/dev/i2c/smscmon.c src/sys/dev/i2c/w83795g.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/i2c/as3722.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/i2c/at24cxx.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/i2c/axp20x.c src/sys/dev/i2c/axppmic.c
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/i2c/dbcool.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/ddc.c src/sys/dev/i2c/ibmhawk.c \
src/sys/dev/i2c/tcakp.c
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/i2c/i2c.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/i2c/i2cvar.h
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/i2c/lm75.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/lm87.c src/sys/dev/i2c/r2025.c
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/i2c/m41st84.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/i2c/m41t00.c src/sys/dev/i2c/x1226.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/i2c/max6900.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/mcp980x.c src/sys/dev/i2c/tps65950.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/pcf8563.c src/sys/dev/i2c/sgsmix.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/i2c/pcf8583.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/i2c/rs5c372.c \
src/sys/dev/i2c/spdmem_i2c.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/i2c/sdtemp.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/i2c/tps65217pmic.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/evbmips/loongson/dev/stvii.c
diff -u src/sys/arch/evbmips/loongson/dev/stvii.c:1.5 src/sys/arch/evbmips/loongson/dev/stvii.c:1.6
--- src/sys/arch/evbmips/loongson/dev/stvii.c:1.5	Mon Feb 29 18:24:31 2016
+++ src/sys/arch/evbmips/loongson/dev/stvii.c	Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: stvii.c,v 1.5 2016/02/29 18:24:31 christos Exp $	*/
+/*	$NetBSD: stvii.c,v 1.6 2018/06/16 21:22:13 thorpej Exp $	*/
 
 /*-
  * Copyright (C) 2011 Michael Lorenz.
@@ -30,7 +30,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: stvii.c,v 1.5 2016/02/29 18:24:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: stvii.c,v 1.6 2018/06/16 21:22:13 thorpej Exp $");
 
 #include 
 #include 
@@ -136,7 +136,7 @@ stvii_match(device_t parent, cfdata_t cf
 		DPRINTF("%02x\n", in);
 		

CVS commit: src/external/bsd/nvi/dist/common

2018-06-16 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Jun 16 21:00:12 UTC 2018

Modified Files:
src/external/bsd/nvi/dist/common: log.c

Log Message:
Correct previous change to CHAR_T_OFFSET

The intended operation is offsetof(), not alignof().

Noted by 


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/log.c

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

Modified files:

Index: src/external/bsd/nvi/dist/common/log.c
diff -u src/external/bsd/nvi/dist/common/log.c:1.4 src/external/bsd/nvi/dist/common/log.c:1.5
--- src/external/bsd/nvi/dist/common/log.c:1.4	Sat Jun 16 18:54:52 2018
+++ src/external/bsd/nvi/dist/common/log.c	Sat Jun 16 21:00:12 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: log.c,v 1.4 2018/06/16 18:54:52 kamil Exp $ */
+/*	$NetBSD: log.c,v 1.5 2018/06/16 21:00:12 kamil Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: log.c,v 10.26 2002/03/02 23:12:13 skimo Exp  (Berkeley) Date: 2002/03/02 23:12:13 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: log.c,v 1.4 2018/06/16 18:54:52 kamil Exp $");
+__RCSID("$NetBSD: log.c,v 1.5 2018/06/16 21:00:12 kamil Exp $");
 #endif
 
 #include 
@@ -90,7 +90,7 @@ typedef struct {
 chardata[sizeof(u_char) /* type */ + sizeof(db_recno_t)];
 CHAR_T  str[1];
 } log_t;
-#define CHAR_T_OFFSET (__alignof__(log_t))
+#define CHAR_T_OFFSET (offsetof(log_t, str))
 
 /*
  * log_init --



CVS commit: src/share/mk

2018-06-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Jun 16 19:05:17 UTC 2018

Modified Files:
src/share/mk: bsd.own.mk

Log Message:
check MK{FOO} defaults for $MACHINE as well as $MACHINE_ARCH.
should restore firmware files for some platforms that were
missing them.


To generate a diff of this commit:
cvs rdiff -u -r1.1064 -r1.1065 src/share/mk/bsd.own.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.own.mk
diff -u src/share/mk/bsd.own.mk:1.1064 src/share/mk/bsd.own.mk:1.1065
--- src/share/mk/bsd.own.mk:1.1064	Sat Jun  2 14:30:35 2018
+++ src/share/mk/bsd.own.mk	Sat Jun 16 19:05:17 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.1064 2018/06/02 14:30:35 christos Exp $
+#	$NetBSD: bsd.own.mk,v 1.1065 2018/06/16 19:05:17 mrg Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -1177,7 +1177,7 @@ _MKVARS.no= \
 	MKX11 MKX11MOTIF MKXORG_SERVER \
 	MKZFS
 .for var in ${_MKVARS.no}
-${var}?=	${${var}.${MACHINE_ARCH}:Uno}
+${var}?=	${${var}.${MACHINE_ARCH}:U${${var}.${MACHINE}:Uno}}
 .endfor
 
 .if ${MACHINE_ARCH} == "i386" || \



CVS commit: src/lib/csu

2018-06-16 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Jun 16 18:58:00 UTC 2018

Modified Files:
src/lib/csu: Makefile

Log Message:
Disable MKSANITIZER in lib/csu

These low-level libraries are expected to be not touched by a sanitizer.
Every libc program not using sanitizers cannot work with sanitized csu.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/lib/csu/Makefile

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

Modified files:

Index: src/lib/csu/Makefile
diff -u src/lib/csu/Makefile:1.35 src/lib/csu/Makefile:1.36
--- src/lib/csu/Makefile:1.35	Sun Aug 10 23:25:49 2014
+++ src/lib/csu/Makefile	Sat Jun 16 18:58:00 2018
@@ -1,4 +1,6 @@
-#	$NetBSD: Makefile,v 1.35 2014/08/10 23:25:49 matt Exp $
+#	$NetBSD: Makefile,v 1.36 2018/06/16 18:58:00 kamil Exp $
+
+NOSANITIZER=		# defined
 
 .include 
 



CVS commit: src/external/bsd/nvi/dist/common

2018-06-16 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Jun 16 18:54:52 UTC 2018

Modified Files:
src/external/bsd/nvi/dist/common: log.c

Log Message:
Do not cause Undefined Behavior in vi(1)

Replace unportable manual calculation of alignof() that causes UB, with
a GCC extension __alignof__.

This fixes a problem reported by UBSan with the MKSANITIZER distribution.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/log.c

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

Modified files:

Index: src/external/bsd/nvi/dist/common/log.c
diff -u src/external/bsd/nvi/dist/common/log.c:1.3 src/external/bsd/nvi/dist/common/log.c:1.4
--- src/external/bsd/nvi/dist/common/log.c:1.3	Sun Jan 26 21:43:45 2014
+++ src/external/bsd/nvi/dist/common/log.c	Sat Jun 16 18:54:52 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: log.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
+/*	$NetBSD: log.c,v 1.4 2018/06/16 18:54:52 kamil Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: log.c,v 10.26 2002/03/02 23:12:13 skimo Exp  (Berkeley) Date: 2002/03/02 23:12:13 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: log.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
+__RCSID("$NetBSD: log.c,v 1.4 2018/06/16 18:54:52 kamil Exp $");
 #endif
 
 #include 
@@ -90,7 +90,7 @@ typedef struct {
 chardata[sizeof(u_char) /* type */ + sizeof(db_recno_t)];
 CHAR_T  str[1];
 } log_t;
-#define CHAR_T_OFFSET ((char *)(((log_t*)0)->str) - (char *)0)
+#define CHAR_T_OFFSET (__alignof__(log_t))
 
 /*
  * log_init --



CVS commit: src/crypto/external/bsd/heimdal/dist/lib/krb5

2018-06-16 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Jun 16 18:51:36 UTC 2018

Modified Files:
src/crypto/external/bsd/heimdal/dist/lib/krb5: config_file.c

Log Message:
Do not reference buffer after the code scope {}

rk_getpwuid_r() returns a pointer pwd->pw_dir to a buffer pwbuf[].

It's not safe to store another a copy of pwd->pw_dir in outter scope and
use it out of the scope where there exists pwbuf[].

This fixes a problem reported by ASan under MKSANITIZER.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/crypto/external/bsd/heimdal/dist/lib/krb5/config_file.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/external/bsd/heimdal/dist/lib/krb5/config_file.c
diff -u src/crypto/external/bsd/heimdal/dist/lib/krb5/config_file.c:1.3 src/crypto/external/bsd/heimdal/dist/lib/krb5/config_file.c:1.4
--- src/crypto/external/bsd/heimdal/dist/lib/krb5/config_file.c:1.3	Fri Sep  8 15:29:43 2017
+++ src/crypto/external/bsd/heimdal/dist/lib/krb5/config_file.c	Sat Jun 16 18:51:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: config_file.c,v 1.3 2017/09/08 15:29:43 christos Exp $	*/
+/*	$NetBSD: config_file.c,v 1.4 2018/06/16 18:51:36 kamil Exp $	*/
 
 /*
  * Copyright (c) 1997 - 2004 Kungliga Tekniska Högskolan
@@ -430,6 +430,8 @@ krb5_config_parse_file_multi (krb5_conte
 if (ISTILDE(fname[0]) && ISPATHSEP(fname[1])) {
 #ifndef KRB5_USE_PATH_TOKENS
 	const char *home = NULL;
+	struct passwd pw, *pwd = NULL;
+	char pwbuf[2048];
 
 	if (!_krb5_homedir_access(context)) {
 	krb5_set_error_message(context, EPERM,
@@ -441,9 +443,6 @@ krb5_config_parse_file_multi (krb5_conte
 	home = getenv("HOME");
 
 	if (home == NULL) {
-	struct passwd pw, *pwd = NULL;
-	char pwbuf[2048];
-
 	if (rk_getpwuid_r(getuid(), , pwbuf, sizeof(pwbuf), ) == 0)
 		home = pwd->pw_dir;
 	}



CVS commit: src/sys/dev/mii

2018-06-16 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Jun 16 17:44:53 UTC 2018

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

Log Message:
switch to using OpenBSD eehpy(4) code to drive maphy(4), synchronizing support
for several special PHY conditions, particularly:
- Properly re-initialise the PHY upon resume
- Store next page in the Link Partner Next Page register for compatibility
  with 802.3ab on 88E3016 PHYs.  Fixes some autonegotiation problems on msk(4)
- Make 88E3016 actually work
- Make sure page 0 is selected when we initialize the PHY.  Fixes problems
  with the eephy(4) that attaches to nfe(4) on machines like the Sun Ultra 40.
  (we had condition for this, now the page 0 is selected for any PHY type)
- Disable fiber/copper auto-selection on the 88E if it is in RGMII mode, to
  work around the fact that the onboard PHYs attached to nfe(4) on the Sun
  X4100 M2 have fiber/copper auto-selection enabled even though the interfaces
  are clearly copper-only

make sure to also add appropriate licenses, since basically nothing
really significant remains out of previous code

use FreeBSD  for register definitions as a base instead
of OpenBSD , since it has some extra definitions for some
3016 bits, but add the several extra bits from OpenBSD needed by the code;
removed no longed used 

tested with PHY 88E, there no particular change observed - the
link status works as it did before, just now it does media nego
even before the interface is up

should however fix 88E3016 support and hence PR kern/49270 and PR kern/53301


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/mii/e1000phyreg.h
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/mii/makphy.c
cvs rdiff -u -r1.6 -r0 src/sys/dev/mii/makphyreg.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/makphy.c
diff -u src/sys/dev/mii/makphy.c:1.43 src/sys/dev/mii/makphy.c:1.44
--- src/sys/dev/mii/makphy.c:1.43	Wed Jun 13 23:27:48 2018
+++ src/sys/dev/mii/makphy.c	Sat Jun 16 17:44:53 2018
@@ -1,4 +1,5 @@
-/*	$NetBSD: makphy.c,v 1.43 2018/06/13 23:27:48 jdolecek Exp $	*/
+/*	$NetBSD: makphy.c,v 1.44 2018/06/16 17:44:53 jdolecek Exp $	*/
+/*	$OpenBSD: eephy.c,v 1.56 2015/03/14 03:38:48 jsg Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -55,11 +56,47 @@
  */
 
 /*
+ * Principal Author: Parag Patel
+ * Copyright (c) 2001
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice unmodified, this list of conditions, and the following
+ *disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Additonal Copyright (c) 2001 by Traakan Software under same licence.
+ * Secondary Author: Matthew Jacob
+ */
+/*
  * Driver for the Marvell 88E1000 ``Alaska'' 10/100/1000 PHY.
  */
 
+/*
+ * Support added for the Marvell 88E1011 (Alaska) 1000/100/10baseTX and
+ * 1000baseSX PHY.
+ * Nathan Binkert 
+ */
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.43 2018/06/13 23:27:48 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.44 2018/06/16 17:44:53 jdolecek Exp $");
 
 #include 
 #include 
@@ -75,7 +112,7 @@ __KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1
 #include 
 #include 
 
-#include 
+#include 
 
 static int	makphymatch(device_t, cfdata_t, void *);
 static void	makphyattach(device_t, device_t, void *);
@@ -87,11 +124,11 @@ static int	makphy_service(struct mii_sof
 static void	makphy_status(struct mii_softc *);
 static void	makphy_reset(struct mii_softc *);
 
-static const struct mii_phy_funcs makphy_funcs = {
+static const struct mii_phy_funcs eephy_funcs = {
 	makphy_service, makphy_status, makphy_reset,
 };
 
-static 

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

2018-06-16 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Jun 16 17:11:13 UTC 2018

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

Log Message:
Need IPIs when enabling eager fpu switch, to clear each fpu and get us
started. Otherwise it is possible that the first context switch on one of
the cpus will restore an invalid fpu state in the new lwp, if that lwp
had its fpu state stored on another cpu that didn't have time to do an
fpu save since eager-fpu was enabled.

Use barriers and all the related crap. The point is that we want to
ensure that no context switch occurs between [each fpu is cleared] and
[x86_fpu_eager is set to 'true'].

Also add KASSERTs.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x86/x86/fpu.c
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/x86/x86/x86_machdep.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.35 src/sys/arch/x86/x86/fpu.c:1.36
--- src/sys/arch/x86/x86/fpu.c:1.35	Sat Jun 16 05:52:17 2018
+++ src/sys/arch/x86/x86/fpu.c	Sat Jun 16 17:11:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.35 2018/06/16 05:52:17 maxv Exp $	*/
+/*	$NetBSD: fpu.c,v 1.36 2018/06/16 17:11:13 maxv Exp $	*/
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.35 2018/06/16 05:52:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.36 2018/06/16 17:11:13 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -107,6 +107,8 @@ __KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.35
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -339,6 +341,8 @@ fpu_eagerrestore(struct lwp *l)
 	struct cpu_info *ci = curcpu();
 
 	clts();
+	KASSERT(ci->ci_fpcurlwp == NULL);
+	KASSERT(pcb->pcb_fpcpu == NULL);
 	ci->ci_fpcurlwp = l;
 	pcb->pcb_fpcpu = ci;
 	fpu_restore(l);
@@ -393,6 +397,10 @@ fputrap(struct trapframe *frame)
 	if (!USERMODE(frame->tf_cs))
 		panic("fpu trap from kernel, trapframe %p\n", frame);
 
+	if (__predict_false(x86_fpu_eager)) {
+		panic("%s: got DNA with EagerFPU enabled", __func__);
+	}
+
 	/*
 	 * At this point, fpcurlwp should be curlwp.  If it wasn't, the TS bit
 	 * should be set, and we should have gotten a DNA exception.
@@ -890,3 +898,110 @@ process_read_fpregs_s87(struct lwp *l, s
 		memcpy(fpregs, _save->sv_87, sizeof(fpu_save->sv_87));
 	}
 }
+
+/* -- */
+
+static volatile unsigned long eagerfpu_cpu_barrier1 __cacheline_aligned;
+static volatile unsigned long eagerfpu_cpu_barrier2 __cacheline_aligned;
+
+static void
+eager_change_cpu(void *arg1, void *arg2)
+{
+	struct cpu_info *ci = curcpu();
+	bool enabled = (bool)arg1;
+	int s;
+
+	s = splhigh();
+
+	/* Rendez-vous 1. */
+	atomic_dec_ulong(_cpu_barrier1);
+	while (atomic_cas_ulong(_cpu_barrier1, 0, 0) != 0) {
+		x86_pause();
+	}
+
+	fpusave_cpu(true);
+	if (ci == _info_primary) {
+		x86_fpu_eager = enabled;
+	}
+
+	/* Rendez-vous 2. */
+	atomic_dec_ulong(_cpu_barrier2);
+	while (atomic_cas_ulong(_cpu_barrier2, 0, 0) != 0) {
+		x86_pause();
+	}
+
+	splx(s);
+}
+
+static int
+eager_change(bool enabled)
+{
+	struct cpu_info *ci = NULL;
+	CPU_INFO_ITERATOR cii;
+	uint64_t xc;
+
+	mutex_enter(_lock);
+
+	/*
+	 * We expect all the CPUs to be online.
+	 */
+	for (CPU_INFO_FOREACH(cii, ci)) {
+		struct schedstate_percpu *spc = >ci_schedstate;
+		if (spc->spc_flags & SPCF_OFFLINE) {
+			printf("[!] cpu%d offline, EagerFPU not changed\n",
+			cpu_index(ci));
+			mutex_exit(_lock);
+			return EOPNOTSUPP;
+		}
+	}
+
+	/* Initialize the barriers */
+	eagerfpu_cpu_barrier1 = ncpu;
+	eagerfpu_cpu_barrier2 = ncpu;
+
+	printf("[+] %s EagerFPU...",
+	enabled ? "Enabling" : "Disabling");
+	xc = xc_broadcast(0, eager_change_cpu,
+	(void *)enabled, NULL);
+	xc_wait(xc);
+	printf(" done!\n");
+
+	mutex_exit(_lock);
+
+	return 0;
+}
+
+static int
+sysctl_machdep_fpu_eager(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node;
+	int error;
+	bool val;
+
+	val = *(bool *)rnode->sysctl_data;
+
+	node = *rnode;
+	node.sysctl_data = 
+
+	error = sysctl_lookup(SYSCTLFN_CALL());
+	if (error != 0 || newp == NULL)
+		return error;
+
+	if (val == x86_fpu_eager)
+		return 0;
+	return eager_change(val);
+}
+
+void sysctl_eagerfpu_init(struct sysctllog **);
+
+void
+sysctl_eagerfpu_init(struct sysctllog **clog)
+{
+	sysctl_createv(clog, 0, NULL, NULL,
+		   CTLFLAG_READWRITE,
+		   CTLTYPE_BOOL, "fpu_eager",
+		   SYSCTL_DESCR("Whether the kernel uses Eager FPU Switch"),
+		   sysctl_machdep_fpu_eager, 0,
+		   _fpu_eager, 0,
+		   CTL_MACHDEP, CTL_CREATE, CTL_EOL);
+}

Index: src/sys/arch/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.116 src/sys/arch/x86/x86/x86_machdep.c:1.117
--- src/sys/arch/x86/x86/x86_machdep.c:1.116	Thu Jun 14 14:36:46 2018
+++ 

CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2018-06-16 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Jun 16 15:18:33 UTC 2018

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_ioctl.c

Log Message:
Use space between words


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.11 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.12
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.11	Mon May 28 21:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c	Sat Jun 16 15:18:33 2018
@@ -7133,7 +7133,7 @@ zfs_modcmd(modcmd_t cmd, void *arg)
 		printf("WARNING: ZFS on NetBSD is under development\n");
 		availrmem = (uint64_t)physmem * PAGE_SIZE / 1048576;
 		if (availrmem < ZFS_MIN_MEGS * 80 / 100) {
-			printf("ERROR: at least %dMB of memory required to"
+			printf("ERROR: at least %dMB of memory required to "
 			"use ZFS\n", ZFS_MIN_MEGS);
 			return ENOMEM;
 		}



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

2018-06-16 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Jun 16 15:04:29 UTC 2018

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
uncomment ena(4) now that it compiles; even though it's not working yet, this
ensures it's included in eventual subsystem rototils


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/amd64/conf/ALL

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

Modified files:

Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.89 src/sys/arch/amd64/conf/ALL:1.90
--- src/sys/arch/amd64/conf/ALL:1.89	Thu Jun  7 13:36:28 2018
+++ src/sys/arch/amd64/conf/ALL	Sat Jun 16 15:04:29 2018
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.89 2018/06/07 13:36:28 thorpej Exp $
+# $NetBSD: ALL,v 1.90 2018/06/16 15:04:29 jdolecek Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.89 $"
+#ident		"ALL-$Revision: 1.90 $"
 
 maxusers	64		# estimated number of users
 
@@ -951,7 +951,7 @@ bwi*	at pci? dev ? function ?	# Broadcom
 cas*	at pci? dev ? function ?	# Sun Cassini/Cassini+ Ethernet
 dge*	at pci? dev ? function ?	# Intel 82597 10GbE LR
 en*	at pci? dev ? function ?	# ENI/Adaptec ATM
-#ena*	at pci? dev ? function ?	# experimental - Amazon Elastic Network Adapter
+ena*	at pci? dev ? function ?	# NOT WORKING - Amazon Elastic Network Adapter
 ep*	at pci? dev ? function ?	# 3Com 3c59x
 epic*	at pci? dev ? function ?	# SMC EPIC/100 Ethernet
 esh*	at pci? dev ? function ?	# Essential HIPPI card



CVS commit: src/sys

2018-06-16 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Jun 16 15:00:35 UTC 2018

Modified Files:
src/sys/dev/pci: if_ena.c if_enavar.h
src/sys/external/bsd/ena-com: ena_plat.h

Log Message:
make ena(4) compile, with best efford exercised to convert code to NetBSD
equivalents; where possible left the original code intact to make it
easier to compare against FreeBSD original

made non-working stubs for some functions which don't have direct
equivalent yet - this includes all of , m_getjcl(),
m_append, and m_collapse(); these need to be adressed

left XXX/TODO in if_enavar.h, colocated with the non-working stubs


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/if_ena.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/if_enavar.h
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/ena-com/ena_plat.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_ena.c
diff -u src/sys/dev/pci/if_ena.c:1.3 src/sys/dev/pci/if_ena.c:1.4
--- src/sys/dev/pci/if_ena.c:1.3	Fri Jun  1 09:34:39 2018
+++ src/sys/dev/pci/if_ena.c	Sat Jun 16 15:00:35 2018
@@ -31,7 +31,7 @@
 #if 0
 __FBSDID("$FreeBSD: head/sys/dev/ena/ena.c 333456 2018-05-10 09:37:54Z mw $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.3 2018/06/01 09:34:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.4 2018/06/16 15:00:35 jdolecek Exp $");
 
 #include 
 #include 
@@ -47,31 +47,37 @@ __KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 
+#include 
+#include 
+
 #include 
 
 /*
  *  Function prototypes
  */
 static int	ena_probe(device_t, cfdata_t, void *);
-static void	ena_intr_msix_mgmnt(void *);
-static int	ena_allocate_pci_resources(struct ena_adapter*);
+static int	ena_intr_msix_mgmnt(void *);
+static int	ena_allocate_pci_resources(struct pci_attach_args *,
+		struct ena_adapter *);
 static void	ena_free_pci_resources(struct ena_adapter *);
 static int	ena_change_mtu(struct ifnet *, int);
-static inline void ena_alloc_counters(struct evcnt *, int);
-static inline void ena_free_counters(struct evcnt *, int);
-static inline void ena_reset_counters(struct evcnt *, int);
 static void	ena_init_io_rings_common(struct ena_adapter *,
 struct ena_ring *, uint16_t);
 static void	ena_init_io_rings(struct ena_adapter *);
 static void	ena_free_io_ring_resources(struct ena_adapter *, unsigned int);
 static void	ena_free_all_io_rings_resources(struct ena_adapter *);
+#if 0
 static int	ena_setup_tx_dma_tag(struct ena_adapter *);
 static int	ena_free_tx_dma_tag(struct ena_adapter *);
 static int	ena_setup_rx_dma_tag(struct ena_adapter *);
 static int	ena_free_rx_dma_tag(struct ena_adapter *);
+#endif
 static int	ena_setup_tx_resources(struct ena_adapter *, int);
 static void	ena_free_tx_resources(struct ena_adapter *, int);
 static int	ena_setup_all_tx_resources(struct ena_adapter *);
@@ -96,19 +102,19 @@ static void	ena_destroy_all_rx_queues(st
 static void	ena_destroy_all_io_queues(struct ena_adapter *);
 static int	ena_create_io_queues(struct ena_adapter *);
 static int	ena_tx_cleanup(struct ena_ring *);
-static void	ena_deferred_rx_cleanup(void *, int);
+static void	ena_deferred_rx_cleanup(struct work *, void *);
 static int	ena_rx_cleanup(struct ena_ring *);
 static inline int validate_tx_req_id(struct ena_ring *, uint16_t);
+#if 0
 static void	ena_rx_hash_mbuf(struct ena_ring *, struct ena_com_rx_ctx *,
 struct mbuf *);
+#endif
 static struct mbuf* ena_rx_mbuf(struct ena_ring *, struct ena_com_rx_buf_info *,
 struct ena_com_rx_ctx *, uint16_t *);
 static inline void ena_rx_checksum(struct ena_ring *, struct ena_com_rx_ctx *,
 struct mbuf *);
-static void	ena_handle_msix(void *);
+static int	ena_handle_msix(void *);
 static int	ena_enable_msix(struct ena_adapter *);
-static void	ena_setup_mgmnt_intr(struct ena_adapter *);
-static void	ena_setup_io_intr(struct ena_adapter *);
 static int	ena_request_mgmnt_irq(struct ena_adapter *);
 static int	ena_request_io_irq(struct ena_adapter *);
 static void	ena_free_mgmnt_irq(struct ena_adapter *);
@@ -125,7 +131,7 @@ static uint64_t	ena_get_counter(struct i
 #endif
 static int	ena_media_change(struct ifnet *);
 static void	ena_media_status(struct ifnet *, struct ifmediareq *);
-static void	ena_init(void *);
+static int	ena_init(struct ifnet *);
 static int	ena_ioctl(struct ifnet *, u_long, void *);
 static int	ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *);
 static void	ena_update_host_info(struct ena_admin_host_info *, struct ifnet *);
@@ -138,17 +144,21 @@ static int	ena_check_and_collapse_mbuf(s
 static int	ena_xmit_mbuf(struct ena_ring *, struct mbuf **);
 static void	ena_start_xmit(struct ena_ring *);
 static int	ena_mq_start(struct ifnet *, struct mbuf *);

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

2018-06-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 16 14:41:25 UTC 2018

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

Log Message:
Comment out EARLYCONS


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

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

Modified files:

Index: src/sys/arch/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.17 src/sys/arch/evbarm/conf/GENERIC64:1.18
--- src/sys/arch/evbarm/conf/GENERIC64:1.17	Sat Jun 16 00:19:04 2018
+++ src/sys/arch/evbarm/conf/GENERIC64	Sat Jun 16 14:41:25 2018
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.17 2018/06/16 00:19:04 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.18 2018/06/16 14:41:25 jmcneill Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -67,7 +67,7 @@ options 	DEBUG
 options 	VERBOSE_INIT_ARM # verbose bootstrapping messages
 # EARLYCONS is required for early init messages from VERBOSE_INIT_ARM.
 #options 	EARLYCONS=bcm2837
-options 	EARLYCONS=rk3328, CONSADDR=0xff13
+#options 	EARLYCONS=rk3328, CONSADDR=0xff13
 #options 	EARLYCONS=sunxi, CONSADDR=0x01c28000
 #options 	EARLYCONS=tegra, CONSADDR=0x70006000
 #options 	EARLYCONS=virt



CVS commit: src/sys/arch/aarch64/aarch64

2018-06-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 16 13:53:45 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: bus_space.c

Log Message:
initialize bs_cookie for generic_dsb tags


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/bus_space.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/aarch64/bus_space.c
diff -u src/sys/arch/aarch64/aarch64/bus_space.c:1.4 src/sys/arch/aarch64/aarch64/bus_space.c:1.5
--- src/sys/arch/aarch64/aarch64/bus_space.c:1.4	Fri Jun  8 18:09:43 2018
+++ src/sys/arch/aarch64/aarch64/bus_space.c	Sat Jun 16 13:53:45 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.4 2018/06/08 18:09:43 jmcneill Exp $ */
+/* $NetBSD: bus_space.c,v 1.5 2018/06/16 13:53:45 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: bus_space.c,v 1.4 2018/06/08 18:09:43 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bus_space.c,v 1.5 2018/06/16 13:53:45 jmcneill Exp $");
 
 #include 
 #include 
@@ -166,6 +166,8 @@ struct bus_space arm_generic_bs_tag = {
 };
 
 struct bus_space aarch64_generic_dsb_bs_tag = {
+	.bs_cookie = _generic_dsb_bs_tag,
+
 	.bs_stride = 0,
 	.bs_flags = 0,
 
@@ -408,6 +410,8 @@ struct bus_space arm_generic_a4x_bs_tag 
 };
 
 struct bus_space aarch64_generic_a4x_dsb_bs_tag = {
+	.bs_cookie = _generic_a4x_dsb_bs_tag,
+
 	.bs_stride = 2,
 	.bs_flags = 0,
 



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

2018-06-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 16 13:24:04 UTC 2018

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

Log Message:
Fix rate calculation of fractional mode PLLs


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_cru_pll.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_pll.c
diff -u src/sys/arch/arm/rockchip/rk_cru_pll.c:1.1 src/sys/arch/arm/rockchip/rk_cru_pll.c:1.2
--- src/sys/arch/arm/rockchip/rk_cru_pll.c:1.1	Sat Jun 16 00:19:04 2018
+++ src/sys/arch/arm/rockchip/rk_cru_pll.c	Sat Jun 16 13:24:04 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_cru_pll.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $ */
+/* $NetBSD: rk_cru_pll.c,v 1.2 2018/06/16 13:24:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_cru_pll.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_cru_pll.c,v 1.2 2018/06/16 13:24:04 jmcneill Exp $");
 
 #include 
 #include 
@@ -96,7 +96,7 @@ rk_cru_pll_get_rate(struct rk_cru_softc 
 		foutvco = fref / refdiv * fbdiv;
 	} else {
 		/* fractional mode */
-		foutvco = fref / refdiv * (fbdiv + fracdiv / 224);
+		foutvco = fref / refdiv * fbdiv + ((fref * fracdiv) >> 24);
 	}
 	foutpostdiv = foutvco / postdiv1 / postdiv2;
 



CVS commit: src/usr.sbin/ndp

2018-06-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun 16 13:09:41 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
PR/53371: Thomas Barabosch: Potential memory leak in usr.sbin/ndp/ndp.c


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/ndp/ndp.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/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.50 src/usr.sbin/ndp/ndp.c:1.51
--- src/usr.sbin/ndp/ndp.c:1.50	Wed Jun 28 04:17:50 2017
+++ src/usr.sbin/ndp/ndp.c	Sat Jun 16 09:09:41 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.50 2017/06/28 08:17:50 ozaki-r Exp $	*/
+/*	$NetBSD: ndp.c,v 1.51 2018/06/16 13:09:41 christos Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -376,6 +376,7 @@ set(int argc, char **argv)
 		return 1;
 	}
 	makeaddr(mysin, res->ai_addr);
+	freeaddrinfo(res);
 	ea = (u_char *)LLADDR(_m);
 	if (ndp_ether_aton(eaddr, ea) == 0)
 		sdl_m.sdl_alen = 6;
@@ -441,6 +442,7 @@ get(char *host)
 		return;
 	}
 	makeaddr(mysin, res->ai_addr);
+	freeaddrinfo(res);
 	do_foreach(>sin6_addr, host, 0);
 	if (found_entry == 0) {
 		(void)getnameinfo((struct sockaddr *)(void *)mysin,
@@ -467,6 +469,7 @@ delete_one(char *host)
 		return;
 	}
 	makeaddr(mysin, res->ai_addr);
+	freeaddrinfo(res);
 	do_foreach(>sin6_addr, host, NDP_F_DELETE);
 }
 



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

2018-06-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 16 12:49:46 UTC 2018

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

Log Message:
Fix reading through /dev/gpio and use the same style for writing registers in 
both fdt and /dev/gpio cases


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

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

Modified files:

Index: src/sys/arch/arm/rockchip/rk_gpio.c
diff -u src/sys/arch/arm/rockchip/rk_gpio.c:1.1 src/sys/arch/arm/rockchip/rk_gpio.c:1.2
--- src/sys/arch/arm/rockchip/rk_gpio.c:1.1	Sat Jun 16 00:19:04 2018
+++ src/sys/arch/arm/rockchip/rk_gpio.c	Sat Jun 16 12:49:46 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_gpio.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $ */
+/* $NetBSD: rk_gpio.c,v 1.2 2018/06/16 12:49:46 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_gpio.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_gpio.c,v 1.2 2018/06/16 12:49:46 jmcneill Exp $");
 
 #include 
 #include 
@@ -190,8 +190,10 @@ rk_gpio_write(device_t dev, void *priv, 
 
 	mutex_enter(>sc_lock);
 	data = RD4(sc, GPIO_SWPORTA_DR_REG);
-	data &= ~data_mask;
-	data |= __SHIFTIN(val, data_mask);
+	if (val)
+		data |= data_mask;
+	else
+		data &= ~data_mask;
 	WR4(sc, GPIO_SWPORTA_DR_REG, data);
 	mutex_exit(>sc_lock);
 }
@@ -215,7 +217,7 @@ rk_gpio_pin_read(void *priv, int pin)
 	const uint32_t data_mask = __BIT(pin);
 
 	/* No lock required for reads */
-	data = RD4(sc, GPIO_SWPORTA_DR_REG);
+	data = RD4(sc, GPIO_EXT_PORTA_REG);
 	val = __SHIFTOUT(data, data_mask);
 
 	return val;



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

2018-06-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 16 10:42:41 UTC 2018

Modified Files:
src/sys/arch/arm/virt: virt_platform.c

Log Message:
incldue -> include


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/virt/virt_platform.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/virt/virt_platform.c
diff -u src/sys/arch/arm/virt/virt_platform.c:1.3 src/sys/arch/arm/virt/virt_platform.c:1.4
--- src/sys/arch/arm/virt/virt_platform.c:1.3	Fri Jun 15 23:57:55 2018
+++ src/sys/arch/arm/virt/virt_platform.c	Sat Jun 16 10:42:41 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: virt_platform.c,v 1.3 2018/06/15 23:57:55 jmcneill Exp $ */
+/* $NetBSD: virt_platform.c,v 1.4 2018/06/16 10:42:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -31,7 +31,7 @@
 #include "opt_fdt_arm.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virt_platform.c,v 1.3 2018/06/15 23:57:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virt_platform.c,v 1.4 2018/06/16 10:42:41 jmcneill Exp $");
 
 #include 
 #include 
@@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: virt_platfor
 
 #include 
 #include 
-#incldue 
+#include 
 
 #include 
 #include 



CVS commit: src/sys/dev/usb

2018-06-16 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Sat Jun 16 08:24:55 UTC 2018

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

Log Message:
Change aprint_error_dev to aprint_normal_dev for normal completion case.


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/dev/usb/uaudio.c

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

Modified files:

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.155 src/sys/dev/usb/uaudio.c:1.156
--- src/sys/dev/usb/uaudio.c:1.155	Wed Jul 26 07:45:05 2017
+++ src/sys/dev/usb/uaudio.c	Sat Jun 16 08:24:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.155 2017/07/26 07:45:05 maya Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.156 2018/06/16 08:24:55 nakayama Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.155 2017/07/26 07:45:05 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.156 2018/06/16 08:24:55 nakayama Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1585,7 +1585,7 @@ uaudio_process_as(struct uaudio_softc *s
 		return USBD_INVAL;
 
 	if (asf1d->bFormatType != FORMAT_TYPE_I) {
-		aprint_error_dev(sc->sc_dev,
+		aprint_normal_dev(sc->sc_dev,
 		"ignored setting with type %d format\n", UGETW(asid->wFormatTag));
 		return USBD_NORMAL_COMPLETION;
 	}
@@ -1616,7 +1616,7 @@ uaudio_process_as(struct uaudio_softc *s
 	if (dir == UE_DIR_IN && type == UE_ISO_ADAPT) {
 		sync = TRUE;
 #ifndef UAUDIO_MULTIPLE_ENDPOINTS
-		aprint_error_dev(sc->sc_dev,
+		aprint_normal_dev(sc->sc_dev,
 		"ignored input endpoint of type adaptive\n");
 		return USBD_NORMAL_COMPLETION;
 #endif
@@ -1624,7 +1624,7 @@ uaudio_process_as(struct uaudio_softc *s
 	if (dir != UE_DIR_IN && type == UE_ISO_ASYNC) {
 		sync = TRUE;
 #ifndef UAUDIO_MULTIPLE_ENDPOINTS
-		aprint_error_dev(sc->sc_dev,
+		aprint_normal_dev(sc->sc_dev,
 		"ignored output endpoint of type async\n");
 		return USBD_NORMAL_COMPLETION;
 #endif
@@ -1693,7 +1693,7 @@ uaudio_process_as(struct uaudio_softc *s
 	chan = asf1d->bNrChannels;
 	prec = asf1d->bBitResolution;
 	if (prec != 8 && prec != 16 && prec != 24) {
-		aprint_error_dev(sc->sc_dev,
+		aprint_normal_dev(sc->sc_dev,
 		"ignored setting with precision %d\n", prec);
 		return USBD_NORMAL_COMPLETION;
 	}
@@ -1726,7 +1726,7 @@ uaudio_process_as(struct uaudio_softc *s
 		break;
 	case UA_FMT_IEEE_FLOAT:
 	default:
-		aprint_error_dev(sc->sc_dev,
+		aprint_normal_dev(sc->sc_dev,
 		"ignored setting with format %d\n", format);
 		return USBD_NORMAL_COMPLETION;
 	}



CVS commit: src/lib/libc/atomic

2018-06-16 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Jun 16 08:11:33 UTC 2018

Modified Files:
src/lib/libc/atomic: atomic_and.3 atomic_ops.3 atomic_or.3

Log Message:
atomic_and/atomic_or do bitwise ops, not logical ops.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/atomic/atomic_and.3 \
src/lib/libc/atomic/atomic_or.3
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/atomic/atomic_ops.3

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

Modified files:

Index: src/lib/libc/atomic/atomic_and.3
diff -u src/lib/libc/atomic/atomic_and.3:1.1 src/lib/libc/atomic/atomic_and.3:1.2
--- src/lib/libc/atomic/atomic_and.3:1.1	Mon Jun 23 10:22:40 2008
+++ src/lib/libc/atomic/atomic_and.3	Sat Jun 16 08:11:32 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: atomic_and.3,v 1.1 2008/06/23 10:22:40 ad Exp $
+.\"	$NetBSD: atomic_and.3,v 1.2 2018/06/16 08:11:32 dholland Exp $
 .\"
 .\" Copyright (c) 2007 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -40,7 +40,7 @@
 .Nm atomic_and_uint_nv ,
 .Nm atomic_and_ulong_nv ,
 .Nm atomic_and_64_nv
-.Nd atomic logical
+.Nd atomic bitwise
 .Sq and
 operations
 .\" .Sh LIBRARY
@@ -68,7 +68,7 @@ The
 .Nm atomic_and
 family of functions load the value of the variable referenced by
 .Fa ptr ,
-perform a logical
+perform a bitwise
 .Sq and
 with the value
 .Fa bits ,
Index: src/lib/libc/atomic/atomic_or.3
diff -u src/lib/libc/atomic/atomic_or.3:1.1 src/lib/libc/atomic/atomic_or.3:1.2
--- src/lib/libc/atomic/atomic_or.3:1.1	Mon Jun 23 10:22:40 2008
+++ src/lib/libc/atomic/atomic_or.3	Sat Jun 16 08:11:32 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: atomic_or.3,v 1.1 2008/06/23 10:22:40 ad Exp $
+.\"	$NetBSD: atomic_or.3,v 1.2 2018/06/16 08:11:32 dholland Exp $
 .\"
 .\" Copyright (c) 2007 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -40,7 +40,7 @@
 .Nm atomic_or_uint_nv ,
 .Nm atomic_or_ulong_nv ,
 .Nm atomic_or_64_nv
-.Nd atomic logical
+.Nd atomic bitwise
 .Sq or
 operations
 .\" .Sh LIBRARY
@@ -68,7 +68,7 @@ The
 .Nm atomic_or
 family of functions load the value of the variable referenced by
 .Fa ptr ,
-perform a logical
+perform a bitwise
 .Sq or
 with the value
 .Fa bits ,

Index: src/lib/libc/atomic/atomic_ops.3
diff -u src/lib/libc/atomic/atomic_ops.3:1.7 src/lib/libc/atomic/atomic_ops.3:1.8
--- src/lib/libc/atomic/atomic_ops.3:1.7	Wed Feb  7 09:59:56 2018
+++ src/lib/libc/atomic/atomic_ops.3	Sat Jun 16 08:11:32 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: atomic_ops.3,v 1.7 2018/02/07 09:59:56 martin Exp $
+.\"	$NetBSD: atomic_ops.3,v 1.8 2018/06/16 08:11:32 dholland Exp $
 .\"
 .\" Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -47,7 +47,7 @@ There are 7 classes of atomic memory ope
 .It Xr atomic_add 3
 These functions perform atomic addition.
 .It Xr atomic_and 3
-These functions perform atomic logical
+These functions perform atomic bitwise
 .Dq and .
 .It Xr atomic_cas 3
 These functions perform atomic compare-and-swap.
@@ -56,7 +56,7 @@ These functions perform atomic decrement
 .It Xr atomic_inc 3
 These functions perform atomic increment.
 .It Xr atomic_or 3
-These functions perform atomic logical
+These functions perform atomic bitwise
 .Dq or .
 .It Xr atomic_swap 3
 These functions perform atomic swap.