1. 27 7月, 2010 1 次提交
    • S
      USB: xhci: Set EP0 dequeue ptr after reset of configured device. · 2d1ee590
      Sarah Sharp 提交于
      When a configured device is reset, the control endpoint's ring is reused.
      If control transfers to the device were issued before the device is reset,
      the dequeue pointer will be somewhere in the middle of the ring.  If the
      device is then issued an address with the set address command, the xHCI
      driver must provide a valid input context for control endpoint zero.
      
      The original code would give the hardware the original input context,
      which had a dequeue pointer set to the top of the ring.  This would cause
      the host to re-execute any control transfers until it reached the ring's
      enqueue pointer.  When issuing a set address command for a device that has
      just been configured and then reset, use the control endpoint's enqueue
      pointer as the hardware's dequeue pointer.
      
      Assumption:  All control transfers will be completed or cancelled before
      the set address command is issued to the device.  If there are any
      outstanding control transfers, this code will not work.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2d1ee590
  2. 21 5月, 2010 4 次提交
    • A
      USB: remove the usb_host_ss_ep_comp structure · 842f1690
      Alan Stern 提交于
      This patch (as1375) eliminates the usb_host_ss_ep_comp structure used
      for storing a dynamically-allocated copy of the SuperSpeed endpoint
      companion descriptor.  The SuperSpeed descriptor is placed directly in
      the usb_host_endpoint structure, alongside the standard endpoint
      descriptor.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      842f1690
    • R
      USB: clean up some host controller sparse warnings · 326b4810
      Randy Dunlap 提交于
      Fix usb sparse warnings:
      
      drivers/usb/host/isp1362-hcd.c:2220:50: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-mem.c:43:24: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-mem.c:49:24: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-mem.c:161:24: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-mem.c:198:16: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-mem.c:319:31: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-mem.c:1231:33: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-pci.c:177:23: warning: non-ANSI function declaration of function 'xhci_register_pci'
      drivers/usb/host/xhci-pci.c:182:26: warning: non-ANSI function declaration of function 'xhci_unregister_pci'
      drivers/usb/host/xhci-ring.c:342:32: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-ring.c:525:34: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-ring.c:1009:32: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-ring.c:1031:32: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-ring.c:1041:16: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-ring.c:1096:30: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-ring.c:1100:27: warning: Using plain integer as NULL pointer
      drivers/usb/host/xhci-mem.c:224:27: warning: symbol 'xhci_alloc_container_ctx' was not declared. Should it be static?
      drivers/usb/host/xhci-mem.c:242:6: warning: symbol 'xhci_free_container_ctx' was not declared. Should it be static?
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Cc: Lothar Wassmann <LW@KARO-electronics.de>
      Signed-off By: Sarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      326b4810
    • S
      USB: xhci: Correct assumptions about number of rings per endpoint. · e9df17eb
      Sarah Sharp 提交于
      Much of the xHCI driver code assumes that endpoints only have one ring.
      Now an endpoint can have one ring per enabled stream ID, so correct that
      assumption.  Use functions that translate the stream_id field in the URB
      or the DMA address of a TRB into the correct stream ring.
      
      Correct the polling loop to print out all enabled stream rings.  Make the
      URB cancellation routine find the correct stream ring if the URB has
      stream_id set.  Make sure the URB enqueueing routine does the same.  Also
      correct the code that handles stalled/halted endpoints.
      
      Check that commands and registers that can take stream IDs handle them
      properly.  That includes ringing an endpoint doorbell, resetting a
      stalled/halted endpoint, and setting a transfer ring dequeue pointer
      (since that command can set the dequeue pointer in a stream context or an
      endpoint context).
      
      Correct the transfer event handler to translate a TRB DMA address into the
      stream ring it was enqueued to.  Make the code to allocate and prepare TD
      structures adds the TD to the right td_list for the stream ring.  Make
      sure the code to give the first TRB in a TD to the hardware manipulates
      the correct stream ring.
      
      When an endpoint stalls, store the stream ID of the stream ring that
      stalled in the xhci_virt_ep structure.  Use that instead of the stream ID
      in the URB, since an URB may be re-used after it is given back after a
      non-control endpoint stall.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e9df17eb
    • S
      USB: xhci: Add memory allocation for USB3 bulk streams. · 8df75f42
      Sarah Sharp 提交于
      Add support for allocating streams for USB 3.0 bulk endpoints.  See
      Documentation/usb/bulk-streams.txt for more information about how and why
      you would use streams.
      
      When an endpoint has streams enabled, instead of having one ring where all
      transfers are enqueued to the hardware, it has several rings.  The ring
      dequeue pointer in the endpoint context is changed to point to a "Stream
      Context Array".  This is basically an array of pointers to transfer rings,
      one for each stream ID that the driver wants to use.
      
      The Stream Context Array size must be a power of two, and host controllers
      can place a limit on the size of the array (4 to 2^16 entries).  These
      two facts make calculating the size of the Stream Context Array and the
      number of entries actually used by the driver a bit tricky.
      
      Besides the Stream Context Array and rings for all the stream IDs, we need
      one more data structure.  The xHCI hardware will not tell us which stream
      ID a transfer event was for, but it will give us the slot ID, endpoint
      index, and physical address for the TRB that caused the event.  For every
      endpoint on a device, add a radix tree to map physical TRB addresses to
      virtual segments within a stream ring.
      
      Keep track of whether an endpoint is transitioning to using streams, and
      don't enqueue any URBs while that's taking place.  Refuse to transition an
      endpoint to streams if there are already URBs enqueued for that endpoint.
      
      We need to make sure that freeing streams does not fail, since a driver's
      disconnect() function may attempt to do this, and it cannot fail.
      Pre-allocate the command structure used to issue the Configure Endpoint
      command, and reserve space on the command ring for each stream endpoint.
      This may be a bit overkill, but it is permissible for the driver to
      allocate all streams in one call and free them in multiple calls.  (It is
      not advised, however, since it is a waste of resources and time.)
      
      Even with the memory and ring room pre-allocated, freeing streams can
      still fail because the xHC rejects the configure endpoint command.  It is
      valid (by the xHCI 0.96 spec) to return a "Bandwidth Error" or a "Resource
      Error" for a configure endpoint command.  We should never see a Bandwidth
      Error, since bulk endpoints do not effect the reserved bandwidth.  The
      host controller can still return a Resource Error, but it's improbable
      since the xHC would be going from a more resource-intensive configuration
      (streams) to a less resource-intensive configuration (no streams).
      
      If the xHC returns a Resource Error, the endpoint will be stuck with
      streams and will be unusable for drivers.  It's an unavoidable consequence
      of broken host controller hardware.
      
      Includes bug fixes from the original patch, contributed by
      John Youn <John.Youn@synopsys.com> and Andy Green <AGreen@PLXTech.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8df75f42
  3. 01 5月, 2010 2 次提交
    • S
      USB: xhci: properly set endpoint context fields for periodic eps. · 9238f25d
      Sarah Sharp 提交于
      For periodic endpoints, we must let the xHCI hardware know the maximum
      payload an endpoint can transfer in one service interval.  The xHCI
      specification refers to this as the Maximum Endpoint Service Interval Time
      Payload (Max ESIT Payload).  This is used by the hardware for bandwidth
      management and scheduling of packets.
      
      For SuperSpeed endpoints, the maximum is calculated by multiplying the max
      packet size by the number of bursts and the number of opportunities to
      transfer within a service interval (the Mult field of the SuperSpeed
      Endpoint companion descriptor).  Devices advertise this in the
      wBytesPerInterval field of their SuperSpeed Endpoint Companion Descriptor.
      
      For high speed devices, this is taken by multiplying the max packet size by the
      "number of additional transaction opportunities per microframe" (the high
      bits of the wMaxPacketSize field in the endpoint descriptor).
      
      For FS/LS devices, this is just the max packet size.
      
      The other thing we must set in the endpoint context is the Average TRB
      Length.  This is supposed to be the average of the total bytes in the
      transfer descriptor (TD), divided by the number of transfer request blocks
      (TRBs) it takes to describe the TD.  This gives the host controller an
      indication of whether the driver will be enqueuing a scatter gather list
      with many entries comprised of small buffers, or one contiguous buffer.
      
      It also takes into account the number of extra TRBs you need for every TD.
      This includes No-op TRBs and Link TRBs used to link ring segments
      together.  Some drivers may choose to chain an Event Data TRB on the end
      of every TD, thus increasing the average number of TRBs per TD.  The Linux
      xHCI driver does not use Event Data TRBs.
      
      In theory, if there was an API to allow drivers to state what their
      bandwidth requirements are, we could set this field accurately.  For now,
      we set it to the same number as the Max ESIT payload.
      
      The Average TRB Length should also be set for bulk and control endpoints,
      but I have no idea how to guess what it should be.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      9238f25d
    • S
      USB: xhci: properly set the "Mult" field of the endpoint context. · 1cf62246
      Sarah Sharp 提交于
      A SuperSpeed interrupt or isochronous endpoint can define the number of
      "burst transactions" it can handle in a service interval.  This is
      indicated by the "Mult" bits in the bmAttributes of the SuperSpeed
      Endpoint Companion Descriptor.  For example, if it has a max packet size
      of 1024, a max burst of 11, and a mult of 3, the host may send 33
      1024-byte packets in one service interval.
      
      We must tell the xHCI host controller the number of multiple service
      opportunities (mults) the device can handle when the endpoint is
      installed.  We do that by setting the Mult field of the Endpoint Context
      before a configure endpoint command is sent down.  The Mult field is
      invalid for control or bulk SuperSpeed endpoints.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      1cf62246
  4. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  5. 19 3月, 2010 1 次提交
  6. 03 3月, 2010 3 次提交
  7. 12 12月, 2009 4 次提交
    • S
      USB: xhci: Make reverting an alt setting "unfailable". · 74f9fe21
      Sarah Sharp 提交于
      When a driver wants to switch to a different alternate setting for an
      interface, the USB core will (soon) check whether there is enough
      bandwidth.  Once the new alternate setting is installed in the xHCI
      hardware, the USB core will send a USB_REQ_SET_INTERFACE control
      message.  That can fail in various ways, and the USB core needs to be
      able to reinstate the old alternate setting.
      
      With the old code, reinstating the old alt setting could fail if the
      there's not enough memory to allocate new endpoint rings.  Keep
      around a cache of (at most 31) endpoint rings for this case.  When we
      successfully switch the xHCI hardware to the new alt setting, the old
      alt setting's rings will be stored in the cache.  Therefore we'll
      always have enough rings to satisfy a conversion back to a previous
      device setting.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      74f9fe21
    • J
      USB: xhci-mem.c: introduce missing kfree · 06e18291
      Julia Lawall 提交于
      Error handling code following a kzalloc should free the allocated data.
      
      The semantic match that finds this problem is as follows:
      (http://www.emn.fr/x-info/coccinelle/)
      
      // <smpl>
      @r exists@
      local idexpression x;
      statement S;
      expression E;
      identifier f,f1,l;
      position p1,p2;
      expression *ptr != NULL;
      @@
      
      x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
      ...
      if (x == NULL) S
      <... when != x
           when != if (...) { <+...x...+> }
      (
      x->f1 = E
      |
       (x->f1 == NULL || ...)
      |
       f(...,x->f1,...)
      )
      ...>
      (
       return \(0\|<+...x...+>\|ptr\);
      |
       return@p2 ...;
      )
      
      @script:python@
      p1 << r.p1;
      p2 << r.p2;
      @@
      
      print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
      // </smpl>
      Signed-off-by: NJulia Lawall <julia@diku.dk>
      Acked-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      06e18291
    • S
      USB: xhci: Add tests for TRB address translation. · 6648f29d
      Sarah Sharp 提交于
      It's not surprising that the transfer request buffer (TRB) physical to
      virtual address translation function has bugs in it, since I wrote most of
      it at 4am last October.  Add a test suite to check the TRB math.  This
      runs at memory initialization time, and causes the driver to fail to load
      if the TRB math fails.
      
      Please excuse the excessively long lines in the test vectors; they can't
      really be made shorter and still be readable.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6648f29d
    • S
      USB: xhci: Add watchdog timer for URB cancellation. · 6f5165cf
      Sarah Sharp 提交于
      In order to giveback a canceled URB, we must ensure that the xHCI
      hardware will not access the buffer in an URB.  We can't modify the
      buffer pointers on endpoint rings without issuing and waiting for a stop
      endpoint command.  Since URBs can be canceled in interrupt context, we
      can't wait on that command.  The old code trusted that the host
      controller would respond to the command, and would giveback the URBs in
      the event handler.  If the hardware never responds to the stop endpoint
      command, the URBs will never be completed, and we might hang the USB
      subsystem.
      
      Implement a watchdog timer that is spawned whenever a stop endpoint
      command is queued.  If a stop endpoint command event is found on the
      event ring during an interrupt, we need to stop the watchdog timer with
      del_timer().  Since del_timer() can fail if the timer is running and
      waiting on the xHCI lock, we need a way to signal to the timer that
      everything is fine and it should exit.  If we simply clear
      EP_HALT_PENDING, a new stop endpoint command could sneak in and set it
      before the watchdog timer can grab the lock.
      
      Instead we use a combination of the EP_HALT_PENDING flag and a counter
      for the number of pending stop endpoint commands
      (xhci_virt_ep->stop_cmds_pending).  If we need to cancel the watchdog
      timer and del_timer() succeeds, we decrement the number of pending stop
      endpoint commands.  If del_timer() fails, we leave the number of pending
      stop endpoint commands alone.  In either case, we clear the
      EP_HALT_PENDING flag.
      
      The timer will decrement the number of pending stop endpoint commands
      once it obtains the lock.  If the timer is the tail end of the last stop
      endpoint command (xhci_virt_ep->stop_cmds_pending == 0), and the
      endpoint's command is still pending (EP_HALT_PENDING is set), we assume
      the host is dying.  The watchdog timer will set XHCI_STATE_DYING, try to
      halt the xHCI host, and give back all pending URBs.
      
      Various other places in the driver need to check whether the xHCI host
      is dying.  If the interrupt handler ever notices, it should immediately
      stop processing events.  The URB enqueue function should also return
      -ESHUTDOWN.  The URB dequeue function should simply return the value
      of usb_hcd_check_unlink_urb() and the watchdog timer will take care of
      giving the URB back.  When a device is disconnected, the xHCI hardware
      structures should be freed without issuing a disable slot command (since
      the hardware probably won't respond to it anyway).  The debugging
      polling loop should stop polling if the host is dying.
      
      When a device is disconnected, any pending watchdog timers are killed
      with del_timer_sync().  It must be synchronous so that the watchdog
      timer doesn't attempt to access the freed endpoint structures.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6f5165cf
  8. 18 11月, 2009 2 次提交
  9. 23 9月, 2009 7 次提交
    • S
      USB: xhci: Set multi-TT field for LS/FS devices under hubs. · 07b6de10
      Sarah Sharp 提交于
      When setting up a slot context for an address device command, set the
      multi-TT field if this is a low or full speed device under a HS hub with
      multiple transaction translators.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      07b6de10
    • S
      USB: xhci: Set route string for all devices. · 4a0cd967
      Sarah Sharp 提交于
      The xHCI driver needs to set the route string in the slot context of all
      devices, not just SuperSpeed devices.  The route string concept was added
      in the USB 3.0 specification, section 10.1.3.2.  Each hub in the topology
      is expected to have no more than 15 ports in order for the route string of
      a device to be unique.  SuperSpeed hubs are restricted to only having 15
      ports, but FS/LS/HS hubs are not.  The xHCI specification says that if the
      port number the device is under is greater than 15, that portion of the
      route string shall be set to 15.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4a0cd967
    • S
      USB: xhci: Change how xHCI commands are handled. · 913a8a34
      Sarah Sharp 提交于
      Some commands to the xHCI hardware cannot be allowed to fail due to out of
      memory issues or the command ring being full.
      
      Add a way to reserve a TRB on the command ring, and make all command
      queueing functions indicate whether they are using a reserved TRB.
      
      Add a way to pre-allocate all the memory a command might need.  A command
      needs an input context, a variable to store the status, and (optionally) a
      completion for the caller to wait on.  Change all code that assumes the
      input device context, status, and completion for a command is stored in
      the xhci virtual USB device structure (xhci_virt_device).
      
      Store pending completions in a FIFO in xhci_virt_device.  Make the event
      handler for a configure endpoint command check to see whether a pending
      command in the list has completed.  We need to use separate input device
      contexts for some configure endpoint commands, since multiple drivers can
      submit requests at the same time that require a configure endpoint
      command.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      913a8a34
    • S
      USB: xhci: Endpoint representation refactoring. · 63a0d9ab
      Sarah Sharp 提交于
      The xhci_ring structure contained information that is really related to an
      endpoint, not a ring.  This will cause problems later when endpoint
      streams are supported and there are multiple rings per endpoint.
      
      Move the endpoint state and cancellation information into a new virtual
      endpoint structure, xhci_virt_ep.  The list of TRBs to be cancelled should
      be per endpoint, not per ring, for easy access.  There can be only one TRB
      that the endpoint stopped on after a stop endpoint command (even with
      streams enabled); move the stopped TRB information into the new virtual
      endpoint structure.  Also move the 31 endpoint rings and temporary ring
      storage from the virtual device structure (xhci_virt_device) into the
      virtual endpoint structure (xhci_virt_ep).
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      63a0d9ab
    • S
      USB: xhci: Set correct max packet size for HS/FS control endpoints. · 47aded8a
      Sarah Sharp 提交于
      Set the max packet size for the default control endpoint on high speed
      devices to be 64 bytes.  High speed devices always have a max packet size
      of 64 bytes.  There's no use setting it to eight for the initial 8 byte
      descriptor fetch and then issuing (and waiting for) an evaluate context
      command to update it to 64 bytes for the subsequent control transfers.
      
      The USB core guesses that the max packet size on a full speed control
      endpoint is 64 bytes, and then updates it after the first 8-byte
      descriptor fetch.  Change the initial setup for the xHCI internal
      representation of the full speed device to have a 64 byte max packet size.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      47aded8a
    • S
      USB: xhci: Configure endpoint code refactoring. · f2217e8e
      Sarah Sharp 提交于
      Refactor out the code issue, wait for, and parse the event completion code
      for a configure endpoint command.  Modify it to support the evaluate
      context command, which has a very similar submission process.  Add
      functions to copy parts of the output context into the input context
      (which will be used in the evaluate context command).
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f2217e8e
    • S
      USB: xhci: Work around for chain bit in link TRBs. · b0567b3f
      Sarah Sharp 提交于
      Different sections of the xHCI 0.95 specification had opposing
      requirements for the chain bit in a link transaction request buffer (TRB).
      The chain bit is used to designate that adjacent TRBs are all part of the
      same scatter gather list that should be sent to the device.  Link TRBs can
      be in the middle, or at the beginning or end of these chained TRBs.
      
      Sections 4.11.5.1 and 6.4.4.1 both stated the link TRB "shall have the
      chain bit set to 1", meaning it is always chained to the next TRB.
      However, section 4.6.9 on the stop endpoint command has specific cases for
      what the hardware must do for a link TRB with the chain bit set to 0.  The
      0.96 specification errata later cleared up this issue by fixing the
      4.11.5.1 and 6.4.4.1 sections to state that a link TRB can have the chain
      bit set to 1 or 0.
      
      The problem is that the xHCI cancellation code depends on the chain bit of
      the link TRB being cleared when it's at the end of a TD, and some 0.95
      xHCI hardware simply stops processing the ring when it encounters a link
      TRB with the chain bit cleared.
      
      Allow users who are testing 0.95 xHCI prototypes to set a module parameter
      (link_quirk) to turn on this link TRB work around.  Cancellation may not
      work if the ring is stopped exactly on a link TRB with chain bit set, but
      cancellation should be a relatively uncommon case.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b0567b3f
  10. 29 7月, 2009 6 次提交
  11. 16 6月, 2009 9 次提交
    • S
      USB: xhci: Respect critical sections. · f88ba78d
      Sarah Sharp 提交于
      Narrow down time spent holding the xHCI spinlock so that it's only used to
      protect the xHCI rings, not as mutual exclusion.  Stop allocating memory
      while holding the spinlock and calling xhci_alloc_virt_device() and
      xhci_endpoint_init().
      
      The USB core should have locking in it to prevent device state to be
      manipulated by more than one kernel thread.  E.g. you can't free a device
      while you're in the middle of setting a new configuration.  So removing
      the locks from the sections where xhci_alloc_dev() and
      xhci_reset_bandwidth() touch xHCI's representation of the device should be
      OK.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f88ba78d
    • S
      USB: xhci: Make xhci-mem.c include linux/dmapool.h · 527c6d7f
      Sarah Sharp 提交于
      xhci-mem.c includes calls to dma_pool_alloc() and other functions defined
      in linux/dmapool.h.  Make sure to include that header file.
      Reported-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      527c6d7f
    • S
      USB: Change names of SuperSpeed ep companion descriptor structs. · f0058c62
      Sarah Sharp 提交于
      Differentiate between SuperSpeed endpoint companion descriptor and the
      wireless USB endpoint companion descriptor.  Make all structure names for
      this descriptor have "ss" (SuperSpeed) in them.  David Vrabel asked for
      this change in http://marc.info/?l=linux-usb&m=124091465109367&w=2Reported-by: NDavid Vrabel <david.vrabel@csr.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f0058c62
    • S
      USB: xhci: Avoid global namespace pollution. · 23e3be11
      Sarah Sharp 提交于
      Make all globally visible functions start with xhci_ and mark functions as
      static if they're only called within the same C file.  Fix some long lines
      while we're at it.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      23e3be11
    • S
      USB: xhci: Fix register write order. · 3841d56e
      Sarah Sharp 提交于
      The 0.95 xHCI spec says that if the xHCI HW support 64-bit addressing, you
      must write the whole 64-bit address as one atomic operation, or write the
      low 32 bits, and then the high 32 bits.  I had the register writes
      swapped in some places.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3841d56e
    • G
      USB: xhci: fix lots of compiler warnings. · 700e2052
      Greg Kroah-Hartman 提交于
      Turns out someone never built this code on a 64bit platform.
      
      Someone owes me a beer...
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      700e2052
    • S
      USB: xhci: URB cancellation support. · ae636747
      Sarah Sharp 提交于
      Add URB cancellation support to the xHCI host controller driver.  This
      currently supports cancellation for endpoints that do not have streams
      enabled.
      
      An URB is represented by a number of Transaction Request Buffers (TRBs),
      that are chained together to make one (or more) Transaction Descriptors
      (TDs) on an endpoint ring.  The ring is comprised of contiguous segments,
      linked together with Link TRBs (which may or may not be chained into a TD).
      
      To cancel an URB, we must stop the endpoint ring, make the hardware skip
      over the TDs in the URB (either by turning them into No-op TDs, or by
      moving the hardware's ring dequeue pointer past the last TRB in the last
      TD), and then restart the ring.
      
      There are times when we must drop the xHCI lock during this process, like
      when we need to complete cancelled URBs.  We must ensure that additional
      URBs can be marked as cancelled, and that new URBs can be enqueued (since
      the URB completion handlers can do either).  The new endpoint ring
      variables cancels_pending and state (which can only be modified while
      holding the xHCI lock) ensure that future cancellation and enqueueing do
      not interrupt any pending cancellation code.
      
      To facilitate cancellation, we must keep track of the starting ring
      segment, first TRB, and last TRB for each URB.  We also need to keep track
      of the list of TDs that have been marked as cancelled, separate from the
      list of TDs that are queued for this endpoint.  The new variables and
      cancellation list are stored in the xhci_td structure.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      ae636747
    • S
      USB: xhci: Bulk transfer support · b10de142
      Sarah Sharp 提交于
      Allow device drivers to submit URBs to bulk endpoints on devices under an
      xHCI host controller.  Share code between the control and bulk enqueueing
      functions when it makes sense.
      
      To get the best performance out of bulk transfers, SuperSpeed devices must
      have the bMaxBurst size copied from their endpoint companion controller
      into the xHCI device context.  This allows the host controller to "burst"
      up to 16 packets before it has to wait for the device to acknowledge the
      first packet.
      
      The buffers in Transfer Request Blocks (TRBs) can cross page boundaries,
      but they cannot cross 64KB boundaries.  The buffer must be broken into
      multiple TRBs if a 64KB boundary is crossed.
      
      The sum of buffer lengths in all the TRBs in a Transfer Descriptor (TD)
      cannot exceed 64MB.  To work around this, the enqueueing code must enqueue
      multiple TDs.  The transfer event handler may incorrectly give back the
      URB in this case, if it gets a transfer event that points somewhere in the
      first TD.  FIXME later.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b10de142
    • S
      USB: xhci: Bandwidth allocation support · f94e0186
      Sarah Sharp 提交于
      Since the xHCI host controller hardware (xHC) has an internal schedule, it
      needs a better representation of what devices are consuming bandwidth on
      the bus.  Each device is represented by a device context, with data about
      the device, endpoints, and pointers to each endpoint ring.
      
      We need to update the endpoint information for a device context before a
      new configuration or alternate interface setting is selected.  We setup an
      input device context with modified endpoint information and newly
      allocated endpoint rings, and then submit a Configure Endpoint Command to
      the hardware.
      
      The host controller can reject the new configuration if it exceeds the bus
      bandwidth, or the host controller doesn't have enough internal resources
      for the configuration.  If the command fails, we still have the older
      device context with the previous configuration.  If the command succeeds,
      we free the old endpoint rings.
      
      The root hub isn't a real device, so always say yes to any bandwidth
      changes for it.
      
      The USB core will enable, disable, and then enable endpoint 0 several
      times during the initialization sequence.  The device will always have an
      endpoint ring for endpoint 0 and bandwidth allocated for that, unless the
      device is disconnected or gets a SetAddress 0 request.  So we don't pay
      attention for when xhci_check_bandwidth() is called for a re-add of
      endpoint 0.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f94e0186