CVS commit: src/external/gpl3/gcc/dist/libsanitizer/tsan

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 20:09:00 UTC 2016

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/tsan: tsan_interface.cc

Log Message:
Don't re-define standard types!


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interface.cc

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

Modified files:

Index: src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interface.cc
diff -u src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interface.cc:1.1.1.2 src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interface.cc:1.2
--- src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interface.cc:1.1.1.2	Sun Jan 24 01:05:42 2016
+++ src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interface.cc	Sun Jun  5 16:09:00 2016
@@ -18,9 +18,11 @@
 
 using namespace __tsan;  // NOLINT
 
+#if !SANITIZER_NETBSD
 typedef u16 uint16_t;
 typedef u32 uint32_t;
 typedef u64 uint64_t;
+#endif
 
 void __tsan_init() {
   Initialize(cur_thread());



CVS commit: src/external/gpl3/gcc/lib/libtsan

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 20:08:26 UTC 2016

Modified Files:
src/external/gpl3/gcc/lib/libtsan: Makefile
Added Files:
src/external/gpl3/gcc/lib/libtsan: tsan_rtl_unimpl.cc

Log Message:
add glue for unimplemented platforms


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/gcc/lib/libtsan/Makefile
cvs rdiff -u -r0 -r1.1 src/external/gpl3/gcc/lib/libtsan/tsan_rtl_unimpl.cc

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

Modified files:

Index: src/external/gpl3/gcc/lib/libtsan/Makefile
diff -u src/external/gpl3/gcc/lib/libtsan/Makefile:1.4 src/external/gpl3/gcc/lib/libtsan/Makefile:1.5
--- src/external/gpl3/gcc/lib/libtsan/Makefile:1.4	Wed Jun  1 18:48:55 2016
+++ src/external/gpl3/gcc/lib/libtsan/Makefile	Sun Jun  5 16:08:26 2016
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2016/06/01 22:48:55 christos Exp $
+# $NetBSD: Makefile,v 1.5 2016/06/05 20:08:26 christos Exp $
 
 .include 
 
@@ -35,6 +35,12 @@ tsan_suppressions.o \
 tsan_symbolize.o \
 tsan_sync.o
 
+.if exists(${SANITIZER}/tsan/tsan_rtl_${MACHINE}.S)
+TSAN_SRCS+= tsan_rtl_${MACHINE}.S
+.else
+TSAN_SRCS+= tsan_rtl_unimpl.cc
+.endif
+
 LIB=	tsan
 SRCS+=	${TSAN_SRCS}
 

Added files:

Index: src/external/gpl3/gcc/lib/libtsan/tsan_rtl_unimpl.cc
diff -u /dev/null src/external/gpl3/gcc/lib/libtsan/tsan_rtl_unimpl.cc:1.1
--- /dev/null	Sun Jun  5 16:08:26 2016
+++ src/external/gpl3/gcc/lib/libtsan/tsan_rtl_unimpl.cc	Sun Jun  5 16:08:26 2016
@@ -0,0 +1,4 @@
+#include 
+
+extern "C" void __tsan_report_race_thunk(void) { abort(); }
+extern "C" void __tsan_trace_switch_thunk(void) { abort(); }



CVS commit: src/external/gpl3/gcc/dist/libsanitizer/tsan

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 19:17:23 UTC 2016

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/tsan: tsan_interceptors.cc

Log Message:
comment out the ones we don't have


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc

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

Modified files:

Index: src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc
diff -u src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc:1.2 src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc:1.3
--- src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc:1.2	Tue May 31 16:47:25 2016
+++ src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc	Sun Jun  5 15:17:23 2016
@@ -2266,6 +2266,7 @@ struct ScopedSyscall {
   }
 };
 
+#if !SANITIZER_NETBSD
 static void syscall_access_range(uptr pc, uptr p, uptr s, bool write) {
   TSAN_SYSCALL();
   MemoryAccessRange(thr, pc, p, s, write);
@@ -2287,6 +2288,7 @@ static void syscall_fd_close(uptr pc, in
   TSAN_SYSCALL();
   FdClose(thr, pc, fd);
 }
+#endif
 
 static USED void syscall_fd_acquire(uptr pc, int fd) {
   TSAN_SYSCALL();
@@ -2300,6 +2302,7 @@ static USED void syscall_fd_release(uptr
   FdRelease(thr, pc, fd);
 }
 
+#if !SANITIZER_NETBSD
 static void syscall_pre_fork(uptr pc) {
   TSAN_SYSCALL();
   ForkBefore(thr, pc);
@@ -2319,6 +2322,7 @@ static void syscall_post_fork(uptr pc, i
 ForkParentAfter(thr, pc);
   }
 }
+#endif
 
 #define COMMON_SYSCALL_PRE_READ_RANGE(p, s) \
   syscall_access_range(GET_CALLER_PC(), (uptr)(p), (uptr)(s), false)



CVS commit: src/sys/dev/usb

2016-06-05 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Jun  5 18:46:03 UTC 2016

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

Log Message:
Use MUSB2_REG_RXNAKLIMIT instead of MUSB2_REG_TXNAKLIMIT in the recieve path.

XXX MUSB2_REG_RXNAKLIMIT in awin_otgreg.h is probably wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/usb/motg.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/motg.c
diff -u src/sys/dev/usb/motg.c:1.16 src/sys/dev/usb/motg.c:1.17
--- src/sys/dev/usb/motg.c:1.16	Fri May  6 13:03:06 2016
+++ src/sys/dev/usb/motg.c	Sun Jun  5 18:46:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: motg.c,v 1.16 2016/05/06 13:03:06 skrll Exp $	*/
+/*	$NetBSD: motg.c,v 1.17 2016/06/05 18:46:03 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.16 2016/05/06 13:03:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.17 2016/06/05 18:46:03 jakllsch Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_motg.h"
@@ -1230,10 +1230,10 @@ motg_setup_endpoint_rx(struct usbd_xfer 
 	);
 	if (epnumber == 0) {
 		if (sc->sc_high_speed) {
-			UWRITE1(sc, MUSB2_REG_TXNAKLIMIT,
+			UWRITE1(sc, MUSB2_REG_RXNAKLIMIT,
 			NAK_TO_CTRL_HIGH);
 		} else {
-			UWRITE1(sc, MUSB2_REG_TXNAKLIMIT, NAK_TO_CTRL);
+			UWRITE1(sc, MUSB2_REG_RXNAKLIMIT, NAK_TO_CTRL);
 		}
 	} else {
 		if ((xfer->ux_pipe->up_endpoint->ue_edesc->bmAttributes & UE_XFERTYPE)



CVS commit: src/games/mille

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 18:39:02 UTC 2016

Modified Files:
src/games/mille: varpush.c

Log Message:
get rid of gets


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/games/mille/varpush.c

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

Modified files:

Index: src/games/mille/varpush.c
diff -u src/games/mille/varpush.c:1.12 src/games/mille/varpush.c:1.13
--- src/games/mille/varpush.c:1.12	Wed Aug 31 12:24:56 2011
+++ src/games/mille/varpush.c	Sun Jun  5 14:39:02 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: varpush.c,v 1.12 2011/08/31 16:24:56 plunky Exp $	*/
+/*	$NetBSD: varpush.c,v 1.13 2016/06/05 18:39:02 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)varpush.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: varpush.c,v 1.12 2011/08/31 16:24:56 plunky Exp $");
+__RCSID("$NetBSD: varpush.c,v 1.13 2016/06/05 18:39:02 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -81,10 +81,12 @@ varpush(int file, ssize_t (*func)(int, c
 		Topcard = [temp];
 #ifdef DEBUG
 		if (Debug) {
-			char	buf[80];
+			char	buf[80], *bp;
 over:
 			printf("Debug file:");
-			gets(buf);
+			fgets(buf, (int)sizeof(buf), stdin);
+			if ((bp = strchr(buf, '\n')) != NULL)
+*bp = '\0';
 			if ((outf = fopen(buf, "w")) == NULL) {
 warn("%s", buf);
 goto over;



CVS commit: src/usr.bin/indent

2016-06-05 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jun  5 18:35:32 UTC 2016

Modified Files:
src/usr.bin/indent: lexi.c

Log Message:
Fix CSRG-era typo: typedef, not typdef. Spotted by Piotr Stefaniak.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/indent/lexi.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.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.13 src/usr.bin/indent/lexi.c:1.14
--- src/usr.bin/indent/lexi.c:1.13	Sun Apr 12 11:09:49 2009
+++ src/usr.bin/indent/lexi.c	Sun Jun  5 18:35:32 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.13 2009/04/12 11:09:49 lukem Exp $	*/
+/*	$NetBSD: lexi.c,v 1.14 2016/06/05 18:35:32 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -68,7 +68,7 @@
 #if 0
 static char sccsid[] = "@(#)lexi.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: lexi.c,v 1.13 2009/04/12 11:09:49 lukem Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.14 2016/06/05 18:35:32 dholland Exp $");
 #endif
 #endif/* not lint */
 
@@ -108,7 +108,7 @@ struct templ specials[1000] =
 	{"double", 4},
 	{"long", 4},
 	{"short", 4},
-	{"typdef", 4},
+	{"typedef", 4},
 	{"unsigned", 4},
 	{"register", 4},
 	{"static", 4},



CVS commit: src/sys/arch/hp300/stand/inst

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 17:44:40 UTC 2016

Modified Files:
src/sys/arch/hp300/stand/inst: inst.c

Log Message:
get rid of gets


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/hp300/stand/inst/inst.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/hp300/stand/inst/inst.c
diff -u src/sys/arch/hp300/stand/inst/inst.c:1.20 src/sys/arch/hp300/stand/inst/inst.c:1.21
--- src/sys/arch/hp300/stand/inst/inst.c:1.20	Sun Aug 10 03:40:49 2014
+++ src/sys/arch/hp300/stand/inst/inst.c	Sun Jun  5 13:44:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: inst.c,v 1.20 2014/08/10 07:40:49 isaki Exp $	*/
+/*	$NetBSD: inst.c,v 1.21 2016/06/05 17:44:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -131,7 +131,7 @@ main(void)
 	for (;;) {
 		printf("sys_inst> ");
 		memset(line, 0, sizeof(line));
-		gets(line);
+		gets_s(line, sizeof(line));
 		if (line[0] == '\n' || line[0] == '\0')
 			continue;
 
@@ -200,7 +200,7 @@ dsklabel(void)
  disklabel_loop:
 	memset(line, 0, sizeof(line));
 	printf("(z)ap, (e)dit, (s)how, (w)rite, (d)one > ");
-	gets(line);
+	gets_s(line, sizeof(line));
 	if (line[0] == '\n' || line[0] == '\0')
 		goto disklabel_loop;
 
@@ -259,28 +259,28 @@ dsklabel(void)
 #define GETNUM(out, num)		\
 	printf((out), (num));		\
 	memset(line, 0, sizeof(line));	\
-	gets(line);			\
+	gets_s(line, sizeof(line));			\
 	if (line[0])			\
 		(num) = atoi(line);
 
 #define GETNUM2(out, num1, num2)	\
 	printf((out), (num1), (num2));	\
 	memset(line, 0, sizeof(line));	\
-	gets(line);			\
+	gets_s(line, sizeof(line));			\
 	if (line[0])			\
 		(num2) = atoi(line);
 
 #define GETSTR(out, str)		\
 	printf((out), (str));		\
 	memset(line, 0, sizeof(line));	\
-	gets(line);			\
+	gets_s(line, sizeof(line));			\
 	if (line[0])			\
 		strcpy((str), line);
 
 #define FLAGS(out, flag)		\
 	printf((out), lp->d_flags & (flag) ? 'y' : 'n');		\
 	memset(line, 0, sizeof(line));	\
-	gets(line);			\
+	gets_s(line, sizeof(line));			\
 	if (line[0] == 'y' || line[0] == 'Y')\
 		lp->d_flags |= (flag);	\
 	else\
@@ -514,7 +514,7 @@ opendisk(char *question, char *diskname,
 	printf("%s ", question);
 	memset(diskname, 0, len);
 	memset(fulldiskname, 0, sizeof(fulldiskname));
-	gets(diskname);
+	gets_s(diskname, sizeof(diskname));
 	if (diskname[0] == '\n' || diskname[0] == '\0')
 		goto getdiskname;
 
@@ -570,7 +570,7 @@ miniroot(void)
  getsource:
 	printf("Source? (N)FS, (t)ape, (d)one > ");
 	memset(line, 0, sizeof(line));
-	gets(line);
+	gets_s(line, sizeof(line));
 	if (line[0] == '\0')
 		goto getsource;
 
@@ -581,7 +581,7 @@ miniroot(void)
 		printf("Name of miniroot file? ");
 		memset(line, 0, sizeof(line));
 		memset(minirootname, 0, sizeof(minirootname));
-		gets(line);
+		gets_s(line, sizeof(line));
 		if (line[0] == '\0')
 			goto name_of_nfs_miniroot;
 		(void)strcat(minirootname, "le0a:");
@@ -613,7 +613,7 @@ miniroot(void)
 		memset(line, 0, sizeof(line));
 		memset(minirootname, 0, sizeof(minirootname));
 		memset(tapename, 0, sizeof(tapename));
-		gets(line);
+		gets_s(line, sizeof(line));
 		if (line[0] == '\0')
 			goto name_of_tape_miniroot;
 		strcat(minirootname, line);
@@ -621,7 +621,7 @@ miniroot(void)
 
 		printf("File number (first == 1)? ");
 		memset(line, 0, sizeof(line));
-		gets(line);
+		gets_s(line, sizeof(line));
 		fileno = a2int(line);
 		if (fileno < 1 || fileno > 8) {
 			printf("Invalid file number: %s\n", line);
@@ -643,7 +643,7 @@ miniroot(void)
 		ignoreshread = 0;
 		printf("Copy how many %d byte blocks? ", DEV_BSIZE);
 		memset(line, 0, sizeof(line));
-		gets(line);
+		gets_s(line, sizeof(line));
 		nblks = a2int(line);
 		if (nblks < 0) {
 			printf("Invalid block count: %s\n", line);
@@ -723,7 +723,7 @@ bootmini(void)
 	printf("Disk to boot from? ");
 	memset(diskname, 0, sizeof(diskname));
 	memset(bootname, 0, sizeof(bootname));
-	gets(diskname);
+	gets_s(diskname, sizeof(diskname));
 	if (diskname[0] == '\n' || diskname[0] == '\0')
 		goto getdiskname;
 



CVS commit: src/sys/arch/hp300/stand

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 17:43:02 UTC 2016

Modified Files:
src/sys/arch/hp300/stand/common: netio.c samachdep.h tgets.c
src/sys/arch/hp300/stand/uboot: uboot.c

Log Message:
get rid of gets/tgets


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hp300/stand/common/netio.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/hp300/stand/common/samachdep.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hp300/stand/common/tgets.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/hp300/stand/uboot/uboot.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/hp300/stand/common/netio.c
diff -u src/sys/arch/hp300/stand/common/netio.c:1.14 src/sys/arch/hp300/stand/common/netio.c:1.15
--- src/sys/arch/hp300/stand/common/netio.c:1.14	Sun Jul 17 16:54:40 2011
+++ src/sys/arch/hp300/stand/common/netio.c	Sun Jun  5 13:43:02 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: netio.c,v 1.14 2011/07/17 20:54:40 joerg Exp $	*/
+/*	$NetBSD: netio.c,v 1.15 2016/06/05 17:43:02 christos Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -169,7 +169,7 @@ netmountroot(struct open_file *f, char *
  get_my_ip:
 		printf("My IP address? ");
 		memset(input_line, 0, sizeof(input_line));
-		gets(input_line);
+		gets_s(input_line, sizeof(input_line));
 		if ((myip.s_addr = inet_addr(input_line)) ==
 		htonl(INADDR_NONE)) {
 			printf("invalid IP address: %s\n", input_line);
@@ -179,7 +179,7 @@ netmountroot(struct open_file *f, char *
  get_my_netmask:
 		printf("My netmask? ");
 		memset(input_line, 0, sizeof(input_line)); 
-		gets(input_line);
+		gets_s(input_line, sizeof(input_line));
 		if ((netmask = inet_addr(input_line)) ==
 		htonl(INADDR_NONE)) {
 			printf("invalid netmask: %s\n", input_line);
@@ -189,7 +189,7 @@ netmountroot(struct open_file *f, char *
  get_my_gateway:
 		printf("My gateway? ");
 		memset(input_line, 0, sizeof(input_line)); 
-		gets(input_line);
+		gets_s(input_line, sizeof(input_line));
 		if ((gateip.s_addr = inet_addr(input_line)) ==
 		htonl(INADDR_NONE)) {
 			printf("invalid IP address: %s\n", input_line);
@@ -199,7 +199,7 @@ netmountroot(struct open_file *f, char *
  get_server_ip:
 		printf("Server IP address? ");
 		memset(input_line, 0, sizeof(input_line)); 
-		gets(input_line);
+		gets_s(input_line, sizeof(input_line));
 		if ((rootip.s_addr = inet_addr(input_line)) ==
 		htonl(INADDR_NONE)) {
 			printf("invalid IP address: %s\n", input_line);
@@ -209,7 +209,7 @@ netmountroot(struct open_file *f, char *
  get_server_path:
 		printf("Server path? ");
 		memset(rootpath, 0, sizeof(rootpath)); 
-		gets(rootpath);
+		gets_s(rootpath, sizeof(rootpath));
 		if (rootpath[0] == '\0' || rootpath[0] == '\n')
 			goto get_server_path;
 

Index: src/sys/arch/hp300/stand/common/samachdep.h
diff -u src/sys/arch/hp300/stand/common/samachdep.h:1.18 src/sys/arch/hp300/stand/common/samachdep.h:1.19
--- src/sys/arch/hp300/stand/common/samachdep.h:1.18	Sun Aug 10 03:40:49 2014
+++ src/sys/arch/hp300/stand/common/samachdep.h	Sun Jun  5 13:43:02 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: samachdep.h,v 1.18 2014/08/10 07:40:49 isaki Exp $	*/
+/*	$NetBSD: samachdep.h,v 1.19 2016/06/05 17:43:02 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -98,7 +98,7 @@ void romout(int, char *);
 void _transfer(char *, int, int, int, char *, char *);
 
 /* tget.c */
-int tgets(char *);
+int tgets_s(char *, size_t);
 
 
 #define DELAY(n)			\

Index: src/sys/arch/hp300/stand/common/tgets.c
diff -u src/sys/arch/hp300/stand/common/tgets.c:1.5 src/sys/arch/hp300/stand/common/tgets.c:1.6
--- src/sys/arch/hp300/stand/common/tgets.c:1.5	Sun Dec 11 07:17:19 2005
+++ src/sys/arch/hp300/stand/common/tgets.c	Sun Jun  5 13:43:02 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tgets.c,v 1.5 2005/12/11 12:17:19 christos Exp $	*/
+/*	$NetBSD: tgets.c,v 1.6 2016/06/05 17:43:02 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -38,13 +38,18 @@
 #include 
 
 int
-tgets(char *buf)
+tgets_s(char *buf, size_t size)
 {
 	int c;
 	int i;
 	char *lp = buf;
 
 	for (i = 24; i > 0; i--) {
+if (lp - buf == size) {
+lp--;
+*lp = '\0';
+return; 
+}
 		c = tgetchar() & 0177;
 		if (c) {
 			for (;;) {

Index: src/sys/arch/hp300/stand/uboot/uboot.c
diff -u src/sys/arch/hp300/stand/uboot/uboot.c:1.15 src/sys/arch/hp300/stand/uboot/uboot.c:1.16
--- src/sys/arch/hp300/stand/uboot/uboot.c:1.15	Wed Jul 16 09:44:51 2008
+++ src/sys/arch/hp300/stand/uboot/uboot.c	Sun Jun  5 13:43:02 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: uboot.c,v 1.15 2008/07/16 13:44:51 tsutsui Exp $	*/
+/*	$NetBSD: uboot.c,v 1.16 2016/06/05 17:43:02 christos Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -109,7 +109,7 @@ getbootdev(int *howto)
 	printf("Boot: [[[%s%d%c:]%s][-a][-c][-d][-s][-v][-q]] :- ",
 	

CVS commit: src/sys/arch/mvme68k/stand/bootst

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 17:37:36 UTC 2016

Modified Files:
src/sys/arch/mvme68k/stand/bootst: boot.c

Log Message:
use gets_s


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mvme68k/stand/bootst/boot.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/mvme68k/stand/bootst/boot.c
diff -u src/sys/arch/mvme68k/stand/bootst/boot.c:1.8 src/sys/arch/mvme68k/stand/bootst/boot.c:1.9
--- src/sys/arch/mvme68k/stand/bootst/boot.c:1.8	Sat Jan 12 04:54:30 2008
+++ src/sys/arch/mvme68k/stand/bootst/boot.c	Sun Jun  5 13:37:36 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.8 2008/01/12 09:54:30 tsutsui Exp $ */
+/*	$NetBSD: boot.c,v 1.9 2016/06/05 17:37:36 christos Exp $ */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -62,7 +62,7 @@ main(void)
 
 	if (flag & RB_ASKNAME) {
 		printf("tapeboot: segment? [%s] ", defname);
-		gets(line);
+		gets_s(line, sizeof(line));
 		if (line[0])
 			file = line;
 	}



CVS commit: src/distrib/sets/lists/comp

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 17:33:50 UTC 2016

Modified Files:
src/distrib/sets/lists/comp: mi

Log Message:
remove dup


To generate a diff of this commit:
cvs rdiff -u -r1.2041 -r1.2042 src/distrib/sets/lists/comp/mi

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.2041 src/distrib/sets/lists/comp/mi:1.2042
--- src/distrib/sets/lists/comp/mi:1.2041	Sun Jun  5 13:17:35 2016
+++ src/distrib/sets/lists/comp/mi	Sun Jun  5 13:33:49 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2041 2016/06/05 17:17:35 christos Exp $
+#	$NetBSD: mi,v 1.2042 2016/06/05 17:33:49 christos Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -5363,7 +5363,6 @@
 ./usr/share/man/cat3/bottom_panel.0		comp-c-catman		.cat
 ./usr/share/man/cat3/box.0			comp-c-catman		.cat
 ./usr/share/man/cat3/bsd_signal.0		comp-c-catman		.cat
-./usr/share/man/cat3/bsd_signal.0		comp-c-catman		.cat
 ./usr/share/man/cat3/bsearch.0			comp-c-catman		.cat
 ./usr/share/man/cat3/bstring.0			comp-c-catman		.cat
 ./usr/share/man/cat3/bswap.0			comp-c-catman		.cat



CVS commit: src/distrib/sets/lists/comp

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 17:17:35 UTC 2016

Modified Files:
src/distrib/sets/lists/comp: mi

Log Message:
Add bsd_signal (GSoC 2016 Charles Cui)


To generate a diff of this commit:
cvs rdiff -u -r1.2040 -r1.2041 src/distrib/sets/lists/comp/mi

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.2040 src/distrib/sets/lists/comp/mi:1.2041
--- src/distrib/sets/lists/comp/mi:1.2040	Sat Jun  4 21:31:03 2016
+++ src/distrib/sets/lists/comp/mi	Sun Jun  5 13:17:35 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2040 2016/06/05 01:31:03 christos Exp $
+#	$NetBSD: mi,v 1.2041 2016/06/05 17:17:35 christos Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -5362,6 +5362,8 @@
 ./usr/share/man/cat3/border.0			comp-c-catman		.cat
 ./usr/share/man/cat3/bottom_panel.0		comp-c-catman		.cat
 ./usr/share/man/cat3/box.0			comp-c-catman		.cat
+./usr/share/man/cat3/bsd_signal.0		comp-c-catman		.cat
+./usr/share/man/cat3/bsd_signal.0		comp-c-catman		.cat
 ./usr/share/man/cat3/bsearch.0			comp-c-catman		.cat
 ./usr/share/man/cat3/bstring.0			comp-c-catman		.cat
 ./usr/share/man/cat3/bswap.0			comp-c-catman		.cat
@@ -12627,6 +12629,7 @@
 ./usr/share/man/html3/border.html		comp-c-htmlman		html
 ./usr/share/man/html3/bottom_panel.html		comp-c-htmlman		html
 ./usr/share/man/html3/box.html			comp-c-htmlman		html
+./usr/share/man/html3/bsd_signal.html		comp-c-htmlman		html
 ./usr/share/man/html3/bsearch.html		comp-c-htmlman		html
 ./usr/share/man/html3/bstring.html		comp-c-htmlman		html
 ./usr/share/man/html3/bswap.html		comp-c-htmlman		html
@@ -19697,6 +19700,7 @@
 ./usr/share/man/man3/border.3			comp-c-man		.man
 ./usr/share/man/man3/bottom_panel.3		comp-c-man		.man
 ./usr/share/man/man3/box.3			comp-c-man		.man
+./usr/share/man/man3/bsd_signal.3		comp-c-man		.man
 ./usr/share/man/man3/bsearch.3			comp-c-man		.man
 ./usr/share/man/man3/bstring.3			comp-c-man		.man
 ./usr/share/man/man3/bswap.3			comp-c-man		.man



CVS commit: src/lib/libc/gen

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 17:16:44 UTC 2016

Modified Files:
src/lib/libc/gen: Makefile.inc signal.3
Added Files:
src/lib/libc/gen: bsd_signal.3

Log Message:
Document bsd_signal (From GSoC 2016 by Charles Cui)


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/lib/libc/gen/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/gen/bsd_signal.3
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/gen/signal.3

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

Modified files:

Index: src/lib/libc/gen/Makefile.inc
diff -u src/lib/libc/gen/Makefile.inc:1.194 src/lib/libc/gen/Makefile.inc:1.195
--- src/lib/libc/gen/Makefile.inc:1.194	Sat Apr  2 20:19:42 2016
+++ src/lib/libc/gen/Makefile.inc	Sun Jun  5 13:16:44 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.194 2016/04/03 00:19:42 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.195 2016/06/05 17:16:44 christos Exp $
 #	from: @(#)Makefile.inc	8.6 (Berkeley) 5/4/95
 
 # gen sources
@@ -53,8 +53,8 @@ COPTS.syslog.c = -Wno-format-nonliteral
 
 .include "${ARCHDIR}/gen/Makefile.inc"
 
-MAN+=	alarm.3 arc4random.3 basename.3 bswap.3 clock.3 closefrom.3 \
-	confstr.3 \
+MAN+=	alarm.3 arc4random.3 basename.3 bsd_signal.3 bswap.3 \
+	clock.3 closefrom.3 confstr.3 \
 	cpuset.3 ctermid.3 ctype.3 daemon.3 devname.3 directory.3 dirname.3 \
 	endutxent.3 err.3 exec.3 extattr_copy_file.3 extattr_namespace_to_string.3 \
 	fmtcheck.3 fmtmsg.3 fnmatch.3 fpclassify.3 fpgetmask.3 \

Index: src/lib/libc/gen/signal.3
diff -u src/lib/libc/gen/signal.3:1.24 src/lib/libc/gen/signal.3:1.25
--- src/lib/libc/gen/signal.3:1.24	Sun Jun 13 15:17:06 2004
+++ src/lib/libc/gen/signal.3	Sun Jun  5 13:16:44 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: signal.3,v 1.24 2004/06/13 19:17:06 lha Exp $
+.\"	$NetBSD: signal.3,v 1.25 2016/06/05 17:16:44 christos Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)signal.3	8.3 (Berkeley) 4/19/94
 .\"
-.Dd June 11, 2004
+.Dd June 5, 2016
 .Dt SIGNAL 3
 .Os
 .Sh NAME
@@ -43,6 +43,8 @@
 .\" fix it.
 .Ft void \*(lp*
 .Fn signal "int sig" "void \*(lp*func\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint"
+.Ft void \*(lp*
+.Fn bsd_signal "int sig" "void \*(lp*func\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint"
 .Sh DESCRIPTION
 This
 .Fn signal
@@ -179,6 +181,7 @@ or
 .Xr sigaltstack 2 ,
 .Xr sigprocmask 2 ,
 .Xr sigsuspend 2 ,
+.Xr bsd_signal 3 ,
 .Xr psignal 3 ,
 .Xr setjmp 3 ,
 .Xr strsignal 3 ,

Added files:

Index: src/lib/libc/gen/bsd_signal.3
diff -u /dev/null src/lib/libc/gen/bsd_signal.3:1.1
--- /dev/null	Sun Jun  5 13:16:44 2016
+++ src/lib/libc/gen/bsd_signal.3	Sun Jun  5 13:16:44 2016
@@ -0,0 +1,68 @@
+.\"	$NetBSD: bsd_signal.3,v 1.1 2016/06/05 17:16:44 christos Exp $
+.\"
+.\" Copyright (c) 1980, 1991, 1993
+.\"	The Regents of the University of California.  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.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"may be used to endorse or promote products derived from this software
+.\"without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)bsd_signal.3	8.3 (Berkeley) 4/19/94
+.\"
+.Dd June 04, 2016
+.Dt BSD_SIGNAL 3
+.Os
+.Sh NAME
+.Nm bsd_signal
+.Nd BSD version of
+.Xr signal
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In signal.h
+.\" The following is Quite Ugly, but syntactically correct.  Don't try to
+.\" fix it.
+.Ft void \*(lp*
+.Fn bsd_signal "int sig" "void \*(lp*func\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint"
+.Sh DESCRIPTION
+The
+.Fn bsd_signal
+function provides a partially compatible 

CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 16:43:10 UTC 2016

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
sanitizer_internal_defs.h

Log Message:
Don't play type games with size_t for NetBSD. It is either 32 bits for ILP32
or 64 bits for LP64.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \

src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h

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

Modified files:

Index: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h
diff -u src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:1.5 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:1.6
--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:1.5	Thu Jun  2 15:54:38 2016
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h	Sun Jun  5 12:43:10 2016
@@ -88,11 +88,16 @@ typedef uptr OFF_T;
 #endif
 typedef u64  OFF64_T;
 
+#if SANITIZER_NETBSD
+#include 
+typedef size_t operator_new_size_type;
+#else
 #if (SANITIZER_WORDSIZE == 64) || SANITIZER_MAC
 typedef uptr operator_new_size_type;
 #else
 typedef u32 operator_new_size_type;
 #endif
+#endif
 }  // namespace __sanitizer
 
 extern "C" {



CVS commit: src/external/bsd/byacc/bin

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 16:24:34 UTC 2016

Modified Files:
src/external/bsd/byacc/bin: yacc.1

Log Message:
Sync mdoc page with the one provided from upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/byacc/bin/yacc.1

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

Modified files:

Index: src/external/bsd/byacc/bin/yacc.1
diff -u src/external/bsd/byacc/bin/yacc.1:1.4 src/external/bsd/byacc/bin/yacc.1:1.5
--- src/external/bsd/byacc/bin/yacc.1:1.4	Sat Sep 10 17:38:59 2011
+++ src/external/bsd/byacc/bin/yacc.1	Sun Jun  5 12:24:34 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: yacc.1,v 1.4 2011/09/10 21:38:59 christos Exp $
+.\"	$NetBSD: yacc.1,v 1.5 2016/06/05 16:24:34 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1990 The Regents of the University of California.
 .\" All rights reserved.
@@ -31,10 +31,10 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	from: @(#)yacc.1	5.7 (Berkeley) 7/30/91
-.\"	from: Id: yacc.1,v 1.12 2011/09/08 00:40:44 tom Exp
-.\"	$NetBSD: yacc.1,v 1.4 2011/09/10 21:38:59 christos Exp $
+.\"	from: Id: yacc.1,v 1.24 2014/10/06 00:03:48 tom Exp 
+.\"	$NetBSD: yacc.1,v 1.5 2016/06/05 16:24:34 christos Exp $
 .\"
-.Dd September 7, 2011
+.Dd October 5, 2014
 .Dt YACC 1
 .Os
 .Sh NAME
@@ -44,9 +44,9 @@
 parser generator
 .Sh SYNOPSIS
 .Nm
-.Op Fl dgilPrtVv
-.Op Fl b Ar prefix
-.Op Fl o Ar outputfile
+.Op Fl BdgilLPrtvVy
+.Op Fl b Ar file_prefix
+.Op Fl o Ar output_file
 .Op Fl p Ar symbol_prefix
 .Ar filename
 .Sh DESCRIPTION
@@ -65,15 +65,18 @@ normally writes the parse tables and the
 .Pa y.tab.c .
 .Pp
 The following options are available:
-.Bl -tag -width Ar
-.It Fl b Ar prefix
+.Bl -tag -width symbol_prefixXXX
+.It Fl b Ar file_prefix
 The
 .Fl b
 option changes the prefix prepended to the output file names to
 the string denoted by
-.Ar prefix .
+.Ar file_prefix .
 The default prefix is the character
 .Ar y .
+.It Fl B
+Create a backtracking parser (compile-type configuration for
+.Nm ) .
 .It Fl d
 The
 .Fl d
@@ -124,11 +127,19 @@ option is specified,
 .Nm
 will not insert the #line directives.
 #line directives specified by the user will be retained.
-.It Fl o Ar outputfile
-The
-.Fl o
-option specifies an explicit output file name should be used instead
-of the default.
+.It Fl L
+Enable position processing, e.g., 
+.Dq %locations
+(compile-type configuration for
+.Nm ) .
+.It Fl o Ar output_file
+Specify the filename for the parser file.
+If this option is not given, the output filename is
+the file prefix concatenated with the file suffix, e.g.
+.Pa y.tab.c .
+This overrides the
+.Fl b
+option. 
 .It Fl P
 The
 .Fl P
@@ -155,6 +166,53 @@ The code file is named
 .Pa y.code.c ,
 and the tables file is named
 .Pa y.tab.c .
+The prefix 
+.Dq y.
+can be overridden using the
+.Fl b
+option.
+.It Fl s
+Suppress 
+.Dq #define
+statements generated for string literals in a
+.Dq %token
+statement, to more closely match original
+.Nm 
+behavior.
+.Pp
+Normally when
+.Nm 
+sees a line such as
+.Dq %token OP_ADD "ADD"
+it notices that the quoted
+.Dq ADD
+is a valid C identifier, and generates a #define not only for 
+.Dv OP_ADD ,
+but for 
+.Dv ADD
+as well,
+e.g.,
+.Bd -literal -offset indent
+#define OP_ADD 257
+#define ADD 258
+.Ed
+The original
+.Nm
+does not generate the second
+.Dq #define .
+The 
+.Fl s
+option suppresses this
+.Dq #define .
+.Pp
+.St -p1003.1
+documents only names and numbers for
+.Dq %token ,
+though the original
+.Nm 
+and
+.Xr bison 1
+also accept string literals.
 .It Fl t
 The
 .Fl t
@@ -171,14 +229,87 @@ The
 option causes a human-readable description of the generated parser to
 be written to the file
 .Pa y.output .
+.It Fl y
+.Nm
+ignores this option,
+which
+.Xr bison 1
+supports for ostensible POSIX compatibility.
 .El
 .Sh EXTENSIONS
 .Nm
-provides some extensions for compatibility with 
+provides some extensions for
+compatibility with
 .Xr bison 1
-and other implementations
-of 
-.Nm :
+and other implementations of yacc.
+The 
+.Dq %destructor
+and 
+.Dq %locations
+features are available only if 
+.Nm yacc
+has been configured and compiled to support the back-tracking functionality.
+The remaining features are always available:
+.Pp
+.Dv %destructor {
+.Dv code }
+.Dv symbol+
+.Pp
+Defines code that is invoked when a symbol is automatically
+discarded during error recovery.
+This code can be used to
+reclaim dynamically allocated memory associated with the corresponding
+semantic value for cases where user actions cannot manage the memory
+explicitly.
+.Pp
+On encountering a parse error, the generated parser
+discards symbols on the stack and input tokens until it reaches a state
+that will allow parsing to continue.
+This error recovery approach results in a memory leak
+if the
+.Dq YYSTYPE
+value is, or contains, pointers to dynamically allocated memory.
+.Pp
+The bracketed 
+.Dv code
+is invoked whenever the parser discards 

CVS commit: src/sys/lib/libsa

2016-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  5 15:05:49 UTC 2016

Modified Files:
src/sys/lib/libsa: gets.c

Log Message:
dedup


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/gets.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/lib/libsa/gets.c
diff -u src/sys/lib/libsa/gets.c:1.11 src/sys/lib/libsa/gets.c:1.12
--- src/sys/lib/libsa/gets.c:1.11	Sun Jun  5 09:33:03 2016
+++ src/sys/lib/libsa/gets.c	Sun Jun  5 11:05:49 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: gets.c,v 1.11 2016/06/05 13:33:03 maxv Exp $	*/
+/*	$NetBSD: gets.c,v 1.12 2016/06/05 15:05:49 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -36,54 +36,7 @@
 void
 gets(char *buf)
 {
-	int c;
-	char *lp;
-
-	for (lp = buf;;) {
-		switch (c = getchar() & 0177) {
-		case '\n':
-		case '\r':
-			*lp = '\0';
-			putchar('\n');
-			return;
-		case '\b':
-		case '\177':
-			if (lp > buf) {
-lp--;
-putchar('\b');
-putchar(' ');
-putchar('\b');
-			}
-			break;
-#if HASH_ERASE
-		case '#':
-			if (lp > buf)
---lp;
-			break;
-#endif
-		case 'r' & 037: {
-			char *p;
-
-			putchar('\n');
-			for (p = buf; p < lp; ++p)
-putchar(*p);
-			break;
-		}
-#if AT_ERASE
-		case '@':
-#endif
-		case 'u' & 037:
-		case 'w' & 037:
-			lp = buf;
-			putchar('\n');
-			break;
-		default:
-			*lp++ = c;
-			putchar(c);
-			break;
-		}
-	}
-	/*NOTREACHED*/
+	gets_s(buf, (size_t)-1);
 }
 
 void



CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 15:04:31 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_ioctl.c

Log Message:
use correct comparison of serial numbers


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/iscsi/iscsi_ioctl.c

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

Modified files:

Index: src/sys/dev/iscsi/iscsi_ioctl.c
diff -u src/sys/dev/iscsi/iscsi_ioctl.c:1.20 src/sys/dev/iscsi/iscsi_ioctl.c:1.21
--- src/sys/dev/iscsi/iscsi_ioctl.c:1.20	Sun Jun  5 13:45:56 2016
+++ src/sys/dev/iscsi/iscsi_ioctl.c	Sun Jun  5 15:04:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_ioctl.c,v 1.20 2016/06/05 13:45:56 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_ioctl.c,v 1.21 2016/06/05 15:04:31 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -875,7 +875,7 @@ recreate_connection(iscsi_login_paramete
 		/* if we get an error on reassign, restart the original request */
 		if (rc && ccb->pdu_waiting != NULL) {
 			mutex_enter(>lock);
-			if (ccb->CmdSN < session->ExpCmdSN) {
+			if (sn_a_lt_b(ccb->CmdSN, session->ExpCmdSN)) {
 pdu = ccb->pdu_waiting;
 sn = get_sernum(session, !(pdu->pdu.Opcode & OP_IMMEDIATE));
 



CVS commit: src/sys/arch/i386/stand/lib

2016-06-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun  5 14:13:57 UTC 2016

Modified Files:
src/sys/arch/i386/stand/lib: bootinfo.c bootinfo.h exec.c

Log Message:
Don't use a magic value. Define a limit, and enforce it.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/bootinfo.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/lib/bootinfo.h
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/i386/stand/lib/exec.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/i386/stand/lib/bootinfo.c
diff -u src/sys/arch/i386/stand/lib/bootinfo.c:1.5 src/sys/arch/i386/stand/lib/bootinfo.c:1.6
--- src/sys/arch/i386/stand/lib/bootinfo.c:1.5	Sun Dec 14 18:46:33 2008
+++ src/sys/arch/i386/stand/lib/bootinfo.c	Sun Jun  5 14:13:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.c,v 1.5 2008/12/14 18:46:33 christos Exp $	*/
+/*	$NetBSD: bootinfo.c,v 1.6 2016/06/05 14:13:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -40,6 +40,11 @@ bi_add(struct btinfo_common *what, int t
 	what->len = size;
 	what->type = type;
 
-	if (bootinfo)
-		bootinfo->entry[bootinfo->nentries++] = vtophys(what);
+	if (bootinfo == NULL) {
+		return;
+	}
+	if (bootinfo->nentries >= BTINFO_MAX) {
+		panic("bootinfo too big");
+	}
+	bootinfo->entry[bootinfo->nentries++] = vtophys(what);
 }

Index: src/sys/arch/i386/stand/lib/bootinfo.h
diff -u src/sys/arch/i386/stand/lib/bootinfo.h:1.10 src/sys/arch/i386/stand/lib/bootinfo.h:1.11
--- src/sys/arch/i386/stand/lib/bootinfo.h:1.10	Mon Nov 18 03:52:45 2013
+++ src/sys/arch/i386/stand/lib/bootinfo.h	Sun Jun  5 14:13:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.h,v 1.10 2013/11/18 03:52:45 jakllsch Exp $	*/
+/*	$NetBSD: bootinfo.h,v 1.11 2016/06/05 14:13:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -35,6 +35,8 @@ struct bootinfo {
 
 extern struct bootinfo *bootinfo;
 
+#define BTINFO_MAX	32
+
 #define BI_ALLOC(max) (bootinfo = alloc(sizeof(struct bootinfo) \
 + ((max) - 1) * sizeof(uint32_t))) \
   ->nentries = 0

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.60 src/sys/arch/i386/stand/lib/exec.c:1.61
--- src/sys/arch/i386/stand/lib/exec.c:1.60	Sun Jun  5 14:06:31 2016
+++ src/sys/arch/i386/stand/lib/exec.c	Sun Jun  5 14:13:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.60 2016/06/05 14:06:31 maxv Exp $	 */
+/*	$NetBSD: exec.c,v 1.61 2016/06/05 14:13:57 maxv Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -356,7 +356,7 @@ exec_netbsd(const char *file, physaddr_t
 	   file ? file : "NULL", loadaddr);
 #endif
 
-	BI_ALLOC(32); /* ??? */
+	BI_ALLOC(BTINFO_MAX);
 
 	BI_ADD(_console, BTINFO_CONSOLE, sizeof(struct btinfo_console));
 



CVS commit: src/sys/arch/i386/stand/lib

2016-06-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun  5 14:06:31 UTC 2016

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c exec.c

Log Message:
The bootinfo is refreshed each time the bootloader tries to execute a
kernel, so there's no point in using this global variable. Because of
this variable, only one "boot" command can be issued in the prompt, and
you have to reboot the machine if you mistyped the kernel name.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/i386/stand/lib/exec.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/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.44 src/sys/arch/i386/stand/lib/biosdisk.c:1.45
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.44	Sun Jan 18 20:18:07 2015
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Sun Jun  5 14:06:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.44 2015/01/18 20:18:07 jakllsch Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.45 2016/06/05 14:06:31 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -701,24 +701,13 @@ biosdisk_findpartition(int biosdev, dadd
 static void
 add_biosdisk_bootinfo(void)
 {
-	static bool done;
-
 	if (bootinfo == NULL) {
-		done = false;
 		return;
 	}
-	
-	if (done)
-		return;
-
 	BI_ADD(_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
 	BI_ADD(_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
-
-	done = true;
-
 	return;
 }
-
 #endif
 
 int

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.59 src/sys/arch/i386/stand/lib/exec.c:1.60
--- src/sys/arch/i386/stand/lib/exec.c:1.59	Sun Apr  6 19:18:00 2014
+++ src/sys/arch/i386/stand/lib/exec.c	Sun Jun  5 14:06:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.59 2014/04/06 19:18:00 jakllsch Exp $	 */
+/*	$NetBSD: exec.c,v 1.60 2016/06/05 14:06:31 maxv Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -411,7 +411,7 @@ exec_netbsd(const char *file, physaddr_t
 
 out:
 	BI_FREE();
-	bootinfo = 0;
+	bootinfo = NULL;
 	return -1;
 }
 



CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 14:00:13 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_rcv.c

Log Message:
Don't resume throttled CCBs when connection is terminating, except for
those being actively waited for. Stop unthrottling when reaching MaxCmdSN
again.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/iscsi/iscsi_rcv.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/iscsi/iscsi_rcv.c
diff -u src/sys/dev/iscsi/iscsi_rcv.c:1.19 src/sys/dev/iscsi/iscsi_rcv.c:1.20
--- src/sys/dev/iscsi/iscsi_rcv.c:1.19	Sun Jun  5 11:01:39 2016
+++ src/sys/dev/iscsi/iscsi_rcv.c	Sun Jun  5 14:00:12 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_rcv.c,v 1.19 2016/06/05 11:01:39 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_rcv.c,v 1.20 2016/06/05 14:00:12 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -1148,6 +1148,7 @@ receive_pdu(connection_t *conn, pdu_t *p
 
 	if (sn_a_lt_b(sess->MaxCmdSN, MaxCmdSN)) {
 		sess->MaxCmdSN = MaxCmdSN;
+
 		if (TAILQ_FIRST(>ccbs_throttled) == NULL) {
 			mutex_exit(>lock);
 			return 0;
@@ -1157,24 +1158,39 @@ receive_pdu(connection_t *conn, pdu_t *p
 
 		TAILQ_INIT();
 		while ((req_ccb = TAILQ_FIRST(>ccbs_throttled)) != NULL) {
-			throttle_ccb(req_ccb, FALSE);
-			TAILQ_INSERT_TAIL(, req_ccb, chain);
+			if (!conn->terminating ||
+			(req_ccb->flags & CCBF_WAITING) != 0) {
+throttle_ccb(req_ccb, FALSE);
+TAILQ_INSERT_TAIL(, req_ccb, chain);
+			}
 		}
-		mutex_exit(>lock);
 
 		while ((req_ccb = TAILQ_FIRST()) != NULL) {
+			if (!sernum_in_window(sess))
+break;
+			mutex_exit(>lock);
+
 			TAILQ_REMOVE(, req_ccb, chain);
 
 			DEBC(conn, 10, ("Unthrottling - ccb = %p, disp = %d\n",
 	req_ccb, req_ccb->disp));
 
-			if (req_ccb->flags & CCBF_WAITING) {
+			if ((req_ccb->flags & CCBF_WAITING) != 0) {
 cv_broadcast(>ccb_cv);
-			} else
+			} else {
 send_command(req_ccb, req_ccb->disp, FALSE, FALSE);
+			}
+
+			mutex_enter(>lock);
 		}
-	} else
-		mutex_exit(>lock);
+
+		while ((req_ccb = TAILQ_FIRST()) != NULL) {
+			TAILQ_REMOVE(, req_ccb, chain);
+			throttle_ccb(req_ccb, TRUE);
+		}
+	}
+
+	mutex_exit(>lock);
 
 	return 0;
 }



CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 13:54:28 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_send.c iscsi_utils.c

Log Message:
Handle freeing of PDU when referencing CCB is freed.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/iscsi/iscsi_send.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/iscsi/iscsi_utils.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/iscsi/iscsi_send.c
diff -u src/sys/dev/iscsi/iscsi_send.c:1.29 src/sys/dev/iscsi/iscsi_send.c:1.30
--- src/sys/dev/iscsi/iscsi_send.c:1.29	Sun Jun  5 09:12:48 2016
+++ src/sys/dev/iscsi/iscsi_send.c	Sun Jun  5 13:54:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_send.c,v 1.29 2016/06/05 09:12:48 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_send.c,v 1.30 2016/06/05 13:54:28 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -291,6 +291,7 @@ iscsi_send_thread(void *par)
 	ccb_t *ccb, *nccb;
 	pdu_t *pdu;
 	struct file *fp;
+	pdu_disp_t pdisp;
 
 	sess = conn->session;
 	/* so cleanup thread knows there's someone left */
@@ -302,6 +303,7 @@ iscsi_send_thread(void *par)
 			while (!conn->terminating &&
 (pdu = TAILQ_FIRST(>pdus_to_send)) != NULL) {
 TAILQ_REMOVE(>pdus_to_send, pdu, send_chain);
+pdu->flags &= ~PDUF_INQUEUE;
 mutex_exit(>lock);
 
 /* update ExpStatSN here to avoid discontinuities */
@@ -315,12 +317,14 @@ iscsi_send_thread(void *par)
 my_soo_write(conn, >uio);
 
 mutex_enter(>lock);
-pdu->flags &= ~PDUF_INQUEUE;
-if (pdu->disp > PDUDISP_FREE)
+pdisp = pdu->disp;
+if (pdisp <= PDUDISP_FREE)
+	pdu->disp = PDUDISP_UNUSED;
+else
 	pdu->flags &= ~PDUF_BUSY;
 mutex_exit(>lock);
 
-if (pdu->disp <= PDUDISP_FREE)
+if (pdisp <= PDUDISP_FREE)
 	free_pdu(pdu);
 
 mutex_enter(>lock);

Index: src/sys/dev/iscsi/iscsi_utils.c
diff -u src/sys/dev/iscsi/iscsi_utils.c:1.18 src/sys/dev/iscsi/iscsi_utils.c:1.19
--- src/sys/dev/iscsi/iscsi_utils.c:1.18	Sun Jun  5 09:21:14 2016
+++ src/sys/dev/iscsi/iscsi_utils.c	Sun Jun  5 13:54:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_utils.c,v 1.18 2016/06/05 09:21:14 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_utils.c,v 1.19 2016/06/05 13:54:28 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2008 The NetBSD Foundation, Inc.
@@ -268,16 +268,17 @@ void
 free_ccb(ccb_t *ccb)
 {
 	session_t *sess = ccb->session;
+	connection_t *conn = ccb->connection;
 	pdu_t *pdu;
 
-	DEBC(ccb->connection, 15, (
+	DEBC(conn, 15, (
 		"free_ccb: ccb = %p, usecount = %d\n",
-		ccb, ccb->connection->usecount-1));
+		ccb, conn->usecount-1));
 
 	KASSERT((ccb->flags & CCBF_THROTTLING) == 0);
 	KASSERT((ccb->flags & CCBF_WAITQUEUE) == 0);
 
-	atomic_dec_uint(>connection->usecount);
+	atomic_dec_uint(>usecount);
 	ccb->connection = NULL;
 
 	if (ccb->disp > CCBDISP_NOWAIT) {
@@ -296,6 +297,12 @@ free_ccb(ccb_t *ccb)
 	/* free PDU waiting for ACK */
 	if ((pdu = ccb->pdu_waiting) != NULL) {
 		ccb->pdu_waiting = NULL;
+		mutex_enter(>lock);
+		if ((pdu->flags & PDUF_INQUEUE) != 0) {
+			TAILQ_REMOVE(>pdus_to_send, pdu, send_chain);
+			pdu->flags &= ~PDUF_INQUEUE;
+		}
+		mutex_exit(>lock);
 		free_pdu(pdu);
 	}
 



CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 13:45:56 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_ioctl.c

Log Message:
More debug output. Dump pending CCBs when cleaning up.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/iscsi/iscsi_ioctl.c

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

Modified files:

Index: src/sys/dev/iscsi/iscsi_ioctl.c
diff -u src/sys/dev/iscsi/iscsi_ioctl.c:1.19 src/sys/dev/iscsi/iscsi_ioctl.c:1.20
--- src/sys/dev/iscsi/iscsi_ioctl.c:1.19	Sun Jun  5 08:30:13 2016
+++ src/sys/dev/iscsi/iscsi_ioctl.c	Sun Jun  5 13:45:56 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_ioctl.c,v 1.19 2016/06/05 08:30:13 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_ioctl.c,v 1.20 2016/06/05 13:45:56 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -1690,6 +1690,11 @@ iscsi_cleanup_thread(void *par)
 if (conn->usecount != last_usecount) {
 	DEBC(conn, 5,("Cleanup: %d CCBs busy\n", conn->usecount));
 	last_usecount = conn->usecount;
+	mutex_enter(>lock);
+	TAILQ_FOREACH(ccb, >ccbs_waiting, chain) {
+		DEBC(conn, 5,("Cleanup: ccb=%p disp=%d timedout=%d\n", ccb,ccb->disp, ccb->timedout));
+	}
+	mutex_exit(>lock);
 }
 kpause("finalwait", false, hz, NULL);
 			}



CVS commit: src/sys/lib/libsa

2016-06-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun  5 13:44:48 UTC 2016

Modified Files:
src/sys/lib/libsa: alloc.c

Log Message:
Remove the ALLOC_FIRST_FIT and ALLOC_TRACE options. This is a rather simple
allocator, and it does not need to be that complicated.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/lib/libsa/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/lib/libsa/alloc.c
diff -u src/sys/lib/libsa/alloc.c:1.26 src/sys/lib/libsa/alloc.c:1.27
--- src/sys/lib/libsa/alloc.c:1.26	Sat Jul 30 03:43:20 2011
+++ src/sys/lib/libsa/alloc.c	Sun Jun  5 13:44:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: alloc.c,v 1.26 2011/07/30 03:43:20 jakllsch Exp $	*/
+/*	$NetBSD: alloc.c,v 1.27 2016/06/05 13:44:48 maxv Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -103,11 +103,6 @@
  *
  * Compile options:
  *
- *	ALLOC_TRACE	enable tracing of allocations/deallocations
-
- *	ALLOC_FIRST_FIT	use a first-fit allocation algorithm, rather than
- *			the default best-fit algorithm.
- *
  *	HEAP_LIMIT	heap limit address (defaults to "no limit").
  *
  *	HEAP_START	start address of heap (defaults to '').
@@ -138,6 +133,9 @@
  * However, note that ALIGN(sizeof(unsigned int)) + ALIGN(data size) must
  * be at least 'sizeof(struct fl)', so that blocks can be used as structures
  * when on the free list.
+ *
+ * When HEAP_LIMIT is defined and the heap limit is reached, alloc() panics.
+ * Otherwise, it never fails.
  */
 struct fl {
 	unsigned int	size;
@@ -166,22 +164,10 @@ __compactcall void *
 alloc(size_t size)
 {
 	struct fl **f = , **bestf = NULL;
-#ifndef ALLOC_FIRST_FIT
 	unsigned int bestsize = 0x;	/* greater than any real size */
-#endif
 	char *help;
 	int failed;
 
-#ifdef ALLOC_TRACE
-	printf("alloc(%zu)", size);
-#endif
-
-#ifdef ALLOC_FIRST_FIT
-	while (*f != (struct fl *)0 && (size_t)(*f)->size < size)
-		f = &((*f)->next);
-	bestf = f;
-	failed = (*bestf == (struct fl *)0);
-#else
 	/* scan freelist */
 	while (*f) {
 		if ((size_t)(*f)->size >= size) {
@@ -199,7 +185,6 @@ alloc(size_t size)
 
 	/* no match in freelist if bestsize unchanged */
 	failed = (bestsize == 0x);
-#endif
 
 	if (failed) { /* nothing found */
 		/*
@@ -217,25 +202,16 @@ alloc(size_t size)
 			panic("heap full (%p+%zu)", help, size);
 #endif
 		*(unsigned int *)(void *)help = (unsigned int)ALIGN(size);
-#ifdef ALLOC_TRACE
-		printf("=%lx\n", (u_long)help + ALIGN(sizeof(unsigned int)));
-#endif
 		return help + ALIGN(sizeof(unsigned int));
 	}
 
 	/* we take the best fit */
 	f = bestf;
 
-#ifndef ALLOC_FIRST_FIT
 found:
-#endif
 	/* remove from freelist */
 	help = (char *)(void *)*f;
 	*f = (*f)->next;
-#ifdef ALLOC_TRACE
-	printf("=%lx (origsize %u)\n",
-	(u_long)help + ALIGN(sizeof(unsigned int)), *(unsigned int *)help);
-#endif
 	return help + ALIGN(sizeof(unsigned int));
 }
 
@@ -246,9 +222,6 @@ dealloc(void *ptr, size_t size)
 	struct fl *f =
 	(struct fl *)(void *)((char *)(void *)ptr -
 	ALIGN(sizeof(unsigned int)));
-#ifdef ALLOC_TRACE
-	printf("dealloc(%lx, %zu) (origsize %u)\n", (u_long)ptr, size, f->size);
-#endif
 #ifdef DEBUG
 	if (size > (size_t)f->size) {
 		printf("dealloc %zu bytes @%lx, should be <=%u\n",



CVS commit: src/sys

2016-06-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun  5 13:33:03 UTC 2016

Modified Files:
src/sys/arch/i386/stand/lib: bootmenu.c menuutils.c
src/sys/lib/libsa: gets.c stand.h

Log Message:
Use gets_s instead of gets. The x86 bootloader prompt is easy to
overflow.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/i386/stand/lib/bootmenu.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/lib/menuutils.c
cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/gets.c
cvs rdiff -u -r1.79 -r1.80 src/sys/lib/libsa/stand.h

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

Modified files:

Index: src/sys/arch/i386/stand/lib/bootmenu.c
diff -u src/sys/arch/i386/stand/lib/bootmenu.c:1.14 src/sys/arch/i386/stand/lib/bootmenu.c:1.15
--- src/sys/arch/i386/stand/lib/bootmenu.c:1.14	Sun Aug 10 07:40:49 2014
+++ src/sys/arch/i386/stand/lib/bootmenu.c	Sun Jun  5 13:33:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootmenu.c,v 1.14 2014/08/10 07:40:49 isaki Exp $	*/
+/*	$NetBSD: bootmenu.c,v 1.15 2016/06/05 13:33:03 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -178,7 +178,7 @@ doboottypemenu(void)
 printf("\nOption: [%d]:",
 bootcfg_info.def + 1);
 
-			gets(input);
+			gets_s(input, sizeof(input));
 			choice = getchoicefrominput(input, bootcfg_info.def);
 		} else if (bootcfg_info.timeout == 0)
 			choice = bootcfg_info.def;

Index: src/sys/arch/i386/stand/lib/menuutils.c
diff -u src/sys/arch/i386/stand/lib/menuutils.c:1.4 src/sys/arch/i386/stand/lib/menuutils.c:1.5
--- src/sys/arch/i386/stand/lib/menuutils.c:1.4	Sun Apr  6 19:11:26 2014
+++ src/sys/arch/i386/stand/lib/menuutils.c	Sun Jun  5 13:33:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: menuutils.c,v 1.4 2014/04/06 19:11:26 jakllsch Exp $	*/
+/*	$NetBSD: menuutils.c,v 1.5 2016/06/05 13:33:03 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997
@@ -71,7 +71,7 @@ bootmenu(void)
 
 		input[0] = '\0';
 		printf("> ");
-		gets(input);
+		gets_s(input, sizeof(input));
 
 		/*
 		 * Skip leading whitespace.

Index: src/sys/lib/libsa/gets.c
diff -u src/sys/lib/libsa/gets.c:1.10 src/sys/lib/libsa/gets.c:1.11
--- src/sys/lib/libsa/gets.c:1.10	Sat Nov 24 13:20:55 2007
+++ src/sys/lib/libsa/gets.c	Sun Jun  5 13:33:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: gets.c,v 1.10 2007/11/24 13:20:55 isaki Exp $	*/
+/*	$NetBSD: gets.c,v 1.11 2016/06/05 13:33:03 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -85,3 +85,61 @@ gets(char *buf)
 	}
 	/*NOTREACHED*/
 }
+
+void
+gets_s(char *buf, size_t size)
+{
+	int c;
+	char *lp;
+
+	for (lp = buf;;) {
+		if (lp - buf == size) {
+			lp--;
+			*lp = '\0';
+			return;
+		}
+		switch (c = getchar() & 0177) {
+		case '\n':
+		case '\r':
+			*lp = '\0';
+			putchar('\n');
+			return;
+		case '\b':
+		case '\177':
+			if (lp > buf) {
+lp--;
+putchar('\b');
+putchar(' ');
+putchar('\b');
+			}
+			break;
+#if HASH_ERASE
+		case '#':
+			if (lp > buf)
+--lp;
+			break;
+#endif
+		case 'r' & 037: {
+			char *p;
+
+			putchar('\n');
+			for (p = buf; p < lp; ++p)
+putchar(*p);
+			break;
+		}
+#if AT_ERASE
+		case '@':
+#endif
+		case 'u' & 037:
+		case 'w' & 037:
+			lp = buf;
+			putchar('\n');
+			break;
+		default:
+			*lp++ = c;
+			putchar(c);
+			break;
+		}
+	}
+	/*NOTREACHED*/
+}

Index: src/sys/lib/libsa/stand.h
diff -u src/sys/lib/libsa/stand.h:1.79 src/sys/lib/libsa/stand.h:1.80
--- src/sys/lib/libsa/stand.h:1.79	Sun Aug 10 07:40:49 2014
+++ src/sys/lib/libsa/stand.h	Sun Jun  5 13:33:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: stand.h,v 1.79 2014/08/10 07:40:49 isaki Exp $	*/
+/*	$NetBSD: stand.h,v 1.80 2016/06/05 13:33:03 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -78,6 +78,7 @@
 #ifdef LIBSA_RENAME_PRINTF
 #define getchar		libsa_getchar
 #define gets		libsa_gets
+#define gets_s		libsa_gets_s
 #define printf		libsa_printf
 #define putchar		libsa_putchar
 #define vprintf		libsa_vprintf
@@ -258,6 +259,7 @@ int	vsnprintf(char *, size_t, const char
 __attribute__((__format__(__printf__, 3, 0)));
 void	twiddle(void);
 void	gets(char *);
+void	gets_s(char *, size_t);
 int	getfile(char *prompt, int mode);
 char	*strerror(int);
 __dead void	exit(int);



CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 11:01:39 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_rcv.c

Log Message:
more debug output


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/iscsi/iscsi_rcv.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/iscsi/iscsi_rcv.c
diff -u src/sys/dev/iscsi/iscsi_rcv.c:1.18 src/sys/dev/iscsi/iscsi_rcv.c:1.19
--- src/sys/dev/iscsi/iscsi_rcv.c:1.18	Sun Jun  5 05:40:29 2016
+++ src/sys/dev/iscsi/iscsi_rcv.c	Sun Jun  5 11:01:39 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_rcv.c,v 1.18 2016/06/05 05:40:29 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_rcv.c,v 1.19 2016/06/05 11:01:39 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -132,13 +132,20 @@ ccb_from_itt(connection_t *conn, uint32_
 
 	ccb = >session->ccb[cidx];
 
-	if (ccb->ITT != itt || ccb->disp <= CCBDISP_BUSY) {
+	if (ccb->ITT != itt) {
 		DEBC(conn, 0,
 		 ("ccb_from_itt: received invalid CCB itt %08x != %08x\n",
 		  itt, ccb->ITT));
 		return NULL;
 	}
 
+	if (ccb->disp <= CCBDISP_BUSY) {
+		DEBC(conn, 0,
+		 ("ccb_from_itt: received CCB with invalid disp %d\n",
+		  ccb->disp));
+		return NULL;
+	}
+
 	return ccb;
 }
 
@@ -1029,7 +1036,8 @@ receive_pdu(connection_t *conn, pdu_t *p
 		}
 	}
 
-	DEBC(conn, 99, ("Received PDU ExpCmdSN = %u\n",
+	DEBC(conn, 99, ("Received PDU ExpCmdSN = %u, MaxCmdSN = %u\n",
+	 ntohl(pdu->pdu.p.response.ExpCmdSN),
 	 ntohl(pdu->pdu.p.response.ExpCmdSN)));
 
 	req_ccb = ccb_from_itt(conn, pdu->pdu.InitiatorTaskTag);



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

2016-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun  5 10:50:36 UTC 2016

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

Log Message:
Sync with HEAD


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.70 -r1.28.2.71 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.70 src/sys/dev/usb/xhci.c:1.28.2.71
--- src/sys/dev/usb/xhci.c:1.28.2.70	Mon May 30 06:48:46 2016
+++ src/sys/dev/usb/xhci.c	Sun Jun  5 10:50:36 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.28.2.70 2016/05/30 06:48:46 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.28.2.71 2016/06/05 10:50:36 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.70 2016/05/30 06:48:46 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.71 2016/06/05 10:50:36 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -142,13 +142,16 @@ static usbd_status xhci_configure_endpoi
 static usbd_status xhci_reset_endpoint(struct usbd_pipe *);
 static usbd_status xhci_stop_endpoint(struct usbd_pipe *);
 
+static void xhci_host_dequeue(struct xhci_ring * const);
 static usbd_status xhci_set_dequeue(struct usbd_pipe *);
 
 static usbd_status xhci_do_command(struct xhci_softc * const,
 struct xhci_trb * const, int);
 static usbd_status xhci_do_command_locked(struct xhci_softc * const,
 struct xhci_trb * const, int);
-static usbd_status xhci_init_slot(struct usbd_device *, uint32_t, uint32_t, int);
+static usbd_status xhci_init_slot(struct usbd_device *, uint32_t);
+static void xhci_free_slot(struct xhci_softc *, struct xhci_slot *, int, int);
+static usbd_status xhci_set_address(struct usbd_device *, uint32_t, bool);
 static usbd_status xhci_enable_slot(struct xhci_softc * const,
 uint8_t * const);
 static usbd_status xhci_disable_slot(struct xhci_softc * const, uint8_t);
@@ -161,6 +164,12 @@ static usbd_status xhci_ring_init(struct
 struct xhci_ring * const, size_t, size_t);
 static void xhci_ring_free(struct xhci_softc * const, struct xhci_ring * const);
 
+static void xhci_setup_ctx(struct usbd_pipe *);
+static void xhci_setup_route(struct usbd_pipe *, uint32_t *);
+static void xhci_setup_tthub(struct usbd_pipe *, uint32_t *);
+static void xhci_setup_maxburst(struct usbd_pipe *, uint32_t *);
+static uint32_t xhci_bival2ival(uint32_t, uint32_t);
+
 static void xhci_noop(struct usbd_pipe *);
 
 static usbd_status xhci_root_intr_transfer(struct usbd_xfer *);
@@ -559,7 +568,6 @@ xhci_detach(struct xhci_softc *sc, int f
 
 	mutex_destroy(>sc_lock);
 	mutex_destroy(>sc_intr_lock);
-	cv_destroy(>sc_softwake_cv);
 
 	pool_cache_destroy(sc->sc_xferpool);
 
@@ -1020,7 +1028,6 @@ xhci_init(struct xhci_softc *sc)
 	cv_init(>sc_cmdbusy_cv, "xhcicmdq");
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
 	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_USB);
-	cv_init(>sc_softwake_cv, "xhciab");
 
 	/* Set up the bus struct. */
 	sc->sc_bus.ub_methods = _bus_methods;
@@ -1029,7 +1036,7 @@ xhci_init(struct xhci_softc *sc)
 	struct xhci_erste *erst;
 	erst = KERNADDR(>sc_eventst_dma, 0);
 	erst[0].erste_0 = htole64(xhci_ring_trbp(>sc_er, 0));
-	erst[0].erste_2 = htole32(XHCI_EVENT_RING_TRBS);
+	erst[0].erste_2 = htole32(sc->sc_er.xr_ntrb);
 	erst[0].erste_3 = htole32(0);
 	usb_syncmem(>sc_eventst_dma, 0,
 	XHCI_ERSTE_SIZE * XHCI_EVENT_RING_SEGMENTS, BUS_DMASYNC_PREWRITE);
@@ -1053,7 +1060,7 @@ xhci_init(struct xhci_softc *sc)
 		xhci_rt_write_4(sc, XHCI_IMOD(0), XHCI_IMOD_DEFAULT_LP);
 	else
 		xhci_rt_write_4(sc, XHCI_IMOD(0), 0);
-	aprint_debug_dev(sc->sc_dev, "setting IMOD %u\n",
+	aprint_debug_dev(sc->sc_dev, "current IMOD %u\n",
 	xhci_rt_read_4(sc, XHCI_IMOD(0)));
 
 	xhci_op_write_4(sc, XHCI_USBCMD, XHCI_CMD_INTE|XHCI_CMD_RS); /* Go! */
@@ -1216,269 +1223,8 @@ xhci_xspeed2psspeed(int xspeed)
 	}
 }
 
-/* construct slot context */
-static void
-xhci_setup_sctx(struct usbd_device *dev, uint32_t *cp)
-{
-	usb_device_descriptor_t * const dd = >ud_ddesc;
-	int speed = dev->ud_speed;
-	int tthubslot, ttportnum;
-	bool ishub;
-	bool usemtt;
-
-	XHCIHIST_FUNC(); XHCIHIST_CALLED();
-
-	/*
-	 * 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.
-	 *   This is 0 if device is not LS/FS device ||
-	 *   parent hub is not HS hub ||
-	 *   attached to root hub.
-	 * ttportnum:
-	 *   This is the downstream facing port of parent HS hub
-	 *   if LS/FS device is connected.
-	 *   This is 0 if device is not LS/FS device ||
-	 *   parent hub is not HS hub ||
-	 *   attached to root hub.
-	 */
-	if (dev->ud_myhsport != NULL &&
-	dev->ud_myhub != NULL && dev->ud_myhub->ud_depth != 0 &&
-	(dev->ud_myhub != NULL &&
-	 dev->ud_myhub->ud_speed == USB_SPEED_HIGH) &&

CVS commit: src/sys/dev/usb

2016-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun  5 10:45:16 UTC 2016

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

Log Message:
PR/51202: XHCI driver sends stale TRBs from a pipe previously opened

Use xhci_host_dequeue in xhci_set_dequeue


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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.55 src/sys/dev/usb/xhci.c:1.56
--- src/sys/dev/usb/xhci.c:1.55	Sun Jun  5 09:16:02 2016
+++ src/sys/dev/usb/xhci.c	Sun Jun  5 10:45:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.55 2016/06/05 09:16:02 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.56 2016/06/05 10:45:16 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.55 2016/06/05 09:16:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.56 2016/06/05 10:45:16 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1356,13 +1356,7 @@ xhci_set_dequeue(struct usbd_pipe *pipe)
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
 	DPRINTFN(4, "slot %u dci %u", xs->xs_idx, dci, 0, 0);
 
-	memset(xr->xr_trb, 0, xr->xr_ntrb * XHCI_TRB_SIZE);
-	usb_syncmem(>xr_dma, 0, xr->xr_ntrb * XHCI_TRB_SIZE,
-	BUS_DMASYNC_PREWRITE);
-	memset(xr->xr_cookies, 0, xr->xr_ntrb * sizeof(*xr->xr_cookies));
-
-	xr->xr_ep = 0;
-	xr->xr_cs = 1;
+	xhci_host_dequeue(xr);
 
 	/* set DCS */
 	trb.trb_0 = xhci_ring_trbp(xr, 0) | 1; /* XXX */



CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 09:21:14 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_utils.c

Log Message:
acquire session lock when changing throttling queue


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/iscsi/iscsi_utils.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/iscsi/iscsi_utils.c
diff -u src/sys/dev/iscsi/iscsi_utils.c:1.17 src/sys/dev/iscsi/iscsi_utils.c:1.18
--- src/sys/dev/iscsi/iscsi_utils.c:1.17	Sun Jun  5 09:03:10 2016
+++ src/sys/dev/iscsi/iscsi_utils.c	Sun Jun  5 09:21:14 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_utils.c,v 1.17 2016/06/05 09:03:10 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_utils.c,v 1.18 2016/06/05 09:21:14 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2008 The NetBSD Foundation, Inc.
@@ -398,8 +398,10 @@ wake_ccb(ccb_t *ccb, uint32_t status)
 {
 	ccb_disp_t disp;
 	connection_t *conn;
+	session_t *sess;
 
 	conn = ccb->connection;
+	sess = ccb->session;
 
 #ifdef ISCSI_DEBUG
 	DEBC(conn, 9, ("CCB done, ccb = %p, disp = %d\n",
@@ -417,13 +419,16 @@ wake_ccb(ccb_t *ccb, uint32_t status)
 	}
 
 	suspend_ccb(ccb, FALSE);
-	throttle_ccb(ccb, FALSE);
 
 	/* change the disposition so nobody tries this again */
 	ccb->disp = CCBDISP_BUSY;
 	ccb->status = status;
 	mutex_exit(>lock);
 
+	mutex_enter(>lock);
+	throttle_ccb(ccb, FALSE);
+	mutex_exit(>lock);
+
 	switch (disp) {
 	case CCBDISP_FREE:
 		free_ccb(ccb);



CVS commit: src/sys/dev/usb

2016-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun  5 09:16:02 UTC 2016

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

Log Message:
PR/51202: XHCI driver sends stale TRBs from a pipe previously opened

A similar patch was sent to me by t-hash and the xhci_setup_ctx is taken
from that.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 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.54 src/sys/dev/usb/xhci.c:1.55
--- src/sys/dev/usb/xhci.c:1.54	Sun Jun  5 08:25:05 2016
+++ src/sys/dev/usb/xhci.c	Sun Jun  5 09:16:02 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.54 2016/06/05 08:25:05 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.55 2016/06/05 09:16:02 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.54 2016/06/05 08:25:05 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.55 2016/06/05 09:16:02 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -142,6 +142,7 @@ static usbd_status xhci_configure_endpoi
 static usbd_status xhci_reset_endpoint(struct usbd_pipe *);
 static usbd_status xhci_stop_endpoint(struct usbd_pipe *);
 
+static void xhci_host_dequeue(struct xhci_ring * const);
 static usbd_status xhci_set_dequeue(struct usbd_pipe *);
 
 static usbd_status xhci_do_command(struct xhci_softc * const,
@@ -1500,6 +1501,9 @@ xhci_close_pipe(struct usbd_pipe *pipe)
 	cp = xhci_slot_get_icv(sc, xs, xhci_dci_to_ici(XHCI_DCI_SLOT));
 	cp[0] = htole32(XHCI_SCTX_0_CTX_NUM_SET(dci));
 
+	/* configure ep context performs an implicit dequeue */
+	xhci_host_dequeue(>xs_ep[dci].xe_tr);
+
 	/* sync input contexts before they are read from memory */
 	usb_syncmem(>xs_ic_dma, 0, sc->sc_pgsz, BUS_DMASYNC_PREWRITE);
 
@@ -1545,6 +1549,19 @@ xhci_abort_xfer(struct usbd_xfer *xfer, 
 	KASSERT(mutex_owned(>sc_lock));
 }
 
+static void
+xhci_host_dequeue(struct xhci_ring * const xr)
+{
+	/* When dequeueing the controller, update our struct copy too */
+	memset(xr->xr_trb, 0, xr->xr_ntrb * XHCI_TRB_SIZE);
+	usb_syncmem(>xr_dma, 0, xr->xr_ntrb * XHCI_TRB_SIZE,
+	BUS_DMASYNC_PREWRITE);
+	memset(xr->xr_cookies, 0, xr->xr_ntrb * sizeof(*xr->xr_cookies));
+
+	xr->xr_ep = 0;
+	xr->xr_cs = 1;
+}
+
 /*
  * Recover STALLed endpoint.
  * xHCI 1.1 sect 4.10.2.1
@@ -2173,11 +2190,8 @@ xhci_ring_init(struct xhci_softc * const
 	xr->xr_cookies = kmem_zalloc(sizeof(*xr->xr_cookies) * ntrb, KM_SLEEP);
 	xr->xr_trb = xhci_ring_trbv(xr, 0);
 	xr->xr_ntrb = ntrb;
-	xr->xr_ep = 0;
-	xr->xr_cs = 1;
-	memset(xr->xr_trb, 0, size);
-	usb_syncmem(>xr_dma, 0, size, BUS_DMASYNC_PREWRITE);
 	xr->is_halted = false;
+	xhci_host_dequeue(xr);
 
 	return USBD_NORMAL_COMPLETION;
 }
@@ -2751,6 +2765,7 @@ xhci_setup_ctx(struct usbd_pipe *pipe)
 	DPRINTFN(4, "setting ival %u MaxBurst %#x",
 	XHCI_EPCTX_0_IVAL_GET(cp[0]), XHCI_EPCTX_1_MAXB_GET(cp[1]), 0, 0);
 
+	/* rewind TR dequeue pointer in xHC */
 	/* can't use xhci_ep_get_dci() yet? */
 	*(uint64_t *)([2]) = htole64(
 	xhci_ring_trbp(>xs_ep[dci].xe_tr, 0) |
@@ -2760,6 +2775,12 @@ xhci_setup_ctx(struct usbd_pipe *pipe)
 	cp[1] = htole32(cp[1]);
 	cp[4] = htole32(cp[4]);
 
+	/* rewind TR dequeue pointer in driver */
+	struct xhci_ring *xr = >xs_ep[dci].xe_tr;
+	mutex_enter(>xr_lock);
+	xhci_host_dequeue(xr);
+	mutex_exit(>xr_lock);
+
 	/* sync input contexts before they are read from memory */
 	usb_syncmem(>xs_ic_dma, 0, sc->sc_pgsz, BUS_DMASYNC_PREWRITE);
 }



CVS commit: src/sbin/nvmectl

2016-06-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Jun  5 09:13:08 UTC 2016

Modified Files:
src/sbin/nvmectl: nvmectl.8

Log Message:
Try improving SYNOPSIS per my understanding of how this works.
Use more markup. Fix some markup.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/nvmectl/nvmectl.8

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

Modified files:

Index: src/sbin/nvmectl/nvmectl.8
diff -u src/sbin/nvmectl/nvmectl.8:1.1 src/sbin/nvmectl/nvmectl.8:1.2
--- src/sbin/nvmectl/nvmectl.8:1.1	Sat Jun  4 16:29:35 2016
+++ src/sbin/nvmectl/nvmectl.8	Sun Jun  5 09:13:08 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: nvmectl.8,v 1.1 2016/06/04 16:29:35 nonaka Exp $
+.\" $NetBSD: nvmectl.8,v 1.2 2016/06/05 09:13:08 wiz Exp $
 .\"
 .\" Copyright (c) 2012 Intel Corporation
 .\" All rights reserved.
@@ -45,14 +45,13 @@
 .Ic devlist
 .Nm
 .Ic identify
-.Op Fl v
-.Op Fl x
-.Aq device id
+.Op Fl x Op Fl v
+.Ar device_id
 .\".Nm
 .\".Ic perftest
+.\".Op Fl p
 .\".Aq Fl n Ar num_threads
 .\".Aq Fl o Ar read|write
-.\".Op Fl p
 .\".Aq Fl s Ar size_in_bytes
 .\".Aq Fl t Ar time_in_sec
 .\".Aq namespace id
@@ -61,21 +60,21 @@
 .\".Aq controller id
 .Nm
 .Ic logpage
-.Aq Fl p Ar page_id
 .Op Fl x
-.Aq device id
-.Aq namespace id
+.Op Fl p Ar page_id
+.Ar device_id Ns | Ns Ar namespace_id
 .\".Nm
 .\".Ic firmware
+.\".Op Fl a
 .\".Op Fl s Ar slot
 .\".Op Fl f Ar path_to_firmware
-.\".Op Fl a
 .\".Aq device id
 .Nm
 .Ic power
 .Op Fl l
-.Op Fl p power_state
-.Op fl w workload_hint
+.Op Fl p Ar power_state
+.Op Fl w Ar workload_hint
+.Ar device_id
 .Sh DESCRIPTION
 NVM Express (NVMe) is a storage protocol standard, for SSDs and other
 high-speed storage devices over PCI Express.
@@ -90,8 +89,9 @@ Display a human-readable summary of the 
 .Pp
 .Dl nvmectl identify -x -v nvme0ns1
 .Pp
-Display an hexadecimal dump of the nvme0 IDENTIFY_NAMESPACE data for namespace
-1.
+Display an hexadecimal dump of the nvme0
+.Dv IDENTIFY_NAMESPACE
+data for namespace 1.
 .\".Pp
 .\".Dl nvmectl perftest -n 32 -o read -s 512 -t 30 nvme0ns1
 .\".Pp



CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 09:12:49 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_send.c

Log Message:
wrong assertion.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/iscsi/iscsi_send.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/iscsi/iscsi_send.c
diff -u src/sys/dev/iscsi/iscsi_send.c:1.28 src/sys/dev/iscsi/iscsi_send.c:1.29
--- src/sys/dev/iscsi/iscsi_send.c:1.28	Sun Jun  5 09:09:57 2016
+++ src/sys/dev/iscsi/iscsi_send.c	Sun Jun  5 09:12:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_send.c,v 1.28 2016/06/05 09:09:57 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_send.c,v 1.29 2016/06/05 09:12:48 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -304,8 +304,6 @@ iscsi_send_thread(void *par)
 TAILQ_REMOVE(>pdus_to_send, pdu, send_chain);
 mutex_exit(>lock);
 
-KASSERT(!pdu->uio.uio_resid);
-
 /* update ExpStatSN here to avoid discontinuities */
 /* and delays in updating target */
 pdu->pdu.p.command.ExpStatSN = htonl(conn->StatSN_buf.ExpSN);



CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 09:09:57 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_send.c

Log Message:
Need session mutex to read serial number.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/iscsi/iscsi_send.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/iscsi/iscsi_send.c
diff -u src/sys/dev/iscsi/iscsi_send.c:1.27 src/sys/dev/iscsi/iscsi_send.c:1.28
--- src/sys/dev/iscsi/iscsi_send.c:1.27	Sun Jun  5 06:19:59 2016
+++ src/sys/dev/iscsi/iscsi_send.c	Sun Jun  5 09:09:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_send.c,v 1.27 2016/06/05 06:19:59 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_send.c,v 1.28 2016/06/05 09:09:57 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -629,7 +629,9 @@ init_login_pdu(connection_t *conn, ccb_t
 
 	pdu->Opcode = IOP_Login_Request | OP_IMMEDIATE;
 
+	mutex_enter(>session->lock);
 	ccb->CmdSN = get_sernum(conn->session, false);
+	mutex_exit(>session->lock);
 
 	if (next) {
 		c_phase = (pdu->Flags >> CSG_SHIFT) & SG_MASK;
@@ -741,7 +743,9 @@ init_text_pdu(connection_t *conn, ccb_t 
 	pdu->Opcode = IOP_Text_Request | OP_IMMEDIATE;
 	pdu->Flags = FLAG_FINAL;
 
+	mutex_enter(>session->lock);
 	ccb->CmdSN = get_sernum(conn->session, false);
+	mutex_exit(>session->lock);
 
 	if (rx_pdu != NULL) {
 		pdu->p.text_req.TargetTransferTag =



CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 09:03:10 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_utils.c

Log Message:
initialize before check.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/iscsi/iscsi_utils.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/iscsi/iscsi_utils.c
diff -u src/sys/dev/iscsi/iscsi_utils.c:1.16 src/sys/dev/iscsi/iscsi_utils.c:1.17
--- src/sys/dev/iscsi/iscsi_utils.c:1.16	Sun Jun  5 05:41:53 2016
+++ src/sys/dev/iscsi/iscsi_utils.c	Sun Jun  5 09:03:10 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_utils.c,v 1.16 2016/06/05 05:41:53 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_utils.c,v 1.17 2016/06/05 09:03:10 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2008 The NetBSD Foundation, Inc.
@@ -367,9 +367,10 @@ throttle_ccb(ccb_t *ccb, bool yes)
 {
 	session_t *sess;
 
+	sess = ccb->session;
+
 	KASSERT(mutex_owned(>lock));
 
-	sess = ccb->session;
 	if (yes) {
 		KASSERT((ccb->flags & CCBF_THROTTLING) == 0);
 		KASSERT((ccb->flags & CCBF_WAITQUEUE) == 0);



CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 08:30:13 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_ioctl.c

Log Message:
appease compiler


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/iscsi/iscsi_ioctl.c

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

Modified files:

Index: src/sys/dev/iscsi/iscsi_ioctl.c
diff -u src/sys/dev/iscsi/iscsi_ioctl.c:1.18 src/sys/dev/iscsi/iscsi_ioctl.c:1.19
--- src/sys/dev/iscsi/iscsi_ioctl.c:1.18	Sun Jun  5 04:48:17 2016
+++ src/sys/dev/iscsi/iscsi_ioctl.c	Sun Jun  5 08:30:13 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_ioctl.c,v 1.18 2016/06/05 04:48:17 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_ioctl.c,v 1.19 2016/06/05 08:30:13 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -1789,7 +1789,7 @@ iscsi_cleanup_thread(void *par)
 }
 
 void
-iscsi_init_cleanup()
+iscsi_init_cleanup(void)
 {
 
 	mutex_init(_cleanup_mtx, MUTEX_DEFAULT, IPL_BIO);
@@ -1803,7 +1803,7 @@ iscsi_init_cleanup()
 }
 
 void
-iscsi_destroy_cleanup()
+iscsi_destroy_cleanup(void)
 {
 	
 	iscsi_detaching = true;
@@ -1820,7 +1820,7 @@ iscsi_destroy_cleanup()
 }
 
 void
-iscsi_notify_cleanup()
+iscsi_notify_cleanup(void)
 {
 	cv_signal(_cleanup_cv);
 }



CVS commit: src/sys/dev/usb

2016-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun  5 08:25:05 UTC 2016

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

Log Message:
Update some comments.  Some from t-hash with updates from me.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 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.53 src/sys/dev/usb/xhci.c:1.54
--- src/sys/dev/usb/xhci.c:1.53	Sun Jun  5 08:12:00 2016
+++ src/sys/dev/usb/xhci.c	Sun Jun  5 08:25:05 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.53 2016/06/05 08:12:00 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.54 2016/06/05 08:25:05 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.53 2016/06/05 08:12:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.54 2016/06/05 08:25:05 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1219,7 +1219,7 @@ xhci_xspeed2psspeed(int xspeed)
 }
 
 /*
- * Construct input contexts and issue TRB
+ * Construct input contexts and issue TRB to open pipe.
  */
 static usbd_status
 xhci_configure_endpoint(struct usbd_pipe *pipe)
@@ -1336,9 +1336,11 @@ xhci_stop_endpoint(struct usbd_pipe *pip
 
 /*
  * Set TR Dequeue Pointer.
- * xCHI 1.1  4.6.10  6.4.3.9
- * Purge all of the transfer requests on ring.
- * EPSTATE of endpoint must be ERROR or STOPPED, or CONTEXT_STATE error.
+ * xHCI 1.1  4.6.10  6.4.3.9
+ * Purge all of the TRBs on ring and reinitialize ring.
+ * Set TR dequeue Pointr to 0 and Cycle State to 1.
+ * EPSTATE of endpoint must be ERROR or STOPPED, otherwise CONTEXT_STATE
+ * error will be generated.
  */
 static usbd_status
 xhci_set_dequeue(struct usbd_pipe *pipe)
@@ -1512,7 +1514,6 @@ xhci_close_pipe(struct usbd_pipe *pipe)
 
 /*
  * Abort transfer.
- * Called with sc_lock held.
  * May be called from softintr context.
  */
 static void
@@ -1529,7 +1530,7 @@ xhci_abort_xfer(struct usbd_xfer *xfer, 
 	if (sc->sc_dying) {
 		/* If we're dying, just do the software part. */
 		DPRINTFN(4, "xfer %p dying %u", xfer, xfer->ux_status, 0, 0);
-		xfer->ux_status = status;  /* make software ignore it */
+		xfer->ux_status = status;
 		callout_stop(>ux_callout);
 		usb_transfer_complete(xfer);
 		return;
@@ -1672,7 +1673,7 @@ xhci_event_transfer(struct xhci_softc * 
 			0, 0);
 		}
 	} else {
-		/* When ED != 0, trb_0 is kaddr of struct xhci_xfer. */
+		/* When ED != 0, trb_0 is virtual addr of struct xhci_xfer. */
 		xx = (void *)(uintptr_t)(trb_0 & ~0x3);
 	}
 	/* XXX this may not happen */
@@ -1709,6 +1710,26 @@ xhci_event_transfer(struct xhci_softc * 
 	switch (trbcode) {
 	case XHCI_TRB_ERROR_SHORT_PKT:
 	case XHCI_TRB_ERROR_SUCCESS:
+		/*
+		 * A ctrl transfer generates two events if it has a Data stage.
+		 * After a successful Data stage we cannot call call
+		 * usb_transfer_complete - this can only happen after the Data
+		 * stage.
+		 *
+		 * Note: Data and Status stage events point at same xfer.
+		 * ux_actlen and ux_dmabuf will be passed to
+		 * usb_transfer_complete after the Status stage event.
+		 *
+		 * It can be distingished which stage generates the event:
+		 * + by checking least 3 bits of trb_0 if ED==1.
+		 *   (see xhci_device_ctrl_start).
+		 * + by checking the type of original TRB if ED==0.
+		 *
+		 * In addition, intr, bulk, and isoc transfer currently
+		 * consists of single TD, so the "skip" is not needed.
+		 * ctrl xfer uses EVENT_DATA, and others do not.
+		 * Thus driver can switch the flow by checking ED bit.
+		 */
 		xfer->ux_actlen =
 		xfer->ux_length - XHCI_TRB_2_REM_GET(trb_2);
 		err = USBD_NORMAL_COMPLETION;
@@ -1954,6 +1975,7 @@ extern uint32_t usb_cookie_no;
  *   Determine initial MaxPacketSize (mps) by speed.
  *   Read full device descriptor.
  *   Register this device.
+ * Finally state of device transitions ADDRESSED.
  */
 static usbd_status
 xhci_new_device(device_t parent, struct usbd_bus *bus, int depth,
@@ -2270,7 +2292,7 @@ xhci_ring_put(struct xhci_softc * const 
 
 /*
  * Stop execution commands, purge all commands on command ring, and
- * rewind enqueue pointer.
+ * rewind dequeue pointer.
  */
 static void
 xhci_abort_command(struct xhci_softc *sc)
@@ -2310,10 +2332,10 @@ xhci_abort_command(struct xhci_softc *sc
 
 /*
  * Put a command on command ring, ring bell, set timer, and cv_timedwait.
- * Command completion is notified by cv_signal from xhci_handle_event
- * (called from interrupt from xHCI), or timed-out.
- * Command validation is performed in xhci_handle_event by checking if
- * trb_0 in CMD_COMPLETE TRB and sc->sc_command_addr are identical.
+ * Command completion is notified by cv_signal from xhci_event_cmd()
+ * (called from xhci_softint), or timed-out.
+ * The completion code is copied to sc->sc_result_trb in xhci_event_cmd(),
+ * then do_command examines it.
  */
 

CVS commit: src/sys/dev/usb

2016-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun  5 08:12:00 UTC 2016

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

Log Message:
More debug


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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.52 src/sys/dev/usb/xhci.c:1.53
--- src/sys/dev/usb/xhci.c:1.52	Sun Jun  5 08:10:59 2016
+++ src/sys/dev/usb/xhci.c	Sun Jun  5 08:12:00 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.52 2016/06/05 08:10:59 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.53 2016/06/05 08:12:00 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.52 2016/06/05 08:10:59 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.53 2016/06/05 08:12:00 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1055,7 +1055,7 @@ xhci_init(struct xhci_softc *sc)
 		xhci_rt_write_4(sc, XHCI_IMOD(0), XHCI_IMOD_DEFAULT_LP);
 	else
 		xhci_rt_write_4(sc, XHCI_IMOD(0), 0);
-	aprint_debug_dev(sc->sc_dev, "setting IMOD %u\n",
+	aprint_debug_dev(sc->sc_dev, "current IMOD %u\n",
 	xhci_rt_read_4(sc, XHCI_IMOD(0)));
 
 	xhci_op_write_4(sc, XHCI_USBCMD, XHCI_CMD_INTE|XHCI_CMD_RS); /* Go! */
@@ -1387,9 +1387,13 @@ xhci_open(struct usbd_pipe *pipe)
 	const uint8_t xfertype = UE_GET_XFERTYPE(ed->bmAttributes);
 
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
-	DPRINTFN(1, "addr %d depth %d port %d speed %d",
-	dev->ud_addr, dev->ud_depth, dev->ud_powersrc->up_portno,
-	dev->ud_speed);
+	DPRINTFN(1, "addr %d depth %d port %d speed %d", dev->ud_addr,
+	dev->ud_depth, dev->ud_powersrc->up_portno, dev->ud_speed);
+	DPRINTFN(1, " dci %u type 0x%02x epaddr 0x%02x attr 0x%02x",
+	xhci_ep_get_dci(ed), ed->bDescriptorType, ed->bEndpointAddress,
+	ed->bmAttributes);
+	DPRINTFN(1, " mps %u ival %u", UGETW(ed->wMaxPacketSize), ed->bInterval,
+	0, 0);
 
 	if (sc->sc_dying)
 		return USBD_IOERROR;
@@ -1524,7 +1528,7 @@ xhci_abort_xfer(struct usbd_xfer *xfer, 
 
 	if (sc->sc_dying) {
 		/* If we're dying, just do the software part. */
-		DPRINTFN(4, "dying", 0, 0, 0, 0);
+		DPRINTFN(4, "xfer %p dying %u", xfer, xfer->ux_status, 0, 0);
 		xfer->ux_status = status;  /* make software ignore it */
 		callout_stop(>ux_callout);
 		usb_transfer_complete(xfer);
@@ -1661,8 +1665,11 @@ xhci_event_transfer(struct xhci_softc * 
 		 * hciversion == 0.96 and FSE of hcc1 is set.
 		 */
 		if (xx == NULL || trbcode == XHCI_TRB_ERROR_LENGTH) {
-			DPRINTFN(1, "xx NULL: #%u: cookie %p: code %u trb_0 %"
-			PRIx64, idx, xx, trbcode, trb_0);
+			DPRINTFN(1, "Ignore #%u: cookie %p cc %u dci %u",
+			idx, xx, trbcode, dci);
+			DPRINTFN(1, " orig TRB %"PRIx64" type %u", trb_0,
+			XHCI_TRB_3_TYPE_GET(le32toh(xr->xr_trb[idx].trb_3)),
+			0, 0);
 		}
 	} else {
 		/* When ED != 0, trb_0 is kaddr of struct xhci_xfer. */
@@ -1843,7 +1850,7 @@ xhci_softintr(void *v)
 	i = er->xr_ep;
 	j = er->xr_cs;
 
-	DPRINTFN(16, "xr_ep %d xr_cs %d", i, j, 0, 0);
+	DPRINTFN(16, "er: xr_ep %d xr_cs %d", i, j, 0, 0);
 
 	while (1) {
 		usb_syncmem(>xr_dma, XHCI_TRB_SIZE * i, XHCI_TRB_SIZE,
@@ -2719,6 +2726,8 @@ xhci_setup_ctx(struct usbd_pipe *pipe)
 	default:
 		break;
 	}
+	DPRINTFN(4, "setting ival %u MaxBurst %#x",
+	XHCI_EPCTX_0_IVAL_GET(cp[0]), XHCI_EPCTX_1_MAXB_GET(cp[1]), 0, 0);
 
 	/* can't use xhci_ep_get_dci() yet? */
 	*(uint64_t *)([2]) = htole64(



CVS commit: src/sys/dev/usb

2016-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun  5 08:11:00 UTC 2016

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

Log Message:
Replace num of TRBs with xr->xr_ntrb.  From t-hash.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 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.51 src/sys/dev/usb/xhci.c:1.52
--- src/sys/dev/usb/xhci.c:1.51	Sun Jun  5 08:05:27 2016
+++ src/sys/dev/usb/xhci.c	Sun Jun  5 08:10:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.51 2016/06/05 08:05:27 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.52 2016/06/05 08:10:59 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.51 2016/06/05 08:05:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.52 2016/06/05 08:10:59 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1031,7 +1031,7 @@ xhci_init(struct xhci_softc *sc)
 	struct xhci_erste *erst;
 	erst = KERNADDR(>sc_eventst_dma, 0);
 	erst[0].erste_0 = htole64(xhci_ring_trbp(>sc_er, 0));
-	erst[0].erste_2 = htole32(XHCI_EVENT_RING_TRBS);
+	erst[0].erste_2 = htole32(sc->sc_er.xr_ntrb);
 	erst[0].erste_3 = htole32(0);
 	usb_syncmem(>sc_eventst_dma, 0,
 	XHCI_ERSTE_SIZE * XHCI_EVENT_RING_SEGMENTS, BUS_DMASYNC_PREWRITE);
@@ -1857,7 +1857,7 @@ xhci_softintr(void *v)
 		xhci_handle_event(sc, trb);
 
 		i++;
-		if (i == XHCI_EVENT_RING_TRBS) {
+		if (i == er->xr_ntrb) {
 			i = 0;
 			j ^= 1;
 		}



CVS commit: src/sys/dev/usb

2016-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun  5 08:05:27 UTC 2016

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

Log Message:
>From t-hash
+ Gather up setting slot and device context into xhci_setup_ctx(),
  and split out setting route string and TT hub params.
+ Apply htole{32,64} to contexts at once as possible.
+ Use xhci_setup_ctx in xhci_set_address and xhci_configure_endpoint.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 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.50 src/sys/dev/usb/xhci.c:1.51
--- src/sys/dev/usb/xhci.c:1.50	Sun Jun  5 07:55:28 2016
+++ src/sys/dev/usb/xhci.c	Sun Jun  5 08:05:27 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.50 2016/06/05 07:55:28 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.51 2016/06/05 08:05:27 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.50 2016/06/05 07:55:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.51 2016/06/05 08:05:27 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -150,7 +150,7 @@ static usbd_status xhci_do_command_locke
 struct xhci_trb * const, int);
 static usbd_status xhci_init_slot(struct usbd_device *, uint32_t);
 static void xhci_free_slot(struct xhci_softc *, struct xhci_slot *, int, int);
-static usbd_status xhci_set_address(struct usbd_device *, uint32_t, uint32_t, int, bool);
+static usbd_status xhci_set_address(struct usbd_device *, uint32_t, bool);
 static usbd_status xhci_enable_slot(struct xhci_softc * const,
 uint8_t * const);
 static usbd_status xhci_disable_slot(struct xhci_softc * const, uint8_t);
@@ -163,6 +163,12 @@ static usbd_status xhci_ring_init(struct
 struct xhci_ring * const, size_t, size_t);
 static void xhci_ring_free(struct xhci_softc * const, struct xhci_ring * const);
 
+static void xhci_setup_ctx(struct usbd_pipe *);
+static void xhci_setup_route(struct usbd_pipe *, uint32_t *);
+static void xhci_setup_tthub(struct usbd_pipe *, uint32_t *);
+static void xhci_setup_maxburst(struct usbd_pipe *, uint32_t *);
+static uint32_t xhci_bival2ival(uint32_t, uint32_t);
+
 static void xhci_noop(struct usbd_pipe *);
 
 static usbd_status xhci_root_intr_transfer(struct usbd_xfer *);
@@ -561,7 +567,6 @@ xhci_detach(struct xhci_softc *sc, int f
 
 	mutex_destroy(>sc_lock);
 	mutex_destroy(>sc_intr_lock);
-	cv_destroy(>sc_softwake_cv);
 
 	pool_cache_destroy(sc->sc_xferpool);
 
@@ -1018,7 +1023,6 @@ xhci_init(struct xhci_softc *sc)
 	cv_init(>sc_command_cv, "xhcicmd");
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
 	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_USB);
-	cv_init(>sc_softwake_cv, "xhciab");
 
 	/* Set up the bus struct. */
 	sc->sc_bus.ub_methods = _bus_methods;
@@ -1214,267 +1218,6 @@ xhci_xspeed2psspeed(int xspeed)
 	}
 }
 
-/* construct slot context */
-static void
-xhci_setup_sctx(struct usbd_device *dev, uint32_t *cp)
-{
-	usb_device_descriptor_t * const dd = >ud_ddesc;
-	int speed = dev->ud_speed;
-	int tthubslot, ttportnum;
-	bool ishub;
-	bool usemtt;
-
-	XHCIHIST_FUNC(); XHCIHIST_CALLED();
-
-	/*
-	 * 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.
-	 *   This is 0 if device is not LS/FS device ||
-	 *   parent hub is not HS hub ||
-	 *   attached to root hub.
-	 * ttportnum:
-	 *   This is the downstream facing port of parent HS hub
-	 *   if LS/FS device is connected.
-	 *   This is 0 if device is not LS/FS device ||
-	 *   parent hub is not HS hub ||
-	 *   attached to root hub.
-	 */
-	if (dev->ud_myhsport != NULL &&
-	dev->ud_myhub != NULL && dev->ud_myhub->ud_depth != 0 &&
-	(dev->ud_myhub != NULL &&
-	 dev->ud_myhub->ud_speed == USB_SPEED_HIGH) &&
-	(speed == USB_SPEED_LOW || speed == USB_SPEED_FULL)) {
-		ttportnum = dev->ud_myhsport->up_portno;
-		tthubslot = dev->ud_myhsport->up_parent->ud_addr;
-	} else {
-		ttportnum = 0;
-		tthubslot = 0;
-	}
-	DPRINTFN(4, "myhsport %p ttportnum=%d tthubslot=%d",
-	dev->ud_myhsport, ttportnum, tthubslot, 0);
-
-	/* ishub is valid after reading UDESC_DEVICE */
-	ishub = (dd->bDeviceClass == UDCLASS_HUB);
-
-	/* dev->ud_hub is valid after reading UDESC_HUB */
-	if (ishub && dev->ud_hub) {
-		usb_hub_descriptor_t *hd = >ud_hub->uh_hubdesc;
-
-		cp[1] |= htole32(XHCI_SCTX_1_NUM_PORTS_SET(hd->bNbrPorts));
-		cp[2] |= htole32(XHCI_SCTX_2_TT_THINK_TIME_SET(
-		__SHIFTOUT(UGETW(hd->wHubCharacteristics), UHD_TT_THINK)));
-		DPRINTFN(4, "nports=%d ttt=%d",
-		hd->bNbrPorts, XHCI_SCTX_2_TT_THINK_TIME_GET(cp[2]), 0, 0);
-	}
-
-#define IS_TTHUB(dd) \
-((dd)->bDeviceProtocol == UDPROTO_HSHUBSTT || \
- (dd)->bDeviceProtocol == UDPROTO_HSHUBMTT)
-
-	/*
-	 * MTT flag is set if
-	 * 

CVS commit: src/sys/dev/usb

2016-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun  5 07:55:29 UTC 2016

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

Log Message:
Wrap long lines and other whitespace.  From t-hash.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 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.49 src/sys/dev/usb/xhci.c:1.50
--- src/sys/dev/usb/xhci.c:1.49	Sun Jun  5 07:54:01 2016
+++ src/sys/dev/usb/xhci.c	Sun Jun  5 07:55:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.49 2016/06/05 07:54:01 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.50 2016/06/05 07:55:28 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.49 2016/06/05 07:54:01 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.50 2016/06/05 07:55:28 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2015,8 +2015,7 @@ xhci_event_transfer(struct xhci_softc * 
 
 /* Process Command complete events */
 static void
-xhci_event_cmd(struct xhci_softc * const sc,
-const struct xhci_trb * const trb)
+xhci_event_cmd(struct xhci_softc * const sc, const struct xhci_trb * const trb)
 {
 	uint64_t trb_0;
 	uint32_t trb_2, trb_3;
@@ -2250,6 +2249,7 @@ xhci_new_device(device_t parent, struct 
 	dev->ud_ep0desc.bDescriptorType = UDESC_ENDPOINT;
 	dev->ud_ep0desc.bEndpointAddress = USB_CONTROL_ENDPOINT;
 	dev->ud_ep0desc.bmAttributes = UE_CONTROL;
+
 	/* 4.3,  4.8.2.1 */
 	switch (speed) {
 	case USB_SPEED_SUPER:
@@ -2355,8 +2355,10 @@ xhci_new_device(device_t parent, struct 
 		err = xhci_enable_slot(sc, );
 		if (err)
 			goto bad;
+
 		xs = >sc_slots[slot];
 		dev->ud_hcpriv = xs;
+
 		/* 4.3.3 initialize slot structure */
 		err = xhci_init_slot(dev, slot);
 		if (err) {
@@ -2379,6 +2381,7 @@ xhci_new_device(device_t parent, struct 
 
 		/* Allow device time to set new address */
 		usbd_delay_ms(dev, USB_SET_ADDRESS_SETTLE);
+
 		cp = xhci_slot_get_dcv(sc, xs, XHCI_DCI_SLOT);
 		//hexdump("slot context", cp, sc->sc_ctxsz);
 		uint8_t addr = XHCI_SCTX_3_DEV_ADDR_GET(cp[3]);
@@ -2394,6 +2397,7 @@ xhci_new_device(device_t parent, struct 
 		err = usbd_get_initial_ddesc(dev, dd);
 		if (err)
 			goto bad;
+
 		/* 4.8.2.1 */
 		if (USB_IS_SS(speed)) {
 			if (dd->bMaxPacketSize != 9) {
@@ -2411,6 +2415,7 @@ xhci_new_device(device_t parent, struct 
 		DPRINTFN(4, "bMaxPacketSize %u", dd->bMaxPacketSize, 0, 0, 0);
 		xhci_update_ep0_mps(sc, xs,
 		UGETW(dev->ud_ep0desc.wMaxPacketSize));
+
 		err = usbd_reload_device_desc(dev);
 		if (err)
 			goto bad;
@@ -2626,8 +2631,8 @@ xhci_abort_command(struct xhci_softc *sc
  * trb_0 in CMD_COMPLETE TRB and sc->sc_command_addr are identical.
  */
 static usbd_status
-xhci_do_command_locked(struct xhci_softc * const sc, struct xhci_trb * const trb,
-int timeout)
+xhci_do_command_locked(struct xhci_softc * const sc,
+struct xhci_trb * const trb, int timeout)
 {
 	struct xhci_ring * const cr = >sc_cr;
 	usbd_status err;



CVS commit: src/sys/dev/usb

2016-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun  5 07:54:01 UTC 2016

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

Log Message:
Reduce the scope of some variable.  From t-hash


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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.48 src/sys/dev/usb/xhci.c:1.49
--- src/sys/dev/usb/xhci.c:1.48	Sun Jun  5 07:52:16 2016
+++ src/sys/dev/usb/xhci.c	Sun Jun  5 07:54:01 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.48 2016/06/05 07:52:16 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.49 2016/06/05 07:54:01 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.48 2016/06/05 07:52:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.49 2016/06/05 07:54:01 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2231,8 +2231,6 @@ xhci_new_device(device_t parent, struct 
 	struct xhci_slot *xs;
 	uint32_t *cp;
 	uint32_t route = 0;
-	uint8_t slot = 0;
-	uint8_t addr;
 
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
 	DPRINTFN(4, "port=%d depth=%d speed=%d upport %d",
@@ -2351,6 +2349,8 @@ xhci_new_device(device_t parent, struct 
 		if (err)
 			goto bad;
 	} else {
+		uint8_t slot = 0;
+
 		/* 4.3.2 */
 		err = xhci_enable_slot(sc, );
 		if (err)
@@ -2381,7 +2381,7 @@ xhci_new_device(device_t parent, struct 
 		usbd_delay_ms(dev, USB_SET_ADDRESS_SETTLE);
 		cp = xhci_slot_get_dcv(sc, xs, XHCI_DCI_SLOT);
 		//hexdump("slot context", cp, sc->sc_ctxsz);
-		addr = XHCI_SCTX_3_DEV_ADDR_GET(cp[3]);
+		uint8_t addr = XHCI_SCTX_3_DEV_ADDR_GET(cp[3]);
 		DPRINTFN(4, "device address %u", addr, 0, 0, 0);
 		/* XXX ensure we know when the hardware does something
 		   we can't yet cope with */



CVS commit: src/sys/dev/usb

2016-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun  5 07:52:16 UTC 2016

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

Log Message:
>From t-hash
+ Split out setting address device.
+ Split out freeing slot structure.
+ Use xhci_free_slot() in xhci_disable_slot().


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 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.47 src/sys/dev/usb/xhci.c:1.48
--- src/sys/dev/usb/xhci.c:1.47	Tue May 31 09:22:11 2016
+++ src/sys/dev/usb/xhci.c	Sun Jun  5 07:52:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.47 2016/05/31 09:22:11 mlelstv Exp $	*/
+/*	$NetBSD: xhci.c,v 1.48 2016/06/05 07:52:16 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.47 2016/05/31 09:22:11 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.48 2016/06/05 07:52:16 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -148,7 +148,9 @@ static usbd_status xhci_do_command(struc
 struct xhci_trb * const, int);
 static usbd_status xhci_do_command_locked(struct xhci_softc * const,
 struct xhci_trb * const, int);
-static usbd_status xhci_init_slot(struct usbd_device *, uint32_t, uint32_t, int);
+static usbd_status xhci_init_slot(struct usbd_device *, uint32_t);
+static void xhci_free_slot(struct xhci_softc *, struct xhci_slot *, int, int);
+static usbd_status xhci_set_address(struct usbd_device *, uint32_t, uint32_t, int, bool);
 static usbd_status xhci_enable_slot(struct xhci_softc * const,
 uint8_t * const);
 static usbd_status xhci_disable_slot(struct xhci_softc * const, uint8_t);
@@ -2349,12 +2351,14 @@ xhci_new_device(device_t parent, struct 
 		if (err)
 			goto bad;
 	} else {
+		/* 4.3.2 */
 		err = xhci_enable_slot(sc, );
 		if (err)
 			goto bad;
 		xs = >sc_slots[slot];
 		dev->ud_hcpriv = xs;
-		err = xhci_init_slot(dev, slot, route, rhport);
+		/* 4.3.3 initialize slot structure */
+		err = xhci_init_slot(dev, slot);
 		if (err) {
 			dev->ud_hcpriv = NULL;
 			/*
@@ -2368,6 +2372,11 @@ xhci_new_device(device_t parent, struct 
 			goto bad;
 		}
 
+		/* 4.3.4 Address Assignment */
+		err = xhci_set_address(dev, slot, route, rhport, false);
+		if (err)
+			goto bad;
+
 		/* Allow device time to set new address */
 		usbd_delay_ms(dev, USB_SET_ADDRESS_SETTLE);
 		cp = xhci_slot_get_dcv(sc, xs, XHCI_DCI_SLOT);
@@ -2735,12 +2744,7 @@ xhci_disable_slot(struct xhci_softc * co
 	if (!err) {
 		xs = >sc_slots[slot];
 		if (xs->xs_idx != 0) {
-			for (int i = XHCI_DCI_SLOT + 1; i < 32; i++) {
-xhci_ring_free(sc, >xs_ep[i].xe_tr);
-memset(>xs_ep[i], 0, sizeof(xs->xs_ep[i]));
-			}
-			usb_freemem(>sc_bus, >xs_ic_dma);
-			usb_freemem(>sc_bus, >xs_dc_dma);
+			xhci_free_slot(sc, xs, XHCI_DCI_SLOT + 1, 32);
 			xhci_set_dcba(sc, 0, slot);
 			memset(xs, 0, sizeof(*xs));
 		}
@@ -2827,23 +2831,19 @@ xhci_set_dcba(struct xhci_softc * const 
 }
 
 /*
- * Allocate DMA buffer and ring buffer for specified slot
- * and set Device Context Base Address
- * and issue Set Address device command.
+ * Allocate device and input context DMA buffer, and
+ * TRB DMA buffer for each endpoint.
  */
 static usbd_status
-xhci_init_slot(struct usbd_device *dev, uint32_t slot, uint32_t route, int rhport)
+xhci_init_slot(struct usbd_device *dev, uint32_t slot)
 {
 	struct xhci_softc * const sc = XHCI_BUS2SC(dev->ud_bus);
 	struct xhci_slot *xs;
 	usbd_status err;
 	u_int dci;
-	uint32_t *cp;
-	uint32_t mps = UGETW(dev->ud_ep0desc.wMaxPacketSize);
 
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
-	DPRINTFN(4, "slot %u speed %d route %05x rhport %d",
-	slot, dev->ud_speed, route, rhport);
+	DPRINTFN(4, "slot %u", slot, 0, 0, 0);
 
 	xs = >sc_slots[slot];
 
@@ -2873,6 +2873,56 @@ xhci_init_slot(struct usbd_device *dev, 
 		}
 	}
 
+ bad2:
+	if (err == USBD_NORMAL_COMPLETION) {
+		xs->xs_idx = slot;
+	} else {
+		xhci_free_slot(sc, xs, XHCI_DCI_SLOT + 1, dci);
+	}
+
+	return err;
+
+ bad1:
+	usb_freemem(>sc_bus, >xs_dc_dma);
+	xs->xs_idx = 0;
+	return err;
+}
+
+static void
+xhci_free_slot(struct xhci_softc *sc, struct xhci_slot *xs, int start_dci,
+int end_dci)
+{
+	u_int dci;
+
+	XHCIHIST_FUNC(); XHCIHIST_CALLED();
+	DPRINTFN(4, "slot %u start %u end %u", xs->xs_idx, start_dci, end_dci,
+	0);
+
+	for (dci = start_dci; dci < end_dci; dci++) {
+		xhci_ring_free(sc, >xs_ep[dci].xe_tr);
+		memset(>xs_ep[dci], 0, sizeof(xs->xs_ep[dci]));
+	}
+	usb_freemem(>sc_bus, >xs_ic_dma);
+	usb_freemem(>sc_bus, >xs_dc_dma);
+	xs->xs_idx = 0;
+}
+
+/*
+ * Setup slot context, set Device Context Base Address, and issue
+ * Set Address Device command.
+ */
+static usbd_status
+xhci_set_address(struct usbd_device *dev, uint32_t slot, uint32_t route,
+int rhport, bool bsr)
+{
+	struct xhci_softc * const sc = 

CVS commit: src/sys/dev/iscsi

2016-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun  5 06:19:59 UTC 2016

Modified Files:
src/sys/dev/iscsi: iscsi_send.c

Log Message:
Add missing mutex_exit().


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/iscsi/iscsi_send.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/iscsi/iscsi_send.c
diff -u src/sys/dev/iscsi/iscsi_send.c:1.26 src/sys/dev/iscsi/iscsi_send.c:1.27
--- src/sys/dev/iscsi/iscsi_send.c:1.26	Sun Jun  5 05:40:29 2016
+++ src/sys/dev/iscsi/iscsi_send.c	Sun Jun  5 06:19:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_send.c,v 1.26 2016/06/05 05:40:29 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_send.c,v 1.27 2016/06/05 06:19:59 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -1368,6 +1368,7 @@ send_command(ccb_t *ccb, ccb_disp_t disp
 		throttle_ccb(ccb, TRUE);
 
 		if (!waitok) {
+			mutex_exit(>lock);
 			DEBC(conn, 10, ("Throttling send_command, ccb = %p\n",ccb));
 			return;
 		}