1. 24 5月, 2014 1 次提交
    • A
      USB: Avoid runtime suspend loops for HCDs that can't handle suspend/resume · 8ef42ddd
      Alan Stern 提交于
      Not all host controller drivers have bus-suspend and bus-resume
      methods.  When one doesn't, it will cause problems if runtime PM is
      enabled in the kernel.  The PM core will attempt to suspend the
      controller's root hub, the suspend will fail because there is no
      bus-suspend routine, and a -EBUSY error code will be returned to the
      PM core.  This will cause the suspend attempt to be repeated shortly
      thereafter, in a never-ending loop.
      
      Part of the problem is that the original error code -ENOENT gets
      changed to -EBUSY in usb_runtime_suspend(), on the grounds that the PM
      core will interpret -ENOENT as meaning that the root hub has gotten
      into a runtime-PM error state.  While this change is appropriate for
      real USB devices, it's not such a good idea for a root hub.  In fact,
      considering the root hub to be in a runtime-PM error state would not
      be far from the truth.  Therefore this patch updates
      usb_runtime_suspend() so that it adjusts error codes only for
      non-root-hub devices.
      
      Furthermore, the patch attempts to prevent the problem from occurring
      in the first place by not enabling runtime PM by default for root hubs
      whose host controller driver doesn't have bus_suspend and bus_resume
      methods.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NWill Deacon <will.deacon@arm.com>
      Tested-by: NWill Deacon <will.deacon@arm.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8ef42ddd
  2. 20 3月, 2014 1 次提交
    • A
      USB: disable reset-resume when USB_QUIRK_RESET is set · 1d10255c
      Alan Stern 提交于
      The USB_QUIRK_RESET flag indicates that a USB device changes its
      identity in some way when it is reset.  It may lose its firmware, its
      descriptors may change, or it may switch back to a default mode of
      operation.
      
      If a device does this, the kernel needs to avoid resetting it.  Resets
      are likely to fail, or worse, succeed while changing the device's
      state in a way the system can't detect.
      
      This means we should disable the reset-resume mechanism whenever this
      quirk flag is present.  An attempted reset-resume will fail, the
      device will be logically disconnected, and later on the hub driver
      will rediscover and re-enumerate the device.  This will cause the
      appropriate udev events to be generated, so that userspace will have a
      chance to switch the device into its normal operating mode, if
      necessary.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Oliver Neukum <oliver@neukum.org>
      Reviewed-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1d10255c
  3. 18 3月, 2014 1 次提交
    • A
      USB: unbind all interfaces before rebinding any · 6aec044c
      Alan Stern 提交于
      When a driver doesn't have pre_reset, post_reset, or reset_resume
      methods, the USB core unbinds that driver when its device undergoes a
      reset or a reset-resume, and then rebinds it afterward.
      
      The existing straightforward implementation can lead to problems,
      because each interface gets unbound and rebound before the next
      interface is handled.  If a driver claims additional interfaces, the
      claim may fail because the old binding instance may still own the
      additional interface when the new instance tries to claim it.
      
      This patch fixes the problem by first unbinding all the interfaces
      that are marked (i.e., their needs_binding flag is set) and then
      rebinding all of them.
      
      The patch also makes the helper functions in driver.c a little more
      uniform and adjusts some out-of-date comments.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-and-tested-by: N"Poulain, Loic" <loic.poulain@intel.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6aec044c
  4. 11 3月, 2014 1 次提交
  5. 09 3月, 2014 1 次提交
  6. 07 3月, 2014 1 次提交
    • T
      usb: don't use PREPARE_DELAYED_WORK · 77fa83cf
      Tejun Heo 提交于
      PREPARE_[DELAYED_]WORK() are being phased out.  They have few users
      and a nasty surprise in terms of reentrancy guarantee as workqueue
      considers work items to be different if they don't have the same work
      function.
      
      usb_hub->init_work is multiplexed with multiple work functions;
      however, the work item is never queued while in-flight, so we can
      simply use INIT_DELAYED_WORK() before each queueing.
      
      It would probably be best to route this with other related updates
      through the workqueue tree.
      
      Lightly tested.
      
      v2: Greg and Alan confirm that the work item is never queued while
          in-flight.  Simply use INIT_DELAYED_WORK().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: linux-usb@vger.kernel.org
      77fa83cf
  7. 05 3月, 2014 3 次提交
    • H
      usb: Reset USB-3 devices on USB-3 link bounce · a82b76f7
      Hans de Goede 提交于
      On disconnect USB3 protocol ports transit from U0 to SS.Inactive to Rx.Detect,
      on a recoverable error, the port stays in SS.Inactive and we recover from it by
      doing a warm-reset (through usb_device_reset if we have a udev for the port).
      
      If this really is a disconnect we may end up trying the warm-reset anyways,
      since khubd may run before the SS.Inactive to Rx.Detect transition, or it
      may get skipped if the transition to Rx.Detect happens before khubd gets run.
      
      With a loose connector, or in the case which actually led me to debugging this
      bad ACPI firmware toggling Vbus off and on in quick succession, the port
      may transition from Rx.Detect to U0 again before khubd gets run. In this case
      the device state is unknown really, but khubd happily goes into the resuscitate
      an existing device path, and the device driver never gets notified about the
      device state being messed up.
      
      If the above scenario happens with a streams using device, as soon as an urb
      is submitted to an endpoint with streams, the following appears in dmesg:
      
      ERROR Transfer event for disabled endpoint or incorrect stream ring
      @0000000036807420 00000000 00000000 04000000 04078000
      
      Notice how the TRB address is all zeros. I've seen this both on Intel
      Pantherpoint and Nec xhci hosts.
      
      Luckily we can detect the U0 to SS.Inactive to Rx.Detect to U0 all having
      happened before khubd runs case since the C_LINK_STATE bit gets set in the
      portchange bits on the U0 -> SS.Inactive change. This bit will also be set on
      suspend / resume, but then it gets cleared by port_hub_init before khubd runs.
      
      So if the C_LINK_STATE bit is set and a warm-reset is not needed, iow the port
      is not still in SS.Inactive, and the port still has a connection, then the
      device needs to be reset to put it back in a known state.
      
      I've verified that doing the device reset also fixes the transfer event with
      all zeros address issue.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      a82b76f7
    • H
      usb: Clear host_endpoint->streams when implicitly freeing streams · 7a7b562d
      Hans de Goede 提交于
      If streams are still allocated on device-reset or set-interface then the hcd
      code implictly frees the streams. Clear host_endpoint->streams in this case
      so that if a driver later tries to re-allocate them it won't run afoul of the
      device already having streams check in usb_alloc_streams().
      
      Note normally streams still being allocated at reset / set-intf  would be a
      driver bug, but this can happen without it being a driver bug on reset-resume.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      7a7b562d
    • S
      usb/xhci: Change how we indicate a host supports Link PM. · 25cd2882
      Sarah Sharp 提交于
      The xHCI driver currently uses a USB core internal field,
      udev->lpm_capable, to indicate the xHCI driver knows how to calculate
      the LPM timeout values.  If this value is set for the host controller
      udev, it means Link PM can be enabled for child devices under that host.
      
      Change the code so the xHCI driver isn't mucking with USB core internal
      fields.  Instead, indicate the xHCI driver doesn't support Link PM on
      this host by clearing the U1 and U2 exit latencies in the roothub
      SuperSpeed Extended Capabilities BOS descriptor.
      
      The code to check for the roothub setting U1 and U2 exit latencies to
      zero will also disable LPM for external devices that do that same.  This
      was already effectively done with commit
      ae8963ad "usb: Don't enable LPM if the
      exit latency is zero."  Leave that code in place, so that if a device
      sets one exit latency value to zero, but the other is set to a valid
      value, LPM is only enabled for the U1 or U2 state that had the valid
      value.  This is the same behavior the code had before.
      
      Also, change messages about missing Link PM information from warning
      level to info level.  Only print a warning about the first device that
      doesn't support LPM, to avoid log spam.  Further, cleanup some
      unnecessary line breaks to help people to grep for the error messages.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      25cd2882
  8. 01 3月, 2014 2 次提交
  9. 08 2月, 2014 1 次提交
  10. 23 1月, 2014 1 次提交
    • S
      Revert "usbcore: set lpm_capable field for LPM capable root hubs" · 140e3026
      Sarah Sharp 提交于
      Commit 9df89d85 "usbcore: set
      lpm_capable field for LPM capable root hubs" was created under the
      assumption that all USB host controllers should have USB 3.0 Link PM
      enabled for all devices under the hosts.
      
      Unfortunately, that's not the case.  The xHCI driver relies on knowledge
      of the host hardware scheduler to calculate the LPM U1/U2 timeout
      values, and it only sets lpm_capable to one for Intel host controllers
      (that have the XHCI_LPM_SUPPORT quirk set).
      
      When LPM is enabled for some Fresco Logic hosts, it causes failures with
      a AgeStar 3UBT USB 3.0 hard drive dock:
      
      Jan 11 13:59:03 sg-laptop kernel: usb 3-1: new SuperSpeed USB device number 2 using xhci_hcd
      Jan 11 13:59:03 sg-laptop kernel: usb 3-1: Set SEL for device-initiated U1 failed.
      Jan 11 13:59:08 sg-laptop kernel: usb 3-1: Set SEL for device-initiated U2 failed.
      Jan 11 13:59:08 sg-laptop kernel: usb-storage 3-1:1.0: USB Mass Storage device detected
      Jan 11 13:59:08 sg-laptop mtp-probe[613]: checking bus 3, device 2: "/sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb3/3-1"
      Jan 11 13:59:08 sg-laptop mtp-probe[613]: bus: 3, device: 2 was not an MTP device
      Jan 11 13:59:08 sg-laptop kernel: scsi6 : usb-storage 3-1:1.0
      Jan 11 13:59:13 sg-laptop kernel: usb 3-1: Set SEL for device-initiated U1 failed.
      Jan 11 13:59:18 sg-laptop kernel: usb 3-1: Set SEL for device-initiated U2 failed.
      Jan 11 13:59:18 sg-laptop kernel: usbcore: registered new interface driver usb-storage
      Jan 11 13:59:40 sg-laptop kernel: usb 3-1: reset SuperSpeed USB device number 2 using xhci_hcd
      Jan 11 13:59:41 sg-laptop kernel: usb 3-1: device descriptor read/8, error -71
      Jan 11 13:59:41 sg-laptop kernel: usb 3-1: reset SuperSpeed USB device number 2 using xhci_hcd
      Jan 11 13:59:46 sg-laptop kernel: usb 3-1: device descriptor read/8, error -110
      Jan 11 13:59:46 sg-laptop kernel: scsi 6:0:0:0: Device offlined - not ready after error recovery
      Jan 11 13:59:46 sg-laptop kernel: usb 3-1: USB disconnect, device number 2
      
      lspci for the affected host:
      
      04:00.0 0c03: 1b73:1000 (rev 04) (prog-if 30 [XHCI])
              Subsystem: 1043:1039
              Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
              Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
              Latency: 0, Cache Line Size: 64 bytes
              Interrupt: pin A routed to IRQ 19
              Region 0: Memory at dd200000 (32-bit, non-prefetchable) [size=64K]
              Capabilities: [50] Power Management version 3
                      Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold-)
                      Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
              Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
                      Address: 0000000000000000  Data: 0000
              Capabilities: [80] Express (v1) Endpoint, MSI 00
                      DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <2us, L1 <32us
                              ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
                      DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
                              RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
                              MaxPayload 128 bytes, MaxReadReq 512 bytes
                      DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
                      LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 unlimited, L1 unlimited
                              ClockPM- Surprise- LLActRep- BwNot-
                      LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
                              ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
                      LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
              Kernel driver in use: xhci_hcd
              Kernel modules: xhci_hcd
      
      The commit was backported to stable kernels, and will need to be
      reverted there as well.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@intel.com>
      Reported-by: NSergey Galanov <sergey.e.galanov@gmail.com>
      Cc: stable@vger.kernel.org
      140e3026
  11. 09 1月, 2014 1 次提交
  12. 08 1月, 2014 2 次提交
    • R
    • A
      USB: fix race between hub_disconnect and recursively_mark_NOTATTACHED · 543d7784
      Alan Stern 提交于
      There is a race in the hub driver between hub_disconnect() and
      recursively_mark_NOTATTACHED().  This race can be triggered if the
      driver is unbound from a device at the same time as the bus's root hub
      is removed.  When the race occurs, it can cause an oops:
      
      BUG: unable to handle kernel NULL pointer dereference at 0000015c
      IP: [<c16d5fb0>] recursively_mark_NOTATTACHED+0x20/0x60
      Call Trace:
       [<c16d5fc4>] recursively_mark_NOTATTACHED+0x34/0x60
       [<c16d5fc4>] recursively_mark_NOTATTACHED+0x34/0x60
       [<c16d5fc4>] recursively_mark_NOTATTACHED+0x34/0x60
       [<c16d5fc4>] recursively_mark_NOTATTACHED+0x34/0x60
       [<c16d6082>] usb_set_device_state+0x92/0x120
       [<c16d862b>] usb_disconnect+0x2b/0x1a0
       [<c16dd4c0>] usb_remove_hcd+0xb0/0x160
       [<c19ca846>] ? _raw_spin_unlock_irqrestore+0x26/0x50
       [<c1704efc>] ehci_mid_remove+0x1c/0x30
       [<c1704f26>] ehci_mid_stop_host+0x16/0x30
       [<c16f7698>] penwell_otg_work+0xd28/0x3520
       [<c19c945b>] ? __schedule+0x39b/0x7f0
       [<c19cdb9d>] ? sub_preempt_count+0x3d/0x50
       [<c125e97d>] process_one_work+0x11d/0x3d0
       [<c19c7f4d>] ? mutex_unlock+0xd/0x10
       [<c125e0e5>] ? manage_workers.isra.24+0x1b5/0x270
       [<c125f009>] worker_thread+0xf9/0x320
       [<c19ca846>] ? _raw_spin_unlock_irqrestore+0x26/0x50
       [<c125ef10>] ? rescuer_thread+0x2b0/0x2b0
       [<c1264ac4>] kthread+0x94/0xa0
       [<c19d0f77>] ret_from_kernel_thread+0x1b/0x28
       [<c1264a30>] ? kthread_create_on_node+0xc0/0xc0
      
      One problem is that recursively_mark_NOTATTACHED() uses the intfdata
      value and hub->hdev->maxchild while hub_disconnect() is clearing them.
      Another problem is that it uses hub->ports[i] while the port device is
      being released.
      
      To fix this race, we need to hold the device_state_lock while
      hub_disconnect() changes the values.  (Note that usb_disconnect()
      and hub_port_connect_change() already acquire this lock at similar
      critical times during a USB device's life cycle.)  We also need to
      remove the port devices after maxchild has been set to 0, instead of
      before.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: N"Du, Changbin" <changbinx.du@intel.com>
      Tested-by: N"Du, Changbin" <changbinx.du@intel.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      543d7784
  13. 22 12月, 2013 1 次提交
    • G
      USB: core: remove CONFIG_USB_DEBUG usage · 3482528e
      Greg Kroah-Hartman 提交于
      CONFIG_USB_DEBUG is going away, so remove the few places in the USB core
      that relied on them.
      
      This means that we always now do the "debug" checks for every urb
      submitted, which is a good idea, as who knows how many driver bugs we
      have been ignoring when people forget to enable this option.  Also, with
      the overall speed of USB, doing these extra checks should not cause any
      additional overhead.
      
      Also, no longer announce all devices being added to the system if
      CONFIG_USB_DEBUG is enabled, as it's not going to be around much longer.
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3482528e
  14. 11 12月, 2013 1 次提交
    • D
      usb: xhci: change enumeration scheme to 'new scheme' by default · 48fc7dbd
      Dan Williams 提交于
      Change the default enumeration scheme for xhci attached non-SuperSpeed
      devices from:
      
         Reset
         SetAddress [xhci address-device BSR = 0]
         GetDescriptor(8)
         GetDescriptor(18)
      
      ...to:
      
         Reset
         [xhci address-device BSR = 1]
         GetDescriptor(64)
         Reset
         SetAddress [xhci address-device BSR = 0]
         GetDescriptor(18)
      
      ...as some devices misbehave when encountering a SetAddress command
      prior to GetDescriptor.  There are known legacy devices that require
      this scheme, but testing has found at least one USB3 device that fails
      enumeration when presented with this ordering.  For now, follow the ehci
      case and enable 'new scheme' by default for non-SuperSpeed devices.
      
      To support this enumeration scheme on xhci the AddressDevice operation
      needs to be performed twice.  The first instance of the command enables
      the HC's device and slot context info for the device, but omits sending
      the device a SetAddress command (BSR == block set address request).
      Then, after GetDescriptor completes, follow up with the full
      AddressDevice+SetAddress operation.
      
      As mentioned before, this ordering of events with USB3 devices causes an
      extra state transition to be exposed to xhci.  Previously USB3 devices
      would transition directly from 'enabled' to 'addressed' and never need
      to underrun responses to 'get descriptor'. We do see the 64-byte
      descriptor fetch the correct data, but the following 18-byte descriptor
      read after the reset gets:
      
      bLength            = 0
      bDescriptorType    = 0
      bcdUSB             = 0
      bDeviceClass       = 0
      bDeviceSubClass    = 0
      bDeviceProtocol    = 0
      bMaxPacketSize0    = 9
      
      instead of:
      
      bLength            = 12
      bDescriptorType    = 1
      bcdUSB             = 300
      bDeviceClass       = 0
      bDeviceSubClass    = 0
      bDeviceProtocol    = 0
      bMaxPacketSize0    = 9
      
      which results in the discovery process looping until falling back to
      'old scheme' enumeration.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NDavid Moore <david.moore@gmail.com>
      Suggested-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      48fc7dbd
  15. 10 12月, 2013 1 次提交
  16. 05 12月, 2013 1 次提交
  17. 15 11月, 2013 1 次提交
  18. 17 10月, 2013 5 次提交
    • D
      usb: hub_activate kill an 'else' · fd1ac4cf
      Dan Williams 提交于
      Remove a few extra lines and make it clear that all implementations
      disable the port by sharing the same line of code.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      fd1ac4cf
    • J
      usb: hub: Clear Port Reset Change during init/resume · e92aee33
      Julius Werner 提交于
      This patch adds the Port Reset Change flag to the set of bits that are
      preemptively cleared on init/resume of a hub. In theory this bit should
      never be set unexpectedly... in practice it can still happen if BIOS,
      SMM or ACPI code plays around with USB devices without cleaning up
      correctly. This is especially dangerous for XHCI root hubs, which don't
      generate any more Port Status Change Events until all change bits are
      cleared, so this is a good precaution to have (similar to how it's
      already done for the Warm Port Reset Change flag).
      Signed-off-by: NJulius Werner <jwerner@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>
      e92aee33
    • M
      xhci: Enable LPM support only for hardwired or BESL devices · 890dae88
      Mathias Nyman 提交于
      Some usb3 devices falsely claim they support usb2 hardware Link PM
      when connected to a usb2 port. We only trust hardwired devices
      or devices with the later BESL LPM support to be LPM enabled as default.
      
      [Note: Sarah re-worked the original patch to move the code into the USB
      core, and updated it to check whether the USB device supports BESL,
      instead of checking if the xHCI port it's connected to supports BESL
      encoding.]
      
      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: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      890dae88
    • 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
    • S
      usb: Disable USB 2.0 Link PM before device reset. · dcc01c08
      Sarah Sharp 提交于
      Before the USB core resets a device, we need to disable the L1 timeout
      for the roothub, if USB 2.0 Link PM is enabled.  Otherwise the port may
      transition into L1 in between descriptor fetches, before we know if the
      USB device descriptors changed.  LPM will be re-enabled after the
      full device descriptors are fetched, and we can confirm the device still
      supports USB 2.0 LPM after the reset.
      
      We don't need to wait for the USB device to exit L1 before resetting the
      device, since the xHCI roothub port diagrams show a transition to the
      Reset state from any of the Ux states (see Figure 34 in the 2012-08-14
      xHCI specification update).
      
      This patch should be backported to kernels as old as 3.2, that contain
      the commit 65580b43 "xHCI: set USB2
      hardware LPM".  That was the first commit to enable USB 2.0
      hardware-driven Link Power Management.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      dcc01c08
  19. 12 10月, 2013 3 次提交
  20. 27 9月, 2013 1 次提交
  21. 24 9月, 2013 1 次提交
  22. 18 9月, 2013 2 次提交
  23. 31 8月, 2013 2 次提交
  24. 24 8月, 2013 3 次提交
  25. 16 8月, 2013 2 次提交
    • L
      usb: don't check pm qos NO_POWER_OFF flag in usb_port_suspend() · 98a4f1ff
      Lan Tianyu 提交于
      The pm qos NO_POWER_OFF flag is checked twice during usb device suspend
      to see if the usb port power off condition is met. This is redundant and
      also will prevent the port from being powered off if the NO_POWER_OFF
      flag is changed to 1 from 0 after the device was already suspended.
      
      More detail in the following link.
      	http://marc.info/?l=linux-usb&m=136543949130865&w=2
      
      This patch should be backported to kernels as old as 3.7, that
      contain the commit f7ac7787 "usb/acpi:
      Use ACPI methods to power off ports."
      Signed-off-by: NLan Tianyu <tianyu.lan@intel.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      98a4f1ff
    • A
      USB: handle LPM errors during device suspend correctly · aa5ceae2
      Alan Stern 提交于
      The hub driver's usb_port_suspend() routine doesn't handle errors
      related to Link Power Management properly.  It always returns failure,
      it doesn't try to clean up the wakeup setting, (in the case of system
      sleep) it doesn't try to go ahead with the port suspend regardless,
      and it doesn't try to apply the new power-off mechanism.
      
      This patch fixes these problems.
      
      Note: Sarah fixed this patch to apply against 3.11, since the original
      commit (4fae6f0f "USB: handle LPM errors
      during device suspend correctly") called usb_disable_remote_wakeup,
      which won't be added until 3.12.
      
      This patch should be backported to kernels as old as 3.5, that
      contain the commit 8306095f "USB:
      Disable USB 3.0 LPM in critical sections.".  There will be merge
      conflicts, since LTM wasn't added until 3.6.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      aa5ceae2