1. 10 5月, 2011 3 次提交
  2. 03 5月, 2011 3 次提交
    • S
      xhci 1.0: Set transfer burst last packet count field. · b61d378f
      Sarah Sharp 提交于
      The xHCI 1.0 specification defines a new isochronous TRB field, called
      transfer burst last packet count (TBLPC).  This field defines the number
      of packets in the last "burst" of packets in a TD.  Only SuperSpeed
      endpoints can handle more than one burst, so this is set to the number for
      packets in a TD for all non-SuperSpeed devices (minus one, since the field
      is zero based).
      
      This patch should have no effect on host controllers that don't advertise
      the xHCI 1.0 (0x100) version number in their hci_version field.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      b61d378f
    • S
      xhci 1.0: Set transfer burst count field. · 5cd43e33
      Sarah Sharp 提交于
      The xHCI 1.0 specification adds a new field to the fourth dword in an
      isochronous TRB: the transfer burst count (TBC).  This field is only
      non-zero for SuperSpeed devices.  Each SS endpoint sets the bMaxBurst
      field in the SuperSpeed endpoint companion descriptor, which indicates how
      many max-packet-sized "bursts" it can handle in one service interval.  The
      device driver may choose to burst less max packet sized chunks each
      service interval (which is defined by one TD).  The xHCI driver indicates
      to the host controller how many bursts it needs to schedule through the
      transfer burst count field.
      
      This patch will only effect xHCI hosts that advertise 1.0 support (0x100)
      in the HCI version field of their capabilities register.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      5cd43e33
    • M
      xhci: Make xHCI driver endian-safe · 28ccd296
      Matt Evans 提交于
      This patch changes the struct members defining access to xHCI device-visible
      memory to use __le32/__le64 where appropriate, and then adds swaps where
      required.  Checked with sparse that all accesses are correct.
      
      MMIO accesses use readl/writel so already are performed LE, but prototypes
      now reflect this with __le*.
      
      There were a couple of (debug) instances of DMA pointers being truncated to
      32bits which have been fixed too.
      Signed-off-by: NMatt Evans <matt@ozlabs.org>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      28ccd296
  3. 14 4月, 2011 3 次提交
    • A
      xHCI: Implement AMD PLL quirk · c41136b0
      Andiry Xu 提交于
      This patch disable the optional PM feature inside the Hudson3 platform under
      the following conditions:
      
      1. If an isochronous device is connected to xHCI port and is active;
      2. Optional PM feature that powers down the internal Bus PLL when the link is
         in low power state is enabled.
      
      The PM feature needs to be disabled to eliminate PLL startup delays when the
      link comes out of low power state. The performance of DMA data transfer could
      be impacted if system delay were encountered and in addition to the PLL start
      up delays. Disabling the PM would leave room for unpredictable system delays
      in order to guarantee uninterrupted data transfer to isochronous audio or
      video stream devices that require time sensitive information. If data in an
      audio/video stream was interrupted then erratic audio or video performance
      may be encountered.
      
      AMD PLL quirk is already implemented in OHCI/EHCI driver. After moving the
      quirk code to pci-quirks.c and export them, xHCI driver can call it directly
      without having the quirk implementation in itself.
      Signed-off-by: NAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      c41136b0
    • D
      USB: xhci: unsigned char never equals -1 · 22e04870
      Dan Carpenter 提交于
      There were some places that compared port_speed == -1 where port_speed
      is a u8.  This doesn't work unless we cast the -1 to u8.  Some places
      did it correctly.
      
      Instead of using -1 directly, I've created a DUPLICATE_ENTRY define
      which does the cast and is more descriptive as well.
      Signed-off-by: NDan Carpenter <error27@gmail.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      22e04870
    • D
      USB: xhci - fix unsafe macro definitions · 5a6c2f3f
      Dmitry Torokhov 提交于
      Macro arguments used in expressions need to be enclosed in parenthesis
      to avoid unpleasant surprises.
      
      This should be queued for kernels back to 2.6.31
      Signed-off-by: NDmitry Torokhov <dtor@vmware.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@kernel.org
      5a6c2f3f
  4. 31 3月, 2011 1 次提交
  5. 14 3月, 2011 8 次提交
    • S
      xhci: Update internal dequeue pointers after stalls. · bf161e85
      Sarah Sharp 提交于
      When an endpoint stalls, the xHCI driver must move the endpoint ring's
      dequeue pointer past the stalled transfer.  To do that, the driver issues
      a Set TR Dequeue Pointer command, which will complete some time later.
      
      Takashi was having issues with USB 1.1 audio devices that stalled, and his
      analysis of the code was that the old code would not update the xHCI
      driver's ring dequeue pointer after the command completes.  However, the
      dequeue pointer is set in xhci_find_new_dequeue_state(), just before the
      set command is issued to the hardware.
      
      Setting the dequeue pointer before the Set TR Dequeue Pointer command
      completes is a dangerous thing to do, since the xHCI hardware can fail the
      command.  Instead, store the new dequeue pointer in the xhci_virt_ep
      structure, and update the ring's dequeue pointer when the Set TR dequeue
      pointer command completes.
      
      While we're at it, make sure we can't queue another Set TR Dequeue Command
      while the first one is still being processed.  This just won't work with
      the internal xHCI state code.  I'm still not sure if this is the right
      thing to do, since we might have a case where a driver queues multiple
      URBs to a control ring, one of the URBs Stalls, and then the driver tries
      to cancel the second URB.  There may be a race condition there where the
      xHCI driver might try to issue multiple Set TR Dequeue Pointer commands,
      but I would have to think very hard about how the Stop Endpoint and
      cancellation code works.  Keep the fix simple until when/if we run into
      that case.
      
      This patch should be queued to kernels all the way back to 2.6.31.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NTakashi Iwai <tiwai@suse.de>
      Cc: stable@kernel.org
      bf161e85
    • S
      xhci: Return canceled URBs immediately when host is halted. · c6cc27c7
      Sarah Sharp 提交于
      When the xHCI host controller is halted, it won't respond to commands
      placed on the command ring.  So if an URB is cancelled after the first
      roothub is deallocated, it will try to place a stop endpoint command on
      the command ring, which will fail.  The command watchdog timer will fire
      after five seconds, and the host controller will be marked as dying, and
      all URBs will be completed.
      
      Add a flag to the xHCI's internal state variable for when the host
      controller is halted.  Immediately return the canceled URB if the host
      controller is halted.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      c6cc27c7
    • S
      xhci: Register second xHCI roothub. · f6ff0ac8
      Sarah Sharp 提交于
      This patch changes the xHCI driver to allocate two roothubs.  This touches
      the driver initialization and shutdown paths, roothub emulation code, and
      port status change event handlers.  This is a rather large patch, but it
      can't be broken up, or it would break git-bisect.
      
      Make the xHCI driver register its own PCI probe function.  This will call
      the USB core to create the USB 2.0 roothub, and then create the USB 3.0
      roothub.  This gets the code for registering a shared roothub out of the
      USB core, and allows other HCDs later to decide if and how many shared
      roothubs they want to allocate.
      
      Make sure the xHCI's reset method marks the xHCI host controller's primary
      roothub as the USB 2.0 roothub.  This ensures that the high speed bus will
      be processed first when the PCI device is resumed, and any USB 3.0 devices
      that have migrated over to high speed will migrate back after being reset.
      This ensures that USB persist works with these odd devices.
      
      The reset method will also mark the xHCI USB2 roothub as having an
      integrated TT.  Like EHCI host controllers with a "rate matching hub" the
      xHCI USB 2.0 roothub doesn't have an OHCI or UHCI companion controller.
      It doesn't really have a TT, but we'll lie and say it has an integrated
      TT.  We need to do this because the USB core will reject LS/FS devices
      under a HS hub without a TT.
      
      Other details:
      -------------
      
      The roothub emulation code is changed to return the correct number of
      ports for the two roothubs.  For the USB 3.0 roothub, it only reports the
      USB 3.0 ports.  For the USB 2.0 roothub, it reports all the LS/FS/HS
      ports.  The code to disable a port now checks the speed of the roothub,
      and refuses to disable SuperSpeed ports under the USB 3.0 roothub.
      
      The code for initializing a new device context must be changed to set the
      proper roothub port number.  Since we've split the xHCI host into two
      roothubs, we can't just use the port number in the ancestor hub.  Instead,
      we loop through the array of hardware port status register speeds and find
      the Nth port with a similar speed.
      
      The port status change event handler is updated to figure out whether the
      port that reported the change is a USB 3.0 port, or a non-SuperSpeed port.
      Once it figures out the port speed, it kicks the proper roothub.
      
      The function to find a slot ID based on the port index is updated to take
      into account that the two roothubs will have over-lapping port indexes.
      It checks that the virtual device with a matching port index is the same
      speed as the passed in roothub.
      
      There's also changes to the driver initialization and shutdown paths:
      
       1. Make sure that the xhci_hcd pointer is shared across the two
          usb_hcd structures.  The xhci_hcd pointer is allocated and the
          registers are mapped in when xhci_pci_setup() is called with the
          primary HCD.  When xhci_pci_setup() is called with the non-primary
          HCD, the xhci_hcd pointer is stored.
      
       2. Make sure to set the sg_tablesize for both usb_hcd structures.  Set
          the PCI DMA mask for the non-primary HCD to allow for 64-bit or 32-bit
          DMA.  (The PCI DMA mask is set from the primary HCD further down in
          the xhci_pci_setup() function.)
      
       3. Ensure that the host controller doesn't start kicking khubd in
          response to port status changes before both usb_hcd structures are
          registered.  xhci_run() only starts the xHC running once it has been
          called with the non-primary roothub.  Similarly, the xhci_stop()
          function only halts the host controller when it is called with the
          non-primary HCD.  Then on the second call, it resets and cleans up the
          MSI-X irqs.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      f6ff0ac8
    • S
      xhci: Change xhci_find_slot_id_by_port() API. · 5233630f
      Sarah Sharp 提交于
      xhci_find_slot_id_by_port() tries to map the port index to the slot ID for
      the USB device.  In the future, there will be two xHCI roothubs, and their
      port indices will overlap.  Therefore, xhci_find_slot_id_by_port() will
      need to use information in the roothub's usb_hcd structure to map the port
      index and roothub speed to the right slot ID.
      
      Add a new parameter to xhci_find_slot_id_by_port(), in order to pass in
      the roothub's usb_hcd structure.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      5233630f
    • S
      xhci: Refactor bus suspend state into a struct. · 20b67cf5
      Sarah Sharp 提交于
      There are several variables in the xhci_hcd structure that are related to
      bus suspend and resume state.  There are a couple different port status
      arrays that are accessed by port index.  Move those variables into a
      separate structure, xhci_bus_state.  Stash that structure in xhci_hcd.
      
      When we have two roothhubs that can be suspended and resumed separately,
      we can have two xhci_bus_states, and index into the port arrays in each
      structure with the fake roothub port index (not the real hardware port
      index).
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      20b67cf5
    • S
      xhci: Change hcd_priv into a pointer. · b02d0ed6
      Sarah Sharp 提交于
      Instead of allocating space for the whole xhci_hcd structure at the end of
      usb_hcd, make the USB core allocate enough space for a pointer to the
      xhci_hcd structure.  This will make it easy to share the xhci_hcd
      structure across the two roothubs (the USB 3.0 usb_hcd and the USB 2.0
      usb_hcd).
      
      Deallocate the xhci_hcd at PCI remove time, so the hcd_priv will be
      deallocated after the usb_hcd is deallocated.  We do this by registering a
      different PCI remove function that calls the usb_hcd_pci_remove()
      function, and then frees the xhci_hcd.  usb_hcd_pci_remove() calls
      kput() on the usb_hcd structure, which will deallocate the memory that
      contains the hcd_priv pointer, but not the memory it points to.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      b02d0ed6
    • S
      xhci: Rework port suspend structures for limited ports. · 1d5810b6
      Sarah Sharp 提交于
      The USB core only allows up to 31 (USB_MAXCHILDREN) ports under a roothub.
      The xHCI driver keeps track of which ports are suspended, which ports have
      a suspend change bit set, and what time the port will be done resuming.
      It keeps track of the first two by setting a bit in a u32 variable,
      suspended_ports or port_c_suspend.  The xHCI driver currently assumes we
      can have up to 256 ports under a roothub, so it allocates an array of 8
      u32 variables for both suspended_ports and port_c_suspend.  It also
      allocates a 256-element array to keep track of when the ports will be done
      resuming.
      
      Since we can only have 31 roothub ports, we only need to use one u32 for
      each of the suspend state and change variables.  We simplify the bit math
      that's trying to index into those arrays and set the correct bit, if we
      assume wIndex never exceeds 30.  (wIndex is zero-based after it's
      decremented from the value passed in from the USB core.)  Finally, we
      change the resume_done array to only hold 31 elements.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Andiry Xu <andiry.xu@amd.com>
      1d5810b6
    • S
      xhci: Remove old no-op test. · 0b8ca72a
      Sarah Sharp 提交于
      The test of placing a number of command no-ops on the command ring and
      counting the number of no-op events that were generated was only used
      during the initial xHCI driver bring up.  This test is no longer used, so
      delete it.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      0b8ca72a
  6. 20 2月, 2011 1 次提交
  7. 15 1月, 2011 1 次提交
  8. 20 11月, 2010 1 次提交
    • S
      xhci: Setup array of USB 2.0 and USB 3.0 ports. · da6699ce
      Sarah Sharp 提交于
      An xHCI host controller contains USB 2.0 and USB 3.0 ports, which can
      occur in any order in the PORTSC registers.  We cannot read the port speed
      bits in the PORTSC registers at init time to determine the port speed,
      since those bits are only valid when a USB device is plugged into the
      port.
      
      Instead, we read the "Supported Protocol Capability" registers in the xHC
      Extended Capabilities space.  Those describe the protocol, port offset in
      the PORTSC registers, and port count.  We use those registers to create
      two arrays of pointers to the PORTSC registers, one for USB 3.0 ports, and
      another for USB 2.0 ports.  A third array keeps track of the port protocol
      major revision, and is indexed with the internal xHCI port number.
      
      This commit is a bit big, but it should be queued for stable because the "Don't
      let the USB core disable SuperSpeed ports" patch depends on it.  There is no
      other way to determine which ports are SuperSpeed ports without this patch.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NDon Zickus <dzickus@redhat.com>
      Cc: stable@kernel.org
      da6699ce
  9. 12 11月, 2010 1 次提交
  10. 23 10月, 2010 8 次提交
  11. 11 8月, 2010 8 次提交
    • S
      USB: xhci: Make xhci_set_hc_event_deq() static. · 257d585a
      Sarah Sharp 提交于
      Now that the event handler functions no longer use xhci_set_hc_event_deq()
      to update the event ring dequeue pointer, that function is not used by
      anything in xhci-ring.c.  Move that function into xhci-mem.c and make it
      static.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      257d585a
    • S
      USB: xhci: Make xhci_handle_event() static. · d6d98a4d
      Sarah Sharp 提交于
      xhci_handle_event() is now only called from within xhci-ring.c, so make it
      static.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d6d98a4d
    • S
      USB: xhci: Performance - move interrupt handlers into xhci-ring.c · 9032cd52
      Sarah Sharp 提交于
      Most of the work for interrupt handling is done in xhci-ring.c, so it makes
      sense to move the functions that are first called when an interrupt happens
      (xhci_irq() or xhci_msi_irq()) into xhci-ring.c, so that the compiler can better
      optimize them.
      
      Shorten some lines to make it pass checkpatch.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9032cd52
    • S
      USB: xhci: Performance - move functions that find ep ring. · 021bff91
      Sarah Sharp 提交于
      I've been using perf to measure the top symbols while transferring 1GB of data
      on a USB 3.0 drive with dd.  This is using the raw disk with /dev/sdb, with a
      block size of 1K.
      
      During performance testing, the top symbol was xhci_triad_to_transfer_ring(), a
      function that should return immediately if streams are not enabled for an
      endpoint.  It turned out that the functions to find the endpoint ring was
      defined in xhci-mem.c and used in xhci-ring.c and xhci-hcd.c.  I moved a copy of
      xhci_triad_to_transfer_ring() and xhci_urb_to_transfer_ring() into xhci-ring.c
      and declared them static.  I also made a static version of
      xhci_urb_to_transfer_ring() in xhci.c.
      
      This improved throughput on a 1GB read of the raw disk with dd from
      186MB/s to 195MB/s, and perf reported sampling the xhci_triad_to_transfer_ring()
      0.06% of the time, rather than 9.26% of the time.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      021bff91
    • A
      USB: xHCI: Isochronous transfer implementation · 04e51901
      Andiry Xu 提交于
      This patch implements isochronous urb enqueue and interrupt handler part.
      
      When an isochronous urb is passed to xHCI driver, first check the transfer
      ring to guarantee there is enough room for the whole urb. Then update the
      start_frame and interval field of the urb. Always assume URB_ISO_ASAP
      is set, and never use urb->start_frame as input.
      
      The number of isoc TDs is equal to urb->number_of_packets. One isoc TD is
      consumed every Interval. Each isoc TD consists of an Isoch TRB chained to
      zero or more Normal TRBs.
      
      Call prepare_transfer for each TD to do initialization; then calculate the
      number of TRBs needed for each TD. If the data required by an isoc TD is
      physically contiguous (not crosses a page boundary), then only one isoc TRB
      is needed; otherwise one or more additional normal TRB shall be chained to
      the isoc TRB by the host.
      
      Set TRB_IOC to the last TRB of each isoc TD. Do not ring endpoint doorbell
      to start xHC procession until all the TDs are inserted to the endpoint
      transer ring.
      
      In irq handler, update urb status and actual_length, increase
      urb_priv->td_cnt. When all the TDs are completed(td_cnt is equal to
      urb_priv->length), giveback the urb to usbcore.
      Signed-off-by: NAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      04e51901
    • A
      USB: xHCI: Introduce urb_priv structure · 8e51adcc
      Andiry Xu 提交于
      Add urb_priv data structure to xHCI driver. This structure allows multiple
      xhci TDs to be linked to one urb, which is essential for isochronous
      transfer. For non-isochronous urb, only one TD is needed for one urb;
      for isochronous urb, the TD number for the urb is equal to
      urb->number_of_packets.
      
      The length field of urb_priv indicates the number of TDs in the urb.
      The td_cnt field indicates the number of TDs already processed by xHC.
      When td_cnt matches length, the urb can be given back to usbcore.
      
      When an urb is dequeued or cancelled, add all the unprocessed TDs to the
      endpoint's cancelled_td_list. When process a cancelled TD, increase
      td_cnt field. When td_cnt equals urb_priv->length, giveback the
      cancelled urb.
      Signed-off-by: NAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      8e51adcc
    • A
      USB: xHCI: Missed Service Error Event process · d18240db
      Andiry Xu 提交于
      This patch adds mechanism to process Missed Service Error Event.
      Sometimes the xHC is unable to process the isoc TDs in time, it will
      generate Missed Service Error Event. In this case some TDs on the ring are
      not processed and missed. When encounter a Missed Servce Error Event, set
      the skip flag of the ep, and process the missed TDs until reach the next
      processed TD, then clear the skip flag.
      Signed-off-by: NAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d18240db
    • D
      USB: xHCI: Supporting MSI/MSI-X · 43b86af8
      Dong Nguyen 提交于
      Enable MSI/MSI-X supporting in xhci driver.
      
      Provide the mechanism to fall back using MSI and Legacy IRQs
      if MSI-X IRQs register failed.
      Signed-off-by: NDong Nguyen <Dong.Nguyen@amd.com>
      Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>,
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      43b86af8
  12. 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
  13. 05 6月, 2010 1 次提交
    • S
      USB: xhci: Print NEC firmware version. · 0238634d
      Sarah Sharp 提交于
      The NEC xHCI host controller firmware version can be found by putting a
      vendor-specific command on the command ring and extracting the BCD
      encoded-version out of the vendor-specific event TRB.
      
      The firmware version debug line in dmesg will look like:
      
      xhci_hcd 0000:05:00.0: NEC firmware version 30.21
      
      (NEC merged with Renesas Technologies and became Renesas Electronics on
      April 1, 2010.  I have their OK to merge this vendor-specific code.)
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Satoshi Otani <satoshi.otani.xm@renesas.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0238634d