CVS commit: [netbsd-8] src/doc

2017-08-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Aug 26 03:55:04 UTC 2017

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

Log Message:
fix description of ticket 229. spotted by kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.43 -r1.1.2.44 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.43 src/doc/CHANGES-8.0:1.1.2.44
--- src/doc/CHANGES-8.0:1.1.2.43	Fri Aug 25 14:40:11 2017
+++ src/doc/CHANGES-8.0	Sat Aug 26 03:55:04 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.43 2017/08/25 14:40:11 martin Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.44 2017/08/26 03:55:04 snj Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -5325,7 +5325,7 @@ sys/arch/arm/omap/am335x_prcm.c			1.10
 
 share/man/man9/locking.9			1.6
 
-	Add locking(9) and psref(9) summaries to locking(9).
+	Add localcount(9) and psref(9) summaries to locking(9).
 	PR misc/52504
 	[pgoyette, ticket #229]
 



CVS commit: src/tests/lib/libpthread

2017-08-25 Thread Brian Ginsbach
Module Name:src
Committed By:   ginsbach
Date:   Fri Aug 25 22:59:47 UTC 2017

Modified Files:
src/tests/lib/libpthread: t_once.c

Log Message:
PR/49003: Ngie Cooper: add 


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libpthread/t_once.c

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

Modified files:

Index: src/tests/lib/libpthread/t_once.c
diff -u src/tests/lib/libpthread/t_once.c:1.1 src/tests/lib/libpthread/t_once.c:1.2
--- src/tests/lib/libpthread/t_once.c:1.1	Fri Jul 16 15:42:53 2010
+++ src/tests/lib/libpthread/t_once.c	Fri Aug 25 22:59:47 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_once.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $ */
+/* $NetBSD: t_once.c,v 1.2 2017/08/25 22:59:47 ginsbach Exp $ */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,8 +29,9 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_once.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $");
+__RCSID("$NetBSD: t_once.c,v 1.2 2017/08/25 22:59:47 ginsbach Exp $");
 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/dev/pci

2017-08-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Aug 25 22:45:33 UTC 2017

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

Log Message:
Radeon PLLs can't have odd post dividers when used with digital outputs -
add a flag to track this in relevant functions.
Now DVI output works properly on my Mini 2
Needs testing on Mini 1 and other hardware...


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/pci/radeonfb.c

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

Modified files:

Index: src/sys/dev/pci/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.91 src/sys/dev/pci/radeonfb.c:1.92
--- src/sys/dev/pci/radeonfb.c:1.91	Wed Aug 23 19:47:39 2017
+++ src/sys/dev/pci/radeonfb.c	Fri Aug 25 22:45:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.91 2017/08/23 19:47:39 macallan Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.92 2017/08/25 22:45:33 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.91 2017/08/23 19:47:39 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.92 2017/08/25 22:45:33 macallan Exp $");
 
 #include 
 #include 
@@ -120,13 +120,16 @@ static uintmax_t radeonfb_getprop_num(st
 static int radeonfb_getclocks(struct radeonfb_softc *);
 static int radeonfb_gettmds(struct radeonfb_softc *);
 static int radeonfb_calc_dividers(struct radeonfb_softc *, uint32_t,
-uint32_t *, uint32_t *);
+uint32_t *, uint32_t *, int);
+/* flags for radeonfb_calc_dividers */
+#define NO_ODD_FBDIV	1
+
 static int radeonfb_getconnectors(struct radeonfb_softc *);
 static const struct videomode *radeonfb_modelookup(const char *);
 static void radeonfb_init_screen(void *, struct vcons_screen *, int, long *);
 static void radeonfb_pllwriteupdate(struct radeonfb_softc *, int);
 static void radeonfb_pllwaitatomicread(struct radeonfb_softc *, int);
-static void radeonfb_program_vclk(struct radeonfb_softc *, int, int);
+static void radeonfb_program_vclk(struct radeonfb_softc *, int, int, int);
 static void radeonfb_modeswitch(struct radeonfb_display *);
 static void radeonfb_setcrtc(struct radeonfb_display *, int);
 static void radeonfb_init_misc(struct radeonfb_softc *);
@@ -580,9 +583,12 @@ radeonfb_attach(device_t parent, device_
 	PRINTREG(RADEON_TMDS_TRANSMITTER_CNTL);
 	PRINTREG(RADEON_TMDS_PLL_CNTL);
 	PRINTREG(RADEON_LVDS_GEN_CNTL);
-	PRINTREG(RADEON_FP_HORZ_STRETCH);
-	PRINTREG(RADEON_FP_VERT_STRETCH);
 	PRINTREG(RADEON_DISP_HW_DEBUG);
+	PRINTREG(RADEON_PIXCLKS_CNTL);
+	PRINTREG(RADEON_CRTC_H_SYNC_STRT_WID);
+	PRINTREG(RADEON_FP_H_SYNC_STRT_WID);
+	PRINTREG(RADEON_CRTC2_H_SYNC_STRT_WID);
+	PRINTREG(RADEON_FP_H2_SYNC_STRT_WID);
 	if (IS_RV100(sc))
 		PUT32(sc, RADEON_TMDS_PLL_CNTL, 0xa27);
 
@@ -1041,6 +1047,7 @@ radeonfb_attach(device_t parent, device_
 	PRINTREG(RADEON_TMDS_CNTL);
 	PRINTREG(RADEON_TMDS_TRANSMITTER_CNTL);
 	PRINTREG(RADEON_TMDS_PLL_CNTL);
+	PRINTREG(RADEON_PIXCLKS_CNTL);
 
 	return;
 
@@ -1625,7 +1632,7 @@ dontprobe:
 
 int
 radeonfb_calc_dividers(struct radeonfb_softc *sc, uint32_t dotclock,
-uint32_t *postdivbit, uint32_t *feedbackdiv)
+uint32_t *postdivbit, uint32_t *feedbackdiv, int flags)
 {
 	int		i;
 	uint32_t	outfreq;
@@ -1633,6 +1640,7 @@ radeonfb_calc_dividers(struct radeonfb_s
 
 	DPRINTF(("dot clock: %u\n", dotclock));
 	for (i = 0; (div = radeonfb_dividers[i].divider) != 0; i++) {
+		if ((flags & NO_ODD_FBDIV) && ((div & 1) != 0)) continue;
 		outfreq = div * dotclock;
 		if ((outfreq >= sc->sc_minpll) &&
 		(outfreq <= sc->sc_maxpll)) {
@@ -2021,13 +2029,13 @@ radeonfb_pllwaitatomicread(struct radeon
 }
 
 void
-radeonfb_program_vclk(struct radeonfb_softc *sc, int dotclock, int crtc)
+radeonfb_program_vclk(struct radeonfb_softc *sc, int dotclock, int crtc, int flags)
 {
 	uint32_t	pbit = 0;
 	uint32_t	feed = 0;
 	uint32_t	data, refdiv, div0;
 
-	radeonfb_calc_dividers(sc, dotclock, , );
+	radeonfb_calc_dividers(sc, dotclock, , , flags);
 
 	if (crtc == 0) {
 
@@ -2190,6 +2198,21 @@ radeonfb_modeswitch(struct radeonfb_disp
 	for (i = 0; i < dp->rd_ncrtcs; i++)
 		radeonfb_setcrtc(dp, i);
 
+#if 0
+	/*
+	 * DVO chip voodoo from xf86-video-radeon
+	 * apparently this is needed for some powerbooks with DVI outputs
+	 */
+
+	uint8_t data[5][2] = {{0x8, 0x030}, {0x9, 0}, {0xa, 0x90}, {0xc, 0x89}, {0x8, 0x3b}};
+	int n = 0;
+	iic_acquire_bus(>sc_i2c[0].ric_controller, 0);
+	for (i = 0; i < 5; i++)
+		n += iic_exec(>sc_i2c[0].ric_controller, I2C_OP_WRITE, 0x38, data[i], 2, NULL, 0, 0);
+	iic_release_bus(>sc_i2c[0].ric_controller, 0);
+	printf("n = %d\n", n);
+#endif
+
 	/* activate the display */
 	radeonfb_blank(dp, 0);
 }
@@ -2197,7 +2220,7 @@ radeonfb_modeswitch(struct radeonfb_disp
 void
 radeonfb_setcrtc(struct radeonfb_display *dp, int index)
 {
-	int			crtc;
+	int			crtc, flags = 0;
 	struct videomode	*mode;
 	struct radeonfb_softc	*sc;
 	struct radeonfb_crtc	*cp;
@@ 

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

2017-08-25 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri Aug 25 22:23:59 UTC 2017

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S trap.c

Log Message:
- reorder faultbuf member.
- introduce trap() and interrupt(). now brk insn work.
-


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/aarch64/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/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.3 src/sys/arch/aarch64/aarch64/locore.S:1.4
--- src/sys/arch/aarch64/aarch64/locore.S:1.3	Fri Aug 25 21:43:49 2017
+++ src/sys/arch/aarch64/aarch64/locore.S	Fri Aug 25 22:23:59 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.3 2017/08/25 21:43:49 nisimura Exp $ */
+/* $NetBSD: locore.S,v 1.4 2017/08/25 22:23:59 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include "opt_ddb.h"
 
-RCSID("$NetBSD: locore.S,v 1.3 2017/08/25 21:43:49 nisimura Exp $")
+RCSID("$NetBSD: locore.S,v 1.4 2017/08/25 22:23:59 nisimura Exp $")
 
 // XXX:AARCH64
 lr	.req	x30
@@ -304,10 +304,10 @@ ENTRY(cpu_set_onfault)
 	stp	x23, x24, [x0, #32]
 	stp	x25, x26, [x0, #48]
 	stp	x27, x28, [x0, #64]
-	stp	x29, x9, [x0, #80]
-	stp	lr, x1, [x0, #96]
-	mrs	x3, tpidr_el1		/* curcpu */
-	ldr	x2, [x3, #CI_CURLWP]	/* curlwp */
+	stp	x29, lr, [x0, #80]
+	stp	x9, x1, [x0, #96]
+	mrs	x3, tpidr_el1
+	ldr	x2, [x3, #CI_CURLWP]	/* curlwp = curcpu()->ci_curlwp */
 	str	x0, [x2, #L_MD_ONFAULT] /* l_md.md_onfault = fb */
 	mov	x0, #0
 END(cpu_set_onfault)

Index: src/sys/arch/aarch64/aarch64/trap.c
diff -u src/sys/arch/aarch64/aarch64/trap.c:1.2 src/sys/arch/aarch64/aarch64/trap.c:1.3
--- src/sys/arch/aarch64/aarch64/trap.c:1.2	Wed Aug 16 22:48:11 2017
+++ src/sys/arch/aarch64/aarch64/trap.c	Fri Aug 25 22:23:59 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.2 2017/08/16 22:48:11 nisimura Exp $ */
+/* $NetBSD: trap.c,v 1.3 2017/08/25 22:23:59 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,21 +31,105 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.2 2017/08/16 22:48:11 nisimura Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.3 2017/08/25 22:23:59 nisimura Exp $");
 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
+
+#include 
+#include 
+#include 
 
 #include 
 
+static void
+dump_trapframe(struct trapframe *tf, void (*pr)(const char *, ...))
+{
+	(*pr)("trapframe @ %p:\n", tf);
+	(*pr)("esr=%016"PRIxREGISTER
+	",  pc=%016"PRIxREGISTER
+	",  lr=%016"PRIxREGISTER
+	",  sp=%016"PRIxREGISTER"\n",
+	tf->tf_esr, tf->tf_pc, tf->tf_lr, tf->tf_sp);
+	(*pr)(" x0=%016"PRIxREGISTER
+	",  x1=%016"PRIxREGISTER
+	",  x2=%016"PRIxREGISTER
+	",  x3=%016"PRIxREGISTER"\n",
+	tf->tf_reg[0], tf->tf_reg[1], tf->tf_reg[2], tf->tf_reg[3]);
+	(*pr)(" x4=%016"PRIxREGISTER
+	",  x5=%016"PRIxREGISTER
+	",  x6=%016"PRIxREGISTER
+	",  x7=%016"PRIxREGISTER"\n",
+	tf->tf_reg[4], tf->tf_reg[5], tf->tf_reg[6], tf->tf_reg[7]);
+	(*pr)(" x8=%016"PRIxREGISTER
+	",  x9=%016"PRIxREGISTER
+	", x10=%016"PRIxREGISTER
+	", x11=%016"PRIxREGISTER"\n",
+	tf->tf_reg[8], tf->tf_reg[9], tf->tf_reg[10], tf->tf_reg[11]);
+	(*pr)("x12=%016"PRIxREGISTER
+	", x13=%016"PRIxREGISTER
+	", x14=%016"PRIxREGISTER
+	", x15=%016"PRIxREGISTER"\n",
+	tf->tf_reg[12], tf->tf_reg[13], tf->tf_reg[14], tf->tf_reg[15]);
+	(*pr)("x16=%016"PRIxREGISTER
+	", x17=%016"PRIxREGISTER
+	", x18=%016"PRIxREGISTER
+	", x19=%016"PRIxREGISTER"\n",
+	tf->tf_reg[16], tf->tf_reg[17], tf->tf_reg[18], tf->tf_reg[19]);
+	(*pr)("x20=%016"PRIxREGISTER
+	", x21=%016"PRIxREGISTER
+	", x22=%016"PRIxREGISTER
+	", x23=%016"PRIxREGISTER"\n",
+	tf->tf_reg[20], tf->tf_reg[21], tf->tf_reg[22], tf->tf_reg[23]);
+	(*pr)("x24=%016"PRIxREGISTER
+	", x25=%016"PRIxREGISTER
+	", x26=%016"PRIxREGISTER
+	", x27=%016"PRIxREGISTER"\n",
+	tf->tf_reg[24], tf->tf_reg[25], tf->tf_reg[26], tf->tf_reg[27]);
+	(*pr)("x28=%016"PRIxREGISTER
+	", x29=%016"PRIxREGISTER
+	", x30=%016"PRIxREGISTER"\n",
+	tf->tf_reg[28], tf->tf_reg[29], tf->tf_reg[30]);
+}
+
 void
 userret(struct lwp *l, struct trapframe *tf)
 {
 	mi_userret(l);
 }
 
+void
+trap(struct trapframe *tf, int reason)
+{
+	struct lwp * const l = curlwp;
+	size_t code = tf->tf_esr & 0x;
+	bool usertrap_p = tf->tf_esr & 01;
+	bool ok = true;
+	ksiginfo_t ksi;
+
+	code = code;
+	dump_trapframe(tf, printf);
+
+	if (usertrap_p) {
+		if (!ok)
+			(*l->l_proc->p_emul->e_trapsignal)(l, );
+		userret(l, tf);
+	}
+	else if (!ok) {
+		dump_trapframe(tf, printf);
+		panic("%s: fatal kernel trap", __func__);
+	}
+}
+
+void
+interrupt(struct trapframe *tf)
+{
+}
+
 // XXXAARCH64 might be populated in frame.h in future
 
 #define FB_X19	0
@@ -59,8 

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

2017-08-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Aug 25 21:52:01 UTC 2017

Modified Files:
src/sys/arch/arm/sunxi: sunxi_timer.c

Log Message:
Use the 64-bit counter as timecounter, and only use it in UP configs.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_timer.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/sunxi/sunxi_timer.c
diff -u src/sys/arch/arm/sunxi/sunxi_timer.c:1.1 src/sys/arch/arm/sunxi/sunxi_timer.c:1.2
--- src/sys/arch/arm/sunxi/sunxi_timer.c:1.1	Fri Aug 25 00:07:03 2017
+++ src/sys/arch/arm/sunxi/sunxi_timer.c	Fri Aug 25 21:52:01 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_timer.c,v 1.1 2017/08/25 00:07:03 jmcneill Exp $ */
+/* $NetBSD: sunxi_timer.c,v 1.2 2017/08/25 21:52:01 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_timer.c,v 1.1 2017/08/25 00:07:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_timer.c,v 1.2 2017/08/25 21:52:01 jmcneill Exp $");
 
 #include 
 #include 
@@ -57,6 +57,12 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_timer.
 #define	 TMR0_CTRL_EN		__BIT(0)
 #define	TMR0_INTV_VALUE_REG	0x14
 #define	TMR0_CURNT_VALUE_REG	0x18
+#define	COUNTER64_CTRL_REG	0xa0
+#define	 COUNTER64_CTRL_CLK_SRC_SEL	__BIT(2)
+#define	 COUNTER64_CTRL_RLATCH_EN	__BIT(1)
+#define	 COUNTER64_CTRL_CLR_EN		__BIT(0)
+#define	COUNTER64_LOW_REG	0xa4
+#define	COUNTER64_HI_REG	0xa8
 
 static const char * const compatible[] = {
 	"allwinner,sun4i-a10-timer",
@@ -126,8 +132,17 @@ static u_int
 sunxi_timer_get_timecount(struct timecounter *tc)
 {
 	struct sunxi_timer_softc * const sc = tc->tc_priv;
+	uint32_t val;
 
-	return ~TIMER_READ(sc, TMR0_CURNT_VALUE_REG);
+	/* Enable read latch and wait for it to clear */
+	val = TIMER_READ(sc, COUNTER64_CTRL_REG);
+	val |= COUNTER64_CTRL_RLATCH_EN;
+	TIMER_WRITE(sc, COUNTER64_CTRL_REG, val);
+	do {
+		val = TIMER_READ(sc, COUNTER64_CTRL_REG);
+	} while (val & COUNTER64_CTRL_RLATCH_EN);
+
+	return TIMER_READ(sc, COUNTER64_LOW_REG);
 }
 
 static int
@@ -147,6 +162,7 @@ sunxi_timer_attach(device_t parent, devi
 	const int phandle = faa->faa_phandle;
 	bus_addr_t addr;
 	bus_size_t size;
+	uint32_t val;
 
 	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
 		aprint_error(": couldn't get registers\n");
@@ -180,12 +196,17 @@ sunxi_timer_attach(device_t parent, devi
 	__SHIFTIN(TMR0_CTRL_CLK_SRC_OSC24M, TMR0_CTRL_CLK_SRC) |
 	TMR0_CTRL_RELOAD | TMR0_CTRL_EN);
 
+	/* Set 64-bit counter source to OSC24M */
+	val = TIMER_READ(sc, COUNTER64_CTRL_REG);
+	val &= ~COUNTER64_CTRL_CLK_SRC_SEL;
+	TIMER_WRITE(sc, COUNTER64_CTRL_REG, val);
+
 	/* Timecounter setup */
 	tc->tc_get_timecount = sunxi_timer_get_timecount;
 	tc->tc_counter_mask = ~0u,
 	tc->tc_frequency = clk_get_rate(sc->sc_clk);
-	tc->tc_name = device_xname(self);
-	tc->tc_quality = 100;
+	tc->tc_name = "CNT64";
+	tc->tc_quality = arm_has_mpext_p ? -1 : 200;
 	tc->tc_priv = sc;
 	tc_init(tc);
 



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

2017-08-25 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri Aug 25 21:43:49 UTC 2017

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

Log Message:
make them better shape


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/aarch64/locore.S

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.2 src/sys/arch/aarch64/aarch64/locore.S:1.3
--- src/sys/arch/aarch64/aarch64/locore.S:1.2	Wed Aug 16 22:49:05 2017
+++ src/sys/arch/aarch64/aarch64/locore.S	Fri Aug 25 21:43:49 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.2 2017/08/16 22:49:05 nisimura Exp $ */
+/* $NetBSD: locore.S,v 1.3 2017/08/25 21:43:49 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -34,10 +34,16 @@
 
 #include "opt_ddb.h"
 
-RCSID("$NetBSD: locore.S,v 1.2 2017/08/16 22:49:05 nisimura Exp $")
+RCSID("$NetBSD: locore.S,v 1.3 2017/08/25 21:43:49 nisimura Exp $")
 
 // XXX:AARCH64
 lr	.req	x30
+	.macro DISABLE_INTERRUPT
+	msr	daifset, #DAIF_I|DAIF_F		/* daif'set */
+	.endm
+	.macro ENABLE_INTERRUPT
+	msr	daifclr, #DAIF_I|DAIF_F		/* daif'clr */
+	.endm
 
 /*
  * At IPL_SCHED:
@@ -50,9 +56,9 @@ ENTRY_NP(cpu_switchto)
 	cbz	x0, .Lrestore_lwp
 
 	/*
-	 * Store the callee saved register on the stack in a trapframe
+	 * Store the callee saved register on the stack.
 	 */
-	sub	sp, sp, #TF_SIZE
+	sub	sp, sp, #TF_SIZE		/* make switchframe */
 	stp	x19, x20, [sp, #TF_X19]
 	stp	x21, x22, [sp, #TF_X21]
 	stp	x23, x24, [sp, #TF_X23]
@@ -61,20 +67,20 @@ ENTRY_NP(cpu_switchto)
 	stp	x29, x30, [sp, #TF_X29]
 
 	/*
-	 * Get the previous trapframe pointer and the user writeable Thread ID
-	 * register and save them in the trap frame.
+	 * Save the previous trapframe pointer and EL0 thread ID in the
+	 * switchframe.
 	 */
 	ldr	x5, [x0, #L_MD_KTF]
 	mrs	x4, tpidr_el0
 #if TF_TPIDR + 8 == TF_CHAIN
-	str	x4, x5, [sp, #TF_TPIDR]
+	stp	x4, x5, [sp, #TF_TPIDR]
 #else
 	str	x4, [sp, #TF_TPIDR]
 	str	x5, [sp, #TF_CHAIN]
 #endif
 
 	/*
-	 * Get the current stack pointer and the CPACR and save them in
+	 * Save the current stack pointer and the CPACR and save them in
 	 * old lwp md area.
 	 */
 	mov	x4, sp 
@@ -90,48 +96,109 @@ ENTRY_NP(cpu_switchto)
 
 .Lrestore_lwp:
 #if L_MD_KTF + 8 == L_MD_CPACR
-	ldp	x4, x5, [x1, #L_MD_KTF]	// get trapframe ptr and cpacr_el1
+	ldp	x4, x5, [x1, #L_MD_KTF]	/* get trapframe ptr and cpacr_el1 */
 #else
-	ldr	x4, [x0, #L_MD_KTF]	// get trapframe ptr (aka SP)
-	ldr	x5, [x0, #L_MD_CPACR]	// get cpacr_el1
+	ldr	x4, [x1, #L_MD_KTF]	/* get trapframe ptr (aka SP) */
+	ldr	x5, [x1, #L_MD_CPACR]	/* get cpacr_el1 */
 #endif
-	mov	sp, x4			// restore stack pointer
-	msr	cpacr_el1, x5		// restore cpacr_el1
+	mov	sp, x4			/* restore stack pointer */
+	msr	cpacr_el1, x5		/* restore cpacr_el1 */
 
-	ldr	x4, [sp, #TF_TPIDR]	// load user writeable thread ip reg
-	msr	tpidr_el0, x4		// restore it
+	ldr	x4, [sp, #TF_TPIDR]
+	msr	tpidr_el0, x4		/* restore EL0 thread ID */
 
-	mrs	x3, tpidr_el1		// get curcpu
-	str	x1, [x3, #CI_CURLWP]	// show as curlwp
+	mrs	x3, tpidr_el1
+	str	x1, [x3, #CI_CURLWP]	/* switch curlwp to new lwp */
 
 	/*
-	 * Restore callee save registers
+	 * Restore callee save registers.
 	 */
 	ldp	x19, x20, [sp, #TF_X19]
 	ldp	x21, x22, [sp, #TF_X21]
 	ldp	x23, x24, [sp, #TF_X23]
 	ldp	x25, x26, [sp, #TF_X25]
 	ldp	x27, x28, [sp, #TF_X27]
-	ldp	x29, x30, [sp, #TF_X29]
-	add	sp, sp, #TF_SIZE	/* pop trapframe from stack */
+	ldp	x29, lr, [sp, #TF_X29]
+	add	sp, sp, #TF_SIZE	/* unwind switchframe */
 
 	ret
 END(cpu_switchto)
 
 /*
- *	x0 = lwp
- *	x1 = ipl
+ * void
+ * cpu_switchto_softint(struct lwp *softlwp, int ipl)
+ * {
+ *	build a switchframe on kernel stack.
+ *	craft TF_X30 to have softint_cleanup.
+ *	pinned_lwp = curlwp
+ *	switch to softlwp context.
+ *	call softint_dispatch(pinned_lwp, ipl);
+ *	switch back to pinned_lwp context.
+ *	unwind switchframe made on kernel stack.
+ *	return to caller this time.
+ * }
  */
 ENTRY_NP(cpu_switchto_softint)
-//
-//XXXAARCH64
-//
+	sub	sp, sp, #TF_SIZE	/* make switchframe */
+	adr	x2, softint_cleanup
+	stp	x19, x20, [sp, #TF_X19]
+	stp	x21, x22, [sp, #TF_X21]
+	stp	x23, x24, [sp, #TF_X23]
+	stp	x25, x26, [sp, #TF_X25]
+	stp	x27, x28, [sp, #TF_X27]
+	stp	x29, x2, [sp, #TF_X29]	/* tf->lr = softint_cleanup; */
+
+	mrs	x3, tpidr_el1
+	ldr	x2, [x3, #CI_CURLWP]	/* x2 := curcpu()->ci_curlwp */
+	mov	x4, sp			/* x4 := sp */
+	DISABLE_INTERRUPT
+	str	x4, [x2, #L_MD_KTF]	/* curlwp->l_md_ktf := sp */
+	str	x0, [x3, #CI_CURLWP]	/* curcpu()->ci_curlwp = softlwp; */
+	ldr	x4, [x0, #L_MD_KTF]	/* switch to softlwp stack */
+	mov	sp, x4			/* new sp := softlwp->l_md_ktf */
+	ENABLE_INTERRUPT
+	mov	x19, x2			/* x19 := pinned_lwp */
+	mov	x20, lr			/* x20 := original lr */
+
+	/* softint_dispatch(pinned_lwp, ipl) */
+	mov	x0, x19
+	bl	

CVS commit: xsrc/external/mit/xf86-input-keyboard/dist/src

2017-08-25 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Fri Aug 25 21:27:34 UTC 2017

Modified Files:
xsrc/external/mit/xf86-input-keyboard/dist/src: bsd_KbdMap.c

Log Message:
fix tpyo


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.c

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

Modified files:

Index: xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.c
diff -u xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.c:1.12 xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.c:1.13
--- xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.c:1.12	Sun Mar  5 08:05:23 2017
+++ xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.c	Fri Aug 25 21:27:34 2017
@@ -1226,7 +1226,7 @@ static CARD8 wsSunMap[] = {
 	/* 0x01 */ KEY_L1,		/* stop */
 	/* 0x02 */ KEY_AudioLower,	/* BrightnessDown / S-VolumeDown */
 	/* 0x03 */ KEY_L2,		/* again */
-	/* 0x04 */ KEY_AudioRaise,	/* BridgtnessUp / S-VolumeUp */
+	/* 0x04 */ KEY_AudioRaise,	/* BrightnessUp / S-VolumeUp */
 	/* 0x05 */ KEY_F1,
 	/* 0x06 */ KEY_F2,
 	/* 0x07 */ KEY_F10,



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

2017-08-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Aug 25 20:36:16 UTC 2017

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

Log Message:
The assertion at the bottom of intr_ipi_send is invalid for UP configs; add
a text for arm_cpu_max == 1


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/arm/pic/pic.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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.37 src/sys/arch/arm/pic/pic.c:1.38
--- src/sys/arch/arm/pic/pic.c:1.37	Thu Jun  1 02:45:06 2017
+++ src/sys/arch/arm/pic/pic.c	Fri Aug 25 20:36:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.37 2017/06/01 02:45:06 chs Exp $	*/
+/*	$NetBSD: pic.c,v 1.38 2017/08/25 20:36:16 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.37 2017/06/01 02:45:06 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.38 2017/08/25 20:36:16 jmcneill Exp $");
 
 #include 
 #include 
@@ -206,7 +206,7 @@ intr_ipi_send(const kcpuset_t *kcp, u_lo
 			sent_p = true;
 		}
 	}
-	KASSERT(cold || sent_p);
+	KASSERT(cold || sent_p || arm_cpu_max == 1);
 }
 #endif /* MULTIPROCESSOR */
 



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

2017-08-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Aug 25 17:43:33 UTC 2017

Modified Files:
src/sys/arch/arm/include: cpufunc_proto.h

Log Message:
fix the build (rump does not have opt_foo.h)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/include/cpufunc_proto.h

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

Modified files:

Index: src/sys/arch/arm/include/cpufunc_proto.h
diff -u src/sys/arch/arm/include/cpufunc_proto.h:1.6 src/sys/arch/arm/include/cpufunc_proto.h:1.7
--- src/sys/arch/arm/include/cpufunc_proto.h:1.6	Thu Aug 24 10:19:36 2017
+++ src/sys/arch/arm/include/cpufunc_proto.h	Fri Aug 25 13:43:33 2017
@@ -44,7 +44,9 @@
 
 #ifdef _KERNEL
 
-#include "opt_multiprocessor.h"
+#if !defined(_MODULE) && defined(_KERNEL_OPT)
+# include "opt_multiprocessor.h"
+#endif
 
 #include 
 #include 



CVS commit: src/doc

2017-08-25 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Aug 25 15:06:51 UTC 2017

Modified Files:
src/doc: BRANCHES

Log Message:
matt-timespec never saw any actual commits, so it has been removed.


To generate a diff of this commit:
cvs rdiff -u -r1.342 -r1.343 src/doc/BRANCHES

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

Modified files:

Index: src/doc/BRANCHES
diff -u src/doc/BRANCHES:1.342 src/doc/BRANCHES:1.343
--- src/doc/BRANCHES:1.342	Sun Jun  4 07:17:09 2017
+++ src/doc/BRANCHES	Fri Aug 25 15:06:51 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: BRANCHES,v 1.342 2017/06/04 07:17:09 snj Exp $
+#	$NetBSD: BRANCHES,v 1.343 2017/08/25 15:06:51 joerg Exp $
 #
 # This file contains a list of branches that exist in the NetBSD CVS
 # tree and their current state.
@@ -548,17 +548,6 @@ Scope:		kernel (OMAP3 support, device dr
 Notes:		Do not hesitate to communicate any change that would be welcome
 		in HEAD.
 
-Branch:		matt-timespec
-Description:	Convert the kernel to struct timespec as its primary time
-		storage mechanism.
-Status:		Inactive
-Start Date:	2005-02-19
-End Date:
-Base Tag:	
-Maintainer:	Matt Thomas 
-Scope:		kernel
-Notes:	
-
 Branch:		matt-mips64
 Description:	Rototill the mips code to support LP64 mips and N32/N64 ABIs
 Status:		Mostly dead



CVS commit: [netbsd-8] src/doc

2017-08-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 25 14:40:11 UTC 2017

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

Log Message:
Ticket #211


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.42 -r1.1.2.43 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.42 src/doc/CHANGES-8.0:1.1.2.43
--- src/doc/CHANGES-8.0:1.1.2.42	Fri Aug 25 05:56:00 2017
+++ src/doc/CHANGES-8.0	Fri Aug 25 14:40:11 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.42 2017/08/25 05:56:00 snj Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.43 2017/08/25 14:40:11 martin Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -5334,3 +5334,8 @@ sys/arch/i386/conf/GENERIC			1.1158
 	i386 GENERIC: Disable VM86 by default.
 	[maxv, ticket #230]
 
+etc/etc.evbarm/Makefile.inc			1.83-1.84
+
+	Replace ALLWINNER_A80 (it's never really worked) with VEXPRESS_A15.
+	[snj, ticket #211]
+



CVS commit: [netbsd-8] src/etc/etc.evbarm

2017-08-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 25 14:38:31 UTC 2017

Modified Files:
src/etc/etc.evbarm [netbsd-8]: Makefile.inc

Log Message:
Pull up following revision(s) (requested by snj in ticket #211):
etc/etc.evbarm/Makefile.inc: revision 1.83
etc/etc.evbarm/Makefile.inc: revision 1.84
Replace ALLWINNER_A80 (it's never really worked) with VEXPRESS_A15.
Idea from jmcneill@
Don't try and build VEXPRESS_A15_INSTALL


To generate a diff of this commit:
cvs rdiff -u -r1.81.6.2 -r1.81.6.3 src/etc/etc.evbarm/Makefile.inc

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

Modified files:

Index: src/etc/etc.evbarm/Makefile.inc
diff -u src/etc/etc.evbarm/Makefile.inc:1.81.6.2 src/etc/etc.evbarm/Makefile.inc:1.81.6.3
--- src/etc/etc.evbarm/Makefile.inc:1.81.6.2	Thu Jul 20 01:18:42 2017
+++ src/etc/etc.evbarm/Makefile.inc	Fri Aug 25 14:38:31 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.81.6.2 2017/07/20 01:18:42 snj Exp $
+#	$NetBSD: Makefile.inc,v 1.81.6.3 2017/08/25 14:38:31 martin Exp $
 #
 #	etc.evbarm/Makefile.inc -- evbarm-specific etc Makefile targets
 #
@@ -18,8 +18,8 @@ IMAGEENDIAN=	be
 KERNEL_SETS.armv4+=		IXM1200
 EVBARM_BOARDS.xscale+=		ADI_BRH
 KERNEL_SETS.xscale+=		NSLU2
-EVBARM_BOARDS.armv7+=		ALLWINNER_A80
-EVBARM_BOARDS.armv7hf+=		ALLWINNER_A80
+KERNEL_SETS.armv7+=		VEXPRESS_A15
+KERNEL_SETS.armv7hf+=		VEXPRESS_A15
 EVBARM_BOARDS.armv7+=		BCM5301X
 EVBARM_BOARDS.armv7hf+=		BCM5301X
 #EVBARM_BOARDS.armv7+=		BCM56340
@@ -76,8 +76,8 @@ KERNEL_SETS.armv6hf+=	 	RPI2
 EVBARM_BOARDS.armv6+=		TISDP2420
 EVBARM_BOARDS.armv6hf+= 	TISDP2420
 #EVBARM_BOARDS.armv6+=		TISDP2430
-EVBARM_BOARDS.armv7+=		ALLWINNER_A80
-EVBARM_BOARDS.armv7hf+=		ALLWINNER_A80
+KERNEL_SETS.armv7+=		VEXPRESS_A15
+KERNEL_SETS.armv7hf+=		VEXPRESS_A15
 EVBARM_BOARDS.armv7+=		ARMADAXP
 EVBARM_BOARDS.armv7hf+=		ARMADAXP
 EVBARM_BOARDS.armv7+=		BCM5301X



CVS commit: src/sys/external/bsd/drm2/linux

2017-08-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 25 14:14:44 UTC 2017

Modified Files:
src/sys/external/bsd/drm2/linux: linux_ww_mutex.c

Log Message:
Fix lockdebug_locked annotations.

When thread A grants ownership to thread B waiting with a context,
thread B needs to assert lockdebug_locked; otherwise, when it
releases, lockdebug_unlocked thinks it's releasing an unlocked
ww_mutex.

Fixes LOCKDEBUG failure with radeon noticed by martin@.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/linux/linux_ww_mutex.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/external/bsd/drm2/linux/linux_ww_mutex.c
diff -u src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.2 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.3
--- src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.2	Thu May 21 21:55:55 2015
+++ src/sys/external/bsd/drm2/linux/linux_ww_mutex.c	Fri Aug 25 14:14:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_ww_mutex.c,v 1.2 2015/05/21 21:55:55 riastradh Exp $	*/
+/*	$NetBSD: linux_ww_mutex.c,v 1.3 2017/08/25 14:14:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.2 2015/05/21 21:55:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.3 2017/08/25 14:14:44 riastradh Exp $");
 
 #include 
 #include 
@@ -334,7 +334,6 @@ retry:	switch (mutex->wwm_state) {
 	case WW_UNLOCKED:
 		mutex->wwm_state = WW_OWNED;
 		mutex->wwm_u.owner = curlwp;
-		WW_LOCKED(mutex);
 		break;
 	case WW_OWNED:
 		KASSERTMSG((mutex->wwm_u.owner != curlwp),
@@ -356,6 +355,7 @@ retry:	switch (mutex->wwm_state) {
 	}
 	KASSERT(mutex->wwm_state == WW_OWNED);
 	KASSERT(mutex->wwm_u.owner == curlwp);
+	WW_LOCKED(mutex);
 	mutex_exit(>wwm_lock);
 }
 
@@ -369,7 +369,6 @@ retry:	switch (mutex->wwm_state) {
 	case WW_UNLOCKED:
 		mutex->wwm_state = WW_OWNED;
 		mutex->wwm_u.owner = curlwp;
-		WW_LOCKED(mutex);
 		break;
 	case WW_OWNED:
 		KASSERTMSG((mutex->wwm_u.owner != curlwp),
@@ -395,6 +394,7 @@ retry:	switch (mutex->wwm_state) {
 	}
 	KASSERT(mutex->wwm_state == WW_OWNED);
 	KASSERT(mutex->wwm_u.owner == curlwp);
+	WW_LOCKED(mutex);
 	ret = 0;
 out:	mutex_exit(>wwm_lock);
 	return ret;
@@ -433,7 +433,6 @@ retry:	switch (mutex->wwm_state) {
 		WW_WANTLOCK(mutex);
 		mutex->wwm_state = WW_CTX;
 		mutex->wwm_u.ctx = ctx;
-		WW_LOCKED(mutex);
 		goto locked;
 	case WW_OWNED:
 		WW_WANTLOCK(mutex);
@@ -490,10 +489,11 @@ retry:	switch (mutex->wwm_state) {
 	 */
 	ww_mutex_lock_wait(mutex, ctx);
 
-locked:	ctx->wwx_acquired++;
-	KASSERT((mutex->wwm_state == WW_CTX) ||
+locked:	KASSERT((mutex->wwm_state == WW_CTX) ||
 	(mutex->wwm_state == WW_WANTOWN));
 	KASSERT(mutex->wwm_u.ctx == ctx);
+	WW_LOCKED(mutex);
+	ctx->wwx_acquired++;
 	mutex_exit(>wwm_lock);
 	return 0;
 }
@@ -531,7 +531,6 @@ retry:	switch (mutex->wwm_state) {
 		WW_WANTLOCK(mutex);
 		mutex->wwm_state = WW_CTX;
 		mutex->wwm_u.ctx = ctx;
-		WW_LOCKED(mutex);
 		goto locked;
 	case WW_OWNED:
 		WW_WANTLOCK(mutex);
@@ -597,6 +596,7 @@ retry:	switch (mutex->wwm_state) {
 locked:	KASSERT((mutex->wwm_state == WW_CTX) ||
 	(mutex->wwm_state == WW_WANTOWN));
 	KASSERT(mutex->wwm_u.ctx == ctx);
+	WW_LOCKED(mutex);
 	ctx->wwx_acquired++;
 	ret = 0;
 out:	mutex_exit(>wwm_lock);
@@ -634,7 +634,6 @@ retry:	switch (mutex->wwm_state) {
 	case WW_UNLOCKED:
 		mutex->wwm_state = WW_CTX;
 		mutex->wwm_u.ctx = ctx;
-		WW_LOCKED(mutex);
 		goto locked;
 	case WW_OWNED:
 		KASSERTMSG((mutex->wwm_u.owner != curlwp),
@@ -665,6 +664,7 @@ retry:	switch (mutex->wwm_state) {
 locked:	KASSERT((mutex->wwm_state == WW_CTX) ||
 	(mutex->wwm_state == WW_WANTOWN));
 	KASSERT(mutex->wwm_u.ctx == ctx);
+	WW_LOCKED(mutex);
 	ctx->wwx_acquired++;
 	mutex_exit(>wwm_lock);
 }
@@ -699,7 +699,6 @@ retry:	switch (mutex->wwm_state) {
 	case WW_UNLOCKED:
 		mutex->wwm_state = WW_CTX;
 		mutex->wwm_u.ctx = ctx;
-		WW_LOCKED(mutex);
 		goto locked;
 	case WW_OWNED:
 		KASSERTMSG((mutex->wwm_u.owner != curlwp),
@@ -736,6 +735,7 @@ retry:	switch (mutex->wwm_state) {
 locked:	KASSERT((mutex->wwm_state == WW_CTX) ||
 	(mutex->wwm_state == WW_WANTOWN));
 	KASSERT(mutex->wwm_u.ctx == ctx);
+	WW_LOCKED(mutex);
 	ctx->wwx_acquired++;
 	ret = 0;
 out:	mutex_exit(>wwm_lock);



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

2017-08-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Aug 25 12:28:51 UTC 2017

Modified Files:
src/sys/arch/arm/sunxi: sunxi_usbphy.c

Log Message:
Lookup reg resources by name instead of index; fixes USB on non-H3/A64 SoCs


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_usbphy.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/sunxi/sunxi_usbphy.c
diff -u src/sys/arch/arm/sunxi/sunxi_usbphy.c:1.4 src/sys/arch/arm/sunxi/sunxi_usbphy.c:1.5
--- src/sys/arch/arm/sunxi/sunxi_usbphy.c:1.4	Fri Aug 25 00:07:03 2017
+++ src/sys/arch/arm/sunxi/sunxi_usbphy.c	Fri Aug 25 12:28:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_usbphy.c,v 1.4 2017/08/25 00:07:03 jmcneill Exp $ */
+/* $NetBSD: sunxi_usbphy.c,v 1.5 2017/08/25 12:28:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_usbphy.c,v 1.4 2017/08/25 00:07:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_usbphy.c,v 1.5 2017/08/25 12:28:51 jmcneill Exp $");
 
 #include 
 #include 
@@ -194,7 +194,7 @@ sunxi_usbphy_attach(device_t parent, dev
 	sc->sc_bst = faa->faa_bst;
 	sc->sc_type = of_search_compatible(phandle, compat_data)->data;
 
-	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
+	if (fdtbus_get_reg_byname(phandle, "phy_ctrl", , ) != 0) {
 		aprint_error(": couldn't get phy ctrl registers\n");
 		return;
 	}
@@ -204,11 +204,14 @@ sunxi_usbphy_attach(device_t parent, dev
 	}
 
 	for (sc->sc_nphys = 0; sc->sc_nphys < SUNXI_MAXUSBPHY; sc->sc_nphys++) {
-		if (fdtbus_get_reg(phandle, sc->sc_nphys + 1, , ) != 0)
-			break;
 		phy = >sc_phys[sc->sc_nphys];
 		phy->phy_index = sc->sc_nphys;
-		if (bus_space_map(sc->sc_bst, addr, size, 0, >phy_bsh) != 0) {
+		snprintf(pname, sizeof(pname), "pmu%d", sc->sc_nphys);
+		if (fdtbus_get_reg_byname(phandle, pname, , ) != 0) {
+			/* There may be no registers for OTG PHY */
+			if (sc->sc_nphys > 0)
+break;
+		} else if (bus_space_map(sc->sc_bst, addr, size, 0, >phy_bsh) != 0) {
 			aprint_error(": failed to map reg #%d\n", sc->sc_nphys);
 			return;
 		}



CVS commit: src/sys/dev/fdt

2017-08-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Aug 25 12:28:10 UTC 2017

Modified Files:
src/sys/dev/fdt: fdt_subr.c fdtvar.h

Log Message:
Add fdtbus_get_reg_byname


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/fdt/fdt_subr.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/fdt/fdtvar.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/fdt/fdt_subr.c
diff -u src/sys/dev/fdt/fdt_subr.c:1.17 src/sys/dev/fdt/fdt_subr.c:1.18
--- src/sys/dev/fdt/fdt_subr.c:1.17	Wed Jul 19 20:18:07 2017
+++ src/sys/dev/fdt/fdt_subr.c	Fri Aug 25 12:28:10 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_subr.c,v 1.17 2017/07/19 20:18:07 jmcneill Exp $ */
+/* $NetBSD: fdt_subr.c,v 1.18 2017/08/25 12:28:10 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.17 2017/07/19 20:18:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.18 2017/08/25 12:28:10 jmcneill Exp $");
 
 #include 
 #include 
@@ -199,6 +199,32 @@ fdtbus_decode_range(int phandle, uint64_
 }
 
 int
+fdtbus_get_reg_byname(int phandle, const char *name, bus_addr_t *paddr,
+bus_size_t *psize)
+{
+	const char *reg_names, *p;
+	u_int index;
+	int len, resid;
+	int error = ENOENT;
+
+	reg_names = fdtbus_get_prop(phandle, "reg-names", );
+	if (len <= 0)
+		return error;
+
+	p = reg_names;
+	for (index = 0, resid = len; resid > 0; index++) {
+		if (strcmp(p, name) == 0) {
+			error = fdtbus_get_reg(phandle, index, paddr, psize);
+			break;
+		}
+		resid -= strlen(p);
+		p += strlen(p) + 1;
+	}
+
+	return error;
+}
+
+int
 fdtbus_get_reg(int phandle, u_int index, bus_addr_t *paddr, bus_size_t *psize)
 {
 	uint64_t addr, size;

Index: src/sys/dev/fdt/fdtvar.h
diff -u src/sys/dev/fdt/fdtvar.h:1.25 src/sys/dev/fdt/fdtvar.h:1.26
--- src/sys/dev/fdt/fdtvar.h:1.25	Sun Aug 13 18:27:11 2017
+++ src/sys/dev/fdt/fdtvar.h	Fri Aug 25 12:28:10 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.25 2017/08/13 18:27:11 jmcneill Exp $ */
+/* $NetBSD: fdtvar.h,v 1.26 2017/08/25 12:28:10 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -227,6 +227,8 @@ int		fdtbus_register_phy_controller(devi
 		const struct fdtbus_phy_controller_func *);
 
 int		fdtbus_get_reg(int, u_int, bus_addr_t *, bus_size_t *);
+int		fdtbus_get_reg_byname(int, const char *, bus_addr_t *,
+		bus_size_t *);
 int		fdtbus_get_reg64(int, u_int, uint64_t *, uint64_t *);
 int		fdtbus_get_phandle(int, const char *);
 int		fdtbus_get_phandle_from_native(int);



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

2017-08-25 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Aug 25 11:35:03 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: copy.S

Log Message:
Move incq outside of the copy section. No functional change, reduces
my smap diff.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/amd64/amd64/copy.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/copy.S
diff -u src/sys/arch/amd64/amd64/copy.S:1.23 src/sys/arch/amd64/amd64/copy.S:1.24
--- src/sys/arch/amd64/amd64/copy.S:1.23	Fri Aug 25 11:05:46 2017
+++ src/sys/arch/amd64/amd64/copy.S	Fri Aug 25 11:35:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: copy.S,v 1.23 2017/08/25 11:05:46 maxv Exp $	*/
+/*	$NetBSD: copy.S,v 1.24 2017/08/25 11:35:03 maxv Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -259,10 +259,9 @@ ENTRY(copyoutstr)
 	jae	1f
 	movq	%rax,%rdx
 	movq	%rax,%r8
-
-.Lcopyoutstr_start:
 1:	incq	%rdx
 
+.Lcopyoutstr_start:
 1:	decq	%rdx
 	jz	2f
 	lodsb
@@ -300,10 +299,9 @@ ENTRY(copyinstr)
 	jae	1f
 	movq	%rax,%rdx
 	movq	%rax,%r8
-
-.Lcopyinstr_start:
 1:	incq	%rdx
 
+.Lcopyinstr_start:
 1:	decq	%rdx
 	jz	2f
 	lodsb



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

2017-08-25 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Aug 25 11:05:46 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: copy.S

Log Message:
Split comment, otherwise it is misleading. kcopy operates on kernel
memory, and must *not* be used with userland pages.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/amd64/copy.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/copy.S
diff -u src/sys/arch/amd64/amd64/copy.S:1.22 src/sys/arch/amd64/amd64/copy.S:1.23
--- src/sys/arch/amd64/amd64/copy.S:1.22	Wed Aug 23 08:14:18 2017
+++ src/sys/arch/amd64/amd64/copy.S	Fri Aug 25 11:05:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: copy.S,v 1.22 2017/08/23 08:14:18 maxv Exp $	*/
+/*	$NetBSD: copy.S,v 1.23 2017/08/25 11:05:46 maxv Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -107,9 +107,6 @@ ENTRY(do_pmap_load)
 	ret
 
 /*
- * int kcopy(const void *from, void *to, size_t len);
- * Copy len bytes, abort on fault.
- *
  * Copy routines from and to userland, plus a few more. See the
  * section 9 manpages for info. Some cases can be optimized more.
  *
@@ -125,6 +122,10 @@ ENTRY(do_pmap_load)
  * be ably to do cache-line size copies
  */
 
+/*
+ * int kcopy(const void *from, void *to, size_t len);
+ * Copy len bytes from and to kernel memory, and abort on fault.
+ */
 ENTRY(kcopy)
 	xchgq	%rdi,%rsi
 	movq	%rdx,%rcx