1. 14 Mar, 2011 39 commits
    • Paul Zimmerman's avatar
      USB: Add support for SuperSpeed isoc endpoints · 500132a0
      Paul Zimmerman authored
      Use the Mult and bMaxBurst values from the endpoint companion
      descriptor to calculate the max length of an isoc transfer.
      
      Add USB_SS_MULT macro to access Mult field of bmAttributes, at
      Sarah's suggestion.
      
      This patch should be queued for the 2.6.36 and 2.6.37 stable trees, since
      those were the first kernels to have isochronous support for SuperSpeed
      devices.
      Signed-off-by: default avatarPaul Zimmerman <paulz@synopsys.com>
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@kernel.org
      500132a0
    • Sarah Sharp's avatar
      xhci: Clean up cycle bit math used during stalls. · ba0a4d9a
      Sarah Sharp authored
      Use XOR to invert the cycle bit, instead of a more complicated
      calculation.  Eliminate a check for the link TRB type in find_trb_seg().
      We know that there will always be a link TRB at the end of a segment, so
      xhci_segment->trbs[TRBS_PER_SEGMENT - 1] will always have a link TRB type.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: default avatarTakashi Iwai <tiwai@suse.de>
      ba0a4d9a
    • Sarah Sharp's avatar
      xhci: Fix cycle bit calculation during stall handling. · 01a1fdb9
      Sarah Sharp authored
      When an endpoint stalls, we need to update the xHCI host's internal
      dequeue pointer to move it past the stalled transfer.  This includes
      updating the cycle bit (TRB ownership bit) if we have moved the dequeue
      pointer past a link TRB with the toggle cycle bit set.
      
      When we're trying to find the new dequeue segment, find_trb_seg() is
      supposed to keep track of whether we've passed any link TRBs with the
      toggle cycle bit set.  However, this while loop's body
      
      	while (cur_seg->trbs > trb ||
      			&cur_seg->trbs[TRBS_PER_SEGMENT - 1] < trb) {
      
      Will never get executed if the ring only contains one segment.
      find_trb_seg() will return immediately, without updating the new cycle
      bit.  Since find_trb_seg() has no idea where in the segment the TD that
      stalled was, make the caller, xhci_find_new_dequeue_state(), check for
      this special case and update the cycle bit accordingly.
      
      This patch should be queued to kernels all the way back to 2.6.31.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: default avatarTakashi Iwai <tiwai@suse.de>
      Cc: stable@kernel.org
      01a1fdb9
    • Sarah Sharp's avatar
      xhci: Update internal dequeue pointers after stalls. · bf161e85
      Sarah Sharp authored
      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: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: default avatarTakashi Iwai <tiwai@suse.de>
      Cc: stable@kernel.org
      bf161e85
    • Sarah Sharp's avatar
      USB: Disable auto-suspend for USB 3.0 hubs. · 0c9ffe0f
      Sarah Sharp authored
      USB 3.0 devices have a slightly different suspend sequence than USB
      2.0/1.1 devices.  There isn't support for USB 3.0 device suspend yet, so
      make khubd leave autosuspend disabled for USB 3.0 hubs.  Make sure that
      USB 3.0 roothubs still have autosuspend enabled, since that path in the
      xHCI driver works fine.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      0c9ffe0f
    • Sarah Sharp's avatar
      USB: Remove bogus USB_PORT_STAT_SUPER_SPEED symbol. · 131dec34
      Sarah Sharp authored
      USB_PORT_STAT_SUPER_SPEED is a made up symbol that the USB core used to
      track whether USB ports had a SuperSpeed device attached.  This is a
      linux-internal symbol that was used when SuperSpeed and non-SuperSpeed
      devices would show up under the same xHCI roothub.  This particular
      port status is never returned by external USB 3.0 hubs.  (Instead they
      have a USB_PORT_STAT_SPEED_5GBPS that uses a completely different speed
      mask.)
      
      Now that the xHCI driver registers two roothubs, USB 3.0 devices will only
      show up under USB 3.0 hubs.  Rip out USB_PORT_STAT_SUPER_SPEED and replace
      it with calls to hub_is_superspeed().
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      131dec34
    • Sarah Sharp's avatar
      xhci: Return canceled URBs immediately when host is halted. · c6cc27c7
      Sarah Sharp authored
      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: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      c6cc27c7
    • Sarah Sharp's avatar
      xhci: Fixes for suspend/resume of shared HCDs. · b3209379
      Sarah Sharp authored
      Make sure the HCD_FLAG_HW_ACCESSIBLE flag is mirrored by both roothubs,
      since it refers to whether the shared hardware is accessible.  Make sure
      each bus is marked as suspended by setting usb_hcd->state to
      HC_STATE_SUSPENDED when the PCI host controller is resumed.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      b3209379
    • Sarah Sharp's avatar
      xhci: Fix re-init on power loss after resume. · 65b22f93
      Sarah Sharp authored
      When a host controller has lost power during a suspend, we must
      reinitialize it.  Now that the xHCI host has two roothubs, xhci_run() and
      xhci_stop() expect to be called with both usb_hcd structures.  Be sure
      that the re-initialization code in xhci_resume() mirrors the process the
      USB PCI probe function uses.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      65b22f93
    • Sarah Sharp's avatar
      xhci: Make roothub functions deal with device removal. · f9de8151
      Sarah Sharp authored
      Return early in the roothub control and status functions if the xHCI host
      controller is not electrically present in the system (register reads
      return all "fs").  This issue only shows up when the xHCI driver registers
      two roothubs and the host controller is removed from the system.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      f9de8151
    • Sarah Sharp's avatar
      xhci: Limit roothub ports to 15 USB3 & 31 USB2 ports. · d30b2a20
      Sarah Sharp authored
      The USB core allocates a USB 2.0 roothub descriptor that has room for 31
      (USB_MAXCHILDREN) ports' worth of DeviceRemovable and PortPwrCtrlMask
      fields.  Limit the number of USB 2.0 roothub ports accordingly.  I don't
      expect to run into this limitation ever, but this prevents a buffer
      overflow issue in the roothub descriptor filling code.
      
      Similarly, a USB 3.0 hub can only have 15 downstream ports, so limit the
      USB 3.0 roothub to 15 USB 3.0 ports.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      d30b2a20
    • Sarah Sharp's avatar
      xhci: Return a USB 3.0 hub descriptor for USB3 roothub. · 4bbb0ace
      Sarah Sharp authored
      Return the correct xHCI roothub descriptor, based on whether the roothub
      is marked as USB 3.0 or USB 2.0 in usb_hcd->bcdUSB.  Fill in
      DeviceRemovable for the USB 2.0 and USB 3.0 roothub descriptors, using the
      Device Removable bit in the port status and control registers.  xHCI is
      the first host controller to actually properly set these bits (other hosts
      say all devices are removable).
      
      When userspace asks for a USB 2.0-style hub descriptor for the USB 3.0
      roothub, stall the endpoint.  This is what real external USB 3.0 hubs do,
      and we don't want to return a descriptor that userspace didn't ask for.
      
      The USB core is already fixed to always ask for USB 3.0-style hub
      descriptors.  Only usbfs (typically lsusb) will ask for the USB 2.0-style
      hub descriptors.  This has already been fixed in usbutils version 0.91,
      but the kernel needs to deal with older usbutils versions.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      4bbb0ace
    • Sarah Sharp's avatar
      xhci: Register second xHCI roothub. · f6ff0ac8
      Sarah Sharp authored
      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: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      f6ff0ac8
    • Sarah Sharp's avatar
      xhci: Change xhci_find_slot_id_by_port() API. · 5233630f
      Sarah Sharp authored
      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: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      5233630f
    • Sarah Sharp's avatar
      xhci: Refactor bus suspend state into a struct. · 20b67cf5
      Sarah Sharp authored
      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: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      20b67cf5
    • Sarah Sharp's avatar
      xhci: Index with a port array instead of PORTSC addresses. · 5308a91b
      Sarah Sharp authored
      In the upcoming patches, the roothub emulation code will need to return
      port status and port change buffers based on whether they are called with
      the xHCI USB 2.0 or USB 3.0 roothub.  To facilitate that, make the roothub
      code index into an array of port addresses with wIndex, rather than
      calculating the address using the offset and the address of the PORTSC
      registers.  Later we can set the port array to be the array of USB 3.0
      port addresses, or the USB 2.0 port addresses, depending on the roothub
      passed in.
      
      Create a temporary (statically sized) port array and fill it in with both
      USB 3.0 and USB 2.0 port addresses.  This is inefficient to do for every
      roothub call, but this is needed for git bisect compatibility.  The
      temporary port array will be deleted in a subsequent patch.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      5308a91b
    • Sarah Sharp's avatar
      USB: Set usb_hcd->state and flags for shared roothubs. · ff9d78b3
      Sarah Sharp authored
      The hcd->flags are in a sorry state.  Some of them are clearly specific to
      the particular roothub (HCD_POLL_RH, HCD_POLL_PENDING, and
      HCD_WAKEUP_PENDING), but some flags are related to PCI device state
      (HCD_HW_ACCESSIBLE and HCD_SAW_IRQ).  This is an issue when one PCI device
      can have two roothubs that share the same IRQ line and hardware.
      
      Make sure to set HCD_FLAG_SAW_IRQ for both roothubs when an interrupt is
      serviced, or an URB is unlinked without an interrupt.  (We can't tell if
      the host actually serviced an interrupt for a particular bus, but we can
      tell it serviced some interrupt.)
      
      HCD_HW_ACCESSIBLE is set once by usb_add_hcd(), which is set for both
      roothubs as they are added, so it doesn't need to be modified.
      HCD_POLL_RH and HCD_POLL_PENDING are only checked by the USB core, and
      they are never set by the xHCI driver, since the roothub never needs to be
      polled.
      
      The usb_hcd's state field is a similar mess.  Sometimes the state applies
      to the underlying hardware: HC_STATE_HALT, HC_STATE_RUNNING, and
      HC_STATE_QUIESCING.  But sometimes the state refers to the roothub state:
      HC_STATE_RESUMING and HC_STATE_SUSPENDED.
      
      Alan Stern recently made the USB core not rely on the hcd->state variable.
      Internally, the xHCI driver still checks for HC_STATE_SUSPENDED, so leave
      that code in.  Remove all references to HC_STATE_HALT, since the xHCI
      driver only sets and doesn't test those variables.  We still have to set
      HC_STATE_RUNNING, since Alan's patch has a bug that means the roothub
      won't get registered if we don't set that.
      
      Alan's patch made the USB core check a different variable when trying to
      determine whether to suspend a roothub.  The xHCI host has a split
      roothub, where two buses are registered for one PCI device.  Each bus in
      the xHCI split roothub can be suspended separately, but both buses must be
      suspended before the PCI device can be suspended.  Therefore, make sure
      that the USB core checks HCD_RH_RUNNING() for both roothubs before
      suspending the PCI host.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      ff9d78b3
    • Sarah Sharp's avatar
      usb: Make core allocate resources per PCI-device. · c5635437
      Sarah Sharp authored
      Introduce the notion of a PCI device that may be associated with more than
      one USB host controller driver (struct usb_hcd).  This patch is the start
      of the work to separate the xHCI host controller into two roothubs: a USB
      3.0 roothub with SuperSpeed-only ports, and a USB 2.0 roothub with
      HS/FS/LS ports.
      
      One usb_hcd structure is designated to be the "primary HCD", and a pointer
      is added to the usb_hcd structure to keep track of that.  A new function
      call, usb_hcd_is_primary_hcd() is added to check whether the USB hcd is
      marked as the primary HCD (or if it is not part of a roothub pair).  To
      allow the USB core and xHCI driver to access either roothub in a pair, a
      "shared_hcd" pointer is added to the usb_hcd structure.
      
      Add a new function, usb_create_shared_hcd(), that does roothub allocation
      for paired roothubs.  It will act just like usb_create_hcd() did if the
      primary_hcd pointer argument is NULL.  If it is passed a non-NULL
      primary_hcd pointer, it sets usb_hcd->shared_hcd and usb_hcd->primary_hcd
      fields.  It will also skip the bandwidth_mutex allocation, and set the
      secondary hcd's bandwidth_mutex pointer to the primary HCD's mutex.
      
      IRQs are only allocated once for the primary roothub.
      
      Introduce a new usb_hcd driver flag that indicates the host controller
      driver wants to create two roothubs.  If the HCD_SHARED flag is set, then
      the USB core PCI probe methods will allocate a second roothub, and make
      sure that second roothub gets freed during rmmod and in initialization
      error paths.
      
      When usb_hc_died() is called with the primary HCD, make sure that any
      roothubs that share that host controller are also marked as being dead.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      c5635437
    • Sarah Sharp's avatar
      usb: Store bus type in usb_hcd, not in driver flags. · 83de4b2b
      Sarah Sharp authored
      The xHCI driver essentially has both a USB 2.0 and a USB 3.0 roothub.  So
      setting the HCD_USB3 bits in the hcd->driver->flags is a bit misleading.
      Add a new field to usb_hcd, bcdUSB.  Store the result of
      hcd->driver->flags & HCD_MASK in it.  Later, when we have the xHCI driver
      register the two roothubs, we'll set the usb_hcd->bcdUSB field to HCD_USB2
      for the USB 2.0 roothub, and HCD_USB3 for the USB 3.0 roothub.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      83de4b2b
    • Sarah Sharp's avatar
      usb: Change usb_hcd->bandwidth_mutex to a pointer. · d673bfcb
      Sarah Sharp authored
      Change the bandwith_mutex in struct usb_hcd to a pointer.  This will allow
      the pointer to be shared across usb_hcds for the upcoming work to split
      the xHCI driver roothub into a USB 2.0/1.1 and a USB 3.0 bus.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      d673bfcb
    • Sarah Sharp's avatar
      usb: Refactor irq enabling out of usb_add_hcd() · 23e0d106
      Sarah Sharp authored
      Refactor out the code in usb_add_hcd() to request the IRQ line for the
      HCD.  This will only need to be called once for the two xHCI roothubs, so
      it's easier to refactor it into a function, rather than wrapping the long
      if-else block into another if statement.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      23e0d106
    • Sarah Sharp's avatar
      usb: Make usb_hcd_pci_probe labels more descriptive. · 8766c815
      Sarah Sharp authored
      Make the labels for the goto statements in usb_hcd_pci_probe()
      describe the cleanup they do, rather than being numbered err[1-4].
      This makes it easier to add error handling later.
      
      The error handling for this function looks a little fishy, since
      set_hs_companion() isn't called until the very end of the function, and
      clear_hs_companion() is called if this function fails earlier than that.
      But it should be harmless to clear a NULL pointer, so leave the error
      handling as-is.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      8766c815
    • Sarah Sharp's avatar
      xhci: Change hcd_priv into a pointer. · b02d0ed6
      Sarah Sharp authored
      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: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      b02d0ed6
    • Sarah Sharp's avatar
      xhci: Always use usb_hcd in URB instead of converting xhci_hcd. · 214f76f7
      Sarah Sharp authored
      Make sure to call into the USB core's link, unlink, and giveback URB
      functions with the usb_hcd pointer found by using urb->dev->bus.  This
      will avoid confusion later, when the xHCI driver will deal with URBs from
      two separate buses (the USB 3.0 roothub and the faked USB 2.0 roothub).
      
      Assume xhci_urb_dequeue() will be called with the proper usb_hcd.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      214f76f7
    • Sarah Sharp's avatar
      xhci: Modify check for TT info. · aa1b13ef
      Sarah Sharp authored
      Commit d199c96d by Alan Stern ensured that low speed and full speed
      devices below a high speed hub without a transaction translator (TT) would
      never get enumerated.  Simplify the check for a TT in the xHCI virtual
      device allocation to only check if the usb_device references a parent's
      TT.
      
      Make sure not to set the TT information on LS/FS devices directly
      connected to the roothub.  The xHCI host doesn't really have a TT, and the
      host will throw an error when those virtual device TT fields are set for a
      device connected to the roothub.  We need this check because the xHCI
      driver will shortly register two roothubs: a USB 2.0 roothub and a USB 3.0
      roothub.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      aa1b13ef
    • Sarah Sharp's avatar
      usb: Make USB 3.0 roothub have a SS EP comp descriptor. · 22c6a35d
      Sarah Sharp authored
      Make the USB 3.0 roothub registered by the USB core have a SuperSpeed
      Endpoint Companion Descriptor after the interrupt endpoint.  All USB 3.0
      devices are required to have this, and the USB 3.0 bus specification
      (section 10.13.1) says which values the descriptor should have.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      22c6a35d
    • Sarah Sharp's avatar
      USB: Clear "warm" port reset change. · c7061574
      Sarah Sharp authored
      In USB 3.0, there are two types of resets: a "hot" port reset and a "warm"
      port reset.  The hot port reset is always tried first, and involves
      sending the reset signaling for a shorter amount of time.  But sometimes
      devices don't respond to the hot reset, and a "Bigger Hammer" is needed.
      
      External hubs and roothubs will automatically try a warm reset when the
      hot reset fails, and they will set a status change bit to indicate when
      there is a "BH reset" change.  Make sure the USB core clears that port
      status change bit, or we'll get lots of status change notifications on the
      interrupt endpoint of the USB 3.0 hub.
      
      (Side note: you may be confused why the USB 3.0 spec calls the same type
      of reset "warm reset" in some places and "BH reset" in other places.  "BH"
      reset is supposed to stand for "Big Hammer" reset, but it also stands for
      "Brad Hosler".  Brad died shortly after the USB 3.0 bus specification was
      started, and they decided to name the reset after him.  The suggestion was
      made shortly before the spec was finalized, so the wording is a bit
      inconsistent.)
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      c7061574
    • John Youn's avatar
      USB 3.0 Hub Changes · dbe79bbe
      John Youn authored
      Update the USB core to deal with USB 3.0 hubs.  These hubs have a slightly
      different hub descriptor than USB 2.0 hubs, with a fixed (rather than
      variable length) size.  Change the USB core's hub descriptor to have a
      union for the last fields that differ.  Change the host controller drivers
      that access those last fields (DeviceRemovable and PortPowerCtrlMask) to
      use the union.
      
      Translate the new version of the hub port status field into the old
      version that khubd understands.  (Note: we need to fix it to translate the
      roothub's port status once we stop converting it to USB 2.0 hub status
      internally.)
      
      Add new code to handle link state change status.  Send out new control
      messages that are needed for USB 3.0 hubs, like Set Hub Depth.
      
      This patch is a modified version of the original patch submitted by John
      Youn.  It's updated to reflect the removal of the "bitmap" #define, and
      change the hub descriptor accesses of a couple new host controller
      drivers.
      Signed-off-by: default avatarJohn Youn <johnyoun@synopsys.com>
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
      Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
      Cc: Tony Olech <tony.olech@elandigitalsystems.com>
      Cc: "Robert P. J. Day" <rpjday@crashcourse.ca>
      Cc: Max Vozeler <mvz@vozeler.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: Rodolfo Giometti <giometti@linux.it>
      Cc: Mike Frysinger <vapier@gentoo.org>
      Cc: Anton Vorontsov <avorontsov@mvista.com>
      Cc: Sebastian Siewior <bigeasy@linutronix.de>
      Cc: Lothar Wassmann <LW@KARO-electronics.de>
      Cc: Olav Kongas <ok@artecdesign.ee>
      Cc: Martin Fuzzey <mfuzzey@gmail.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: David Brownell <dbrownell@users.sourceforge.net>
      dbe79bbe
    • Sarah Sharp's avatar
      xhci: Remove references to HC_STATE_RUNNING. · ad73dff3
      Sarah Sharp authored
      The USB core will set hcd->state to HC_STATE_RUNNING before calling
      xhci_run, so there's no point in setting it twice.  The USB core also
      doesn't pay attention to HC_STATE_RUNNING on the resume path anymore; it
      uses HCD_RH_RUNNING(), which looks at hcd->flags & (1U <<
      HCD_FLAG_RH_RUNNING.  Therefore, it's safe to remove the state set in
      xhci_bus_resume().
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      ad73dff3
    • Sarah Sharp's avatar
      usb: Initialize hcd->state roothubs. · 4814030c
      Sarah Sharp authored
      We would like to allow host controller drivers to stop using hcd->state.
      Unfortunately, some host controller drivers use hcd->state as an
      implicit way of telling the core that a controller has died.  The
      roothub registration functions must assume the host died if hcd->state
      equals HC_STATE_HALT.
      
      To facilitate drivers that don't want to set hcd->state to
      HC_STATE_RUNNING in their initialization routines, we set the state to
      running before calling the host controller's start function.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      4814030c
    • Sarah Sharp's avatar
      xhci: Remove references to HC_STATE_HALT. · ac04e6ff
      Sarah Sharp authored
      The xHCI driver doesn't ever test hcd->state for HC_STATE_HALT.  The USB
      core recently stopped using it internally, so there's no point in setting
      it in the driver.  We still need to set HC_STATE_RUNNING in order to make
      it past the USB core's hcd->state check in register_roothub().
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      ac04e6ff
    • Andiry Xu's avatar
      xHCI: prolong host controller halt time limit · bdfca502
      Andiry Xu authored
      xHCI 1.0 spec specifies the xHC shall halt within 16ms after software clears
      Run/Stop bit. In xHCI 0.96 spec the time limit is 16 microframes (2ms), it's
      too short and often cause dmesg shows "Host controller not halted, aborting
      reset." message when rmmod xhci-hcd.
      
      Modify the time limit to comply with xHCI 1.0 specification and prevents the
      warning message showing when remove xhci-hcd.
      Signed-off-by: default avatarAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      bdfca502
    • Andiry Xu's avatar
      xHCI: Remove redundant variable in xhci_resume() · 019a35f1
      Andiry Xu authored
      Set hcd->state = HC_STATE_SUSPENDED if there is a power loss during system
      resume or the system is hibernated, otherwise leave it be. The variable
      old_state is redundant and made an unreachable code path, so remove it.
      Signed-off-by: default avatarAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      019a35f1
    • Sarah Sharp's avatar
      xhci: Rename variables and reduce register reads. · 518e848e
      Sarah Sharp authored
      The xhci_bus_suspend() and xhci_bus_resume() functions are a bit hard to
      read, because they have an ambiguously named variable "port".  Rename it
      to "port_index".  Introduce a new temporary variable, "max_ports" that
      holds the maximum number of roothub ports the host controller supports.
      This will reduce the number of register reads, and make it easy to change
      the maximum number of ports when there are two roothubs.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      518e848e
    • Sarah Sharp's avatar
      xhci: Rework port suspend structures for limited ports. · 1d5810b6
      Sarah Sharp authored
      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: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Andiry Xu <andiry.xu@amd.com>
      1d5810b6
    • Sarah Sharp's avatar
      USB: Fix usb_add_hcd() checkpatch errors. · abc4f9b0
      Sarah Sharp authored
      The irq enabling code is going to be refactored into a new function, so
      clean up some checkpatch errors before moving it.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      abc4f9b0
    • Sarah Sharp's avatar
      USB: Remove bitmap #define from hcd.h · da13051c
      Sarah Sharp authored
      Using a #define to redefine a common variable name is a bad thing,
      especially when the #define is in a header.  include/linux/usb/hcd.h
      redefined bitmap to DeviceRemovable to avoid typing a long field in the
      hub descriptor.  This has unintended side effects for files like
      drivers/usb/core/devio.c that include that file, since another header
      included after hcd.h has different variables named bitmap.
      
      Remove the bitmap #define and replace instances of it in the host
      controller code.  Cleanup the spaces around function calls and square
      brackets while we're at it.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
      Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
      Cc: Tony Olech <tony.olech@elandigitalsystems.com>
      Cc: "Robert P. J. Day" <rpjday@crashcourse.ca>
      Cc: Max Vozeler <mvz@vozeler.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: Rodolfo Giometti <giometti@linux.it>
      Cc: Mike Frysinger <vapier@gentoo.org>
      Cc: Anton Vorontsov <avorontsov@mvista.com>
      Cc: Sebastian Siewior <bigeasy@linutronix.de>
      Cc: Lothar Wassmann <LW@KARO-electronics.de>
      Cc: Olav Kongas <ok@artecdesign.ee>
      Cc: Martin Fuzzey <mfuzzey@gmail.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: David Brownell <dbrownell@users.sourceforge.net>
      da13051c
    • Sarah Sharp's avatar
      xhci: Remove old no-op test. · 0b8ca72a
      Sarah Sharp authored
      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: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      0b8ca72a
    • Sarah Sharp's avatar
      usb: Always return 0 or -EBUSY to the runtime PM core. · db7c7c0a
      Sarah Sharp authored
      The PM core reacts badly when the return code from usb_runtime_suspend()
      is not 0, -EAGAIN, or -EBUSY.  The PM core regards this as a fatal error,
      and refuses to run anymore PM helper functions.  In particular,
      usbfs_open() and other usbfs functions will fail because the PM core will
      return an error code when usb_autoresume_device() is called.  This causes
      libusb and/or lsusb to either hang or segfault.
      
      If a USB device cannot suspend for some reason (e.g. a hub doesn't report
      it has remote wakeup capabilities), we still want lsusb and other
      userspace programs to work.  So return -EBUSY, which will fill people's
      log files with failed tries, but will ensure userspace still works.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      db7c7c0a
  2. 11 Mar, 2011 1 commit