Module Name: src
Committed By: skrll
Date: Wed Sep 7 10:26:39 UTC 2016
Modified Files:
src/sys/dev/usb [netbsd-7-nhusb]: if_athn_usb.c usb_subr.c usbdi.c
xhci.c xhcireg.h
Log Message:
Sync with HEAD
To generate a diff of this commit:
cvs rdiff -u -r1.6.12.1 -r1.6.12.2 src/sys/dev/usb/if_athn_usb.c
cvs rdiff -u -r1.196.4.2.2.1 -r1.196.4.2.2.2 src/sys/dev/usb/usb_subr.c
cvs rdiff -u -r1.161.2.1.4.1 -r1.161.2.1.4.2 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.23.2.4.2.1 -r1.23.2.4.2.2 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.1.10.1.4.1 -r1.1.10.1.4.2 src/sys/dev/usb/xhcireg.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/usb/if_athn_usb.c
diff -u src/sys/dev/usb/if_athn_usb.c:1.6.12.1 src/sys/dev/usb/if_athn_usb.c:1.6.12.2
--- src/sys/dev/usb/if_athn_usb.c:1.6.12.1 Tue Sep 6 20:33:08 2016
+++ src/sys/dev/usb/if_athn_usb.c Wed Sep 7 10:26:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: if_athn_usb.c,v 1.6.12.1 2016/09/06 20:33:08 skrll Exp $ */
+/* $NetBSD: if_athn_usb.c,v 1.6.12.2 2016/09/07 10:26:39 skrll Exp $ */
/* $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $ */
/*-
@@ -22,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.12.1 2016/09/06 20:33:08 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.12.2 2016/09/07 10:26:39 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -716,6 +716,7 @@ athn_usb_alloc_tx_cmd(struct athn_usb_so
"could not allocate command xfer\n");
return err;
}
+ data->buf = usbd_get_buffer(data->xfer);
return 0;
}
Index: src/sys/dev/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.196.4.2.2.1 src/sys/dev/usb/usb_subr.c:1.196.4.2.2.2
--- src/sys/dev/usb/usb_subr.c:1.196.4.2.2.1 Tue Sep 6 20:33:09 2016
+++ src/sys/dev/usb/usb_subr.c Wed Sep 7 10:26:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_subr.c,v 1.196.4.2.2.1 2016/09/06 20:33:09 skrll Exp $ */
+/* $NetBSD: usb_subr.c,v 1.196.4.2.2.2 2016/09/07 10:26:39 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 <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.196.4.2.2.1 2016/09/06 20:33:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.196.4.2.2.2 2016/09/07 10:26:39 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -595,7 +595,7 @@ usbd_set_config_index(struct usbd_device
{
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
usb_config_descriptor_t cd, *cdp;
- usb_bos_descriptor_t bd, *bdp = NULL;
+ usb_bos_descriptor_t *bdp = NULL;
usbd_status err;
int i, ifcidx, nifc, len, selfpowered, power;
@@ -666,6 +666,8 @@ usbd_set_config_index(struct usbd_device
}
if (USB_IS_SS(dev->ud_speed)) {
+ usb_bos_descriptor_t bd;
+
/* get short bos desc */
err = usbd_get_bos_desc(dev, index, &bd);
if (!err) {
@@ -1522,7 +1524,7 @@ usbd_fill_deviceinfo(struct usbd_device
int usedev)
{
struct usbd_port *p;
- int i, j, err, s;
+ int i, j, err;
di->udi_bus = device_unit(dev->ud_bus->ub_usbctl);
di->udi_addr = dev->ud_addr;
@@ -1573,38 +1575,38 @@ usbd_fill_deviceinfo(struct usbd_device
for (/* j is set */; j < USB_MAX_DEVNAMES; j++)
di->udi_devnames[j][0] = 0; /* empty */
- if (dev->ud_hub) {
- for (i = 0;
- i < sizeof(di->udi_ports) / sizeof(di->udi_ports[0]) &&
- i < dev->ud_hub->uh_hubdesc.bNbrPorts;
- i++) {
- p = &dev->ud_hub->uh_ports[i];
- if (p->up_dev)
- err = p->up_dev->ud_addr;
- else {
- s = UGETW(p->up_status.wPortStatus);
- if (s & UPS_PORT_ENABLED)
- err = USB_PORT_ENABLED;
- else if (s & UPS_SUSPEND)
- err = USB_PORT_SUSPENDED;
- /*
- * Note: UPS_PORT_POWER_SS is available only
- * on 3.x, and UPS_PORT_POWER is available
- * only on 2.0 or 1.1.
- */
- else if (USB_IS_SS(dev->ud_speed) &&
- (s & UPS_PORT_POWER_SS))
- err = USB_PORT_POWERED;
- else if (s & UPS_PORT_POWER)
- err = USB_PORT_POWERED;
- else
- err = USB_PORT_DISABLED;
- }
- di->udi_ports[i] = err;
- }
- di->udi_nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
- } else
+ if (!dev->ud_hub) {
di->udi_nports = 0;
+ return;
+ }
+
+ const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
+ for (i = 0; i < __arraycount(di->udi_ports) && i < nports; i++) {
+ p = &dev->ud_hub->uh_ports[i];
+ if (p->up_dev)
+ err = p->up_dev->ud_addr;
+ else {
+ int s = UGETW(p->up_status.wPortStatus);
+ if (s & UPS_PORT_ENABLED)
+ err = USB_PORT_ENABLED;
+ else if (s & UPS_SUSPEND)
+ err = USB_PORT_SUSPENDED;
+ /*
+ * Note: UPS_PORT_POWER_SS is available only
+ * on 3.x, and UPS_PORT_POWER is available
+ * only on 2.0 or 1.1.
+ */
+ else if (USB_IS_SS(dev->ud_speed) &&
+ (s & UPS_PORT_POWER_SS))
+ err = USB_PORT_POWERED;
+ else if (s & UPS_PORT_POWER)
+ err = USB_PORT_POWERED;
+ else
+ err = USB_PORT_DISABLED;
+ }
+ di->udi_ports[i] = err;
+ }
+ di->udi_nports = nports;
}
#ifdef COMPAT_30
@@ -1613,7 +1615,7 @@ usbd_fill_deviceinfo_old(struct usbd_dev
int usedev)
{
struct usbd_port *p;
- int i, j, err, s;
+ int i, j, err;
di->udi_bus = device_unit(dev->ud_bus->ub_usbctl);
di->udi_addr = dev->ud_addr;
@@ -1648,30 +1650,31 @@ usbd_fill_deviceinfo_old(struct usbd_dev
for (/* j is set */; j < USB_MAX_DEVNAMES; j++)
di->udi_devnames[j][0] = 0; /* empty */
- if (dev->ud_hub) {
- for (i = 0;
- i < sizeof(di->udi_ports) / sizeof(di->udi_ports[0]) &&
- i < dev->ud_hub->uh_hubdesc.bNbrPorts;
- i++) {
- p = &dev->ud_hub->uh_ports[i];
- if (p->up_dev)
- err = p->up_dev->ud_addr;
- else {
- s = UGETW(p->up_status.wPortStatus);
- if (s & UPS_PORT_ENABLED)
- err = USB_PORT_ENABLED;
- else if (s & UPS_SUSPEND)
- err = USB_PORT_SUSPENDED;
- else if (s & UPS_PORT_POWER)
- err = USB_PORT_POWERED;
- else
- err = USB_PORT_DISABLED;
- }
- di->udi_ports[i] = err;
- }
- di->udi_nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
- } else
+ if (!dev->ud_hub) {
di->udi_nports = 0;
+ return;
+ }
+
+ const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
+ for (i = 0; i < __arraycount(di->udi_ports) && i < nports;
+ i++) {
+ p = &dev->ud_hub->uh_ports[i];
+ if (p->up_dev)
+ err = p->up_dev->ud_addr;
+ else {
+ int s = UGETW(p->up_status.wPortStatus);
+ if (s & UPS_PORT_ENABLED)
+ err = USB_PORT_ENABLED;
+ else if (s & UPS_SUSPEND)
+ err = USB_PORT_SUSPENDED;
+ else if (s & UPS_PORT_POWER)
+ err = USB_PORT_POWERED;
+ else
+ err = USB_PORT_DISABLED;
+ }
+ di->udi_ports[i] = err;
+ }
+ di->udi_nports = nports;
}
#endif
Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.161.2.1.4.1 src/sys/dev/usb/usbdi.c:1.161.2.1.4.2
--- src/sys/dev/usb/usbdi.c:1.161.2.1.4.1 Tue Sep 6 20:33:09 2016
+++ src/sys/dev/usb/usbdi.c Wed Sep 7 10:26:39 2016
@@ -1,7 +1,7 @@
-/* $NetBSD: usbdi.c,v 1.161.2.1.4.1 2016/09/06 20:33:09 skrll Exp $ */
+/* $NetBSD: usbdi.c,v 1.161.2.1.4.2 2016/09/07 10:26:39 skrll Exp $ */
/*
- * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.161.2.1.4.1 2016/09/06 20:33:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.161.2.1.4.2 2016/09/07 10:26:39 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.23.2.4.2.1 src/sys/dev/usb/xhci.c:1.23.2.4.2.2
--- src/sys/dev/usb/xhci.c:1.23.2.4.2.1 Tue Sep 6 20:33:09 2016
+++ src/sys/dev/usb/xhci.c Wed Sep 7 10:26:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: xhci.c,v 1.23.2.4.2.1 2016/09/06 20:33:09 skrll Exp $ */
+/* $NetBSD: xhci.c,v 1.23.2.4.2.2 2016/09/07 10:26:39 skrll Exp $ */
/*
* Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.23.2.4.2.1 2016/09/06 20:33:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.23.2.4.2.2 2016/09/07 10:26:39 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -1511,11 +1511,8 @@ xhci_close_pipe(struct usbd_pipe *pipe)
return;
}
- /*
- * This may fail in the case that xhci_close_pipe is called after
- * xhci_abort_xfer e.g. usbd_kill_pipe.
- */
- (void)xhci_stop_endpoint(pipe);
+ if (xhci_get_epstate(sc, xs, dci) != XHCI_EPSTATE_STOPPED)
+ (void)xhci_stop_endpoint(pipe);
/*
* set appropriate bit to be dropped.
@@ -2501,7 +2498,14 @@ xhci_do_command_locked(struct xhci_softc
/* XXX KASSERT may fire when cv_timedwait unlocks sc_lock */
KASSERT(sc->sc_command_addr == 0);
- sc->sc_command_addr = xhci_ring_trbp(cr, cr->xr_ep);
+ /*
+ * If enqueue pointer points at last of ring, it's Link TRB,
+ * command TRB will be stored in 0th TRB.
+ */
+ if (cr->xr_ep == cr->xr_ntrb - 1)
+ sc->sc_command_addr = xhci_ring_trbp(cr, 0);
+ else
+ sc->sc_command_addr = xhci_ring_trbp(cr, cr->xr_ep);
mutex_enter(&cr->xr_lock);
xhci_ring_put(sc, cr, NULL, trb, 1);
Index: src/sys/dev/usb/xhcireg.h
diff -u src/sys/dev/usb/xhcireg.h:1.1.10.1.4.1 src/sys/dev/usb/xhcireg.h:1.1.10.1.4.2
--- src/sys/dev/usb/xhcireg.h:1.1.10.1.4.1 Tue Sep 6 20:33:09 2016
+++ src/sys/dev/usb/xhcireg.h Wed Sep 7 10:26:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: xhcireg.h,v 1.1.10.1.4.1 2016/09/06 20:33:09 skrll Exp $ */
+/* $NetBSD: xhcireg.h,v 1.1.10.1.4.2 2016/09/07 10:26:39 skrll Exp $ */
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
@@ -79,7 +79,7 @@
#define XHCI_HCC_LHRC(x) (((x) >> 5) & 0x1) /* light HC reset */
#define XHCI_HCC_LTC(x) (((x) >> 6) & 0x1) /* latency tolerance msg */
#define XHCI_HCC_NSS(x) (((x) >> 7) & 0x1) /* no secondary sid */
-#define XHCI_HCC_PAE(x) (((x) >> 8) & 0x1) /* Pase All Event Data */
+#define XHCI_HCC_PAE(x) (((x) >> 8) & 0x1) /* Parse All Event Data */
#define XHCI_HCC_SPC(x) (((x) >> 9) & 0x1) /* Short packet */
#define XHCI_HCC_SEC(x) (((x) >> 10) & 0x1) /* Stopped EDTLA */
#define XHCI_HCC_CFC(x) (((x) >> 11) & 0x1) /* Configuous Frame ID */
@@ -232,7 +232,7 @@
/* XHCI extended capability ID's */
#define XHCI_ID_USB_LEGACY 0x0001 /* USB Legacy Support */
-#define XHCI_XECP_USBLESUP 0x0000 /* Legacy Support Capability Reg */
+#define XHCI_XECP_USBLEGSUP 0x0000 /* Legacy Support Capability Reg */
#define XHCI_XECP_USBLEGCTLSTS 0x0004 /* Legacy Support Ctrl & Status Reg */
#define XHCI_ID_PROTOCOLS 0x0002 /* Supported Protocol */
#define XHCI_ID_POWER_MGMT 0x0003 /* Extended Power Management */