1. 21 1月, 2010 2 次提交
    • S
      USB: Fix duplicate sysfs problem after device reset. · 04a723ea
      Sarah Sharp 提交于
      Borislav Petkov reports issues with duplicate sysfs endpoint files after a
      resume from a hibernate.  It turns out that the code to support alternate
      settings under xHCI has issues when a device with a non-default alternate
      setting is reset during the hibernate:
      
      [  427.681810] Restarting tasks ...
      [  427.681995] hub 1-0:1.0: state 7 ports 6 chg 0004 evt 0000
      [  427.682019] usb usb3: usb resume
      [  427.682030] ohci_hcd 0000:00:12.0: wakeup root hub
      [  427.682191] hub 1-0:1.0: port 2, status 0501, change 0000, 480 Mb/s
      [  427.682205] usb 1-2: usb wakeup-resume
      [  427.682226] usb 1-2: finish reset-resume
      [  427.682886] done.
      [  427.734658] ehci_hcd 0000:00:12.2: port 2 high speed
      [  427.734663] ehci_hcd 0000:00:12.2: GetStatus port 2 status 001005 POWER sig=se0 PE CONNECT
      [  427.746682] hub 3-0:1.0: hub_reset_resume
      [  427.746693] hub 3-0:1.0: trying to enable port power on non-switchable hub
      [  427.786715] usb 1-2: reset high speed USB device using ehci_hcd and address 2
      [  427.839653] ehci_hcd 0000:00:12.2: port 2 high speed
      [  427.839666] ehci_hcd 0000:00:12.2: GetStatus port 2 status 001005 POWER sig=se0 PE CONNECT
      [  427.847717] ohci_hcd 0000:00:12.0: GetStatus roothub.portstatus [1] = 0x00010100 CSC PPS
      [  427.915497] hub 1-2:1.0: remove_intf_ep_devs: if: ffff88022f9e8800 ->ep_devs_created: 1
      [  427.915774] hub 1-2:1.0: remove_intf_ep_devs: bNumEndpoints: 1
      [  427.915934] hub 1-2:1.0: if: ffff88022f9e8800: endpoint devs removed.
      [  427.916158] hub 1-2:1.0: create_intf_ep_devs: if: ffff88022f9e8800 ->ep_devs_created: 0, ->unregistering: 0
      [  427.916434] hub 1-2:1.0: create_intf_ep_devs: bNumEndpoints: 1
      [  427.916609]  ep_81: create, parent hub
      [  427.916632] ------------[ cut here ]------------
      [  427.916644] WARNING: at fs/sysfs/dir.c:477 sysfs_add_one+0x82/0x96()
      [  427.916649] Hardware name: System Product Name
      [  427.916653] sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:12.2/usb1/1-2/1-2:1.0/ep_81'
      [  427.916658] Modules linked in: binfmt_misc kvm_amd kvm powernow_k8 cpufreq_ondemand cpufreq_powersave cpufreq_userspace freq_table cpufreq_conservative ipv6 vfat fat
      +8250_pnp 8250 pcspkr ohci_hcd serial_core k10temp edac_core
      [  427.916694] Pid: 278, comm: khubd Not tainted 2.6.33-rc2-00187-g08d869aa-dirty #13
      [  427.916699] Call Trace:
      
      The problem is caused by a mismatch between the USB core's view of the
      device state and the USB device and xHCI host's view of the device state.
      
      After the device reset and re-configuration, the device and the xHCI host
      think they are using alternate setting 0 of all interfaces.  However, the
      USB core keeps track of the old state, which may include non-zero
      alternate settings.  It uses intf->cur_altsetting to keep the endpoint
      sysfs files for the old state across the reset.
      
      The bandwidth allocation functions need to know what the xHCI host thinks
      the current alternate settings are, so original patch set
      intf->cur_altsetting to the alternate setting 0.  This caused duplicate
      endpoint files to be created.
      
      The solution is to not set intf->cur_altsetting before calling
      usb_set_interface() in usb_reset_and_verify_device().  Instead, we add a
      new flag to struct usb_interface to tell usb_hcd_alloc_bandwidth() to use
      alternate setting 0 as the currently installed alternate setting.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NBorislav Petkov <petkovbb@googlemail.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      04a723ea
    • A
      USB: add missing delay during remote wakeup · 49d0f078
      Alan Stern 提交于
      This patch (as1330) fixes a bug in khbud's handling of remote
      wakeups.  When a device sends a remote-wakeup request, the parent hub
      (or the host controller driver, for directly attached devices) begins
      the resume sequence and notifies khubd when the sequence finishes.  At
      this point the port's SUSPEND feature is automatically turned off.
      
      However the device needs an additional 10-ms resume-recovery time
      (TRSMRCY in the USB spec).  Khubd does not wait for this delay if the
      SUSPEND feature is off, and as a result some devices fail to behave
      properly following a remote wakeup.  This patch adds the missing
      delay to the remote-wakeup path.
      
      It also extends the resume-signalling delay used by ehci-hcd and
      uhci-hcd from 20 ms (the value in the spec) to 25 ms (the value we use
      for non-remote-wakeup resumes).  The extra time appears to help some
      devices.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org>
      Cc: Rickard Bellini <rickard.bellini@ericsson.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      49d0f078
  2. 24 12月, 2009 2 次提交
    • A
      USB: fix bugs in usb_(de)authorize_device · da307123
      Alan Stern 提交于
      This patch (as1315) fixes some bugs in the USB core authorization
      code:
      
      	usb_deauthorize_device() should deallocate the device strings
      	instead of leaking them, and it should invoke
      	usb_destroy_configuration() (which does proper reference
      	counting) instead of freeing the config information directly.
      
      	usb_authorize_device() shouldn't change the device strings
      	until it knows that the authorization will succeed, and it should
      	autosuspend the device at the end (having autoresumed the
      	device at the start).
      
      	Because the device strings can be changed, the sysfs routines
      	to display the strings must protect the string pointers by
      	locking the device.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Inaky Perez-Gonzalez <inaky@linux.intel.com>
      Acked-by: NDavid Vrabel <david.vrabel@csr.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      da307123
    • A
      USB: rename usb_configure_device · 8d8558d1
      Alan Stern 提交于
      This patch (as1314) renames usb_configure_device() and
      usb_configure_device_otg() in the hub driver.  Neither name is
      appropriate because these routines enumerate devices, they don't
      configure them.  That's handled by usb_choose_configuration() and
      usb_set_configuration().
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8d8558d1
  3. 12 12月, 2009 6 次提交
    • F
      USB: core: hub: fix sparse warning · 2eb5052e
      Felipe Balbi 提交于
      Fix the following sparse warning:
      
      drivers/usb/core/hub.c:1664:37: warning: Using plain integer as NULL pointer
      Signed-off-by: NFelipe Balbi <felipe.balbi@nokia.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2eb5052e
    • S
      USB: Check bandwidth when switching alt settings. · 3f0479e0
      Sarah Sharp 提交于
      Make the USB core check the bandwidth when switching from one
      interface alternate setting to another.  Also check the bandwidth
      when resetting a configuration (so that alt setting 0 is used).  If
      this check fails, the device's state is unchanged.  If the device
      refuses the new alt setting, re-instate the old alt setting in the
      host controller hardware.
      
      If a USB device doesn't have an alternate interface setting 0, install
      the first alt setting in its descriptors when a new configuration is
      requested, or the device is reset.
      
      Add a mutex per root hub to protect bandwidth operations:
      adding/reseting/changing configurations, and changing alternate interface
      settings.  We want to ensure that the xHCI host controller and the USB
      device are set up for the same configurations and alternate settings.
      There are two (possibly three) steps to do this:
      
       1. The host controller needs to check that bandwidth is available for a
          different setting, by issuing and waiting for a configure endpoint
          command.
       2. Once that returns successfully, a control message is sent to the
          device.
       3. If that fails, the host controller must be notified through another
          configure endpoint command.
      
      The mutex is used to make these three operations seem atomic, to prevent
      another driver from using more bandwidth for a different device while
      we're in the middle of these operations.
      
      While we're touching the bandwidth code, rename usb_hcd_check_bandwidth()
      to usb_hcd_alloc_bandwidth().  This function does more than just check
      that the bandwidth change won't exceed the bus bandwidth; it actually
      changes the bandwidth configuration in the xHCI host controller.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3f0479e0
    • A
      USB: prepare for changover to Runtime PM framework · 8e4ceb38
      Alan Stern 提交于
      This patch (as1303) revises the USB Power Management infrastructure to
      make it compatible with the new driver-model Runtime PM framework:
      
      	Drivers are no longer allowed to access intf->pm_usage_cnt
      	directly; the PM framework manages its own usage counters.
      
      	usb_autopm_set_interface() is eliminated, because it directly
      	sets intf->pm_usage_cnt.
      
      	usb_autopm_enable() and usb_autopm_disable() are eliminated,
      	because they call usb_autopm_set_interface().
      
      	usb_autopm_get_interface_no_resume() and
      	usb_autopm_put_interface_no_suspend() are added.  They
      	correspond to pm_runtime_get_noresume() and
      	pm_runtime_put_noidle() in the PM framework.
      
      	The power/level attribute no longer accepts "suspend", only
      	"on" and "auto".  The PM framework doesn't allow devices to be
      	forced into a suspended mode.
      
      The hub driver contains the only code that violates the new
      guidelines.  It is updated to use the new interface routines instead.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8e4ceb38
    • A
      USB: add a "remove hardware" sysfs attribute · 253e0572
      Alan Stern 提交于
      This patch (as1297) adds a "remove" attribute to each USB device's
      directory in sysfs.  Writing to this attribute causes the device to be
      deconfigured (the same as writing 0 to the "bConfigurationValue"
      attribute) and then tells the hub driver to disable the device's
      upstream port.  The device remains locked during these activities so
      there is no possibility of it getting reconfigured in between.  The
      port will remain disabled until after the device is unplugged.
      
      The purpose of this is to provide a means for user programs to imitate
      the "Safely remove hardware" applet in Windows.  Some devices do
      expect their ports to be disabled before they are unplugged, and they
      provide visual feedback to users indicating when they can safely be
      unplugged.
      
      The security implications are minimal.  Writing to the "remove"
      attribute is no more dangerous than writing to the
      "bConfigurationValue" attribute.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: David Zeuthen <davidz@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      253e0572
    • A
      USB: don't use a fixed DMA mapping for hub status URBs · d697cdda
      Alan Stern 提交于
      This patch (as1296) gets rid of the fixed DMA-buffer mapping used by
      the hub driver for its status URB.  This URB doesn't get used much --
      mainly when a device is plugged in or unplugged -- so the dynamic
      mapping overhead is minimal.  And most systems have many fewer
      external hubs than root hubs, which don't need a mapped buffer anyway.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d697cdda
    • O
      USB: improved error handling in usb_port_suspend() · 0c487206
      Oliver Neukum 提交于
      usb: better error handling in usb_port_suspend
      
      - disable remote wakeup only if it was enabled
      - refuse to autosuspend if remote wakeup fails to be enabled
      Signed-off-by: NOliver Neukum <oliver@neukum.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0c487206
  4. 01 12月, 2009 1 次提交
    • A
      USB: EHCI: don't send Clear-TT-Buffer following a STALL · c2f6595f
      Alan Stern 提交于
      This patch (as1304) fixes a regression in ehci-hcd.  Evidently some
      hubs don't handle Clear-TT-Buffer requests correctly, so we should
      avoid sending them when they don't appear to be absolutely necessary.
      The reported symptom is that output on a downstream audio device cuts
      out because the hub stops relaying isochronous packets.
      
      The patch prevents Clear-TT-Buffer requests from being sent following
      a STALL handshake.  In theory a STALL indicates either that the
      downstream device sent a STALL or that no matching TT buffer could be
      found.  In either case, the transfer is completed and the TT buffer
      does not remain busy, so it doesn't need to be cleared.
      
      Also, the patch fixes a minor flaw in the code that actually sends the
      Clear-TT-Buffer requests.  Although the pipe direction isn't really
      used for control transfers, it should be a Send rather than a Receive.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NJavier Kohen <jkohen@users.sourceforge.net>
      CC: David Brownell <david-b@pacbell.net>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      c2f6595f
  5. 23 9月, 2009 5 次提交
    • S
      USB: Add hub descriptor update hook for xHCI · b356b7c7
      Sarah Sharp 提交于
      Add a hook for updating xHCI internal structures after khubd fetches the
      hub descriptor and sets up the hub's TT information.  The xHCI driver must
      update the internal structures before devices under the hub can be
      enumerated.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b356b7c7
    • A
      USB: don't lose mode switch events on suspended devices · 527101ce
      Alan Stern 提交于
      This patch (as1268) changes the way usbcore handles child devices that
      undergo a disconnection and reconnection while the parent hub is
      suspended.  Currently, if the child isn't enabled for remote wakeup we
      leave it alone, figuring that it will go through a reset-resume when
      somebody tries to use it.
      
      However this isn't a good approach if the reason for the disconnection
      is that the child decided to switch modes or in some other way alter
      its descriptors.  In that case we want to re-enumerate it as soon as
      possible, not wait until somebody forces a reset-resume.
      
      To resolve the issue, this patch treats reconnected suspended child
      devices as though they had requested a remote wakeup, even if they
      weren't enabled for it.  The mode switch or descriptor change will be
      detected during the reset part of the reset-resume, and the device
      will be re-enumerated immediately.
      
      The disadvantage of this change is that it will cause autosuspended
      devices to be resumed when the computer wakes up from a system sleep
      during which the root hub was reset or lost power.  This shouldn't
      matter much; some people would even argue that autosuspended devices
      should _always_ be resumed when the system wakes up!
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Tested-by: N"Yang Fei-AFY095" <fei.yang@motorola.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      527101ce
    • A
      USB: check for hub driver not bound to root hub device · 25118084
      Alan Stern 提交于
      This patch (as1267) changes usb_kick_khubd() and hdev_to_hub() to make
      them more resilient against situations where a hub device isn't bound
      to the hub driver.  The code assumes that if a root hub was
      successfully registered then it must be bound to the hub driver.
      
      But this assumption can fail if the user manually unbinds the hub
      driver, or more importantly, if the host controller dies causing
      usb_set_configuration to fail.
      
      To protect against these possibilities, make hdev_to_hub() check that
      the hub device is configured before dereferencing the active
      configuration, and make usb_kick_khubd() check that the pointer to the
      hub's private data structure isn't NULL.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      25118084
    • 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
  6. 13 7月, 2009 1 次提交
    • A
      USB: fix the clear_tt_buffer interface · cb88a1b8
      Alan Stern 提交于
      This patch (as1255) updates the interface for calling
      usb_hub_clear_tt_buffer().  Even the name of the function is changed!
      
      When an async URB (i.e., Control or Bulk) going through a high-speed
      hub to a non-high-speed device is cancelled or fails, the hub's
      Transaction Translator buffer may be left busy still trying to
      complete the transaction.  The buffer has to be cleared; that's what
      usb_hub_clear_tt_buffer() does.
      
      It isn't safe to send any more URBs to the same endpoint until the TT
      buffer is fully clear.  Therefore the HCD needs to be told when the
      Clear-TT-Buffer request has finished.  This patch adds a callback
      method to struct hc_driver for that purpose, and makes the hub driver
      invoke the callback at the proper time.
      
      The patch also changes a couple of names; "hub_tt_kevent" and
      "tt.kevent" now look rather antiquated.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      cb88a1b8
  7. 16 6月, 2009 5 次提交
    • S
      USB: Support for addressing a USB device under xHCI · c6515272
      Sarah Sharp 提交于
      Add host controller driver API and a slot_id variable to struct
      usb_device.  This allows the xHCI host controller driver to ask the
      hardware to allocate a slot for the device when a struct usb_device is
      allocated.  The slot needs to be allocated at that point because the
      hardware can run out of internal resources, and we want to know that very
      early in the device connection process.  Don't call this new API for root
      hubs, since they aren't real devices.
      
      Add HCD API to let the host controller choose the device address.  This is
      especially important for xHCI hardware running in a virtualized
      environment.  The guests running under the VM don't need to know which
      addresses on the bus are taken, because the hardware picks the address for
      them.  Announce SuperSpeed USB devices after the address has been assigned
      by the hardware.
      
      Don't use the new get descriptor/set address scheme with xHCI.  Unless
      special handling is done in the host controller driver, the xHC can't
      issue control transfers before you set the device address.  Support for
      the older addressing scheme will be added when the xHCI driver supports
      the Block Set Address Request (BSR) flag in the Address Device command.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      c6515272
    • S
      USB: Don't reset USB 3.0 devices on port change detection. · e7b77172
      Sarah Sharp 提交于
      The USB 3.0 bus specification defines a new connection sequence for USB 3.0
      hubs and roothubs.  USB 3.0 devices are reset and link trained by the hub
      before the port status change notification is sent to the host OS.  This means
      that an entire tree of devices can be trained in parallel on power up, and the
      OS no longer needs to reset USB 3.0 devices.  Change the USB core's hub port
      init sequence so that it does not reset USB 3.0 devices.
      
      The port status change from the roothub and from the USB 3.0 hub will report
      the SuperSpeed connect correctly.  This patch currently only handles the
      roothub case.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e7b77172
    • S
      USB: Add USB 3.0 roothub support to USB core. · d2e9b4d6
      Sarah Sharp 提交于
      Add USB 3.0 root hub descriptors.  This is a kludge because I reused the old
      USB 2.0 descriptors, instead of using the new USB 3.0 hub descriptors with
      endpoint companion descriptors and other descriptors.  I did this because I
      wasn't ready to add USB 3.0 hub changes to khubd.  For now, a USB 3.0 roothub
      looks like a USB 2.0 roothub, with a higher speed.
      
      USB 3.0 hubs have no transaction translator (TT).
      
      Make USB core debugging handle super speed ports.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d2e9b4d6
    • S
      USB: Add SuperSpeed to the list of USB device speeds. · 6b403b02
      Sarah Sharp 提交于
      Modify the USB core to handle the new USB 3.0 speed, "SuperSpeed".  This
      is 5.0 Gbps (wire speed).  There are probably more places that check for
      speed that I've missed.
      
      SuperSpeed devices have a 512 byte endpoint 0 max packet size.  This shows
      up as a bMaxPacketSize0 set to 0x09 (see table 9-8 of the USB 3.0 bus
      spec).
      
      xHCI spec says that the xHC can handle intervals up to 2^15 microframes.  That
      might change when real silicon becomes available.
      
      Add FIXME note for SuperSpeed isochronous endpoints.  They can transmit up
      to 16 packets in one "burst" before they wait for an acknowledgment of the
      packets.  They can do up to 3 bursts per microframe (determined by the
      mult value in the endpoint companion descriptor).  The xHCI driver doesn't
      have support for isoc yet, so fix this later.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6b403b02
    • H
      USB: hub.c: fix sparse warnings · d0f830d3
      H Hartley Sweeten 提交于
      Fix sparse warning in drivers/usb/core/hub.c.
      
      The following sparse warning is seen when building on ARM due
      do the macro raw_local_irq_save():
      
      	warning: symbol 'temp' shadows an earlier one
      Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d0f830d3
  8. 25 3月, 2009 4 次提交
    • R
      USB: more u32 conversion after transfer_buffer_length and actual_length · 71d2718f
      Roel Kluin 提交于
      transfer_buffer_length and actual_length have become unsigned, therefore some
      additional conversion of local variables, function arguments and print
      specifications is desired.
      
      A test for a negative urb->transfer_buffer_length became obsolete; instead
      we ensure that it does not exceed INT_MAX. Also, urb->actual_length is always
      less than urb->transfer_buffer_length.
      
      rh_string() does no longer return -EPIPE in the case of an unsupported ID.
      Instead its only caller, rh_call_control() does the check.
      Signed-off-by: NRoel Kluin <roel.kluin@gmail.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      71d2718f
    • A
      USB: don't send Set-Interface after reset · 4fe0387a
      Alan Stern 提交于
      This patch (as1221) changes the way usbcore reinitializes a device
      following a reset or a reset-resume.  Currently we call
      usb_set_interface() for every interface in the active configuration;
      this is to put the interface into the same altsetting as before the
      reset and to make sure that the host's endpoint state matches the
      device's endpoint state.
      
      However, sending a Set-Interface request is a waste of time if an
      interface was already in altsetting 0 before the reset, since it is
      certainly in altsetting 0 afterward.  In addition, many devices can't
      handle Set-Interface requests -- they crash when they receive them.
      
      So instead, the patch adds code to check each interface.  If the
      interface wasn't in altsetting 0 before the reset, we go head with the
      Set-Interface request as before.  But if it was then we skip sending
      the Set-Interface request, and we clear out the host-side endpoint
      state by calling usb_disable_interface() followed by
      usb_enable_interface().
      
      The patch also adds a couple of new comments to explain what's going
      on.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4fe0387a
    • D
      USB: allow libusb to talk to unauthenticated WUSB devices · 6da9c990
      David Vrabel 提交于
      To permit a userspace application to associate with WUSB devices
      using numeric association, control transfers to unauthenticated WUSB
      devices must be allowed.
      
      This requires that wusbcore correctly sets the device state to
      UNAUTHENTICATED, DEFAULT and ADDRESS and that control transfers can be
      performed to UNAUTHENTICATED devices.
      Signed-off-by: NDavid Vrabel <david.vrabel@csr.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6da9c990
    • H
      USB: replace uses of __constant_{endian} · 551509d2
      Harvey Harrison 提交于
      The base versions handle constant folding now.
      Signed-off-by: NHarvey Harrison <harvey.harrison@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      551509d2
  9. 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
  10. 16 1月, 2009 1 次提交
  11. 08 1月, 2009 7 次提交
    • 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
    • W
      USB: make printk messages more searchable · b9cef6c3
      Wu Fengguang 提交于
      USB: make printk messages more searchable
      
      Make USB printk messages long and straightforward.  One of these
      decorated USB error messages cost me non-trivial efforts to locate.
      Signed-off-by: NWu Fengguang <fengguang.wu@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b9cef6c3
    • 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: announce new devices earlier · 6cd13201
      Alan Stern 提交于
      This patch (as1166) changes usb_new_device().  Now new devices will be
      announced in the log _prior_ to being registered; this way the "new
      device" lines will appear before all the output from driver probing,
      which seems much more logical.
      
      Also, the patch adds a call to usb_stop_pm() to the failure pathway,
      so that the parent's count of unsuspended children will remain correct
      if registration fails.  In order for this to work properly, the code
      to increment that count has to be moved forward, before the first
      point where a failure can occur.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6cd13201
    • 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
  12. 30 10月, 2008 2 次提交
    • A
      USB: prevent autosuspend during hub initialization · 61fbeba1
      Alan Stern 提交于
      This patch (as1153) fixes a potential problem in hub initialization.
      Starting in 2.6.28, initialization was split into several tasks to
      help speed up booting.  This opens the possibility that the hub may be
      autosuspended before all the initialization tasks can complete.
      
      Normally that wouldn't matter, but with incomplete initialization
      there is a risk that the hub would never autoresume -- especially if
      devices were plugged into the hub beforehand.  The solution is a
      simple one-line change to suppress autosuspend until the
      initialization is finished.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      61fbeba1
    • A
      USB: fix crash when URBs are unlinked after the device is gone · cde217a5
      Alan Stern 提交于
      This patch (as1151) protects usbcore against drivers that try to
      unlink an URB after the URB's device or bus have been removed.  The
      core does not currently check for this, and certain drivers can cause
      a crash if they are running while an HCD is unloaded.
      
      Certainly it would be best to fix the guilty drivers.  But a little
      defensive programming doesn't hurt, especially since it appears that
      quite a few drivers need to be fixed.
      
      The patch prevents the problem by grabbing a reference to the device
      while an unlink is in progress and using a new spinlock to synchronize
      unlinks with device removal.  (There's no need to acquire a reference
      to the bus as well, since the device structure itself keeps a
      reference to the bus.)  In addition, the kerneldoc is updated to
      indicate that URBs should not be unlinked after the disconnect method
      returns.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      cde217a5
  13. 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
  14. 18 10月, 2008 2 次提交