Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7-nhusb]: src/sys/dev/usb Sync with HEAD



details:   https://anonhg.NetBSD.org/src/rev/53cf31e43ef4
branches:  netbsd-7-nhusb
changeset: 801028:53cf31e43ef4
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Sep 07 10:26:39 2016 +0000

description:
Sync with HEAD

diffstat:

 sys/dev/usb/if_athn_usb.c |    5 +-
 sys/dev/usb/usb_subr.c    |  121 +++++++++++++++++++++++----------------------
 sys/dev/usb/usbdi.c       |    6 +-
 sys/dev/usb/xhci.c        |   20 ++++---
 sys/dev/usb/xhcireg.h     |    6 +-
 5 files changed, 83 insertions(+), 75 deletions(-)

diffs (truncated from 302 to 300 lines):

diff -r eba0219b3e72 -r 53cf31e43ef4 sys/dev/usb/if_athn_usb.c
--- a/sys/dev/usb/if_athn_usb.c Wed Sep 07 09:03:33 2016 +0000
+++ b/sys/dev/usb/if_athn_usb.c Wed Sep 07 10:26:39 2016 +0000
@@ -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 @@
                    "could not allocate command xfer\n");
                return err;
        }
+       data->buf = usbd_get_buffer(data->xfer);
 
        return 0;
 }
diff -r eba0219b3e72 -r 53cf31e43ef4 sys/dev/usb/usb_subr.c
--- a/sys/dev/usb/usb_subr.c    Wed Sep 07 09:03:33 2016 +0000
+++ b/sys/dev/usb/usb_subr.c    Wed Sep 07 10:26:39 2016 +0000
@@ -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 @@
 {
        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 @@
        }
 
        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 @@
                     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 @@
        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;
+       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_nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
-       } else
-               di->udi_nports = 0;
+               di->udi_ports[i] = err;
+       }
+       di->udi_nports = nports;
 }
 
 #ifdef COMPAT_30
@@ -1613,7 +1615,7 @@
                          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 @@
        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;
+       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_nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
-       } else
-               di->udi_nports = 0;
+               di->udi_ports[i] = err;
+       }
+       di->udi_nports = nports;
 }
 #endif
 
diff -r eba0219b3e72 -r 53cf31e43ef4 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c       Wed Sep 07 09:03:33 2016 +0000
+++ b/sys/dev/usb/usbdi.c       Wed Sep 07 10:26:39 2016 +0000
@@ -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"
diff -r eba0219b3e72 -r 53cf31e43ef4 sys/dev/usb/xhci.c
--- a/sys/dev/usb/xhci.c        Wed Sep 07 09:03:33 2016 +0000
+++ b/sys/dev/usb/xhci.c        Wed Sep 07 10:26:39 2016 +0000
@@ -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 @@
                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 @@
 
        /* 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);
diff -r eba0219b3e72 -r 53cf31e43ef4 sys/dev/usb/xhcireg.h
--- a/sys/dev/usb/xhcireg.h     Wed Sep 07 09:03:33 2016 +0000
+++ b/sys/dev/usb/xhcireg.h     Wed Sep 07 10:26:39 2016 +0000
@@ -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 */



Home | Main Index | Thread Index | Old Index