1. 19 5月, 2012 2 次提交
    • S
      xhci: Add infrastructure for host-specific LPM policies. · 3b3db026
      Sarah Sharp 提交于
      The choice of U1 and U2 timeouts for USB 3.0 Link Power Management (LPM)
      is highly host controller specific.  Here are a few examples of why it's
      host specific:
      
       1. Setting the U1/U2 timeout too short may cause the link to go into
          U1/U2 in between service intervals, which some hosts may tolerate,
          and some may not.
      
       2. The host controller has to modify its bus schedule in order to take
          into account the Maximum Exit Latency (MEL) to bring all the links
          from the host to the device into U0.  If the MEL is too big, and it
          takes too long to bring the links into an active state, the host
          controller may not be able to service periodic endpoints in time.
      
       3. Host controllers may also have scheduling limitations that force
          them to disable U1 or U2 if a USB device is behind too many tiers of
          hubs.
      
      We could take an educated guess at what U1/U2 timeouts may work for a
      particular host controller.  However, that would result in a binary
      search on every new configuration or alt setting installation, with
      multiple failed Evaluate Context commands.  Worse, the host may blindly
      accept the timeouts and just fail to update its schedule for U1/U2 exit
      latencies, which could result in randomly delayed periodic transfers.
      
      Since we don't want to cause jitter in periodic transfers, or delay
      config/alt setting changes too much, lay down a framework that xHCI
      vendors can extend in order to add their own U1/U2 timeout policies.
      
      To extend the framework, they will need to:
      
       - Modify the PCI init code to add a new xhci->quirk for their host, and
         set the XHCI_LPM_SUPPORT quirk flag.
       - Add their own vendor-specific hooks, like the ones that will be added
         in xhci_call_host_update_timeout_for_endpoint() and
         xhci_check_tier_policy()
       - Make the LPM enable/disable methods call those functions based on the
         xhci->quirk for their host.
      
      An example will be provided for the Intel xHCI host controller in the
      next patch.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      3b3db026
    • S
      xhci: Some Evaluate Context commands must succeed. · 4b266541
      Sarah Sharp 提交于
      The upcoming USB 3.0 Link PM patches will introduce new API to enable
      and disable low-power link states.  We must be able to disable LPM in
      order to reset a device, or place the device into U3 (device suspend).
      Therefore, we need to make sure the Evaluate Context command to disable
      the LPM timeouts can't fail due to there being no room on the command
      ring.
      
      Introduce a new flag to the function that queues the Evaluate Context
      command, command_must_succeed.  This tells the ring handler that a TRB
      has already been reserved for the command (by incrementing
      xhci->cmd_ring_reserved_trbs), and basically ensures that prepare_ring()
      won't fail.  A similar flag was already implemented for the Configure
      Endpoint command queuing function.
      
      All functions that currently call xhci_configure_endpoint() to issue an
      Evaluate Context command pass "false" for the "must_succeed" parameter,
      so this patch should have no effect on current xHCI driver behavior.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      4b266541
  2. 08 5月, 2012 1 次提交
  3. 04 5月, 2012 1 次提交
    • A
      xHCI: keep track of ports being resumed and indicate in hub_status_data · f370b996
      Andiry Xu 提交于
      This commit adds a bit-array to xhci bus_state for keeping track of
      which ports are undergoing a resume transition. If any of the bits
      are set when xhci_hub_status_data() is called, the routine will return
      a non-zero value even if no ports have any status changes pending.
      This will allow usbcore to handle races between root-hub suspend and
      port wakeup.
      
      This patch should be backported to kernels as old as 3.4, that contain
      the commit 879d38e6 "USB: fix race
      between root-hub suspend and remote wakeup".
      Signed-off-by: NAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: stable@vger.kernel.org
      f370b996
  4. 11 4月, 2012 3 次提交
    • S
      xhci: Fix register save/restore order. · c7713e73
      Sarah Sharp 提交于
      The xHCI 1.0 spec errata released on June 13, 2011, changes the ordering
      that the xHCI registers are saved and restored in.  It moves the
      interrupt pending (IMAN) and interrupt control (IMOD) registers to be
      saved and restored last.  I believe that's because the host controller
      may attempt to fetch the event ring table when interrupts are
      re-enabled.  Therefore we need to restore the event ring registers
      before we re-enable interrupts.
      
      This should be backported to kernels as old as 2.6.37, that contain the
      commit 5535b1d5 "USB: xHCI: PCI power
      management implementation"
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NElric Fu <elricfu1@gmail.com>
      Cc: Andiry Xu <andiry.xu@amd.com>
      Cc: stable@vger.kernel.org
      c7713e73
    • S
      xhci: Restore event ring dequeue pointer on resume. · fb3d85bc
      Sarah Sharp 提交于
      The xhci_save_registers() function saved the event ring dequeue pointer
      in the s3 register structure, but xhci_restore_registers() never
      restored it.  No other code in the xHCI successful resume path would
      ever restore it either.  Fix that.
      
      This should be backported to kernels as old as 2.6.37, that contain the
      commit 5535b1d5 "USB: xHCI: PCI power
      management implementation".
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NElric Fu <elricfu1@gmail.com>
      Cc: Andiry Xu <andiry.xu@amd.com>
      Cc: stable@vger.kernel.org
      fb3d85bc
    • S
      xhci: Warn when hosts don't halt. · 5af98bb0
      Sarah Sharp 提交于
      Eric Fu reports a problem with his VIA host controller fetching a zeroed
      event ring pointer on resume from suspend.  The host should have been
      halted, but we can't be sure because that code ignores the return value
      from xhci_halt().  Print a warning when the host controller refuses to
      halt within XHCI_MAX_HALT_USEC (currently 16 seconds).
      
      (Update: it turns out that the VIA host controller is reporting a halted
      state when it fetches the zeroed event ring pointer.  However, we still
      need this warning for other host controllers.)
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      5af98bb0
  5. 14 3月, 2012 3 次提交
  6. 13 3月, 2012 1 次提交
  7. 02 3月, 2012 1 次提交
  8. 15 2月, 2012 1 次提交
    • S
      USB: Don't fail USB3 probe on missing legacy PCI IRQ. · 68d07f64
      Sarah Sharp 提交于
      Intel has a PCI USB xhci host controller on a new platform. It doesn't
      have a line IRQ definition in BIOS.  The Linux driver refuses to
      initialize this controller, but Windows works well because it only depends
      on MSI.
      
      Actually, Linux also can work for MSI.  This patch avoids the line IRQ
      checking for USB3 HCDs in usb core PCI probe.  It allows the xHCI driver
      to try to enable MSI or MSI-X first.  It will fail the probe if MSI
      enabling failed and there's no legacy PCI IRQ.
      
      This patch should be backported to kernels as old as 2.6.32.
      Signed-off-by: NAlex Shi <alex.shi@intel.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      68d07f64
  9. 05 1月, 2012 2 次提交
    • F
      usb: ch9: fix up MaxStreams helper · 18b7ede5
      Felipe Balbi 提交于
      According to USB 3.0 Specification Table 9-22, if
      bmAttributes [4:0] are set to zero, it means "no
      streams supported", but the way this helper was
      defined on Linux, we will *always* have one stream
      which might cause several problems.
      
      For example on DWC3, we would tell the controller
      endpoint has streams enabled and yet start transfers
      with Stream ID set to 0, which would goof up the host
      side.
      
      While doing that, convert the macro to an inline
      function due to the different checks we now need.
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      18b7ede5
    • H
      xhci: Properly handle COMP_2ND_BW_ERR · 71d85724
      Hans de Goede 提交于
      I encountered a result of COMP_2ND_BW_ERR while improving how the pwc
      webcam driver handles not having the full usb1 bandwidth available to
      itself.
      
      I created the following test setup, a NEC xhci controller with a
      single TT USB 2 hub plugged into it, with a usb keyboard and a pwc webcam
      plugged into the usb2 hub. This caused the following to show up in dmesg
      when trying to stream from the pwc camera at its highest alt setting:
      
      xhci_hcd 0000:01:00.0: ERROR: unexpected command completion code 0x23.
      usb 6-2.1: Not enough bandwidth for altsetting 9
      
      And usb_set_interface returned -EINVAL, which caused my pwc code to not
      do the right thing as it expected -ENOSPC.
      
      This patch makes the xhci driver properly handle COMP_2ND_BW_ERR and makes
      usb_set_interface return -ENOSPC as expected.
      
      This should be backported to stable kernels as old as 2.6.32.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      71d85724
  10. 23 12月, 2011 2 次提交
    • S
      xhci: Be less verbose during URB cancellation. · 79688acf
      Sarah Sharp 提交于
      With devices that can need up to 128 segments (with 64 TRBs per
      segment), we can't afford to print out the entire endpoint ring every
      time an URB is canceled.  Instead, print the offset of the TRB, along
      with device pathname and endpoint number.
      
      Only print DMA addresses, since virtual addresses of internal structures
      are not useful.  Change the cancellation code to be more clear about
      what steps of the cancellation it is in the process of doing (queueing
      the request, handling the stop endpoint command, turning the TDs into
      no-ops, or moving the dequeue pointers).
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      79688acf
    • S
      xhci: Remove warnings about MSI and MSI-X capabilities. · 3b9783b2
      Sarah Sharp 提交于
      xHCI host controllers may not be capable of MSI, but they should be able
      to be used in legacy PCI interrupt mode.  Similarly, some xHCI host
      controllers will have MSI support but not MSI-X support.  Lower the
      dmesg log level from an error to debug.  The message won't appear unless
      CONFIG_USB_XHCI_HCD_DEBUGGING is turned on.
      
      If we need to find out whether the device can support MSI or MSI-X and
      it's not being enabled by the driver, it's easy to ask the user to run
      lspci.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      3b9783b2
  11. 02 12月, 2011 1 次提交
    • A
      xHCI: fix bug in xhci_clear_command_ring() · 158886cd
      Andiry Xu 提交于
      When system enters suspend, xHCI driver clears command ring by writing zero
      to all the TRBs. However, this also writes zero to the Link TRB, and the ring
      is mangled. This may cause driver accesses wrong memory address and the
      result is unpredicted.
      
      When clear the command ring, keep the last Link TRB intact, only clear its
      cycle bit. This should fix the "command ring full" issue reported by Oliver
      Neukum.
      
      This should be backported to stable kernels as old as 2.6.37, since the
      commit 89821320 "xhci: Fix command ring replay after resume" is merged.
      Signed-off-by: NAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: NOliver Neukum <oneukum@suse.de>
      158886cd
  12. 15 11月, 2011 1 次提交
    • A
      USB: XHCI: resume root hubs when the controller resumes · f69e3120
      Alan Stern 提交于
      This patch (as1494) fixes a problem in xhci-hcd's resume routine.
      When the controller is runtime-resumed, this can only mean that one of
      the two root hubs has made a wakeup request and therefore needs to be
      resumed as well.  Rather than try to determine which root hub requires
      attention (which might be difficult in the case where a new
      non-SuperSpeed device has been plugged in), the patch simply resumes
      both root hubs.
      
      Without this change, there is a race: The controller might be put back
      to sleep before it can activate its IRQ line, and the wakeup condition
      might never get handled.
      
      The patch also simplifies the logic in xhci_resume a little, combining
      some repeated flag settings into a single pair of statements.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Sarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable <stable@vger.kernel.org>
      Tested-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f69e3120
  13. 05 11月, 2011 1 次提交
    • S
      xhci: Set slot and ep0 flags for address command. · d31c285b
      Sarah Sharp 提交于
      Matt's AsMedia xHCI host controller was responding with a Context Error
      to an address device command after a configured device reset.  Some
      sequence of events leads both the slot and endpoint zero add flags
      cleared to zero, which the AsMedia host doesn't like:
      
      [  223.701839] xhci_hcd 0000:03:00.0: Slot ID 1 Input Context:
      [  223.701841] xhci_hcd 0000:03:00.0: @ffff880137b25000 (virt) @ffffc000 (dma) 0x000000 - drop flags
      [  223.701843] xhci_hcd 0000:03:00.0: @ffff880137b25004 (virt) @ffffc004 (dma) 0x000000 - add flags
      [  223.701846] xhci_hcd 0000:03:00.0: @ffff880137b25008 (virt) @ffffc008 (dma) 0x000000 - rsvd2[0]
      [  223.701848] xhci_hcd 0000:03:00.0: @ffff880137b2500c (virt) @ffffc00c (dma) 0x000000 - rsvd2[1]
      [  223.701850] xhci_hcd 0000:03:00.0: @ffff880137b25010 (virt) @ffffc010 (dma) 0x000000 - rsvd2[2]
      [  223.701852] xhci_hcd 0000:03:00.0: @ffff880137b25014 (virt) @ffffc014 (dma) 0x000000 - rsvd2[3]
      [  223.701854] xhci_hcd 0000:03:00.0: @ffff880137b25018 (virt) @ffffc018 (dma) 0x000000 - rsvd2[4]
      [  223.701857] xhci_hcd 0000:03:00.0: @ffff880137b2501c (virt) @ffffc01c (dma) 0x000000 - rsvd2[5]
      [  223.701858] xhci_hcd 0000:03:00.0: Slot Context:
      [  223.701860] xhci_hcd 0000:03:00.0: @ffff880137b25020 (virt) @ffffc020 (dma) 0x8400000 - dev_info
      [  223.701862] xhci_hcd 0000:03:00.0: @ffff880137b25024 (virt) @ffffc024 (dma) 0x010000 - dev_info2
      [  223.701864] xhci_hcd 0000:03:00.0: @ffff880137b25028 (virt) @ffffc028 (dma) 0x000000 - tt_info
      [  223.701866] xhci_hcd 0000:03:00.0: @ffff880137b2502c (virt) @ffffc02c (dma) 0x000000 - dev_state
      [  223.701869] xhci_hcd 0000:03:00.0: @ffff880137b25030 (virt) @ffffc030 (dma) 0x000000 - rsvd[0]
      [  223.701871] xhci_hcd 0000:03:00.0: @ffff880137b25034 (virt) @ffffc034 (dma) 0x000000 - rsvd[1]
      [  223.701873] xhci_hcd 0000:03:00.0: @ffff880137b25038 (virt) @ffffc038 (dma) 0x000000 - rsvd[2]
      [  223.701875] xhci_hcd 0000:03:00.0: @ffff880137b2503c (virt) @ffffc03c (dma) 0x000000 - rsvd[3]
      [  223.701877] xhci_hcd 0000:03:00.0: Endpoint 00 Context:
      [  223.701879] xhci_hcd 0000:03:00.0: @ffff880137b25040 (virt) @ffffc040 (dma) 0x000000 - ep_info
      [  223.701881] xhci_hcd 0000:03:00.0: @ffff880137b25044 (virt) @ffffc044 (dma) 0x2000026 - ep_info2
      [  223.701883] xhci_hcd 0000:03:00.0: @ffff880137b25048 (virt) @ffffc048 (dma) 0xffffe8e0 - deq
      [  223.701885] xhci_hcd 0000:03:00.0: @ffff880137b25050 (virt) @ffffc050 (dma) 0x000000 - tx_info
      [  223.701887] xhci_hcd 0000:03:00.0: @ffff880137b25054 (virt) @ffffc054 (dma) 0x000000 - rsvd[0]
      [  223.701889] xhci_hcd 0000:03:00.0: @ffff880137b25058 (virt) @ffffc058 (dma) 0x000000 - rsvd[1]
      [  223.701892] xhci_hcd 0000:03:00.0: @ffff880137b2505c (virt) @ffffc05c (dma) 0x000000 - rsvd[2]
      ...
      [  223.701927] xhci_hcd 0000:03:00.0: // Ding dong!
      [  223.701992] xhci_hcd 0000:03:00.0: Setup ERROR: address device command for slot 1.
      
      The xHCI spec says that both flags must be set to one for the Address
      Device command.  When the device is first enumerated,
      xhci_setup_addressable_virt_dev() does set those flags.  However, when
      the device is addressed after it has been reset in the configured state,
      xhci_setup_addressable_virt_dev() is not called, and
      xhci_copy_ep0_dequeue_into_input_ctx() is called instead.  That function
      relies on the flags being set up by previous commands, which apparently
      isn't a good assumption.
      
      Move the setting of the flags into the common parent function.
      
      This should be queued for stable kernels as old as 2.6.35, since that
      was the first introduction of xhci_copy_ep0_dequeue_into_input_ctx.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NMatt <mdm@iinet.net.au>
      Cc: stable@vger.kernel.org
      d31c285b
  14. 27 9月, 2011 7 次提交
  15. 21 9月, 2011 2 次提交
  16. 10 9月, 2011 8 次提交
    • S
      xhci: Redundant check in xhci_check_args for xhci->devs · 73ddc247
      sifram.rajas@gmail.com 提交于
      The xhci_hcd->devs is an array of pointers rather than pointer to pointer.
      Hence this check is not required.
      
      Signed-off-by: Sifram Rajas <Sifram Rajas sifram.rajas@gmail.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      73ddc247
    • A
      xHCI: refine td allocation · 2ffdea25
      Andiry Xu 提交于
      In xhci_urb_enqueue(), allocate a block of memory for all the TDs instead
      of allocating memory for each of them separately. This reduces the number
      of kzalloc calling when an isochronous usb is submitted.
      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>
      2ffdea25
    • S
      xhci: Implement HS/FS/LS bandwidth checking. · c29eea62
      Sarah Sharp 提交于
      Now that we have a bandwidth interval table per root port or TT that
      describes the endpoint bandwidth information, we can finally use it to
      check whether the bus bandwidth is oversubscribed for a new device
      configuration/alternate interface setting.
      
      The complication for this algorithm is that the bit of hardware logic that
      creates the bus schedule is only 12-bit logic.  In order to make sure it
      can represent the maximum bus bandwidth in 12 bits, it has to convert the
      endpoint max packet size and max esit payload into "blocks" (basically a
      less-precise representation).  The block size for each speed of device is
      different, aside from low speed and full speed.  In order to make sure we
      don't allow a setup where the scheduler might fail, we also have to do the
      bandwidth checking in blocks.
      
      After checking that the endpoints fit in the schedule, we store the
      bandwidth used for this root port or TT.  If this is a FS/LS device under
      an external HS hub, we also update the TT bandwidth and the root port
      bandwidth (if this is a newly activated or deactivated TT).
      
      I won't go into the details of the algorithm, as it's pretty well
      documented in the comments.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      c29eea62
    • S
      xhci: Track interval bandwidth tables per port/TT. · 2e27980e
      Sarah Sharp 提交于
      In order to update the root port or TT's bandwidth interval table, we will
      need to keep track of a list of endpoints, per interval.  That way we can
      easily know the new largest max packet size when we have to remove an
      endpoint.
      
      Add an endpoint list for each root port or TT structure, sorted by
      endpoint max packet size.  Insert new endpoints into the list such that
      the head of the list always has the endpoint with the greatest max packet
      size.  Only insert endpoints and update the interval table with new
      information when those endpoints are periodic.
      
      Make sure to update the number of active TTs when we add or drop periodic
      endpoints.  A TT is only considered active if it has one or more periodic
      endpoints attached (control and bulk are best effort, and counted in the
      20% reserved on the high speed bus).  If the number of active endpoints
      for a TT was zero, and it's now non-zero, increment the number of active
      TTs for the rootport.  If the number of active endpoints was non-zero, and
      it's now zero, decrement the number of active TTs.
      
      We have to be careful when we're checking the bandwidth for a new
      configuration/alt setting.  If we don't have enough bandwidth, we need to
      be able to "roll back" the bandwidth information stored in the endpoint
      and the root port/TT interval bandwidth table.  We can't just create a
      copy of the interval bandwidth table, modify it, and check the bandwidth
      with the copy because we have lists of endpoints and entries can't be on
      more than one list.  Instead, we copy the old endpoint bandwidth
      information, and use it to revert the interval table when the bandwidth
      check fails.
      
      We don't check the bandwidth after endpoints are dropped from the interval
      table when a device is reset or freed after a disconnect, because having
      endpoints use less bandwidth should not push the bandwidth usage over the
      limits.  Besides which, we can't fail a device disconnect.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2e27980e
    • S
      xhci: Store endpoint bandwidth information. · 9af5d71d
      Sarah Sharp 提交于
      In the upcoming patches, we'll use some stored endpoint information to
      make software keep track of the worst-case bandwidth schedule.  We need to
      store several variables associated with each periodic endpoint:
       - the type of endpoint
       - Max Packet Size
       - Mult
       - Max ESIT payload
       - Max Burst Size (aka number of packets, stored in one-based form)
       - the endpoint interval (normalized to powers of 2 microframes)
      
      All this information is available to the hardware, and stored in its
      device output context.  However, we need to ensure that the new
      information is stored before the xHCI driver drops the xhci->lock to wait
      on the Configure Endpoint command, so that another driver requesting a
      configuration or alt setting change will see the update.  The Configure
      Endpoint command will never fail on the hardware that needs this software
      bandwidth checking (assuming the slot is enabled and the flags are set
      properly), so updating the endpoint info before the command completes
      should be fine.
      
      Until we add in the bandwidth checking code, just update the endpoint
      information after the Configure Endpoint command completes, and after a
      Reset Device command completes.  Don't bother to clear the endpoint
      bandwidth info when a device is being freed, since the xhci_virt_ep is
      just going to be freed anyway.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9af5d71d
    • S
      xhci: Store information about roothubs and TTs. · 839c817c
      Sarah Sharp 提交于
      For upcoming patches, we need to keep information about the bandwidth
      domains under the xHCI host.  Each root port is a separate primary
      bandwidth domain, and each high speed hub's TT (and potentially each port
      on a multi-TT hub) is a secondary bandwidth domain.
      
      If the table were in text form, it would look a bit like this:
      
      EP Interval	Sum of Number	Largest Max	Max Packet
      		of Packets	Packet Size	Overhead
      	0	   N		   mps		  overhead
      ...
      	15	   N		   mps		  overhead
      
      Overhead is the maximum packet overhead (for bit stuffing, CRC, protocol
      overhead, etc) for all the endpoints in this interval.  Devices with
      different speeds have different max packet overhead.  For example, if
      there is a low speed and a full speed endpoint that both have an interval
      of 3, we would use the higher overhead (the low speed overhead).  Interval
      0 is a bit special, since we really just want to know the sum of the max
      ESIT payloads instead of the largest max packet size.  That's stored in
      the interval0_esit_payload variable.  For root ports, we also need to keep
      track of the number of active TTs.
      
      For each root port, and each TT under a root port, store some information
      about the bandwidth consumption.  Dynamically allocate an array of root
      port bandwidth information for the number of root ports on the xHCI host.
      Each root port stores a list of TTs under the root port.  A single TT hub
      only has one entry in the list, but a multi-TT hub will have an entry per
      port.
      
      When the USB core says that a USB device is a hub, create one or more
      entries in the root port TT list for the hub.  When a device is deleted,
      and it is a hub, search through the root port TT list and delete all
      TT entries for the hub.  Keep track of which TT entry is associated with a
      device under a TT.
      
      LS/FS devices attached directly to the root port will have usb_device->tt
      set to the roothub.  Ignore that, and treat it like a primary bandwidth
      domain, since there isn't really a high speed bus between the roothub and
      the host.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      839c817c
    • S
      xhci: Refactor endpoint limit checking. · 750645f8
      Sarah Sharp 提交于
      Move the code to check whether we've reached the host controller's limit
      on the number of endpoints out of the two conditional statements, to
      remove duplicate code.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      750645f8
    • S
      xhci: If no endpoints changed, don't issue BW command. · 2dc37539
      Sarah Sharp 提交于
      Some alternate interface settings have no endpoints associated with them.
      This shows up in some USB webcams, particularly the Logitech HD 1080p,
      which uses the uvcvideo driver.  If a driver switches between two alt
      settings with no endpoints, there is no need to issue a configure endpoint
      command, because there is no endpoint information to update.
      
      The only time a configure endpoint command with just the add slot flag set
      makes sense is when the driver is updating hub characteristics in the slot
      context.  However, that code never calls xhci_check_bandwidth, so we
      should be safe not issuing a command if only the slot context add flag is
      set.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2dc37539
  17. 24 8月, 2011 1 次提交
    • K
      USB: use usb_endpoint_maxp() instead of le16_to_cpu() · 29cc8897
      Kuninori Morimoto 提交于
      Now ${LINUX}/drivers/usb/* can use usb_endpoint_maxp(desc) to get maximum packet size
      instead of le16_to_cpu(desc->wMaxPacketSize).
      This patch fix it up
      
      Cc: Armin Fuerst <fuerst@in.tum.de>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Johannes Erdfelt <johannes@erdfelt.com>
      Cc: Vojtech Pavlik <vojtech@suse.cz>
      Cc: Oliver Neukum <oliver@neukum.name>
      Cc: David Kubicek <dave@awk.cz>
      Cc: Johan Hovold <jhovold@gmail.com>
      Cc: Brad Hards <bhards@bigpond.net.au>
      Acked-by: NFelipe Balbi <balbi@ti.com>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Thomas Dahlmann <dahlmann.thomas@arcor.de>
      Cc: David Brownell <david-b@pacbell.net>
      Cc: David Lopo <dlopo@chipidea.mips.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Michal Nazarewicz <m.nazarewicz@samsung.com>
      Cc: Xie Xiaobo <X.Xie@freescale.com>
      Cc: Li Yang <leoli@freescale.com>
      Cc: Jiang Bo <tanya.jiang@freescale.com>
      Cc: Yuan-hsin Chen <yhchen@faraday-tech.com>
      Cc: Darius Augulis <augulis.darius@gmail.com>
      Cc: Xiaochen Shen <xiaochen.shen@intel.com>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: OKI SEMICONDUCTOR, <toshiharu-linux@dsn.okisemi.com>
      Cc: Robert Jarzmik <robert.jarzmik@free.fr>
      Cc: Ben Dooks <ben@simtec.co.uk>
      Cc: Thomas Abraham <thomas.ab@samsung.com>
      Cc: Herbert Pötzl <herbert@13thfloor.at>
      Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
      Cc: Roman Weissgaerber <weissg@vienna.at>
      Acked-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Tony Olech <tony.olech@elandigitalsystems.com>
      Cc: Florian Floe Echtler <echtler@fs.tum.de>
      Cc: Christian Lucht <lucht@codemercs.com>
      Cc: Juergen Stuber <starblue@sourceforge.net>
      Cc: Georges Toth <g.toth@e-biz.lu>
      Cc: Bill Ryder <bryder@sgi.com>
      Cc: Kuba Ober <kuba@mareimbrium.org>
      Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      29cc8897
  18. 10 8月, 2011 2 次提交
    • S
      xhci: Remove TDs from TD lists when URBs are canceled. · 585df1d9
      Sarah Sharp 提交于
      When a driver tries to cancel an URB, and the host controller is dying,
      xhci_urb_dequeue will giveback the URB without removing the xhci_tds
      that comprise that URB from the td_list or the cancelled_td_list.  This
      can cause a race condition between the driver calling URB dequeue and
      the stop endpoint command watchdog timer.
      
      If the timer fires on a dying host, and a driver attempts to resubmit
      while the watchdog timer has dropped the xhci->lock to giveback a
      cancelled URB, URBs may be given back by the xhci_urb_dequeue() function.
      At that point, the URB's priv pointer will be freed and set to NULL, but
      the TDs will remain on the td_list.  This will cause an oops in
      xhci_giveback_urb_in_irq() when the watchdog timer attempts to loop
      through the endpoints' td_lists, giving back killed URBs.
      
      Make sure that xhci_urb_dequeue() removes TDs from the TD lists and
      canceled TD lists before it gives back the URB.
      
      This patch should be backported to kernels as old as 2.6.36.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Andiry Xu <andiry.xu@amd.com>
      Cc: stable@kernel.org
      585df1d9
    • S
      xhci: Fix memory leak during failed enqueue. · d13565c1
      Sarah Sharp 提交于
      When the isochronous transfer support was introduced, and the xHCI driver
      switched to using urb->hcpriv to store an "urb_priv" pointer, a couple of
      memory leaks were introduced into the URB enqueue function in its error
      handling paths.
      
      xhci_urb_enqueue allocates urb_priv, but it doesn't free it if changing
      the control endpoint's max packet size fails or the bulk endpoint is in
      the middle of allocating or deallocating streams.
      
      xhci_urb_enqueue also doesn't free urb_priv if any of the four endpoint
      types' enqueue functions fail.  Instead, it expects those functions to
      free urb_priv if an error occurs.  However, the bulk, control, and
      interrupt enqueue functions do not free urb_priv if the endpoint ring is
      NULL.  It will, however, get freed if prepare_transfer() fails in those
      enqueue functions.
      
      Several of the error paths in the isochronous endpoint enqueue function
      also fail to free it.  xhci_queue_isoc_tx_prepare() doesn't free urb_priv
      if prepare_ring() indicates there is not enough room for all the
      isochronous TDs in this URB.  If individual isochronous TDs fail to be
      queued (perhaps due to an endpoint state change), urb_priv is also leaked.
      
      This argues that the freeing of urb_priv should be done in the function
      that allocated it, xhci_urb_enqueue.
      
      This patch looks rather ugly, but refactoring the code will have to wait
      because this patch needs to be backported to stable kernels.
      
      This patch should be backported to kernels as old as 2.6.36.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Andiry Xu <andiry.xu@amd.com>
      Cc: stable@kernel.org
      d13565c1