1. 11 10月, 2017 1 次提交
  2. 18 4月, 2017 1 次提交
  3. 23 3月, 2017 3 次提交
  4. 24 10月, 2016 1 次提交
  5. 04 5月, 2016 1 次提交
    • A
      USB: leave LPM alone if possible when binding/unbinding interface drivers · 6fb650d4
      Alan Stern 提交于
      When a USB driver is bound to an interface (either through probing or
      by claiming it) or is unbound from an interface, the USB core always
      disables Link Power Management during the transition and then
      re-enables it afterward.  The reason is because the driver might want
      to prevent hub-initiated link power transitions, in which case the HCD
      would have to recalculate the various LPM parameters.  This
      recalculation takes place when LPM is re-enabled and the new
      parameters are sent to the device and its parent hub.
      
      However, if the driver does not want to prevent hub-initiated link
      power transitions then none of this work is necessary.  The parameters
      don't need to be recalculated, and LPM doesn't need to be disabled and
      re-enabled.
      
      It turns out that disabling and enabling LPM can be time-consuming,
      enough so that it interferes with user programs that want to claim and
      release interfaces rapidly via usbfs.  Since the usbfs kernel driver
      doesn't set the disable_hub_initiated_lpm flag, we can speed things up
      and get the user programs to work by leaving LPM alone whenever the
      flag isn't set.
      
      And while we're improving the way disable_hub_initiated_lpm gets used,
      let's also fix its kerneldoc.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Tested-by: NMatthew Giassa <matthew@giassa.net>
      CC: Mathias Nyman <mathias.nyman@intel.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6fb650d4
  6. 29 4月, 2016 1 次提交
    • C
      usb: core: hub: hub_port_init lock controller instead of bus · feb26ac3
      Chris Bainbridge 提交于
      The XHCI controller presents two USB buses to the system - one for USB2
      and one for USB3. The hub init code (hub_port_init) is reentrant but
      only locks one bus per thread, leading to a race condition failure when
      two threads attempt to simultaneously initialise a USB2 and USB3 device:
      
      [    8.034843] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
      [   13.183701] usb 3-3: device descriptor read/all, error -110
      
      On a test system this failure occurred on 6% of all boots.
      
      The call traces at the point of failure are:
      
      Call Trace:
       [<ffffffff81b9bab7>] schedule+0x37/0x90
       [<ffffffff817da7cd>] usb_kill_urb+0x8d/0xd0
       [<ffffffff8111e5e0>] ? wake_up_atomic_t+0x30/0x30
       [<ffffffff817dafbe>] usb_start_wait_urb+0xbe/0x150
       [<ffffffff817db10c>] usb_control_msg+0xbc/0xf0
       [<ffffffff817d07de>] hub_port_init+0x51e/0xb70
       [<ffffffff817d4697>] hub_event+0x817/0x1570
       [<ffffffff810f3e6f>] process_one_work+0x1ff/0x620
       [<ffffffff810f3dcf>] ? process_one_work+0x15f/0x620
       [<ffffffff810f4684>] worker_thread+0x64/0x4b0
       [<ffffffff810f4620>] ? rescuer_thread+0x390/0x390
       [<ffffffff810fa7f5>] kthread+0x105/0x120
       [<ffffffff810fa6f0>] ? kthread_create_on_node+0x200/0x200
       [<ffffffff81ba183f>] ret_from_fork+0x3f/0x70
       [<ffffffff810fa6f0>] ? kthread_create_on_node+0x200/0x200
      
      Call Trace:
       [<ffffffff817fd36d>] xhci_setup_device+0x53d/0xa40
       [<ffffffff817fd87e>] xhci_address_device+0xe/0x10
       [<ffffffff817d047f>] hub_port_init+0x1bf/0xb70
       [<ffffffff811247ed>] ? trace_hardirqs_on+0xd/0x10
       [<ffffffff817d4697>] hub_event+0x817/0x1570
       [<ffffffff810f3e6f>] process_one_work+0x1ff/0x620
       [<ffffffff810f3dcf>] ? process_one_work+0x15f/0x620
       [<ffffffff810f4684>] worker_thread+0x64/0x4b0
       [<ffffffff810f4620>] ? rescuer_thread+0x390/0x390
       [<ffffffff810fa7f5>] kthread+0x105/0x120
       [<ffffffff810fa6f0>] ? kthread_create_on_node+0x200/0x200
       [<ffffffff81ba183f>] ret_from_fork+0x3f/0x70
       [<ffffffff810fa6f0>] ? kthread_create_on_node+0x200/0x200
      
      Which results from the two call chains:
      
      hub_port_init
       usb_get_device_descriptor
        usb_get_descriptor
         usb_control_msg
          usb_internal_control_msg
           usb_start_wait_urb
            usb_submit_urb / wait_for_completion_timeout / usb_kill_urb
      
      hub_port_init
       hub_set_address
        xhci_address_device
         xhci_setup_device
      
      Mathias Nyman explains the current behaviour violates the XHCI spec:
      
       hub_port_reset() will end up moving the corresponding xhci device slot
       to default state.
      
       As hub_port_reset() is called several times in hub_port_init() it
       sounds reasonable that we could end up with two threads having their
       xhci device slots in default state at the same time, which according to
       xhci 4.5.3 specs still is a big no no:
      
       "Note: Software shall not transition more than one Device Slot to the
        Default State at a time"
      
       So both threads fail at their next task after this.
       One fails to read the descriptor, and the other fails addressing the
       device.
      
      Fix this in hub_port_init by locking the USB controller (instead of an
      individual bus) to prevent simultaneous initialisation of both buses.
      
      Fixes: 638139eb ("usb: hub: allow to process more usb hub events in parallel")
      Link: https://lkml.org/lkml/2016/2/8/312
      Link: https://lkml.org/lkml/2016/2/4/748Signed-off-by: NChris Bainbridge <chris.bainbridge@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      feb26ac3
  7. 27 4月, 2016 2 次提交
  8. 15 2月, 2016 2 次提交
  9. 04 2月, 2016 2 次提交
  10. 02 12月, 2015 2 次提交
  11. 04 10月, 2015 1 次提交
  12. 29 9月, 2015 1 次提交
  13. 23 9月, 2015 1 次提交
  14. 19 8月, 2015 1 次提交
  15. 15 8月, 2015 1 次提交
  16. 08 4月, 2015 1 次提交
    • F
      usb: define a generic USB_RESUME_TIMEOUT macro · 62f0342d
      Felipe Balbi 提交于
      Every USB Host controller should use this new
      macro to define for how long resume signalling
      should be driven on the bus.
      
      Currently, almost every single USB controller
      is using a 20ms timeout for resume signalling.
      
      That's problematic for two reasons:
      
      a) sometimes that 20ms timer expires a little
      before 20ms, which makes us fail certification
      
      b) some (many) devices actually need more than
      20ms resume signalling.
      
      Sure, in case of (b) we can state that the device
      is against the USB spec, but the fact is that
      we have no control over which device the certification
      lab will use. We also have no control over which host
      they will use. Most likely they'll be using a Windows
      PC which, again, we have no control over how that
      USB stack is written and how long resume signalling
      they are using.
      
      At the end of the day, we must make sure Linux passes
      electrical compliance when working as Host or as Device
      and currently we don't pass compliance as host because
      we're driving resume signallig for exactly 20ms and
      that confuses certification test setup resulting in
      Certification failure.
      
      Cc: <stable@vger.kernel.org> # v3.10+
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      62f0342d
  17. 25 1月, 2015 2 次提交
  18. 04 12月, 2014 1 次提交
  19. 25 9月, 2014 1 次提交
    • M
      usb: Add LED triggers for USB activity · 0cfbd328
      Michal Sojka 提交于
      With this patch, USB activity can be signaled by blinking a LED. There
      are two triggers, one for activity on USB host and one for USB gadget.
      
      Both triggers should work with all host/device controllers. Tested only
      with musb.
      
      Performace: I measured performance overheads on ARM Cortex-A8 (TI
      AM335x) running on 600 MHz.
      
      Duration of usb_led_activity():
      - with no LED attached to the trigger:        2 ± 1 µs
      - with one GPIO LED attached to the trigger:  2 ± 1 µs or 8 ± 2 µs (two peaks in histogram)
      
      Duration of functions calling usb_led_activity() (with this patch
      applied and no LED attached to the trigger):
      - __usb_hcd_giveback_urb():    10 - 25 µs
      - usb_gadget_giveback_request(): 2 - 6 µs
      Signed-off-by: NMichal Sojka <sojka@merica.cz>
      Acked-by: NFelipe Balbi <balbi@ti.com>
      Tested-by: NFelipe Balbi <balbi@ti.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0cfbd328
  20. 28 5月, 2014 1 次提交
    • T
      USB: separate usb_address0 mutexes for each bus · 6fecd4f2
      Todd E Brandt 提交于
      This patch creates a separate instance of the usb_address0 mutex for each USB
      bus, and attaches it to the usb_bus device struct. This allows devices on
      separate buses to be enumerated in parallel; saving time.
      
      In the current code, there is a single, global instance of the usb_address0
      mutex which is used for all devices on all buses. This isn't completely
      necessary, as this mutex is only needed to prevent address0 collisions for
      devices on the *same* bus (usb 2.0 spec, sec 4.6.1). This superfluous coverage
      can cause additional delay in system resume on systems with multiple hosts
      (up to several seconds depending on what devices are attached).
      Signed-off-by: NTodd Brandt <todd.e.brandt@linux.intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6fecd4f2
  21. 11 3月, 2014 1 次提交
  22. 09 3月, 2014 1 次提交
  23. 05 3月, 2014 2 次提交
  24. 08 2月, 2014 2 次提交
  25. 11 1月, 2014 1 次提交
  26. 03 12月, 2013 1 次提交
    • D
      usb: xhci: Link TRB must not occur within a USB payload burst · 35773dac
      David Laight 提交于
      Section 4.11.7.1 of rev 1.0 of the xhci specification states that a link TRB
      can only occur at a boundary between underlying USB frames (512 bytes for
      high speed devices).
      
      If this isn't done the USB frames aren't formatted correctly and, for example,
      the USB3 ethernet ax88179_178a card will stop sending (while still receiving)
      when running a netperf tcp transmit test with (say) and 8k buffer.
      
      This should be a candidate for stable, the ax88179_178a driver defaults to
      gso and tso enabled so it passes a lot of fragmented skb to the USB stack.
      
      Notes from Sarah:
      
      Discussion: http://marc.info/?l=linux-usb&m=138384509604981&w=2
      
      This patch fixes a long-standing xHCI driver bug that was revealed by a
      change in 3.12 in the usb-net driver.  Commit
      638c5115 "USBNET: support DMA SG" added
      support to use bulk endpoint scatter-gather (urb->sg).  Only the USB
      ethernet drivers trigger this bug, because the mass storage driver sends
      sg list entries in page-sized chunks.
      
      This patch only fixes the issue for bulk endpoint scatter-gather.  The
      problem will still occur for periodic endpoints, because hosts will
      interpret no-op transfers as a request to skip a service interval, which
      is not what we want.
      
      Luckily, the USB core isn't set up for scatter-gather on isochronous
      endpoints, and no USB drivers use scatter-gather for interrupt
      endpoints.  Document this known limitation so that developers won't try
      to use urb->sg for interrupt endpoints until this issue is fixed.  The
      more comprehensive fix would be to allow link TRBs in the middle of the
      endpoint ring and revert this patch, but that fix would touch too much
      code to be allowed in for stable.
      
      This patch should be backported to kernels as old as 3.12, that contain
      the commit 638c5115 "USBNET: support DMA
      SG".  Without this patch, the USB network device gets wedged, and stops
      sending packets.  Mark Lord confirms this patch fixes the regression:
      
      http://marc.info/?l=linux-netdev&m=138487107625966&w=2Signed-off-by: NDavid Laight <david.laight@aculab.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NMark Lord <mlord@pobox.com>
      Cc: stable@vger.kernel.org
      35773dac
  27. 17 10月, 2013 1 次提交
    • S
      usb: Don't enable USB 2.0 Link PM by default. · de68bab4
      Sarah Sharp 提交于
      How it's supposed to work:
      --------------------------
      
      USB 2.0 Link PM is a lower power state that some newer USB 2.0 devices
      support.  USB 3.0 devices certified by the USB-IF are required to
      support it if they are plugged into a USB 2.0 only port, or a USB 2.0
      cable is used.  USB 2.0 Link PM requires both a USB device and a host
      controller that supports USB 2.0 hardware-enabled LPM.
      
      USB 2.0 Link PM is designed to be enabled once by software, and the host
      hardware handles transitions to the L1 state automatically.  The premise
      of USB 2.0 Link PM is to be able to put the device into a lower power
      link state when the bus is idle or the device NAKs USB IN transfers for
      a specified amount of time.
      
      ...but hardware is broken:
      --------------------------
      
      It turns out many USB 3.0 devices claim to support USB 2.0 Link PM (by
      setting the LPM bit in their USB 2.0 BOS descriptor), but they don't
      actually implement it correctly.  This manifests as the USB device
      refusing to respond to transfers when it is plugged into a USB 2.0 only
      port under the Haswell-ULT/Lynx Point LP xHCI host.
      
      These devices pass the xHCI driver's simple test to enable USB 2.0 Link
      PM, wait for the port to enter L1, and then bring it back into L0.  They
      only start to break when L1 entry is interleaved with transfers.
      
      Some devices then fail to respond to the next control transfer (usually
      a Set Configuration).  This results in devices never enumerating.
      
      Other mass storage devices (such as a later model Western Digital My
      Passport USB 3.0 hard drive) respond fine to going into L1 between
      control transfers.  They ACK the entry, come out of L1 when the host
      needs to send a control transfer, and respond properly to those control
      transfers.  However, when the first READ10 SCSI command is sent, the
      device NAKs the data phase while it's reading from the spinning disk.
      Eventually, the host requests to put the link into L1, and the device
      ACKs that request.  Then it never responds to the data phase of the
      READ10 command.  This results in not being able to read from the drive.
      
      Some mass storage devices (like the Corsair Survivor USB 3.0 flash
      drive) are well behaved.  They ACK the entry into L1 during control
      transfers, and when SCSI commands start coming in, they NAK the requests
      to go into L1, because they need to be at full power.
      
      Not all USB 3.0 devices advertise USB 2.0 link PM support.  My Point
      Grey USB 3.0 webcam advertises itself as a USB 2.1 device, but doesn't
      have a USB 2.0 BOS descriptor, so we don't enable USB 2.0 Link PM.  I
      suspect that means the device isn't certified.
      
      What do we do about it?
      -----------------------
      
      There's really no good way for the kernel to test these devices.
      Therefore, the kernel needs to disable USB 2.0 Link PM by default, and
      distros will have to enable it by writing 1 to the sysfs file
      /sys/bus/usb/devices/../power/usb2_hardware_lpm.  Rip out the xHCI Link
      PM test, since it's not sufficient to detect these buggy devices, and
      don't automatically enable LPM after the device is addressed.
      
      This patch should be backported to kernels as old as 3.11, that
      contain the commit a558ccdc "usb: xhci:
      add USB2 Link power management BESL support".  Without this fix, some
      USB 3.0 devices will not enumerate or work properly under USB 2.0 ports
      on Haswell-ULT systems.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      de68bab4
  28. 12 10月, 2013 2 次提交
    • H
      usb-anchor: Delay usb_wait_anchor_empty_timeout wake up till completion is done · 6ec4147e
      Hans de Goede 提交于
      usb_wait_anchor_empty_timeout() should wait till the completion handler
      has run. Both the zd1211rw driver and the uas driver (in its task mgmt) depend
      on the completion handler having completed when usb_wait_anchor_empty_timeout()
      returns, as they read state set by the completion handler after an
      usb_wait_anchor_empty_timeout() call.
      
      But __usb_hcd_giveback_urb() calls usb_unanchor_urb before calling the
      completion handler. This is necessary as the completion handler may
      re-submit and re-anchor the urb. But this introduces a race where the state
      these drivers want to read has not been set yet by the completion handler
      (this race is easily triggered with the uas task mgmt code).
      
      I've considered adding an anchor_count to struct urb, which would be
      incremented on anchor and decremented on unanchor, and then only actually
      do the anchor / unanchor on 0 -> 1 and 1 -> 0 transtions, combined with
      moving the unanchor call in hcd_giveback_urb to after calling the completion
      handler. But this will only work if urb's are only re-anchored to the same
      anchor as they were anchored to before the completion handler ran.
      
      And at least one driver re-anchors to another anchor from the completion
      handler (rtlwifi).
      
      So I have come up with this patch instead, which adds the ability to
      suspend wakeups of usb_wait_anchor_empty_timeout() waiters to the usb_anchor
      functionality, and uses this in __usb_hcd_giveback_urb() to delay wake-ups
      until the completion handler has run.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Acked-by: NOliver Neukum <oliver@neukum.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ec4147e
    • H
      usb-anchor: Ensure poisened gets initialized to 0 · 9ef73dbd
      Hans de Goede 提交于
      And do so in a way which ensures that any fields added in the future will
      also get properly zero-ed.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Acked-by: NOliver Neukum <oliver@neukum.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ef73dbd
  29. 18 9月, 2013 1 次提交
  30. 13 8月, 2013 1 次提交