CVS commit: src/sys/dev/usb

2022-01-19 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 20 03:14:03 UTC 2022

Modified Files:
src/sys/dev/usb: usb_quirks.c usbdi.c usbroothub.c

Log Message:
don't 'extern' some other .c file's data, espcially when it's
already in usbhist.h.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/usb/usb_quirks.c
cvs rdiff -u -r1.221 -r1.222 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/usb/usbroothub.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/usb_quirks.c
diff -u src/sys/dev/usb/usb_quirks.c:1.103 src/sys/dev/usb/usb_quirks.c:1.104
--- src/sys/dev/usb/usb_quirks.c:1.103	Mon Jan 17 11:12:28 2022
+++ src/sys/dev/usb/usb_quirks.c	Thu Jan 20 03:14:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_quirks.c,v 1.103 2022/01/17 11:12:28 bouyer Exp $	*/
+/*	$NetBSD: usb_quirks.c,v 1.104 2022/01/20 03:14:03 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.103 2022/01/17 11:12:28 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.104 2022/01/20 03:14:03 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -48,10 +48,6 @@ __KERNEL_RCSID(0, "$NetBSD: usb_quirks.c
 #include 
 #include 
 
-#ifdef USB_DEBUG
-extern int usbdebug;
-#endif
-
 #define DPRINTF(FMT,A,B,C,D)USBHIST_LOG(usbdebug,FMT,A,B,C,D)
 
 #define ANY 0x

Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.221 src/sys/dev/usb/usbdi.c:1.222
--- src/sys/dev/usb/usbdi.c:1.221	Fri Dec 31 12:00:18 2021
+++ src/sys/dev/usb/usbdi.c	Thu Jan 20 03:14:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.221 2021/12/31 12:00:18 skrll Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.222 2022/01/20 03:14:03 mrg Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.221 2021/12/31 12:00:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.222 2022/01/20 03:14:03 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -61,8 +61,6 @@ __KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.
 /* UTF-8 encoding stuff */
 #include 
 
-extern int usbdebug;
-
 SDT_PROBE_DEFINE5(usb, device, pipe, open,
 "struct usbd_interface *"/*iface*/,
 "uint8_t"/*address*/,

Index: src/sys/dev/usb/usbroothub.c
diff -u src/sys/dev/usb/usbroothub.c:1.10 src/sys/dev/usb/usbroothub.c:1.11
--- src/sys/dev/usb/usbroothub.c:1.10	Wed Jul 21 06:35:45 2021
+++ src/sys/dev/usb/usbroothub.c	Thu Jan 20 03:14:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: usbroothub.c,v 1.10 2021/07/21 06:35:45 skrll Exp $ */
+/* $NetBSD: usbroothub.c,v 1.11 2022/01/20 03:14:03 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbroothub.c,v 1.10 2021/07/21 06:35:45 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbroothub.c,v 1.11 2022/01/20 03:14:03 mrg Exp $");
 
 #include 
 #include 		/* for ostype */
@@ -69,8 +69,6 @@ __KERNEL_RCSID(0, "$NetBSD: usbroothub.c
 #include 
 #include 
 
-extern int usbdebug;
-
 /* helper functions for USB root hub emulation */
 
 static usbd_status	roothub_ctrl_transfer(struct usbd_xfer *);



CVS commit: src/sys/dev/usb

2022-01-19 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 20 03:14:03 UTC 2022

Modified Files:
src/sys/dev/usb: usb_quirks.c usbdi.c usbroothub.c

Log Message:
don't 'extern' some other .c file's data, espcially when it's
already in usbhist.h.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/usb/usb_quirks.c
cvs rdiff -u -r1.221 -r1.222 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/usb/usbroothub.c

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



CVS commit: src/sys/dev/usb

2022-01-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Jan 17 11:12:28 UTC 2022

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

Log Message:
Add UQ_HID_IGNORE for the Microchip PICkit2 and 3 programmers.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/usb/usb_quirks.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/usb_quirks.c
diff -u src/sys/dev/usb/usb_quirks.c:1.102 src/sys/dev/usb/usb_quirks.c:1.103
--- src/sys/dev/usb/usb_quirks.c:1.102	Wed Jan 12 12:55:46 2022
+++ src/sys/dev/usb/usb_quirks.c	Mon Jan 17 11:12:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_quirks.c,v 1.102 2022/01/12 12:55:46 martin Exp $	*/
+/*	$NetBSD: usb_quirks.c,v 1.103 2022/01/17 11:12:28 bouyer Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.102 2022/01/12 12:55:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.103 2022/01/17 11:12:28 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -200,6 +200,10 @@ Static const struct usbd_quirk_entry {
 	{ UQ_HID_IGNORE, NULL }},
  { USB_VENDOR_MICROCHIP,	USB_PRODUCT_MICROCHIP_PICKIT1,		ANY,
 	{ UQ_HID_IGNORE, NULL }},
+ { USB_VENDOR_MICROCHIP,	USB_PRODUCT_MICROCHIP_PICKIT2,		ANY,
+	{ UQ_HID_IGNORE, NULL }},
+ { USB_VENDOR_MICROCHIP,	USB_PRODUCT_MICROCHIP_PICKIT3,		ANY,
+	{ UQ_HID_IGNORE, NULL }},
  { USB_VENDOR_TRIPPLITE2,	ANY,	ANY,
 	{ UQ_HID_IGNORE, NULL }},
  { USB_VENDOR_MISC,		USB_PRODUCT_MISC_WISPY_24X,		ANY,



CVS commit: src/sys/dev/usb

2022-01-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Jan 17 11:12:28 UTC 2022

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

Log Message:
Add UQ_HID_IGNORE for the Microchip PICkit2 and 3 programmers.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/usb/usb_quirks.c

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



CVS commit: src/sys/dev/usb

2022-01-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Jan 17 11:11:42 UTC 2022

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
Regen: Add the Microchip PICkit3 programmer


To generate a diff of this commit:
cvs rdiff -u -r1.791 -r1.792 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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



CVS commit: src/sys/dev/usb

2022-01-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Jan 17 11:11:42 UTC 2022

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
Regen: Add the Microchip PICkit3 programmer


To generate a diff of this commit:
cvs rdiff -u -r1.791 -r1.792 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.791 src/sys/dev/usb/usbdevs.h:1.792
--- src/sys/dev/usb/usbdevs.h:1.791	Wed Jan 12 12:54:45 2022
+++ src/sys/dev/usb/usbdevs.h	Mon Jan 17 11:11:41 2022
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.791 2022/01/12 12:54:45 martin Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.792 2022/01/17 11:11:41 bouyer Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.800 2022/01/12 12:54:02 martin Exp
+ *	NetBSD: usbdevs,v 1.801 2022/01/17 11:09:57 bouyer Exp
  */
 
 /*-
@@ -2337,6 +2337,7 @@
 /* Microchip Technology products */
 #define	USB_PRODUCT_MICROCHIP_PICKIT1	0x0032		/* PICkit(TM) 1 FLASH Starter Kit */
 #define	USB_PRODUCT_MICROCHIP_PICKIT2	0x0033		/* PICkit 2 Microcontroller Programmer */
+#define	USB_PRODUCT_MICROCHIP_PICKIT3	0x900a		/* PICkit 3 Microcontroller Programmer */
 
 /* Microdia / Sonix Technology Co., Ltd. products */
 #define	USB_PRODUCT_MICRODIA_YUREX	0x1010		/* YUREX */
Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.791 src/sys/dev/usb/usbdevs_data.h:1.792
--- src/sys/dev/usb/usbdevs_data.h:1.791	Wed Jan 12 12:54:45 2022
+++ src/sys/dev/usb/usbdevs_data.h	Mon Jan 17 11:11:41 2022
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.791 2022/01/12 12:54:45 martin Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.792 2022/01/17 11:11:41 bouyer Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.800 2022/01/12 12:54:02 martin Exp
+ *	NetBSD: usbdevs,v 1.801 2022/01/17 11:09:57 bouyer Exp
  */
 
 /*-
@@ -3108,6 +3108,8 @@ static const uint32_t usb_products[] = {
 	14294, 5627, 14305, 14311, 14319, 0,
 	USB_VENDOR_MICROCHIP, USB_PRODUCT_MICROCHIP_PICKIT2, 
 	14323, 6595, 14330, 14346, 0,
+	USB_VENDOR_MICROCHIP, USB_PRODUCT_MICROCHIP_PICKIT3, 
+	14323, 6597, 14330, 14346, 0,
 	USB_VENDOR_MICRODIA, USB_PRODUCT_MICRODIA_YUREX, 
 	14357, 0,
 	USB_VENDOR_MICRONET, USB_PRODUCT_MICRONET_SP128AR, 
@@ -5904,7 +5906,7 @@ static const char usb_words[] = { "." 
 	"5\0" /* 1 refs @ 6588 */
 	"iPad\0" /* 4 refs @ 6590 */
 	"2\0" /* 12 refs @ 6595 */
-	"3\0" /* 4 refs @ 6597 */
+	"3\0" /* 5 refs @ 6597 */
 	"Mini\0" /* 5 refs @ 6599 */
 	"Host\0" /* 11 refs @ 6604 */
 	"MacBookPro\0" /* 3 refs @ 6609 */
@@ -6927,9 +6929,9 @@ static const char usb_words[] = { "." 
 	"FLASH\0" /* 1 refs @ 14305 */
 	"Starter\0" /* 1 refs @ 14311 */
 	"Kit\0" /* 2 refs @ 14319 */
-	"PICkit\0" /* 1 refs @ 14323 */
-	"Microcontroller\0" /* 1 refs @ 14330 */
-	"Programmer\0" /* 1 refs @ 14346 */
+	"PICkit\0" /* 2 refs @ 14323 */
+	"Microcontroller\0" /* 2 refs @ 14330 */
+	"Programmer\0" /* 2 refs @ 14346 */
 	"YUREX\0" /* 1 refs @ 14357 */
 	"SP128AR\0" /* 1 refs @ 14363 */
 	"EtherFast\0" /* 1 refs @ 14371 */



CVS commit: src/sys/dev/usb

2022-01-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Jan 17 11:09:57 UTC 2022

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add the Microchip PICkit3 programmer


To generate a diff of this commit:
cvs rdiff -u -r1.800 -r1.801 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.800 src/sys/dev/usb/usbdevs:1.801
--- src/sys/dev/usb/usbdevs:1.800	Wed Jan 12 12:54:02 2022
+++ src/sys/dev/usb/usbdevs	Mon Jan 17 11:09:57 2022
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.800 2022/01/12 12:54:02 martin Exp $
+$NetBSD: usbdevs,v 1.801 2022/01/17 11:09:57 bouyer Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -2330,6 +2330,7 @@ product MSI BLUETOOTH_3		0xa97a	Bluetoot
 /* Microchip Technology products */
 product MICROCHIP PICKIT1	0x0032	PICkit(TM) 1 FLASH Starter Kit
 product MICROCHIP PICKIT2	0x0033	PICkit 2 Microcontroller Programmer
+product MICROCHIP PICKIT3	0x900a	PICkit 3 Microcontroller Programmer
 
 /* Microdia / Sonix Technology Co., Ltd. products */
 product MICRODIA YUREX		0x1010	YUREX



CVS commit: src/sys/dev/usb

2022-01-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Jan 17 11:09:57 UTC 2022

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add the Microchip PICkit3 programmer


To generate a diff of this commit:
cvs rdiff -u -r1.800 -r1.801 src/sys/dev/usb/usbdevs

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



CVS commit: src/sys/dev/usb

2022-01-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan 16 20:25:37 UTC 2022

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

Log Message:
xhci(4): Fix citation in comment.

4.15.2.1 is device-initiated resume, but we are doing host-initiated.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 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.152 src/sys/dev/usb/xhci.c:1.153
--- src/sys/dev/usb/xhci.c:1.152	Sun Jan 16 20:25:18 2022
+++ src/sys/dev/usb/xhci.c	Sun Jan 16 20:25:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.152 2022/01/16 20:25:18 riastradh Exp $	*/
+/*	$NetBSD: xhci.c,v 1.153 2022/01/16 20:25:36 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.152 2022/01/16 20:25:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.153 2022/01/16 20:25:36 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -979,7 +979,7 @@ xhci_resume(device_t self, const pmf_qua
 	 * external hub ports attached to USB devices.'
 	 *
 	 * This follows the procedure in 4.15 `Suspend-Resume', 4.15.2
-	 * `Port Resume', 4.15.2.1 `Host Initiated'.
+	 * `Port Resume', 4.15.2.2 `Host Initiated'.
 	 *
 	 * XXX We should maybe batch up initiating the state
 	 * transitions, and then wait for them to complete all at once.



CVS commit: src/sys/dev/usb

2022-01-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan 16 20:25:37 UTC 2022

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

Log Message:
xhci(4): Fix citation in comment.

4.15.2.1 is device-initiated resume, but we are doing host-initiated.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 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.



CVS commit: src/sys/dev/usb

2022-01-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan 16 20:25:18 UTC 2022

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

Log Message:
xhci(4): Fix copypasto in resume error message.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 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.151 src/sys/dev/usb/xhci.c:1.152
--- src/sys/dev/usb/xhci.c:1.151	Tue Dec 21 09:51:22 2021
+++ src/sys/dev/usb/xhci.c	Sun Jan 16 20:25:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.151 2021/12/21 09:51:22 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.152 2022/01/16 20:25:18 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.151 2021/12/21 09:51:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.152 2022/01/16 20:25:18 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -944,7 +944,7 @@ xhci_resume(device_t self, const pmf_qua
 		usb_delay_ms(>sc_bus, 1);
 	}
 	if (i >= XHCI_WAIT_RSS) {
-		device_printf(self, "suspend timeout, USBSTS.RSS\n");
+		device_printf(self, "resume timeout, USBSTS.RSS\n");
 		goto out;
 	}
 



CVS commit: src/sys/dev/usb

2022-01-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan 16 20:25:18 UTC 2022

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

Log Message:
xhci(4): Fix copypasto in resume error message.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 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.



CVS commit: src/sys/dev/usb

2022-01-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 12 12:55:46 UTC 2022

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

Log Message:
Ignore new APC UPS devices when matching uhid devices.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/dev/usb/usb_quirks.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/usb_quirks.c
diff -u src/sys/dev/usb/usb_quirks.c:1.101 src/sys/dev/usb/usb_quirks.c:1.102
--- src/sys/dev/usb/usb_quirks.c:1.101	Fri Dec 17 08:17:40 2021
+++ src/sys/dev/usb/usb_quirks.c	Wed Jan 12 12:55:46 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_quirks.c,v 1.101 2021/12/17 08:17:40 mrg Exp $	*/
+/*	$NetBSD: usb_quirks.c,v 1.102 2022/01/12 12:55:46 martin Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.101 2021/12/17 08:17:40 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.102 2022/01/12 12:55:46 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -184,6 +184,8 @@ Static const struct usbd_quirk_entry {
  /* Devices which should be ignored by uhid */
  { USB_VENDOR_APC,		USB_PRODUCT_APC_UPS,			ANY,
 	{ UQ_HID_IGNORE, NULL }},
+ { USB_VENDOR_APC,		USB_PRODUCT_APC_UPS3,			ANY,
+	{ UQ_HID_IGNORE, NULL }},
  { USB_VENDOR_CYBERPOWER,	USB_PRODUCT_CYBERPOWER_UPS0,		ANY,
 	{ UQ_HID_IGNORE, NULL }},
  { USB_VENDOR_CYBERPOWER,	USB_PRODUCT_CYBERPOWER_UPS,		ANY,



CVS commit: src/sys/dev/usb

2022-01-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 12 12:55:46 UTC 2022

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

Log Message:
Ignore new APC UPS devices when matching uhid devices.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/dev/usb/usb_quirks.c

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



CVS commit: src/sys/dev/usb

2022-01-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 12 12:54:45 UTC 2022

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen (new APC UPS device id)


To generate a diff of this commit:
cvs rdiff -u -r1.790 -r1.791 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.790 src/sys/dev/usb/usbdevs.h:1.791
--- src/sys/dev/usb/usbdevs.h:1.790	Fri Dec 17 08:17:04 2021
+++ src/sys/dev/usb/usbdevs.h	Wed Jan 12 12:54:45 2022
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.790 2021/12/17 08:17:04 mrg Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.791 2022/01/12 12:54:45 martin Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.799 2021/12/17 08:16:14 mrg Exp
+ *	NetBSD: usbdevs,v 1.800 2022/01/12 12:54:02 martin Exp
  */
 
 /*-
@@ -831,6 +831,7 @@
 
 /* American Power Conversion products */
 #define	USB_PRODUCT_APC_UPS	0x0002		/* Uninterruptible Power Supply */
+#define	USB_PRODUCT_APC_UPS3	0x0003		/* Uninterruptible Power Supply */
 
 /* Ambit Microsystems products */
 #define	USB_PRODUCT_AMBIT_NTL_250	0x6098		/* NTL 250 cable modem */
Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.790 src/sys/dev/usb/usbdevs_data.h:1.791
--- src/sys/dev/usb/usbdevs_data.h:1.790	Fri Dec 17 08:17:04 2021
+++ src/sys/dev/usb/usbdevs_data.h	Wed Jan 12 12:54:45 2022
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.790 2021/12/17 08:17:04 mrg Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.791 2022/01/12 12:54:45 martin Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.799 2021/12/17 08:16:14 mrg Exp
+ *	NetBSD: usbdevs,v 1.800 2022/01/12 12:54:02 martin Exp
  */
 
 /*-
@@ -880,6 +880,8 @@ static const uint32_t usb_products[] = {
 	6011, 6002, 0,
 	USB_VENDOR_APC, USB_PRODUCT_APC_UPS, 
 	6018, 1229, 1982, 0,
+	USB_VENDOR_APC, USB_PRODUCT_APC_UPS3, 
+	6018, 1229, 1982, 0,
 	USB_VENDOR_AMBIT, USB_PRODUCT_AMBIT_NTL_250, 
 	6034, 6038, 6042, 6048, 0,
 	USB_VENDOR_AMD, USB_PRODUCT_AMD_TV_WONDER_600_USB, 
@@ -5199,7 +5201,7 @@ static const char usb_words[] = { "." 
 	"Components\0" /* 3 refs @ 1200 */
 	"Kawatsu\0" /* 1 refs @ 1211 */
 	"Composite\0" /* 1 refs @ 1219 */
-	"Power\0" /* 6 refs @ 1229 */
+	"Power\0" /* 7 refs @ 1229 */
 	"Conversion\0" /* 1 refs @ 1235 */
 	"Connectek\0" /* 1 refs @ 1246 */
 	"USA\0" /* 1 refs @ 1256 */
@@ -5299,7 +5301,7 @@ static const char usb_words[] = { "." 
 	"TEAC\0" /* 1 refs @ 1962 */
 	"Graphics\0" /* 2 refs @ 1967 */
 	"Sanwa\0" /* 1 refs @ 1976 */
-	"Supply\0" /* 5 refs @ 1982 */
+	"Supply\0" /* 6 refs @ 1982 */
 	"WayTech\0" /* 1 refs @ 1989 */
 	"Development,\0" /* 1 refs @ 1997 */
 	"Linksys\0" /* 4 refs @ 2010 */
@@ -5839,7 +5841,7 @@ static const char usb_words[] = { "." 
 	"ADA70\0" /* 1 refs @ 5996 */
 	"Speakers\0" /* 3 refs @ 6002 */
 	"ASC495\0" /* 1 refs @ 6011 */
-	"Uninterruptible\0" /* 4 refs @ 6018 */
+	"Uninterruptible\0" /* 5 refs @ 6018 */
 	"NTL\0" /* 1 refs @ 6034 */
 	"250\0" /* 3 refs @ 6038 */
 	"cable\0" /* 2 refs @ 6042 */



CVS commit: src/sys/dev/usb

2022-01-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 12 12:54:45 UTC 2022

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen (new APC UPS device id)


To generate a diff of this commit:
cvs rdiff -u -r1.790 -r1.791 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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



CVS commit: src/sys/dev/usb

2022-01-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 12 12:54:02 UTC 2022

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add a new APC UPS device id.


To generate a diff of this commit:
cvs rdiff -u -r1.799 -r1.800 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.799 src/sys/dev/usb/usbdevs:1.800
--- src/sys/dev/usb/usbdevs:1.799	Fri Dec 17 08:16:14 2021
+++ src/sys/dev/usb/usbdevs	Wed Jan 12 12:54:02 2022
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.799 2021/12/17 08:16:14 mrg Exp $
+$NetBSD: usbdevs,v 1.800 2022/01/12 12:54:02 martin Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -824,6 +824,7 @@ product ALTEC ASC495		0xff05	ASC495 Spea
 
 /* American Power Conversion products */
 product APC UPS			0x0002	Uninterruptible Power Supply
+product APC UPS3		0x0003	Uninterruptible Power Supply
 
 /* Ambit Microsystems products */
 product AMBIT NTL_250		0x6098	NTL 250 cable modem



CVS commit: src/sys/dev/usb

2022-01-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 12 12:54:02 UTC 2022

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add a new APC UPS device id.


To generate a diff of this commit:
cvs rdiff -u -r1.799 -r1.800 src/sys/dev/usb/usbdevs

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



CVS commit: src/sys/dev/usb

2022-01-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan  9 18:27:23 UTC 2022

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

Log Message:
uvideo(4): Fix USB interface numbering.

Don't try to be clever and count -- just use bInterfaceNumber.

The previous logic to count interface descriptors failed to consider
interfaces with alternate settings, which led it to pass an invalid
interface number to usbd_device2interface_handle.

It is simpler to just use the recorded bInterfaceNumber, which is
guaranteed by the USB spec to be zero-indexed and below
bNumInterfaces as we need.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/usb/uvideo.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/uvideo.c
diff -u src/sys/dev/usb/uvideo.c:1.63 src/sys/dev/usb/uvideo.c:1.64
--- src/sys/dev/usb/uvideo.c:1.63	Sun Nov 14 08:32:07 2021
+++ src/sys/dev/usb/uvideo.c	Sun Jan  9 18:27:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvideo.c,v 1.63 2021/11/14 08:32:07 andvar Exp $	*/
+/*	$NetBSD: uvideo.c,v 1.64 2022/01/09 18:27:23 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008 Patrick Mahoney
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.63 2021/11/14 08:32:07 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.64 2022/01/09 18:27:23 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -328,8 +328,7 @@ static struct uvideo_stream *	uvideo_str
 static usbd_status		uvideo_stream_init(
 	struct uvideo_stream *,
 	struct uvideo_softc *,
-	const usb_interface_descriptor_t *,
-	uint8_t);
+	const usb_interface_descriptor_t *);
 static usbd_status		uvideo_stream_init_desc(
 	struct uvideo_stream *,
 	const usb_interface_descriptor_t *,
@@ -490,7 +489,6 @@ uvideo_attach(device_t parent, device_t 
 	const usb_interface_descriptor_t *ifdesc;
 	struct uvideo_stream *vs;
 	usbd_status err;
-	uint8_t ifaceidx;
 
 	sc->sc_dev = self;
 
@@ -522,10 +520,7 @@ uvideo_attach(device_t parent, device_t 
 
 	/* iterate through interface descriptors and initialize softc */
 	usb_desc_iter_init(sc->sc_udev, );
-	for (ifaceidx = 0;
-	 (ifdesc = usb_desc_iter_next_interface()) != NULL;
-	 ++ifaceidx)
-	{
+	while ((ifdesc = usb_desc_iter_next_interface()) != NULL) {
 		if (ifdesc->bLength < USB_INTERFACE_DESCRIPTOR_SIZE) {
 			DPRINTFN(50, ("uvideo_attach: "
   "ignoring incorrect descriptor len=%d\n",
@@ -562,8 +557,7 @@ uvideo_attach(device_t parent, device_t 
 			vs = uvideo_find_stream(sc, ifdesc->bInterfaceNumber);
 			if (vs == NULL) {
 vs = uvideo_stream_alloc();
-err = uvideo_stream_init(vs, sc, ifdesc,
-			 ifaceidx);
+err = uvideo_stream_init(vs, sc, ifdesc);
 if (err != USBD_NORMAL_COMPLETION) {
 	DPRINTF(("uvideo_attach: "
 		 "error initializing stream: "
@@ -1026,8 +1020,7 @@ uvideo_unit_free_controls(struct uvideo_
 static usbd_status
 uvideo_stream_init(struct uvideo_stream *vs,
 		   struct uvideo_softc *sc,
-		   const usb_interface_descriptor_t *ifdesc,
-		   uint8_t idx)
+		   const usb_interface_descriptor_t *ifdesc)
 {
 	uWord len;
 	usbd_status err;
@@ -1043,7 +1036,8 @@ uvideo_stream_init(struct uvideo_stream 
 	vs->vs_current_format.priv = -1;
 	vs->vs_xfer_type = 0;
 
-	err = usbd_device2interface_handle(sc->sc_udev, idx, >vs_iface);
+	err = usbd_device2interface_handle(sc->sc_udev, vs->vs_ifaceno,
+	>vs_iface);
 	if (err != USBD_NORMAL_COMPLETION) {
 		DPRINTF(("uvideo_stream_init: "
 			 "error getting vs interface: "



CVS commit: src/sys/dev/usb

2022-01-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan  9 18:27:23 UTC 2022

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

Log Message:
uvideo(4): Fix USB interface numbering.

Don't try to be clever and count -- just use bInterfaceNumber.

The previous logic to count interface descriptors failed to consider
interfaces with alternate settings, which led it to pass an invalid
interface number to usbd_device2interface_handle.

It is simpler to just use the recorded bInterfaceNumber, which is
guaranteed by the USB spec to be zero-indexed and below
bNumInterfaces as we need.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/usb/uvideo.c

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



CVS commit: src/sys/dev/usb

2022-01-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jan  8 17:34:14 UTC 2022

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

Log Message:
ukbd(4): Fix previous change to initial LED flashing.

Without this change the LEDs would get stuck on until the first
keypress.  (This also seemed to trigger a crash in heavy load on
bringing aue(4) up and down over and over again while unplugging, but
I'm not sure why and I hope it's not actually related...)


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

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

Modified files:

Index: src/sys/dev/usb/ukbd.c
diff -u src/sys/dev/usb/ukbd.c:1.156 src/sys/dev/usb/ukbd.c:1.157
--- src/sys/dev/usb/ukbd.c:1.156	Fri Dec 31 14:24:06 2021
+++ src/sys/dev/usb/ukbd.c	Sat Jan  8 17:34:14 2022
@@ -1,4 +1,4 @@
-/*  $NetBSD: ukbd.c,v 1.156 2021/12/31 14:24:06 riastradh Exp $*/
+/*  $NetBSD: ukbd.c,v 1.157 2022/01/08 17:34:14 riastradh Exp $*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.156 2021/12/31 14:24:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.157 2022/01/08 17:34:14 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -490,6 +490,7 @@ ukbd_attach(device_t parent, device_t se
 	/* Flash the leds; no real purpose, just shows we're alive. */
 	ukbd_set_leds(sc, WSKBD_LED_SCROLL | WSKBD_LED_NUM | WSKBD_LED_CAPS
 			| WSKBD_LED_COMPOSE);
+	sc->sc_leds_set = 0;	/* not explicitly set by wskbd yet */
 	callout_reset(>sc_ledreset, mstohz(400), ukbd_delayed_leds_off,
 	sc);
 



CVS commit: src/sys/dev/usb

2022-01-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jan  8 17:34:14 UTC 2022

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

Log Message:
ukbd(4): Fix previous change to initial LED flashing.

Without this change the LEDs would get stuck on until the first
keypress.  (This also seemed to trigger a crash in heavy load on
bringing aue(4) up and down over and over again while unplugging, but
I'm not sure why and I hope it's not actually related...)


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

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



CVS commit: src/sys/dev/usb

2021-12-31 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec 31 14:24:16 UTC 2021

Modified Files:
src/sys/dev/usb: umass.c umass_scsipi.c umassvar.h

Log Message:
umass(4): Omit needless reference counting.

autoconf never detaches before attach has completed, so there is no
longer any need for this mechanism.


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/sys/dev/usb/umass.c
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/usb/umass_scsipi.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/usb/umassvar.h

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

Modified files:

Index: src/sys/dev/usb/umass.c
diff -u src/sys/dev/usb/umass.c:1.186 src/sys/dev/usb/umass.c:1.187
--- src/sys/dev/usb/umass.c:1.186	Thu Sep 16 22:19:11 2021
+++ src/sys/dev/usb/umass.c	Fri Dec 31 14:24:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: umass.c,v 1.186 2021/09/16 22:19:11 andvar Exp $	*/
+/*	$NetBSD: umass.c,v 1.187 2021/12/31 14:24:16 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.186 2021/09/16 22:19:11 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.187 2021/12/31 14:24:16 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -392,7 +392,6 @@ umass_attach(device_t parent, device_t s
 	aprint_normal("\n");
 
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
-	cv_init(>sc_detach_cv, "umassdet");
 
 	devinfop = usbd_devinfo_alloc(uiaa->uiaa_device, 0);
 	aprint_normal_dev(self, "%s\n", devinfop);
@@ -872,18 +871,6 @@ umass_detach(device_t self, int flags)
 	}
 	usbd_abort_default_pipe(sc->sc_udev);
 
-	/* Do we really need reference counting?  Perhaps in ioctl() */
-	mutex_enter(>sc_lock);
-	if (--sc->sc_refcnt >= 0) {
-#ifdef DIAGNOSTIC
-		aprint_normal_dev(self, "waiting for refcnt\n");
-#endif
-		/* Wait for processes to go away. */
-		if (cv_timedwait(>sc_detach_cv, >sc_lock, hz * 60))
-			aprint_error_dev(self, ": didn't detach\n");
-	}
-	mutex_exit(>sc_lock);
-
 	scbus = sc->bus;
 	if (scbus != NULL) {
 		if (scbus->sc_child != NULL)
@@ -925,7 +912,6 @@ umass_detach(device_t self, int flags)
 	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev);
 
 	mutex_destroy(>sc_lock);
-	cv_destroy(>sc_detach_cv);
 
 out:	SDT_PROBE2(usb, umass, device, detach__done,  sc, rv);
 	return rv;

Index: src/sys/dev/usb/umass_scsipi.c
diff -u src/sys/dev/usb/umass_scsipi.c:1.69 src/sys/dev/usb/umass_scsipi.c:1.70
--- src/sys/dev/usb/umass_scsipi.c:1.69	Sat Aug  7 16:19:17 2021
+++ src/sys/dev/usb/umass_scsipi.c	Fri Dec 31 14:24:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: umass_scsipi.c,v 1.69 2021/08/07 16:19:17 thorpej Exp $	*/
+/*	$NetBSD: umass_scsipi.c,v 1.70 2021/12/31 14:24:16 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.69 2021/08/07 16:19:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.70 2021/12/31 14:24:16 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -131,6 +131,8 @@ umass_scsi_attach(struct umass_softc *sc
 	UMASSHIST_FUNC(); UMASSHIST_CALLED();
 	struct umass_scsipi_softc *scbus;
 
+	KASSERT(KERNEL_LOCKED_P());
+
 	scbus = umass_scsipi_setup(sc);
 
 	scbus->sc_channel.chan_bustype = _bustype;
@@ -139,17 +141,9 @@ umass_scsi_attach(struct umass_softc *sc
 	scbus->sc_channel.chan_id = scbus->sc_channel.chan_ntargets - 1;
 	DPRINTFM(UDMASS_USB, "sc %#jx: SCSI", (uintptr_t)sc, 0, 0, 0);
 
-	mutex_enter(>sc_lock);
-	sc->sc_refcnt++;
-	mutex_exit(>sc_lock);
 	scbus->base.sc_child =
 	config_found(sc->sc_dev, >sc_channel, scsiprint,
 			 CFARGS(.iattr = "scsi"));
-	mutex_enter(>sc_lock);
-	if (--sc->sc_refcnt < 0)
-		cv_broadcast(>sc_detach_cv);
-	mutex_exit(>sc_lock);
-
 
 	return 0;
 }
@@ -171,6 +165,8 @@ umass_atapi_attach(struct umass_softc *s
 	UMASSHIST_FUNC(); UMASSHIST_CALLED();
 	struct umass_scsipi_softc *scbus;
 
+	KASSERT(KERNEL_LOCKED_P());
+
 	scbus = umass_scsipi_setup(sc);
 	scbus->sc_atapi_adapter.atapi_probe_device =  umass_atapi_probe_device;
 
@@ -181,16 +177,9 @@ umass_atapi_attach(struct umass_softc *s
 	scbus->sc_channel.chan_defquirks |= sc->sc_busquirks;
 	DPRINTFM(UDMASS_USB, "sc %#jxp: ATAPI", (uintptr_t)sc, 0, 0, 0);
 
-	mutex_enter(>sc_lock);
-	sc->sc_refcnt++;
-	mutex_exit(>sc_lock);
 	scbus->base.sc_child =
 	config_found(sc->sc_dev, >sc_channel, atapiprint,
 			 CFARGS(.iattr = "atapi"));
-	mutex_enter(>sc_lock);
-	if (--sc->sc_refcnt < 0)
-		cv_broadcast(>sc_detach_cv);
-	mutex_exit(>sc_lock);
 
 	return 0;
 }

Index: src/sys/dev/usb/umassvar.h
diff -u src/sys/dev/usb/umassvar.h:1.39 src/sys/dev/usb/umassvar.h:1.40
--- src/sys/dev/usb/umassvar.h:1.39	Tue Nov 13 10:30:57 2018
+++ src/sys/dev/usb/umassvar.h	Fri Dec 31 14:24:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: umassvar.h,v 1.39 2018/11/13 10:30:57 mlelstv Exp $	*/
+/*	

CVS commit: src/sys/dev/usb

2021-12-31 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec 31 14:24:16 UTC 2021

Modified Files:
src/sys/dev/usb: umass.c umass_scsipi.c umassvar.h

Log Message:
umass(4): Omit needless reference counting.

autoconf never detaches before attach has completed, so there is no
longer any need for this mechanism.


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/sys/dev/usb/umass.c
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/usb/umass_scsipi.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/usb/umassvar.h

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



CVS commit: src/sys/dev/usb

2021-12-31 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec 31 14:24:06 UTC 2021

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

Log Message:
ukbd(4): Avoid races in LED setting on attach.

- Don't reuse sc_delay for LED task -- a keyboard interrupt shortly
  after attach might reset sc_delay so that the LEDs never get turned
  back off.

- Don't turn the LEDs back off after attach if something else has
  already changed them by the time the callout fires.

(And make sure to callout_halt before done this time!)


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

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

Modified files:

Index: src/sys/dev/usb/ukbd.c
diff -u src/sys/dev/usb/ukbd.c:1.155 src/sys/dev/usb/ukbd.c:1.156
--- src/sys/dev/usb/ukbd.c:1.155	Sun Dec 26 16:08:21 2021
+++ src/sys/dev/usb/ukbd.c	Fri Dec 31 14:24:06 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: ukbd.c,v 1.155 2021/12/26 16:08:21 andvar Exp $*/
+/*  $NetBSD: ukbd.c,v 1.156 2021/12/31 14:24:06 riastradh Exp $*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.155 2021/12/26 16:08:21 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.156 2021/12/31 14:24:06 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -270,6 +270,8 @@ struct ukbd_softc {
 	struct hid_location sc_compose;
 	int sc_leds;
 	struct usb_task sc_ledtask;
+	struct callout sc_ledreset;
+	int sc_leds_set;
 	device_t sc_wskbddev;
 
 #if defined(WSDISPLAY_COMPAT_RAWKBD)
@@ -483,11 +485,13 @@ ukbd_attach(device_t parent, device_t se
 	sc->sc_data_r = 0;
 
 	usb_init_task(>sc_ledtask, ukbd_set_leds_task, sc, 0);
+	callout_init(>sc_ledreset, 0);
 
 	/* Flash the leds; no real purpose, just shows we're alive. */
 	ukbd_set_leds(sc, WSKBD_LED_SCROLL | WSKBD_LED_NUM | WSKBD_LED_CAPS
 			| WSKBD_LED_COMPOSE);
-	callout_reset(>sc_delay, mstohz(400), ukbd_delayed_leds_off, sc);
+	callout_reset(>sc_ledreset, mstohz(400), ukbd_delayed_leds_off,
+	sc);
 
 	sc->sc_wskbddev = config_found(self, , wskbddevprint, CFARGS_NONE);
 
@@ -573,6 +577,7 @@ ukbd_detach(device_t self, int flags)
 		rv = config_detach(sc->sc_wskbddev, flags);
 
 	callout_halt(>sc_delay, NULL);
+	callout_halt(>sc_ledreset, NULL);
 	usb_rem_task_wait(sc->sc_hdev.sc_parent->sc_udev, >sc_ledtask,
 	USB_TASKQ_DRIVER, NULL);
 
@@ -715,6 +720,13 @@ ukbd_delayed_leds_off(void *addr)
 {
 	struct ukbd_softc *sc = addr;
 
+	/*
+	 * If the LEDs have already been set after attach, other than
+	 * by our initial flashing of them, leave them be.
+	 */
+	if (sc->sc_leds_set)
+		return;
+
 	ukbd_set_leds(sc, 0);
 }
 
@@ -880,6 +892,8 @@ ukbd_set_leds(void *v, int leds)
 	if (sc->sc_dying)
 		return;
 
+	sc->sc_leds_set = 1;
+
 	if (sc->sc_leds == leds)
 		return;
 



CVS commit: src/sys/dev/usb

2021-12-31 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec 31 14:24:06 UTC 2021

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

Log Message:
ukbd(4): Avoid races in LED setting on attach.

- Don't reuse sc_delay for LED task -- a keyboard interrupt shortly
  after attach might reset sc_delay so that the LEDs never get turned
  back off.

- Don't turn the LEDs back off after attach if something else has
  already changed them by the time the callout fires.

(And make sure to callout_halt before done this time!)


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

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



CVS commit: src/sys/dev/usb

2021-12-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Dec 31 12:00:18 UTC 2021

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

Log Message:
usbd_do_request_len (and friends) return usbd_status so return one in
the usbd_create_xfer failure case.  Spotted by Riastradh.


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 src/sys/dev/usb/usbdi.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/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.220 src/sys/dev/usb/usbdi.c:1.221
--- src/sys/dev/usb/usbdi.c:1.220	Tue Dec 21 09:51:22 2021
+++ src/sys/dev/usb/usbdi.c	Fri Dec 31 12:00:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.220 2021/12/21 09:51:22 skrll Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.221 2021/12/31 12:00:18 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.220 2021/12/21 09:51:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.221 2021/12/31 12:00:18 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1243,7 +1243,7 @@ usbd_do_request_len(struct usbd_device *
 
 	int error = usbd_create_xfer(dev->ud_pipe0, len, 0, 0, );
 	if (error)
-		return error;
+		return USBD_NOMEM;
 
 	usbd_setup_default_xfer(xfer, dev, 0, timeout, req, data,
 	UGETW(req->wLength), flags, NULL);



CVS commit: src/sys/dev/usb

2021-12-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Dec 31 12:00:18 UTC 2021

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

Log Message:
usbd_do_request_len (and friends) return usbd_status so return one in
the usbd_create_xfer failure case.  Spotted by Riastradh.


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 src/sys/dev/usb/usbdi.c

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



CVS commit: src/sys/dev/usb

2021-12-29 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 30 04:19:23 UTC 2021

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

Log Message:
convert the ehci device owner ship change message to display the ehciN as well.


To generate a diff of this commit:
cvs rdiff -u -r1.299 -r1.300 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.299 src/sys/dev/usb/ehci.c:1.300
--- src/sys/dev/usb/ehci.c:1.299	Fri Dec 24 22:56:55 2021
+++ src/sys/dev/usb/ehci.c	Thu Dec 30 04:19:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.299 2021/12/24 22:56:55 nia Exp $ */
+/*	$NetBSD: ehci.c,v 1.300 2021/12/30 04:19:23 mrg Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.299 2021/12/24 22:56:55 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.300 2021/12/30 04:19:23 mrg Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2703,7 +2703,8 @@ ehci_disown_sched_callback(ehci_softc_t 
 	mutex_exit(>sc_complock);
 
 	config_pending_incr(sc->sc_dev);
-	aprint_normal("delaying %s by %u seconds due to USB owner change.\n",
+	aprint_normal_dev(sc->sc_dev,
+	"delaying %s by %u seconds due to USB owner change.\n",
 	(boothowto & RB_ASKNAME) != 0 ? "ask root" : "single user",
 	ehci_disown_delay_seconds);
 }



CVS commit: src/sys/dev/usb

2021-12-29 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 30 04:19:23 UTC 2021

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

Log Message:
convert the ehci device owner ship change message to display the ehciN as well.


To generate a diff of this commit:
cvs rdiff -u -r1.299 -r1.300 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec 25 13:41:12 UTC 2021

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

Log Message:
ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/dev/usb/ukbd.c

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

Modified files:

Index: src/sys/dev/usb/ukbd.c
diff -u src/sys/dev/usb/ukbd.c:1.153 src/sys/dev/usb/ukbd.c:1.154
--- src/sys/dev/usb/ukbd.c:1.153	Mon Oct 11 00:00:03 2021
+++ src/sys/dev/usb/ukbd.c	Sat Dec 25 13:41:12 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: ukbd.c,v 1.153 2021/10/11 00:00:03 jmcneill Exp $*/
+/*  $NetBSD: ukbd.c,v 1.154 2021/12/25 13:41:12 riastradh Exp $*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.153 2021/10/11 00:00:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.154 2021/12/25 13:41:12 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -572,6 +572,10 @@ ukbd_detach(device_t self, int flags)
 	if (sc->sc_wskbddev != NULL)
 		rv = config_detach(sc->sc_wskbddev, flags);
 
+	callout_halt(>sc_delay, NULL);
+	usb_rem_task_wait(sc->sc_hdev.sc_parent->sc_udev, >sc_ledtask,
+	USB_TASKQ_DRIVER, NULL);
+
 	/* The console keyboard does not get a disable call, so check pipe. */
 	if (sc->sc_hdev.sc_state & UHIDEV_OPEN)
 		uhidev_close(>sc_hdev);



CVS commit: src/sys/dev/usb

2021-12-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec 25 13:41:12 UTC 2021

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

Log Message:
ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/dev/usb/ukbd.c

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



CVS commit: src/sys/dev/usb

2021-12-24 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Dec 24 22:56:56 UTC 2021

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

Log Message:
ehci(4): fix PR kern/56574: uaudio at ehci (not xhci) only outputs
rapid gunfire (patch from nick)


To generate a diff of this commit:
cvs rdiff -u -r1.298 -r1.299 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.298 src/sys/dev/usb/ehci.c:1.299
--- src/sys/dev/usb/ehci.c:1.298	Thu Dec 23 11:03:48 2021
+++ src/sys/dev/usb/ehci.c	Fri Dec 24 22:56:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.298 2021/12/23 11:03:48 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.299 2021/12/24 22:56:55 nia Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.298 2021/12/23 11:03:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.299 2021/12/24 22:56:55 nia Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -4414,12 +4414,16 @@ ehci_device_fs_isoc_transfer(struct usbd
 		EHCI_SITD_SET_LEN(xfer->ux_frlengths[i]));
 
 		/* Set page0 index and offset - TP and T-offset are set below */
-		sitd->sitd.sitd_buffer[0] = htole32(DMAADDR(dma_buf, offs));
+		const bus_addr_t sba = DMAADDR(dma_buf, offs);
+		sitd->sitd.sitd_buffer[0] = htole32(BUS_ADDR_LO32(sba));
+		sitd->sitd.sitd_buffer_hi[0] = htole32(BUS_ADDR_HI32(sba));
 
 		offs += xfer->ux_frlengths[i];
 
+		const bus_addr_t eba = DMAADDR(dma_buf, offs - 1);
 		sitd->sitd.sitd_buffer[1] =
-		htole32(EHCI_SITD_SET_BPTR(DMAADDR(dma_buf, offs - 1)));
+		htole32(EHCI_SITD_SET_BPTR(BUS_ADDR_LO32(eba)));
+		sitd->sitd.sitd_buffer_hi[1] = htole32(BUS_ADDR_HI32(eba));
 
 		u_int huba __diagused = dev->ud_myhsport->up_parent->ud_addr;
 



CVS commit: src/sys/dev/usb

2021-12-24 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Dec 24 22:56:56 UTC 2021

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

Log Message:
ehci(4): fix PR kern/56574: uaudio at ehci (not xhci) only outputs
rapid gunfire (patch from nick)


To generate a diff of this commit:
cvs rdiff -u -r1.298 -r1.299 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Dec 23 11:03:48 UTC 2021

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

Log Message:
Use the correct dmatag for all control structures. Also, don't KASSERT that
we're using the low 4GB for them and simply error out.

kern/56570: ehci panic on boot


To generate a diff of this commit:
cvs rdiff -u -r1.297 -r1.298 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.297 src/sys/dev/usb/ehci.c:1.298
--- src/sys/dev/usb/ehci.c:1.297	Wed Dec 22 21:45:02 2021
+++ src/sys/dev/usb/ehci.c	Thu Dec 23 11:03:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.297 2021/12/22 21:45:02 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.298 2021/12/23 11:03:48 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.297 2021/12/22 21:45:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.298 2021/12/23 11:03:48 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -539,7 +539,7 @@ ehci_init(ehci_softc_t *sc)
 		err = EIO;
 		goto fail1;
 	}
-	err = usb_allocmem(sc->sc_bus.ub_dmatag,
+	err = usb_allocmem(sc->sc_dmatag,
 	sc->sc_flsize * sizeof(ehci_link_t),
 	EHCI_FLALIGN_ALIGN, USBMALLOC_COHERENT, >sc_fldma);
 	if (err) {
@@ -553,9 +553,15 @@ ehci_init(ehci_softc_t *sc)
 		sc->sc_flist[i] = EHCI_NULL;
 	}
 
-	KASSERT(BUS_ADDR_HI32(DMAADDR(>sc_fldma, 0)) == 0);
-	uint32_t lo32 = BUS_ADDR_LO32(DMAADDR(>sc_fldma, 0));
+	const bus_addr_t flba = DMAADDR(>sc_fldma, 0);
+	const uint32_t hi32 = BUS_ADDR_HI32(flba);
+	if (hi32 != 0) {
+		aprint_error_dev(sc->sc_dev, "DMA memory segment error (%08x)\n",
+		hi32);
+		goto fail2;
+	}
 
+	const uint32_t lo32 = BUS_ADDR_LO32(flba);
 	EOWRITE4(sc, EHCI_PERIODICLISTBASE, lo32);
 
 	sc->sc_softitds = kmem_zalloc(sc->sc_flsize * sizeof(ehci_soft_itd_t *),
@@ -579,7 +585,7 @@ ehci_init(ehci_softc_t *sc)
 		sqh = ehci_alloc_sqh(sc);
 		if (sqh == NULL) {
 			err = ENOMEM;
-			goto fail2;
+			goto fail3;
 		}
 		sc->sc_islots[i].sqh = sqh;
 	}
@@ -622,7 +628,7 @@ ehci_init(ehci_softc_t *sc)
 	sqh = ehci_alloc_sqh(sc);
 	if (sqh == NULL) {
 		err = ENOMEM;
-		goto fail2;
+		goto fail3;
 	}
 	/* Fill the QH */
 	sqh->qh.qh_endp =
@@ -670,7 +676,7 @@ ehci_init(ehci_softc_t *sc)
 	if (hcr) {
 		aprint_error("%s: run timeout\n", device_xname(sc->sc_dev));
 		err = EIO;
-		goto fail3;
+		goto fail4;
 	}
 
 	/* Enable interrupts */
@@ -679,10 +685,10 @@ ehci_init(ehci_softc_t *sc)
 
 	return 0;
 
-fail3:
+fail4:
 	ehci_free_sqh(sc, sc->sc_async_head);
 
-fail2:
+fail3:
 	for (i = 0; i < EHCI_INTRQHS; i++) {
 		sqh = sc->sc_islots[i].sqh;
 		if (sqh)
@@ -690,6 +696,8 @@ fail2:
 	}
 
 	kmem_free(sc->sc_softitds, sc->sc_flsize * sizeof(ehci_soft_itd_t *));
+
+fail2:
 	usb_freemem(>sc_fldma);
 
 fail1:
@@ -3210,7 +3218,7 @@ ehci_alloc_sitd(ehci_softc_t *sc)
 		mutex_exit(>sc_lock);
 
 		usb_dma_t dma;
-		int err = usb_allocmem(sc->sc_bus.ub_dmatag,
+		int err = usb_allocmem(sc->sc_dmatag,
 		EHCI_SITD_SIZE * EHCI_SITD_CHUNK,
 		EHCI_PAGE_SIZE, USBMALLOC_COHERENT, );
 



CVS commit: src/sys/dev/usb

2021-12-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Dec 23 11:03:48 UTC 2021

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

Log Message:
Use the correct dmatag for all control structures. Also, don't KASSERT that
we're using the low 4GB for them and simply error out.

kern/56570: ehci panic on boot


To generate a diff of this commit:
cvs rdiff -u -r1.297 -r1.298 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Dec 22 21:36:40 UTC 2021

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

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.295 -r1.296 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.295 src/sys/dev/usb/ehci.c:1.296
--- src/sys/dev/usb/ehci.c:1.295	Tue Dec 21 10:16:05 2021
+++ src/sys/dev/usb/ehci.c	Wed Dec 22 21:36:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.295 2021/12/21 10:16:05 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.296 2021/12/22 21:36:40 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.295 2021/12/21 10:16:05 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.296 2021/12/22 21:36:40 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2001,8 +2001,8 @@ ehci_open(struct usbd_pipe *pipe)
 	switch (xfertype) {
 	case UE_CONTROL:
 		err = usb_allocmem(sc->sc_bus.ub_dmatag,
-		 sizeof(usb_device_request_t), 0, USBMALLOC_COHERENT,
-		 >ctrl.reqdma);
+		sizeof(usb_device_request_t), 0, USBMALLOC_COHERENT,
+		>ctrl.reqdma);
 #ifdef EHCI_DEBUG
 		if (err)
 			printf("ehci_open: usb_allocmem()=%d\n", err);



CVS commit: src/sys/dev/usb

2021-12-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Dec 22 21:36:40 UTC 2021

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

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.295 -r1.296 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 10:16:05 UTC 2021

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

Log Message:
Remove an empty line


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.294 src/sys/dev/usb/ehci.c:1.295
--- src/sys/dev/usb/ehci.c:1.294	Tue Dec 21 10:14:43 2021
+++ src/sys/dev/usb/ehci.c	Tue Dec 21 10:16:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.294 2021/12/21 10:14:43 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.295 2021/12/21 10:16:05 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.294 2021/12/21 10:14:43 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.295 2021/12/21 10:16:05 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -3163,7 +3163,6 @@ ehci_alloc_sitd(ehci_softc_t *sc)
 	mutex_enter(>sc_lock);
 	freesitd = LIST_FIRST(>sc_freesitds);
 	if (freesitd == NULL) {
-
 		DPRINTF("allocating chunk", 0, 0, 0, 0);
 		mutex_exit(>sc_lock);
 



CVS commit: src/sys/dev/usb

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 10:16:05 UTC 2021

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

Log Message:
Remove an empty line


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 10:14:43 UTC 2021

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

Log Message:
Wrap a long line


To generate a diff of this commit:
cvs rdiff -u -r1.293 -r1.294 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.293 src/sys/dev/usb/ehci.c:1.294
--- src/sys/dev/usb/ehci.c:1.293	Tue Dec 21 09:51:22 2021
+++ src/sys/dev/usb/ehci.c	Tue Dec 21 10:14:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.293 2021/12/21 09:51:22 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.294 2021/12/21 10:14:43 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.293 2021/12/21 09:51:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.294 2021/12/21 10:14:43 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2000,8 +2000,9 @@ ehci_open(struct usbd_pipe *pipe)
 
 	switch (xfertype) {
 	case UE_CONTROL:
-		err = usb_allocmem(sc->sc_bus.ub_dmatag, sizeof(usb_device_request_t),
-		0, USBMALLOC_COHERENT, >ctrl.reqdma);
+		err = usb_allocmem(sc->sc_bus.ub_dmatag,
+		 sizeof(usb_device_request_t), 0, USBMALLOC_COHERENT,
+		 >ctrl.reqdma);
 #ifdef EHCI_DEBUG
 		if (err)
 			printf("ehci_open: usb_allocmem()=%d\n", err);



CVS commit: src/sys/dev/usb

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 10:14:43 UTC 2021

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

Log Message:
Wrap a long line


To generate a diff of this commit:
cvs rdiff -u -r1.293 -r1.294 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 09:25:17 UTC 2021

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

Log Message:
Pass up bus_dma error from usb_block_allocmem rather than always returning
USBD_NOMEM on error.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/usb/usb_mem.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/usb_mem.c
diff -u src/sys/dev/usb/usb_mem.c:1.82 src/sys/dev/usb/usb_mem.c:1.83
--- src/sys/dev/usb/usb_mem.c:1.82	Tue Dec 21 09:23:41 2021
+++ src/sys/dev/usb/usb_mem.c	Tue Dec 21 09:25:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_mem.c,v 1.82 2021/12/21 09:23:41 skrll Exp $	*/
+/*	$NetBSD: usb_mem.c,v 1.83 2021/12/21 09:25:17 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.82 2021/12/21 09:23:41 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.83 2021/12/21 09:25:17 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -210,7 +210,7 @@ usb_block_allocmem(bus_dma_tag_t tag, si
 	kmem_free(b, sizeof(*b));
 	mutex_enter(_blk_lock);
 
-	return USBD_NOMEM;
+	return error;
 }
 
 #if 0



CVS commit: src/sys/dev/usb

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 09:25:17 UTC 2021

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

Log Message:
Pass up bus_dma error from usb_block_allocmem rather than always returning
USBD_NOMEM on error.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/usb/usb_mem.c

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



CVS commit: src/sys/dev/usb

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 09:23:41 UTC 2021

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

Log Message:
Style.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/usb/usb_mem.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/usb_mem.c
diff -u src/sys/dev/usb/usb_mem.c:1.81 src/sys/dev/usb/usb_mem.c:1.82
--- src/sys/dev/usb/usb_mem.c:1.81	Thu May 27 10:44:29 2021
+++ src/sys/dev/usb/usb_mem.c	Tue Dec 21 09:23:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_mem.c,v 1.81 2021/05/27 10:44:29 jmcneill Exp $	*/
+/*	$NetBSD: usb_mem.c,v 1.82 2021/12/21 09:23:41 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.81 2021/05/27 10:44:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.82 2021/12/21 09:23:41 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -167,9 +167,8 @@ usb_block_allocmem(bus_dma_tag_t tag, si
 	b->segs = kmem_alloc(b->nsegs * sizeof(*b->segs), KM_SLEEP);
 	b->nsegs_alloc = b->nsegs;
 
-	error = bus_dmamem_alloc(tag, b->size, align, 0,
- b->segs, b->nsegs,
- >nsegs, BUS_DMA_WAITOK);
+	error = bus_dmamem_alloc(tag, b->size, align, 0, b->segs, b->nsegs,
+	>nsegs, BUS_DMA_WAITOK);
 	if (error)
 		goto free0;
 
@@ -178,13 +177,13 @@ usb_block_allocmem(bus_dma_tag_t tag, si
 	if (error)
 		goto free1;
 
-	error = bus_dmamap_create(tag, b->size, b->nsegs, b->size,
-  0, BUS_DMA_WAITOK, >map);
+	error = bus_dmamap_create(tag, b->size, b->nsegs, b->size, 0,
+	BUS_DMA_WAITOK, >map);
 	if (error)
 		goto unmap;
 
 	error = bus_dmamap_load(tag, b->map, b->kaddr, b->size, NULL,
-BUS_DMA_WAITOK);
+	BUS_DMA_WAITOK);
 	if (error)
 		goto destroy;
 



CVS commit: src/sys/dev/usb

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 09:23:41 UTC 2021

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

Log Message:
Style.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/usb/usb_mem.c

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



CVS commit: src/sys/dev/usb

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 08:49:03 UTC 2021

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

Log Message:
KASSERT(BUS_ADDR_HI32(baddr) == 0) in, and apply some consistent code
style to all of ehci_alloc_{sqh,sqtd,itd,sitd}.

While ehci can address memory >4GB for control structures
EHCI_CTRLDSSEGMENT is always set to zero so ehci assumes it's using the
low 4GB.


To generate a diff of this commit:
cvs rdiff -u -r1.291 -r1.292 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.291 src/sys/dev/usb/ehci.c:1.292
--- src/sys/dev/usb/ehci.c:1.291	Sat Dec 18 14:48:14 2021
+++ src/sys/dev/usb/ehci.c	Tue Dec 21 08:49:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.291 2021/12/18 14:48:14 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.292 2021/12/21 08:49:03 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.291 2021/12/18 14:48:14 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.292 2021/12/21 08:49:03 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2787,8 +2787,6 @@ Static ehci_soft_qh_t *
 ehci_alloc_sqh(ehci_softc_t *sc)
 {
 	ehci_soft_qh_t *sqh;
-	int i, offs;
-	usb_dma_t dma;
 
 	EHCIHIST_FUNC(); EHCIHIST_CALLED();
 
@@ -2797,6 +2795,7 @@ ehci_alloc_sqh(ehci_softc_t *sc)
 		DPRINTF("allocating chunk", 0, 0, 0, 0);
 		mutex_exit(>sc_lock);
 
+		usb_dma_t dma;
 		int err = usb_allocmem(>sc_bus,
 		EHCI_SQH_SIZE * EHCI_SQH_CHUNK,
 		EHCI_PAGE_SIZE, USBMALLOC_COHERENT, );
@@ -2807,12 +2806,17 @@ ehci_alloc_sqh(ehci_softc_t *sc)
 		}
 
 		mutex_enter(>sc_lock);
-		for (i = 0; i < EHCI_SQH_CHUNK; i++) {
-			offs = i * EHCI_SQH_SIZE;
+		for (size_t i = 0; i < EHCI_SQH_CHUNK; i++) {
+			const int offs = i * EHCI_SQH_SIZE;
+			const bus_addr_t baddr = DMAADDR(, offs);
+
+			KASSERT(BUS_ADDR_HI32(baddr) == 0);
+
 			sqh = KERNADDR(, offs);
-			sqh->physaddr = DMAADDR(, offs);
+			sqh->physaddr = BUS_ADDR_LO32(baddr);
 			sqh->dma = dma;
 			sqh->offs = offs;
+
 			sqh->next = sc->sc_freeqhs;
 			sc->sc_freeqhs = sqh;
 		}
@@ -2839,8 +2843,6 @@ Static ehci_soft_qtd_t *
 ehci_alloc_sqtd(ehci_softc_t *sc)
 {
 	ehci_soft_qtd_t *sqtd = NULL;
-	int i, offs;
-	usb_dma_t dma;
 
 	EHCIHIST_FUNC(); EHCIHIST_CALLED();
 
@@ -2849,6 +2851,7 @@ ehci_alloc_sqtd(ehci_softc_t *sc)
 		DPRINTF("allocating chunk", 0, 0, 0, 0);
 		mutex_exit(>sc_lock);
 
+		usb_dma_t dma;
 		int err = usb_allocmem(>sc_bus,
 		EHCI_SQTD_SIZE * EHCI_SQTD_CHUNK,
 		EHCI_PAGE_SIZE, USBMALLOC_COHERENT, );
@@ -2859,10 +2862,14 @@ ehci_alloc_sqtd(ehci_softc_t *sc)
 		}
 
 		mutex_enter(>sc_lock);
-		for (i = 0; i < EHCI_SQTD_CHUNK; i++) {
-			offs = i * EHCI_SQTD_SIZE;
+		for (size_t i = 0; i < EHCI_SQTD_CHUNK; i++) {
+			const int offs = i * EHCI_SQTD_SIZE;
+			const bus_addr_t baddr = DMAADDR(, offs);
+
+			KASSERT(BUS_ADDR_HI32(baddr) == 0);
+
 			sqtd = KERNADDR(, offs);
-			sqtd->physaddr = DMAADDR(, offs);
+			sqtd->physaddr = BUS_ADDR_LO32(baddr);
 			sqtd->dma = dma;
 			sqtd->offs = offs;
 
@@ -3094,7 +3101,6 @@ Static ehci_soft_itd_t *
 ehci_alloc_itd(ehci_softc_t *sc)
 {
 	struct ehci_soft_itd *itd, *freeitd;
-	usb_dma_t dma;
 
 	EHCIHIST_FUNC(); EHCIHIST_CALLED();
 
@@ -3105,6 +3111,7 @@ ehci_alloc_itd(ehci_softc_t *sc)
 		DPRINTF("allocating chunk", 0, 0, 0, 0);
 		mutex_exit(>sc_lock);
 
+		usb_dma_t dma;
 		int err = usb_allocmem(>sc_bus,
 		EHCI_ITD_SIZE * EHCI_ITD_CHUNK,
 		EHCI_PAGE_SIZE, USBMALLOC_COHERENT, );
@@ -3115,12 +3122,17 @@ ehci_alloc_itd(ehci_softc_t *sc)
 		}
 
 		mutex_enter(>sc_lock);
-		for (int i = 0; i < EHCI_ITD_CHUNK; i++) {
-			int offs = i * EHCI_ITD_SIZE;
+		for (size_t i = 0; i < EHCI_ITD_CHUNK; i++) {
+			const int offs = i * EHCI_ITD_SIZE;
+			const bus_addr_t baddr = DMAADDR(, offs);
+
+			KASSERT(BUS_ADDR_HI32(baddr) == 0);
+
 			itd = KERNADDR(, offs);
-			itd->physaddr = DMAADDR(, offs);
+			itd->physaddr = BUS_ADDR_LO32(baddr);
 	 		itd->dma = dma;
 			itd->offs = offs;
+
 			LIST_INSERT_HEAD(>sc_freeitds, itd, free_list);
 		}
 		freeitd = LIST_FIRST(>sc_freeitds);
@@ -3143,17 +3155,17 @@ Static ehci_soft_sitd_t *
 ehci_alloc_sitd(ehci_softc_t *sc)
 {
 	struct ehci_soft_sitd *sitd, *freesitd;
-	int i, offs;
-	usb_dma_t dma;
 
 	EHCIHIST_FUNC(); EHCIHIST_CALLED();
 
 	mutex_enter(>sc_lock);
 	freesitd = LIST_FIRST(>sc_freesitds);
 	if (freesitd == NULL) {
+
 		DPRINTF("allocating chunk", 0, 0, 0, 0);
 		mutex_exit(>sc_lock);
 
+		usb_dma_t dma;
 		int err = usb_allocmem(>sc_bus,
 		EHCI_SITD_SIZE * EHCI_SITD_CHUNK,
 		EHCI_PAGE_SIZE, USBMALLOC_COHERENT, );
@@ -3164,12 +3176,17 @@ ehci_alloc_sitd(ehci_softc_t *sc)
 		}
 
 		mutex_enter(>sc_lock);
-		for (i = 0; i < EHCI_SITD_CHUNK; i++) {
-			offs = i * EHCI_SITD_SIZE;
+		for (size_t i = 0; i < EHCI_SITD_CHUNK; 

CVS commit: src/sys/dev/usb

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 08:49:03 UTC 2021

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

Log Message:
KASSERT(BUS_ADDR_HI32(baddr) == 0) in, and apply some consistent code
style to all of ehci_alloc_{sqh,sqtd,itd,sitd}.

While ehci can address memory >4GB for control structures
EHCI_CTRLDSSEGMENT is always set to zero so ehci assumes it's using the
low 4GB.


To generate a diff of this commit:
cvs rdiff -u -r1.291 -r1.292 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 18 14:48:14 UTC 2021

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

Log Message:
Fix two bugs

i)  EHCI_HCSPARAMS should be read with EREAD4 (and not EOREAD4). Spotted by
jmcneill

ii) Apply brackets so that ?: vs | operator precedence doesn't give the
wrong result.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.290 src/sys/dev/usb/ehci.c:1.291
--- src/sys/dev/usb/ehci.c:1.290	Tue Dec  7 08:04:10 2021
+++ src/sys/dev/usb/ehci.c	Sat Dec 18 14:48:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.290 2021/12/07 08:04:10 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.291 2021/12/18 14:48:14 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.290 2021/12/07 08:04:10 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.291 2021/12/18 14:48:14 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2426,11 +2426,10 @@ ehci_roothub_ctrl(struct usbd_bus *bus, 
 		totlen = uimin(buflen, sizeof(hubd));
 		memcpy(, buf, totlen);
 		hubd.bNbrPorts = sc->sc_noport;
-		v = EOREAD4(sc, EHCI_HCSPARAMS);
+		v = EREAD4(sc, EHCI_HCSPARAMS);
 		USETW(hubd.wHubCharacteristics,
-		EHCI_HCS_PPC(v) ? UHD_PWR_INDIVIDUAL : UHD_PWR_NO_SWITCH |
-		EHCI_HCS_P_INDICATOR(EREAD4(sc, EHCI_HCSPARAMS))
-			? UHD_PORT_IND : 0);
+		(EHCI_HCS_PPC(v) ? UHD_PWR_INDIVIDUAL : UHD_PWR_NO_SWITCH) |
+		(EHCI_HCS_P_INDICATOR(v) ? UHD_PORT_IND : 0));
 		hubd.bPwrOn2PwrGood = 200; /* XXX can't find out? */
 		for (i = 0, l = sc->sc_noport; l > 0; i++, l -= 8, v >>= 8)
 			hubd.DeviceRemovable[i++] = 0; /* XXX can't find out? */



CVS commit: src/sys/dev/usb

2021-12-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 18 14:48:14 UTC 2021

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

Log Message:
Fix two bugs

i)  EHCI_HCSPARAMS should be read with EREAD4 (and not EOREAD4). Spotted by
jmcneill

ii) Apply brackets so that ?: vs | operator precedence doesn't give the
wrong result.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec 17 08:17:40 UTC 2021

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

Log Message:
add two additional cyperpower ups ids for ignore hid.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/usb/usb_quirks.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/usb_quirks.c
diff -u src/sys/dev/usb/usb_quirks.c:1.100 src/sys/dev/usb/usb_quirks.c:1.101
--- src/sys/dev/usb/usb_quirks.c:1.100	Sat Oct 16 05:40:46 2021
+++ src/sys/dev/usb/usb_quirks.c	Fri Dec 17 08:17:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_quirks.c,v 1.100 2021/10/16 05:40:46 mrg Exp $	*/
+/*	$NetBSD: usb_quirks.c,v 1.101 2021/12/17 08:17:40 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.100 2021/10/16 05:40:46 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.101 2021/12/17 08:17:40 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -184,8 +184,12 @@ Static const struct usbd_quirk_entry {
  /* Devices which should be ignored by uhid */
  { USB_VENDOR_APC,		USB_PRODUCT_APC_UPS,			ANY,
 	{ UQ_HID_IGNORE, NULL }},
+ { USB_VENDOR_CYBERPOWER,	USB_PRODUCT_CYBERPOWER_UPS0,		ANY,
+	{ UQ_HID_IGNORE, NULL }},
  { USB_VENDOR_CYBERPOWER,	USB_PRODUCT_CYBERPOWER_UPS,		ANY,
 	{ UQ_HID_IGNORE, NULL }},
+ { USB_VENDOR_CYBERPOWER,	USB_PRODUCT_CYBERPOWER_UPS2,		ANY,
+	{ UQ_HID_IGNORE, NULL }},
  { USB_VENDOR_GRETAGMACBETH,	ANY,	ANY,
 	{ UQ_HID_IGNORE, NULL }},
  { USB_VENDOR_MGE,		USB_PRODUCT_MGE_UPS1,			ANY,



CVS commit: src/sys/dev/usb

2021-12-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec 17 08:17:40 UTC 2021

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

Log Message:
add two additional cyperpower ups ids for ignore hid.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/usb/usb_quirks.c

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



CVS commit: src/sys/dev/usb

2021-12-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec 17 08:17:05 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen.


To generate a diff of this commit:
cvs rdiff -u -r1.789 -r1.790 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.789 src/sys/dev/usb/usbdevs.h:1.790
--- src/sys/dev/usb/usbdevs.h:1.789	Thu Oct 21 20:57:06 2021
+++ src/sys/dev/usb/usbdevs.h	Fri Dec 17 08:17:04 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.789 2021/10/21 20:57:06 jakllsch Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.790 2021/12/17 08:17:04 mrg Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.798 2021/10/21 20:16:51 jnemeth Exp
+ *	NetBSD: usbdevs,v 1.799 2021/12/17 08:16:14 mrg Exp
  */
 
 /*-
@@ -1307,7 +1307,9 @@
 #define	USB_PRODUCT_CTX_EX1300	0x		/* Ex1300 hub */
 
 /* CyberPower Systems, Inc. products */
+#define	USB_PRODUCT_CYBERPOWER_UPS0	0x0005		/* Uninterruptible Power Supply */
 #define	USB_PRODUCT_CYBERPOWER_UPS	0x0501		/* Uninterruptible Power Supply */
+#define	USB_PRODUCT_CYBERPOWER_UPS2	0x0601		/* Uninterruptible Power Supply */
 
 /* CyberTAN Technology products */
 #define	USB_PRODUCT_CYBERTAN_TG54USB	0x1666		/* TG54USB */
Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.789 src/sys/dev/usb/usbdevs_data.h:1.790
--- src/sys/dev/usb/usbdevs_data.h:1.789	Thu Oct 21 20:57:06 2021
+++ src/sys/dev/usb/usbdevs_data.h	Fri Dec 17 08:17:04 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.789 2021/10/21 20:57:06 jakllsch Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.790 2021/12/17 08:17:04 mrg Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.798 2021/10/21 20:16:51 jnemeth Exp
+ *	NetBSD: usbdevs,v 1.799 2021/12/17 08:16:14 mrg Exp
  */
 
 /*-
@@ -1586,8 +1586,12 @@ static const uint32_t usb_products[] = {
 	4939, 8599, 8603, 0,
 	USB_VENDOR_CTX, USB_PRODUCT_CTX_EX1300, 
 	8609, 7120, 0,
+	USB_VENDOR_CYBERPOWER, USB_PRODUCT_CYBERPOWER_UPS0, 
+	6018, 1229, 1982, 0,
 	USB_VENDOR_CYBERPOWER, USB_PRODUCT_CYBERPOWER_UPS, 
 	6018, 1229, 1982, 0,
+	USB_VENDOR_CYBERPOWER, USB_PRODUCT_CYBERPOWER_UPS2, 
+	6018, 1229, 1982, 0,
 	USB_VENDOR_CYBERTAN, USB_PRODUCT_CYBERTAN_TG54USB, 
 	8616, 0,
 	USB_VENDOR_CYBERTAN, USB_PRODUCT_CYBERTAN_ZD1211B, 
@@ -5195,7 +5199,7 @@ static const char usb_words[] = { "." 
 	"Components\0" /* 3 refs @ 1200 */
 	"Kawatsu\0" /* 1 refs @ 1211 */
 	"Composite\0" /* 1 refs @ 1219 */
-	"Power\0" /* 4 refs @ 1229 */
+	"Power\0" /* 6 refs @ 1229 */
 	"Conversion\0" /* 1 refs @ 1235 */
 	"Connectek\0" /* 1 refs @ 1246 */
 	"USA\0" /* 1 refs @ 1256 */
@@ -5295,7 +5299,7 @@ static const char usb_words[] = { "." 
 	"TEAC\0" /* 1 refs @ 1962 */
 	"Graphics\0" /* 2 refs @ 1967 */
 	"Sanwa\0" /* 1 refs @ 1976 */
-	"Supply\0" /* 3 refs @ 1982 */
+	"Supply\0" /* 5 refs @ 1982 */
 	"WayTech\0" /* 1 refs @ 1989 */
 	"Development,\0" /* 1 refs @ 1997 */
 	"Linksys\0" /* 4 refs @ 2010 */
@@ -5835,7 +5839,7 @@ static const char usb_words[] = { "." 
 	"ADA70\0" /* 1 refs @ 5996 */
 	"Speakers\0" /* 3 refs @ 6002 */
 	"ASC495\0" /* 1 refs @ 6011 */
-	"Uninterruptible\0" /* 2 refs @ 6018 */
+	"Uninterruptible\0" /* 4 refs @ 6018 */
 	"NTL\0" /* 1 refs @ 6034 */
 	"250\0" /* 3 refs @ 6038 */
 	"cable\0" /* 2 refs @ 6042 */



CVS commit: src/sys/dev/usb

2021-12-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec 17 08:17:05 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen.


To generate a diff of this commit:
cvs rdiff -u -r1.789 -r1.790 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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



CVS commit: src/sys/dev/usb

2021-12-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec 17 08:16:15 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
add two more models of cyperpower UPS.


To generate a diff of this commit:
cvs rdiff -u -r1.798 -r1.799 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.798 src/sys/dev/usb/usbdevs:1.799
--- src/sys/dev/usb/usbdevs:1.798	Thu Oct 21 20:16:51 2021
+++ src/sys/dev/usb/usbdevs	Fri Dec 17 08:16:14 2021
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.798 2021/10/21 20:16:51 jnemeth Exp $
+$NetBSD: usbdevs,v 1.799 2021/12/17 08:16:14 mrg Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1300,7 +1300,9 @@ product CMEDIA USBAUDIO		0x013c	USB Pnp 
 product CTX EX1300		0x	Ex1300 hub
 
 /* CyberPower Systems, Inc. products */
+product CYBERPOWER UPS0		0x0005	Uninterruptible Power Supply
 product CYBERPOWER UPS		0x0501	Uninterruptible Power Supply
+product CYBERPOWER UPS2		0x0601	Uninterruptible Power Supply
 
 /* CyberTAN Technology products */
 product CYBERTAN TG54USB	0x1666	TG54USB



CVS commit: src/sys/dev/usb

2021-12-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec 17 08:16:15 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
add two more models of cyperpower UPS.


To generate a diff of this commit:
cvs rdiff -u -r1.798 -r1.799 src/sys/dev/usb/usbdevs

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



CVS commit: src/sys/dev/usb

2021-12-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec  7 08:04:10 UTC 2021

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

Log Message:
Match variable names to register names. Same binary before and after.


To generate a diff of this commit:
cvs rdiff -u -r1.289 -r1.290 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec  7 08:04:10 UTC 2021

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

Log Message:
Match variable names to register names. Same binary before and after.


To generate a diff of this commit:
cvs rdiff -u -r1.289 -r1.290 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.289 src/sys/dev/usb/ehci.c:1.290
--- src/sys/dev/usb/ehci.c:1.289	Tue Dec  7 07:58:20 2021
+++ src/sys/dev/usb/ehci.c	Tue Dec  7 08:04:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.289 2021/12/07 07:58:20 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.290 2021/12/07 08:04:10 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.289 2021/12/07 07:58:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.290 2021/12/07 08:04:10 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -401,7 +401,7 @@ static const uint8_t revbits[EHCI_MAX_PO
 int
 ehci_init(ehci_softc_t *sc)
 {
-	uint32_t vers, sparams, cparams, hcr;
+	uint32_t vers, hcr;
 	u_int i;
 	int err;
 	ehci_soft_qh_t *sqh;
@@ -432,10 +432,10 @@ ehci_init(ehci_softc_t *sc)
 	aprint_verbose("%s: EHCI version %x.%x\n", device_xname(sc->sc_dev),
 	vers >> 8, vers & 0xff);
 
-	sparams = EREAD4(sc, EHCI_HCSPARAMS);
-	DPRINTF("sparams=%#jx", sparams, 0, 0, 0);
-	sc->sc_npcomp = EHCI_HCS_N_PCC(sparams);
-	ncomp = EHCI_HCS_N_CC(sparams);
+	const uint32_t hcsparams = EREAD4(sc, EHCI_HCSPARAMS);
+	DPRINTF("hcsparams=%#jx", hcsparams, 0, 0, 0);
+	sc->sc_npcomp = EHCI_HCS_N_PCC(hcsparams);
+	ncomp = EHCI_HCS_N_CC(hcsparams);
 	if (ncomp != sc->sc_ncomp) {
 		aprint_verbose("%s: wrong number of companions (%d != %d)\n",
 		device_xname(sc->sc_dev), ncomp, sc->sc_ncomp);
@@ -452,8 +452,8 @@ ehci_init(ehci_softc_t *sc)
 		"%d companion controller%s, %d port%s%s",
 		sc->sc_ncomp,
 		sc->sc_ncomp!=1 ? "s" : "",
-		EHCI_HCS_N_PCC(sparams),
-		EHCI_HCS_N_PCC(sparams)!=1 ? "s" : "",
+		EHCI_HCS_N_PCC(hcsparams),
+		EHCI_HCS_N_PCC(hcsparams)!=1 ? "s" : "",
 		sc->sc_ncomp!=1 ? " each" : "");
 		if (sc->sc_comps[0]) {
 			aprint_normal(":");
@@ -468,21 +468,21 @@ ehci_init(ehci_softc_t *sc)
 		cv_init(>sc_compcv, "ehciccv");
 		sc->sc_comp_state = CO_EARLY;
 	}
-	sc->sc_noport = EHCI_HCS_N_PORTS(sparams);
-	sc->sc_hasppc = EHCI_HCS_PPC(sparams);
+	sc->sc_noport = EHCI_HCS_N_PORTS(hcsparams);
+	sc->sc_hasppc = EHCI_HCS_PPC(hcsparams);
 
-	cparams = EREAD4(sc, EHCI_HCCPARAMS);
-	DPRINTF("cparams=%#jx", cparams, 0, 0, 0);
+	const uint32_t hccparams = EREAD4(sc, EHCI_HCCPARAMS);
+	DPRINTF("hccparams=%#jx", hccparams, 0, 0, 0);
 
-	if (EHCI_HCC_64BIT(cparams)) {
+	if (EHCI_HCC_64BIT(hccparams)) {
 		/* MUST clear segment register if 64 bit capable. */
 		EOWRITE4(sc, EHCI_CTRLDSSEGMENT, 0);
 	}
 
-	if (cparams & EHCI_HCC_IST_FULLFRAME) {
+	if (hccparams & EHCI_HCC_IST_FULLFRAME) {
 		sc->sc_istthreshold = 0;
 	} else {
-		sc->sc_istthreshold = EHCI_HCC_GET_IST_THRESHOLD(cparams);
+		sc->sc_istthreshold = EHCI_HCC_GET_IST_THRESHOLD(hccparams);
 	}
 
 	sc->sc_bus.ub_revision = USBREV_2_0;



CVS commit: src/sys/dev/usb

2021-12-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec  7 07:58:20 UTC 2021

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

Log Message:
More usb_status_t -> int


To generate a diff of this commit:
cvs rdiff -u -r1.288 -r1.289 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.288 src/sys/dev/usb/ehci.c:1.289
--- src/sys/dev/usb/ehci.c:1.288	Tue Dec  7 07:54:32 2021
+++ src/sys/dev/usb/ehci.c	Tue Dec  7 07:58:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.288 2021/12/07 07:54:32 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.289 2021/12/07 07:58:20 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.288 2021/12/07 07:54:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.289 2021/12/07 07:58:20 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -403,7 +403,7 @@ ehci_init(ehci_softc_t *sc)
 {
 	uint32_t vers, sparams, cparams, hcr;
 	u_int i;
-	usbd_status err;
+	int err;
 	ehci_soft_qh_t *sqh;
 	u_int ncomp;
 



CVS commit: src/sys/dev/usb

2021-12-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec  7 07:58:20 UTC 2021

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

Log Message:
More usb_status_t -> int


To generate a diff of this commit:
cvs rdiff -u -r1.288 -r1.289 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec  7 07:54:32 UTC 2021

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

Log Message:
Code consistency.  NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.287 src/sys/dev/usb/ehci.c:1.288
--- src/sys/dev/usb/ehci.c:1.287	Sun Dec  5 11:05:37 2021
+++ src/sys/dev/usb/ehci.c	Tue Dec  7 07:54:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.287 2021/12/05 11:05:37 riastradh Exp $ */
+/*	$NetBSD: ehci.c,v 1.288 2021/12/07 07:54:32 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.287 2021/12/05 11:05:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.288 2021/12/07 07:54:32 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2788,7 +2788,6 @@ Static ehci_soft_qh_t *
 ehci_alloc_sqh(ehci_softc_t *sc)
 {
 	ehci_soft_qh_t *sqh;
-	usbd_status err;
 	int i, offs;
 	usb_dma_t dma;
 
@@ -2799,14 +2798,14 @@ ehci_alloc_sqh(ehci_softc_t *sc)
 		DPRINTF("allocating chunk", 0, 0, 0, 0);
 		mutex_exit(>sc_lock);
 
-		err = usb_allocmem(>sc_bus, EHCI_SQH_SIZE * EHCI_SQH_CHUNK,
+		int err = usb_allocmem(>sc_bus,
+		EHCI_SQH_SIZE * EHCI_SQH_CHUNK,
 		EHCI_PAGE_SIZE, USBMALLOC_COHERENT, );
-#ifdef EHCI_DEBUG
-		if (err)
-			printf("ehci_alloc_sqh: usb_allocmem()=%d\n", err);
-#endif
-		if (err)
+
+		if (err) {
+			DPRINTF("alloc returned %jd", err, 0, 0, 0);
 			return NULL;
+		}
 
 		mutex_enter(>sc_lock);
 		for (i = 0; i < EHCI_SQH_CHUNK; i++) {
@@ -2852,15 +2851,13 @@ ehci_alloc_sqtd(ehci_softc_t *sc)
 		mutex_exit(>sc_lock);
 
 		int err = usb_allocmem(>sc_bus,
-		EHCI_SQTD_SIZE*EHCI_SQTD_CHUNK,
-		EHCI_PAGE_SIZE, USBMALLOC_COHERENT,
-		);
-#ifdef EHCI_DEBUG
-		if (err)
-			printf("ehci_alloc_sqtd: usb_allocmem()=%d\n", err);
-#endif
-		if (err)
-			goto done;
+		EHCI_SQTD_SIZE * EHCI_SQTD_CHUNK,
+		EHCI_PAGE_SIZE, USBMALLOC_COHERENT, );
+
+		if (err) {
+			DPRINTF("alloc returned %jd", err, 0, 0, 0);
+			return NULL;
+		}
 
 		mutex_enter(>sc_lock);
 		for (i = 0; i < EHCI_SQTD_CHUNK; i++) {
@@ -2883,7 +2880,6 @@ ehci_alloc_sqtd(ehci_softc_t *sc)
 	sqtd->nextqtd = NULL;
 	sqtd->xfer = NULL;
 
-done:
 	return sqtd;
 }
 
@@ -3109,15 +3105,17 @@ ehci_alloc_itd(ehci_softc_t *sc)
 	if (freeitd == NULL) {
 		DPRINTF("allocating chunk", 0, 0, 0, 0);
 		mutex_exit(>sc_lock);
-		int err = usb_allocmem(>sc_bus, EHCI_ITD_SIZE * EHCI_ITD_CHUNK,
+
+		int err = usb_allocmem(>sc_bus,
+		EHCI_ITD_SIZE * EHCI_ITD_CHUNK,
 		EHCI_PAGE_SIZE, USBMALLOC_COHERENT, );
 
 		if (err) {
 			DPRINTF("alloc returned %jd", err, 0, 0, 0);
 			return NULL;
 		}
-		mutex_enter(>sc_lock);
 
+		mutex_enter(>sc_lock);
 		for (int i = 0; i < EHCI_ITD_CHUNK; i++) {
 			int offs = i * EHCI_ITD_SIZE;
 			itd = KERNADDR(, offs);
@@ -3156,12 +3154,13 @@ ehci_alloc_sitd(ehci_softc_t *sc)
 	if (freesitd == NULL) {
 		DPRINTF("allocating chunk", 0, 0, 0, 0);
 		mutex_exit(>sc_lock);
-		int err = usb_allocmem(>sc_bus, EHCI_SITD_SIZE * EHCI_SITD_CHUNK,
+
+		int err = usb_allocmem(>sc_bus,
+		EHCI_SITD_SIZE * EHCI_SITD_CHUNK,
 		EHCI_PAGE_SIZE, USBMALLOC_COHERENT, );
 
 		if (err) {
-			DPRINTF("alloc returned %jd", err, 0, 0,
-			0);
+			DPRINTF("alloc returned %jd", err, 0, 0, 0);
 			return NULL;
 		}
 



CVS commit: src/sys/dev/usb

2021-12-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec  7 07:54:32 UTC 2021

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

Log Message:
Code consistency.  NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-12-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec  5 11:05:37 UTC 2021

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

Log Message:
ehci: Replace bogus polling during suspend by taking bus lock.

The system is not at high IPL or limited to a single CPU at this
point; it is running essentially normally, just with some devices
suspended.  Other threads might be trying to touch EHCI registers,
which might have bad outcomes while we're suspending stuff.  Enabling
polling only makes sense if there is a single thread and single CPU
running, such as when we enter ddb on crash.


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.286 src/sys/dev/usb/ehci.c:1.287
--- src/sys/dev/usb/ehci.c:1.286	Tue Aug 31 08:22:28 2021
+++ src/sys/dev/usb/ehci.c	Sun Dec  5 11:05:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.286 2021/08/31 08:22:28 mrg Exp $ */
+/*	$NetBSD: ehci.c,v 1.287 2021/12/05 11:05:37 riastradh Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.286 2021/08/31 08:22:28 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.287 2021/12/05 11:05:37 riastradh Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -1385,10 +1385,6 @@ ehci_activate(device_t self, enum devact
 /*
  * Handle suspend/resume.
  *
- * We need to switch to polling mode here, because this routine is
- * called from an interrupt context.  This is all right since we
- * are almost suspended anyway.
- *
  * Note that this power handler isn't to be registered directly; the
  * bus glue needs to call out to it.
  */
@@ -1401,9 +1397,7 @@ ehci_suspend(device_t dv, const pmf_qual
 
 	EHCIHIST_FUNC(); EHCIHIST_CALLED();
 
-	mutex_spin_enter(>sc_intr_lock);
-	sc->sc_bus.ub_usepolling++;
-	mutex_spin_exit(>sc_intr_lock);
+	mutex_enter(>sc_lock);
 
 	for (i = 1; i <= sc->sc_noport; i++) {
 		cmd = EOREAD4(sc, EHCI_PORTSC(i)) & ~EHCI_PS_CLEAR;
@@ -1439,9 +1433,7 @@ ehci_suspend(device_t dv, const pmf_qual
 	if (hcr != EHCI_STS_HCH)
 		printf("%s: config timeout\n", device_xname(dv));
 
-	mutex_spin_enter(>sc_intr_lock);
-	sc->sc_bus.ub_usepolling--;
-	mutex_spin_exit(>sc_intr_lock);
+	mutex_exit(>sc_lock);
 
 	return true;
 }
@@ -1455,6 +1447,8 @@ ehci_resume(device_t dv, const pmf_qual_
 
 	EHCIHIST_FUNC(); EHCIHIST_CALLED();
 
+	mutex_enter(>sc_lock);
+
 	/* restore things in case the bios sucks */
 	EOWRITE4(sc, EHCI_CTRLDSSEGMENT, 0);
 	EOWRITE4(sc, EHCI_PERIODICLISTBASE, DMAADDR(>sc_fldma, 0));
@@ -1500,6 +1494,8 @@ ehci_resume(device_t dv, const pmf_qual_
 	if (hcr == EHCI_STS_HCH)
 		printf("%s: config timeout\n", device_xname(dv));
 
+	mutex_exit(>sc_lock);
+
 	return true;
 }
 



CVS commit: src/sys/dev/usb

2021-12-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec  5 11:05:37 UTC 2021

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

Log Message:
ehci: Replace bogus polling during suspend by taking bus lock.

The system is not at high IPL or limited to a single CPU at this
point; it is running essentially normally, just with some devices
suspended.  Other threads might be trying to touch EHCI registers,
which might have bad outcomes while we're suspending stuff.  Enabling
polling only makes sense if there is a single thread and single CPU
running, such as when we enter ddb on crash.


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys/dev/usb

2021-11-14 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Nov 14 08:32:07 UTC 2021

Modified Files:
src/sys/dev/usb: uvideo.c uvideoreg.h

Log Message:
revert bPreferedVersion rename. It's named like the by spec (from jmcneill).


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/usb/uvideo.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/uvideoreg.h

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

Modified files:

Index: src/sys/dev/usb/uvideo.c
diff -u src/sys/dev/usb/uvideo.c:1.62 src/sys/dev/usb/uvideo.c:1.63
--- src/sys/dev/usb/uvideo.c:1.62	Sat Nov 13 21:13:41 2021
+++ src/sys/dev/usb/uvideo.c	Sun Nov 14 08:32:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvideo.c,v 1.62 2021/11/13 21:13:41 andvar Exp $	*/
+/*	$NetBSD: uvideo.c,v 1.63 2021/11/14 08:32:07 andvar Exp $	*/
 
 /*
  * Copyright (c) 2008 Patrick Mahoney
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.62 2021/11/13 21:13:41 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.63 2021/11/14 08:32:07 andvar Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2049,11 +2049,11 @@ uvideo_set_format(void *addr, struct vid
 		  UGETDW(probe.dwMaxPayloadTransferSize)));
 	if (vs->vs_probelen == 34) {
 		DPRINTFN(15, (" dwClockFrequency=%u bmFramingInfo=0x%02x "
-			  "bPreferredVersion=%d bMinVersion=%d "
+			  "bPreferedVersion=%d bMinVersion=%d "
 			  "bMaxVersion=%d",
 			  UGETDW(probe.dwClockFrequency),
 			  probe.bmFramingInfo,
-			  probe.bPreferredVersion,
+			  probe.bPreferedVersion,
 			  probe.bMinVersion,
 			  probe.bMaxVersion));
 	}

Index: src/sys/dev/usb/uvideoreg.h
diff -u src/sys/dev/usb/uvideoreg.h:1.5 src/sys/dev/usb/uvideoreg.h:1.6
--- src/sys/dev/usb/uvideoreg.h:1.5	Sat Nov 13 21:13:41 2021
+++ src/sys/dev/usb/uvideoreg.h	Sun Nov 14 08:32:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvideoreg.h,v 1.5 2021/11/13 21:13:41 andvar Exp $	*/
+/*	$NetBSD: uvideoreg.h,v 1.6 2021/11/14 08:32:07 andvar Exp $	*/
 
 /*
  * Copyright (c) 2008 Patrick Mahoney
@@ -644,7 +644,7 @@ typedef struct {
 	uByte		bmFramingInfo;
 #define UVIDEO_FRAMING_INFO_FID	(1<<0)
 #define UVIDEO_FRAMING_INFO_EOF	(1<<1)
-	uByte		bPreferredVersion;
+	uByte		bPreferedVersion;
 	uByte		bMinVersion;
 	uByte		bMaxVersion;
 } UPACKED uvideo_probe_and_commit_data_t;



CVS commit: src/sys/dev/usb

2021-11-14 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Nov 14 08:32:07 UTC 2021

Modified Files:
src/sys/dev/usb: uvideo.c uvideoreg.h

Log Message:
revert bPreferedVersion rename. It's named like the by spec (from jmcneill).


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/usb/uvideo.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/uvideoreg.h

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



CVS commit: src/sys/dev/usb

2021-11-13 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Nov 13 21:13:41 UTC 2021

Modified Files:
src/sys/dev/usb: uvideo.c uvideoreg.h

Log Message:
s/bPreferedVersion/bPreferredVersion/ in struct property definition.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/usb/uvideo.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/uvideoreg.h

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

Modified files:

Index: src/sys/dev/usb/uvideo.c
diff -u src/sys/dev/usb/uvideo.c:1.61 src/sys/dev/usb/uvideo.c:1.62
--- src/sys/dev/usb/uvideo.c:1.61	Fri Sep  3 21:55:00 2021
+++ src/sys/dev/usb/uvideo.c	Sat Nov 13 21:13:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvideo.c,v 1.61 2021/09/03 21:55:00 andvar Exp $	*/
+/*	$NetBSD: uvideo.c,v 1.62 2021/11/13 21:13:41 andvar Exp $	*/
 
 /*
  * Copyright (c) 2008 Patrick Mahoney
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.61 2021/09/03 21:55:00 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.62 2021/11/13 21:13:41 andvar Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2049,11 +2049,11 @@ uvideo_set_format(void *addr, struct vid
 		  UGETDW(probe.dwMaxPayloadTransferSize)));
 	if (vs->vs_probelen == 34) {
 		DPRINTFN(15, (" dwClockFrequency=%u bmFramingInfo=0x%02x "
-			  "bPreferedVersion=%d bMinVersion=%d "
+			  "bPreferredVersion=%d bMinVersion=%d "
 			  "bMaxVersion=%d",
 			  UGETDW(probe.dwClockFrequency),
 			  probe.bmFramingInfo,
-			  probe.bPreferedVersion,
+			  probe.bPreferredVersion,
 			  probe.bMinVersion,
 			  probe.bMaxVersion));
 	}

Index: src/sys/dev/usb/uvideoreg.h
diff -u src/sys/dev/usb/uvideoreg.h:1.4 src/sys/dev/usb/uvideoreg.h:1.5
--- src/sys/dev/usb/uvideoreg.h:1.4	Fri Dec 23 00:51:49 2011
+++ src/sys/dev/usb/uvideoreg.h	Sat Nov 13 21:13:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvideoreg.h,v 1.4 2011/12/23 00:51:49 jakllsch Exp $	*/
+/*	$NetBSD: uvideoreg.h,v 1.5 2021/11/13 21:13:41 andvar Exp $	*/
 
 /*
  * Copyright (c) 2008 Patrick Mahoney
@@ -644,7 +644,7 @@ typedef struct {
 	uByte		bmFramingInfo;
 #define UVIDEO_FRAMING_INFO_FID	(1<<0)
 #define UVIDEO_FRAMING_INFO_EOF	(1<<1)
-	uByte		bPreferedVersion;
+	uByte		bPreferredVersion;
 	uByte		bMinVersion;
 	uByte		bMaxVersion;
 } UPACKED uvideo_probe_and_commit_data_t;



CVS commit: src/sys/dev/usb

2021-11-13 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Nov 13 21:13:41 UTC 2021

Modified Files:
src/sys/dev/usb: uvideo.c uvideoreg.h

Log Message:
s/bPreferedVersion/bPreferredVersion/ in struct property definition.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/usb/uvideo.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/uvideoreg.h

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



CVS commit: src/sys/dev/usb

2021-11-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 13 10:34:00 UTC 2021

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

Log Message:
Release interrupt lock while allocating ressources in trigger
functions.

Also be more verbose about errors.


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

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



CVS commit: src/sys/dev/usb

2021-11-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 13 10:34:00 UTC 2021

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

Log Message:
Release interrupt lock while allocating ressources in trigger
functions.

Also be more verbose about errors.


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

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

Modified files:

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.172 src/sys/dev/usb/uaudio.c:1.173
--- src/sys/dev/usb/uaudio.c:1.172	Sat Jun 19 05:50:48 2021
+++ src/sys/dev/usb/uaudio.c	Sat Nov 13 10:34:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.172 2021/06/19 05:50:48 mlelstv Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.173 2021/11/13 10:34:00 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.172 2021/06/19 05:50:48 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.173 2021/11/13 10:34:00 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2612,6 +2612,8 @@ uaudio_trigger_input(void *addr, void *s
 	if (sc->sc_dying)
 		return EIO;
 
+	mutex_exit(>sc_intr_lock);
+
 	DPRINTFN(3, "sc=%p start=%p end=%p "
 		"blksize=%d\n", sc, start, end, blksize);
 	ch = >sc_recchan;
@@ -2622,12 +2624,16 @@ uaudio_trigger_input(void *addr, void *s
 
 	err = uaudio_chan_open(sc, ch);
 	if (err) {
+		mutex_enter(>sc_intr_lock);
+		device_printf(sc->sc_dev,"%s open channel err=%s\n",__func__, usbd_errstr(err));
 		return EIO;
 	}
 
 	err = uaudio_chan_alloc_buffers(sc, ch);
 	if (err) {
 		uaudio_chan_close(sc, ch);
+		device_printf(sc->sc_dev,"%s alloc buffers err=%s\n",__func__, usbd_errstr(err));
+		mutex_enter(>sc_intr_lock);
 		return EIO;
 	}
 
@@ -2643,6 +2649,8 @@ uaudio_trigger_input(void *addr, void *s
 		uaudio_chan_rtransfer(ch);
 	}
 
+	mutex_enter(>sc_intr_lock);
+
 	return 0;
 }
 
@@ -2660,6 +2668,8 @@ uaudio_trigger_output(void *addr, void *
 	if (sc->sc_dying)
 		return EIO;
 
+	mutex_exit(>sc_intr_lock);
+
 	DPRINTFN(3, "sc=%p start=%p end=%p "
 		"blksize=%d\n", sc, start, end, blksize);
 	ch = >sc_playchan;
@@ -2670,12 +2680,16 @@ uaudio_trigger_output(void *addr, void *
 
 	err = uaudio_chan_open(sc, ch);
 	if (err) {
+		mutex_enter(>sc_intr_lock);
+		device_printf(sc->sc_dev,"%s open channel err=%s\n",__func__, usbd_errstr(err));
 		return EIO;
 	}
 
 	err = uaudio_chan_alloc_buffers(sc, ch);
 	if (err) {
 		uaudio_chan_close(sc, ch);
+		device_printf(sc->sc_dev,"%s alloc buffers err=%s\n",__func__, usbd_errstr(err));
+		mutex_enter(>sc_intr_lock);
 		return EIO;
 	}
 
@@ -2685,6 +2699,8 @@ uaudio_trigger_output(void *addr, void *
 	for (i = 0; i < UAUDIO_NCHANBUFS; i++)
 		uaudio_chan_ptransfer(ch);
 
+	mutex_enter(>sc_intr_lock);
+
 	return 0;
 }
 
@@ -2866,7 +2882,9 @@ uaudio_chan_ptransfer(struct chan *ch)
 	usbd_setup_isoc_xfer(cb->xfer, cb, cb->sizes, UAUDIO_NFRAMES, 0,
 	uaudio_chan_pintr);
 
-	(void)usbd_transfer(cb->xfer);
+	usbd_status err = usbd_transfer(cb->xfer);
+	if (err != USBD_IN_PROGRESS && err != USBD_NORMAL_COMPLETION)
+		device_printf(ch->sc->sc_dev, "ptransfer error %d\n", err);
 }
 
 Static void
@@ -2883,6 +2901,10 @@ uaudio_chan_pintr(struct usbd_xfer *xfer
 	if (status == USBD_CANCELLED)
 		return;
 
+	if (status != USBD_NORMAL_COMPLETION)
+		device_printf(ch->sc->sc_dev, "pintr error: %s\n",
+		  usbd_errstr(status));
+
 	usbd_get_xfer_status(xfer, NULL, NULL, , NULL);
 	DPRINTFN(5, "count=%d, transferred=%d\n",
 		count, ch->transferred);
@@ -2948,7 +2970,9 @@ uaudio_chan_rtransfer(struct chan *ch)
 	usbd_setup_isoc_xfer(cb->xfer, cb, cb->sizes, UAUDIO_NFRAMES, 0,
 	uaudio_chan_rintr);
 
-	(void)usbd_transfer(cb->xfer);
+	usbd_status err = usbd_transfer(cb->xfer);
+	if (err != USBD_IN_PROGRESS && err != USBD_NORMAL_COMPLETION)
+		device_printf(ch->sc->sc_dev, "rtransfer error %d\n", err);
 }
 
 Static void
@@ -2966,6 +2990,10 @@ uaudio_chan_rintr(struct usbd_xfer *xfer
 	if (status == USBD_CANCELLED)
 		return;
 
+	if (status != USBD_NORMAL_COMPLETION && status != USBD_SHORT_XFER)
+		device_printf(ch->sc->sc_dev, "rintr error: %s\n",
+		  usbd_errstr(status));
+
 	usbd_get_xfer_status(xfer, NULL, NULL, , NULL);
 	DPRINTFN(5, "count=%d, transferred=%d\n", count, ch->transferred);
 



CVS commit: src/sys/dev/usb

2021-11-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov  6 06:44:42 UTC 2021

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

Log Message:
USB style. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.268 -r1.269 src/sys/dev/usb/usb_subr.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/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.268 src/sys/dev/usb/usb_subr.c:1.269
--- src/sys/dev/usb/usb_subr.c:1.268	Sat Nov  6 06:41:02 2021
+++ src/sys/dev/usb/usb_subr.c	Sat Nov  6 06:44:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.268 2021/11/06 06:41:02 skrll Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.269 2021/11/06 06:44:42 skrll Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.268 2021/11/06 06:41:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.269 2021/11/06 06:44:42 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -362,7 +362,7 @@ usbd_find_idesc(usb_config_descriptor_t 
 
 usb_endpoint_descriptor_t *
 usbd_find_edesc(usb_config_descriptor_t *cd, int ifaceidx, int altidx,
-		int endptidx)
+int endptidx)
 {
 	char *p = (char *)cd;
 	char *end = p + UGETW(cd->wTotalLength);
@@ -1093,7 +1093,7 @@ usbd_properties(device_t dv, struct usbd
 
 static usbd_status
 usbd_attachwholedevice(device_t parent, struct usbd_device *dev, int port,
-	int usegeneric)
+int usegeneric)
 {
 	struct usb_attach_arg uaa;
 	usb_device_descriptor_t *dd = >ud_ddesc;
@@ -1141,7 +1141,7 @@ usbd_attachwholedevice(device_t parent, 
 
 static usbd_status
 usbd_attachinterfaces(device_t parent, struct usbd_device *dev,
-		  int port, const int *locators)
+int port, const int *locators)
 {
 	USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
 	struct usbif_attach_arg uiaa;
@@ -1235,7 +1235,7 @@ usbd_attachinterfaces(device_t parent, s
 
 usbd_status
 usbd_probe_and_attach(device_t parent, struct usbd_device *dev,
-  int port, int addr)
+int port, int addr)
 {
 	USBHIST_FUNC();
 	USBHIST_CALLARGS(usbdebug, "trying device specific drivers", 0, 0, 0, 0);
@@ -1305,7 +1305,7 @@ usbd_probe_and_attach(device_t parent, s
  */
 usbd_status
 usbd_reattach_device(device_t parent, struct usbd_device *dev,
- int port, const int *locators)
+int port, const int *locators)
 {
 	int i, loc;
 



CVS commit: src/sys/dev/usb

2021-11-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov  6 06:44:42 UTC 2021

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

Log Message:
USB style. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.268 -r1.269 src/sys/dev/usb/usb_subr.c

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



CVS commit: src/sys/dev/usb

2021-11-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov  6 06:41:02 UTC 2021

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

Log Message:
config_pending_incr doesn't need KERNEL_LOCK protection


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/sys/dev/usb/usb_subr.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/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.267 src/sys/dev/usb/usb_subr.c:1.268
--- src/sys/dev/usb/usb_subr.c:1.267	Tue Sep  7 10:44:18 2021
+++ src/sys/dev/usb/usb_subr.c	Sat Nov  6 06:41:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.267 2021/09/07 10:44:18 riastradh Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.268 2021/11/06 06:41:02 skrll Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.267 2021/09/07 10:44:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.268 2021/11/06 06:41:02 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1120,8 +1120,9 @@ usbd_attachwholedevice(device_t parent, 
 	dlocs[USBDEVIFCF_CONFIGURATION] = -1;
 	dlocs[USBDEVIFCF_INTERFACE] = -1;
 
-	KERNEL_LOCK(1, curlwp);
 	config_pending_incr(parent);
+
+	KERNEL_LOCK(1, curlwp);
 	dv = config_found(parent, , usbd_print,
 			  CFARGS(.submatch = config_stdsubmatch,
  .iattr = "usbdevif",



CVS commit: src/sys/dev/usb

2021-11-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov  6 06:41:02 UTC 2021

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

Log Message:
config_pending_incr doesn't need KERNEL_LOCK protection


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/sys/dev/usb/usb_subr.c

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



CVS commit: src/sys/dev/usb

2021-10-23 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Oct 23 20:40:23 UTC 2021

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

Log Message:
xhci: Always read/write both halves of 64-bit registers

Access the 64-bit registers in their entirety at all times, independent
of the AC64 parameter of the hardware implementation.

Makes xhci(4) work on SolidRun MACCHIATObin (Marvell 8040 SoC)


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 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.149 src/sys/dev/usb/xhci.c:1.150
--- src/sys/dev/usb/xhci.c:1.149	Sun Oct 10 20:10:12 2021
+++ src/sys/dev/usb/xhci.c	Sat Oct 23 20:40:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.149 2021/10/10 20:10:12 jmcneill Exp $	*/
+/*	$NetBSD: xhci.c,v 1.150 2021/10/23 20:40:23 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.149 2021/10/10 20:10:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.150 2021/10/23 20:40:23 jakllsch Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -344,17 +344,13 @@ xhci_op_read_8(const struct xhci_softc *
 {
 	uint64_t value;
 
-	if (XHCI_HCC_AC64(sc->sc_hcc)) {
 #ifdef XHCI_USE_BUS_SPACE_8
-		value = bus_space_read_8(sc->sc_iot, sc->sc_obh, offset);
+	value = bus_space_read_8(sc->sc_iot, sc->sc_obh, offset);
 #else
-		value = bus_space_read_4(sc->sc_iot, sc->sc_obh, offset);
-		value |= (uint64_t)bus_space_read_4(sc->sc_iot, sc->sc_obh,
-		offset + 4) << 32;
+	value = bus_space_read_4(sc->sc_iot, sc->sc_obh, offset);
+	value |= (uint64_t)bus_space_read_4(sc->sc_iot, sc->sc_obh,
+	offset + 4) << 32;
 #endif
-	} else {
-		value = bus_space_read_4(sc->sc_iot, sc->sc_obh, offset);
-	}
 
 	return value;
 }
@@ -363,18 +359,14 @@ static inline void
 xhci_op_write_8(const struct xhci_softc * const sc, bus_size_t offset,
 uint64_t value)
 {
-	if (XHCI_HCC_AC64(sc->sc_hcc)) {
 #ifdef XHCI_USE_BUS_SPACE_8
-		bus_space_write_8(sc->sc_iot, sc->sc_obh, offset, value);
+	bus_space_write_8(sc->sc_iot, sc->sc_obh, offset, value);
 #else
-		bus_space_write_4(sc->sc_iot, sc->sc_obh, offset + 0,
-		(value >> 0) & 0x);
-		bus_space_write_4(sc->sc_iot, sc->sc_obh, offset + 4,
-		(value >> 32) & 0x);
+	bus_space_write_4(sc->sc_iot, sc->sc_obh, offset + 0,
+	(value >> 0) & 0x);
+	bus_space_write_4(sc->sc_iot, sc->sc_obh, offset + 4,
+	(value >> 32) & 0x);
 #endif
-	} else {
-		bus_space_write_4(sc->sc_iot, sc->sc_obh, offset, value);
-	}
 }
 
 static inline uint32_t
@@ -395,17 +387,13 @@ xhci_rt_read_8(const struct xhci_softc *
 {
 	uint64_t value;
 
-	if (XHCI_HCC_AC64(sc->sc_hcc)) {
 #ifdef XHCI_USE_BUS_SPACE_8
-		value = bus_space_read_8(sc->sc_iot, sc->sc_rbh, offset);
+	value = bus_space_read_8(sc->sc_iot, sc->sc_rbh, offset);
 #else
-		value = bus_space_read_4(sc->sc_iot, sc->sc_rbh, offset);
-		value |= (uint64_t)bus_space_read_4(sc->sc_iot, sc->sc_rbh,
-		offset + 4) << 32;
+	value = bus_space_read_4(sc->sc_iot, sc->sc_rbh, offset);
+	value |= (uint64_t)bus_space_read_4(sc->sc_iot, sc->sc_rbh,
+	offset + 4) << 32;
 #endif
-	} else {
-		value = bus_space_read_4(sc->sc_iot, sc->sc_rbh, offset);
-	}
 
 	return value;
 }
@@ -414,18 +402,14 @@ static inline void
 xhci_rt_write_8(const struct xhci_softc * const sc, bus_size_t offset,
 uint64_t value)
 {
-	if (XHCI_HCC_AC64(sc->sc_hcc)) {
 #ifdef XHCI_USE_BUS_SPACE_8
-		bus_space_write_8(sc->sc_iot, sc->sc_rbh, offset, value);
+	bus_space_write_8(sc->sc_iot, sc->sc_rbh, offset, value);
 #else
-		bus_space_write_4(sc->sc_iot, sc->sc_rbh, offset + 0,
-		(value >> 0) & 0x);
-		bus_space_write_4(sc->sc_iot, sc->sc_rbh, offset + 4,
-		(value >> 32) & 0x);
+	bus_space_write_4(sc->sc_iot, sc->sc_rbh, offset + 0,
+	(value >> 0) & 0x);
+	bus_space_write_4(sc->sc_iot, sc->sc_rbh, offset + 4,
+	(value >> 32) & 0x);
 #endif
-	} else {
-		bus_space_write_4(sc->sc_iot, sc->sc_rbh, offset, value);
-	}
 }
 
 #if 0 /* unused */



CVS commit: src/sys/dev/usb

2021-10-23 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Oct 23 20:40:23 UTC 2021

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

Log Message:
xhci: Always read/write both halves of 64-bit registers

Access the 64-bit registers in their entirety at all times, independent
of the AC64 parameter of the hardware implementation.

Makes xhci(4) work on SolidRun MACCHIATObin (Marvell 8040 SoC)


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 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.



CVS commit: src/sys/dev/usb

2021-10-21 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Oct 21 20:57:06 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.788 -r1.789 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.788 src/sys/dev/usb/usbdevs.h:1.789
--- src/sys/dev/usb/usbdevs.h:1.788	Thu Oct 21 20:17:57 2021
+++ src/sys/dev/usb/usbdevs.h	Thu Oct 21 20:57:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdevs.h,v 1.788 2021/10/21 20:17:57 jnemeth Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.789 2021/10/21 20:57:06 jakllsch Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -3687,3 +3687,7 @@
 #define	USB_PRODUCT_ZYXEL_NWD6605	0x3426		/* ND6605 */
 #define	USB_PRODUCT_ZYXEL_RT3070	0x343e		/* RT3070 */
 #define	USB_PRODUCT_ZYXEL_PRESTIGE	0x401a		/* Prestige */
+
+/* Define format strings for non-existent values */
+#define usb_id1_format	"vendor %4.4x"
+#define usb_id2_format	"product %4.4x"
Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.788 src/sys/dev/usb/usbdevs_data.h:1.789
--- src/sys/dev/usb/usbdevs_data.h:1.788	Thu Oct 21 20:17:57 2021
+++ src/sys/dev/usb/usbdevs_data.h	Thu Oct 21 20:57:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdevs_data.h,v 1.788 2021/10/21 20:17:57 jnemeth Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.789 2021/10/21 20:57:06 jakllsch Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -37,7 +37,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-static const uint16_t usb_vendors[] = {
+static const uint32_t usb_vendors[] = {
 	USB_VENDOR_UNKNOWN1, 1, 9, 0,
 	USB_VENDOR_UNKNOWN2, 1, 9, 0,
 	USB_VENDOR_EGALAX2, 16, 24, 0,
@@ -601,7 +601,7 @@ static const uint16_t usb_vendors[] = {
 	USB_VENDOR_USRP, 4918, 3359, 4922, 0,
 };
 
-static const uint16_t usb_products[] = {
+static const uint32_t usb_products[] = {
 	USB_VENDOR_3COM, USB_PRODUCT_3COM_HOMECONN, 
 	4927, 4939, 3016, 0,
 	USB_VENDOR_3COM, USB_PRODUCT_3COM_3CREB96, 



CVS commit: src/sys/dev/usb

2021-10-21 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Oct 21 20:57:06 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.788 -r1.789 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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



CVS commit: src/sys/dev/usb

2021-10-21 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Thu Oct 21 20:18:16 UTC 2021

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

Log Message:
add Edimax N150 adapter; tested on my PBP


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/usb/if_urtwn.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/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.100 src/sys/dev/usb/if_urtwn.c:1.101
--- src/sys/dev/usb/if_urtwn.c:1.100	Fri Sep 17 13:02:52 2021
+++ src/sys/dev/usb/if_urtwn.c	Thu Oct 21 20:18:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.100 2021/09/17 13:02:52 nat Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.101 2021/10/21 20:18:16 jnemeth Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.100 2021/09/17 13:02:52 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.101 2021/10/21 20:18:16 jnemeth Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -213,6 +213,7 @@ static const struct urtwn_dev {
 	URTWN_RTL8188E_DEV(ABOCOM, RTL8188EU),
 	URTWN_RTL8188E_DEV(TPLINK, RTL8188EU),
 	URTWN_RTL8188E_DEV(DLINK, DWA121B1),
+	URTWN_RTL8188E_DEV(EDIMAX, EW7811UNV2),
 
 	/* URTWN_RTL8192EU */
 	URTWN_RTL8192EU_DEV(DLINK,	DWA131E),



CVS commit: src/sys/dev/usb

2021-10-21 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Thu Oct 21 20:18:16 UTC 2021

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

Log Message:
add Edimax N150 adapter; tested on my PBP


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/usb/if_urtwn.c

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



CVS commit: src/sys/dev/usb

2021-10-21 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Thu Oct 21 20:17:57 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.787 -r1.788 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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



CVS commit: src/sys/dev/usb

2021-10-21 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Thu Oct 21 20:16:51 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
add Edimax N150 adapter; tested on my PBP


To generate a diff of this commit:
cvs rdiff -u -r1.797 -r1.798 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.797 src/sys/dev/usb/usbdevs:1.798
--- src/sys/dev/usb/usbdevs:1.797	Sun Oct 17 20:40:03 2021
+++ src/sys/dev/usb/usbdevs	Thu Oct 21 20:16:51 2021
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.797 2021/10/17 20:40:03 andvar Exp $
+$NetBSD: usbdevs,v 1.798 2021/10/21 20:16:51 jnemeth Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1507,6 +1507,7 @@ product EDIMAX RTL8192CU	0x7822	RTL8192C
 product EDIMAX EW7811UTC_1	0xa811	EW-7811UTC
 product EDIMAX EW7811UTC_2	0xa812	EW-7811UTC
 product EDIMAX ELECOM_WDC433SU2M 0xb711	ELECOM WDC-433SU2M
+product EDIMAX EW7811UNV2	0xb811	EW-7811Un V2
 
 /* eGalax Products */
 product EGALAX TPANEL		0x0001	Touch Panel



CVS commit: src/sys/dev/usb

2021-10-21 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Thu Oct 21 20:16:51 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
add Edimax N150 adapter; tested on my PBP


To generate a diff of this commit:
cvs rdiff -u -r1.797 -r1.798 src/sys/dev/usb/usbdevs

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



CVS commit: src/sys/dev/usb

2021-10-17 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Oct 17 20:40:20 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.786 -r1.787 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.786 src/sys/dev/usb/usbdevs.h:1.787
--- src/sys/dev/usb/usbdevs.h:1.786	Sat Oct 16 05:39:32 2021
+++ src/sys/dev/usb/usbdevs.h	Sun Oct 17 20:40:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdevs.h,v 1.786 2021/10/16 05:39:32 mrg Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.787 2021/10/17 20:40:20 andvar Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -2334,7 +2334,7 @@
 #define	USB_PRODUCT_MICROCHIP_PICKIT1	0x0032		/* PICkit(TM) 1 FLASH Starter Kit */
 #define	USB_PRODUCT_MICROCHIP_PICKIT2	0x0033		/* PICkit 2 Microcontroller Programmer */
 
-/* Microdia / Sonix Techonology Co., Ltd. products */
+/* Microdia / Sonix Technology Co., Ltd. products */
 #define	USB_PRODUCT_MICRODIA_YUREX	0x1010		/* YUREX */
 
 /* Micronet Communications products */
Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.786 src/sys/dev/usb/usbdevs_data.h:1.787
--- src/sys/dev/usb/usbdevs_data.h:1.786	Sat Oct 16 05:39:32 2021
+++ src/sys/dev/usb/usbdevs_data.h	Sun Oct 17 20:40:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdevs_data.h,v 1.786 2021/10/16 05:39:32 mrg Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.787 2021/10/17 20:40:20 andvar Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.



CVS commit: src/sys/dev/usb

2021-10-17 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Oct 17 20:40:20 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.786 -r1.787 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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



CVS commit: src/sys/dev/usb

2021-10-17 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Oct 17 20:40:03 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
s/Techonology/Technology/


To generate a diff of this commit:
cvs rdiff -u -r1.796 -r1.797 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.796 src/sys/dev/usb/usbdevs:1.797
--- src/sys/dev/usb/usbdevs:1.796	Sat Oct 16 05:39:11 2021
+++ src/sys/dev/usb/usbdevs	Sun Oct 17 20:40:03 2021
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.796 2021/10/16 05:39:11 mrg Exp $
+$NetBSD: usbdevs,v 1.797 2021/10/17 20:40:03 andvar Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -2327,7 +2327,7 @@ product MSI BLUETOOTH_3		0xa97a	Bluetoot
 product MICROCHIP PICKIT1	0x0032	PICkit(TM) 1 FLASH Starter Kit
 product MICROCHIP PICKIT2	0x0033	PICkit 2 Microcontroller Programmer
 
-/* Microdia / Sonix Techonology Co., Ltd. products */
+/* Microdia / Sonix Technology Co., Ltd. products */
 product MICRODIA YUREX		0x1010	YUREX
 
 /* Micronet Communications products */



CVS commit: src/sys/dev/usb

2021-10-17 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Oct 17 20:40:03 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
s/Techonology/Technology/


To generate a diff of this commit:
cvs rdiff -u -r1.796 -r1.797 src/sys/dev/usb/usbdevs

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



CVS commit: src/sys/dev/usb

2021-10-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Oct 16 05:40:46 UTC 2021

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

Log Message:
apply always-open quirk for logitech B100 mouse.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/usb/usb_quirks.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/usb_quirks.c
diff -u src/sys/dev/usb/usb_quirks.c:1.99 src/sys/dev/usb/usb_quirks.c:1.100
--- src/sys/dev/usb/usb_quirks.c:1.99	Fri Oct  1 21:09:50 2021
+++ src/sys/dev/usb/usb_quirks.c	Sat Oct 16 05:40:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_quirks.c,v 1.99 2021/10/01 21:09:50 macallan Exp $	*/
+/*	$NetBSD: usb_quirks.c,v 1.100 2021/10/16 05:40:46 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.99 2021/10/01 21:09:50 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.100 2021/10/16 05:40:46 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -393,6 +393,8 @@ Static const struct usbd_quirk_entry {
 	{ UQ_ALWAYS_ON, NULL }},
  { USB_VENDOR_PIXART,		USB_PRODUCT_PIXART_RPIMOUSE,		ANY,
 	{ UQ_ALWAYS_ON, NULL }},
+ { USB_VENDOR_LOGITECH, 	USB_PRODUCT_LOGITECH_B100,		ANY,
+	{ UQ_ALWAYS_ON, NULL }},
 /*
  * The HAILUCK USB Keyboard has a built-in touchpad, which
  * needs to be active for the keyboard to function properly.



CVS commit: src/sys/dev/usb

2021-10-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Oct 16 05:40:46 UTC 2021

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

Log Message:
apply always-open quirk for logitech B100 mouse.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/usb/usb_quirks.c

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



CVS commit: src/sys/dev/usb

2021-10-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Oct 16 05:39:32 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen.


To generate a diff of this commit:
cvs rdiff -u -r1.785 -r1.786 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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



CVS commit: src/sys/dev/usb

2021-10-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Oct 16 05:39:11 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
add logitech B100 mouse


To generate a diff of this commit:
cvs rdiff -u -r1.795 -r1.796 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.795 src/sys/dev/usb/usbdevs:1.796
--- src/sys/dev/usb/usbdevs:1.795	Fri Oct  1 21:01:34 2021
+++ src/sys/dev/usb/usbdevs	Sat Oct 16 05:39:11 2021
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.795 2021/10/01 21:01:34 macallan Exp $
+$NetBSD: usbdevs,v 1.796 2021/10/16 05:39:11 mrg Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -2190,6 +2190,7 @@ product LOGITECH BD58		0xc00c	BD58 mouse
 product LOGITECH USBPS2MOUSE	0xc00e	USB-PS/2 Optical Mouse
 product LOGITECH MUV55A		0xc016	M-UV55a
 product LOGITECH UN58A		0xc030	iFeel Mouse
+product LOGITECH B100		0xc077	B100 Optical Mouse
 product LOGITECH WMPAD		0xc208	WingMan GamePad Extreme
 product LOGITECH WMRPAD		0xc20a	WingMan RumblePad
 product LOGITECH WMJOY		0xc281	WingMan Force joystick



CVS commit: src/sys/dev/usb

2021-10-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Oct 16 05:39:11 UTC 2021

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
add logitech B100 mouse


To generate a diff of this commit:
cvs rdiff -u -r1.795 -r1.796 src/sys/dev/usb/usbdevs

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



CVS commit: src/sys/dev/usb

2021-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 15 11:59:17 UTC 2021

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

Log Message:
Revert "usb: uhub: remove unnecessary delays when powering on ports"

syzbot says that the change exposes UB in usb_free_device and I can't
see how, so revert until I have a better understanding of what's going on.

Reported-by: syzbot+c445f7149cce07d4c...@syzkaller.appspotmail.com
Reported-by: syzbot+a2ae42f37de765a54...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/dev/usb/uhub.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/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.157 src/sys/dev/usb/uhub.c:1.158
--- src/sys/dev/usb/uhub.c:1.157	Mon Oct 11 06:30:23 2021
+++ src/sys/dev/usb/uhub.c	Fri Oct 15 11:59:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.157 2021/10/11 06:30:23 msaitoh Exp $	*/
+/*	$NetBSD: uhub.c,v 1.158 2021/10/15 11:59:16 jmcneill Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 /*	$OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.157 2021/10/11 06:30:23 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.158 2021/10/15 11:59:16 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.1
 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -125,8 +124,6 @@ struct uhub_softc {
 	struct lwp		*sc_exploring;
 };
 
-typedef __BITMAP_TYPE(, uint8_t, UHD_NPORTS_MAX + 1) usb_port_mask;
-
 #define UHUB_IS_HIGH_SPEED(sc) \
 ((sc)->sc_proto == UDPROTO_HSHUBSTT || (sc)->sc_proto == UDPROTO_HSHUBMTT)
 #define UHUB_IS_SINGLE_TT(sc) ((sc)->sc_proto == UDPROTO_HSHUBSTT)
@@ -498,8 +495,6 @@ uhub_explore(struct usbd_device *dev)
 	int speed;
 	int port;
 	int change, status, reconnect, rescan;
-	usb_port_mask powerup_port;
-	int powerup_port_count = 0;
 
 	UHUBHIST_FUNC();
 	UHUBHIST_CALLARGS("uhub%jd dev=%#jx addr=%jd speed=%ju",
@@ -552,8 +547,6 @@ uhub_explore(struct usbd_device *dev)
 		}
 	}
 
-	__BITMAP_ZERO(_port);
-
 	for (port = 1; port <= hd->bNbrPorts; port++) {
 		up = >ud_hub->uh_ports[port - 1];
 
@@ -684,26 +677,8 @@ uhub_explore(struct usbd_device *dev)
 		DPRINTF("unit %jd dev->speed=%ju dev->depth=%ju",
 		device_unit(sc->sc_dev), dev->ud_speed, dev->ud_depth, 0);
 
-		__BITMAP_SET(port, _port);
-		powerup_port_count++;
-	}
-
-	if (powerup_port_count == 0) {
-		goto explore;
-	}
-
-	aprint_debug_dev(sc->sc_dev, "power up %u port(s)\n",
-	powerup_port_count);
-
-	/* Wait for maximum device power up time. */
-	usbd_delay_ms(dev, USB_PORT_POWERUP_DELAY);
-
-	for (port = 1; port <= hd->bNbrPorts; port++) {
-		if (!__BITMAP_ISSET(port, _port)) {
-			continue;
-		}
-
-		up = >ud_hub->uh_ports[port - 1];
+		/* Wait for maximum device power up time. */
+		usbd_delay_ms(dev, USB_PORT_POWERUP_DELAY);
 
 		/* Reset port, which implies enabling it. */
 		if (usbd_reset_port(dev, port, >up_status)) {
@@ -841,8 +816,6 @@ uhub_explore(struct usbd_device *dev)
 up->up_dev->ud_hub->uh_explore(up->up_dev);
 		}
 	}
-
-explore:
 	mutex_enter(>sc_lock);
 	sc->sc_explorepending = false;
 	for (int i = 0; i < sc->sc_statuslen; i++) {



CVS commit: src/sys/dev/usb

2021-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 15 11:59:17 UTC 2021

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

Log Message:
Revert "usb: uhub: remove unnecessary delays when powering on ports"

syzbot says that the change exposes UB in usb_free_device and I can't
see how, so revert until I have a better understanding of what's going on.

Reported-by: syzbot+c445f7149cce07d4c...@syzkaller.appspotmail.com
Reported-by: syzbot+a2ae42f37de765a54...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/dev/usb/uhub.c

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



CVS commit: src/sys/dev/usb

2021-10-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 11 06:30:24 UTC 2021

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

Log Message:
Add missing inclusion of sys/bitops.h.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/dev/usb/uhub.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/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.156 src/sys/dev/usb/uhub.c:1.157
--- src/sys/dev/usb/uhub.c:1.156	Mon Oct 11 00:16:08 2021
+++ src/sys/dev/usb/uhub.c	Mon Oct 11 06:30:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.156 2021/10/11 00:16:08 jmcneill Exp $	*/
+/*	$NetBSD: uhub.c,v 1.157 2021/10/11 06:30:23 msaitoh Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 /*	$OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.156 2021/10/11 00:16:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.157 2021/10/11 06:30:23 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.1
 
 #include 
 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/dev/usb

2021-10-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 11 06:30:24 UTC 2021

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

Log Message:
Add missing inclusion of sys/bitops.h.


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

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



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:25:05 UTC 2021

Modified Files:
src/sys/dev/usb: usb.h

Log Message:
Update USB_PORT_RESET_RECOVERT to comply with the USB 2.0 specification
which says it should be max 10 milliseconds.

>From FreeBSD: 
>https://github.com/freebsd/freebsd-src/commit/70ffaaa69c830d26b59136d0b0447ab2f8683db8


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/usb/usb.h

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

Modified files:

Index: src/sys/dev/usb/usb.h
diff -u src/sys/dev/usb/usb.h:1.118 src/sys/dev/usb/usb.h:1.119
--- src/sys/dev/usb/usb.h:1.118	Fri Aug 23 07:17:31 2019
+++ src/sys/dev/usb/usb.h	Mon Oct 11 00:25:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.h,v 1.118 2019/08/23 07:17:31 mrg Exp $	*/
+/*	$NetBSD: usb.h,v 1.119 2021/10/11 00:25:05 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -771,7 +771,7 @@ typedef struct {
 /* Allow for marginal (i.e. non-conforming) devices. */
 #define USB_PORT_RESET_DELAY	50  /* ms */
 #define USB_PORT_ROOT_RESET_DELAY 250  /* ms */
-#define USB_PORT_RESET_RECOVERY	250  /* ms */
+#define USB_PORT_RESET_RECOVERY	10  /* ms */
 #define USB_PORT_POWERUP_DELAY	300 /* ms */
 #define USB_SET_ADDRESS_SETTLE	10  /* ms */
 #define USB_RESUME_DELAY	(50*5)  /* ms */



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:25:05 UTC 2021

Modified Files:
src/sys/dev/usb: usb.h

Log Message:
Update USB_PORT_RESET_RECOVERT to comply with the USB 2.0 specification
which says it should be max 10 milliseconds.

>From FreeBSD: 
>https://github.com/freebsd/freebsd-src/commit/70ffaaa69c830d26b59136d0b0447ab2f8683db8


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/usb/usb.h

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



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:16:08 UTC 2021

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

Log Message:
uhub: Skip USB_POWER_DOWN_TIME delay for root hubs


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/dev/usb/uhub.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/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.155 src/sys/dev/usb/uhub.c:1.156
--- src/sys/dev/usb/uhub.c:1.155	Mon Oct 11 00:08:31 2021
+++ src/sys/dev/usb/uhub.c	Mon Oct 11 00:16:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.155 2021/10/11 00:08:31 jmcneill Exp $	*/
+/*	$NetBSD: uhub.c,v 1.156 2021/10/11 00:16:08 jmcneill Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 /*	$OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.155 2021/10/11 00:08:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.156 2021/10/11 00:16:08 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -388,8 +388,9 @@ uhub_attach(device_t parent, device_t se
 		goto bad;
 	}
 
-	/* Wait with power off for a while. */
-	usbd_delay_ms(dev, USB_POWER_DOWN_TIME);
+	/* Wait with power off for a while if we are not a root hub */
+	if (dev->ud_powersrc->up_parent != NULL)
+		usbd_delay_ms(dev, USB_POWER_DOWN_TIME);
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, dev, sc->sc_dev);
 



CVS commit: src/sys/dev/usb

2021-10-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 11 00:16:08 UTC 2021

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

Log Message:
uhub: Skip USB_POWER_DOWN_TIME delay for root hubs


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

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



  1   2   3   4   5   6   7   8   >