CVS commit: [netbsd-8] src/sys/dev/usb

2024-03-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar 12 12:36:17 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-8]: usbdi.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1940):

sys/dev/usb/usbdi.c: revision 1.248

usbdi(9): Avoid calling ubm_softint with lock held and polling on.

PR kern/57783


To generate a diff of this commit:
cvs rdiff -u -r1.173.2.5 -r1.173.2.6 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.173.2.5 src/sys/dev/usb/usbdi.c:1.173.2.6
--- src/sys/dev/usb/usbdi.c:1.173.2.5	Fri Jan 11 15:52:24 2019
+++ src/sys/dev/usb/usbdi.c	Tue Mar 12 12:36:17 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.173.2.5 2019/01/11 15:52:24 martin Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.173.2.6 2024/03/12 12:36:17 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.173.2.5 2019/01/11 15:52:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.173.2.6 2024/03/12 12:36:17 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1169,14 +1169,34 @@ usbd_dopoll(struct usbd_interface *iface
 void
 usbd_set_polling(struct usbd_device *dev, int on)
 {
-	if (on)
-		dev->ud_bus->ub_usepolling++;
-	else
-		dev->ud_bus->ub_usepolling--;
 
-	/* Kick the host controller when switching modes */
 	mutex_enter(dev->ud_bus->ub_lock);
-	dev->ud_bus->ub_methods->ubm_softint(dev->ud_bus);
+	if (on) {
+		/*
+		 * Enabling polling.  If we're enabling for the first
+		 * time, call the softint routine on transition while
+		 * we hold the lock and polling is still disabled, and
+		 * then enable polling -- once polling is enabled, we
+		 * must not hold the lock when we call the softint
+		 * routine.
+		 */
+		KASSERT(dev->ud_bus->ub_usepolling < __type_max(char));
+		if (dev->ud_bus->ub_usepolling == 0)
+			dev->ud_bus->ub_methods->ubm_softint(dev->ud_bus);
+		dev->ud_bus->ub_usepolling++;
+	} else {
+		/*
+		 * Disabling polling.  If we're disabling polling for
+		 * the last time, disable polling first and then call
+		 * the softint routine while we hold the lock -- until
+		 * polling is disabled, we must not hold the lock when
+		 * we call the softint routine.
+		 */
+		KASSERT(dev->ud_bus->ub_usepolling > 0);
+		dev->ud_bus->ub_usepolling--;
+		if (dev->ud_bus->ub_usepolling == 0)
+			dev->ud_bus->ub_methods->ubm_softint(dev->ud_bus);
+	}
 	mutex_exit(dev->ud_bus->ub_lock);
 }
 



CVS commit: [netbsd-8] src/sys/dev/usb

2024-03-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar 12 12:36:17 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-8]: usbdi.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1940):

sys/dev/usb/usbdi.c: revision 1.248

usbdi(9): Avoid calling ubm_softint with lock held and polling on.

PR kern/57783


To generate a diff of this commit:
cvs rdiff -u -r1.173.2.5 -r1.173.2.6 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: [netbsd-8] src/sys/dev/usb

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:00:27 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-8]: if_urtwn.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1942):

sys/dev/usb/if_urtwn.c: revision 1.109 (patch)

urtwn(4): Ditch old queued commands on overflow.
Don't increment ring->queued past what the task will decrement.

This is a stop-gap measure; really, we should just have one task for
each operation that is deferred to the task thread.

PR kern/57965


To generate a diff of this commit:
cvs rdiff -u -r1.53.2.6 -r1.53.2.7 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.53.2.6 src/sys/dev/usb/if_urtwn.c:1.53.2.7
--- src/sys/dev/usb/if_urtwn.c:1.53.2.6	Sat Dec 14 12:33:47 2019
+++ src/sys/dev/usb/if_urtwn.c	Sun Mar 10 19:00:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.53.2.6 2019/12/14 12:33:47 martin Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.53.2.7 2024/03/10 19:00:27 martin 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.53.2.6 2019/12/14 12:33:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.53.2.7 2024/03/10 19:00:27 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -808,6 +808,24 @@ urtwn_free_tx_list(struct urtwn_softc *s
 }
 
 static void
+urtwn_cmdq_invariants(struct urtwn_softc *sc)
+{
+	struct urtwn_host_cmd_ring *const ring __diagused = >cmdq;
+
+	KASSERT(mutex_owned(>sc_task_mtx));
+	KASSERTMSG((ring->cur >= 0 && ring->cur < URTWN_HOST_CMD_RING_COUNT),
+	"%s: cur=%d next=%d queued=%d",
+	device_xname(sc->sc_dev), ring->cur, ring->next, ring->queued);
+	KASSERTMSG((ring->next >= 0 && ring->next < URTWN_HOST_CMD_RING_COUNT),
+	"%s: cur=%d next=%d queued=%d",
+	device_xname(sc->sc_dev), ring->cur, ring->next, ring->queued);
+	KASSERTMSG((ring->queued >= 0 &&
+		ring->queued <= URTWN_HOST_CMD_RING_COUNT),
+	"%s: %d commands queued",
+	device_xname(sc->sc_dev), ring->queued);
+}
+
+static void
 urtwn_task(void *arg)
 {
 	struct urtwn_softc *sc = arg;
@@ -820,7 +838,11 @@ urtwn_task(void *arg)
 	/* Process host commands. */
 	s = splusb();
 	mutex_spin_enter(>sc_task_mtx);
+	urtwn_cmdq_invariants(sc);
 	while (ring->next != ring->cur) {
+		KASSERTMSG(ring->queued > 0, "%s: cur=%d next=%d queued=%d",
+		device_xname(sc->sc_dev),
+		ring->cur, ring->next, ring->queued);
 		cmd = >cmd[ring->next];
 		mutex_spin_exit(>sc_task_mtx);
 		splx(s);
@@ -828,6 +850,10 @@ urtwn_task(void *arg)
 		cmd->cb(sc, cmd->data);
 		s = splusb();
 		mutex_spin_enter(>sc_task_mtx);
+		urtwn_cmdq_invariants(sc);
+		KASSERTMSG(ring->queued > 0, "%s: cur=%d next=%d queued=%d",
+		device_xname(sc->sc_dev),
+		ring->cur, ring->next, ring->queued);
 		ring->queued--;
 		ring->next = (ring->next + 1) % URTWN_HOST_CMD_RING_COUNT;
 	}
@@ -842,6 +868,7 @@ urtwn_do_async(struct urtwn_softc *sc, v
 {
 	struct urtwn_host_cmd_ring *ring = >cmdq;
 	struct urtwn_host_cmd *cmd;
+	bool schedtask = false;
 	int s;
 
 	DPRINTFN(DBG_FN, ("%s: %s: cb=%p, arg=%p, len=%d\n",
@@ -849,19 +876,27 @@ urtwn_do_async(struct urtwn_softc *sc, v
 
 	s = splusb();
 	mutex_spin_enter(>sc_task_mtx);
+	urtwn_cmdq_invariants(sc);
 	cmd = >cmd[ring->cur];
 	cmd->cb = cb;
 	KASSERT(len <= sizeof(cmd->data));
 	memcpy(cmd->data, arg, len);
 	ring->cur = (ring->cur + 1) % URTWN_HOST_CMD_RING_COUNT;
 
-	/* If there is no pending command already, schedule a task. */
-	if (!sc->sc_dying && ++ring->queued == 1) {
-		mutex_spin_exit(>sc_task_mtx);
-		usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER);
-	} else
-		mutex_spin_exit(>sc_task_mtx);
+	/*
+	 * Schedule a task to process the command if need be.
+	 */
+	if (!sc->sc_dying) {
+		if (ring->queued == URTWN_HOST_CMD_RING_COUNT)
+			device_printf(sc->sc_dev, "command queue overflow\n");
+		else if (ring->queued++ == 0)
+			schedtask = true;
+	}
+	mutex_spin_exit(>sc_task_mtx);
 	splx(s);
+
+	if (schedtask)
+		usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER);
 }
 
 static void



CVS commit: [netbsd-8] src/sys/dev/usb

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:00:27 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-8]: if_urtwn.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1942):

sys/dev/usb/if_urtwn.c: revision 1.109 (patch)

urtwn(4): Ditch old queued commands on overflow.
Don't increment ring->queued past what the task will decrement.

This is a stop-gap measure; really, we should just have one task for
each operation that is deferred to the task thread.

PR kern/57965


To generate a diff of this commit:
cvs rdiff -u -r1.53.2.6 -r1.53.2.7 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: [netbsd-8] src/sys/dev/usb

2023-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  2 10:24:17 UTC 2023

Modified Files:
src/sys/dev/usb [netbsd-8]: ehci.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1877):

sys/dev/usb/ehci.c: revision 1.317

PR 57518: usb keyboard causes host controller to miss microframe

As per the USB 2.0 specification section 11.18.4; paragraph 3.b
For interrupt IN/OUT full-/low-speed transactions, the host must  schedule a
complete-split transaction in each of the two microframes following the
first microframe in which the full-/low-speed transaction is budgeted. An
additional complete-split must also be scheduled in the third following
microframe unless the full-/low-speed transaction was budgeted to start
in microframe Y6.


To generate a diff of this commit:
cvs rdiff -u -r1.254.8.7 -r1.254.8.8 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: [netbsd-8] src/sys/dev/usb

2023-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  2 10:24:17 UTC 2023

Modified Files:
src/sys/dev/usb [netbsd-8]: ehci.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1877):

sys/dev/usb/ehci.c: revision 1.317

PR 57518: usb keyboard causes host controller to miss microframe

As per the USB 2.0 specification section 11.18.4; paragraph 3.b
For interrupt IN/OUT full-/low-speed transactions, the host must  schedule a
complete-split transaction in each of the two microframes following the
first microframe in which the full-/low-speed transaction is budgeted. An
additional complete-split must also be scheduled in the third following
microframe unless the full-/low-speed transaction was budgeted to start
in microframe Y6.


To generate a diff of this commit:
cvs rdiff -u -r1.254.8.7 -r1.254.8.8 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.254.8.7 src/sys/dev/usb/ehci.c:1.254.8.8
--- src/sys/dev/usb/ehci.c:1.254.8.7	Tue Feb 25 18:52:44 2020
+++ src/sys/dev/usb/ehci.c	Wed Aug  2 10:24:16 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.254.8.7 2020/02/25 18:52:44 martin Exp $ */
+/*	$NetBSD: ehci.c,v 1.254.8.8 2023/08/02 10:24:16 martin Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.254.8.7 2020/02/25 18:52:44 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.254.8.8 2023/08/02 10:24:16 martin Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -1989,14 +1989,17 @@ ehci_open(struct usbd_pipe *pipe)
 		);
 		sqh->qh.qh_endphub = htole32(
 		EHCI_QH_SET_MULT(1) |
-		EHCI_QH_SET_SMASK(xfertype == UE_INTERRUPT ? 0x02 : 0)
+		(xfertype == UE_INTERRUPT ?
+			EHCI_QH_SET_SMASK(__BIT(1))	   /* Start Split Y1 */
+			: 0)
 		);
 		if (speed != EHCI_QH_SPEED_HIGH)
 			sqh->qh.qh_endphub |= htole32(
 			EHCI_QH_SET_PORT(hshubport) |
 			EHCI_QH_SET_HUBA(hshubaddr) |
 			(xfertype == UE_INTERRUPT ?
- EHCI_QH_SET_CMASK(0x08) : 0)
+ EHCI_QH_SET_CMASK(__BITS(3,5)) /* CS Y[345] */
+ : 0)
 			);
 		sqh->qh.qh_curqtd = EHCI_NULL;
 		/* Fill the overlay qTD */



CVS commit: [netbsd-8] src/sys/dev/usb

2023-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug  1 13:48:15 UTC 2023

Modified Files:
src/sys/dev/usb [netbsd-8]: xhci.c xhcivar.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1869):

sys/dev/usb/xhci.c: revision 1.176
sys/dev/usb/xhcivar.h: revision 1.23

xhci(4): Defer root intr xfers while polling.

Root intr xfers require taking adaptive locks, which is forbidden
while polling.

This is not great -- any USB transfer completion callbacks might try
to take adaptive locks, not just uhub_intr, and that will always
causes trouble.  We get lucky with ukbd_intr because it's not
MP-safe, so it relies only on the kernel lock (a spin lock) anyway.
But this change brings xhci in line with ehci.

PR kern/57326


To generate a diff of this commit:
cvs rdiff -u -r1.72.2.14 -r1.72.2.15 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.7.6.2 -r1.7.6.3 src/sys/dev/usb/xhcivar.h

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

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.72.2.14 src/sys/dev/usb/xhci.c:1.72.2.15
--- src/sys/dev/usb/xhci.c:1.72.2.14	Mon Jan 23 12:10:12 2023
+++ src/sys/dev/usb/xhci.c	Tue Aug  1 13:48:15 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.72.2.14 2023/01/23 12:10:12 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.72.2.15 2023/08/01 13:48:15 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.72.2.14 2023/01/23 12:10:12 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.72.2.15 2023/08/01 13:48:15 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1893,11 +1893,15 @@ xhci_rhpsc(struct xhci_softc * const sc,
 		return;
 
 	uint8_t *p = xfer->ux_buf;
-	memset(p, 0, xfer->ux_length);
+	if (!xhci_polling_p(sc) || !sc->sc_intrxfer_deferred[bn])
+		memset(p, 0, xfer->ux_length);
 	p[rhp / NBBY] |= 1 << (rhp % NBBY);
 	xfer->ux_actlen = xfer->ux_length;
 	xfer->ux_status = USBD_NORMAL_COMPLETION;
-	usb_transfer_complete(xfer);
+	if (xhci_polling_p(sc))
+		sc->sc_intrxfer_deferred[bn] = true;
+	else
+		usb_transfer_complete(xfer);
 }
 
 /* Process Transfer Events */
@@ -2199,7 +2203,7 @@ xhci_softintr(void *v)
 	struct xhci_softc * const sc = XHCI_BUS2SC(bus);
 	struct xhci_ring * const er = >sc_er;
 	struct xhci_trb *trb;
-	int i, j, k;
+	int i, j, k, bn;
 
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
 
@@ -2210,6 +2214,20 @@ xhci_softintr(void *v)
 
 	DPRINTFN(16, "er: xr_ep %jd xr_cs %jd", i, j, 0, 0);
 
+	/*
+	 * Handle deferred root intr xfer, in case we just switched off
+	 * polling.  It's not safe to complete root intr xfers while
+	 * polling -- too much kernel machinery gets involved.
+	 */
+	if (!xhci_polling_p(sc)) {
+		for (bn = 0; bn < 2; bn++) {
+			if (__predict_false(sc->sc_intrxfer_deferred[bn])) {
+sc->sc_intrxfer_deferred[bn] = false;
+usb_transfer_complete(sc->sc_intrxfer[bn]);
+			}
+		}
+	}
+
 	while (1) {
 		usb_syncmem(>xr_dma, XHCI_TRB_SIZE * i, XHCI_TRB_SIZE,
 		BUS_DMASYNC_POSTREAD);

Index: src/sys/dev/usb/xhcivar.h
diff -u src/sys/dev/usb/xhcivar.h:1.7.6.2 src/sys/dev/usb/xhcivar.h:1.7.6.3
--- src/sys/dev/usb/xhcivar.h:1.7.6.2	Mon Jan 23 12:10:12 2023
+++ src/sys/dev/usb/xhcivar.h	Tue Aug  1 13:48:15 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhcivar.h,v 1.7.6.2 2023/01/23 12:10:12 martin Exp $	*/
+/*	$NetBSD: xhcivar.h,v 1.7.6.3 2023/08/01 13:48:15 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -109,7 +109,7 @@ struct xhci_softc {
 	int *sc_rhportmap[2];
 	int sc_rhportcount[2];
 	struct usbd_xfer *sc_intrxfer[2];
-
+	bool sc_intrxfer_deferred[2];
 
 	struct xhci_slot * sc_slots;
 



CVS commit: [netbsd-8] src/sys/dev/usb

2023-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug  1 13:48:15 UTC 2023

Modified Files:
src/sys/dev/usb [netbsd-8]: xhci.c xhcivar.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1869):

sys/dev/usb/xhci.c: revision 1.176
sys/dev/usb/xhcivar.h: revision 1.23

xhci(4): Defer root intr xfers while polling.

Root intr xfers require taking adaptive locks, which is forbidden
while polling.

This is not great -- any USB transfer completion callbacks might try
to take adaptive locks, not just uhub_intr, and that will always
causes trouble.  We get lucky with ukbd_intr because it's not
MP-safe, so it relies only on the kernel lock (a spin lock) anyway.
But this change brings xhci in line with ehci.

PR kern/57326


To generate a diff of this commit:
cvs rdiff -u -r1.72.2.14 -r1.72.2.15 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.7.6.2 -r1.7.6.3 src/sys/dev/usb/xhcivar.h

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



CVS commit: [netbsd-8] src/sys/dev/usb

2023-01-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 19 10:57:50 UTC 2023

Modified Files:
src/sys/dev/usb [netbsd-8]: usb.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1786):

sys/dev/usb/usb.h: revision 1.121

Cast to uint32_t to avoid undefined behavior in UGETDW(). Found by kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.115.6.1 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: [netbsd-8] src/sys/dev/usb

2023-01-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 19 10:57:50 UTC 2023

Modified Files:
src/sys/dev/usb [netbsd-8]: usb.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1786):

sys/dev/usb/usb.h: revision 1.121

Cast to uint32_t to avoid undefined behavior in UGETDW(). Found by kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.115.6.1 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.115 src/sys/dev/usb/usb.h:1.115.6.1
--- src/sys/dev/usb/usb.h:1.115	Thu Jan 19 16:05:00 2017
+++ src/sys/dev/usb/usb.h	Thu Jan 19 10:57:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.h,v 1.115 2017/01/19 16:05:00 skrll Exp $	*/
+/*	$NetBSD: usb.h,v 1.115.6.1 2023/01/19 10:57:50 martin Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -78,7 +78,8 @@ typedef uint8_t uDWord[4];
 #define UGETW(w) ((w)[0] | ((w)[1] << 8))
 #define USETW(w,v) ((w)[0] = (uint8_t)(v), (w)[1] = (uint8_t)((v) >> 8))
 #define USETWD(val) { (uint8_t)(val), (uint8_t)((val) >> 8) }
-#define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | ((w)[3] << 24))
+#define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) |	\
+	((uint32_t)(w)[3] << 24))
 #define USETDW(w,v) ((w)[0] = (uint8_t)(v), \
 		 (w)[1] = (uint8_t)((v) >> 8), \
 		 (w)[2] = (uint8_t)((v) >> 16), \



CVS commit: [netbsd-8] src/sys/dev/usb

2022-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 16 18:34:20 UTC 2022

Modified Files:
src/sys/dev/usb [netbsd-8]: xhci.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1765):

sys/dev/usb/xhci.c: revision 1.154

Accept USB 3.2 in xhci_id_protocols().


To generate a diff of this commit:
cvs rdiff -u -r1.72.2.12 -r1.72.2.13 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.72.2.12 src/sys/dev/usb/xhci.c:1.72.2.13
--- src/sys/dev/usb/xhci.c:1.72.2.12	Sat Nov 16 16:30:09 2019
+++ src/sys/dev/usb/xhci.c	Fri Sep 16 18:34:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.72.2.12 2019/11/16 16:30:09 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.72.2.13 2022/09/16 18:34:20 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.72.2.12 2019/11/16 16:30:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.72.2.13 2022/09/16 18:34:20 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -781,6 +781,7 @@ xhci_id_protocols(struct xhci_softc *sc,
 	case 0x0300:
 	case 0x0301:
 	case 0x0310:
+	case 0x0320:
 		aprint_debug_dev(sc->sc_dev, " %s ports %d - %d\n",
 		major == 3 ? "ss" : "hs", cpo, cpo + cpc -1);
 		break;



CVS commit: [netbsd-8] src/sys/dev/usb

2022-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 16 18:34:20 UTC 2022

Modified Files:
src/sys/dev/usb [netbsd-8]: xhci.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1765):

sys/dev/usb/xhci.c: revision 1.154

Accept USB 3.2 in xhci_id_protocols().


To generate a diff of this commit:
cvs rdiff -u -r1.72.2.12 -r1.72.2.13 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: [netbsd-8] src/sys/dev/usb

2022-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug  1 09:38:02 UTC 2022

Modified Files:
src/sys/dev/usb [netbsd-8]: uslsa.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #1753):

sys/dev/usb/uslsa.c: revision 1.32

PR kern/56946
Baud rate must be in little endian for SLSA_R_SET_BAUDRATE request.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.23.8.1 src/sys/dev/usb/uslsa.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/uslsa.c
diff -u src/sys/dev/usb/uslsa.c:1.23 src/sys/dev/usb/uslsa.c:1.23.8.1
--- src/sys/dev/usb/uslsa.c:1.23	Fri Dec 16 14:56:34 2016
+++ src/sys/dev/usb/uslsa.c	Mon Aug  1 09:38:02 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: uslsa.c,v 1.23 2016/12/16 14:56:34 maya Exp $ */
+/* $NetBSD: uslsa.c,v 1.23.8.1 2022/08/01 09:38:02 martin Exp $ */
 
 /* from ugensa.c */
 
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uslsa.c,v 1.23 2016/12/16 14:56:34 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uslsa.c,v 1.23.8.1 2022/08/01 09:38:02 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -411,7 +411,7 @@ uslsa_param(void *vsc, int portno, struc
 	USETW(req.wIndex, sc->sc_ifnum);
 	USETW(req.wLength, 4);
 
-	baud = t->c_ospeed;
+	baud = htole32(t->c_ospeed);
 	status = usbd_do_request(sc->sc_udev, , );
 	if (status != USBD_NORMAL_COMPLETION) {
 		/* fallback method for devices that don't know SET_BAUDRATE */



CVS commit: [netbsd-8] src/sys/dev/usb

2022-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug  1 09:38:02 UTC 2022

Modified Files:
src/sys/dev/usb [netbsd-8]: uslsa.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #1753):

sys/dev/usb/uslsa.c: revision 1.32

PR kern/56946
Baud rate must be in little endian for SLSA_R_SET_BAUDRATE request.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.23.8.1 src/sys/dev/usb/uslsa.c

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



CVS commit: [netbsd-8] src/sys/dev/usb

2019-09-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep 17 18:53:52 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: xhci.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1377):

sys/dev/usb/xhci.c: revision 1.113
sys/dev/usb/xhci.c: revision 1.109

match xhci version 3.10.  allows properly finding all the USB
busses on new ryzen 3 based systems.

unfortunately, the USB busses are still non-functional.

 -

fix ryzen usb issue: we set TD size to '1', where has xhci spec 4.11.2.4
says final TRB for a TD should have this set to '0'.  since we currently
only generate sinel TRB TDs, set this to 0.

XXX: pullup-all
from sc.dying


To generate a diff of this commit:
cvs rdiff -u -r1.72.2.10 -r1.72.2.11 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.72.2.10 src/sys/dev/usb/xhci.c:1.72.2.11
--- src/sys/dev/usb/xhci.c:1.72.2.10	Fri Jan  4 14:55:40 2019
+++ src/sys/dev/usb/xhci.c	Tue Sep 17 18:53:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.72.2.10 2019/01/04 14:55:40 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.72.2.11 2019/09/17 18:53:52 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.72.2.10 2019/01/04 14:55:40 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.72.2.11 2019/09/17 18:53:52 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -755,6 +755,8 @@ hexdump(const char *msg, const void *bas
 static void
 xhci_id_protocols(struct xhci_softc *sc, bus_size_t ecp)
 {
+	XHCIHIST_FUNC(); XHCIHIST_CALLED();
+
 	/* XXX Cache this lot */
 
 	const uint32_t w0 = xhci_read_4(sc, ecp);
@@ -778,6 +780,7 @@ xhci_id_protocols(struct xhci_softc *sc,
 	case 0x0200:
 	case 0x0300:
 	case 0x0301:
+	case 0x0310:
 		aprint_debug_dev(sc->sc_dev, " %s ports %d - %d\n",
 		major == 3 ? "ss" : "hs", cpo, cpo + cpc -1);
 		break;
@@ -3832,7 +3835,7 @@ xhci_device_ctrl_start(struct usbd_xfer 
 		parameter = DMAADDR(dma, 0);
 		KASSERTMSG(len <= 0x1, "len %d", len);
 		status = XHCI_TRB_2_IRQ_SET(0) |
-		XHCI_TRB_2_TDSZ_SET(1) |
+		XHCI_TRB_2_TDSZ_SET(0) |
 		XHCI_TRB_2_BYTES_SET(len);
 		control = (isread ? XHCI_TRB_3_DIR_IN : 0) |
 		XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_DATA_STAGE) |
@@ -3963,7 +3966,7 @@ xhci_device_bulk_start(struct usbd_xfer 
 	 */
 	KASSERTMSG(len <= 0x1, "len %d", len);
 	status = XHCI_TRB_2_IRQ_SET(0) |
-	XHCI_TRB_2_TDSZ_SET(1) |
+	XHCI_TRB_2_TDSZ_SET(0) |
 	XHCI_TRB_2_BYTES_SET(len);
 	control = XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_NORMAL) |
 	(usbd_xfer_isread(xfer) ? XHCI_TRB_3_ISP_BIT : 0) |
@@ -4075,7 +4078,7 @@ xhci_device_intr_start(struct usbd_xfer 
 	parameter = DMAADDR(dma, 0);
 	KASSERTMSG(len <= 0x1, "len %d", len);
 	status = XHCI_TRB_2_IRQ_SET(0) |
-	XHCI_TRB_2_TDSZ_SET(1) |
+	XHCI_TRB_2_TDSZ_SET(0) |
 	XHCI_TRB_2_BYTES_SET(len);
 	control = XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_NORMAL) |
 	(usbd_xfer_isread(xfer) ? XHCI_TRB_3_ISP_BIT : 0) |



CVS commit: [netbsd-8] src/sys/dev/usb

2019-09-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep 17 18:53:52 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: xhci.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1377):

sys/dev/usb/xhci.c: revision 1.113
sys/dev/usb/xhci.c: revision 1.109

match xhci version 3.10.  allows properly finding all the USB
busses on new ryzen 3 based systems.

unfortunately, the USB busses are still non-functional.

 -

fix ryzen usb issue: we set TD size to '1', where has xhci spec 4.11.2.4
says final TRB for a TD should have this set to '0'.  since we currently
only generate sinel TRB TDs, set this to 0.

XXX: pullup-all
from sc.dying


To generate a diff of this commit:
cvs rdiff -u -r1.72.2.10 -r1.72.2.11 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: [netbsd-8] src/sys/dev/usb

2019-08-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 12 17:19:02 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: ohci.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1334):

sys/dev/usb/ohci.c: revision 1.289
sys/dev/usb/ohci.c: revision 1.290

adjust KASSERT() for sc_lock to handle polling case.
should fix usb kdb in ddb.  reported by martin.

 -

relax an assert to be mutex_owned || polling.

half of the patch i sent for netbsd-8 in PR#54331.
the other half is already applied.


To generate a diff of this commit:
cvs rdiff -u -r1.273.6.4 -r1.273.6.5 src/sys/dev/usb/ohci.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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.273.6.4 src/sys/dev/usb/ohci.c:1.273.6.5
--- src/sys/dev/usb/ohci.c:1.273.6.4	Thu Sep 27 14:52:26 2018
+++ src/sys/dev/usb/ohci.c	Mon Aug 12 17:19:02 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.273.6.4 2018/09/27 14:52:26 martin Exp $	*/
+/*	$NetBSD: ohci.c,v 1.273.6.5 2019/08/12 17:19:02 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.273.6.4 2018/09/27 14:52:26 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.273.6.5 2019/08/12 17:19:02 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -587,7 +587,7 @@ ohci_reset_std_chain(ohci_softc_t *sc, s
 	OHCIHIST_FUNC(); OHCIHIST_CALLED();
 	DPRINTF("start len=%jd", alen, 0, 0, 0);
 
-	KASSERT(mutex_owned(>sc_lock));
+	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock));
 
 	DPRINTFN(8, "addr=%jd endpt=%jd len=%jd speed=%jd",
 	xfer->ux_pipe->up_dev->ud_addr,
@@ -1675,7 +1675,7 @@ ohci_device_bulk_done(struct usbd_xfer *
 	int isread =
 	(UE_GET_DIR(xfer->ux_pipe->up_endpoint->ue_edesc->bEndpointAddress) == UE_DIR_IN);
 
-	KASSERT(mutex_owned(>sc_lock));
+	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock));
 
 	OHCIHIST_FUNC(); OHCIHIST_CALLED();
 	DPRINTFN(10, "xfer=%#jx, actlen=%jd", (uintptr_t)xfer, xfer->ux_actlen,



CVS commit: [netbsd-8] src/sys/dev/usb

2019-08-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 12 17:19:02 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: ohci.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1334):

sys/dev/usb/ohci.c: revision 1.289
sys/dev/usb/ohci.c: revision 1.290

adjust KASSERT() for sc_lock to handle polling case.
should fix usb kdb in ddb.  reported by martin.

 -

relax an assert to be mutex_owned || polling.

half of the patch i sent for netbsd-8 in PR#54331.
the other half is already applied.


To generate a diff of this commit:
cvs rdiff -u -r1.273.6.4 -r1.273.6.5 src/sys/dev/usb/ohci.c

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



CVS commit: [netbsd-8] src/sys/dev/usb

2019-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Aug  1 13:41:56 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: usbdevs.h usbdevs_data.h

Log Message:
regen for ticket #1310


To generate a diff of this commit:
cvs rdiff -u -r1.727.2.4 -r1.727.2.5 src/sys/dev/usb/usbdevs.h
cvs rdiff -u -r1.728.2.4 -r1.728.2.5 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: [netbsd-8] src/sys/dev/usb

2019-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Aug  1 13:40:54 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: usbdevs

Log Message:
Pull up the following revisions, via patch (requested by msaitoh in
ticket #1310):

sys/dev/usb/usbdevs 1.754-1.755

- Add Cinterion
- Add Sierra Wireless C01SW.
- Add SMSC USB 2.0 7-Port Hub.
- Add ZTE MF633 USUPA USB modem, USB MSM installer, ZTE MF112, MF119,
  MF190, MF228 modem and Softbank 004Z.
- Add Huawei HWD12, E353, E355, E392, EC156, E3272 / Softbank 203HW
- Add NetIndex RT-WJ02 and UX312NC.
- Add Siemens HC28


To generate a diff of this commit:
cvs rdiff -u -r1.736.2.4 -r1.736.2.5 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: [netbsd-8] src/sys/dev/usb

2019-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Aug  1 13:40:54 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: usbdevs

Log Message:
Pull up the following revisions, via patch (requested by msaitoh in
ticket #1310):

sys/dev/usb/usbdevs 1.754-1.755

- Add Cinterion
- Add Sierra Wireless C01SW.
- Add SMSC USB 2.0 7-Port Hub.
- Add ZTE MF633 USUPA USB modem, USB MSM installer, ZTE MF112, MF119,
  MF190, MF228 modem and Softbank 004Z.
- Add Huawei HWD12, E353, E355, E392, EC156, E3272 / Softbank 203HW
- Add NetIndex RT-WJ02 and UX312NC.
- Add Siemens HC28


To generate a diff of this commit:
cvs rdiff -u -r1.736.2.4 -r1.736.2.5 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.736.2.4 src/sys/dev/usb/usbdevs:1.736.2.5
--- src/sys/dev/usb/usbdevs:1.736.2.4	Wed Jul 17 16:07:38 2019
+++ src/sys/dev/usb/usbdevs	Thu Aug  1 13:40:54 2019
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.736.2.4 2019/07/17 16:07:38 martin Exp $
+$NetBSD: usbdevs,v 1.736.2.5 2019/08/01 13:40:54 martin Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -558,6 +558,7 @@ vendor 4GSYSTEMS	0x1c9e	4G Systems
 vendor PEGATRON		0x1d4d	Pegatron
 vendor FUTUREBITS	0x1d50	Future Bits
 vendor LINUXFOUNDATION	0x1d6b	Linux Foundation
+vendor CINTERION	0x1e2d	Cinterion
 vendor AIRTIES		0x1eda	AirTies
 vendor DLINK		0x2001	D-Link
 vendor PLANEX2		0x2019	Planex Communications
@@ -1117,7 +1118,6 @@ product BROADCOM BCM43143	0xbd1e	BCM4314
 product BROADCOM BCM43242	0xbd1f	BCM43242
 product BROADCOM BCM43569	0xbd27	BCM43569
 
-
 /* Brother Industries products */
 product BROTHER HL1050		0x0002	HL-1050 laser printer
 
@@ -1831,17 +1831,21 @@ product HUAWEI U8150		0x1037	Huawei U815
 product HUAWEI EM770W		0x1404	Huawei EM770W
 product HUAWEI E1750		0x140c	Huawei E1750
 product HUAWEI E182		0x1429	Huawei E182
+product HUAWEI E353		0x1442	Huawei E353
 product HUAWEI E1750INIT	0x1446	Huawei E1750 USB CD
 product HUAWEI K3765		0x1465	Huawei K3765
 product HUAWEI E1820		0x14ac	Huawei E1820
+product HUAWEI HWD12_RNDIS	0x14db	Huawei HWD12 RNDIS mode
 product HUAWEI E171INIT		0x14fe	Huawei E171 USB CD
-product HUAWEI E171		0x1506	Huawei E171
+product HUAWEI E392INIT		0x1505	Huawei E392 EC156 Installer
+product HUAWEI E171		0x1506	Huawei E171 / HWD12 RAS mode
 product HUAWEI E353_HiLink	0x1507	Huawei E353_HiLink
 /* Accessing http://192.168.1.1/html/switchProjectMode.html on
a Huawei HiLink device will switch it to u3g mode */
-product HUAWEI E353 0x1442	Huawei E353
 product HUAWEI K3765INIT	0x1520	Huawei K3765 USB CD
+product HUAWEI E3272		0x1c1e	Huawei E3272 E355 / Softbank 203HW
 product HUAWEI E353INIT		0x1f01	Huawei E353 USB CD
+product HUAWEI HWD12_INSTALLER	0x1f03	Huawei HWD12 Installer
 
 /* Huawei-3Com products */
 product HUAWEI3COM RT2573	0x0009	RT2573
@@ -2448,6 +2452,8 @@ product NETGEAR3 WPN111_NF	0x5f01	WPN111
 product NETGEAR4 RTL8188CU	0x9041	RTL8188CU
 
 /* NetIndex products */
+product NETINDEX RTWJ02		0x1022	RT-WJ02
+product NETINDEX UX312NC	0x1032	UX312NC
 product NETINDEX WS002IN	0x2001	Willcom WS002IN (DD)
 
 /* NHJ product */
@@ -2988,6 +2994,9 @@ product SIEMENS SPEEDSTREAM22	0x1022	Spe
 /* Siemens Info products */
 product SIEMENS2 WLL013		0x001b	WLL013
 product SIEMENS2 MC75		0x0034	Wireless Modules MC75
+product SIEMENS2 HC28MDMNET	0x004a	HC28 MdmNet
+product SIEMENS2 HC28MS		0x004b	HC28 Mass Storage Device
+product SIEMENS2 HC28MDM	0x004c	HC28 Mdm
 product SIEMENS2 WL54G		0x3c06	54g USB Network Adapter
 
 /* Sierra Wireless products */
@@ -3019,6 +3028,7 @@ product SIERRA AC881E		0x6853	Sierra Wir
 product SIERRA AC880U		0x6855	Sierra Wireless AirCard 880U
 product SIERRA AC881U		0x6856	Sierra Wireless AirCard 881U
 product SIERRA AC885U		0x6880	Sierra Wireless AirCard 885U
+product SIERRA C01SW		0x6890	C01SW
 product SIERRA USB305		0x68a3	Sierra Wireless AirCard USB 305
 product SIERRA MC7304		0x68c0	MC7304
 product SIERRA EM7455		0x9079	EM7455
@@ -3135,6 +3145,7 @@ product SMSC 2020HUB		0x2020	USB Hub
 product SMSC 2512HUB		0x2512	USB 2.0 2-Port Hub
 product SMSC 2513HUB		0x2513	USB 2.0 3-Port Hub
 product SMSC 2514HUB		0x2514	USB 2.0 4-Port Hub
+product SMSC 2517HUB		0x2517	USB 2.0 7-Port Hub
 product SMSC LAN7500		0x7500	LAN7500 USB 2.0 gigabit ethernet device
 product SMSC LAN7505		0x7505	LAN7505 USB 2.0 gigabit ethernet device
 product SMSC LAN7800		0x7800	LAN7800 USB 3.1 gigabit ethernet device
@@ -3560,7 +3571,11 @@ product ZORAN EX20DSC		0x4343	Digital Ca
 /* ZTE products */
 product ZTE MF622		0x0001	MF622 modem
 product ZTE MF628		0x0015	MF628 modem
+product ZTE MF633		0x0016	MF633 USUPA USB modem
 product ZTE MF626		0x0031	MF626 modem
+product ZTE UMASS_INSTALLER2	0x0103	USB MSM installer
+product ZTE MF112		0x0117	MF112 MF119 MF190 MF228 modem / Softbank 004Z
+product ZTE 

CVS commit: [netbsd-8] src/sys/dev/usb

2019-07-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jul 17 16:20:26 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: if_athn_usb.c

Log Message:
Pull up the following revisions (via patch), requested by msaitoh
in ticket #1299:

sys/dev/usb/if_athn_usb.c   1.24,1.31-1.34

- Match BUFFALO CEWL-1 (Sony UWA-BR100 WLAN).
- Add support for Panasonic N5HBZ055, from David H. Gutteridge
  in PR kern/53647.
- Resolves build on macppc by renaming imask to intr_mask as imask is
  defined globally in sys/arch/powerpc/include/intr.h.
- Use pmf(9).
- Fix the detach path to prevent panic.


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.3 -r1.22.2.4 src/sys/dev/usb/if_athn_usb.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_athn_usb.c
diff -u src/sys/dev/usb/if_athn_usb.c:1.22.2.3 src/sys/dev/usb/if_athn_usb.c:1.22.2.4
--- src/sys/dev/usb/if_athn_usb.c:1.22.2.3	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_athn_usb.c	Wed Jul 17 16:20:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_athn_usb.c,v 1.22.2.3 2018/08/08 10:28:35 martin Exp $	*/
+/*	$NetBSD: if_athn_usb.c,v 1.22.2.4 2019/07/17 16:20:26 martin Exp $	*/
 /*	$OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $	*/
 
 /*-
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.22.2.3 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.22.2.4 2019/07/17 16:20:26 martin Exp $");
 
 #ifdef	_KERNEL_OPT
 #include "opt_inet.h"
@@ -223,7 +223,9 @@ athn_usb_lookup(int vendor, int product)
 		_D( LITEON,	LITEON_AR9271,	  	NONE ),
 		_D( NETGEAR,	NETGEAR_WNA1100,	NONE ),
 		_D( NETGEAR,	NETGEAR_WNDA3200,	AR7010 ),
-		_D( VIA,	VIA_AR9271,		NONE )
+		_D( VIA,	VIA_AR9271,		NONE ),
+		_D( MELCO,	MELCO_CEWL_1,		AR7010 ),
+		_D( PANASONIC,	PANASONIC_N5HBZ055,	AR7010 ),
 #undef _D
 	};
 
@@ -323,6 +325,9 @@ athn_usb_attach(device_t parent, device_
 	config_mountroot(self, athn_usb_attachhook);
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, usc->usc_udev, sc->sc_dev);
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	return;
 
  fail:
@@ -473,6 +478,8 @@ athn_usb_detach(device_t self, int flags
 
 	DPRINTFN(DBG_FN, usc, "\n");
 
+	pmf_device_deregister(self);
+
 	mutex_enter(>usc_lock);
 	usc->usc_dying = 1;
 	mutex_exit(>usc_lock);
@@ -501,6 +508,7 @@ athn_usb_detach(device_t self, int flags
 
 	athn_usb_wait_async(usc);
 
+	athn_usb_stop(>sc_if, 0);
 	usb_rem_task_wait(usc->usc_udev, >usc_task, USB_TASKQ_DRIVER,
 	NULL);
 
@@ -516,6 +524,7 @@ athn_usb_detach(device_t self, int flags
 	athn_usb_free_rx_list(usc);
 	athn_usb_free_tx_list(usc);
 	athn_usb_free_tx_cmd(usc);
+	athn_usb_free_tx_msg(usc);
 
 	/* Close Tx/Rx pipes. */
 	athn_usb_close_pipes(usc);
@@ -757,10 +766,6 @@ athn_usb_free_tx_list(struct athn_usb_so
 		if (xfer != NULL)
 			usbd_destroy_xfer(xfer);
 	}
-	if (usc->usc_tx_bcn) {
-		usbd_destroy_xfer(usc->usc_tx_bcn->xfer);
-		usc->usc_tx_bcn = NULL;
-	}
 }
 
 Static int
@@ -1420,7 +1425,7 @@ athn_usb_newstate_cb(struct athn_usb_sof
 	struct athn_softc *sc = >usc_sc;
 	struct ieee80211com *ic = >sc_ic;
 	enum ieee80211_state ostate, nstate;
-	uint32_t reg, imask;
+	uint32_t reg, intr_mask;
 	int s;
 
 	DPRINTFN(DBG_FN, sc, "\n");
@@ -1477,13 +1482,13 @@ athn_usb_newstate_cb(struct athn_usb_sof
 		if (ic->ic_opmode == IEEE80211_M_HOSTAP) {
 			athn_set_hostap_timers(sc);
 			/* Enable software beacon alert interrupts. */
-			imask = htobe32(AR_IMR_SWBA);
+			intr_mask = htobe32(AR_IMR_SWBA);
 		} else
 #endif
 		{
 			athn_set_sta_timers(sc);
 			/* Enable beacon miss interrupts. */
-			imask = htobe32(AR_IMR_BMISS);
+			intr_mask = htobe32(AR_IMR_BMISS);
 
 			/* Stop receiving beacons from other BSS. */
 			reg = AR_READ(sc, AR_RX_FILTER);
@@ -1493,7 +1498,7 @@ athn_usb_newstate_cb(struct athn_usb_sof
 			AR_WRITE_BARRIER(sc);
 		}
 		athn_usb_wmi_xcmd(usc, AR_WMI_CMD_ENABLE_INTR,
-		, sizeof(imask), NULL);
+		_mask, sizeof(intr_mask), NULL);
 		break;
 	}
 	if (!usc->usc_dying)



CVS commit: [netbsd-8] src/sys/dev/usb

2019-07-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jul 17 16:20:26 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: if_athn_usb.c

Log Message:
Pull up the following revisions (via patch), requested by msaitoh
in ticket #1299:

sys/dev/usb/if_athn_usb.c   1.24,1.31-1.34

- Match BUFFALO CEWL-1 (Sony UWA-BR100 WLAN).
- Add support for Panasonic N5HBZ055, from David H. Gutteridge
  in PR kern/53647.
- Resolves build on macppc by renaming imask to intr_mask as imask is
  defined globally in sys/arch/powerpc/include/intr.h.
- Use pmf(9).
- Fix the detach path to prevent panic.


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.3 -r1.22.2.4 src/sys/dev/usb/if_athn_usb.c

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



CVS commit: [netbsd-8] src/sys/dev/usb

2019-07-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jul 17 16:08:12 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: usbdevs.h usbdevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.727.2.3 -r1.727.2.4 src/sys/dev/usb/usbdevs.h
cvs rdiff -u -r1.728.2.3 -r1.728.2.4 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: [netbsd-8] src/sys/dev/usb

2019-07-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jul 17 16:07:38 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: usbdevs

Log Message:
Pull up the following revisions (via patch), requested by msaitoh
in ticket #1297:

sys/dev/usb/usbdevs 1.737-1.741,1.743-1.752,
1.756-1.759,1.763-1.770

- Add yet another moschip serial adapter chip.
- Add some classic Roland products from Shinichi Doyashiki in
  PR kern/52385.
- Add Ralink RT73.
- Add Wacom Intuos2 A4 and Intuos Art pen tablets.
- Add ELAN keyboard.
- Add Sony UWA-BR100 WLAN adapter.
- Add the TP-LINK TL-WN823N (version 2).
- Add RT Systems RTS-03 USB to Serial Adapter.
- Add West Mountain Radio IDs from OpenBSD.
- Add LAN78xx family (Raspberry Pi 3B+) entries - PR kern/53105.
- Add Linux Foundation vendor ID, and their root hub device IDs.
- Apple Bluetooth adapter, as found on the G4 PowerBook FW-800
  (PowerBook5,2).
- Add Yubico Yubikey devices.
- Add Huawei E182.
- Add the Sierra Wireless MC7304 and EM7455 USB modems.
- Add SMSC LAN7505 USB 2.0 gigabit ethernet device.
- Add Panasonic N5HBZ055 WiFi device reported by
  David H. Gutteridge in PR kern/53647.
- Add Logitech Gamepad F310 and Logitech Dual Action Gamepad.
- Add D-Link LTE products.
- Add D-Link DWA-131 rev E "Wireless N300 Nano USB Adapter"
- Add Microsoft Natural Wireless Mouse 600 from Julian in
  PR kern/44634.
- Add Gretag Macbeth/X-Rite Huey device ids.
- Add HP LP2[24]75w hub.
- Prefer longer "canonical" names and add some vendors (mainly from
  FreeBSD r334649).
- Make whitespace much more consistent.
- Lowercase hexadecimal number.
- Update comment.


To generate a diff of this commit:
cvs rdiff -u -r1.736.2.3 -r1.736.2.4 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.736.2.3 src/sys/dev/usb/usbdevs:1.736.2.4
--- src/sys/dev/usb/usbdevs:1.736.2.3	Thu Feb  7 06:13:26 2019
+++ src/sys/dev/usb/usbdevs	Wed Jul 17 16:07:38 2019
@@ -1,6 +1,6 @@
-$NetBSD: usbdevs,v 1.736.2.3 2019/02/07 06:13:26 msaitoh Exp $
+$NetBSD: usbdevs,v 1.736.2.4 2019/07/17 16:07:38 martin Exp $
 
-/*
+/*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -31,7 +31,7 @@ $NetBSD: usbdevs,v 1.736.2.3 2019/02/07 
  */
 
 /*
- * Use "make -f Makefile.usbdevs" to regenerate usbdevs.h and usbdevs_data.h
+ * Follow the handling instructions in Makefile.usbdevs
  */
 
 /*
@@ -62,7 +62,8 @@ vendor UNKNOWN1		0x0053	Unknown vendor
 vendor UNKNOWN2		0x0105	Unknown vendor
 vendor EGALAX2		0x0123	eGalax, Inc.
 vendor QUAN		0x01e1	Quan
-vendor CHIPSBANK	0x0204	Chipsbank
+vendor CHIPSBANK	0x0204	Chipsbank Microelectronics Co.
+vendor HUMAX		0x02ad	HUMAX
 vendor AOX		0x03e8	AOX
 vendor ATMEL		0x03eb	Atmel
 vendor MITSUMI		0x03ee	Mitsumi
@@ -91,9 +92,10 @@ vendor ALPS		0x044e	Alps Electric
 vendor THRUST		0x044f	Thrustmaster
 vendor TI		0x0451	Texas Instruments
 vendor ANALOGDEVICES	0x0456	Analog Devices
-vendor SIS		0x0457	Silicon Integrated Systems
+vendor SIS		0x0457	Silicon Integrated Systems Corp.
 vendor KYE		0x0458	KYE Systems
 vendor DIAMOND2		0x045a	Diamond (Supra)
+vendor RENESAS		0x045b	Renesas
 vendor MICROSOFT	0x045e	Microsoft
 vendor PRIMAX		0x0461	Primax Electronics
 vendor MGE		0x0463	MGE UPS Systems
@@ -103,12 +105,14 @@ vendor MEGATRENDS	0x046b	American Megatr
 vendor LOGITECH		0x046d	Logitech
 vendor BTC		0x046e	Behavior Tech. Computer
 vendor PHILIPS		0x0471	Philips
+vendor SUN2		0x0472	Sun Microsystems (official)
 vendor SANYO		0x0474	Sanyo Electric
+vendor SEAGATE		0x0477	Seagate
 vendor CONNECTIX	0x0478	Connectix
 vendor KENSINGTON	0x047d	Kensington
 vendor LUCENT		0x047e	Lucent
 vendor PLANTRONICS	0x047f	Plantronics
-vendor KYOCERA		0x0482	Kyocera
+vendor KYOCERA		0x0482	Kyocera Wireless Corp.
 vendor STMICRO		0x0483	STMicroelectronics
 vendor FOXCONN		0x0489	Foxconn / Hon Hai
 vendor MEIZU		0x0492	Meizu Electronics
@@ -116,6 +120,7 @@ vendor YAMAHA		0x0499	YAMAHA
 vendor COMPAQ		0x049f	Compaq
 vendor HITACHI		0x04a4	Hitachi
 vendor ACERP		0x04a5	Acer Peripherals
+vendor DAVIDCOM		0x04a6	Davicom
 vendor VISIONEER	0x04a7	Visioneer
 vendor CANON		0x04a9	Canon
 vendor NIKON		0x04b0	Nikon
@@ -145,6 +150,7 @@ vendor ALTEC		0x04d2	Altec Lansing
 vendor MICROCHIP	0x04d8	Microchip Technology
 vendor HOLTEK		0x04d9	Holtek Semiconductor
 vendor PANASONIC	0x04da	Panasonic (Matsushita)
+vendor HUANHSIN		0x04dc	Huan Hsin
 vendor SHARP		0x04dd	Sharp
 vendor IIYAMA		0x04e1	Iiyama
 vendor SHUTTLE		0x04e6	Shuttle Technology
@@ -152,7 +158,7 @@ vendor SAMSUNG		0x04e8	Samsung Electroni
 vendor ANNABOOKS	0x04ed	Annabooks
 vendor JVC		0x04f1	JVC
 vendor CHICONY		0x04f2	Chicony Electronics
-vendor ELAN		0x04f3  ELAN Microelectronics
+vendor ELAN		0x04f3	ELAN Microelectronics
 vendor BROTHER		0x04f9	

CVS commit: [netbsd-8] src/sys/dev/usb

2019-07-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jul 17 16:07:38 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: usbdevs

Log Message:
Pull up the following revisions (via patch), requested by msaitoh
in ticket #1297:

sys/dev/usb/usbdevs 1.737-1.741,1.743-1.752,
1.756-1.759,1.763-1.770

- Add yet another moschip serial adapter chip.
- Add some classic Roland products from Shinichi Doyashiki in
  PR kern/52385.
- Add Ralink RT73.
- Add Wacom Intuos2 A4 and Intuos Art pen tablets.
- Add ELAN keyboard.
- Add Sony UWA-BR100 WLAN adapter.
- Add the TP-LINK TL-WN823N (version 2).
- Add RT Systems RTS-03 USB to Serial Adapter.
- Add West Mountain Radio IDs from OpenBSD.
- Add LAN78xx family (Raspberry Pi 3B+) entries - PR kern/53105.
- Add Linux Foundation vendor ID, and their root hub device IDs.
- Apple Bluetooth adapter, as found on the G4 PowerBook FW-800
  (PowerBook5,2).
- Add Yubico Yubikey devices.
- Add Huawei E182.
- Add the Sierra Wireless MC7304 and EM7455 USB modems.
- Add SMSC LAN7505 USB 2.0 gigabit ethernet device.
- Add Panasonic N5HBZ055 WiFi device reported by
  David H. Gutteridge in PR kern/53647.
- Add Logitech Gamepad F310 and Logitech Dual Action Gamepad.
- Add D-Link LTE products.
- Add D-Link DWA-131 rev E "Wireless N300 Nano USB Adapter"
- Add Microsoft Natural Wireless Mouse 600 from Julian in
  PR kern/44634.
- Add Gretag Macbeth/X-Rite Huey device ids.
- Add HP LP2[24]75w hub.
- Prefer longer "canonical" names and add some vendors (mainly from
  FreeBSD r334649).
- Make whitespace much more consistent.
- Lowercase hexadecimal number.
- Update comment.


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

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