1. 12 12月, 2009 3 次提交
    • 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: fix a bug in the scatter-gather library · ed1db3ad
      Alan Stern 提交于
      This patch (as1298) fixes a bug in the new scatter-gather URB
      facility.  If an URB uses a scatterlist then it should not have the
      URB_NO_INTERRUPT flag set; otherwise the system won't be notified when
      the transfer completes.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NDavid Vrabel <david.vrabel@csr.com>
      CC: Sarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      ed1db3ad
    • D
      USB: make urb scatter-gather support more generic · 4c1bd3d7
      David Vrabel 提交于
      The WHCI HCD will also support urbs with scatter-gather lists.  Add a
      usb_bus field to indicated how many sg list elements are supported by
      the HCD.  Use this to decide whether to pass the scatter-list to the HCD
      or not.
      
      Make the usb-storage driver use this new field.
      Signed-off-by: NDavid Vrabel <david.vrabel@csr.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4c1bd3d7
  2. 04 12月, 2009 1 次提交
  3. 23 9月, 2009 1 次提交
  4. 13 7月, 2009 1 次提交
    • D
      USB: fix LANGID=0 regression · 0cce2eda
      Daniel Mack 提交于
      commit b7af0bb2 ("USB: allow malformed LANGID descriptors") broke support
      for devices without string descriptor support.
      
      Reporting string descriptors is optional to USB devices, and a device
      lets us know it can't deal with strings by responding to the LANGID
      request with a STALL token.
      
      The kernel handled that correctly before b7af0bb2 came in, but failed
      hard if the LANGID was reported but broken. More than that, if a device
      was not able to provide string descriptors, the LANGID was retrieved
      over and over again at each string read request.
      
      This patch changes the behaviour so that
      
       a) the LANGID is only queried once
       b) devices which can't handle string requests are not asked again
       c) devices with malformed LANGID values have a sane fallback to 0x0409
      Signed-off-by: NDaniel Mack <daniel@caiaq.de>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0cce2eda
  5. 16 6月, 2009 4 次提交
    • S
      USB: Push scatter gather lists down to host controller drivers. · e04748e3
      Sarah Sharp 提交于
      This is the original patch I created before David Vrabel posted a better
      patch (http://marc.info/?l=linux-usb&m=123377477209109&w=2) that does
      basically the same thing.  This patch will get replaced with his
      (modified) patch later.
      
      Allow USB device drivers that use usb_sg_init() and usb_sg_wait() to push
      bulk endpoint scatter gather lists down to the host controller drivers.
      This allows host controller drivers to more efficiently enqueue these
      transfers, and allows the xHCI host controller to better take advantage of
      USB 3.0 "bursts" for bulk endpoints.
      
      This patch currently only enables scatter gather lists for bulk endpoints.
      Other endpoint types that use the usb_sg_* functions will not have their
      scatter gather lists pushed down to the host controller.  For periodic
      endpoints, we want each scatterlist entry to be a separate transfer.
      Eventually, HCDs could parse these scatter-gather lists for periodic
      endpoints also.  For now, we use the old code and call usb_submit_urb()
      for each scatterlist entry.
      
      The caller of usb_sg_init() can request that all bytes in the scatter
      gather list be transferred by passing in a length of zero.  Handle that
      request for a bulk endpoint under xHCI by walking the scatter gather list
      and calculating the length.  We could let the HCD handle a zero length in
      this case, but I'm not sure if the core layers in between will get
      confused by this.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e04748e3
    • S
      USB: Support for bandwidth allocation. · 79abb1ab
      Sarah Sharp 提交于
      Originally, the USB core had no support for allocating bandwidth when a
      particular configuration or alternate setting for an interface was
      selected.  Instead, the device driver's URB submission would fail if
      there was not enough bandwidth for a periodic endpoint.  Drivers could
      work around this, by using the scatter-gather list API to guarantee
      bandwidth.
      
      This patch adds host controller API to allow the USB core to allocate or
      deallocate bandwidth for an endpoint.  Endpoints are added to or dropped
      from a copy of the current schedule by calling add_endpoint() or
      drop_endpoint(), and then the schedule is atomically evaluated with a
      call to check_bandwidth().  This allows all the endpoints for a new
      configuration or alternate setting to be added at the same time that the
      endpoints from the old configuration or alt setting are dropped.
      
      Endpoints must be added to the schedule before any URBs are submitted to
      them.  The HCD must be allowed to reject a new configuration or alt
      setting before the control transfer is sent to the device requesting the
      change.  It may reject the change because there is not enough bandwidth,
      not enough internal resources (such as memory on an embedded host
      controller), or perhaps even for security reasons in a virtualized
      environment.
      
      If the call to check_bandwidth() fails, the USB core must call
      reset_bandwidth().  This causes the schedule to be reverted back to the
      state it was in just after the last successful check_bandwidth() call.
      
      If the call succeeds, the host controller driver (and hardware) will have
      changed its internal state to match the new configuration or alternate
      setting.  The USB core can then issue a control transfer to the device to
      change the configuration or alt setting.  This allows the core to test new
      configurations or alternate settings before unbinding drivers bound to
      interfaces in the old configuration.
      
      WIP:
      
      The USB core must add endpoints from all interfaces in a configuration
      to the schedule, because a driver may claim that interface at any time.
      A slight optimization might be to add the endpoints to the schedule once
      a driver claims that interface.  FIXME
      
      This patch does not cover changing alternate settings, but it does
      handle a configuration change or de-configuration.  FIXME
      
      The code for managing the schedule is currently HCD specific.  A generic
      scheduling algorithm could be added for host controllers without
      built-in scheduling support.  For now, if a host controller does not
      define the check_bandwidth() function, the call to
      usb_hcd_check_bandwidth() will always succeed.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      79abb1ab
    • A
      NLS: update handling of Unicode · 74675a58
      Alan Stern 提交于
      This patch (as1239) updates the kernel's treatment of Unicode.  The
      character-set conversion routines are well behind the current state of
      the Unicode specification: They don't recognize the existence of code
      points beyond plane 0 or of surrogate pairs in the UTF-16 encoding.
      
      The old wchar_t 16-bit type is retained because it's still used in
      lots of places.  This shouldn't cause any new problems; if a
      conversion now results in an invalid 16-bit code then before it must
      have yielded an undefined code.
      
      Difficult-to-read names like "utf_mbstowcs" are replaced with more
      transparent names like "utf8s_to_utf16s" and the ordering of the
      parameters is rationalized (buffer lengths come immediate after the
      pointers they refer to, and the inputs precede the outputs).
      Fortunately the low-level conversion routines are used in only a few
      places; the interfaces to the higher-level uni2char and char2uni
      methods have been left unchanged.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NClemens Ladisch <clemens@ladisch.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      74675a58
    • C
      usb: return device strings in UTF-8 · a853a3d4
      Clemens Ladisch 提交于
      Change the encoding of strings returned by usb_string() from ISO 8859-1
      to UTF-8.
      Signed-off-by: NClemens Ladisch <clemens@ladisch.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      a853a3d4
  6. 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
  7. 25 3月, 2009 3 次提交
  8. 28 2月, 2009 1 次提交
    • A
      USB: usb_get_string should check the descriptor type · 67f5a4ba
      Alan Stern 提交于
      This patch (as1218) fixes a problem with a radio-control joystick used
      in the "walkera 4#3" helicopter.  This device responds to the initial
      Get-String-Descriptor request for string 0 (which is really the list
      of supported languages) by sending its config descriptor!  The
      usb_get_string() routine needs to check whether it got the right
      type of descriptor.
      
      Oddly enough, this sort of check is already present in
      usb_get_descriptor().  The patch changes the error code from -EPROTO
      to -ENODATA, because -EPROTO shows up in so many other contexts to
      indicate a hardware failure rather than a firmware error.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Tested-by: NGuillermo Jarabo <williamjap@gmail.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      ===================================================================
      67f5a4ba
  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. 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: cancel pending Set-Config requests if userspace gets there first · df718962
      Alan Stern 提交于
      This patch (as1195) eliminates a potential problem identified by
      Oliver Neukum.  When a driver queues an asynchronous Set-Config
      request using usb_driver_set_configuration(), the request should be
      cancelled if userspace changes the configuration first.  The patch
      introduces a linked list of pending async Set-Config requests, and
      uses it to invalidate the requests for a particular device whenever
      that device's configuration is set.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: Oliver Neukum <oliver@neukum.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      df718962
    • 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
    • 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
    • H
      USB: avoid needless address-taking of function parameters · da2bbdcc
      Harvey Harrison 提交于
      There's no need to take the address of the function params or local variables
      when the direct value byteswapping routines are available.
      Signed-off-by: NHarvey Harrison <harvey.harrison@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      da2bbdcc
  11. 14 11月, 2008 1 次提交
    • A
      USB: don't register endpoints for interfaces that are going away · 352d0263
      Alan Stern 提交于
      This patch (as1155) fixes a bug in usbcore.  When interfaces are
      deleted, either because the device was disconnected or because of a
      configuration change, the extra attribute files and child endpoint
      devices may get left behind.  This is because the core removes them
      before calling device_del().  But during device_del(), after the
      driver is unbound the core will reinstall altsetting 0 and recreate
      those extra attributes and children.
      
      The patch prevents this by adding a flag to record when the interface
      is in the midst of being unregistered.  When the flag is set, the
      attribute files and child devices will not be created.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org> [2.6.27, 2.6.26, 2.6.25]
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      352d0263
  12. 18 10月, 2008 1 次提交
  13. 14 8月, 2008 1 次提交
  14. 06 8月, 2008 1 次提交
    • A
      Fix USB storage hang on command abort · 580da348
      Alan Stern 提交于
      Okay, I found the cause of the hang.  It is a simple bug in the USB
      scatter-gather library, caused by changes added in response to the S-G
      chaining modification.
      
      This patch (as1125) fixes a bug in the USB scatter-gather library.
      Early exit from the S-G initialization loop does not reset the count of
      outstanding URBs.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Cc: David Brownell <david-b@pacbell.net>
      Cc: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      580da348
  15. 22 7月, 2008 4 次提交
  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. 03 5月, 2008 1 次提交
    • Y
      USB: fix cannot work usb storage when using ohci-sm501 · e2722528
      Yoshihiro Shimoda 提交于
      When I used ohci-sm501, hcd_alloc_coherent() in map_urb_for_dma() is not
      called, because usb_sg_init() always sets URB_NO_TRANSFER_DMA_MAP.
      
      dmesg (CONFIG_USB_STORAGE_DEBUG enabled):
      
      usb-storage: Bulk Command S 0x43425355 T 0x1 L 36 F 128 Trg 0 LUN 0 CL 6
      usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes
      usb-storage: Status code 0; transferred 31/31
      usb-storage: -- transfer complete
      usb-storage: Bulk command transfer result=0
      usb-storage: usb_stor_bulk_transfer_sglist: xfer 36 bytes, 1 entries
      usb-storage: Status code -75; transferred 0/36
      usb-storage: -- babble
      usb-storage: Bulk data transfer result 0x3
      usb-storage: Attempting to get CSW...
      usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes
      usb-storage: Status code 0; transferred 13/13
      usb-storage: -- transfer complete
      usb-storage: Bulk status result = 0
      usb-storage: Bulk Status S 0x53425355 T 0x1 R 0 Stat 0x0
      usb-storage: scsi cmd done, result=0x2
      Signed-off-by: NYoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e2722528
  18. 25 4月, 2008 3 次提交
  19. 25 3月, 2008 1 次提交
  20. 02 2月, 2008 2 次提交
  21. 29 11月, 2007 2 次提交
    • 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
    • A
      USB: keep track of whether interface sysfs files exist · 7e61559f
      Alan Stern 提交于
      This patch (as1009) solves the problem of multiple registrations for
      USB sysfs files in a more satisfying way than the existing code.  It
      simply adds a flag to keep track of whether or not the files have been
      created; that way the files can be created or removed as needed.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      7e61559f
  22. 30 10月, 2007 1 次提交