1. 26 8月, 2013 1 次提交
  2. 24 8月, 2013 4 次提交
  3. 16 8月, 2013 3 次提交
    • S
      usb: Don't fail port power resume on device disconnect. · d49dad3e
      Sarah Sharp 提交于
      Userspace can tell the kernel to power off any USB port, including ones
      that are visible and connectible to users.  When an attached USB device
      goes into suspend, the port will be powered off if the
      pm_qos_no_port_poweroff file for its port is set to 0, the device does
      not have remote wakeup enabled, and the device is marked as persistent.
      
      If the user disconnects the USB device while the port is powered off,
      the current code does not handle that properly.  If you disconnect a
      device, and then run `lsusb -v -s` for the device, the device disconnect
      does not get handled by the USB core.  The runtime resume of the port
      fails, because hub_port_debounce_be_connected() returns -ETIMEDOUT.
      
      This means the port resume fails and khubd doesn't handle the USB device
      disconnect.  This leaves the device listed in lsusb, and the port's
      runtime_status will be permanently marked as "error".
      
      Fix this by ignoring the return value of hub_port_debounce_be_connected.
      Users can disconnect USB devices while the ports are powered off, and we
      must be able to handle that.
      
      This patch should be backported to kernels as old as 3.9, that
      contain the commit ad493e5e "usb: add
      usb port auto power off mechanism"
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Lan Tianyu <tianyu.lan@intel.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      d49dad3e
    • 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
  4. 15 8月, 2013 2 次提交
  5. 13 8月, 2013 4 次提交
    • M
      usb/hcd: Log error code if reset() fails · c10750b2
      Mark Brown 提交于
      If someone provided meaningful error codes from reset() we should tell the
      user what they were.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c10750b2
    • H
      usb: config->desc.bLength may not exceed amount of data returned by the device · b4f17a48
      Hans de Goede 提交于
      While reading the config parsing code I noticed this check is missing, without
      this check config->desc.wTotalLength can end up with a value larger then the
      dev->rawdescriptors length for the config, and when userspace then tries to
      get the rawdescriptors bad things may happen.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b4f17a48
    • M
      USB: introduce usb_device_no_sg_constraint() helper · bcc48f1a
      Ming Lei 提交于
      Some host controllers(such as xHCI) can support building
      packet from discontinuous buffers, so introduce one flag
      and helper for this kind of host controllers, then the
      feature can help some applications(such as usbnet) by
      supporting arbitrary length of sg buffers.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bcc48f1a
    • M
      USB: HCD: support giveback of URB in tasklet context · 94dfd7ed
      Ming Lei 提交于
      This patch implements the mechanism of giveback of URB in
      tasklet context, so that hardware interrupt handling time for
      usb host controller can be saved much, and HCD interrupt handling
      can be simplified.
      
      Motivations:
      
      1), on some arch(such as ARM), DMA mapping/unmapping is a bit
      time-consuming, for example: when accessing usb mass storage
      via EHCI on pandaboard, the common length of transfer buffer is 120KB,
      the time consumed on DMA unmapping may reach hundreds of microseconds;
      even on A15 based box, the time is still about scores of microseconds
      
      2), on some arch, reading DMA coherent memoery is very time-consuming,
      the most common example is usb video class driver[1]
      
      3), driver's complete() callback may do much things which is driver
      specific, so the time is consumed unnecessarily in hardware irq context.
      
      4), running driver's complete() callback in hardware irq context causes
      that host controller driver has to release its lock in interrupt handler,
      so reacquiring the lock after return may busy wait a while and increase
      interrupt handling time. More seriously, releasing the HCD lock makes
      HCD becoming quite complicated to deal with introduced races.
      
      So the patch proposes to run giveback of URB in tasklet context, then
      time consumed in HCD irq handling doesn't depend on drivers' complete and
      DMA mapping/unmapping any more, also we can simplify HCD since the HCD
      lock isn't needed to be released during irq handling.
      
      The patch should be reasonable and doable:
      
      1), for drivers, they don't care if the complete() is called in hard irq
      context or softirq context
      
      2), the biggest change is the situation in which usb_submit_urb() is called
      in complete() callback, so the introduced tasklet schedule delay might be a
      con, but it shouldn't be a big deal:
      
      	- control/bulk asynchronous transfer isn't sensitive to schedule
      	  delay
      
      	- the patch schedules giveback of periodic URBs using
      	  tasklet_hi_schedule, so the introduced delay should be very
      	  small
      
      	- for ISOC transfer, generally, drivers submit several URBs
      	  concurrently to avoid interrupt delay, so it is OK with the
      	  little schedule delay.
      
      	- for interrupt transfer, generally, drivers only submit one URB
      	  at the same time, but interrupt transfer is often used in event
      	  report, polling, ... situations, and a little delay should be OK.
      
      Considered that HCDs may optimize on submitting URB in complete(), the
      patch may cause the optimization not working, so introduces one flag to mark
      if the HCD supports to run giveback URB in tasklet context. When all HCDs
      are ready, the flag can be removed.
      
      [1], http://marc.info/?t=136438111600010&r=1&w=2
      
      Cc: Oliver Neukum <oliver@neukum.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      94dfd7ed
  6. 03 8月, 2013 1 次提交
  7. 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
  8. 26 7月, 2013 3 次提交
  9. 25 7月, 2013 2 次提交
  10. 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
  11. 19 6月, 2013 1 次提交
  12. 07 6月, 2013 1 次提交
  13. 06 6月, 2013 1 次提交
  14. 04 6月, 2013 2 次提交
  15. 29 5月, 2013 1 次提交
  16. 21 5月, 2013 1 次提交
    • J
      usb: ehci: Only sleep for post-resume handover if devices use persist · 9b790915
      Julius Werner 提交于
      The current EHCI code sleeps a flat 110ms in the resume path if there
      was a USB 1.1 device connected to its companion controller during
      suspend, waiting for the device to reappear and reset so that it can be
      handed back to the companion. This is necessary if the device uses
      persist, so that the companion controller can actually see it during its
      own resume path.
      
      However, if the device doesn't use persist, this is entirely
      unnecessary. We might just as well ignore it and have the normal device
      detection/reset/handoff code handle it asynchronously when it eventually
      shows up. As USB 1.1 devices are almost exclusively HIDs these days (for
      which persist has no value), this can allow distros to shave another
      tenth of a second off their resume time.
      
      In order to enable this optimization, the patch also adds a new
      usb_for_each_dev() iterator that is exported by the USB core and wraps
      bus_for_each_dev() with the logic to differentiate between struct
      usb_device and struct usb_interface on the usb_bus_type bus.
      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>
      9b790915
  17. 18 5月, 2013 5 次提交
  18. 17 5月, 2013 1 次提交
  19. 16 5月, 2013 1 次提交