1. 21 5月, 2010 1 次提交
  2. 01 5月, 2010 1 次提交
  3. 03 3月, 2010 2 次提交
    • H
      USB: Move hcd free_dev call into usb_disconnect to fix oops · f7410ced
      Herbert Xu 提交于
      USB: Move hcd free_dev call into usb_disconnect
      
      I found a way to oops the kernel:
      
      1. Open a USB device through devio.
      2. Remove the hcd module in the host kernel.
      3. Close the devio file descriptor.
      
      The problem is that closing the file descriptor does usb_release_dev
      as it is the last reference.  usb_release_dev then tries to invoke
      the hcd free_dev function (or rather dereferencing the hcd driver
      struct).  This causes an oops as the hcd driver has already been
      unloaded so the struct is gone.
      
      This patch tries to fix this by bringing the free_dev call earlier
      and into usb_disconnect.  I have verified that repeating the
      above steps no longer crashes with this patch applied.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f7410ced
    • A
      USB: convert to the runtime PM framework · 9bbdf1e0
      Alan Stern 提交于
      This patch (as1329) converts the USB stack over to the PM core's
      runtime PM framework.  This involves numerous changes throughout
      usbcore, especially to hub.c and driver.c.  Perhaps the most notable
      change is that CONFIG_USB_SUSPEND now depends on CONFIG_PM_RUNTIME
      instead of CONFIG_PM.
      
      Several fields in the usb_device and usb_interface structures are no
      longer needed.  Some code which used to depend on CONFIG_USB_PM now
      depends on CONFIG_USB_SUSPEND (requiring some rearrangement of header
      files).
      
      The only visible change in behavior should be that following a system
      sleep (resume from RAM or resume from hibernation), autosuspended USB
      devices will be resumed just like everything else.  They won't remain
      suspended.  But if they aren't in use then they will naturally
      autosuspend again in a few seconds.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9bbdf1e0
  4. 24 12月, 2009 1 次提交
  5. 16 12月, 2009 1 次提交
  6. 15 12月, 2009 2 次提交
    • R
      USB: Close usb_find_interface race v3 · c2d284ee
      Russ Dill 提交于
      USB drivers that create character devices call usb_register_dev in their
      probe function. This associates the usb_interface device with that minor
      number and creates the character device and announces it to the world.
      However, the driver's probe function is called before the new
      usb_interface is added to the driver's klist_devices.
      
      This is a problem because userspace will respond to the character device
      creation announcement by opening the character device. The driver's open
      function will the call usb_find_interface to find the usb_interface
      associated with that minor number. usb_find_interface will walk the
      driver's list of devices and find the usb_interface with the matching
      minor number.
      
      Because the announcement happens before the usb_interface is added to the
      driver's klist_devices, a race condition exists. A straightforward fix
      is to walk the list of devices on usb_bus_type instead since the device
      is added to that list before the announcement occurs.
      
      bus_find_device calls get_device to bump the reference count on the found
      device. It is arguable that the reference count should be dropped by the
      caller of usb_find_interface instead of usb_find_interface, however,
      the current users of usb_find_interface do not expect this.
      
      The original version of this patch only matched against minor number
      instead of driver and minor number. This version matches against both.
      Signed-off-by: NRuss Dill <Russ.Dill@gmail.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      c2d284ee
    • G
      Revert "USB: Close usb_find_interface race" · ab7cd8c7
      Greg Kroah-Hartman 提交于
      This reverts commit a2582bd4.
      
      It turned out to be buggy and broke USB printers from working.
      
      Cc: Russ Dill <Russ.Dill@gmail.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      ab7cd8c7
  7. 12 12月, 2009 3 次提交
    • F
      USB: core: fix sparse warning for static function · 719a6e88
      Felipe Balbi 提交于
      Fix the following sparse warning:
      
      drivers/usb/core/usb.c:1033:15: warning: symbol 'usb_debug_devices' was not declared. Should it be static?
      Signed-off-by: NFelipe Balbi <felipe.balbi@nokia.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      719a6e88
    • S
      USB: Refactor code to find alternate interface settings. · 91017f9c
      Sarah Sharp 提交于
      Refactor out the code to find alternate interface settings into
      usb_find_alt_setting().  Print a debugging message and return null if the
      alt setting is not found.
      
      While we're at it, correct a bug in the refactored code.  The interfaces
      in the configuration's interface cache are not necessarily in numerical
      order, so we can't just use the interface number as an array index.  Loop
      through the interface caches, looking for the correct interface.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      91017f9c
    • R
      USB: Close usb_find_interface race · a2582bd4
      Russ Dill 提交于
      USB drivers that create character devices call usb_register_dev in their
      probe function. This associates the usb_interface device with that minor
      number and creates the character device and announces it to the world.
      However, the driver's probe function is called before the new
      usb_interface is added to the driver's klist_devices.
      
      This is a problem because userspace will respond to the character device
      creation announcement by opening the character device. The driver's open
      function will the call usb_find_interface to find the usb_interface
      associated with that minor number. usb_find_interface will walk the
      driver's list of devices and find the usb_interface with the matching
      minor number.
      
      Because the announcement happens before the usb_interface is added to the
      driver's klist_devices, a race condition exists. A straightforward fix
      is to walk the list of devices on usb_bus_type instead since the device
      is added to that list before the announcement occurs.
      
      bus_find_device calls get_device to bump the reference count on the found
      device. It is arguable that the reference count should be dropped by the
      caller of usb_find_interface instead of usb_find_interface, however,
      the current users of usb_find_interface do not expect this.
      Signed-off-by: NRuss Dill <Russ.Dill@gmail.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      a2582bd4
  8. 23 9月, 2009 2 次提交
    • S
      USB: xhci: Set route string for all devices. · 4a0cd967
      Sarah Sharp 提交于
      The xHCI driver needs to set the route string in the slot context of all
      devices, not just SuperSpeed devices.  The route string concept was added
      in the USB 3.0 specification, section 10.1.3.2.  Each hub in the topology
      is expected to have no more than 15 ports in order for the route string of
      a device to be unique.  SuperSpeed hubs are restricted to only having 15
      ports, but FS/LS/HS hubs are not.  The xHCI specification says that if the
      port number the device is under is greater than 15, that portion of the
      route string shall be set to 15.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4a0cd967
    • J
      USB: make usb_buffer_map_sg consistent with doc · 2912282c
      Jiri Slaby 提交于
      usb_buffer_map_sg should return negative on error according to
      its documentation. But dma_map_sg returns 0 on error. Take this
      into account and return -ENOMEM in such situation.
      
      While at it, return -EINVAL instead of -1 when wrong input is
      passed in.
      
      If this wasn't done, usb_sg_* operations used after usb_sg_init
      which returned 0 may cause oopses/deadlocks since we don't init
      structures/entries, esp. completion and status entry.
      Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2912282c
  9. 20 9月, 2009 1 次提交
  10. 16 6月, 2009 8 次提交
  11. 18 4月, 2009 1 次提交
    • D
      USB: add reset endpoint operations · 3444b26a
      David Vrabel 提交于
      Wireless USB endpoint state has a sequence number and a current
      window and not just a single toggle bit.  So allow HCDs to provide a
      endpoint_reset method and call this or clear the software toggles as
      required (after a clear halt, set configuration etc.).
      
      usb_settoggle() and friends are then HCD internal and are moved into
      core/hcd.h and all device drivers call usb_reset_endpoint() instead.
      
      If the device endpoint state has been reset (with a clear halt) but
      the host endpoint state has not then subsequent data transfers will
      not complete. The device will only work again after it is reset or
      disconnected.
      Signed-off-by: NDavid Vrabel <david.vrabel@csr.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3444b26a
  12. 08 1月, 2009 6 次提交
    • A
      USB: re-enable interface after driver unbinds · 2caf7fcd
      Alan Stern 提交于
      This patch (as1197) fixes an error introduced recently.  Since a
      significant number of devices can't handle Set-Interface requests, we
      no longer call usb_set_interface() when a driver unbinds from an
      interface, provided the interface is already in altsetting 0.  However
      the interface still does get disabled, and the call to
      usb_set_interface() was the only thing re-enabling it.  Since the
      interface doesn't get re-enabled, further attempts to use it fail.
      
      So the patch adds a call to usb_enable_interface() when a driver
      unbinds and the interface is in altsetting 0.  For this to work
      right, the interface's endpoints have to be re-enabled but their
      toggles have to be left alone.  Therefore an additional argument is
      added to usb_enable_endpoint() and usb_enable_interface(), a flag
      indicating whether or not the endpoint toggles should be reset.
      
      This is a forward-ported version of a patch which fixes Bugzilla
      #12301.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NDavid Roka <roka@dawid.hu>
      Reported-by: NErik Ekman <erik@kryo.se>
      Tested-by: NErik Ekman <erik@kryo.se>
      Tested-by: NAlon Bar-Lev <alon.barlev@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2caf7fcd
    • A
      USB: utilize the bus notifiers · 3b23dd6f
      Alan Stern 提交于
      This patch (as1185) makes usbcore take advantage of the bus
      notifications sent out by the driver core.  Now we can create all our
      device and interface attribute files before the device or interface
      uevent is broadcast.
      
      A side effect is that we no longer create the endpoint "pseudo"
      devices at the same time as a device or interface is registered -- it
      seems like a bad idea to try registering an endpoint before the
      registration of its parent is complete.  So the routines for creating
      and removing endpoint devices have been split out and renamed, and
      they are called explicitly when needed.  A new bitflag is used for
      keeping track of whether or not the interface's endpoint devices have
      been created, since (just as with the interface attributes) they vary
      with the altsetting and hence can be changed at random times.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3b23dd6f
    • A
      USB: Enhance usage of pm_message_t · 65bfd296
      Alan Stern 提交于
      This patch (as1177) modifies the USB core suspend and resume
      routines.  The resume functions now will take a pm_message_t argument,
      so they will know what sort of resume is occurring.  The new argument
      is also passed to the port suspend/resume and bus suspend/resume
      routines (although they don't use it for anything but debugging).
      
      In addition, special pm_message_t values are used for user-initiated,
      device-initiated (i.e., remote wakeup), and automatic suspend/resume.
      By testing these values, drivers can tell whether or not a particular
      suspend was an autosuspend.  Unfortunately, they can't do the same for
      resumes -- not until the pm_message_t argument is also passed to the
      drivers' resume methods.  That will require a bigger change.
      
      IMO, the whole Power Management framework should have been set up this
      way in the first place.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      65bfd296
    • R
      USB: Don't use __module_param_call; use core_param. · 785895ff
      Rusty Russell 提交于
      Impact: cleanup
      
      Found this when I changed args to __module_param_call.  We now have
      core_param for exactly this, but Greg assures me "nousb" is used as a
      module parameter, so we need the #ifdef MODULE.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: Pete Zaitcev <zaitcev@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      785895ff
    • A
      USB: add asynchronous autosuspend/autoresume support · 9ac39f28
      Alan Stern 提交于
      This patch (as1160b) adds support routines for asynchronous autosuspend
      and autoresume, with accompanying documentation updates.  There
      already are several potential users of this interface, and others are
      likely to arise as autosuspend support becomes more widespread.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9ac39f28
    • A
      USB: change interface to usb_lock_device_for_reset() · 011b15df
      Alan Stern 提交于
      This patch (as1161) changes the interface to
      usb_lock_device_for_reset().  The existing interface is apparently not
      very clear, judging from the fact that several of its callers don't
      use it correctly.  The new interface always returns 0 for success and
      it always requires the caller to unlock the device afterward.
      
      The new routine will not return immediately if it is called while the
      driver's probe method is running.  Instead it will wait until the
      probe is over and the device has been unlocked.  This shouldn't cause
      any problems; I don't know of any cases where drivers call
      usb_lock_device_for_reset() during probe.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: Pete Zaitcev <zaitcev@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      011b15df
  13. 07 1月, 2009 1 次提交
    • R
      PM: Simplify the new suspend/hibernation framework for devices · adf09493
      Rafael J. Wysocki 提交于
      PM: Simplify the new suspend/hibernation framework for devices
      
      Following the discussion at the Kernel Summit, simplify the new
      device PM framework by merging 'struct pm_ops' and
      'struct pm_ext_ops' and removing pointers to 'struct pm_ext_ops'
      from 'struct platform_driver' and 'struct pci_driver'.
      
      After this change, the suspend/hibernation callbacks will only
      reside in 'struct device_driver' as well as at the bus type/
      device class/device type level.  Accordingly, PCI and platform
      device drivers are now expected to put their suspend/hibernation
      callbacks into the 'struct device_driver' embedded in
      'struct pci_driver' or 'struct platform_driver', respectively.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NPavel Machek <pavel@suse.cz>
      Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      adf09493
  14. 22 8月, 2008 1 次提交
    • A
      USB: Add new PM callback methods for USB · f2189c47
      Alan Stern 提交于
      This patch (as1129) adds support for the new PM callbacks to usbcore.
      The new callbacks merely invoke the same old USB power management
      routines as the old ones did.
      
      A minor improvement is that the callbacks are present only in the
      "USB-device" device_type structure, rather than in the bus_type
      structure.  This way they will be invoked only for USB devices, not
      for USB interfaces.  The core USB PM routines automatically handle
      suspending and resuming interfaces along with their devices.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f2189c47
  15. 22 7月, 2008 2 次提交
  16. 15 5月, 2008 1 次提交
    • A
      USB: create attributes before sending uevent · 2e5f10e4
      Alan Stern 提交于
      This patch (as1087d) fixes a long-standing problem in usbcore: Device,
      interface, and endpoint attributes aren't added until _after_ the
      creation uevent has already been broadcast.
      
      Unfortunately there are a few attributes which cannot be created that
      early.  The "descriptors" attribute is binary and so must be created
      separately.  The power-management attributes can't be created until
      the dev/power/ group exists.  And the interface string can vary from
      one altsetting to another, so it has to be created dynamically.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2e5f10e4
  17. 05 3月, 2008 1 次提交
  18. 04 3月, 2008 1 次提交
  19. 02 2月, 2008 4 次提交
    • G
      USB: fix codingstyle issues in drivers/usb/core/*.c · 2c044a48
      Greg Kroah-Hartman 提交于
      Fixes a number of coding style issues in the remaining .c files in
      drivers/usb/core/
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2c044a48
    • G
      USB: mark USB drivers as being GPL only · 782e70c6
      Greg Kroah-Hartman 提交于
      Over two years ago, the Linux USB developers stated that they believed
      there was no way to create a USB kernel driver that was not under the
      GPL.  This patch moves the USB apis to enforce that decision.
      
      There are no known closed source USB drivers in the wild, so this patch
      should cause no problems.
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      782e70c6
    • S
      USB: Export suspend statistics · 15123006
      Sarah Sharp 提交于
      This patch exports two statistics to userspace:
      /sys/bus/usb/device/.../power/connected_duration
      /sys/bus/usb/device/.../power/active_duration
      
      connected_duration is the total time (in msec) that the device has
      been connected.  active_duration is the total time the device has not
      been suspended.  With these two statistics, tools like PowerTOP can
      calculate the percentage time that a device is active, i.e. not
      suspended or auto-suspended.
      
      Users can also use the active_duration to check if a device is actually
      autosuspended.  Currently, they can set power/level to auto and
      power/autosuspend to a positive timeout, but there's no way to know from
      userspace if a device was actually autosuspended without looking at the
      dmesg output.  These statistics will be useful in creating an automated
      userspace script to test autosuspend for USB devices.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      15123006
    • A
      USB: make ksuspend_usbd thread non-freezable · 4145ed6d
      Alan Stern 提交于
      This patch (as1012b) makes the ksuspend_usbd kernel thread
      non-freezable.  Since the PM core has been changed to lock all devices
      during a system sleep, the thread no longer needs to be frozen.  It
      won't interfere with a system sleep because before trying to resume a
      root hub device, it acquires the device's lock.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4145ed6d