1. 12 12月, 2009 1 次提交
  2. 23 9月, 2009 3 次提交
    • O
      USB: fix missing error check in probing · 1e5ea5e3
      Oliver Neukum 提交于
      usb: check for IO errors usb_set_interface can return
      
      if they happen while unbinding a flag is set to retry upon probe
      if they happen during probe they are handled as probe errors
      Signed-off-by: NOliver Neukum <oliver@neukum.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      1e5ea5e3
    • A
      USB: make intf.pm_usage an atomic_t · ccf5b801
      Alan Stern 提交于
      This patch (as1260) changes the pm_usage_cnt field in struct
      usb_interface from an int to an atomic_t.  This is so that drivers can
      invoke the usb_autopm_get_interface_async() and
      usb_autopm_put_interface_async() routines without locking and without
      fear of corrupting the pm_usage_cnt value.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      ccf5b801
    • A
      USB: add API for userspace drivers to "claim" ports · 7cbe5dca
      Alan Stern 提交于
      This patch (as1258) implements a feature that users have been asking
      for: It gives programs the ability to "claim" a port on a hub, via a
      new usbfs ioctl.  A device plugged into a "claimed" port will not be
      touched by the kernel beyond the immediate necessities of
      initialization and enumeration.
      
      In particular, when a device is plugged into a "claimed" port, the
      kernel will not select and install a configuration.  And when a config
      is installed by usbfs or sysfs, the kernel will not probe any drivers
      for any of the interfaces.  (However the kernel will fetch various
      string descriptors during enumeration.  One could argue that this
      isn't really necessary, but the strings are exported in sysfs.)
      
      The patch does not guarantee exclusive access to these devices; it is
      still possible for more than one program to open the device file
      concurrently.  Programs are responsible for coordinating access among
      themselves.
      
      A demonstration program showing how to use the new interface can be 
      found in an attachment to
      
      	http://marc.info/?l=linux-usb&m=124345857431452&w=2
      
      The patch also makes a small simplification to the hub driver,
      replacing a bunch of more-or-less useless variants of "out of memory"
      with a single message.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7cbe5dca
  3. 16 6月, 2009 3 次提交
  4. 28 1月, 2009 1 次提交
    • A
      USB: fix toggle mismatch in disable_endpoint paths · ddeac4e7
      Alan Stern 提交于
      This patch (as1200) finishes some fixes that were left incomplete by
      an earlier patch.
      
      Although nobody has addressed this issue in the past, it turns out
      that we need to distinguish between two different modes of disabling
      and enabling endpoints.  In one mode only the data structures in
      usbcore are affected, and in the other mode the host controller and
      device hardware states are affected as well.
      
      The earlier patch added an extra argument to the routines in the
      enable_endpoint pathways to reflect this difference.  This patch adds
      corresponding arguments to the disable_endpoint pathways.  Without
      this change, the endpoint toggle state can get out of sync between
      the host and the device.  The exact mechanism depends on the details
      of the host controller (whether or not it stores its own copy of the
      toggle values).
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NDan Streetman <ddstreet@ieee.org>
      Tested-by: NDan Streetman <ddstreet@ieee.org>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      ddeac4e7
  5. 08 1月, 2009 5 次提交
    • 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: 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
    • A
      USB: utilize round_jiffies_up_relative() · 4ec06d62
      Alan Stern 提交于
      This patch (as1178) uses the new round_jiffies_up_relative() routine
      for setting the autosuspend delayed_work timer.  It's appropriate
      since we don't care too much about the exact length of the delay, but
      we don't want it to be too short (rounded down).
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4ec06d62
    • I
      USB: Introduce usb_queue_reset() to do resets from atomic contexts · dc023dce
      Inaky Perez-Gonzalez 提交于
      This patch introduces a new call to be able to do a USB reset from an
      atomic contect. This is quite helpful in USB callbacks to handle
      errors (when the only thing that can be done is to do a device
      reset).
      
      It is done queuing a work struct that will do the actual reset. The
      struct is "attached" to an interface so pending requests from an
      interface are removed when said interface is unbound from the driver.
      
      The call flow then becomes:
      
      usb_queue_reset_device()
        __usb_queue_reset_device() [workqueue]
          usb_reset_device()
      
      usb_probe_interface()
        usb_cancel_queue_reset()      [error path]
      
      usb_unbind_interface()
        usb_cancel_queue_reset()
      
      usb_driver_release_interface()
        usb_cancel_queue_reset()
      
      Note usb_cancel_queue_reset() needs smarts to try not to unqueue when
      it is actually being executed. This happens when we run the reset from
      the workqueue: usb_reset_device() is called and on interface unbind
      time, usb_cancel_queue_reset() would be called. That would deadlock on
      cancel_work_sync(). To avoid that, we set (before running
      usb_reset_device()) usb_intf->reset_running and clear it inmediately
      after returning.
      
      Patch is against 2.6.28-rc2 and depends on
      http://marc.info/?l=linux-usb&m=122581634925308&w=2 (as submitted by
      Alan Stern).
      Signed-off-by: NInaky Perez-Gonzalez <inaky@linux.intel.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      dc023dce
    • 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
  6. 18 12月, 2008 1 次提交
  7. 23 10月, 2008 1 次提交
    • A
      USB: don't rebind drivers after failed resume or reset · 6c640945
      Alan Stern 提交于
      This patch (as1152) may help prevent some problems associated with the
      new policy of unbinding drivers that don't support suspend/resume or
      pre_reset/post_reset.  If for any reason the resume or reset fails, and
      the device is logically disconnected, there's no point in trying to
      rebind the driver.  So the patch checks for success before carrying
      out the unbind/rebind.
      
      There was a report from one user that this fixed a problem he was
      experiencing, but the details never became fully clear.  In any case,
      adding these tests can't hurt.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6c640945
  8. 18 10月, 2008 1 次提交
  9. 22 8月, 2008 4 次提交
    • A
      USB: Don't rebind before "complete" callback · 5096aedc
      Alan Stern 提交于
      This patch (as1130) fixes an incompatibility between the new PM
      infrastructure and USB power management.  We are not allowed to call
      drivers' probe routines during a system sleep transition between the
      "prepare" and "complete" callbacks, but that's exactly what we do when
      a driver doesn't have full suspend/resume support.  Such drivers are
      unbound during the "suspend" call and reprobed during the "resume" call.
      
      The patch causes the reprobe step to be skipped if the "complete"
      callback hasn't been issued yet, i.e., if the interface's
      dev.power.status field is not equal to DPM_ON.  Thus during the
      "resume" callback nothing bad will happen, and during the final
      "complete" callback the reprobing will occur as desired.
      
      This fixes the problem reported in Bugzilla #11263.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      5096aedc
    • 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
    • A
      USB: Defer Set-Interface for suspended devices · 55151d7d
      Alan Stern 提交于
      This patch (as1128) fixes one of the problems related to the new PM
      infrastructure.  We are not allowed to register new child devices
      during the middle of a system sleep transition, but unbinding a USB
      driver causes the core to automatically install altsetting 0 and
      thereby create new endpoint pseudo-devices.
      
      The patch fixes this problem (and the related problem that installing
      altsetting 0 will fail if the device is suspended) by deferring the
      Set-Interface call until some later time when it is legal and can
      succeed.  Possible later times are: when a new driver is being probed
      for the interface, and when the interface is being resumed.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      55151d7d
    • A
      USB: Add udev argument to interface suspend/resume functions · 65605ae8
      Alan Stern 提交于
      This patch (as1127) makes a minor change to the prototypes of the
      usb_suspend_interface() and usb_resume_interface() routines.  Now the
      usb_device structure is passed as an argument, instead of being
      computed on-the-fly from the usb_interface argument.
      
      It makes the code look simpler, even if it really isn't much different
      from before.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      65605ae8
  10. 14 8月, 2008 2 次提交
  11. 22 7月, 2008 5 次提交
    • A
      USB: Force unbinding of drivers lacking reset_resume or other methods · 78d9a487
      Alan Stern 提交于
      This patch (as1024) takes care of a FIXME issue: Drivers that don't
      have the necessary suspend, resume, reset_resume, pre_reset, or
      post_reset methods will be unbound and their interface reprobed when
      one of the unsupported events occurs.
      
      This is made slightly more difficult by the fact that bind operations
      won't work during a system sleep transition.  So instead the code has
      to defer the operation until the transition ends.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      78d9a487
    • A
      USB: implement "soft" unbinding · 9da82bd4
      Alan Stern 提交于
      This patch (as1091) changes the way usbcore handles interface
      unbinding.  If the interface's driver supports "soft" unbinding (a new
      flag in the driver structure) then in-flight URBs are not cancelled
      and endpoints are not disabled.  Instead the driver is allowed to
      continue communicating with the device (although of course it should
      stop before its disconnect routine returns).
      
      The purpose of this change is to allow drivers to do a clean shutdown
      when they get unbound from a device that is still plugged in.  Killing
      all the URBs and disabling the endpoints before calling the driver's
      disconnect method doesn't give the driver any control over what
      happens, and it can leave devices in indeterminate states.  For
      example, when usb-storage unbinds it doesn't want to stop while in the
      middle of transmitting a SCSI command.
      
      The soft_unbind flag is added because in the past, a number of drivers
      have experienced problems related to ongoing I/O after their disconnect
      routine returned.  Hence "soft" unbinding is made available only to
      drivers that claim to support it.
      
      The patch also replaces "interface_to_usbdev(intf)" with "udev" in a
      couple of places, a minor simplification.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9da82bd4
    • A
      USB: try to salvage lost power sessions · 8808f00c
      Alan Stern 提交于
      This patch (as1073) adds to khubd a way to recover from power-session
      interruption caused by transient connect-change or enable-change
      events.  After the debouncing period, khubd attempts to do a
      USB-Persist-style reset or reset-resume.  If it works, the connection
      will remain unscathed.
      
      The upshot is that we will be more immune to noise caused by EMI.  The
      grace period is on the order of 100 ms, so this won't permit recovery
      from the "accidentally knocked the USB cable out of its socket" type
      of event, but it's a start.
      
      As an added bonus, if a device was suspended when the system goes to
      sleep then we no longer need to check for power-session interruptions
      when the system wakes up.  Khubd will naturally see the status change
      while processing the device's parent hub and will do the right thing.
      
      The remote_wakeup() routine is changed; now it expects the caller to
      acquire the device lock rather than acquiring the lock itself.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8808f00c
    • A
      USB: simplify hub_restart() logic · 6ee0b270
      Alan Stern 提交于
      This patch (as1081) straightens out the logic of the hub_restart()
      routine.  Each port of the hub is scanned and the driver makes sure
      that ports which are supposed to be disabled really _are_ disabled.
      Any ports with a significant change in status are flagged in
      hub->change_bits, so that khubd can focus on them without the need to
      scan all the ports a second time -- which means the hub->activating
      flag is no longer needed.
      
      Also, it is now recognized explicitly that the only reason for
      resuming a port which was not suspended is to carry out a reset-resume
      operation, which happens only in a non-CONFIG_USB_SUSPEND setting.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6ee0b270
    • K
      USB: usb dev_name() instead of dev->bus_id · 7071a3ce
      Kay Sievers 提交于
      The bus_id field is going away, use the dev_name() function instead.
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7071a3ce
  12. 25 4月, 2008 4 次提交
    • H
      USB: replace remaining __FUNCTION__ occurrences · 441b62c1
      Harvey Harrison 提交于
      __FUNCTION__ is gcc-specific, use __func__
      Signed-off-by: NHarvey Harrison <harvey.harrison@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      441b62c1
    • A
      USB: HCDs use the do_remote_wakeup flag · 58a97ffe
      Alan Stern 提交于
      When a USB device is suspended, whether or not it is enabled for
      remote wakeup depends on the device_may_wakeup() setting.  The setting
      is then saved in the do_remote_wakeup flag.
      
      Later on, however, the device_may_wakeup() value can change because of
      user activity.  So when testing whether a suspended device is or
      should be enabled for remote wakeup, we should always test
      do_remote_wakeup instead of device_may_wakeup().  This patch (as1076)
      makes that change for root hubs in several places.
      
      The patch also adjusts uhci-hcd so that when an autostopped controller
      is suspended, the remote wakeup setting agrees with the value recorded
      in the root hub's do_remote_wakeup flag.
      
      And the patch adjusts ehci-hcd so that wakeup events on selectively
      suspended ports (i.e., the bus itself isn't suspended) don't turn on
      the PME# wakeup signal.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      58a97ffe
    • A
      USB: remove dev->power.power_state · 70a1c9e0
      Alan Stern 提交于
      power.power_state is scheduled for removal.  This patch (as1053)
      removes all uses of that field from drivers/usb.  Almost all of them
      were write-only, the most significant exceptions being sl811-hcd.c and
      u132-hcd.c.
      
      Part of this patch was written by Pavel Machek.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: David Brownell <david-b@pacbell.net>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      70a1c9e0
    • A
      USB: EHCI: carry out port handover during each root-hub resume · 3bb1af52
      Alan Stern 提交于
      This patch (as1044) causes EHCI port handover for non-high-speed
      devices to occur during every root-hub resume, not just in cases where
      the controller lost power or was reset.  This is necessary because:
      
      	When some machines go into suspend, they remove power from
      	on-board USB devices while retaining suspend current for USB
      	controllers.
      
      	The user might well unplug a USB device while the system is
      	suspended and then plug it back in before resuming.
      
      A corresponding change is made to the core resume routine; now
      high-speed root hubs will always be resumed when the system wakes up,
      even if they were suspended before the system went to sleep.  If this
      weren't done then EHCI port handover wouldn't work, since it is called
      when the EHCI root hub is resumed.
      
      Finally, a comment is added to the hub driver explaining the khubd has
      to be freezable; if it weren't frozen then it could interfere with
      port handover.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3bb1af52
  13. 02 2月, 2008 3 次提交
  14. 25 1月, 2008 1 次提交
  15. 29 11月, 2007 1 次提交
    • A
      USB: uevent environment key fix · 4a9bee82
      Alan Stern 提交于
      This patch (as1010) was written by both Kay Sievers and me.  It solves
      the problem of duplicated keys in USB uevent structures by refactoring
      the uevent subroutines, taking advantage of the way the hotplug core
      calls uevent handlers for the device's bus and for the device's type.
      Keys needed for both USB-device and USB-interface events are added in
      usb_uevent(), which is the bus handler.  Keys appropriate only for
      USB-device or USB-interface events are added in usb_dev_uevent() or
      usb_if_uevent() respectively, the type handlers.
      
      In addition, unnecessary tests for NULL pointers are removed as are
      duplicated debugging log statements.
      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>
      4a9bee82
  16. 13 10月, 2007 4 次提交
    • A
      USB: fix race in autosuspend reschedule · d1aa3e6a
      Alan Stern 提交于
      This patch (as1002) fixes a small race which can occur when a driver
      expects usbcore to reschedule an autosuspend request.  If the request
      arrives too late, it won't be rescheduled.  The patch adds an extra
      argument to autosuspend_check(), indicating that a reschedule is
      needed no matter how much time has elapsed.
      
      It also tries to avoid letting asynchronous changes to the value of
      jiffies cause a delay to become negative, by caching a local copy of
      the current time.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d1aa3e6a
    • A
      USB: skip autosuspended devices during system resume · 271f9e68
      Alan Stern 提交于
      System suspends and hibernation are supposed to be as transparent as
      possible.  By this reasoning, if a USB device is already autosuspended
      before the system sleep begins then it should remain autosuspended
      after the system wakes up.
      
      This patch (as1001) adds a skip_sys_resume flag to the usb_device
      structure and uses it to avoid waking up devices which were suspended
      when a system sleep began.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      271f9e68
    • A
      USB: don't propagate FREEZE or PRETHAW suspends · 7108f284
      Alan Stern 提交于
      This patch (as992) fixes a recently-added bug.  During a FREEZE or
      PRETHAW suspend notification, non-root devices don't actually get
      suspended.  So we shouldn't tell their parent hubs that they did.
      
      (This code path used to be skipped over, until the FREEZE/PRETHAW test
      got moved out of usb_suspend_both() into generic_suspend().)
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7108f284
    • A
      USB: flush outstanding URBs when suspending · 6840d255
      Alan Stern 提交于
      This patch (as989) makes usbcore flush all outstanding URBs for each
      device as the device is suspended.  This will be true even when
      CONFIG_USB_SUSPEND is not enabled.
      
      In addition, an extra can_submit flag is added to the usb_device
      structure.  That flag will be turned off whenever a suspend request
      has been received for the device, even if the device isn't actually
      suspended because CONFIG_USB_SUSPEND isn't set.
      
      It's no longer necessary to check for the device state being equal to
      USB_STATE_SUSPENDED during URB submission; that check can be replaced
      by a check of the can_submit flag.  This also permits us to remove
      some questionable references to the deprecated power.power_state field.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6840d255