CVS commit: src/sys/dev/bluetooth

2017-08-13 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Mon Aug 14 05:33:30 UTC 2017

Modified Files:
src/sys/dev/bluetooth: bth5.c

Log Message:
Conform to the spec. with regards to acknowlegment packets.  This prevents
the host controller from freezing.

Inmprove communication from inactive to active state.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/bluetooth/bth5.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/bluetooth/bth5.c
diff -u src/sys/dev/bluetooth/bth5.c:1.2 src/sys/dev/bluetooth/bth5.c:1.3
--- src/sys/dev/bluetooth/bth5.c:1.2	Fri Aug 11 00:58:37 2017
+++ src/sys/dev/bluetooth/bth5.c	Mon Aug 14 05:33:30 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bth5.c,v 1.2 2017/08/11 00:58:37 nat Exp $	*/
+/*	$NetBSD: bth5.c,v 1.3 2017/08/14 05:33:30 nat Exp $	*/
 /*
  * Copyright (c) 2017 Nathanial Sloss 
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.2 2017/08/11 00:58:37 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.3 2017/08/14 05:33:30 nat Exp $");
 
 #include 
 #include 
@@ -1076,13 +1076,14 @@ static void
 bth5_sequencing_receive(struct bth5_softc *sc, struct mbuf *m)
 {
 	bth5_hdr_t hdr;
-	uint32_t rxseq;
+	uint32_t exp_rxseq, rxseq;
 
+	exp_rxseq = sc->sc_seq_expected_rxseq & BTH5_FLAGS_SEQ_MASK;
 	m_copydata(m, 0, sizeof(bth5_hdr_t), );
 	rxseq = BTH5_FLAGS_SEQ(hdr.flags);
 
 	DPRINTFN(1, ("%s: seq receive: rxseq=%d, expected %d\n",
-	device_xname(sc->sc_dev), rxseq, sc->sc_seq_expected_rxseq));
+	device_xname(sc->sc_dev), rxseq, exp_rxseq));
 #ifdef BTH5_DEBUG
 	if (bth5_debug == 2)
 		bth5_packet_print(m);
@@ -1094,9 +1095,10 @@ bth5_sequencing_receive(struct bth5_soft
 	 */
 	m_adj(m, sizeof(bth5_hdr_t) - sizeof(uint8_t));
 
-	if (rxseq != sc->sc_seq_expected_rxseq) {
+	if (rxseq != exp_rxseq) {
 		m_freem(m);
 
+		bth5_send_ack_command(sc);
 		/* send ack packet, if needly */
 		bth5_mux_transmit(sc);
 
@@ -1144,10 +1146,15 @@ bth5_sequencing_receive(struct bth5_soft
 		break;
 	}
 
+	if (sc->sc_seq_expected_rxseq / sc->sc_seq_winsize  ==
+	 sc->sc_seq_winsize) {
+		bth5_send_ack_command(sc);
+		sc->sc_seq_txack = sc->sc_seq_expected_rxseq;
+	} else
+		sc->sc_seq_txack = rxseq;
+
 	sc->sc_seq_expected_rxseq =
-	(sc->sc_seq_expected_rxseq + 1) & BTH5_FLAGS_SEQ_MASK;
-	sc->sc_seq_txack = sc->sc_seq_expected_rxseq;
-	bth5_send_ack_command(sc);
+	(sc->sc_seq_expected_rxseq + 1);
 }
 
 static bool
@@ -1539,7 +1546,7 @@ bth5_input_le(struct bth5_softc *sc, str
 		} else if (*rcvpkt == *(const uint16_t *)syncresp) {
 			DPRINTF(("%s: state change to curious\n",
 			device_xname(sc->sc_dev)));
-
+			rplypkt = conf;
 			callout_schedule(>sc_le_timer,
 			BTH5_LE_TCONF_TIMEOUT);
 			sc->sc_le_state = le_state_curious;
@@ -1551,6 +1558,8 @@ bth5_input_le(struct bth5_softc *sc, str
 	case le_state_curious:
 		if (*rcvpkt == *(const uint16_t *)sync)
 			rplypkt = syncresp;
+		else if (*rcvpkt == *(const uint16_t *)syncresp)
+			rplypkt = conf;
 		else if (*rcvpkt == *(const uint16_t *)conf)
 			rplypkt = confresp;
 		else if (*rcvpkt == *(const uint16_t *)confresp) {



CVS commit: src/share/dict

2017-08-13 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug 14 05:29:02 UTC 2017

Modified Files:
src/share/dict: web2

Log Message:
Add potage, it's a stew (French loanword)

from Tom Ivar Helbekkmo


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/share/dict/web2

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

Modified files:

Index: src/share/dict/web2
diff -u src/share/dict/web2:1.35 src/share/dict/web2:1.36
--- src/share/dict/web2:1.35	Mon Aug 14 00:13:20 2017
+++ src/share/dict/web2	Mon Aug 14 05:29:02 2017
@@ -151394,6 +151394,7 @@ pot
 potability
 potable
 potableness
+potage
 potagerie
 potagery
 potamic



CVS commit: src/usr.sbin/btattach

2017-08-13 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Mon Aug 14 05:28:23 UTC 2017

Modified Files:
src/usr.sbin/btattach: init_bcm43xx.c

Log Message:
Set controller clock based on baud rate.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/btattach/init_bcm43xx.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/btattach/init_bcm43xx.c
diff -u src/usr.sbin/btattach/init_bcm43xx.c:1.3 src/usr.sbin/btattach/init_bcm43xx.c:1.4
--- src/usr.sbin/btattach/init_bcm43xx.c:1.3	Thu Aug 10 20:43:12 2017
+++ src/usr.sbin/btattach/init_bcm43xx.c	Mon Aug 14 05:28:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_bcm43xx.c,v 1.3 2017/08/10 20:43:12 jmcneill Exp $	*/
+/*	$NetBSD: init_bcm43xx.c,v 1.4 2017/08/14 05:28:23 nat Exp $	*/
 
 /*-
  * Copyright (c) 2017 Iain Hibbert
@@ -34,7 +34,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: init_bcm43xx.c,v 1.3 2017/08/10 20:43:12 jmcneill Exp $");
+__RCSID("$NetBSD: init_bcm43xx.c,v 1.4 2017/08/14 05:28:23 nat Exp $");
 
 #include 
 
@@ -56,11 +56,17 @@ __RCSID("$NetBSD: init_bcm43xx.c,v 1.3 2
 #define HCI_CMD_BCM43XX_SET_BDADDR		\
 	HCI_OPCODE(HCI_OGF_VENDOR, 0x006)
 
+#define HCI_CMD_BCM43XX_SET_CLOCK		\
+	HCI_OPCODE(HCI_OGF_VENDOR, 0x045)
+
 #define HCI_CMD_43XXFWDN 			\
 	HCI_OPCODE(HCI_OGF_VENDOR, 0x02e)
 
 #define HCI_CMD_GET_LOCAL_NAME			0x0c14
 
+#define BCM43XX_CLK_48	1
+#define BCM43XX_CLK_24	2
+
 static int
 bcm43xx_get_local_name(int fd, char *name, size_t namelen)
 {
@@ -85,7 +91,7 @@ bcm43xx_get_local_name(int fd, char *nam
 void
 init_bcm43xx(int fd, unsigned int speed)
 {
-	uint8_t rate[6];
+	uint8_t rate[6], clock;
 	uint8_t fw_buf[1024];
 	int fwfd, fw_len;
 	uint8_t resp[7];
@@ -134,6 +140,14 @@ init_bcm43xx(int fd, unsigned int speed)
 	uart_recv_cc(fd, HCI_CMD_RESET, , sizeof(resp));
 	/* assume it succeeded? */
 
+	if (speed >= 300) 
+		clock = BCM43XX_CLK_48;
+	else
+		clock = BCM43XX_CLK_24;
+
+	uart_send_cmd(fd, HCI_CMD_BCM43XX_SET_CLOCK, , sizeof(clock));
+	uart_recv_cc(fd, HCI_CMD_BCM43XX_SET_CLOCK, , sizeof(resp));
+
 	rate[2] = speed;
 	rate[3] = speed >> 8;
 	rate[4] = speed >> 16;



CVS commit: src/share/mk

2017-08-13 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Aug 14 02:21:50 UTC 2017

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

Log Message:
swtich luna68k to xorg-server 1.18.  tested by tsutsui@.


To generate a diff of this commit:
cvs rdiff -u -r1.1013 -r1.1014 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.1013 src/share/mk/bsd.own.mk:1.1014
--- src/share/mk/bsd.own.mk:1.1013	Fri Aug  4 22:27:37 2017
+++ src/share/mk/bsd.own.mk	Mon Aug 14 02:21:50 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.1013 2017/08/04 22:27:37 mrg Exp $
+#	$NetBSD: bsd.own.mk,v 1.1014 2017/08/14 02:21:50 mrg Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -1361,7 +1361,6 @@ X11SRCDIR.${_proto}proto?=		${X11SRCDIRM
 ${MACHINE} == "hpcarm"	|| \
 ${MACHINE} == "hpcmips"	|| \
 ${MACHINE} == "hpcsh"	|| \
-${MACHINE} == "luna68k"	|| \
 ${MACHINE} == "mac68k"	|| \
 ${MACHINE} == "netwinder"	|| \
 ${MACHINE} == "newsmips"	|| \



CVS commit: src/share/dict

2017-08-13 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug 14 00:13:20 UTC 2017

Modified Files:
src/share/dict: web2

Log Message:
potate isn't a word (at least not in English), remove it

>From Steve Wart


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/share/dict/web2

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

Modified files:

Index: src/share/dict/web2
diff -u src/share/dict/web2:1.34 src/share/dict/web2:1.35
--- src/share/dict/web2:1.34	Wed Jun 21 14:27:30 2017
+++ src/share/dict/web2	Mon Aug 14 00:13:20 2017
@@ -151419,7 +151419,6 @@ potassamide
 potassic
 potassiferous
 potassium
-potate
 potation
 potative
 potato



CVS commit: src/sys/dev/usb

2017-08-13 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Aug 13 22:29:42 UTC 2017

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

Log Message:
Always try to set USB HID devices into Report Protocol.  (Unless the
device is known to be quirky.)

Some of the most-widely-compatible methods of implementing USB Keyboard
NKRO depend on this Request to function as designed.

Issuing this Request is recommended by the HID 1.11 spec (7.2.6):

... "the host should not make any assumptions about the device's state
and should set the desired protocol whenever initializing a device."


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/usb/uhidev.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/uhidev.c
diff -u src/sys/dev/usb/uhidev.c:1.70 src/sys/dev/usb/uhidev.c:1.71
--- src/sys/dev/usb/uhidev.c:1.70	Thu Jun  1 02:45:12 2017
+++ src/sys/dev/usb/uhidev.c	Sun Aug 13 22:29:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhidev.c,v 1.70 2017/06/01 02:45:12 chs Exp $	*/
+/*	$NetBSD: uhidev.c,v 1.71 2017/08/13 22:29:42 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 2001, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.70 2017/06/01 02:45:12 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.71 2017/08/13 22:29:42 jakllsch Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -153,12 +153,9 @@ uhidev_attach(device_t parent, device_t 
 		aprint_error_dev(self, "couldn't establish power handler\n");
 
 	(void)usbd_set_idle(iface, 0, 0);
-#if 0
 
-	if ((usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_NO_SET_PROTO) == 0 &&
-	id->bInterfaceSubClass != UISUBCLASS_BOOT)
+	if ((usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_NO_SET_PROTO) == 0)
 		(void)usbd_set_protocol(iface, 1);
-#endif
 
 	maxinpktsize = 0;
 	sc->sc_iep_addr = sc->sc_oep_addr = -1;



CVS commit: src/sys/dev

2017-08-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 13 22:23:16 UTC 2017

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

Log Message:
validate length for discard operation and split operation when byte length
doesn't fit into 'int'.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/dksubr.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/dksubr.c
diff -u src/sys/dev/dksubr.c:1.97 src/sys/dev/dksubr.c:1.98
--- src/sys/dev/dksubr.c:1.97	Thu Apr 27 17:07:22 2017
+++ src/sys/dev/dksubr.c	Sun Aug 13 22:23:16 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.97 2017/04/27 17:07:22 jdolecek Exp $ */
+/* $NetBSD: dksubr.c,v 1.98 2017/08/13 22:23:16 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.97 2017/04/27 17:07:22 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.98 2017/08/13 22:23:16 mlelstv Exp $");
 
 #include 
 #include 
@@ -497,7 +497,7 @@ dk_discard(struct dk_softc *dksc, dev_t 
 	const struct dkdriver *dkd = dksc->sc_dkdev.dk_driver;
 	unsigned secsize = dksc->sc_dkdev.dk_geom.dg_secsize;
 	struct buf tmp, *bp = 
-	int error;
+	int maxsz, error;
 
 	DPRINTF_FOLLOW(("%s(%s, %p, 0x"PRIx64", %jd, %jd)\n", __func__,
 	dksc->sc_xname, dksc, (intmax_t)pos, (intmax_t)len));
@@ -507,22 +507,32 @@ dk_discard(struct dk_softc *dksc, dev_t 
 		return ENXIO;
 	}
 
-	if (secsize == 0 || (pos % secsize) != 0)
+	if (secsize == 0 || (pos % secsize) != 0 || (len % secsize) != 0)
 		return EINVAL;
 
-	/* enough data to please the bounds checking code */
-	bp->b_dev = dev;
-	bp->b_blkno = (daddr_t)(pos / secsize);
-	bp->b_bcount = len;
-	bp->b_flags = B_WRITE;
+	/* largest value that b_bcount can store */
+	maxsz = rounddown(INT_MAX, secsize);
 
-	error = dk_translate(dksc, bp);
-	if (error >= 0)
-		return error;
+	while (len > 0) {
+		/* enough data to please the bounds checking code */
+		bp->b_dev = dev;
+		bp->b_blkno = (daddr_t)(pos / secsize);
+		bp->b_bcount = min(len, maxsz);
+		bp->b_flags = B_WRITE;
+
+		error = dk_translate(dksc, bp);
+		if (error >= 0)
+			break;
+
+		error = dkd->d_discard(dksc->sc_dev,
+			(off_t)bp->b_rawblkno * secsize,
+			(off_t)bp->b_bcount);
+		if (error)
+			break;
 
-	error = dkd->d_discard(dksc->sc_dev,
-		(off_t)bp->b_rawblkno * secsize,
-		(off_t)bp->b_bcount);
+		pos += bp->b_bcount;
+		len -= bp->b_bcount;
+	}
 
 	return error;
 }



CVS commit: src/sys/dev/usb

2017-08-13 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Aug 13 22:19:56 UTC 2017

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

Log Message:
Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol.  This is no longer always the case, particularly
with higher-end keyboards.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/dev/usb/ukbd.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/ukbd.c
diff -u src/sys/dev/usb/ukbd.c:1.137 src/sys/dev/usb/ukbd.c:1.138
--- src/sys/dev/usb/ukbd.c:1.137	Sun Aug 13 21:11:45 2017
+++ src/sys/dev/usb/ukbd.c	Sun Aug 13 22:19:56 2017
@@ -1,4 +1,4 @@
-/*  $NetBSD: ukbd.c,v 1.137 2017/08/13 21:11:45 jakllsch Exp $*/
+/*  $NetBSD: ukbd.c,v 1.138 2017/08/13 22:19:56 jakllsch Exp $*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.137 2017/08/13 21:11:45 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.138 2017/08/13 22:19:56 jakllsch Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -83,12 +83,11 @@ int	ukbddebug = 0;
 #define DPRINTFN(n,x)
 #endif
 
-#define MAXKEYCODE 6
-#define MAXMOD 8		/* max 32 */
+#define MAXKEYCODE 32
+#define MAXKEYS 256
 
 struct ukbd_data {
-	uint32_t	modifiers;
-	uint8_t		keycode[MAXKEYCODE];
+	uint8_t		keys[MAXKEYS/NBBY];
 };
 
 #define PRESS0x000
@@ -234,19 +233,14 @@ Static const uint8_t ukbd_trtab[256] = {
 
 #define KEY_ERROR 0x01
 
-#define MAXKEYS (MAXMOD+2*MAXKEYCODE)
-
 struct ukbd_softc {
 	struct uhidev sc_hdev;
 
 	struct ukbd_data sc_ndata;
 	struct ukbd_data sc_odata;
-	struct hid_location sc_modloc[MAXMOD];
-	u_int sc_nmod;
-	struct {
-		uint32_t mask;
-		uint8_t key;
-	} sc_mods[MAXMOD];
+	struct hid_location sc_keyloc[MAXKEYS];
+	uint8_t sc_keyuse[MAXKEYS];
+	u_int sc_nkeyloc;
 
 	struct hid_location sc_keycodeloc;
 	u_int sc_nkeycode;
@@ -307,15 +301,17 @@ void ukbdtracedump(void);
 void
 ukbdtracedump(void)
 {
-	int i;
+	size_t i, j;
 	for (i = 0; i < UKBDTRACESIZE; i++) {
 		struct ukbdtraceinfo *p =
 		[(i+ukbdtraceindex)%UKBDTRACESIZE];
-		printf("%"PRIu64".%06"PRIu64": mod=0x%02x key0=0x%02x key1=0x%02x "
-		   "key2=0x%02x key3=0x%02x\n",
-		   p->tv.tv_sec, (uint64_t)p->tv.tv_usec,
-		   p->ud.modifiers, p->ud.keycode[0], p->ud.keycode[1],
-		   p->ud.keycode[2], p->ud.keycode[3]);
+		printf("%"PRIu64".%06"PRIu64":", p->tv.tv_sec,
+		(uint64_t)p->tv.tv_usec);
+		for (j = 0; j < MAXKEYS; j++) {
+			if (isset(p->ud.keys, j))
+printf(" %zu", j);
+		}
+		printf(".\n");
 	}
 }
 #endif
@@ -438,7 +434,7 @@ ukbd_attach(device_t parent, device_t se
 #endif
 
 #ifdef DIAGNOSTIC
-	aprint_normal(": %d modifier keys, %d key codes", sc->sc_nmod,
+	aprint_normal(": %d Variable keys, %d Array codes", sc->sc_nkeyloc,
 	   sc->sc_nkeycode);
 	if (sc->sc_flags & FLAG_APPLE_FN)
 		aprint_normal(", apple fn key");
@@ -595,21 +591,22 @@ ukbd_translate_keycodes(struct ukbd_soft
 const struct ukbd_keycodetrans *tab)
 {
 	const struct ukbd_keycodetrans *tp;
+	struct ukbd_data oud;
 	int i;
-	uint8_t key;
 
-	for (i = 0; i < sc->sc_nkeycode; i++) {
-		key = ud->keycode[i];
-		if (key)
+	oud = *ud;
+
+	for (i = 4; i < MAXKEYS; i++) {
+		if (isset(oud.keys, i))
 			for (tp = tab; tp->from; tp++)
-if (tp->from == key) {
+if (tp->from == i) {
 	if (tp->to & IS_PMF) {
 		pmf_event_inject(
 		sc->sc_hdev.sc_dev,
 		tp->to & 0xff);
-		ud->keycode[i] = 0;
 	} else
-		ud->keycode[i] = tp->to;
+		setbit(ud->keys, tp->to);
+	clrbit(ud->keys, i);
 	break;
 }
 	}
@@ -652,12 +649,18 @@ ukbd_intr(struct uhidev *addr, void *ibu
 	}
 #endif
 
-	ud->modifiers = 0;
-	for (i = 0; i < sc->sc_nmod; i++)
-		if (hid_get_data(ibuf, >sc_modloc[i]))
-			ud->modifiers |= sc->sc_mods[i].mask;
-	memcpy(ud->keycode, (char *)ibuf + sc->sc_keycodeloc.pos / 8,
-	   sc->sc_nkeycode);
+	memset(ud->keys, 0, sizeof(ud->keys));
+
+	for (i = 0; i < sc->sc_nkeyloc; i++)
+		if (hid_get_data(ibuf, >sc_keyloc[i]))
+			setbit(ud->keys, sc->sc_keyuse[i]);
+
+	const uint8_t * const scancode = (char *)ibuf + sc->sc_keycodeloc.pos / 8;
+	const uint16_t Keyboard_NoEvent = 0x;
+	for (i = 0; i < sc->sc_nkeycode; i++) {
+		if (scancode[i] != Keyboard_NoEvent)
+			setbit(ud->keys, scancode[i]);
+	}
 
 	if (sc->sc_flags & FLAG_APPLE_FN) {
 		if (hid_get_data(ibuf, >sc_apple_fn)) {
@@ -714,10 +717,12 @@ ukbd_delayed_decode(void *addr)
 void
 ukbd_decode(struct ukbd_softc *sc, struct ukbd_data *ud)
 {
-	int mod, omod;
 	uint16_t ibuf[MAXKEYS];	/* chars events */
 	int s;
-	int nkeys, i, j;
+	int nkeys, i;
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+	int j;
+#endif
 	int key;
 #define ADDKEY(c) do { \
 KASSERT(nkeys < MAXKEYS); \
@@ -740,15 +745,17 @@ ukbd_decode(struct 

CVS commit: src/sys/dev/usb

2017-08-13 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Aug 13 21:11:45 UTC 2017

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

Log Message:
Fix memory leak in report parsing error paths.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/dev/usb/ukbd.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/ukbd.c
diff -u src/sys/dev/usb/ukbd.c:1.136 src/sys/dev/usb/ukbd.c:1.137
--- src/sys/dev/usb/ukbd.c:1.136	Fri Jan 20 02:25:24 2017
+++ src/sys/dev/usb/ukbd.c	Sun Aug 13 21:11:45 2017
@@ -1,4 +1,4 @@
-/*  $NetBSD: ukbd.c,v 1.136 2017/01/20 02:25:24 maya Exp $*/
+/*  $NetBSD: ukbd.c,v 1.137 2017/08/13 21:11:45 jakllsch Exp $*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.136 2017/01/20 02:25:24 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.137 2017/08/13 21:11:45 jakllsch Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1078,26 +1078,36 @@ ukbd_parse_desc(struct ukbd_softc *sc)
 			 "cnt=%d\n", imod,
 			 h.usage, h.flags, h.loc.pos, h.loc.size, h.loc.count));
 		if (h.flags & HIO_VARIABLE) {
-			if (h.loc.size != 1)
+			if (h.loc.size != 1) {
+hid_end_parse(d);
 return "bad modifier size";
+			}
 			/* Single item */
 			if (imod < MAXMOD) {
 sc->sc_modloc[imod] = h.loc;
 sc->sc_mods[imod].mask = 1 << imod;
 sc->sc_mods[imod].key = HID_GET_USAGE(h.usage);
 imod++;
-			} else
+			} else {
+hid_end_parse(d);
 return "too many modifier keys";
+			}
 		} else {
 			/* Array */
-			if (h.loc.size != 8)
+			if (h.loc.size != 8) {
+hid_end_parse(d);
 return "key code size != 8";
+			}
 			if (h.loc.count > MAXKEYCODE)
 h.loc.count = MAXKEYCODE;
-			if (h.loc.pos % 8 != 0)
+			if (h.loc.pos % 8 != 0) {
+hid_end_parse(d);
 return "key codes not on byte boundary";
-			if (sc->sc_nkeycode != 0)
+			}
+			if (sc->sc_nkeycode != 0) {
+hid_end_parse(d);
 return "multiple key code arrays";
+			}
 			sc->sc_keycodeloc = h.loc;
 			sc->sc_nkeycode = h.loc.count;
 		}



CVS commit: src/sys/ufs/ffs

2017-08-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 13 21:00:58 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_alloc.c

Log Message:
Don't time out the discard work queue here. Either destroying a work queue
with pending work items panics or accessing freed resources from the work
item will crash. The timeout needs to be handled gracefully by the driver
that implements the discard operation.

Fixes parts of PR 50725.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/ufs/ffs/ffs_alloc.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/ufs/ffs/ffs_alloc.c
diff -u src/sys/ufs/ffs/ffs_alloc.c:1.157 src/sys/ufs/ffs/ffs_alloc.c:1.158
--- src/sys/ufs/ffs/ffs_alloc.c:1.157	Wed Jul 12 09:30:16 2017
+++ src/sys/ufs/ffs/ffs_alloc.c	Sun Aug 13 21:00:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.157 2017/07/12 09:30:16 hannken Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.158 2017/08/13 21:00:58 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.157 2017/07/12 09:30:16 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.158 2017/08/13 21:00:58 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1659,17 +1659,14 @@ ffs_discard_finish(void *vts, int flags)
 {
 	struct discarddata *ts = vts;
 	struct discardopdata *td = NULL;
-	int res = 0;
 
 	/* wait for workqueue to drain */
 	mutex_enter(>wqlk);
 	if (ts->wqcnt) {
 		ts->wqdraining = 1;
-		res = cv_timedwait(>wqcv, >wqlk, mstohz(5000));
+		cv_wait(>wqcv, >wqlk);
 	}
 	mutex_exit(>wqlk);
-	if (res)
-		printf("ffs_discarddata drain timeout\n");
 
 	mutex_enter(>entrylk);
 	if (ts->entry) {



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

2017-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug 13 19:18:08 UTC 2017

Modified Files:
src/sys/arch/arm/sunxi: sun8i_h3_ccu.c sunxi_ccu.h sunxi_ccu_nkmp.c

Log Message:
Add support for H3 CPUX clock.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/sunxi/sun8i_h3_ccu.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_ccu.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu_nkmp.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/sun8i_h3_ccu.c
diff -u src/sys/arch/arm/sunxi/sun8i_h3_ccu.c:1.10 src/sys/arch/arm/sunxi/sun8i_h3_ccu.c:1.11
--- src/sys/arch/arm/sunxi/sun8i_h3_ccu.c:1.10	Sun Aug  6 17:14:37 2017
+++ src/sys/arch/arm/sunxi/sun8i_h3_ccu.c	Sun Aug 13 19:18:08 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_h3_ccu.c,v 1.10 2017/08/06 17:14:37 jmcneill Exp $ */
+/* $NetBSD: sun8i_h3_ccu.c,v 1.11 2017/08/13 19:18:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_h3_ccu.c,v 1.10 2017/08/06 17:14:37 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_h3_ccu.c,v 1.11 2017/08/13 19:18:08 jmcneill Exp $");
 
 #include 
 #include 
@@ -41,6 +41,7 @@ __KERNEL_RCSID(1, "$NetBSD: sun8i_h3_ccu
 #include 
 #include 
 
+#define	PLL_CPUX_CTRL_REG	0x000
 #define	PLL_AUDIO_CTRL_REG	0x008
 #define	PLL_PERIPH0_CTRL_REG	0x028
 #define	AHB1_APB1_CFG_REG	0x054
@@ -143,12 +144,97 @@ static const char *apb1_parents[] = { "a
 static const char *apb2_parents[] = { "losc", "hosc", "pll_periph0" };
 static const char *mod_parents[] = { "hosc", "pll_periph0", "pll_periph1" };
 
-static const struct sunxi_ccu_nkmp_tbl sunx8_h3_ac_dig_table[] = {
+static const struct sunxi_ccu_nkmp_tbl sun8i_h3_cpux_table[] = {
+	{ 6000, 9, 0, 0, 2 },
+	{ 6600, 10, 0, 0, 2 },
+	{ 7200, 11, 0, 0, 2 },
+	{ 7800, 12, 0, 0, 2 },
+	{ 8400, 13, 0, 0, 2 },
+	{ 9000, 14, 0, 0, 2 },
+	{ 9600, 15, 0, 0, 2 },
+	{ 10200, 16, 0, 0, 2 },
+	{ 10800, 17, 0, 0, 2 },
+	{ 11400, 18, 0, 0, 2 },
+	{ 12000, 9, 0, 0, 1 },
+	{ 13200, 10, 0, 0, 1 },
+	{ 14400, 11, 0, 0, 1 },
+	{ 15600, 12, 0, 0, 1 },
+	{ 16800, 13, 0, 0, 1 },
+	{ 18000, 14, 0, 0, 1 },
+	{ 19200, 15, 0, 0, 1 },
+	{ 20400, 16, 0, 0, 1 },
+	{ 21600, 17, 0, 0, 1 },
+	{ 22800, 18, 0, 0, 1 },
+	{ 24000, 9, 0, 0, 0 },
+	{ 26400, 10, 0, 0, 0 },
+	{ 28800, 11, 0, 0, 0 },
+	{ 31200, 12, 0, 0, 0 },
+	{ 33600, 13, 0, 0, 0 },
+	{ 36000, 14, 0, 0, 0 },
+	{ 38400, 15, 0, 0, 0 },
+	{ 40800, 16, 0, 0, 0 },
+	{ 43200, 17, 0, 0, 0 },
+	{ 45600, 18, 0, 0, 0 },
+	{ 48000, 19, 0, 0, 0 },
+	{ 50400, 20, 0, 0, 0 },
+	{ 52800, 21, 0, 0, 0 },
+	{ 55200, 22, 0, 0, 0 },
+	{ 57600, 23, 0, 0, 0 },
+	{ 6, 24, 0, 0, 0 },
+	{ 62400, 25, 0, 0, 0 },
+	{ 64800, 26, 0, 0, 0 },
+	{ 67200, 27, 0, 0, 0 },
+	{ 69600, 28, 0, 0, 0 },
+	{ 72000, 29, 0, 0, 0 },
+	{ 76800, 15, 1, 0, 0 },
+	{ 79200, 10, 2, 0, 0 },
+	{ 81600, 16, 1, 0, 0 },
+	{ 86400, 17, 1, 0, 0 },
+	{ 91200, 18, 1, 0, 0 },
+	{ 93600, 12, 2, 0, 0 },
+	{ 96000, 19, 1, 0, 0 },
+	{ 100800, 20, 1, 0, 0 },
+	{ 105600, 21, 1, 0, 0 },
+	{ 108000, 14, 2, 0, 0 },
+	{ 110400, 22, 1, 0, 0 },
+	{ 115200, 23, 1, 0, 0 },
+	{ 12, 24, 1, 0, 0 },
+	{ 122400, 16, 2, 0, 0 },
+	{ 124800, 25, 1, 0, 0 },
+	{ 129600, 26, 1, 0, 0 },
+	{ 134400, 27, 1, 0, 0 },
+	{ 136800, 18, 2, 0, 0 },
+	{ 139200, 28, 1, 0, 0 },
+	{ 144000, 29, 1, 0, 0 },
+	{ 151200, 20, 2, 0, 0 },
+	{ 153600, 15, 3, 0, 0 },
+	{ 158400, 21, 2, 0, 0 },
+	{ 163200, 16, 3, 0, 0 },
+	{ 165600, 22, 2, 0, 0 },
+	{ 172800, 23, 2, 0, 0 },
+	{ 18, 24, 2, 0, 0 },
+	{ 182400, 18, 3, 0, 0 },
+	{ 187200, 25, 2, 0, 0 },
+	{ 0 }
+};
+
+static const struct sunxi_ccu_nkmp_tbl sun8i_h3_ac_dig_table[] = {
 	{ 24576000, 13, 0, 0, 13 },
 	{ 0 }
 };
 
 static struct sunxi_ccu_clk sun8i_h3_ccu_clks[] = {
+	SUNXI_CCU_NKMP_TABLE(H3_CLK_CPUX, "pll_cpux", "hosc",
+	PLL_CPUX_CTRL_REG,		/* reg */
+	__BITS(12,8),		/* n */
+	__BITS(5,4),		/* k */
+	__BITS(1,0),		/* m */
+	__BITS(17,16),		/* p */
+	__BIT(31),			/* enable */
+	__BIT(28),			/* lock */
+	sun8i_h3_cpux_table,	/* table */
+	SUNXI_CCU_NKMP_SCALE_CLOCK | SUNXI_CCU_NKMP_FACTOR_P_POW2),
+	
 	SUNXI_CCU_NKMP(H3_CLK_PLL_PERIPH0, "pll_periph0", "hosc",
 	PLL_PERIPH0_CTRL_REG,	/* reg */
 	__BITS(12,8),		/* n */
@@ -166,7 +252,7 @@ static struct sunxi_ccu_clk sun8i_h3_ccu
 	__BITS(19,16),		/* p */
 	__BIT(31),			/* enable */
 	__BIT(28),			/* lock */
-	sunx8_h3_ac_dig_table,	/* table */
+	sun8i_h3_ac_dig_table,	/* table */
 	0),
 
 	SUNXI_CCU_PREDIV(H3_CLK_AHB1, "ahb1", ahb1_parents,


CVS commit: src/usr.sbin/btattach

2017-08-13 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Aug 13 18:34:03 UTC 2017

Modified Files:
src/usr.sbin/btattach: btattach.8

Log Message:
Indent to avoid line breaks in tag; give tag width in table; use Nm
to refer to hciattach because we'll probably never have hciattach(8).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/btattach/btattach.8

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

Modified files:

Index: src/usr.sbin/btattach/btattach.8
diff -u src/usr.sbin/btattach/btattach.8:1.9 src/usr.sbin/btattach/btattach.8:1.10
--- src/usr.sbin/btattach/btattach.8:1.9	Fri Aug 11 11:54:08 2017
+++ src/usr.sbin/btattach/btattach.8	Sun Aug 13 18:34:03 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: btattach.8,v 1.9 2017/08/11 11:54:08 jmcneill Exp $
+.\" $NetBSD: btattach.8,v 1.10 2017/08/13 18:34:03 wiz Exp $
 .\"
 .\" Copyright (c) 2007 KIYOHARA Takashi
 .\" All rights reserved.
@@ -55,7 +55,7 @@ given device
 before activating the line discipline.
 .Pp
 Supported types are:
-.Bl -tag -compact -width ericssonxx -offset indent
+.Bl -tag -compact -width 15n -offset indent
 .It Cm bcm2035
 Broadcom BCM2035
 .It Cm bcm43xx
@@ -122,7 +122,7 @@ packet from HCI, or
 .Xr btuart 4 ,
 if there is no response.
 .Sh FILES
-.Bl -tag -compact
+.Bl -tag -compact -width 20n
 .It Pa /var/run/btattach- Ns Bro tty Brc Ns .pid
 .El
 .Sh SEE ALSO
@@ -134,7 +134,7 @@ if there is no response.
 The
 .Nm
 program was written with reference to
-.Xr hciattach 8
+.Nm hciattach
 as provided with the BlueZ tools for Linux and first appeared in
 .Nx 5.0 .
 .Sh AUTHORS



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

2017-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug 13 18:27:48 UTC 2017

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

Log Message:
enable gregulator


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/evbarm/conf/SUNXI

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/SUNXI
diff -u src/sys/arch/evbarm/conf/SUNXI:1.21 src/sys/arch/evbarm/conf/SUNXI:1.22
--- src/sys/arch/evbarm/conf/SUNXI:1.21	Sun Aug  6 17:16:02 2017
+++ src/sys/arch/evbarm/conf/SUNXI	Sun Aug 13 18:27:48 2017
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: SUNXI,v 1.21 2017/08/06 17:16:02 jmcneill Exp $
+#	$NetBSD: SUNXI,v 1.22 2017/08/13 18:27:48 jmcneill Exp $
 #
 #	Allwinner sunxi family
 #
@@ -74,6 +74,7 @@ sunxigates*	at fdt? pass 1		# Misc. cloc
 fclock*		at fdt? pass 1
 ffclock*	at fdt? pass 1
 fregulator*	at fdt? pass 4
+gregulator*	at fdt? pass 4
 gpiokeys*	at fdt?
 gpioleds*	at fdt?
 



CVS commit: src/sys/dev/fdt

2017-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug 13 18:27:31 UTC 2017

Modified Files:
src/sys/dev/fdt: files.fdt
Added Files:
src/sys/dev/fdt: gpioregulator.c

Log Message:
Add GPIO regulator driver.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/fdt/files.fdt
cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/gpioregulator.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/files.fdt
diff -u src/sys/dev/fdt/files.fdt:1.19 src/sys/dev/fdt/files.fdt:1.20
--- src/sys/dev/fdt/files.fdt:1.19	Sat Jul  8 12:37:08 2017
+++ src/sys/dev/fdt/files.fdt	Sun Aug 13 18:27:31 2017
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.19 2017/07/08 12:37:08 jmcneill Exp $
+# $NetBSD: files.fdt,v 1.20 2017/08/13 18:27:31 jmcneill Exp $
 
 include	"external/bsd/libfdt/conf/files.libfdt"
 
@@ -14,6 +14,10 @@ device	fregulator
 attach	fregulator at fdt
 file	dev/fdt/fixedregulator.c		fregulator
 
+device	gregulator
+attach	gregulator at fdt
+file	dev/fdt/gpioregulator.c			gregulator
+
 device	fclock: clk
 attach	fclock at fdt
 file	dev/fdt/fixedclock.c			fclock

Added files:

Index: src/sys/dev/fdt/gpioregulator.c
diff -u /dev/null src/sys/dev/fdt/gpioregulator.c:1.1
--- /dev/null	Sun Aug 13 18:27:31 2017
+++ src/sys/dev/fdt/gpioregulator.c	Sun Aug 13 18:27:31 2017
@@ -0,0 +1,250 @@
+/* $NetBSD: gpioregulator.c,v 1.1 2017/08/13 18:27:31 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2017 Jared McNeill 
+ * 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, 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: gpioregulator.c,v 1.1 2017/08/13 18:27:31 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static int	gpioregulator_match(device_t, cfdata_t, void *);
+static void	gpioregulator_attach(device_t, device_t, void *);
+
+static int	gpioregulator_acquire(device_t);
+static void 	gpioregulator_release(device_t);
+static int	gpioregulator_enable(device_t, bool);
+static int	gpioregulator_set_voltage(device_t, u_int, u_int);
+static int	gpioregulator_get_voltage(device_t, u_int *);
+
+static const struct fdtbus_regulator_controller_func gpioregulator_funcs = {
+	.acquire = gpioregulator_acquire,
+	.release = gpioregulator_release,
+	.enable = gpioregulator_enable,
+	.set_voltage = gpioregulator_set_voltage,
+	.get_voltage = gpioregulator_get_voltage,
+};
+
+struct gpioregulator_state {
+	u_int		st_val;
+	u_int		st_mask;
+};
+
+struct gpioregulator_softc {
+	device_t	sc_dev;
+	int		sc_phandle;
+
+	struct fdtbus_gpio_pin *sc_pin_enable;
+
+	struct fdtbus_gpio_pin **sc_pins;
+	u_int		sc_npins;
+
+	struct gpioregulator_state *sc_states;
+	u_int		sc_nstates;
+
+	bool		sc_always_on;
+	bool		sc_boot_on;
+	bool		sc_enable_val;
+	uint32_t	sc_delay;
+
+	int		sc_gpioflags;
+};
+
+CFATTACH_DECL_NEW(gregulator, sizeof(struct gpioregulator_softc),
+gpioregulator_match, gpioregulator_attach, NULL, NULL);
+
+static int
+gpioregulator_match(device_t parent, cfdata_t cf, void *aux)
+{
+	const char * const compatible[] = { "regulator-gpio", NULL };
+	const struct fdt_attach_args *faa = aux;
+
+	return of_match_compatible(faa->faa_phandle, compatible);
+}
+
+static void
+gpioregulator_attach(device_t parent, device_t self, void *aux)
+{
+	struct gpioregulator_softc * const sc = device_private(self);
+	const struct fdt_attach_args *faa = aux;
+	const int phandle = faa->faa_phandle;
+	const uint32_t *pstates;
+	uint32_t mask;
+	char *name;
+	int len, n;
+
+	sc->sc_dev = self;
+	sc->sc_phandle = phandle;
+
+	aprint_naive("\n");
+
+	len = OF_getproplen(phandle, "regulator-name");
+	if (len > 0) {
+		name = 

CVS commit: src/sys/dev/fdt

2017-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug 13 18:27:11 UTC 2017

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

Log Message:
Add fdtbus_gpio_acquire_index for accessing multi-xref gpios properties.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/fdt/fdt_gpio.c
cvs rdiff -u -r1.24 -r1.25 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_gpio.c
diff -u src/sys/dev/fdt/fdt_gpio.c:1.4 src/sys/dev/fdt/fdt_gpio.c:1.5
--- src/sys/dev/fdt/fdt_gpio.c:1.4	Sat Oct 15 08:30:42 2016
+++ src/sys/dev/fdt/fdt_gpio.c	Sun Aug 13 18:27:11 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_gpio.c,v 1.4 2016/10/15 08:30:42 maxv Exp $ */
+/* $NetBSD: fdt_gpio.c,v 1.5 2017/08/13 18:27:11 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_gpio.c,v 1.4 2016/10/15 08:30:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_gpio.c,v 1.5 2017/08/13 18:27:11 jmcneill Exp $");
 
 #include 
 #include 
@@ -80,39 +80,45 @@ fdtbus_get_gpio_controller(int phandle)
 struct fdtbus_gpio_pin *
 fdtbus_gpio_acquire(int phandle, const char *prop, int flags)
 {
-	struct fdtbus_gpio_controller *gc;
-	struct fdtbus_gpio_pin *gp;
-	int gpio_phandle, len;
-	u_int *data;
-
-	gpio_phandle = fdtbus_get_phandle(phandle, prop);
-	if (gpio_phandle == -1) {
-		return NULL;
-	}
-
-	gc = fdtbus_get_gpio_controller(gpio_phandle);
-	if (gc == NULL) {
-		return NULL;
-	}
+	return fdtbus_gpio_acquire_index(phandle, prop, 0, flags);
+}
 
-	len = OF_getproplen(phandle, prop);
-	if (len < 4) {
-		return NULL;
-	}
+struct fdtbus_gpio_pin *
+fdtbus_gpio_acquire_index(int phandle, const char *prop,
+int index, int flags)
+{
+	struct fdtbus_gpio_controller *gc;
+	struct fdtbus_gpio_pin *gp = NULL;
+	const uint32_t *gpios, *p;
+	u_int n, gpio_cells;
+	int len, resid;
 
-	data = kmem_alloc(len, KM_SLEEP);
-	if (OF_getprop(phandle, prop, data, len) != len) {
-		kmem_free(data, len);
+	gpios = fdtbus_get_prop(phandle, prop, );
+	if (gpios == NULL)
 		return NULL;
-	}
 
-	gp = kmem_alloc(sizeof(*gp), KM_SLEEP);
-	gp->gp_gc = gc;
-	gp->gp_priv = gc->gc_funcs->acquire(gc->gc_dev, data, len, flags);
-	if (gp->gp_priv == NULL) {
-		kmem_free(data, len);
-		kmem_free(gp, sizeof(*gp));
-		return NULL;
+	p = gpios;
+	for (n = 0, resid = len; resid > 0; n++) {
+		const int gc_phandle =
+		fdtbus_get_phandle_from_native(be32toh(p[0]));
+		if (of_getprop_uint32(gc_phandle, "#gpio-cells", _cells))
+			break;
+		if (n == index) {
+			gc = fdtbus_get_gpio_controller(gc_phandle);
+			if (gc == NULL)
+return NULL;
+			gp = kmem_alloc(sizeof(*gp), KM_SLEEP);
+			gp->gp_gc = gc;
+			gp->gp_priv = gc->gc_funcs->acquire(gc->gc_dev,
+			[0], (gpio_cells + 1) * 4, flags);
+			if (gp->gp_priv == NULL) {
+kmem_free(gp, sizeof(*gp));
+return NULL;
+			}
+			break;
+		}
+		resid -= (gpio_cells + 1) * 4;
+		p += gpio_cells + 1;
 	}
 
 	return gp;

Index: src/sys/dev/fdt/fdtvar.h
diff -u src/sys/dev/fdt/fdtvar.h:1.24 src/sys/dev/fdt/fdtvar.h:1.25
--- src/sys/dev/fdt/fdtvar.h:1.24	Sat Jul  8 12:36:51 2017
+++ src/sys/dev/fdt/fdtvar.h	Sun Aug 13 18:27:11 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.24 2017/07/08 12:36:51 jmcneill Exp $ */
+/* $NetBSD: fdtvar.h,v 1.25 2017/08/13 18:27:11 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -236,6 +236,7 @@ void *		fdtbus_intr_establish(int, u_int
 void		fdtbus_intr_disestablish(int, void *);
 bool		fdtbus_intr_str(int, u_int, char *, size_t);
 struct fdtbus_gpio_pin *fdtbus_gpio_acquire(int, const char *, int);
+struct fdtbus_gpio_pin *fdtbus_gpio_acquire_index(int, const char *, int, int);
 void		fdtbus_gpio_release(struct fdtbus_gpio_pin *);
 int		fdtbus_gpio_read(struct fdtbus_gpio_pin *);
 void		fdtbus_gpio_write(struct fdtbus_gpio_pin *, int);



CVS commit: src/share/man/man4

2017-08-13 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Aug 13 18:19:44 UTC 2017

Modified Files:
src/share/man/man4: ip.4

Log Message:
Sort/merge errors.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/share/man/man4/ip.4

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

Modified files:

Index: src/share/man/man4/ip.4
diff -u src/share/man/man4/ip.4:1.39 src/share/man/man4/ip.4:1.40
--- src/share/man/man4/ip.4:1.39	Sun Aug 13 18:18:57 2017
+++ src/share/man/man4/ip.4	Sun Aug 13 18:19:44 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ip.4,v 1.39 2017/08/13 18:18:57 wiz Exp $
+.\"	$NetBSD: ip.4,v 1.40 2017/08/13 18:19:44 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -428,29 +428,28 @@ the kernel will choose an appropriate ad
 .Sh DIAGNOSTICS
 A socket operation may fail with one of the following errors returned:
 .Bl -tag -width [EADDRNOTAVAIL]
+.It Bq Er EACCES
+when an attempt is made to create a raw IP socket by a non-privileged process.
+.It Bq Er EADDRNOTAVAIL
+when an attempt is made to create a socket with a network address
+for which no network interface exists.
 .It Bq Er EISCONN
 when trying to establish a connection on a socket which already
 has one, or when trying to send a datagram with the destination
 address specified and the socket is already connected;
+.It Bq Er ENOBUFS
+when the system runs out of memory for an internal data structure;
 .It Bq Er ENOTCONN
 when trying to send a datagram, but no destination address is
 specified, and the socket hasn't been connected;
-.It Bq Er ENOBUFS
-when the system runs out of memory for an internal data structure;
-.It Bq Er EADDRNOTAVAIL
-when an attempt is made to create a socket with a network address
-for which no network interface exists.
-.It Bq Er EACCES
-when an attempt is made to create a raw IP socket by a non-privileged process.
 .El
 .Pp
 The following errors specific to IP may occur when setting or getting
 IP options:
 .Bl -tag -width EADDRNOTAVAILxx
 .It Bq Er EINVAL
-An unknown socket option name was given.
-.It Bq Er EINVAL
-The IP option field was improperly formed; an option field was
+An unknown socket option name was given; or
+the IP option field was improperly formed; an option field was
 shorter than the minimum value or longer than the option buffer provided.
 .El
 .Sh SEE ALSO



CVS commit: src/share/man/man4

2017-08-13 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Aug 13 18:18:58 UTC 2017

Modified Files:
src/share/man/man4: ip.4

Log Message:
Remove superfluous Tn markup.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/share/man/man4/ip.4

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

Modified files:

Index: src/share/man/man4/ip.4
diff -u src/share/man/man4/ip.4:1.38 src/share/man/man4/ip.4:1.39
--- src/share/man/man4/ip.4:1.38	Thu Aug 10 04:31:58 2017
+++ src/share/man/man4/ip.4	Sun Aug 13 18:18:57 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ip.4,v 1.38 2017/08/10 04:31:58 ryo Exp $
+.\"	$NetBSD: ip.4,v 1.39 2017/08/13 18:18:57 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -41,38 +41,24 @@
 .Ft int
 .Fn socket AF_INET SOCK_RAW proto
 .Sh DESCRIPTION
-.Tn IP
-is the network layer protocol used by the Internet protocol family.
+IP is the network layer protocol used by the Internet protocol family.
 Options may be set at the
-.Tn IP
-level when using higher-level protocols that are based on
-.Tn IP
-(such as
-.Tn TCP
-and
-.Tn UDP ) .
+IP level when using higher-level protocols that are based on
+IP (such as TCP and UDP).
 It may also be accessed through a
 .Dq raw socket
 when developing new protocols, or special-purpose applications.
 .Pp
-There are several
-.Tn IP-level
+There are several IP-level
 .Xr setsockopt 2 Ns / Ns Xr getsockopt 2
 options.
 .Dv IP_OPTIONS
-may be used to provide
-.Tn IP
-options to be transmitted in the
-.Tn IP
-header of each outgoing packet
+may be used to provide IP options to be transmitted in the
+IP header of each outgoing packet
 or to examine the header options on incoming packets.
-.Tn IP
-options may be used with any socket type in the Internet family.
-The format of
-.Tn IP
-options to be sent is that specified by the
-.Tn IP
-protocol specification (RFC 791), with one exception:
+IP options may be used with any socket type in the Internet family.
+The format of IP options to be sent is that specified by the
+IP protocol specification (RFC 791), with one exception:
 the list of addresses for Source Route options must include the first-hop
 gateway at the beginning of the list of gateways.
 The first-hop gateway address will be extracted from the option list
@@ -86,8 +72,7 @@ setsockopt(s, IPPROTO_IP, IP_OPTIONS, NU
 and
 .Dv IP_TTL
 may be used to set the type-of-service and time-to-live fields in the
-.Tn IP
-header for
+IP header for
 .Dv SOCK_STREAM
 and
 .Dv SOCK_DGRAM
@@ -154,8 +139,7 @@ setsockopt(s, IPPROTO_IP, IP_PORTALGO, &
 .Ed
 .Pp
 The port selection can be also viewed and controlled at a global level for all
-.Tn IP
-sockets using the following
+IP sockets using the following
 .Xr sysctl 7
 variables:
 .Dv net.inet.ip.anonportalgo.available
@@ -183,15 +167,9 @@ or
 socket,
 the
 .Xr recvmsg 2
-call will return the destination
-.Tn IP
-address for a
-.Tn UDP
-datagram.
+call will return the destination IP address for a UDP datagram.
 The msg_control field in the msghdr structure points to a buffer
-that contains a cmsghdr structure followed by the
-.Tn IP
-address.
+that contains a cmsghdr structure followed by the IP address.
 The cmsghdr fields have the following values:
 .Bd -literal
 cmsg_len = CMSG_LEN(sizeof(struct in_addr))
@@ -231,13 +209,9 @@ option is enabled on a
 .Dv SOCK_DGRAM
 socket, the
 .Xr recvmsg 2
-call will return the
-.Tn TTL
-of the received datagram.
+call will return the TTL of the received datagram.
 The msg_control field in the msghdr structure points to a buffer
-that contains a cmsghdr structure followed by the
-.Tn TTL
-value.
+that contains a cmsghdr structure followed by the TTL value.
 The cmsghdr fields have the following values:
 .Bd -literal
 cmsg_len = CMSG_LEN(sizeof(uint8_t))
@@ -261,8 +235,7 @@ int minttl = 255;
 setsockopt(s, IPPROTO_IP, IP_MINTTL, , sizeof(minttl));
 .Ed
 .Ss MULTICAST OPTIONS
-.Tn IP
-multicasting is supported only on
+IP multicasting is supported only on
 .Dv AF_INET
 sockets of type
 .Dv SOCK_DGRAM
@@ -298,9 +271,7 @@ struct in_addr addr;
 setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, , sizeof(addr));
 .Ed
 .Pp
-where "addr" is the local
-.Tn IP
-address of the desired interface or
+where "addr" is the local IP address of the desired interface or
 .Dv INADDR_ANY
 to specify the default interface.
 An interface's local IP address and multicast capability can
@@ -371,8 +342,7 @@ struct ip_mreq {
 .Dv imr_interface
 should be
 .Dv INADDR_ANY
-to choose the default multicast interface, or the
-.Tn IP
+to choose the default multicast interface, or the IP
 address of a particular multicast-capable interface if
 the host is multihomed.
 Membership is associated with a single interface;
@@ -394,9 +364,7 @@ contains the same values as used to add 
 Memberships are dropped when the socket is closed or the process exits.
 

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

2017-08-13 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 13 15:12:04 UTC 2017

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

Log Message:
by default make the chaos monkey do nothing, so it's easier to have this
compiled in all the time for testing; the vars can be set via DDB
when needed


To generate a diff of this commit:
cvs rdiff -u -r1.428.2.33 -r1.428.2.34 src/sys/dev/ata/wd.c

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

Modified files:

Index: src/sys/dev/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.428.2.33 src/sys/dev/ata/wd.c:1.428.2.34
--- src/sys/dev/ata/wd.c:1.428.2.33	Sun Aug 13 11:40:25 2017
+++ src/sys/dev/ata/wd.c	Sun Aug 13 15:12:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.428.2.33 2017/08/13 11:40:25 jdolecek Exp $ */
+/*	$NetBSD: wd.c,v 1.428.2.34 2017/08/13 15:12:04 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.33 2017/08/13 11:40:25 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.34 2017/08/13 15:12:04 jdolecek Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -117,7 +117,7 @@ int wdcdebug_wd_mask = 0x0;
 #endif
 
 #ifdef WD_CHAOS_MONKEY
-int wdcdebug_wd_cnt = 200;
+int wdcdebug_wd_cnt = 0;
 int wdcdebug_wd_chaos = 0;
 #endif
 



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

2017-08-13 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 13 11:48:53 UTC 2017

Modified Files:
src/sys/dev/ic [jdolecek-ncq]: mvsata.c

Log Message:
put the non-NCQ KASSERT() before edma disable for bio PIO, we are not supposed
to get there with NCQ command even on retries any more


To generate a diff of this commit:
cvs rdiff -u -r1.35.6.22 -r1.35.6.23 src/sys/dev/ic/mvsata.c

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

Modified files:

Index: src/sys/dev/ic/mvsata.c
diff -u src/sys/dev/ic/mvsata.c:1.35.6.22 src/sys/dev/ic/mvsata.c:1.35.6.23
--- src/sys/dev/ic/mvsata.c:1.35.6.22	Sat Aug 12 22:43:22 2017
+++ src/sys/dev/ic/mvsata.c	Sun Aug 13 11:48:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mvsata.c,v 1.35.6.22 2017/08/12 22:43:22 jdolecek Exp $	*/
+/*	$NetBSD: mvsata.c,v 1.35.6.23 2017/08/13 11:48:53 jdolecek Exp $	*/
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.35.6.22 2017/08/12 22:43:22 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.35.6.23 2017/08/13 11:48:53 jdolecek Exp $");
 
 #include "opt_mvsata.h"
 
@@ -1339,6 +1339,7 @@ do_pio:
 			WDCC_READ : WDCC_WRITE;
 
 		/* EDMA disable, if enabled this channel. */
+		KASSERT((chp->ch_flags & ATACH_NCQ) == 0);
 		if (mvport->port_edmamode_curr != nodma)
 			mvsata_edma_disable(mvport, 10 /* ms */, wait_flags);
 



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

2017-08-13 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 13 11:46:32 UTC 2017

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

Log Message:
move the dump note to post-merge, it's not new
siisata seems to be fine, no longer holds the merge

remove the kill active transfers after software drive reset - not relevant

now only the wd* at umass? stays as new item, but I won't hold the merge
for this, as I don't have the hardware and it is contained enough to be
resolved on HEAD


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.35 -r1.1.2.36 src/sys/dev/ata/TODO.ncq

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

Modified files:

Index: src/sys/dev/ata/TODO.ncq
diff -u src/sys/dev/ata/TODO.ncq:1.1.2.35 src/sys/dev/ata/TODO.ncq:1.1.2.36
--- src/sys/dev/ata/TODO.ncq:1.1.2.35	Sat Aug 12 22:43:22 2017
+++ src/sys/dev/ata/TODO.ncq	Sun Aug 13 11:46:32 2017
@@ -1,19 +1,13 @@
 Bugs
 
-
-siisata - fix all new XXX and unmergable bits
-
 test wd* at umass?, confirm the ata_channel kludge works
 
+Other random notes (do outside the NCQ branch):
+-
 do biodone() in wddone() starting the dump to not leak bufs when dumping from
 active system? make sure to not trigger atastart()
 - call ata_kill_active() + ata_kill_pending() when dumping
 
-kill active transfers after software drive reset - race timeout vs.
-error recovery
-
-Other random notes (do outside the NCQ branch):
--
 implement support for PM FIS-based switching, remove restriction in atastart()
 for hw which supports it, adjust error handling in controller drivers to handle
 xfers for several different drives



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

2017-08-13 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 13 11:40:25 UTC 2017

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

Log Message:
restore the fallback to non-NCQ on retries, do this after WDIORETRIES_SINGLE
retries, but only for non-FUA I/O; also only do the ATA_SINGLE fallback
when non-FUA

this makes sure that bio with ATA_SINGLE is not attempted as NCQ -
the ATA_SINGLE I/O is usually done using PIO by drivers which
actually support it, and thus are not compatible with DMA-only NCQ


To generate a diff of this commit:
cvs rdiff -u -r1.428.2.32 -r1.428.2.33 src/sys/dev/ata/wd.c

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

Modified files:

Index: src/sys/dev/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.428.2.32 src/sys/dev/ata/wd.c:1.428.2.33
--- src/sys/dev/ata/wd.c:1.428.2.32	Sat Aug 12 22:12:04 2017
+++ src/sys/dev/ata/wd.c	Sun Aug 13 11:40:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.428.2.32 2017/08/12 22:12:04 jdolecek Exp $ */
+/*	$NetBSD: wd.c,v 1.428.2.33 2017/08/13 11:40:25 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.32 2017/08/12 22:12:04 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.33 2017/08/13 11:40:25 jdolecek Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -720,9 +720,12 @@ wdstart1(struct wd_softc *wd, struct buf
 	/*
 	 * If we're retrying, retry in single-sector mode. This will give us
 	 * the sector number of the problem, and will eventually allow the
-	 * transfer to succeed.
+	 * transfer to succeed. If FUA is requested, we can't actually
+	 * do this, as ATA_SINGLE is usually executed as PIO transfer by drivers
+	 * which support it, and that isn't compatible with NCQ/FUA.
 	 */
-	if (xfer->c_retries >= WDIORETRIES_SINGLE)
+	if (xfer->c_retries >= WDIORETRIES_SINGLE &&
+	(bp->b_flags & B_MEDIA_FUA) == 0)
 		xfer->c_bio.flags = ATA_SINGLE;
 	else
 		xfer->c_bio.flags = 0;
@@ -734,10 +737,17 @@ wdstart1(struct wd_softc *wd, struct buf
 		xfer->c_bio.flags |= ATA_LBA48;
 
 	/*
-	 * If NCQ was negotiated, always use it. Some drives return random
-	 * errors when switching between NCQ and non-NCQ I/O too often. 
+	 * If NCQ was negotiated, always use it for the first several attempts.
+	 * Since device cancels all outstanding requests on error, downgrade
+	 * to non-NCQ on retry, so that the retried transfer would not cause
+	 * cascade failure for the other transfers if it fails again.
+	 * If FUA was requested, we can't downgrade, as that would violate
+	 * the semantics - FUA would not be honored. In that case, continue
+	 * retrying with NCQ.
 	 */
-	if (wd->drvp->drive_flags & ATA_DRIVE_NCQ) {
+	if (wd->drvp->drive_flags & ATA_DRIVE_NCQ &&
+	(xfer->c_retries < WDIORETRIES_SINGLE ||
+	(bp->b_flags & B_MEDIA_FUA) != 0)) {
 		xfer->c_bio.flags |= ATA_LBA48;
 		xfer->c_flags |= C_NCQ;
 



CVS commit: src/sys/dev/pckbport

2017-08-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 13 08:49:27 UTC 2017

Modified Files:
src/sys/dev/pckbport: files.pckbport pms.c pmsvar.h
Added Files:
src/sys/dev/pckbport: alps.c alpsreg.h alpsvar.h

Log Message:
PR/52483: Ryo ONODERA: Add support for ALPS PS/2 pointing devices


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/pckbport/alps.c \
src/sys/dev/pckbport/alpsreg.h src/sys/dev/pckbport/alpsvar.h
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pckbport/files.pckbport
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pckbport/pms.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pckbport/pmsvar.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/pckbport/files.pckbport
diff -u src/sys/dev/pckbport/files.pckbport:1.8 src/sys/dev/pckbport/files.pckbport:1.9
--- src/sys/dev/pckbport/files.pckbport:1.8	Wed Sep  7 15:05:13 2011
+++ src/sys/dev/pckbport/files.pckbport	Sun Aug 13 04:49:27 2017
@@ -1,4 +1,4 @@
-# $NetBSD: files.pckbport,v 1.8 2011/09/07 19:05:13 jakllsch Exp $
+# $NetBSD: files.pckbport,v 1.9 2017/08/13 08:49:27 christos Exp $
 # devices attached at pckbport, for use with wscons
 
 defflag	opt_wskbdmap.h			WSKBD_USONLY
@@ -16,8 +16,10 @@ defflag	PCKBD_CNATTACH_MAY_FAIL
 obsolete defflag opt_pms.h		PMS_DISABLE_POWERHOOK
 defflag	opt_pms.h			PMS_SYNAPTICS_TOUCHPAD
 defflag opt_pms.h			PMS_ELANTECH_TOUCHPAD
+defflag opt_pms.h			PMS_ALPS_TOUCHPAD
 device	pms: wsmousedev
 attach	pms at pckbport
 file	dev/pckbport/pms.c		pms
 file	dev/pckbport/synaptics.c	pms & pms_synaptics_touchpad
 file	dev/pckbport/elantech.c		pms & pms_elantech_touchpad
+file	dev/pckbport/alps.c		pms & pms_alps_touchpad

Index: src/sys/dev/pckbport/pms.c
diff -u src/sys/dev/pckbport/pms.c:1.35 src/sys/dev/pckbport/pms.c:1.36
--- src/sys/dev/pckbport/pms.c:1.35	Fri Sep  9 10:29:47 2011
+++ src/sys/dev/pckbport/pms.c	Sun Aug 13 04:49:27 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: pms.c,v 1.35 2011/09/09 14:29:47 jakllsch Exp $ */
+/* $NetBSD: pms.c,v 1.36 2017/08/13 08:49:27 christos Exp $ */
 
 /*-
  * Copyright (c) 2004 Kentaro Kurahone.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.35 2011/09/09 14:29:47 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.36 2017/08/13 08:49:27 christos Exp $");
 
 #include "opt_pms.h"
 
@@ -46,6 +46,9 @@ __KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.35
 #ifdef PMS_ELANTECH_TOUCHPAD
 #include 
 #endif
+#ifdef PMS_ALPS_TOUCHPAD
+#include 
+#endif
 
 #include 
 #include 
@@ -207,6 +210,11 @@ pmsattach(device_t parent, device_t self
 		sc->protocol = PMS_ELANTECH;
 	} else
 #endif
+#ifdef PMS_ALPS_TOUCHPAD
+	if (pms_alps_probe_init(sc) == 0) {
+		sc->protocol = PMS_ALPS;
+	} else
+#endif
 		/* Install generic handler. */
 		pckbport_set_inputhandler(sc->sc_kbctag, sc->sc_kbcslot,
 		pmsinput, sc, device_xname(sc->sc_dev));
@@ -255,6 +263,10 @@ do_enable(struct pms_softc *sc)
 	if (sc->protocol == PMS_ELANTECH)
 		pms_elantech_enable(sc);
 #endif
+#ifdef PMS_ALPS_TOUCHPAD
+	if (sc->protocol == PMS_ALPS)
+		pms_alps_enable(sc);
+#endif
 
 	cmd[0] = PMS_DEV_ENABLE;
 	res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd,
@@ -371,6 +383,14 @@ pms_resume(device_t dv, const pmf_qual_t
 		}
 	} else
 #endif
+#ifdef PMS_ALPS_TOUCHPAD
+	if (sc->protocol == PMS_ALPS) {
+		pms_alps_resume(sc);
+		if (sc->sc_enabled) {
+			do_enable(sc);
+		}
+	} else
+#endif
 	if (sc->sc_enabled) {
 		/* recheck protocol & init mouse */
 		sc->protocol = PMS_UNKNOWN;
@@ -445,7 +465,8 @@ pms_reset_thread(void *arg)
 		}
 
 		/* For the synaptics and elantech case, leave the protocol alone. */
-		if (sc->protocol != PMS_SYNAPTICS && sc->protocol != PMS_ELANTECH)
+		if (sc->protocol != PMS_SYNAPTICS && sc->protocol != PMS_ELANTECH
+			&& sc->protocol != PMS_ALPS)
 			sc->protocol = PMS_UNKNOWN;
 
 		pms_enable(sc);

Index: src/sys/dev/pckbport/pmsvar.h
diff -u src/sys/dev/pckbport/pmsvar.h:1.11 src/sys/dev/pckbport/pmsvar.h:1.12
--- src/sys/dev/pckbport/pmsvar.h:1.11	Fri Sep  9 10:29:47 2011
+++ src/sys/dev/pckbport/pmsvar.h	Sun Aug 13 04:49:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmsvar.h,v 1.11 2011/09/09 14:29:47 jakllsch Exp $	*/
+/*	$NetBSD: pmsvar.h,v 1.12 2017/08/13 08:49:27 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004 Kentaro Kurahone.
@@ -30,6 +30,7 @@
 
 #include 
 #include 
+#include 
 
 enum pms_type {
 	PMS_UNKNOWN,
@@ -37,7 +38,8 @@ enum pms_type {
 	PMS_SCROLL3,
 	PMS_SCROLL5,
 	PMS_SYNAPTICS,
-	PMS_ELANTECH
+	PMS_ELANTECH,
+	PMS_ALPS
 };
 
 struct pms_protocol {
@@ -62,7 +64,8 @@ struct pms_softc {		/* driver status inf
 	device_t sc_wsmousedev;
 	struct lwp *sc_event_thread;
 
-#if defined(PMS_SYNAPTICS_TOUCHPAD) || defined(PMS_ELANTECH_TOUCHPAD)
+#if defined(PMS_SYNAPTICS_TOUCHPAD) || defined(PMS_ELANTECH_TOUCHPAD) \
+	 || defined(PMS_ALPS_TOUCHPAD)
 	union {
 #ifdef PMS_SYNAPTICS_TOUCHPAD
 		struct synaptics_softc synaptics;
@@ -70,6 +73,9 @@ 

CVS commit: src/sys/arch

2017-08-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 13 08:48:30 UTC 2017

Modified Files:
src/sys/arch/amd64/conf: ALL GENERIC
src/sys/arch/evbmips/conf: LOONGSON
src/sys/arch/i386/conf: ALL GENERIC

Log Message:
Add ALPS pms support


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.463 -r1.464 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/evbmips/conf/LOONGSON
cvs rdiff -u -r1.426 -r1.427 src/sys/arch/i386/conf/ALL
cvs rdiff -u -r1.1165 -r1.1166 src/sys/arch/i386/conf/GENERIC

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.66 src/sys/arch/amd64/conf/ALL:1.67
--- src/sys/arch/amd64/conf/ALL:1.66	Sat Aug 12 02:46:13 2017
+++ src/sys/arch/amd64/conf/ALL	Sun Aug 13 04:48:30 2017
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.66 2017/08/12 06:46:13 maxv Exp $
+# $NetBSD: ALL,v 1.67 2017/08/13 08:48:30 christos 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.66 $"
+#ident		"ALL-$Revision: 1.67 $"
 
 maxusers	64		# estimated number of users
 
@@ -502,6 +502,7 @@ pckbd*		at pckbc?		# PC keyboard
 pms*		at pckbc?		# PS/2 mouse for wsmouse
 options 	PMS_SYNAPTICS_TOUCHPAD	# Enable support for Synaptics Touchpads
 options 	PMS_ELANTECH_TOUCHPAD	# Enable support for Elantech Touchpads
+options 	PMS_ALPS_TOUCHPAD	# Enable support for Alps Touchpads
 vga0		at isa?
 vga*		at pci? dev ? function ?
 genfb*		at pci? dev ? function ?

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.463 src/sys/arch/amd64/conf/GENERIC:1.464
--- src/sys/arch/amd64/conf/GENERIC:1.463	Fri Aug  4 05:30:19 2017
+++ src/sys/arch/amd64/conf/GENERIC	Sun Aug 13 04:48:30 2017
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.463 2017/08/04 09:30:19 maxv Exp $
+# $NetBSD: GENERIC,v 1.464 2017/08/13 08:48:30 christos Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.463 $"
+#ident		"GENERIC-$Revision: 1.464 $"
 
 maxusers	64		# estimated number of users
 
@@ -394,6 +394,7 @@ pms*		at pckbc?		# PS/2 mouse for wsmous
 #options 	PMS_DISABLE_POWERHOOK	# Disable PS/2 reset on resume
 options 	PMS_SYNAPTICS_TOUCHPAD	# Enable support for Synaptics Touchpads
 options 	PMS_ELANTECH_TOUCHPAD	# Enable support for Elantech Touchpads
+options 	PMS_ALPS_TOUCHPAD	# Enable support for Alps Touchpads
 vga*		at pci? dev ? function ?
 genfb*		at pci? dev ? function ?
 options 	VCONS_DRAW_INTR

Index: src/sys/arch/evbmips/conf/LOONGSON
diff -u src/sys/arch/evbmips/conf/LOONGSON:1.31 src/sys/arch/evbmips/conf/LOONGSON:1.32
--- src/sys/arch/evbmips/conf/LOONGSON:1.31	Thu May 11 03:56:43 2017
+++ src/sys/arch/evbmips/conf/LOONGSON	Sun Aug 13 04:48:30 2017
@@ -1,4 +1,4 @@
-# $NetBSD: LOONGSON,v 1.31 2017/05/11 07:56:43 maya Exp $
+# $NetBSD: LOONGSON,v 1.32 2017/08/13 08:48:30 christos Exp $
 #
 # LOONGSON machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/evbmips/conf/std.loongson
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"LOONGSON-$Revision: 1.31 $"
+#ident 		"LOONGSON-$Revision: 1.32 $"
 
 maxusers	16
 
@@ -200,8 +200,10 @@ isa0		at pcib?
 pckbc0		at isa?# PC keyboard controller
 pckbd*		at pckbc?			# PC keyboard
 pms*		at pckbc?			# PS/2 mouse for wsmouse
+#options 	PMS_DISABLE_POWERHOOK	# Disable PS/2 reset on resume
 options 	PMS_SYNAPTICS_TOUCHPAD	# Enable support for Synaptics Touchpads
 options 	PMS_ELANTECH_TOUCHPAD	# Enable support for Elantech Touchpads
+options 	PMS_ALPS_TOUCHPAD	# Enable support for Alps Touchpads
 wskbd*		at pckbd? console ?
 wsmouse*	at pms? mux 0
 

Index: src/sys/arch/i386/conf/ALL
diff -u src/sys/arch/i386/conf/ALL:1.426 src/sys/arch/i386/conf/ALL:1.427
--- src/sys/arch/i386/conf/ALL:1.426	Sat Aug 12 02:46:13 2017
+++ src/sys/arch/i386/conf/ALL	Sun Aug 13 04:48:30 2017
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.426 2017/08/12 06:46:13 maxv Exp $
+# $NetBSD: ALL,v 1.427 2017/08/13 08:48:30 christos 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/i386/conf/std.i386"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.426 $"
+#ident		"ALL-$Revision: 1.427 $"
 
 maxusers	64		# estimated number of users
 
@@ -574,6 +574,7 @@ pckbd*		at pckbc?		# PC keyboard
 pms*		at pckbc?		# PS/2 mouse for wsmouse
 options 	PMS_SYNAPTICS_TOUCHPAD	# Enable support for Synaptics Touchpads
 options 	PMS_ELANTECH_TOUCHPAD	# Enable support 

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

2017-08-13 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Aug 13 08:07:52 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: process_machdep.c

Log Message:
Mmh, restore %cs and %ss on Xen. Otherwise (unpriv) userland could set a
non-three ring, causing the hypervisor to send a fatal interrupt to the
kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amd64/amd64/process_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/amd64/amd64/process_machdep.c
diff -u src/sys/arch/amd64/amd64/process_machdep.c:1.34 src/sys/arch/amd64/amd64/process_machdep.c:1.35
--- src/sys/arch/amd64/amd64/process_machdep.c:1.34	Sun Aug 13 07:16:44 2017
+++ src/sys/arch/amd64/amd64/process_machdep.c	Sun Aug 13 08:07:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.34 2017/08/13 07:16:44 maxv Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.35 2017/08/13 08:07:52 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -74,8 +74,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.34 2017/08/13 07:16:44 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.35 2017/08/13 08:07:52 maxv Exp $");
 
+#include "opt_xen.h"
 #include 
 #include 
 #include 
@@ -155,6 +156,12 @@ process_write_regs(struct lwp *l, const 
 	tf->tf_err = err;
 	tf->tf_trapno = trapno;
 
+#ifdef XEN
+	/* see comment in cpu_setmcontext */
+	tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
+	tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
+#endif
+
 	return 0;
 }
 



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

2017-08-13 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Aug 13 07:16:44 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: process_machdep.c

Log Message:
Remove unused include, remove dead code, KNF, and fix off-by-one.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/amd64/amd64/process_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/amd64/amd64/process_machdep.c
diff -u src/sys/arch/amd64/amd64/process_machdep.c:1.33 src/sys/arch/amd64/amd64/process_machdep.c:1.34
--- src/sys/arch/amd64/amd64/process_machdep.c:1.33	Tue Aug  8 17:27:34 2017
+++ src/sys/arch/amd64/amd64/process_machdep.c	Sun Aug 13 07:16:44 2017
@@ -1,6 +1,6 @@
-/*	$NetBSD: process_machdep.c,v 1.33 2017/08/08 17:27:34 maxv Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.34 2017/08/13 07:16:44 maxv Exp $	*/
 
-/*-
+/*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -71,19 +71,16 @@
  *
  * process_set_pc(proc)
  *	Set the process's program counter.
- *
  */
 
-
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.33 2017/08/08 17:27:34 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.34 2017/08/13 07:16:44 maxv Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -93,16 +90,12 @@ __KERNEL_RCSID(0, "$NetBSD: process_mach
 #include 
 
 static inline struct trapframe *process_frame(struct lwp *);
-#if 0
-static inline int verr_gdt(struct pmap *, int sel);
-static inline int verr_ldt(struct pmap *, int sel);
-#endif
 
 static inline struct trapframe *
 process_frame(struct lwp *l)
 {
 
-	return (l->l_md.md_regs);
+	return l->l_md.md_regs;
 }
 
 int
@@ -114,7 +107,7 @@ process_read_regs(struct lwp *l, struct 
 	_FRAME_GREG(copy_to_reg)
 #undef copy_to_reg
 
-	return (0);
+	return 0;
 }
 
 int
@@ -162,7 +155,7 @@ process_write_regs(struct lwp *l, const 
 	tf->tf_err = err;
 	tf->tf_trapno = trapno;
 
-	return (0);
+	return 0;
 }
 
 int
@@ -200,7 +193,7 @@ process_sstep(struct lwp *l, int sstep)
 	else
 		tf->tf_rflags &= ~PSL_T;
 	
-	return (0);
+	return 0;
 }
 
 int
@@ -208,9 +201,9 @@ process_set_pc(struct lwp *l, void *addr
 {
 	struct trapframe *tf = process_frame(l);
 
-	if ((uint64_t)addr > VM_MAXUSER_ADDRESS)
+	if ((uint64_t)addr >= VM_MAXUSER_ADDRESS)
 		return EINVAL;
 	tf->tf_rip = (uint64_t)addr;
 
-	return (0);
+	return 0;
 }