CVS commit: [nick-nhusb] src/sys/dev/usb

2015-09-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 13 06:48:03 UTC 2015

Modified Files:
src/sys/dev/usb [nick-nhusb]: xhci.c

Log Message:
Fix locking botch.  From t-hash.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.34 -r1.28.2.35 src/sys/dev/usb/xhci.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/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.28.2.34 src/sys/dev/usb/xhci.c:1.28.2.35
--- src/sys/dev/usb/xhci.c:1.28.2.34	Mon Aug 31 08:33:03 2015
+++ src/sys/dev/usb/xhci.c	Sun Sep 13 06:48:03 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.28.2.34 2015/08/31 08:33:03 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.28.2.35 2015/09/13 06:48:03 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.34 2015/08/31 08:33:03 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.35 2015/09/13 06:48:03 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -1587,7 +1587,7 @@ xhci_close_pipe(struct usbd_pipe *pipe)
 	trb.trb_3 = XHCI_TRB_3_SLOT_SET(xs->xs_idx) |
 	XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_CONFIGURE_EP);
 
-	(void)xhci_do_command(sc, , USBD_DEFAULT_TIMEOUT);
+	(void)xhci_do_command_locked(sc, , USBD_DEFAULT_TIMEOUT);
 	usb_syncmem(>xs_dc_dma, 0, sc->sc_pgsz, BUS_DMASYNC_POSTREAD);
 }
 



CVS commit: src/share/misc

2015-09-13 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Sun Sep 13 09:21:51 UTC 2015

Modified Files:
src/share/misc: airport

Log Message:
Fix a few entries, add a not about IATA vs. ICAO codes.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/share/misc/airport

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

Modified files:

Index: src/share/misc/airport
diff -u src/share/misc/airport:1.58 src/share/misc/airport:1.59
--- src/share/misc/airport:1.58	Sun Sep 21 08:38:03 2014
+++ src/share/misc/airport	Sun Sep 13 09:21:51 2015
@@ -1,8 +1,11 @@
-#	$NetBSD: airport,v 1.58 2014/09/21 08:38:03 mbalmer Exp $
+#	$NetBSD: airport,v 1.59 2015/09/13 09:21:51 mbalmer Exp $
 #	@(#)airport	8.1 (Berkeley) 6/8/93
 #
 # Some of this information is from http://www.mapping.com/airportcodes.html.
 #
+# Note that these are three letter IATA codes, most airports also have a
+# four letter ICAO code, e.g. Bern is BRN (IATA) and LSZB (ICAO).
+#
 # Airport Code : Airport
 AAA:Anaa, French Polynesia
 AAB:Arrabury, Queensland, Australia
@@ -918,7 +921,7 @@ BRJ:Bright, Victoria, Australia
 BRK:Bourke, New South Wales, Australia
 BRL:Burlington Municipal Airport, IA, USA
 BRM:Barquisimeto, Venezuela
-BRN:Bern-Belp, Switzerland
+BRN:Bern Airport, Bern-Belp, Switzerland
 BRO:Brownsville/South Padre Island, TX, USA
 BRP:Biaru, Papua New Guinea
 BRQ:Brno, Czech Republic
@@ -9167,9 +9170,7 @@ ZBX:Branson (Table Rock Heliport), MO, U
 ZBY:Sayaboury, Laos
 ZCC:Baden Baden (Railway Station), Germany
 ZCL:Zacatecas (General Leobardo Ruiz), Mexico
-ZCO:Temuco, Chile
-ZDJ:Bern, Switzerland
-ZDT:Chur, Switzerland
+ZCO:Maquehue Airport, Temuco, Chile
 ZEC:Seconda, South Africa
 ZEF:Elkin Municipal Airport, NC, USA
 ZEG:Senggo, Indonesia



CVS commit: src/sys/ufs/lfs

2015-09-13 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Sep 13 07:53:37 UTC 2015

Modified Files:
src/sys/ufs/lfs: lfs_alloc.c

Log Message:
Fix wrong code in lfs_valloc_fixed(). It was overwriting the inode
number it was supposed to be allocating with the head of the inode
freelist, then applying the wrong test to that result. Net result:
unless the freelist was empty (in which case it would always fail),
it would in general drop a bunch of entries from the freelist.

This code seems to have been broken when the first version of lfsv2
was imported onto the perseant-lfsv2 branch in -r1.47.2.1, and
remained broken since, in spite of having been moved to lfs_rfw.c and
back and rearranged quite a bit in the meantime.

Sigh.

Found by Coverity in a rather confusing way as CID 1316545.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/ufs/lfs/lfs_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/lfs/lfs_alloc.c
diff -u src/sys/ufs/lfs/lfs_alloc.c:1.129 src/sys/ufs/lfs/lfs_alloc.c:1.130
--- src/sys/ufs/lfs/lfs_alloc.c:1.129	Tue Sep  1 06:08:37 2015
+++ src/sys/ufs/lfs/lfs_alloc.c	Sun Sep 13 07:53:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_alloc.c,v 1.129 2015/09/01 06:08:37 dholland Exp $	*/
+/*	$NetBSD: lfs_alloc.c,v 1.130 2015/09/13 07:53:37 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.129 2015/09/01 06:08:37 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.130 2015/09/13 07:53:37 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -274,7 +274,7 @@ lfs_valloc_fixed(struct lfs *fs, ino_t i
 {
 	IFILE *ifp;
 	struct buf *bp, *cbp;
-	ino_t tino, oldnext;
+	ino_t headino, thisino, oldnext;
 	CLEANERINFO *cip;
 
 	/* If the Ifile is too short to contain this inum, extend it */
@@ -289,20 +289,20 @@ lfs_valloc_fixed(struct lfs *fs, ino_t i
 	lfs_if_setversion(fs, ifp, vers);
 	brelse(bp, 0);
 
-	LFS_GET_HEADFREE(fs, cip, cbp, );
-	if (ino) {
+	LFS_GET_HEADFREE(fs, cip, cbp, );
+	if (headino == ino) {
 		LFS_PUT_HEADFREE(fs, cip, cbp, oldnext);
 	} else {
 		ino_t nextfree;
 
-		tino = ino;
+		thisino = headino;
 		while (1) {
-			LFS_IENTRY(ifp, fs, tino, bp);
+			LFS_IENTRY(ifp, fs, thisino, bp);
 			nextfree = lfs_if_getnextfree(fs, ifp);
 			if (nextfree == ino ||
 			nextfree == LFS_UNUSED_INUM)
 break;
-			tino = nextfree;
+			thisino = nextfree;
 			brelse(bp, 0);
 		}
 		if (nextfree == LFS_UNUSED_INUM) {



CVS commit: src

2015-09-13 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Sun Sep 13 09:46:30 UTC 2015

Modified Files:
src/distrib/sets/lists/comp: mi
src/lib/libm: Makefile
src/lib/libm/man: rint.3

Log Message:
Add entries for rintl(3) and the nearbyint functions, and
make manual page links to the new functions.
Bump manual page date.


To generate a diff of this commit:
cvs rdiff -u -r1.1985 -r1.1986 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.168 -r1.169 src/lib/libm/Makefile
cvs rdiff -u -r1.13 -r1.14 src/lib/libm/man/rint.3

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

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1985 src/distrib/sets/lists/comp/mi:1.1986
--- src/distrib/sets/lists/comp/mi:1.1985	Sun Aug 23 18:28:40 2015
+++ src/distrib/sets/lists/comp/mi	Sun Sep 13 09:46:30 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1985 2015/08/23 18:28:40 mrg Exp $
+#	$NetBSD: mi,v 1.1986 2015/09/13 09:46:30 he Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7702,6 +7702,9 @@
 ./usr/share/man/cat3/nc_perror.0		comp-c-catman		.cat
 ./usr/share/man/cat3/nc_sperror.0		comp-c-catman		.cat
 ./usr/share/man/cat3/ndbm.0			comp-c-catman		.cat
+./usr/share/man/cat3/nearbyint.0		comp-c-catman		.cat
+./usr/share/man/cat3/nearbyintf.0		comp-c-catman		.cat
+./usr/share/man/cat3/nearbyintl.0		comp-c-catman		.cat
 ./usr/share/man/cat3/network.0			comp-c-catman		.cat
 ./usr/share/man/cat3/new_field.0		comp-c-catman		.cat
 ./usr/share/man/cat3/new_fieldtype.0		comp-c-catman		.cat
@@ -8435,6 +8438,7 @@
 ./usr/share/man/cat3/rindex.0			comp-c-catman		.cat
 ./usr/share/man/cat3/rint.0			comp-c-catman		.cat
 ./usr/share/man/cat3/rintf.0			comp-c-catman		.cat
+./usr/share/man/cat3/rintl.0			comp-c-catman		.cat
 ./usr/share/man/cat3/ripemd.0			comp-obsolete		obsolete
 ./usr/share/man/cat3/rmd160.0			comp-c-catman		.cat
 ./usr/share/man/cat3/rmtops.0			comp-c-catman		.cat
@@ -14604,6 +14608,9 @@
 ./usr/share/man/html3/nc_perror.html		comp-c-htmlman		html
 ./usr/share/man/html3/nc_sperror.html		comp-c-htmlman		html
 ./usr/share/man/html3/ndbm.html			comp-c-htmlman		html
+./usr/share/man/html3/nearbyint.html		comp-c-htmlman		html
+./usr/share/man/html3/nearbyintf.html		comp-c-htmlman		html
+./usr/share/man/html3/nearbyintl.html		comp-c-htmlman		html
 ./usr/share/man/html3/network.html		comp-c-htmlman		html
 ./usr/share/man/html3/new_field.html		comp-c-htmlman		html
 ./usr/share/man/html3/new_fieldtype.html	comp-c-htmlman		html
@@ -15329,6 +15336,7 @@
 ./usr/share/man/html3/rindex.html		comp-c-htmlman		html
 ./usr/share/man/html3/rint.html			comp-c-htmlman		html
 ./usr/share/man/html3/rintf.html		comp-c-htmlman		html
+./usr/share/man/html3/rintl.html		comp-c-htmlman		html
 ./usr/share/man/html3/rmd160.html		comp-c-htmlman		html
 ./usr/share/man/html3/rmtops.html		comp-c-htmlman		html
 ./usr/share/man/html3/round.html		comp-c-htmlman		html
@@ -21489,6 +21497,9 @@
 ./usr/share/man/man3/nc_perror.3		comp-c-man		.man
 ./usr/share/man/man3/nc_sperror.3		comp-c-man		.man
 ./usr/share/man/man3/ndbm.3			comp-c-man		.man
+./usr/share/man/man3/nearbyint.3		comp-c-man		.man
+./usr/share/man/man3/nearbyintf.3		comp-c-man		.man
+./usr/share/man/man3/nearbyintl.3		comp-c-man		.man
 ./usr/share/man/man3/network.3			comp-c-man		.man
 ./usr/share/man/man3/new_field.3		comp-c-man		.man
 ./usr/share/man/man3/new_fieldtype.3		comp-c-man		.man
@@ -2,6 +22233,7 @@
 ./usr/share/man/man3/rindex.3			comp-c-man		.man
 ./usr/share/man/man3/rint.3			comp-c-man		.man
 ./usr/share/man/man3/rintf.3			comp-c-man		.man
+./usr/share/man/man3/rintl.3			comp-c-man		.man
 ./usr/share/man/man3/ripemd.3			comp-obsolete		obsolete
 ./usr/share/man/man3/rmd160.3			comp-c-man		.man
 ./usr/share/man/man3/rmtops.3			comp-c-man		.man

Index: src/lib/libm/Makefile
diff -u src/lib/libm/Makefile:1.168 src/lib/libm/Makefile:1.169
--- src/lib/libm/Makefile:1.168	Sat Dec 27 16:54:02 2014
+++ src/lib/libm/Makefile	Sun Sep 13 09:46:30 2015
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.168 2014/12/27 16:54:02 martin Exp $
+#  $NetBSD: Makefile,v 1.169 2015/09/13 09:46:30 he Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -146,7 +146,8 @@ ARCH_SRCS = e_acos.S e_asin.S e_atanh.S 
 .elif (${LIBC_MACHINE_ARCH} == "vax")
 .PATH:	${.CURDIR}/arch/vax
 
-#NOIEEE_ARCH= n_infnan.S n_argred.S n_sqrt.S
+#NOIEEE_ARCH+= s_fmax.c s_fmaxf.c s_fmaxl.c
+#NOIEEE_ARCH+= n_infnan.S n_argred.S n_sqrt.S
 #ARCH_SRCS = n_atan2.S n_cabs.S n_cbrt.S n_support.S n_sincos.S n_tan.S
 # XXX - ripped out due to lack of the insn polyd in the Mariah chip,
 # and emulation code isn't written yet.
@@ -352,7 +353,11 @@ MLINKS+=lrint.3 lrintf.3 lrint.3 llrint.
 MLINKS+=remainder.3 remainderf.3 \
 	remainder.3 remquo.3 \
 	remainder.3 remquof.3
-MLINKS+=rint.3 rintf.3
+MLINKS+=rint.3 rintf.3 \
+	rint.3 rintl.3 \
+	rint.3 nearbyint.3 \
+	rint.3 nearbyintf.3 \
+	rint.3 

CVS commit: src/lib/libm/man

2015-09-13 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Sep 13 10:46:41 UTC 2015

Modified Files:
src/lib/libm/man: rint.3

Log Message:
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/libm/man/rint.3

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

Modified files:

Index: src/lib/libm/man/rint.3
diff -u src/lib/libm/man/rint.3:1.14 src/lib/libm/man/rint.3:1.15
--- src/lib/libm/man/rint.3:1.14	Sun Sep 13 09:46:30 2015
+++ src/lib/libm/man/rint.3	Sun Sep 13 10:46:41 2015
@@ -26,7 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)rint.3	5.1 (Berkeley) 5/2/91
-.\"	$NetBSD: rint.3,v 1.14 2015/09/13 09:46:30 he Exp $
+.\"	$NetBSD: rint.3,v 1.15 2015/09/13 10:46:41 wiz Exp $
 .\"
 .Dd September 13, 2015
 .Dt RINT 3
@@ -61,7 +61,7 @@ The
 .Fn rintf ,
 and
 .Fn rintl
-functions returns the integral value nearest to
+functions return the integral value nearest to
 .Fa x
 according to the prevailing rounding mode.
 These functions raise an inexact exception when the original argument



CVS commit: [nick-nhusb] src/sys/dev/usb

2015-09-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 13 06:50:09 UTC 2015

Modified Files:
src/sys/dev/usb [nick-nhusb]: xhci.c

Log Message:
Split xhci_handle_event() into 3 functions.  Whitespace.

>From t-hash.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.35 -r1.28.2.36 src/sys/dev/usb/xhci.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/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.28.2.35 src/sys/dev/usb/xhci.c:1.28.2.36
--- src/sys/dev/usb/xhci.c:1.28.2.35	Sun Sep 13 06:48:03 2015
+++ src/sys/dev/usb/xhci.c	Sun Sep 13 06:50:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.28.2.35 2015/09/13 06:48:03 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.28.2.36 2015/09/13 06:50:09 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.35 2015/09/13 06:48:03 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.36 2015/09/13 06:50:09 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -1677,9 +1677,7 @@ xhci_clear_endpoint_stall_async(struct u
 
 #endif /* XXX experimental */
 
-/*
- * Notify roothub port status/change to uhub_intr.
- */
+/* Process roothub port status/change events and notify to uhub_intr. */
 static void
 xhci_rhpsc(struct xhci_softc * const sc, u_int port)
 {
@@ -1704,176 +1702,221 @@ xhci_rhpsc(struct xhci_softc * const sc,
 	usb_transfer_complete(xfer);
 }
 
-/*
- * Process events:
- * + Transfer comeplete
- * + Command complete
- * + Roothub Port status/change
- */
+/* Process Transfer Events */
 static void
-xhci_handle_event(struct xhci_softc * const sc,
+xhci_event_transfer(struct xhci_softc * const sc,
 const struct xhci_trb * const trb)
 {
 	uint64_t trb_0;
 	uint32_t trb_2, trb_3;
-	uint8_t trberr;
+	uint8_t trbcode;
+	u_int slot, dci;
+	struct xhci_slot *xs;
+	struct xhci_ring *xr;
+	struct xhci_xfer *xx;
+	struct usbd_xfer *xfer;
+	usbd_status err;
 
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
 
 	trb_0 = le64toh(trb->trb_0);
 	trb_2 = le32toh(trb->trb_2);
 	trb_3 = le32toh(trb->trb_3);
-	trberr = XHCI_TRB_2_ERROR_GET(trb_2);
-
-	DPRINTFN(14, "event: %p 0x%016"PRIx64" 0x%08"PRIx32" 0x%08"PRIx32,
-	trb, trb_0, trb_2, trb_3);
-
-	switch (XHCI_TRB_3_TYPE_GET(trb_3)) {
-	case XHCI_TRB_EVENT_TRANSFER: {
-		u_int slot, dci;
-		struct xhci_slot *xs;
-		struct xhci_ring *xr;
-		struct xhci_xfer *xx;
-		struct usbd_xfer *xfer;
-		usbd_status err;
-
-		slot = XHCI_TRB_3_SLOT_GET(trb_3);
-		dci = XHCI_TRB_3_EP_GET(trb_3);
+	trbcode = XHCI_TRB_2_ERROR_GET(trb_2);
+	slot = XHCI_TRB_3_SLOT_GET(trb_3);
+	dci = XHCI_TRB_3_EP_GET(trb_3);
+	xs = >sc_slots[slot];
+	xr = >xs_ep[dci].xe_tr;
 
-		xs = >sc_slots[slot];
-		xr = >xs_ep[dci].xe_tr;
-		/* sanity check */
-		if (xs->xs_idx == 0 || xs->xs_idx >= sc->sc_maxslots) {
-			DPRINTFN(1, "invalid slot %u", xs->xs_idx, 0, 0, 0);
-			break;
-		}
+	/* sanity check */
+	if (xs->xs_idx == 0 || xs->xs_idx >= sc->sc_maxslots) {
+		DPRINTFN(1, "invalid slot %u", xs->xs_idx, 0, 0, 0);
+		return;
+	}
 
-		if ((trb_3 & XHCI_TRB_3_ED_BIT) == 0) {
-			bus_addr_t trbp = xhci_ring_trbp(xr, 0);
-
-			/* trb_0 range sanity check */
-			if (trb_0 < trbp ||
-			(trb_0 - trbp) % sizeof(struct xhci_trb) != 0 ||
-			(trb_0 - trbp) / sizeof(struct xhci_trb) >=
-			 xr->xr_ntrb) {
-DPRINTFN(1,
-"invalid trb_0 0x%"PRIx64" trbp 0x%"PRIx64,
-trb_0, trbp, 0, 0);
-break;
-			}
-			int idx = (trb_0 - trbp) / sizeof(struct xhci_trb);
-			xx = xr->xr_cookies[idx];
-		} else {
-			xx = (void *)(uintptr_t)(trb_0 & ~0x3);
-		}
-		/* XXX this may not happen */
-		if (xx == NULL) {
-			DPRINTFN(1, "xfer done: xx is NULL", 0, 0, 0, 0);
-			break;
-		}
-		xfer = >xx_xfer;
-		/* XXX this may happen when detaching */
-		if (xfer == NULL) {
-			DPRINTFN(1, "xfer done: xfer is NULL", 0, 0, 0, 0);
-			break;
-		}
-		DPRINTFN(14, "xfer %p", xfer, 0, 0, 0);
-		/* XXX I dunno why this happens */
-		KASSERT(xfer->ux_pipe != NULL);
+	if ((trb_3 & XHCI_TRB_3_ED_BIT) == 0) {
+		bus_addr_t trbp = xhci_ring_trbp(xr, 0);
 
-		if (!xfer->ux_pipe->up_repeat &&
-		SIMPLEQ_EMPTY(>ux_pipe->up_queue)) {
-			DPRINTFN(1, "xfer done: xfer not started", 0, 0, 0, 0);
-			break;
+		/* trb_0 range sanity check */
+		if (trb_0 < trbp ||
+		(trb_0 - trbp) % sizeof(struct xhci_trb) != 0 ||
+		(trb_0 - trbp) / sizeof(struct xhci_trb) >=
+		 xr->xr_ntrb) {
+			DPRINTFN(1, "invalid trb_0 0x%"PRIx64" trbp 0x%"PRIx64,
+			trb_0, trbp, 0, 0);
+			return;
 		}
+		int idx = (trb_0 - trbp) / sizeof(struct xhci_trb);
+		xx = xr->xr_cookies[idx];
+	} else {
+		xx = (void *)(uintptr_t)(trb_0 & ~0x3);
+	}
+	/* XXX this may not happen */
+	if (xx == NULL) {
+		DPRINTFN(1, "xfer done: xx is NULL", 0, 0, 0, 0);
+		return;
+	}
+	xfer = >xx_xfer;
+	/* XXX this may happen when detaching */
+	if (xfer == NULL) {
+		DPRINTFN(1, "xfer done: xfer is NULL", 0, 0, 0, 0);

CVS commit: [nick-nhusb] src/sys/dev/usb

2015-09-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 13 09:27:54 UTC 2015

Modified Files:
src/sys/dev/usb [nick-nhusb]: xhci.c xhcireg.h

Log Message:
Various improvements from t-hash (updated by me)

+ Improve xhci_configure_endpoint().
+ Split off maxburst and interval calculation.
+ Start interval calculation with 10, not 11.
+ Put correct maxburst value.
+ Split off constructing endpoint context.
+ Improve xhci_event_transfer()
+ Remove case of unlikely completion codes I added.
+ Clear xr_cookies too when xhci_set_dequeue() clears xr_trb.
+ Return USBD_NO_ADDR if xhci_address_device fails with
  XHCI_TRB_ERROR_NO_SLOTS.
+ Add aprint_debug xhci capability registers.
+ Add & update comments.

I checked HCCPARAMS1 against version 1.1 of the XHCI specification.  Not
sure of previous version formats


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.36 -r1.28.2.37 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/dev/usb/xhcireg.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/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.28.2.36 src/sys/dev/usb/xhci.c:1.28.2.37
--- src/sys/dev/usb/xhci.c:1.28.2.36	Sun Sep 13 06:50:09 2015
+++ src/sys/dev/usb/xhci.c	Sun Sep 13 09:27:54 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.28.2.36 2015/09/13 06:50:09 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.28.2.37 2015/09/13 09:27:54 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.36 2015/09/13 06:50:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.37 2015/09/13 09:27:54 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -613,12 +613,46 @@ hexdump(const char *msg, const void *bas
 #endif
 }
 
+#define XHCI_HCCPREV1_BITS	\
+	"\177\020"	/* New bitmask */			\
+	"f\020\020XECP\0"	\
+	"f\014\4MAXPSA\0"	\
+	"b\013CFC\0"		\
+	"b\012SEC\0"		\
+	"b\011SBD\0"		\
+	"b\010FSE\0"		\
+	"b\7NSS\0"		\
+	"b\6LTC\0"		\
+	"b\5LHRC\0"		\
+	"b\4PIND\0"		\
+	"b\3PPC\0"		\
+	"b\2CZC\0"		\
+	"b\1BNC\0"		\
+	"b\0AC64\0"		\
+	"\0"
+#define XHCI_HCCV1_x_BITS	\
+	"\177\020"	/* New bitmask */			\
+	"f\020\020XECP\0"	\
+	"f\014\4MAXPSA\0"	\
+	"b\013CFC\0"		\
+	"b\012SEC\0"		\
+	"b\011SPC\0"		\
+	"b\010PAE\0"		\
+	"b\7NSS\0"		\
+	"b\6LTC\0"		\
+	"b\5LHRC\0"		\
+	"b\4PIND\0"		\
+	"b\3PPC\0"		\
+	"b\2CSZ\0"		\
+	"b\1BNC\0"		\
+	"b\0AC64\0"		\
+	"\0"
 
 int
 xhci_init(struct xhci_softc *sc)
 {
 	bus_size_t bsz;
-	uint32_t cap, hcs1, hcs2, hcc, dboff, rtsoff;
+	uint32_t cap, hcs1, hcs2, hcs3, hcc, dboff, rtsoff;
 	uint32_t ecp, ecr;
 	uint32_t usbcmd, usbsts, pagesize, config;
 	int i;
@@ -635,7 +669,8 @@ xhci_init(struct xhci_softc *sc)
 	caplength = XHCI_CAP_CAPLENGTH(cap);
 	hciversion = XHCI_CAP_HCIVERSION(cap);
 
-	if ((hciversion < 0x0096) || (hciversion > 0x0100)) {
+	if (hciversion < XHCI_HCIVERSION_0_96 ||
+	hciversion > XHCI_HCIVERSION_1_0) {
 		aprint_normal_dev(sc->sc_dev,
 		"xHCI version %x.%x not known to be supported\n",
 		(hciversion >> 8) & 0xff, (hciversion >> 0) & 0xff);
@@ -655,15 +690,22 @@ xhci_init(struct xhci_softc *sc)
 	sc->sc_maxintrs = XHCI_HCS1_MAXINTRS(hcs1);
 	sc->sc_maxports = XHCI_HCS1_MAXPORTS(hcs1);
 	hcs2 = xhci_cap_read_4(sc, XHCI_HCSPARAMS2);
-	(void)xhci_cap_read_4(sc, XHCI_HCSPARAMS3);
-	hcc = xhci_cap_read_4(sc, XHCI_HCCPARAMS);
+	hcs3 = xhci_cap_read_4(sc, XHCI_HCSPARAMS3);
+	aprint_debug_dev(sc->sc_dev,
+	"hcs1=%"PRIx32" hcs2=%"PRIx32" hcs3=%"PRIx32"\n", hcs1, hcs2, hcs3);
 
+	hcc = xhci_cap_read_4(sc, XHCI_HCCPARAMS);
 	sc->sc_ac64 = XHCI_HCC_AC64(hcc);
 	sc->sc_ctxsz = XHCI_HCC_CSZ(hcc) ? 64 : 32;
-	aprint_debug_dev(sc->sc_dev, "ac64 %d ctxsz %d\n", sc->sc_ac64,
-	sc->sc_ctxsz);
 
+	char sbuf[128];
+	if (hciversion < XHCI_HCIVERSION_1_0)
+		snprintb(sbuf, sizeof(sbuf), XHCI_HCCPREV1_BITS, hcc);
+	else
+		snprintb(sbuf, sizeof sbuf, XHCI_HCCV1_x_BITS, hcc);
+	aprint_debug_dev(sc->sc_dev, "hcc=%s\n", sbuf);
 	aprint_debug_dev(sc->sc_dev, "xECP %x\n", XHCI_HCC_XECP(hcc) * 4);
+
 	ecp = XHCI_HCC_XECP(hcc) * 4;
 	while (ecp != 0) {
 		ecr = xhci_read_4(sc, ecp);
@@ -1072,8 +1114,8 @@ xhci_setup_sctx(struct usbd_device *dev,
 
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
 
-	/* 6.2.2 */
 	/*
+	 * 6.2.2, Table 57-60, 6.2.2.1, 6.2.2.2
 	 * tthubslot:
 	 *   This is the slot ID of parent HS hub
 	 *   if LS/FS device is connected && connected through HS hub.
@@ -1093,7 +1135,6 @@ xhci_setup_sctx(struct usbd_device *dev,
 	 dev->ud_myhub->ud_speed == USB_SPEED_HIGH) &&
 	(speed == USB_SPEED_LOW || speed == USB_SPEED_FULL)) {
 		ttportnum = dev->ud_myhsport->up_portno;
-		/* XXX addr == slot ? */
 		tthubslot = dev->ud_myhsport->up_parent->ud_addr;
 	} else {
 		ttportnum = 0;
@@ 

CVS commit: src/sys

2015-09-13 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Mon Sep 14 01:40:03 UTC 2015

Modified Files:
src/sys/conf: splash.mk
src/sys/dev/splash: files.splash splash.mk
src/sys/kern: init_main.c

Log Message:
Handle splash image generation better.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/conf/splash.mk
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/splash/files.splash
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/splash/splash.mk
cvs rdiff -u -r1.469 -r1.470 src/sys/kern/init_main.c

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

Modified files:

Index: src/sys/conf/splash.mk
diff -u src/sys/conf/splash.mk:1.2 src/sys/conf/splash.mk:1.3
--- src/sys/conf/splash.mk:1.2	Fri Sep 11 15:56:56 2015
+++ src/sys/conf/splash.mk	Mon Sep 14 01:40:03 2015
@@ -1,7 +1,6 @@
-# $NetBSD: splash.mk,v 1.2 2015/09/11 15:56:56 nat Exp $
+# $NetBSD: splash.mk,v 1.3 2015/09/14 01:40:03 uebayasi Exp $
 
 # Option for embedding a splashscreen image.
 .if defined(SPLASHSCREEN_IMAGE) 
 .include "${S}/dev/splash/splash.mk"
-OBJS+= splash_image.o
 .endif

Index: src/sys/dev/splash/files.splash
diff -u src/sys/dev/splash/files.splash:1.4 src/sys/dev/splash/files.splash:1.5
--- src/sys/dev/splash/files.splash:1.4	Fri May  1 02:00:41 2015
+++ src/sys/dev/splash/files.splash	Mon Sep 14 01:40:03 2015
@@ -1,6 +1,8 @@
-# $NetBSD: files.splash,v 1.4 2015/05/01 02:00:41 nat Exp $
+# $NetBSD: files.splash,v 1.5 2015/09/14 01:40:03 uebayasi Exp $
 
 define splash: stbi
 file dev/splash/splash.c	splash & splashscreen
+file splash_image.o		splash & splashscreen
 
 defflag opt_splash.h	SPLASHSCREEN
+			makeoptions_SPLASHSCREEN_IMAGE

Index: src/sys/dev/splash/splash.mk
diff -u src/sys/dev/splash/splash.mk:1.3 src/sys/dev/splash/splash.mk:1.4
--- src/sys/dev/splash/splash.mk:1.3	Fri May  1 02:35:16 2015
+++ src/sys/dev/splash/splash.mk	Mon Sep 14 01:40:03 2015
@@ -1,11 +1,8 @@
-# $NetBSD: splash.mk,v 1.3 2015/05/01 02:35:16 nat Exp $
+# $NetBSD: splash.mk,v 1.4 2015/09/14 01:40:03 uebayasi Exp $
 
 # Makefile for embedding splash image into kernel.
 .include 
 
-MI_OBJS+=	splash_image.o
-CFLAGS+=	-DSPLASHSCREEN_IMAGE
-
 .if (${OBJECT_FMTS:Melf64})
 BFD_ELFTARGET=elf64
 .else

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.469 src/sys/kern/init_main.c:1.470
--- src/sys/kern/init_main.c:1.469	Mon Aug 31 16:46:14 2015
+++ src/sys/kern/init_main.c	Mon Sep 14 01:40:03 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.469 2015/08/31 16:46:14 ozaki-r Exp $	*/
+/*	$NetBSD: init_main.c,v 1.470 2015/09/14 01:40:03 uebayasi Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.469 2015/08/31 16:46:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.470 2015/09/14 01:40:03 uebayasi Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ipsec.h"
@@ -115,7 +115,7 @@ __KERNEL_RCSID(0, "$NetBSD: init_main.c,
 #include "opt_rnd_printf.h"
 #include "opt_splash.h"
 
-#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_IMAGE)
+#if defined(SPLASHSCREEN) && defined(makeoptions_SPLASHSCREEN_IMAGE)
 extern void *_binary_splash_image_start;
 extern void *_binary_splash_image_end;
 #endif



CVS commit: src/sys/netinet6

2015-09-13 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Sep 14 05:34:28 UTC 2015

Modified Files:
src/sys/netinet6: icmp6.c

Log Message:
Update icmp6_redirect_timeout_q when changing net.inet6.icmp6.redirtimeout

We have to update icmp6_redirect_timeout_q as well as icmp6_redirtimeout
when changing net.inet6.icmp6.redirtimeout via sysctl. The updating logic
is copied from sysctl_net_inet_icmp_redirtimeout.

This change is from s-yamaguchi@IIJ (with KNF by ozaki-r) and fixes
PR kern/50240.


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/netinet6/icmp6.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/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.176 src/sys/netinet6/icmp6.c:1.177
--- src/sys/netinet6/icmp6.c:1.176	Mon Aug 31 06:25:15 2015
+++ src/sys/netinet6/icmp6.c	Mon Sep 14 05:34:28 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.176 2015/08/31 06:25:15 ozaki-r Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.177 2015/09/14 05:34:28 ozaki-r Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.176 2015/08/31 06:25:15 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.177 2015/09/14 05:34:28 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2767,6 +2767,38 @@ sysctl_net_inet6_icmp6_stats(SYSCTLFN_AR
 	return (NETSTAT_SYSCTL(icmp6stat_percpu, ICMP6_NSTATS));
 }
 
+static int
+sysctl_net_inet6_icmp6_redirtimeout(SYSCTLFN_ARGS)
+{
+	int error, tmp;
+	struct sysctlnode node;
+
+	node = *rnode;
+	node.sysctl_data = 
+	tmp = icmp6_redirtimeout;
+	error = sysctl_lookup(SYSCTLFN_CALL());
+	if (error || newp == NULL)
+		return error;
+	if (tmp < 0)
+		return EINVAL;
+	icmp6_redirtimeout = tmp;
+
+	if (icmp6_redirect_timeout_q != NULL) {
+		if (icmp6_redirtimeout == 0) {
+			rt_timer_queue_destroy(icmp6_redirect_timeout_q,
+			true);
+		} else {
+			rt_timer_queue_change(icmp6_redirect_timeout_q,
+			icmp6_redirtimeout);
+		}
+	} else if (icmp6_redirtimeout > 0) {
+		icmp6_redirect_timeout_q =
+		rt_timer_queue_create(icmp6_redirtimeout);
+	}
+
+	return 0;
+}
+
 static void
 sysctl_net_inet6_icmp6_setup(struct sysctllog **clog)
 {
@@ -2802,7 +2834,8 @@ sysctl_net_inet6_icmp6_setup(struct sysc
 		   CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
 		   CTLTYPE_INT, "redirtimeout",
 		   SYSCTL_DESCR("Redirect generated route lifetime"),
-		   NULL, 0, _redirtimeout, 0,
+		   sysctl_net_inet6_icmp6_redirtimeout, 0,
+		   _redirtimeout, 0,
 		   CTL_NET, PF_INET6, IPPROTO_ICMPV6,
 		   ICMPV6CTL_REDIRTIMEOUT, CTL_EOL);
 #if 0 /* obsoleted */



CVS commit: src/sbin/route

2015-09-13 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Sep 14 05:12:52 UTC 2015

Modified Files:
src/sbin/route: Makefile

Log Message:
Include a few additional libc functions in rump.route to make it work with inet6

getaddrinfo and if_nametoindex are newly added to interpret interface names
in IPv6 link-local addresses. if_nametoindex looks not used in rump.route,
but it is needed because it is used indirectly from getaddrinfo.

>From s-yamaguchi@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sbin/route/Makefile

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

Modified files:

Index: src/sbin/route/Makefile
diff -u src/sbin/route/Makefile:1.28 src/sbin/route/Makefile:1.29
--- src/sbin/route/Makefile:1.28	Fri May 15 06:58:59 2015
+++ src/sbin/route/Makefile	Mon Sep 14 05:12:52 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.28 2015/05/15 06:58:59 ozaki-r Exp $
+#	$NetBSD: Makefile,v 1.29 2015/09/14 05:12:52 ozaki-r Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 .include 
@@ -8,7 +8,8 @@ MAN=	route.8
 SRCS=	route.c show.c keywords.c rtutil.c
 
 .PATH:		${.CURDIR}/../../lib/libc/net
-RUMPSRCS= if_indextoname.c getifaddrs.c getnameinfo.c
+RUMPSRCS=	getaddrinfo.c getifaddrs.c getnameinfo.c
+RUMPSRCS+=	if_indextoname.c if_nametoindex.c
 .if (${MKRUMP} != "no")
 CPPFLAGS+= -DRUMP_ACTION
 .endif