1. 19 5月, 2012 3 次提交
    • S
      USB: Add support to enable/disable USB3 link states. · 1ea7e0e8
      Sarah Sharp 提交于
      There are various functions within the USB core that will need to
      disable USB 3.0 link power states.  For example, when a USB device
      driver is being bound to an interface, we need to disable USB 3.0 LPM
      until we know if the driver will allow hub-initiated LPM transitions.
      Another example is when the USB core is switching alternate interface
      settings.  The USB 3.0 timeout values are dependent on what endpoints
      are enabled, so we want to ensure that LPM is disabled until the new alt
      setting is fully installed.
      
      Multiple functions need to disable LPM, and those functions can even be
      nested.  For example, usb_bind_interface() could disable LPM, and then
      call into the driver probe function, which may attempt to switch to a
      different alt setting.  Therefore, we need to keep a count of the number
      of functions that require LPM to be disabled at any point in time.
      
      Introduce two new USB core API calls, usb_disable_lpm() and
      usb_enable_lpm().  These functions increment and decrement a new
      variable in the usb_device, lpm_disable_count.  If usb_disable_lpm()
      fails, it will call usb_enable_lpm() in order to balance the
      lpm_disable_count.
      
      These two new functions must be called with the bandwidth_mutex locked.
      If the bandwidth_mutex is not already held by the caller, it should
      instead call usb_unlocked_disable_lpm() and usb_enable_lpm(), which take
      the bandwidth_mutex before calling usb_disable_lpm() and
      usb_enable_lpm(), respectively.
      
      Introduce a new variable (timeout) in the usb3_lpm_params structure to
      keep track of the currently enabled U1/U2 timeout values.  When
      usb_disable_lpm() is called, and the USB device has the U1 or U2
      timeouts set to a non-zero value (meaning either device-initiated or
      hub-initiated LPM is enabled), attempt to disable LPM, regardless of the
      state of the lpm_disable_count.  We want to ensure that all callers can
      be guaranteed that LPM is disabled if usb_disable_lpm() returns zero.
      
      Otherwise the following scenario could occur:
      
      1. Driver A is being bound to interface 1.  usb_probe_interface()
      disables LPM.  Driver A doesn't care if hub-initiated LPM is enabled, so
      even though usb_disable_lpm() fails, the probe of the driver continues,
      and the bandwidth mutex is dropped.
      
      2. Meanwhile, Driver B is being bound to interface 2.
      usb_probe_interface() grabs the bandwidth mutex and calls
      usb_disable_lpm().  That call should attempt to disable LPM, even
      though the lpm_disable_count is set to 1 by Driver A.
      
      For usb_enable_lpm(), we attempt to enable LPM only when the
      lpm_disable_count is zero.  If some step in enabling LPM fails, it will
      only have a minimal impact on power consumption, and all USB device
      drivers should still work properly.  Therefore don't bother to return
      any error codes.
      
      Don't enable device-initiated LPM if the device is unconfigured.  The
      USB device will only accept the U1/U2_ENABLE control transfers in the
      configured state.  Do enable hub-initiated LPM in that case, since
      devices are allowed to accept the LGO_Ux link commands in any state.
      
      Don't enable or disable LPM if the device is marked as not being LPM
      capable.  This can happen if:
       - the USB device doesn't have a SS BOS descriptor,
       - the device's parent hub has a zeroed bHeaderDecodeLatency value, or
       - the xHCI host doesn't support LPM.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Andiry Xu <andiry.xu@amd.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      1ea7e0e8
    • S
      USB: Calculate USB 3.0 exit latencies for LPM. · 51e0a012
      Sarah Sharp 提交于
      There are several different exit latencies associated with coming out of
      the U1 or U2 lower power link state.
      
      Device Exit Latency (DEL) is the maximum time it takes for the USB
      device to bring its upstream link into U0.  That can be found in the
      SuperSpeed Extended Capabilities BOS descriptor for the device.  The
      time it takes for a particular link in the tree to exit to U0 is the
      maximum of either the parent hub's U1/U2 DEL, or the child's U1/U2 DEL.
      
      Hubs introduce a further delay that effects how long it takes a child
      device to transition to U0.  When a USB 3.0 hub receives a header
      packet, it takes some time to decode that header and figure out which
      downstream port the packet was destined for.  If the port is not in U0,
      this hub header decode latency will cause an additional delay for
      bringing the child device to U0.  This Hub Header Decode Latency is
      found in the USB 3.0 hub descriptor.
      
      We can use DEL and the header decode latency, along with additional
      latencies imposed by each additional hub tier, to figure out the exit
      latencies for both host-initiated and device-initiated exit to U0.
      
      The Max Exit Latency (MEL) is the worst-case time it will take for a
      host-initiated exit to U0, based on whether U1 or U2 link states are
      enabled.  The ping or packet must traverse the path to the device, and
      each hub along the way incurs the hub header decode latency in order to
      figure out which device the transfer was bound for.  We say worst-case,
      because some hubs may not be in the lowest link state that is enabled.
      See the examples in section C.2.2.1.
      
      Note that "HSD" is a "host specific delay" that the power appendix
      architect has not been able to tell me how to calculate.  There's no way
      to get HSD from the xHCI registers either, so I'm simply ignoring it.
      
      The Path Exit Latency (PEL) is the worst-case time it will take for a
      device-initiate exit to U0 to place all the links from the device to the
      host into U0.
      
      The System Exit Latency (SEL) is another device-initiated exit latency.
      SEL is useful for USB 3.0 devices that need to send data to the host at
      specific intervals.  The device may send an NRDY to indicate it isn't
      ready to send data, then put its link into a lower power state.  If it
      needs to have that data transmitted at a specific time, it can use SEL
      to back calculate when it will need to bring the link back into U0 to
      meet its deadlines.
      
      SEL is the worst-case time from the device-initiated exit to U0, to when
      the device will receive a packet from the host controller.  It includes
      PEL, the time it takes for an ERDY to get to the host, a host-specific
      delay for the host to process that ERDY, and the time it takes for the
      packet to traverse the path to the device.  See Figure C-2 in the USB
      3.0 bus specification.
      
      Note: I have not been able to get good answers about what the
      host-specific delay to process the ERDY should be.  The Intel HW
      developers say it will be specific to the platform the xHCI host is
      integrated into, and they say it's negligible.  Ignore this too.
      
      Separate from these four exit latencies are the U1/U2 timeout values we
      program into the parent hubs.  These timeouts tell the hub to attempt to
      place the device into a lower power link state after the link has been
      idle for that amount of time.
      
      Create two arrays (one for U1 and one for U2) to store mel, pel, sel,
      and the timeout values.  Store the exit latency values in nanosecond
      units, since that's the smallest units used (DEL is in us, but the Hub
      Header Decode Latency is in ns).
      
      If a USB 3.0 device doesn't have a SuperSpeed Extended Capabilities BOS
      descriptor, it's highly unlikely it will be able to handle LPM requests
      properly.  So it's best to disable LPM for devices that don't have this
      descriptor, and any children beneath it, if it's a USB 3.0 hub.  Warn
      users when that happens, since it means they have a non-compliant USB
      3.0 device or hub.
      
      This patch assumes a simplified design where links deep in the tree will
      not have U1 or U2 enabled unless all their parent links have the
      corresponding LPM state enabled.  Eventually, we might want to allow a
      different policy, and we can revisit this patch when that happens.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      51e0a012
    • S
      USB: Refactor code to set LPM support flag. · d9b2099c
      Sarah Sharp 提交于
      Refactor the code that sets the usb_device flag to indicate the device
      support link power management (lpm_capable).  The current code sets
      lpm_capable unconditionally if the USB devices have a USB 2.0 Extended
      Capabilities Descriptor.  USB 3.0 devices can also have that descriptor,
      but the xHCI driver code that uses lpm_capable will not run the USB 2.0
      LPM test for devices under the USB 3.0 roothub.  Therefore, it's fine
      only set lpm_capable for high speed devices in this refactoring.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      d9b2099c
  2. 18 5月, 2012 1 次提交
    • A
      usbcore: enable USB2 LPM if port suspend fails · c3e751e4
      Andiry Xu 提交于
      USB2 LPM is disabled when device begin to suspend and enabled after device
      is resumed. That's because USB spec does not define the transition from
      U1/U2 state to U3 state.
      
      If usb_port_suspend() fails, usb_port_resume() is never called, and USB2 LPM
      is disabled in this situation. Enable USB2 LPM if port suspend fails.
      
      This patch should be backported to kernels as old as 3.2, that contain
      the commit 65580b43 "xHCI: set USB2
      hardware LPM".
      Signed-off-by: NAndiry Xu <andiry.xu@gmail.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      c3e751e4
  3. 15 5月, 2012 2 次提交
  4. 12 5月, 2012 2 次提交
  5. 18 4月, 2012 1 次提交
    • A
      USB: fix deadlock in bConfigurationValue attribute method · 8963c487
      Alan Stern 提交于
      This patch (as154) fixes a self-deadlock that occurs when userspace
      writes to the bConfigurationValue sysfs attribute for a hub with
      children.  The task tries to lock the bandwidth_mutex at a time when
      it already owns the lock:
      
      	The attribute's method calls usb_set_configuration(),
      	which calls usb_disable_device() with the bandwidth_mutex
      	held.
      
      	usb_disable_device() unregisters the existing interfaces,
      	which causes the hub driver to be unbound.
      
      	The hub_disconnect() routine calls hub_quiesce(), which
      	calls usb_disconnect() for each of the hub's children.
      
      	usb_disconnect() attempts to acquire the bandwidth_mutex
      	around a call to usb_disable_device().
      
      The solution is to make usb_disable_device() acquire the mutex for
      itself instead of requiring the caller to hold it.  Then the mutex can
      cover only the bandwidth deallocation operation and not the region
      where the interfaces are unregistered.
      
      This has the potential to change system behavior slightly when a
      config change races with another config or altsetting change.  Some of
      the bandwidth released from the old config might get claimed by the
      other config or altsetting, make it impossible to restore the old
      config in case of a failure.  But since we don't try to recover from
      config-change failures anyway, this doesn't matter.
      
      [This should be marked for stable kernels that contain the commit
      fccf4e86 "USB: Free bandwidth when
      usb_disable_device is called."
      That commit was marked for stable kernels as old as 2.6.32.]
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8963c487
  6. 11 4月, 2012 1 次提交
    • E
      USB: fix bug of device descriptor got from superspeed device · d8aec3db
      Elric Fu 提交于
      When the Seagate Goflex USB3.0 device is attached to VIA xHCI
      host, sometimes the device will downgrade mode to high speed.
      By the USB analyzer, I found the device finished the link
      training process and worked at superspeed mode. But the device
      descriptor got from the device shows the device works at 2.1.
      It is very strange and seems like the device controller of
      Seagate Goflex has a little confusion.
      
      The first 8 bytes of device descriptor should be:
      12 01 00 03 00 00 00 09
      
      But the first 8 bytes of wrong device descriptor are:
      12 01 10 02 00 00 00 40
      
      The wrong device descriptor caused the initialization of mass
      storage failed. After a while, the device would be recognized
      as a high speed device and works fine.
      
      This patch will warm reset the device to fix the issue after
      finding the bcdUSB field of device descriptor isn't 0x0300
      but the speed mode of device is superspeed.
      
      This patch should be backported to kernels as old as 3.2, or ones that
      contain the commit 75d7cf72 "usbcore:
      refine warm reset logic".
      Signed-off-by: NElric Fu <elricfu1@gmail.com>
      Acked-by: NAndiry Xu <Andiry.Xu@amd.com>
      Acked-by: NSergei Shtylyov <sshtylyov@mvista.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      d8aec3db
  7. 14 3月, 2012 1 次提交
  8. 22 2月, 2012 1 次提交
    • E
      USB: Set hub depth after USB3 hub reset · a45aa3b3
      Elric Fu 提交于
      The superspeed device attached to a USB 3.0 hub(such as VIA's)
      doesn't respond the address device command after resume. The
      root cause is the superspeed hub will miss the Hub Depth value
      that is used as an offset into the route string to locate the
      bits it uses to determine the downstream port number after
      reset, and all packets can't be routed to the device attached
      to the superspeed hub.
      
      Hub driver sends a Set Hub Depth request to the superspeed hub
      except for USB 3.0 root hub when the hub is initialized and
      doesn't send the request again after reset due to the resume
      process. So moving the code that sends the Set Hub Depth request
      to the superspeed hub from hub_configure() to hub_activate()
      is to cover those situations include initialization and reset.
      
      The patch should be backported to kernels as old as 2.6.39.
      Signed-off-by: NElric Fu <elricfu1@gmail.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable@vger.kernel.org
      a45aa3b3
  9. 15 2月, 2012 7 次提交
    • S
      USB: Turn on auto-suspend for USB 3.0 hubs. · 2839f5bc
      Sarah Sharp 提交于
      Now that USB 3.0 hub remote wakeup on port status changes is enabled,
      and USB 3.0 device remote wakeup is handled in the USB core properly,
      let's turn on auto-suspend for all USB 3.0 hubs.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      2839f5bc
    • S
      USB: Set wakeup bits for all children hubs. · 72937e1e
      Sarah Sharp 提交于
      This patch takes care of the race condition between the Function Wake
      Device Notification and the auto-suspend timeout for this situation:
      
      Roothub
        | (U3)
      hub A
        | (U3)
      hub B
        | (U3)
      device C
      
      When device C signals a resume, the xHCI driver will set the wakeup_bits
      for the roothub port that hub A is attached to.  However, since USB 3.0
      hubs do not set a link state change bit on device-initiated resume, hub
      A will not indicate a port event when polled.  Without this patch, khubd
      will notice the wakeup-bits are set for the roothub port, it will resume
      hub A, and then it will poll the events bits for hub A and notice that
      nothing has changed.  Then it will be suspended after 2 seconds.
      
      Change hub_activate() to look at the port link state for each USB 3.0
      hub port, and set hub->change_bits if the link state is U0, indicating
      the device has finished resume.  Change the resume function called by
      hub_events(), hub_handle_remote_wakeup(), to check the link status
      for resume instead of just the port's wakeup_bits.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      72937e1e
    • S
      USB/xHCI: Support device-initiated USB 3.0 resume. · 4ee823b8
      Sarah Sharp 提交于
      USB 3.0 hubs don't have a port suspend change bit (that bit is now
      reserved).  Instead, when a host-initiated resume finishes, the hub sets
      the port link state change bit.
      
      When a USB 3.0 device initiates remote wakeup, the parent hubs with
      their upstream links in U3 will pass the LFPS up the chain.  The first
      hub that has an upstream link in U0 (which may be the roothub) will
      reflect that LFPS back down the path to the device.
      
      However, the parent hubs in the resumed path will not set their link
      state change bit.  Instead, the device that initiated the resume has to
      send an asynchronous "Function Wake" Device Notification up to the host
      controller.  Therefore, we need a way to notify the USB core of a device
      resume without going through the normal hub URB completion method.
      
      First, make the xHCI roothub act like an external USB 3.0 hub and not
      pass up the port link state change bit when a device-initiated resume
      finishes.  Introduce a new xHCI bit field, port_remote_wakeup, so that
      we can tell the difference between a port coming out of the U3Exit state
      (host-initiated resume) and the RExit state (ending state of
      device-initiated resume).
      
      Since the USB core can't tell whether a port on a hub has resumed by
      looking at the Hub Status buffer, we need to introduce a bitfield,
      wakeup_bits, that indicates which ports have resumed.  When the xHCI
      driver notices a port finishing a device-initiated resume, we call into
      a new USB core function, usb_wakeup_notification(), that will set
      the right bit in wakeup_bits, and kick khubd for that hub.
      
      We also call usb_wakeup_notification() when the Function Wake Device
      Notification is received by the xHCI driver.  This covers the case where
      the link between the roothub and the first-tier hub is in U0, and the
      hub reflects the resume signaling back to the device without giving any
      indication it has done so until the device sends the Function Wake
      notification.
      
      Change the code in khubd that handles the remote wakeup to look at the
      state the USB core thinks the device is in, and handle the remote wakeup
      if the port's wakeup bit is set.
      
      This patch only takes care of the case where the device is attached
      directly to the roothub, or the USB 3.0 hub that is attached to the root
      hub is the device sending the Function Wake Device Notification (e.g.
      because a new USB device was attached).  The other cases will be covered
      in a second patch.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      4ee823b8
    • S
      USB: Refactor hub remote wake handling. · 714b07be
      Sarah Sharp 提交于
      Refactor the code to check for a remote wakeup on a port into its own
      function.  Keep the behavior the same, and set connect_change in
      hub_events if the device disconnected on resume.  Cleanup references to
      hdev->children[i-1] to use a common variable.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      714b07be
    • S
      USB/xHCI: Enable USB 3.0 hub remote wakeup. · 4296c70a
      Sarah Sharp 提交于
      USB 3.0 hubs have a different remote wakeup policy than USB 2.0 hubs.
      USB 2.0 hubs, once they have remote wakeup enabled, will always send
      remote wakes when anything changes on a port.
      
      However, USB 3.0 hubs have a per-port remote wake up policy that is off
      by default.  The Set Feature remote wake mask can be changed for any
      port, enabling remote wakeup for a connect, disconnect, or overcurrent
      event, much like EHCI and xHCI host controller "wake on" port status
      bits.  The bits are cleared to zero on the initial hub power on, or
      after the hub has been reset.
      
      Without this patch, when a USB 3.0 hub gets suspended, it will not send
      a remote wakeup on device connect or disconnect.  This would show up to
      the user as "dead ports" unless they ran lsusb -v (since newer versions
      of lsusb use the sysfs files, rather than sending control transfers).
      
      Change the hub driver's suspend method to enable remote wake up for
      disconnect, connect, and overcurrent for all ports on the hub.  Modify
      the xHCI driver's roothub code to handle that request, and set the "wake
      on" bits in the port status registers accordingly.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      4296c70a
    • S
      USB: Suspend functions before putting dev into U3. · 3b9b6acd
      Sarah Sharp 提交于
      The USB 3.0 bus specification introduces a new type of power management
      called function suspend.  The idea is to be able to suspend different
      functions (i.e. a scanner or an SD card reader on a USB printer)
      independently.  A device can be in U0, but have one or more functions
      suspended.  Thus, signaling a function resume with the standard device
      remote wake signaling was not possible.
      
      Instead, a device will (without prompt from the host) send a "device
      notification" for the function remote wake.  A new Set Feature Function
      Remote Wake was developed to turn remote wake up on and off for each
      function.
      
      USB 3.0 devices can still go into device suspend (U3), and signal a
      remote wakeup to bring the link back into U1.  However, they now use the
      function remote wake device notification to allow the host to know which
      function woke the device from U3.
      
      The spec is a bit ambiguous about whether a function is allowed to
      signal a remote wakeup if the function has been enabled for remote
      wakeup, but not placed in function suspend before the device is placed
      into U3.
      
      Section 9.2.5.1 says "Suspending a device with more than one function
      effectively suspends all the functions within the device."  I interpret
      that to mean that putting a device in U3 suspends all functions, and
      thus if the host has previously enabled remote wake for those functions,
      it should be able to signal a remote wake up on port status changes.
      However, hub vendors may have a different interpretation, and it can't
      hurt to put the function into suspend before putting the device into U3.
      
      I cannot get an answer out of the USB 3.0 spec architects about this
      ambiguity, so I'm erring on the safe side and always suspending the
      first function before placing the device in U3.  Note, this code should
      be fixed if we ever find any USB 3.0 devices that have more than one
      function.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      3b9b6acd
    • S
      USB/xhci: Enable remote wakeup for USB3 devices. · 623bef9e
      Sarah Sharp 提交于
      When the USB 3.0 hub support went in, I disabled selective suspend for
      all external USB 3.0 hubs because they used a different mechanism to
      enable remote wakeup.  In fact, other USB 3.0 devices that could signal
      remote wakeup would have been prevented from going into suspend because
      they would have stalled the SetFeature Device Remote Wakeup request.
      
      This patch adds support for the USB 3.0 way of enabling remote wake up
      (with a SetFeature Function Suspend request), and enables selective
      suspend for all hubs during hub_probe.  It assumes that all USB 3.0 have
      only one "function" as defined by the interface association descriptor,
      which is true of all the USB 3.0 devices I've seen so far.  FIXME if
      that turns out to change later.
      
      After a device signals a remote wakeup, it is supposed to send a Device
      Notification packet to the host controller, signaling which function
      sent the remote wakeup.  The host can then put any other functions back
      into function suspend.  Since we don't have support for function suspend
      (and no devices currently support it), we'll just assume the hub
      function will resume the device properly when it received the port
      status change notification, and simply ignore any device notification
      events from the xHCI host controller.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      623bef9e
  10. 10 2月, 2012 1 次提交
  11. 13 1月, 2012 1 次提交
  12. 10 12月, 2011 1 次提交
    • A
      USB: Adding #define in hub_configure() and hcd.c file · 7bf01185
      Aman Deep 提交于
      This patch is in succession of previous patch
      commit c8421147
              xHCI: Adding #define values used for hub descriptor
      
      Hub descriptors characteristics #defines values are added in
      hub_configure() in place of magic numbers as asked by Alan Stern.
      And the indentation for switch and case is changed to be same.
      
      Some #defines values are added in ch11.h for defining hub class
      protocols and used in hub.c and hcd.c in which magic values were
      used for hub class protocols.
      Signed-off-by: NAman Deep <amandeep3986@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7bf01185
  13. 27 11月, 2011 1 次提交
  14. 05 11月, 2011 1 次提交
    • D
      usb, xhci: Clear warm reset change event during init · 79c3dd81
      Don Zickus 提交于
      I noticed on my Panther Point system that I wasn't getting hotplug events
      for my usb3.0 disk on a usb3 port.  I tracked it down to the fact that the
      system had the warm reset change bit still set.  This seemed to block future
      events from being received, including a hotplug event.
      
      Clearing this bit during initialization allowed the hotplug event to be
      received and the disk to be recognized correctly.
      
      This patch should be backported to kernels as old as 2.6.39.
      Signed-off-by: NDon Zickus <dzickus@redhat.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      79c3dd81
  15. 28 9月, 2011 1 次提交
  16. 27 9月, 2011 3 次提交
  17. 21 9月, 2011 2 次提交
    • S
      USB: When hot reset for USB3 fails, try warm reset. · 10d674a8
      Sarah Sharp 提交于
      When a hot reset (standard USB port reset) fails on a USB 3.0 port, the
      host controller transitions to the "Error" state.  It reports the port
      link state as "Inactive", sets the link state change flag, and (if the
      device disconnects) also reports the disconnect and connect change status.
      It's also supposed to transition the link state to "RxDetect", but the NEC
      µPD720200 xHCI host does not.
      
      Unfortunately, Harald found that the combination of the NEC µPD720200 and
      a LogiLink USB 3.0 to SATA adapter triggered this issue.  The USB core
      would reset the device, the port would go into this error state, and the
      device would never be enumerated.  This combination works under Windows,
      but not under Linux.
      
      When a hot reset fails on a USB 3.0 port, and the link state is reported
      as Inactive, fall back to a warm port reset instead.  Harald confirms that
      with a warm port reset (along with all the change bits being correctly
      cleared), the USB 3.0 device will successfully enumerate.
      
      Harald also had to add two other patches ("xhci: Set change bit when warm
      reset change is set." and "usbcore: refine warm reset logic") to make this
      setup work.  Since the warm reset refinement patch is not destined for the
      stable kernels (it's too big), this patch should not be backported either.
      
      This fixes https://bugzilla.kernel.org/show_bug.cgi?id=41752Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NHarald Brennich <harald.brennich@gmx.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      10d674a8
    • A
      usbcore: refine warm reset logic · 75d7cf72
      Andiry Xu 提交于
      Current waiting time for warm(BH) reset in hub_port_warm_reset() is too short
      for xHC host to complete the warm reset and report a BH reset change.
      
      This patch increases the waiting time for warm reset and merges the function
      into hub_port_reset(), so it can handle both cold reset and warm reset, and
      factor out hub_port_finish_reset() to make the code looks cleaner.
      
      This fixes the issue that driver fails to clear BH reset change and port is
      "dead".
      Signed-off-by: NAndiry Xu <andiry.xu@amd.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      75d7cf72
  18. 18 9月, 2011 1 次提交
    • M
      usb: Provide usb_speed_string() function · e538dfda
      Michal Nazarewicz 提交于
      In a few places in the kernel, the code prints
      a human-readable USB device speed (eg. "high speed").
      This involves a switch statement sometimes wrapped
      around in ({ ... }) block leading to code repetition.
      
      To mitigate this issue, this commit introduces
      usb_speed_string() function, which returns
      a human-readable name of provided speed.
      
      It also changes a few places switch was used to use
      this new function.  This changes a bit the way the
      speed is printed in few instances at the same time
      standardising it.
      Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e538dfda
  19. 24 8月, 2011 1 次提交
    • K
      USB: use usb_endpoint_maxp() instead of le16_to_cpu() · 29cc8897
      Kuninori Morimoto 提交于
      Now ${LINUX}/drivers/usb/* can use usb_endpoint_maxp(desc) to get maximum packet size
      instead of le16_to_cpu(desc->wMaxPacketSize).
      This patch fix it up
      
      Cc: Armin Fuerst <fuerst@in.tum.de>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Johannes Erdfelt <johannes@erdfelt.com>
      Cc: Vojtech Pavlik <vojtech@suse.cz>
      Cc: Oliver Neukum <oliver@neukum.name>
      Cc: David Kubicek <dave@awk.cz>
      Cc: Johan Hovold <jhovold@gmail.com>
      Cc: Brad Hards <bhards@bigpond.net.au>
      Acked-by: NFelipe Balbi <balbi@ti.com>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Thomas Dahlmann <dahlmann.thomas@arcor.de>
      Cc: David Brownell <david-b@pacbell.net>
      Cc: David Lopo <dlopo@chipidea.mips.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Michal Nazarewicz <m.nazarewicz@samsung.com>
      Cc: Xie Xiaobo <X.Xie@freescale.com>
      Cc: Li Yang <leoli@freescale.com>
      Cc: Jiang Bo <tanya.jiang@freescale.com>
      Cc: Yuan-hsin Chen <yhchen@faraday-tech.com>
      Cc: Darius Augulis <augulis.darius@gmail.com>
      Cc: Xiaochen Shen <xiaochen.shen@intel.com>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: OKI SEMICONDUCTOR, <toshiharu-linux@dsn.okisemi.com>
      Cc: Robert Jarzmik <robert.jarzmik@free.fr>
      Cc: Ben Dooks <ben@simtec.co.uk>
      Cc: Thomas Abraham <thomas.ab@samsung.com>
      Cc: Herbert Pötzl <herbert@13thfloor.at>
      Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
      Cc: Roman Weissgaerber <weissg@vienna.at>
      Acked-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Tony Olech <tony.olech@elandigitalsystems.com>
      Cc: Florian Floe Echtler <echtler@fs.tum.de>
      Cc: Christian Lucht <lucht@codemercs.com>
      Cc: Juergen Stuber <starblue@sourceforge.net>
      Cc: Georges Toth <g.toth@e-biz.lu>
      Cc: Bill Ryder <bryder@sgi.com>
      Cc: Kuba Ober <kuba@mareimbrium.org>
      Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      29cc8897
  20. 23 8月, 2011 1 次提交
  21. 20 8月, 2011 1 次提交
  22. 16 6月, 2011 2 次提交
    • A
      USB: don't let the hub driver prevent system sleep · cbb33004
      Alan Stern 提交于
      This patch (as1465) continues implementation of the policy that errors
      during suspend or hibernation should not prevent the system from going
      to sleep.
      
      In this case, failure to turn on the Suspend feature for a hub port
      shouldn't be reported as an error.  There are situations where this
      does actually occur (such as when the device plugged into that port
      was disconnected in the recent past), and it turns out to be harmless.
      There's no reason for it to prevent a system sleep.
      
      Also, don't allow the hub driver to fail a system suspend if the
      downstream ports aren't all suspended.  This is also harmless (and
      should never happen, given the change mentioned above); printing a
      warning message in the kernel log is all we really need to do.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      cbb33004
    • S
      USB: Free bandwidth when usb_disable_device is called. · fccf4e86
      Sarah Sharp 提交于
      Tanya ran into an issue when trying to switch a UAS device from the BOT
      configuration to the UAS configuration via the bConfigurationValue sysfs
      file.  Before installing the UAS configuration, set_bConfigurationValue()
      calls usb_disable_device().  That function is supposed to remove all host
      controller resources associated with that device, but it leaves some state
      in the xHCI host controller.
      
      Commit 0791971b
      	usb: allow drivers to use allocated bandwidth until unbound
      added a call to usb_disable_device() in usb_set_configuration(), before
      the xHCI bandwidth functions were invoked.  That commit fixed a bug, but
      also introduced a bug that is triggered when a configured device is
      switched to a new configuration.
      
      usb_disable_device() goes through all the motions of unbinding the drivers
      attached to active interfaces and removing the USB core structures
      associated with those interfaces, but it doesn't actually remove the
      endpoints from the internal xHCI host controller bandwidth structures.
      
      When usb_disable_device() calls usb_disable_endpoint() with reset_hardware
      set to true, the entries in udev->ep_out and udev->ep_in will be set to
      NULL.  Usually, when the USB core installs a new configuration,
      usb_hcd_alloc_bandwidth() will drop all non-NULL endpoints in udev->ep_out
      and udev->ep_in before adding any new endpoints.  However, when the new
      UAS configuration was added, all those entries were null, so none of the
      old endpoints in the BOT configuration were dropped.
      
      The xHCI driver blindly added the UAS configuration endpoints, and some of
      the endpoint addresses overlapped with the old BOT configuration
      endpoints.  This caused the xHCI host to reject the Configure Endpoint
      command.  Now that the xHCI driver code is cleaned up to reject a
      double-add of active endpoints, we need to fix the USB core to properly
      drop old endpoints in usb_disable_device().
      
      If the host controller driver needs bandwidth checking support, make
      usb_disable_device() call usb_disable_endpoint() with
      reset_hardware set to false, drop the endpoints from the xHCI host
      controller, and then call usb_disable_endpoint() again with
      reset_hardware set to true.
      
      The first call to usb_disable_endpoint() will cancel any pending URBs and
      wait on them to be freed in usb_hcd_disable_endpoint(), but will keep the
      pointers in udev->ep_out and udev->ep in intact.  Then
      usb_hcd_alloc_bandwidth() will use those pointers to know which endpoints
      to drop.
      
      The final call to usb_disable_endpoint() will do two things:
      
      1. It will call usb_hcd_disable_endpoint() again, which should be harmless
      since the ep->urb_list should be empty after the first call to
      usb_disable_endpoint() returns.
      
      2. It will set the entries in udev->ep_out and udev->ep in to NULL, and call
      usb_hcd_disable_endpoint().  That call will have no effect, since the xHCI
      driver doesn't set the endpoint_disable function pointer.
      
      Note that usb_disable_device() will now need to be called with
      hcd->bandwidth_mutex held.
      
      This should be backported to kernels as old as 2.6.32.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: NTanya Brokhman <tlinder@codeaurora.org>
      Cc: ablay@codeaurora.org
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: stable@kernel.org
      fccf4e86
  23. 07 6月, 2011 1 次提交
  24. 03 5月, 2011 3 次提交