1. 07 11月, 2018 1 次提交
    • K
      USB: Wait for extra delay time after USB_PORT_FEAT_RESET for quirky hub · 781f0766
      Kai-Heng Feng 提交于
      Devices connected under Terminus Technology Inc. Hub (1a40:0101) may
      fail to work after the system resumes from suspend:
      [  206.063325] usb 3-2.4: reset full-speed USB device number 4 using xhci_hcd
      [  206.143691] usb 3-2.4: device descriptor read/64, error -32
      [  206.351671] usb 3-2.4: device descriptor read/64, error -32
      
      Info for this hub:
      T:  Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=480 MxCh= 4
      D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=1a40 ProdID=0101 Rev=01.11
      S:  Product=USB 2.0 Hub
      C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mA
      I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
      
      Some expirements indicate that the USB devices connected to the hub are
      innocent, it's the hub itself is to blame. The hub needs extra delay
      time after it resets its port.
      
      Hence wait for extra delay, if the device is connected to this quirky
      hub.
      Signed-off-by: NKai-Heng Feng <kai.heng.feng@canonical.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      781f0766
  2. 09 10月, 2018 1 次提交
  3. 03 10月, 2018 1 次提交
  4. 28 9月, 2018 1 次提交
    • J
      usb: core: added uevent for over-current · 201af55d
      Jon Flatley 提交于
      After commit 1cbd53c8 ("usb: core: introduce per-port over-current
      counters") usb ports expose a sysfs value 'over_current_count'
      to user space. This value on its own is not very useful as it requires
      manual polling.
      
      As a solution, fire a udev event from the usb hub device that specifies
      the values 'OVER_CURRENT_PORT' and 'OVER_CURRENT_COUNT' that indicate
      the path of the usb port where the over-current event occurred and the
      value of 'over_current_count' in sysfs. Additionally, call
      sysfs_notify() so the sysfs value supports poll().
      Signed-off-by: NJon Flatley <jflat@chromium.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      201af55d
  5. 21 7月, 2018 1 次提交
  6. 25 6月, 2018 1 次提交
    • A
      USB: Report wakeup events on root-hub ports · 379cacc5
      Alan Stern 提交于
      When a USB device attached to a root-hub port sends a wakeup request
      to a sleeping system, we do not report the wakeup event to the PM
      core.  This is because a system resume involves waking up all
      suspended USB ports as quickly as possible; without the normal
      USB_RESUME_TIMEOUT delay, the host controller driver doesn't set the
      USB_PORT_STAT_C_SUSPEND flag and so usb_port_resume() doesn't realize
      that a wakeup request was received.
      
      However, some environments (such as Chrome OS) want to have all wakeup
      events reported so they can be ascribed to the appropriate device.  To
      accommodate these environments, this patch adds a new routine to the
      hub driver and a corresponding new HCD method to be used when a root
      hub resumes.  The HCD method returns a bitmap of ports that have
      initiated a wakeup signal but not yet completed resuming.  The hub
      driver can then report to the PM core that the child devices attached
      to these ports initiated a wakeup event.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Suggested-by: NAnshuman Gupta <anshuman.gupta@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      379cacc5
  7. 13 6月, 2018 1 次提交
    • K
      treewide: kzalloc() -> kcalloc() · 6396bb22
      Kees Cook 提交于
      The kzalloc() function has a 2-factor argument form, kcalloc(). This
      patch replaces cases of:
      
              kzalloc(a * b, gfp)
      
      with:
              kcalloc(a * b, gfp)
      
      as well as handling cases of:
      
              kzalloc(a * b * c, gfp)
      
      with:
      
              kzalloc(array3_size(a, b, c), gfp)
      
      as it's slightly less ugly than:
      
              kzalloc_array(array_size(a, b), c, gfp)
      
      This does, however, attempt to ignore constant size factors like:
      
              kzalloc(4 * 1024, gfp)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      type TYPE;
      expression THING, E;
      @@
      
      (
        kzalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        kzalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        kzalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_ID)
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_ID
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_CONST
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_ID)
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_ID
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_CONST
      +	COUNT_CONST, sizeof(THING)
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
      - kzalloc
      + kcalloc
        (
      -	SIZE * COUNT
      +	COUNT, SIZE
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        kzalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products,
      // when they're not all constants...
      @@
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(
      -	(E1) * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * (E3)
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants,
      // keeping sizeof() as the second factor argument.
      @@
      expression THING, E1, E2;
      type TYPE;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(sizeof(THING) * C2, ...)
      |
        kzalloc(sizeof(TYPE) * C2, ...)
      |
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(C1 * C2, ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (E2)
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * E2
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (E2)
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * E2
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * E2
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * (E2)
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	E1 * E2
      +	E1, E2
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      6396bb22
  8. 31 5月, 2018 2 次提交
  9. 25 4月, 2018 1 次提交
  10. 22 4月, 2018 4 次提交
    • M
      USB: show USB 3.2 Dual-lane devices as Gen Xx2 during device enumeration · 45455e4d
      Mathias Nyman 提交于
      USB 3.2 specification adds a Gen XxY notion for USB3 devices where
      X is the signaling rate on the wire. Gen 1xY is 5Gbps Superspeed
      and Gen 2xY is 10Gbps SuperSpeedPlus. Y is the lane count.
      
      For normal, non inter-chip (SSIC) devies the rx and tx lane count is
      symmetric, and the maximum lane count for USB 3.2 devices is 2 (dual-lane).
      
      SSIC devices may have asymmetric lane counts, with up to four
      lanes per direction. The USB 3.2 specification doesn't point out
      how to use the Gen XxY notion for these devices, so we limit the Gen Xx2
      notion to symmertic Dual lane devies.
      For other devices just show Gen1 or Gen2
      
      Gen 1 5Gbps
      Gen 2 10Gbps
      Gen 1x2 10Gbps Dual-lane  (USB 3.2)
      Gen 2x2 20Gbps Dual-lane  (USB 3.2)
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45455e4d
    • M
      USB: Add support to store lane count used by USB 3.2 · 013eedb8
      Mathias Nyman 提交于
      USB 3.2 specification adds Dual-lane support, doubling the maximum
      SuperSpeedPlus data rate from 10Gbps to 20Gbps.
      
      Dual-lane takes into use a second set of rx and tx wires/pins in the
      Type-C cable and connector.
      
      Add "rx_lanes" and "tx_lanes" variables to struct usb_device to store
      the numer of lanes in use. Number of lanes can be read using the extended
      port status hub request that was introduced in USB 3.1.
      
      Extended port status rx and tx lane count are zero based, maximum
      lanes supported by non inter-chip (SSIC) USB 3.2 is 2 (dual lane) with
      rx and tx lane count symmetric. SSIC devices support asymmetric lanes
      up to 4 lanes per direction.
      
      If extended port status is not available then default to one lane.
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      013eedb8
    • D
      usb: hub: Don't wait for connect state at resume for powered-off ports · 5d111f51
      Dominik Bozek 提交于
      wait_for_connected() wait till a port change status to
      USB_PORT_STAT_CONNECTION, but this is not possible if
      the port is unpowered. The loop will only exit at timeout.
      
      Such case take place if an over-current incident happen
      while system is in S3. Then during resume wait_for_connected()
      will wait 2s, which may be noticeable by the user.
      Signed-off-by: NDominik Bozek <dominikx.bozek@intel.com>
      Signed-off-by: NKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5d111f51
    • R
      USB: Increment wakeup count on remote wakeup. · 83a62c51
      Ravi Chandra Sadineni 提交于
      On chromebooks we depend on wakeup count to identify the wakeup source.
      But currently USB devices do not increment the wakeup count when they
      trigger the remote wake. This patch addresses the same.
      
      Resume condition is reported differently on USB 2.0 and USB 3.0 devices.
      
      On USB 2.0 devices, a wake capable device, if wake enabled, drives
      resume signal to indicate a remote wake (USB 2.0 spec section 7.1.7.7).
      The upstream facing port then sets C_PORT_SUSPEND bit and reports a
      port change event (USB 2.0 spec section 11.24.2.7.2.3). Thus if a port
      has resumed before driving the resume signal from the host and
      C_PORT_SUSPEND is set, then the device attached to the given port might
      be the reason for the last system wakeup. Increment the wakeup count for
      the same.
      
      On USB 3.0 devices, a function may signal that it wants to exit from device
      suspend by sending a Function Wake Device Notification to the host (USB3.0
      spec section 8.5.6.4) Thus on receiving the Function Wake, increment the
      wakeup count.
      Signed-off-by: NRavi Chandra Sadineni <ravisadineni@chromium.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      83a62c51
  11. 25 3月, 2018 1 次提交
  12. 23 3月, 2018 1 次提交
  13. 22 3月, 2018 1 次提交
    • R
      usb: core: introduce per-port over-current counters · 1cbd53c8
      Richard Leitner 提交于
      For some userspace applications information on the number of
      over-current conditions at specific USB hub ports is relevant.
      
      In our case we have a series of USB hardware (using the cp210x driver)
      which communicates using a proprietary protocol. These devices sometimes
      trigger an over-current situation on some hubs. In case of such an
      over-current situation the USB devices offer an interface for reducing
      the max used power. As these conditions are quite rare and imply
      performance reductions of the device we don't want to reduce the max
      power always.
      
      Therefore give user-space applications the possibility to react
      adequately by introducing an over_current_counter in the usb port struct
      which is exported via sysfs.
      Signed-off-by: NRichard Leitner <richard.leitner@skidata.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1cbd53c8
  14. 10 3月, 2018 1 次提交
    • M
      usb: Don't disable Latency tolerance Messaging (LTM) before port reset · 57edd462
      Mathias Nyman 提交于
      Disabing Latency Tolerance Messaging before port reset is unnecessary.
      LTM is automatically disabled at port reset.
      
      If host can't communicate with the device the LTM message will fail, and
      the hub driver will unnecessarily do a logical disconnect.
      Broken communication is ofter the reason for a reset in the first place.
      
      Additionally we can't guarantee device is in a configured state,
      epecially in reset-resume case when root hub lost power.
      LTM can't be modified unless device is in a configured state.
      
      Just remove LTM disabling before port reset.
      
      Details about LTM and port reset in USB 3 specification:
      
      USB 3 spec section 9.4.5
      "The LTM Enable field can be modified by the SetFeature() and
      ClearFeature() requests using the LTM_ENABLE feature selector.
      This field is reset to zero when the device is reset."
      
      USB 3 spec section 9.4.1
      "The device shall process a Clear Feature (U1_Enable or U2_Enable or
      LTM_Enable) only if the device is in the configured state."
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57edd462
  15. 16 12月, 2017 1 次提交
  16. 06 12月, 2017 1 次提交
  17. 28 11月, 2017 1 次提交
    • M
      usb: hub: Cycle HUB power when initialization fails · 973593a9
      Mike Looijmans 提交于
      Sometimes the USB device gets confused about the state of the initialization and
      the connection fails. In particular, the device thinks that it's already set up
      and running while the host thinks the device still needs to be configured. To
      work around this issue, power-cycle the hub's output to issue a sort of "reset"
      to the device. This makes the device restart its state machine and then the
      initialization succeeds.
      
      This fixes problems where the kernel reports a list of errors like this:
      
      usb 1-1.3: device not accepting address 19, error -71
      
      The end result is a non-functioning device. After this patch, the sequence
      becomes like this:
      
      usb 1-1.3: new high-speed USB device number 18 using ci_hdrc
      usb 1-1.3: device not accepting address 18, error -71
      usb 1-1.3: new high-speed USB device number 19 using ci_hdrc
      usb 1-1.3: device not accepting address 19, error -71
      usb 1-1-port3: attempt power cycle
      usb 1-1.3: new high-speed USB device number 21 using ci_hdrc
      usb-storage 1-1.3:1.2: USB Mass Storage device detected
      Signed-off-by: NMike Looijmans <mike.looijmans@topic.nl>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      973593a9
  18. 07 11月, 2017 1 次提交
  19. 03 11月, 2017 1 次提交
  20. 23 10月, 2017 1 次提交
    • D
      USB: Force disconnect Huawei 4G modem during suspend · 8dd8d2c9
      Daniel Drake 提交于
      When going into S3 suspend, the Acer TravelMate P648-M and P648-G3
      laptops immediately wake up 3-4 seconds later for no obvious reason.
      
      Unbinding the integrated Huawei 4G LTE modem before suspend avoids
      the issue, even though we are not using the modem at all (checked
      from rescue.target/runlevel1). The problem also occurs when the option
      and cdc-ether modem drivers aren't loaded; it reproduces just with the
      base usb driver. Under Windows the system can suspend fine.
      
      Seeking a better fix, we've tried a lot of things, including:
       - Check that the device's power/wakeup is disabled
       - Check that remote wakeup is off at the USB level
       - All the quirks in drivers/usb/core/quirks.c e.g. USB_QUIRK_RESET_RESUME,
         USB_QUIRK_RESET, USB_QUIRK_IGNORE_REMOTE_WAKEUP, USB_QUIRK_NO_LPM.
      
      but none of that makes any difference.
      
      There are no errors in the logs showing any suspend/resume-related issues.
      When the system wakes up due to the modem, log-wise it appears to be a
      normal resume.
      
      Introduce a quirk to disable the port during suspend when the modem is
      detected.
      
      The modem from the P648-G3 model is:
      T:  Bus=01 Lev=01 Prnt=01 Port=08 Cnt=04 Dev#=  5 Spd=480  MxCh= 0
      D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=ff MxPS=64 #Cfgs=  3
      P:  Vendor=12d1 ProdID=15c3 Rev= 1.02
      S:  Manufacturer=Huawei Technologies Co., Ltd.
      S:  Product=HUAWEI Mobile
      S:  SerialNumber=0123456789ABCDEF
      C:  #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=  2mA
      I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=10 Driver=
      E:  Ad=82(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=13 Driver=
      E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=12 Driver=
      E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:  If#= 3 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=06 Prot=16 Driver=
      E:  Ad=86(I) Atr=03(Int.) MxPS=  16 Ivl=2ms
      I:  If#= 3 Alt= 1 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=16 Driver=
      E:  Ad=86(I) Atr=03(Int.) MxPS=  16 Ivl=2ms
      E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:  If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=1b Driver=
      E:  Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      C:* #Ifs= 6 Cfg#= 2 Atr=a0 MxPwr=  2mA
      I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=cdc_ether
      E:  Ad=82(I) Atr=03(Int.) MxPS=  16 Ivl=2ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=06 Prot=00 Driver=cdc_ether
      E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=10 Driver=option
      E:  Ad=84(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=13 Driver=option
      E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=12 Driver=option
      E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=1b Driver=option
      E:  Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      C:  #Ifs= 2 Cfg#= 3 Atr=a0 MxPwr=  2mA
      A:  FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=0e Prot=00
      I:  If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=
      E:  Ad=82(I) Atr=03(Int.) MxPS=  16 Ivl=2ms
      I:  If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=02 Driver=
      I:  If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=
      E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      
      Based on an earlier patch by Chris Chiu.
      Signed-off-by: NDaniel Drake <drake@endlessm.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8dd8d2c9
  21. 19 10月, 2017 1 次提交
  22. 18 9月, 2017 1 次提交
    • D
      usb: Increase quirk delay for USB devices · b2a542bb
      Dmitry Fleytman 提交于
      Commit e0429362
      ("usb: Add device quirk for Logitech HD Pro Webcams C920 and C930e")
      introduced quirk to workaround an issue with some Logitech webcams.
      
      The workaround is introducing delay for some USB operations.
      
      According to our testing, delay introduced by original commit
      is not long enough and in rare cases we still see issues described
      by the aforementioned commit.
      
      This patch increases delays introduced by original commit.
      Having this patch applied we do not see those problems anymore.
      Signed-off-by: NDmitry Fleytman <dmitry@daynix.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2a542bb
  23. 17 8月, 2017 1 次提交
    • M
      usb: Increase root hub reset signaling time to prevent retry · 74072bae
      Mathias Nyman 提交于
      Save 80ms device enumeration time by increasing root hub port reset time
      
      The 50ms reset signaling time is not enough for most root hub ports.
      Increasing the reset time to 60ms allows host controllers to finish port
      reset and removes a retry causing an extra 50ms delay.
      
      The USB 2 specification requires "at least 50ms" for driving root
      port reset. The current msleep is exactly 50ms which may not be
      enough if there are any delays between writing the reset bit to host
      controller portsc register and phy actually driving reset.
      
      On Haswell, Skylake and Kabylake xHC port reset took in average 52-59ms
      
      The 80ms improvement comes from (40ms * 2 port resets) save at enumeration
      for each device connected to a root hub port.
      
      more details about root port reset in USB2 section 7.1.7.5:.
      "Software must ensure that resets issued to the root ports drive reset
      long enough to overwhelm any concurrent resume attempts by downstream
      devices. It is required that resets from root ports have a duration of
      at least 50 ms (TDRSTR).
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      74072bae
  24. 11 8月, 2017 1 次提交
    • A
      USB: Check for dropped connection before switching to full speed · 94c43b98
      Alan Stern 提交于
      Some buggy USB disk adapters disconnect and reconnect multiple times
      during the enumeration procedure.  This may lead to a device
      connecting at full speed instead of high speed, because when the USB
      stack sees that a device isn't able to enumerate at high speed, it
      tries to hand the connection over to a full-speed companion
      controller.
      
      The logic for doing this is careful to check that the device is still
      connected.  But this check is inadequate if the device disconnects and
      reconnects before the check is done.  The symptom is that a device
      works, but much more slowly than it is capable of operating.
      
      The situation was made worse recently by commit 22547c4c ("usb:
      hub: Wait for connection to be reestablished after port reset"), which
      increases the delay following a reset before a disconnect is
      recognized, thus giving the device more time to reconnect.
      
      This patch makes the check more robust.  If the device was
      disconnected at any time during enumeration, we will now skip the
      full-speed handover.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-and-tested-by: NZdenek Kabelac <zkabelac@redhat.com>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      94c43b98
  25. 22 7月, 2017 1 次提交
  26. 29 6月, 2017 1 次提交
  27. 16 6月, 2017 1 次提交
    • M
      usb: Avoid unnecessary LPM enabling and disabling during suspend and resume · d590c231
      Mathias Nyman 提交于
      The original motivation for disabling/enabling Link PM at device
      suspend/resume was to force link state to go via U0 before suspend sets
      the link state to U3. Going directly from U2 to U3 is not allowed.
      
      Disabling LPM will forced the link state to U0, but will send a lot of
      Set port feature requests for evert suspend and resume.
      
      This is not needed as Hub hardware will take care of going via U0
      when a U2 -> U3 transition is requested [1]
      
      [1] USB 3.1 specification section 10.16.2.10 Set Port Feature:
      
      "If the value is 3, then host software wants to selectively suspend the
      device connected to this port. The hub shall transition the link to U3
      from any of the other U states using allowed link state transitions.
      If the port is not already in the U0 state, then it shall transition the
      port to the U0 state and then initiate the transition to U3.
      While this state is active, the hub does not propagate downstream-directed
      traffic to this port, but the hub will respond to resume signaling from the
      port"
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d590c231
  28. 17 5月, 2017 3 次提交
  29. 23 3月, 2017 2 次提交
    • G
      usb: hub: Do not attempt to autosuspend disconnected devices · f5cccf49
      Guenter Roeck 提交于
      While running a bind/unbind stress test with the dwc3 usb driver on rk3399,
      the following crash was observed.
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000218
      pgd = ffffffc00165f000
      [00000218] *pgd=000000000174f003, *pud=000000000174f003,
      				*pmd=0000000001750003, *pte=00e8000001751713
      Internal error: Oops: 96000005 [#1] PREEMPT SMP
      Modules linked in: uinput uvcvideo videobuf2_vmalloc cmac
      ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat rfcomm
      xt_mark fuse bridge stp llc zram btusb btrtl btbcm btintel bluetooth
      ip6table_filter mwifiex_pcie mwifiex cfg80211 cdc_ether usbnet r8152 mii joydev
      snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq snd_seq_device ppp_async
      ppp_generic slhc tun
      CPU: 1 PID: 29814 Comm: kworker/1:1 Not tainted 4.4.52 #507
      Hardware name: Google Kevin (DT)
      Workqueue: pm pm_runtime_work
      task: ffffffc0ac540000 ti: ffffffc0af4d4000 task.ti: ffffffc0af4d4000
      PC is at autosuspend_check+0x74/0x174
      LR is at autosuspend_check+0x70/0x174
      ...
      Call trace:
      [<ffffffc00080dcc0>] autosuspend_check+0x74/0x174
      [<ffffffc000810500>] usb_runtime_idle+0x20/0x40
      [<ffffffc000785ae0>] __rpm_callback+0x48/0x7c
      [<ffffffc000786af0>] rpm_idle+0x1e8/0x498
      [<ffffffc000787cdc>] pm_runtime_work+0x88/0xcc
      [<ffffffc000249bb8>] process_one_work+0x390/0x6b8
      [<ffffffc00024abcc>] worker_thread+0x480/0x610
      [<ffffffc000251a80>] kthread+0x164/0x178
      [<ffffffc0002045d0>] ret_from_fork+0x10/0x40
      
      Source:
      
      (gdb) l *0xffffffc00080dcc0
      0xffffffc00080dcc0 is in autosuspend_check
      (drivers/usb/core/driver.c:1778).
      1773		/* We don't need to check interfaces that are
      1774		 * disabled for runtime PM.  Either they are unbound
      1775		 * or else their drivers don't support autosuspend
      1776		 * and so they are permanently active.
      1777		 */
      1778		if (intf->dev.power.disable_depth)
      1779			continue;
      1780		if (atomic_read(&intf->dev.power.usage_count) > 0)
      1781			return -EBUSY;
      1782		w |= intf->needs_remote_wakeup;
      
      Code analysis shows that intf is set to NULL in usb_disable_device() prior
      to setting actconfig to NULL. At the same time, usb_runtime_idle() does not
      lock the usb device, and neither does any of the functions in the
      traceback. This means that there is no protection against a race condition
      where usb_disable_device() is removing dev->actconfig->interface[] pointers
      while those are being accessed from autosuspend_check().
      
      To solve the problem, synchronize and validate device state between
      autosuspend_check() and usb_disconnect().
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f5cccf49
    • G
      usb: hub: Fix error loop seen after hub communication errors · 245b2eec
      Guenter Roeck 提交于
      While stress testing a usb controller using a bind/unbind looop, the
      following error loop was observed.
      
      usb 7-1.2: new low-speed USB device number 3 using xhci-hcd
      usb 7-1.2: hub failed to enable device, error -108
      usb 7-1-port2: cannot disable (err = -22)
      usb 7-1-port2: couldn't allocate usb_device
      usb 7-1-port2: cannot disable (err = -22)
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: activate --> -22
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: activate --> -22
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: activate --> -22
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: activate --> -22
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: activate --> -22
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: activate --> -22
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: activate --> -22
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: activate --> -22
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      ** 57 printk messages dropped ** hub 7-1:1.0: activate --> -22
      ** 82 printk messages dropped ** hub 7-1:1.0: hub_ext_port_status failed (err = -22)
      
      This continues forever. After adding tracebacks into the code,
      the call sequence leading to this is found to be as follows.
      
      [<ffffffc0007fc8e0>] hub_activate+0x368/0x7b8
      [<ffffffc0007fceb4>] hub_resume+0x2c/0x3c
      [<ffffffc00080b3b8>] usb_resume_interface.isra.6+0x128/0x158
      [<ffffffc00080b5d0>] usb_suspend_both+0x1e8/0x288
      [<ffffffc00080c9c4>] usb_runtime_suspend+0x3c/0x98
      [<ffffffc0007820a0>] __rpm_callback+0x48/0x7c
      [<ffffffc00078217c>] rpm_callback+0xa8/0xd4
      [<ffffffc000786234>] rpm_suspend+0x84/0x758
      [<ffffffc000786ca4>] rpm_idle+0x2c8/0x498
      [<ffffffc000786ed4>] __pm_runtime_idle+0x60/0xac
      [<ffffffc00080eba8>] usb_autopm_put_interface+0x6c/0x7c
      [<ffffffc000803798>] hub_event+0x10ac/0x12ac
      [<ffffffc000249bb8>] process_one_work+0x390/0x6b8
      [<ffffffc00024abcc>] worker_thread+0x480/0x610
      [<ffffffc000251a80>] kthread+0x164/0x178
      [<ffffffc0002045d0>] ret_from_fork+0x10/0x40
      
      kick_hub_wq() is called from hub_activate() even after failures to
      communicate with the hub. This results in an endless sequence of
      hub event -> hub activate -> wq trigger -> hub event -> ...
      
      Provide two solutions for the problem.
      
      - Only trigger the hub event queue if communication with the hub
        is successful.
      - After a suspend failure, only resume already suspended interfaces
        if the communication with the device is still possible.
      
      Each of the changes fixes the observed problem. Use both to improve
      robustness.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      245b2eec
  30. 17 3月, 2017 1 次提交
    • G
      usb: hub: Fix crash after failure to read BOS descriptor · 7b2db29f
      Guenter Roeck 提交于
      If usb_get_bos_descriptor() returns an error, usb->bos will be NULL.
      Nevertheless, it is dereferenced unconditionally in
      hub_set_initial_usb2_lpm_policy() if usb2_hw_lpm_capable is set.
      This results in a crash.
      
      usb 5-1: unable to get BOS descriptor
      ...
      Unable to handle kernel NULL pointer dereference at virtual address 00000008
      pgd = ffffffc00165f000
      [00000008] *pgd=000000000174f003, *pud=000000000174f003,
      		*pmd=0000000001750003, *pte=00e8000001751713
      Internal error: Oops: 96000005 [#1] PREEMPT SMP
      Modules linked in: uinput uvcvideo videobuf2_vmalloc cmac [ ... ]
      CPU: 5 PID: 3353 Comm: kworker/5:3 Tainted: G    B 4.4.52 #480
      Hardware name: Google Kevin (DT)
      Workqueue: events driver_set_config_work
      task: ffffffc0c3690000 ti: ffffffc0ae9a8000 task.ti: ffffffc0ae9a8000
      PC is at hub_port_init+0xc3c/0xd10
      LR is at hub_port_init+0xc3c/0xd10
      ...
      Call trace:
      [<ffffffc0007fbbfc>] hub_port_init+0xc3c/0xd10
      [<ffffffc0007fbe2c>] usb_reset_and_verify_device+0x15c/0x82c
      [<ffffffc0007fc5e0>] usb_reset_device+0xe4/0x298
      [<ffffffbffc0e3fcc>] rtl8152_probe+0x84/0x9b0 [r8152]
      [<ffffffc00080ca8c>] usb_probe_interface+0x244/0x2f8
      [<ffffffc000774a24>] driver_probe_device+0x180/0x3b4
      [<ffffffc000774e48>] __device_attach_driver+0xb4/0xe0
      [<ffffffc000772168>] bus_for_each_drv+0xb4/0xe4
      [<ffffffc0007747ec>] __device_attach+0xd0/0x158
      [<ffffffc000775080>] device_initial_probe+0x24/0x30
      [<ffffffc0007739d4>] bus_probe_device+0x50/0xe4
      [<ffffffc000770bd0>] device_add+0x414/0x738
      [<ffffffc000809fe8>] usb_set_configuration+0x89c/0x914
      [<ffffffc00080a120>] driver_set_config_work+0xc0/0xf0
      [<ffffffc000249bb8>] process_one_work+0x390/0x6b8
      [<ffffffc00024abcc>] worker_thread+0x480/0x610
      [<ffffffc000251a80>] kthread+0x164/0x178
      [<ffffffc0002045d0>] ret_from_fork+0x10/0x40
      
      Since we don't know anything about LPM capabilities without BOS descriptor,
      don't attempt to enable LPM if it is not available.
      
      Fixes: 890dae88 ("xhci: Enable LPM support only for hardwired ...")
      Cc: stable <stable@vger.kernel.org>
      Cc: Mathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Acked-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b2db29f
  31. 02 3月, 2017 1 次提交
  32. 06 1月, 2017 1 次提交
  33. 25 12月, 2016 1 次提交