1. 16 3月, 2013 1 次提交
  2. 04 1月, 2013 1 次提交
    • S
      xhci: Avoid "dead ports", add roothub port polling. · c52804a4
      Sarah Sharp 提交于
      The USB core hub thread (khubd) is designed with external USB hubs in
      mind.  It expects that if a port status change bit is set, the hub will
      continue to send a notification through the hub status data transfer.
      Basically, it expects hub notifications to be level-triggered.
      
      The xHCI host controller is designed to be edge-triggered on the logical
      'OR' of all the port status change bits.  When all port status change
      bits are clear, and a new change bit is set, the xHC will generate a
      Port Status Change Event.  If another change bit is set in the same port
      status register before the first bit is cleared, it will not send
      another event.
      
      This means that the hub code may lose port status changes because of
      race conditions between clearing change bits.  The user sees this as a
      "dead port" that doesn't react to device connects.
      
      The fix is to turn on port polling whenever a new change bit is set.
      Once the USB core issues a hub status request that shows that no change
      bits are set in any USB ports, turn off port polling.
      
      We can't allow the USB core to poll the roothub for port events during
      host suspend because if the PCI host is in D3cold, the port registers
      will be all f's.  Instead, stop the port polling timer, and
      unconditionally restart it when the host resumes.  If there are no port
      change bits set after the resume, the first call to hub_status_data will
      disable polling.
      
      This patch should be backported to stable kernels with the first xHCI
      support, 2.6.31 and newer, that include the commit
      0f2a7930 "USB: xhci: Root hub support."
      There will be merge conflicts because the check for HC_STATE_SUSPENDED
      was moved into xhci_suspend in 3.8.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable@vger.kernel.org
      c52804a4
  3. 13 11月, 2012 4 次提交
  4. 26 10月, 2012 2 次提交
  5. 24 10月, 2012 2 次提交
  6. 18 10月, 2012 1 次提交
  7. 25 9月, 2012 2 次提交
  8. 14 9月, 2012 4 次提交
    • F
      usb: host: xhci: sparse fixes · ed384bd3
      Felipe Balbi 提交于
      drivers/usb/host/xhci.c:1826:14: warning: symbol 'xhci_get_block_size' was not declared. Should it be static?
      drivers/usb/host/xhci.c:1844:14: warning: symbol 'xhci_get_largest_overhead' was not declared. Should it be static?
      drivers/usb/host/xhci-ring.c:2304:36: warning: context imbalance in 'handle_tx_event' - unexpected unlock
      drivers/usb/host/xhci-hub.c:425:6: warning: symbol 'xhci_set_remote_wake_mask' was not declared. Should it be static?
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      ed384bd3
    • E
      xHCI: cancel command after command timeout · 6e4468b9
      Elric Fu 提交于
      The patch is used to cancel command when the command isn't
      acknowledged and a timeout occurs.
      
      This patch should be backported to kernels as old as 3.0, that contain
      the commit 7ed603ec "xhci: Add an
      assertion to check for virt_dev=0 bug." That commit papers over a NULL
      pointer dereference, and this patch fixes the underlying issue that
      caused the NULL pointer dereference.
      Signed-off-by: NElric Fu <elricfu1@gmail.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NMiroslav Sabljic <miroslav.sabljic@avl.com>
      Cc: stable@vger.kernel.org
      6e4468b9
    • E
      xHCI: add aborting command ring function · b92cc66c
      Elric Fu 提交于
      Software have to abort command ring and cancel command
      when a command is failed or hang. Otherwise, the command
      ring will hang up and can't handle the others. An example
      of a command that may hang is the Address Device Command,
      because waiting for a SET_ADDRESS request to be acknowledged
      by a USB device is outside of the xHC's ability to control.
      
      To cancel a command, software will initialize a command
      descriptor for the cancel command, and add it into a
      cancel_cmd_list of xhci.
      
      Sarah: Fixed missing newline on "Have the command ring been stopped?"
      debugging statement.
      
      This patch should be backported to kernels as old as 3.0, that contain
      the commit 7ed603ec "xhci: Add an
      assertion to check for virt_dev=0 bug." That commit papers over a NULL
      pointer dereference, and this patch fixes the underlying issue that
      caused the NULL pointer dereference.
      Signed-off-by: NElric Fu <elricfu1@gmail.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NMiroslav Sabljic <miroslav.sabljic@avl.com>
      Cc: stable@vger.kernel.org
      b92cc66c
    • E
      xHCI: add cmd_ring_state · c181bc5b
      Elric Fu 提交于
      Adding cmd_ring_state for command ring. It helps to verify
      the current command ring state for controlling the command
      ring operations.
      
      This patch should be backported to kernels as old as 3.0.  The commit
      7ed603ec "xhci: Add an assertion to
      check for virt_dev=0 bug." papers over the NULL pointer dereference that
      I now believe is related to a timed out Set Address command.  This (and
      the four patches that follow it) contain the real fix that also allows
      VIA USB 3.0 hubs to consistently re-enumerate during the plug/unplug
      stress tests.
      Signed-off-by: NElric Fu <elricfu1@gmail.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NMiroslav Sabljic <miroslav.sabljic@avl.com>
      Cc: stable@vger.kernel.org
      c181bc5b
  9. 06 9月, 2012 2 次提交
    • A
      usb: host: xhci: Fix Compliance Mode on SN65LVPE502CP Hardware · 71c731a2
      Alexis R. Cortes 提交于
      This patch is intended to work around a known issue on the
      SN65LVPE502CP USB3.0 re-driver that can delay the negotiation
      between a device and the host past the usual handshake timeout.
      
      If that happens on the first insertion, the host controller
      port will enter in Compliance Mode and NO port status event will
      be generated (as per xHCI Spec) making impossible to detect this
      event by software. The port will remain in compliance mode until
      a warm reset is applied to it.
      
      As a result of this, the port will seem "dead" to the user and no
      device connections or disconnections will be detected.
      
      For solving this, the patch creates a timer which polls every 2
      seconds the link state of each host controller's port (this
      by reading the PORTSC register) and recovers the port by issuing a
      Warm reset every time Compliance mode is detected.
      
      If a xHC USB3.0 port has previously entered to U0, the compliance
      mode issue will NOT occur only until system resumes from
      sleep/hibernate, therefore, the compliance mode timer is stopped
      when all xHC USB 3.0 ports have entered U0. The timer is initialized
      again after each system resume.
      
      Since the issue is being caused by a piece of hardware, the timer
      will be enabled ONLY on those systems that have the SN65LVPE502CP
      installed (this patch uses DMI strings for detecting those systems)
      therefore making this patch to act as a quirk (XHCI_COMP_MODE_QUIRK
      has been added to the xhci stack).
      
      This patch applies for these systems:
      Vendor: Hewlett-Packard. System Models: Z420, Z620 and Z820.
      
      This patch should be backported to kernels as old as 3.2, as that was
      the first kernel to support warm reset.  The kernels will need to
      contain both commit 10d674a8 "USB: When
      hot reset for USB3 fails, try warm reset" and commit
      8bea2bd3 "usb: Add support for root hub
      port status CAS".  The first patch add warm reset support, and the
      second patch modifies the USB core to issue a warm reset when the port
      is in compliance mode.
      Signed-off-by: NAlexis R. Cortes <alexis.cortes@ti.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      71c731a2
    • D
      xhci: Fix a logical vs bitwise AND bug · 052c7f9f
      Dan Carpenter 提交于
      The intent was to test whether the flag was set.
      
      This patch should be backported to stable kernels as old as 3.0, since
      it fixes a bug in commit e95829f4 "xhci:
      Switch PPT ports to EHCI on shutdown.", which was marked for stable.
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      052c7f9f
  10. 10 8月, 2012 1 次提交
    • S
      xhci: Switch PPT ports to EHCI on shutdown. · e95829f4
      Sarah Sharp 提交于
      The Intel desktop boards DH77EB and DH77DF have a hardware issue that
      can be worked around by BIOS.  If the USB ports are switched to xHCI on
      shutdown, the xHCI host will send a spurious interrupt, which will wake
      the system.  Some BIOS will work around this, but not all.
      
      The bug can be avoided if the USB ports are switched back to EHCI on
      shutdown.  The Intel Windows driver switches the ports back to EHCI, so
      change the Linux xHCI driver to do the same.
      
      Unfortunately, we can't tell the two effected boards apart from other
      working motherboards, because the vendors will change the DMI strings
      for the DH77EB and DH77DF boards to their own custom names.  One example
      is Compulab's mini-desktop, the Intense-PC.  Instead, key off the
      Panther Point xHCI host PCI vendor and device ID, and switch the ports
      over for all PPT xHCI hosts.
      
      The only impact this will have on non-effected boards is to add a couple
      hundred milliseconds delay on boot when the BIOS has to switch the ports
      over from EHCI to xHCI.
      
      This patch should be backported to kernels as old as 3.0, that contain
      the commit 69e848c2 "Intel xhci: Support
      EHCI/xHCI port switching."
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: NDenis Turischev <denis@compulab.co.il>
      Tested-by: NDenis Turischev <denis@compulab.co.il>
      Cc: stable@vger.kernel.org
      e95829f4
  11. 08 8月, 2012 1 次提交
  12. 07 7月, 2012 1 次提交
    • H
      usbdevfs: Add a USBDEVFS_GET_CAPABILITIES ioctl · 19181bc5
      Hans de Goede 提交于
      There are a few (new) usbdevfs capabilities which an application cannot
      discover in any other way then checking the kernel version. There are 3
      problems with this:
      1) It is just not very pretty.
      2) Given the tendency of enterprise distros to backport stuff it is not
      reliable.
      3) As discussed in length on the mailinglist, USBDEVFS_URB_BULK_CONTINUATION
      does not work as it should when combined with USBDEVFS_URB_SHORT_NOT_OK
      (which is its intended use) on devices attached to an XHCI controller.
      So the availability of these features can be host controller dependent,
      making depending on them based on the kernel version not a good idea.
      
      This patch besides adding the new ioctl also adds flags for the following
      existing capabilities:
      
      USBDEVFS_CAP_ZERO_PACKET,        available since 2.6.31
      USBDEVFS_CAP_BULK_CONTINUATION,  available since 2.6.32, except for XHCI
      USBDEVFS_CAP_NO_PACKET_SIZE_LIM, available since 3.3
      
      Note that this patch only does not advertise the USBDEVFS_URB_BULK_CONTINUATION
      cap for XHCI controllers, bulk transfers with this flag set will still be
      accepted when submitted to XHCI controllers.
      
      Returning -EINVAL for them would break existing apps, and in most cases the
      troublesome scenario wrt USBDEVFS_URB_SHORT_NOT_OK urbs on XHCI controllers
      will never get hit, so this would break working use cases.
      
      The disadvantage of not returning -EINVAL is that cases were it is causing
      real trouble may go undetected / the cause of the trouble may be unclear,
      but this is the best we can do.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      19181bc5
  13. 14 6月, 2012 2 次提交
    • A
      xHCI: Increase the timeout for controller save/restore state operation · 622eb783
      Andiry Xu 提交于
      When system software decides to power down the xHC with the intent of
      resuming operation at a later time, it will ask xHC to save the internal
      state and restore it when resume to correctly recover from a power event.
      Two bits are used to enable this operation: Save State and Restore State.
      
      xHCI spec 4.23.2 says software should "Set the Controller Save/Restore
      State flag in the USBCMD register and wait for the Save/Restore State
      Status flag in the USBSTS register to transition to '0'". However, it does
      not define how long software should wait for the SSS/RSS bit to transition
      to 0.
      
      Currently the timeout is set to 1ms. There is bug report
      (https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1002697)
      indicates that the timeout is too short for ASMedia ASM1042 host controller
      to save/restore the state successfully. Increase the timeout to 10ms helps to
      resolve the issue.
      
      This patch should be backported to stable kernels as old as 2.6.37, that
      contain the commit 5535b1d5 "USB: xHCI:
      PCI power management implementation"
      Signed-off-by: NAndiry Xu <andiry.xu@gmail.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Ming Lei <ming.lei@canonical.com>
      Cc: stable@vger.kernel.org
      622eb783
    • S
      xhci: Fix error path return value. · e25e62ae
      Sarah Sharp 提交于
      This patch fixes an issue discovered by Dan Carpenter:
      
      The patch 3b3db026: "xhci: Add infrastructure for host-specific
      LPM policies." from May 9, 2012, leads to the following warning:
      drivers/usb/host/xhci.c:3909 xhci_get_timeout_no_hub_lpm()
               warn: signedness bug returning '-22'
      
        3906          default:
        3907                  dev_warn(&udev->dev, "%s: Can't get timeout for non-U1 or U2 state.\n",
        3908                                  __func__);
        3909                  return -EINVAL;
                              ^^^^^^^^^^^^^^
      This should be a u16 like USB3_LPM_DISABLED or something.
      
        3910          }
        3911
        3912          if (sel <= max_sel_pel && pel <= max_sel_pel)
        3913                  return USB3_LPM_DEVICE_INITIATED;
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      e25e62ae
  14. 22 5月, 2012 2 次提交
    • S
      xhci: Fix DIV_ROUND_UP compile error. · c88db160
      Sarah Sharp 提交于
      Fengguang reports that the xHCI driver isn't linked properly on his
      machine:
      
      ERROR: "__udivdi3" [drivers/usb/host/xhci-hcd.ko] undefined!
      ERROR: "handle_edge_irq" [drivers/gpio/gpio-pch.ko] undefined!
      ERROR: "irq_to_desc" [drivers/gpio/gpio-pch.ko] undefined!
      
      The driver compiles fine on my 64-bit box (gcc version 4.6.1).
      Fengguang thinks it's because the xHCI driver was using DIV_ROUND_UP()
      instead of DIV_ROUND_UP_ULL() with arguments that were unsigned long
      long variables.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: NWu Fengguang <wfg@linux.intel.com>
      c88db160
    • S
      xhci: Fix compile with CONFIG_USB_SUSPEND=n · b01bcbf7
      Sarah Sharp 提交于
      The USB 2.0 Link PM code is conditionally compiled when
      CONFIG_USB_SUSPEND=y.  I believe that's a mistake, since Link PM is not
      directly related to USB device suspend and Link PM is implemented
      without relying on any of the suspend code in the USB core.  For now,
      keep the USB 2.0 Link PM code conditionally compiled if
      CONFIG_USB_SUSPEND=y.
      
      This patch does move the code to implement USB 3.0 Link PM out of the
      xHCI driver #ifdefs for CONFIG_USB_SUSPEND and moves it into a section
      dependent on CONFIG_PM.  The USB core functions for USB 3.0 Link PM are
      already conditionally compiled when CONFIG_PM=y.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      b01bcbf7
  15. 19 5月, 2012 3 次提交
    • S
      xhci: Add Intel U1/U2 timeout policy. · e3567d2c
      Sarah Sharp 提交于
      All Intel xHCI host controllers support USB 3.0 Link Power Management.
      
      The Panther Point xHCI host controller needs the xHCI driver to
      calculate the U1 and U2 timeout values, because it will blindly accept a
      MEL that would cause scheduling issues.
      
      The Lynx Point xHCI host controller will reject MEL values that are too
      high, but internally it implements the same algorithm that is needed for
      Panther Point xHCI.
      
      Simplify the code paths by just having the xHCI driver calculate what
      the U1/U2 timeouts should be.  Comments on the policy are in the code.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      e3567d2c
    • 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
  16. 08 5月, 2012 1 次提交
  17. 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
  18. 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
  19. 14 3月, 2012 3 次提交
  20. 13 3月, 2012 1 次提交
  21. 02 3月, 2012 1 次提交
  22. 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