1. 17 10月, 2013 4 次提交
    • 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
    • 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
  2. 12 10月, 2013 3 次提交
  3. 27 9月, 2013 1 次提交
  4. 24 9月, 2013 1 次提交
  5. 18 9月, 2013 2 次提交
  6. 31 8月, 2013 2 次提交
  7. 24 8月, 2013 3 次提交
  8. 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
  9. 03 8月, 2013 1 次提交
  10. 01 8月, 2013 5 次提交
    • A
      USB: handle LPM errors during device suspend correctly · 4fae6f0f
      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.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4fae6f0f
    • A
      USB: refactor code for enabling/disabling remote wakeup · 28e86165
      Alan Stern 提交于
      The hub driver is inconsistent in its organization of code for
      enabling and disabling remote wakeup.  There is a special routine to
      disable wakeup for SuperSpeed devices but not for slower devices, and
      there is no special routine to enable wakeup.
      
      This patch refactors the code.  It renames and changes the existing
      function to make it handle both SuperSpeed and non-SuperSpeed devices,
      and it adds a corresponding routine to enable remote wakeup.  It also
      changes the speed determination to look at the device's speed rather
      than the speed of the parent hub -- this shouldn't make any difference
      because a SuperSpeed device always has to be attached to a SuperSpeed
      hub and conversely.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28e86165
    • A
      USB: simplify the interface of usb_get_status() · 15b7336e
      Alan Stern 提交于
      This patch simplifies the interface presented by usb_get_status().
      Instead of forcing callers to check for the proper data length and
      convert the status value to host byte order, the function will now
      do these things itself.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      15b7336e
    • J
      usb: core: don't try to reset_device() a port that got just disconnected · f3e94aa1
      Julius Werner 提交于
      The USB hub driver's event handler contains a check to catch SuperSpeed
      devices that transitioned into the SS.Inactive state and tries to fix
      them with a reset. It decides whether to do a plain hub port reset or
      call the usb_reset_device() function based on whether there was a device
      attached to the port.
      
      However, there are device/hub combinations (found with a JetFlash
      Transcend mass storage stick (8564:1000) on the root hub of an Intel
      LynxPoint PCH) which can transition to the SS.Inactive state on
      disconnect (and stay there long enough for the host to notice). In this
      case, above-mentioned reset check will call usb_reset_device() on the
      stale device data structure. The kernel will send pointless LPM control
      messages to the no longer connected device address and can even cause
      several 5 second khubd stalls on some (buggy?) host controllers, before
      finally accepting the device's fate amongst a flurry of error messages.
      
      This patch makes the choice of reset dependent on the port status that
      has just been read from the hub in addition to the existence of an
      in-kernel data structure for the device, and only proceeds with the more
      extensive reset if both are valid.
      Signed-off-by: NJulius Werner <jwerner@chromium.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f3e94aa1
    • J
      usb: core: don't try to reset_device() a port that got just disconnected · 481f2d4f
      Julius Werner 提交于
      The USB hub driver's event handler contains a check to catch SuperSpeed
      devices that transitioned into the SS.Inactive state and tries to fix
      them with a reset. It decides whether to do a plain hub port reset or
      call the usb_reset_device() function based on whether there was a device
      attached to the port.
      
      However, there are device/hub combinations (found with a JetFlash
      Transcend mass storage stick (8564:1000) on the root hub of an Intel
      LynxPoint PCH) which can transition to the SS.Inactive state on
      disconnect (and stay there long enough for the host to notice). In this
      case, above-mentioned reset check will call usb_reset_device() on the
      stale device data structure. The kernel will send pointless LPM control
      messages to the no longer connected device address and can even cause
      several 5 second khubd stalls on some (buggy?) host controllers, before
      finally accepting the device's fate amongst a flurry of error messages.
      
      This patch makes the choice of reset dependent on the port status that
      has just been read from the hub in addition to the existence of an
      in-kernel data structure for the device, and only proceeds with the more
      extensive reset if both are valid.
      Signed-off-by: NJulius Werner <jwerner@chromium.org>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      481f2d4f
  11. 26 7月, 2013 2 次提交
  12. 17 7月, 2013 1 次提交
    • A
      USB: global suspend and remote wakeup don't mix · e583d9db
      Alan Stern 提交于
      The hub driver was recently changed to use "global" suspend for system
      suspend transitions on non-SuperSpeed buses.  This means that we don't
      suspend devices individually by setting the suspend feature on the
      upstream hub port; instead devices all go into suspend automatically
      when the root hub stops transmitting packets.  The idea was to save
      time and to avoid certain kinds of wakeup races.
      
      Now it turns out that many hubs are buggy; they don't relay wakeup
      requests from a downstream port to their upstream port if the
      downstream port's suspend feature is not set (depending on the speed
      of the downstream port, whether or not the hub is enabled for remote
      wakeup, and possibly other factors).
      
      We can't have hubs dropping wakeup requests.  Therefore this patch
      goes partway back to the old policy: It sets the suspend feature for a
      port if the device attached to that port or any of its descendants is
      enabled for wakeup.  People will still be able to benefit from the
      time savings if they don't care about wakeup and leave it disabled on
      all their devices.
      
      In order to accomplish this, the patch adds a new field to the usb_hub
      structure: wakeup_enabled_descendants is a count of how many devices
      below a suspended hub are enabled for remote wakeup.  A corresponding
      new subroutine determines the number of wakeup-enabled devices at or
      below an arbitrary suspended USB device.
      
      This should be applied to the 3.10 stable kernel.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-and-tested-by: NToralf Förster <toralf.foerster@gmx.de>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e583d9db
  13. 19 6月, 2013 1 次提交
  14. 29 3月, 2013 3 次提交
  15. 26 3月, 2013 1 次提交
  16. 24 2月, 2013 1 次提交
    • M
      usb: forbid memory allocation with I/O during bus reset · 4d769def
      Ming Lei 提交于
      If one storage interface or usb network interface(iSCSI case) exists in
      current configuration, memory allocation with GFP_KERNEL during
      usb_device_reset() might trigger I/O transfer on the storage interface
      itself and cause deadlock because the 'us->dev_mutex' is held in
      .pre_reset() and the storage interface can't do I/O transfer when the
      reset is triggered by other interface, or the error handling can't be
      completed if the reset is triggered by the storage itself (error
      handling path).
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Cc: David Decotigny <david.decotigny@google.com>
      Cc: Tom Herbert <therbert@google.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Oliver Neukum <oneukum@suse.de>
      Reviewed-by: NJiri Kosina <jkosina@suse.cz>
      Cc: Mel Gorman <mel@csn.ul.ie>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Michal Hocko <mhocko@suse.cz>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4d769def
  17. 26 1月, 2013 2 次提交
    • L
      usb: add usb port auto power off mechanism · ad493e5e
      Lan Tianyu 提交于
      This patch is to add usb port auto power off mechanism.
      When usb device is suspending, usb core will suspend usb port and
      usb port runtime pm callback will clear PORT_POWER feature to
      power off port if all conditions were met. These conditions are
      remote wakeup disable, pm qos NO_POWER_OFF flag clear and persist
      enable. When it resumes, power on port again.
      
      Add did_runtime_put in the struct usb_port to ensure
      pm_runtime_get/put(portdev) to be called pairedly.  Set did_runtime_put
      to true when call pm_runtime_put(portdev) during suspending. The
      pm_runtime_get(portdev) only will be called when did_runtime_put
      is set to true during resuming. Set did_runtime_put to false after
      calling pm_runtime_get(portdev).
      
      Make clear_port_feature() and hdev_to_hub() as global symbol.
      Rename clear_port_feature() to usb_clear_port_feature() and
      hdev_to_hub() to usb_hub_to_struct_hub().
      
      Extend hub_port_debounce() with the fuction of debouncing to
      be connected. Add two wraps: hub_port_debounce_be_connected()
      and hub_port_debouce_be_stable().
      
      Increase HUB_DEBOUNCE_TIMEOUT to 2000 because some usb ssds
      needs around 1.5 or more to make the hub port status to be
      connected steadily after being powered off and powered on.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NLan Tianyu <tianyu.lan@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ad493e5e
    • L
      usb: add runtime pm support for usb port device · 971fcd49
      Lan Tianyu 提交于
      This patch is to add runtime pm callback for usb port device.
      Set/clear PORT_POWER feature in the resume/suspend callback.
      Add portnum for struct usb_port to record port number. Do
      pm_rumtime_get_sync/put(portdev) when a device is plugged/unplugged
      to prevent it from being powered off when it is active.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NLan Tianyu <tianyu.lan@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      971fcd49
  18. 25 1月, 2013 1 次提交
    • L
      usb: Using correct way to clear usb3.0 device's remote wakeup feature. · 54a3ac0c
      Lan Tianyu 提交于
      Usb3.0 device defines function remote wakeup which is only for interface
      recipient rather than device recipient. This is different with usb2.0 device's
      remote wakeup feature which is defined for device recipient. According usb3.0
      spec 9.4.5, the function remote wakeup can be modified by the SetFeature()
      requests using the FUNCTION_SUSPEND feature selector. This patch is to use
      correct way to disable usb3.0 device's function remote wakeup after suspend
      error and resuming.
      
      This should be backported to kernels as old as 3.4, that contain the
      commit 623bef9e "USB/xhci: Enable remote
      wakeup for USB3 devices."
      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
      54a3ac0c
  19. 22 1月, 2013 1 次提交
    • L
      USB: Set usb port's DeviceRemovable according acpi information · d2123fd9
      Lan Tianyu 提交于
      ACPI provide "_PLD" and "_UPC" aml methods to describe usb port
      visibility and connectability. This patch is to add usb_hub_adjust_DeviceRemovable()
      to adjust usb hub port's DeviceRemovable according ACPI information and invoke it in
      the rh_call_control(). When hub descriptor request is issued at first time,
      usb port device isn't created and usb port is not bound with acpi. So first
      hub descriptor request is not changed based on ACPI information. After usb
      port devices being created, call usb_hub_adjust_DeviceRemovable in the hub_configure()
      and then set hub port's DeviceRemovable according ACPI information and this also works
      for non-root hub.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NLan Tianyu <tianyu.lan@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d2123fd9
  20. 21 1月, 2013 1 次提交
  21. 19 1月, 2013 1 次提交
  22. 12 1月, 2013 1 次提交