1. 02 6月, 2016 1 次提交
    • A
      USB: EHCI: avoid undefined pointer arithmetic and placate UBSAN · 85e3990b
      Alan Stern 提交于
      Several people have reported that UBSAN doesn't like the pointer
      arithmetic in ehci_hub_control():
      
      	u32 __iomem	*status_reg = &ehci->regs->port_status[
      				(wIndex & 0xff) - 1];
      	u32 __iomem	*hostpc_reg = &ehci->regs->hostpc[(wIndex & 0xff) - 1];
      
      If wIndex is 0 (and it often is), these calculations underflow and
      UBSAN complains.
      
      According to the C standard, pointer computations leading to locations
      outside the bounds of an array object (other than 1 position past the
      end) are undefined.  In this case, the compiler would be justified in
      concluding the wIndex can never be 0 and then optimizing away the
      tests for !wIndex that occur later in the subroutine.  (Although,
      since ehci->regs->port_status and ehci->regs->hostpc are both 0-length
      arrays and are thus GCC extensions to the C standard, it's not clear
      what the compiler is really allowed to do.)
      
      At any rate, we can avoid all these difficulties, at the cost of
      making the code slightly longer, by not decrementing the index when it
      is equal to 0.  The runtime effect is minimal, and anyway
      ehci_hub_control() is not on a hot path.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NValdis Kletnieks <Valdis.Kletnieks@vt.edu>
      Reported-by: NMeelis Roos <mroos@linux.ee>
      Reported-by: NMartin_MOKREJÅ <mmokrejs@gmail.com>
      Reported-by: N"Navin P.S" <navinp1912@gmail.com>
      CC: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      85e3990b
  2. 05 2月, 2016 1 次提交
  3. 04 2月, 2016 2 次提交
    • A
      USB: EHCI: improvements to unlink_empty_async_suspended() · 8df0d77d
      Alan Stern 提交于
      unlink_empty_async_suspended() is marked __maybe_unused.  This is
      because its caller, ehci_bus_suspend(), is protected by "#ifdef
      CONFIG_PM".  We should use the same protection here instead of
      __maybe_unused.
      
      unlink_empty_async_suspended() gets called only when the root hub is
      suspended.  It's silly for it to call start_iaa_cycle() at such a
      time; the IAA mechanism doesn't work when the root hub isn't running.
      It should call end_unlink_async() instead.  But even this isn't
      necessary, since there already is a call to end_iaa_cycle() right
      before the call to unlink_empty_async_suspended().  All we have to do
      is interchange the two subroutine calls.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8df0d77d
    • A
      USB: EHCI: improve handling of the ehci->iaa_in_progress flag · f96fba0d
      Alan Stern 提交于
      This patch improves the way ehci-hcd handles the iaa_in_progress flag.
      The current code is somewhat careless in this regard:
      
      	The flag is meaningless when the root hub isn't running, most
      	particularly after the root hub has been suspended.  But in
      	start_iaa_cycle(), the driver checks the flag before checking
      	the root hub's state.  They should be checked in the opposite
      	order.
      
      	That routine also sets the flag too early, before it has
      	definitely committed to starting an IAA cycle.
      
      	The flag is turned off in end_unlink_async().  Upcoming
      	changes will call that routine at other times, not just at the
      	end of an IAA cycle.  The two actions are logically separate
      	(although related), so we separate out a new routine to be
      	called in place of end_unlink_async() whenever an IAA cycle
      	ends: end_iaa_cycle().
      
      	iaa_in_progress should be turned off when the root hub is
      	suspended -- we certainly don't want it still to be set when
      	the root hub resumes.  Therefore the call to
      	end_unlink_async() in ehci_bus_suspend() should also be
      	replaced with a call to end_iaa_cycle().
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f96fba0d
  4. 15 8月, 2015 1 次提交
  5. 31 5月, 2015 1 次提交
  6. 08 4月, 2015 1 次提交
  7. 04 4月, 2015 1 次提交
  8. 25 1月, 2015 1 次提交
  9. 04 11月, 2014 1 次提交
  10. 29 9月, 2014 1 次提交
  11. 24 9月, 2014 1 次提交
  12. 26 8月, 2014 1 次提交
  13. 25 4月, 2014 1 次提交
  14. 19 2月, 2014 1 次提交
    • A
      USB: EHCI: add delay during suspend to prevent erroneous wakeups · 3e8d6d85
      Alan Stern 提交于
      High-speed USB connections revert back to full-speed signalling when
      the device goes into suspend.  This takes several milliseconds, and
      during that time it's not possible to tell reliably whether the device
      has been disconnected.
      
      On some platforms, the Wake-On-Disconnect circuitry gets confused
      during this intermediate state.  It generates a false wakeup signal,
      which can prevent the controller from going to sleep.
      
      To avoid this problem, this patch adds a 5-ms delay to the
      ehci_bus_suspend() routine if any ports have to switch over to
      full-speed signalling.  (Actually, the delay was already present for
      devices using a particular kind of PHY power management; the patch
      merely causes the delay to be used more widely.)
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reviewed-by: NPeter Chen <Peter.Chen@freescale.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e8d6d85
  15. 04 12月, 2013 1 次提交
  16. 31 8月, 2013 1 次提交
  17. 15 8月, 2013 1 次提交
  18. 13 8月, 2013 3 次提交
    • M
      usb: ehci: Add support for SINGLE_STEP_SET_FEATURE test of EHSET · 9841f37a
      Manu Gautam 提交于
      The USB Embedded High-speed Host Electrical Test (EHSET) defines the
      SINGLE_STEP_SET_FEATURE test as follows:
      
      1) The host enumerates the test device with VID:0x1A0A, PID:0x0108
      2) The host sends the SETUP stage of a GetDescriptor(Device)
      3) The device ACKs the request
      4) The host issues SOFs for 15 seconds allowing the test operator to
         raise the scope trigger just above the SOF voltage level
      5) The host sends the IN packet
      6) The device sends data in response, triggering the scope
      7) The host sends an ACK in response to the data
      
      This patch adds additional handling to the EHCI hub driver and allows
      the EHSET driver to initiate this test mode by issuing a a SetFeature
      request to the root hub with a Test Selector value of 0x06. From there
      it mimics ehci_urb_enqueue() but separately submits QTDs for the
      SETUP and DATA/STATUS stages in order to insert a delay in between.
      Signed-off-by: NManu Gautam <mgautam@codeaurora.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      [jackp@codeaurora.org: imported from commit c2084930 on codeaurora.org;
       minor cleanup and updated author email]
      Signed-off-by: NJack Pham <jackp@codeaurora.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9841f37a
    • M
      USB: EHCI: improve interrupt qh unlink · 9118f9eb
      Ming Lei 提交于
      ehci-hcd currently unlinks an interrupt QH when it becomes empty, that
      is, after its last URB completes.  This works well because in almost
      all cases, the completion handler for an interrupt URB resubmits the
      URB; therefore the QH doesn't become empty and doesn't get unlinked.
      
      When we start using tasklets for URB completion, this scheme won't work
      as well.  The resubmission won't occur until the tasklet runs, which
      will be some time after the completion is queued with the tasklet.
      During that delay, the QH will be empty and so will be unlinked
      unnecessarily.
      
      To prevent this problem, this patch adds a 5-ms time delay before empty
      interrupt QHs are unlinked.  Most often, during that time the interrupt
      URB will be resubmitted and thus we can avoid unlinking the QH.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9118f9eb
    • T
      usb: host: add has_tdi_phy_lpm capability bit · 2cdcec4f
      Tuomas Tynkkynen 提交于
      The has_hostpc capability bit indicates that the host controller has the
      HOSTPC register extensions, but at the same time enables clock disabling
      power saving features with the PHY Low Power Clock Disable (PHCD) bit.
      
      However, some host controllers have the HOSTPC extensions but don't
      support the low-power feature, so the PHCD bit must not be set on those
      controllers. Add a separate capability bit for the low-power feature
      instead, and change all existing users of has_hostpc to use this new
      capability bit.
      
      The idea for this commit is taken from an old 2012 commit that never got
      merged ("disociate chipidea PHY low power suspend control from hostpc")
      Inspired-by: NMatthieu CASTET <matthieu.castet@parrot.com>
      Signed-off-by: NTuomas Tynkkynen <ttynkkynen@nvidia.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Tested-by: NStephen Warren <swarren@nvidia.com>
      Reviewed-by: NStephen Warren <swarren@nvidia.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      2cdcec4f
  19. 02 8月, 2013 2 次提交
    • A
      USB: EHCI: don't depend on hardware for tracking port resets and resumes · 6753f4cf
      Alan Stern 提交于
      In theory, an EHCI controller can turn off the PORT_RESUME or
      PORT_RESET bits in a port status register all by itself (and some
      controllers actually do this).  We shouldn't depend on these bits
      being set correctly.
      
      This patch rearranges the code in ehci-hcd that handles completion of
      port resets and resumes.  We guarantee that ehci->reset_done[portnum]
      is nonzero if a reset or resume is in progress, and that the portnum
      bit is set in ehci->resuming_ports if the operation is a resume.  (To
      help enforce this guarantee, the patch prevents suspended ports from
      being reset.)  Therefore it's not necessary to look at the port status
      bits to learn what's going on.
      
      The patch looks bigger than it really is, because it changes the
      indentation level of a sizeable region of code.  Most of what it
      actually does is interchange some tests.  The only functional changes
      are testing reset_done and resuming_ports rather than PORT_RESUME and
      PORT_RESET, removing a now-unnecessary check for spontaneous
      resets of the PORT_RESUME and PORT_RESET bits, and preventing a
      suspended or resuming port from being reset.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6753f4cf
    • A
      USB: EHCI: keep better track of resuming ports · 3a20446f
      Alan Stern 提交于
      The ehci-hcd driver isn't as careful as it should be about the way it
      uses ehci->resuming_ports.  One of the omissions was fixed recently by
      commit 47a64a13 (USB: EHCI: Fix resume signalling on remote
      wakeup), but there are other places that need attention:
      
      	When a port's suspend feature is explicitly cleared, the
      	corresponding bit in resuming_ports should be set and the core
      	should be notified about the port resume.
      
      	We don't need to clear a resuming_ports bit when a reset
      	completes.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3a20446f
  20. 23 7月, 2013 1 次提交
  21. 18 6月, 2013 1 次提交
  22. 21 5月, 2013 1 次提交
    • J
      usb: ehci: Only sleep for post-resume handover if devices use persist · 9b790915
      Julius Werner 提交于
      The current EHCI code sleeps a flat 110ms in the resume path if there
      was a USB 1.1 device connected to its companion controller during
      suspend, waiting for the device to reappear and reset so that it can be
      handed back to the companion. This is necessary if the device uses
      persist, so that the companion controller can actually see it during its
      own resume path.
      
      However, if the device doesn't use persist, this is entirely
      unnecessary. We might just as well ignore it and have the normal device
      detection/reset/handoff code handle it asynchronously when it eventually
      shows up. As USB 1.1 devices are almost exclusively HIDs these days (for
      which persist has no value), this can allow distros to shave another
      tenth of a second off their resume time.
      
      In order to enable this optimization, the patch also adds a new
      usb_for_each_dev() iterator that is exported by the USB core and wraps
      bus_for_each_dev() with the logic to differentiate between struct
      usb_device and struct usb_interface on the usb_bus_type bus.
      Signed-off-by: NJulius Werner <jwerner@chromium.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9b790915
  23. 04 4月, 2013 1 次提交
  24. 19 3月, 2013 2 次提交
  25. 16 3月, 2013 1 次提交
    • A
      USB: EHCI: fix regression during bus resume · 2a40f324
      Alan Stern 提交于
      This patch (as1663) fixes a regression caused by commit
      6e0c3339 (USB: EHCI: unlink one async
      QH at a time).  In order to avoid keeping multiple QHs in an unusable
      intermediate state, that commit changed unlink_empty_async() so that
      it unlinks only one empty QH at a time.
      
      However, when the EHCI root hub is suspended, _all_ async QHs need to
      be unlinked.  ehci_bus_suspend() used to do this by calling
      unlink_empty_async(), but now this only unlinks one of the QHs, not
      all of them.
      
      The symptom is that when the root hub is resumed, USB communications
      don't work for some period of time.  This is because ehci-hcd doesn't
      realize it needs to restart the async schedule; it assumes that
      because some QHs are already on the schedule, the schedule must be
      running.
      
      The easiest way to fix the problem is add a new function that unlinks
      all the async QHs when the root hub is suspended.
      
      This patch should be applied to all kernels that have the 6e0c3339
      commit.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-and-tested-by: NAdrian Bassett <adrian.bassett@hotmail.co.uk>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a40f324
  26. 26 1月, 2013 2 次提交
  27. 01 11月, 2012 3 次提交
    • A
      USB: EHCI: prepare to make ehci-hcd a library module · 3e023203
      Alan Stern 提交于
      This patch (as1624) prepares ehci-hcd for being split up into a core
      library and separate platform driver modules.  A generic
      ehci_hc_driver structure is created, containing all the "standard"
      values, and a new mechanism is added whereby a driver module can
      specify a set of overrides to those values.  In addition the
      ehci_setup(), ehci_suspend(), and ehci_resume() routines need to be
      EXPORTed for use by the drivers.
      
      As a side effect of this change, a few routines no longer need to be
      marked __maybe_unused.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Felipe Balbi <balbi@ti.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e023203
    • A
      USB: EHCI: remove ehci_port_power() routine · c73cee71
      Alan Stern 提交于
      This patch (as1623) removes the ehci_port_power() routine and all the
      places that call it.  There's no reason for ehci-hcd to change the
      port power settings; the hub driver takes care of all that stuff.
      
      There is one exception: When the controller is resumed from
      hibernation or following a loss of power, the ports that are supposed
      to be handed over to a companion controller must be powered on first.
      Otherwise the handover won't work.  This process is not visible to the
      hub driver, so it has to be handled in ehci-hcd.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c73cee71
    • A
      USB: EHCI: remove unused Link Power Management code · 4968f951
      Alan Stern 提交于
      This patch (as1622) removes the USB-2.1 Link Power Management code
      from the ehci-hcd driver.  This code was never integrated with
      usbcore, it is full of bugs, and it was not getting used by anybody.
      
      However, the debugging code for dumping the LPM-related fields in the
      EHCI registers is left in place.  In theory it might be useful to see
      these values, even though we don't use them.
      
      This essentially amounts to a partial revert of commit
      aa4d8342 (USB: EHCI: EHCI 1.1
      addendum: preparation) and an almost full revert of commit
      48f24970 (USB: EHCI: EHCI 1.1
      addendum: Basic LPM feature support) plus its follow-ons.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4968f951
  28. 25 10月, 2012 1 次提交
  29. 19 9月, 2012 1 次提交
  30. 17 7月, 2012 3 次提交
    • A
      USB: EHCI: resolve some unlikely races · 43fe3a99
      Alan Stern 提交于
      This patch (as1589) resolves some unlikely races involving system
      shutdown or controller death in ehci-hcd:
      
      	Shutdown races with both root-hub resume and controller
      	resume.
      
      	Controller death races with root-hub suspend.
      
      A new bitflag is added to indicate that the controller has been shut
      down (whether for system shutdown or because it died).  Tests are
      added in the suspend and resume pathways to avoid reactivating the
      controller after any sort of shutdown.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43fe3a99
    • A
      USB: EHCI: fix up locking · c4f34764
      Alan Stern 提交于
      This patch (as1588) adjusts the locking in ehci-hcd's various halt,
      shutdown, and suspend/resume pathways.  We want to hold the spinlock
      while writing device registers and accessing shared variables, but not
      while polling in a loop.
      
      In addition, there's no need to call ehci_work() at times when no URBs
      can be active, i.e., in ehci_stop() and ehci_bus_suspend().
      
      Finally, ehci_adjust_port_wakeup_flags() is called only in situations
      where interrupts are enabled; therefore it can use spin_lock_irq
      rather than spin_lock_irqsave.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c4f34764
    • A
      USB: EHCI: use hrtimer for the I/O watchdog · 18aafe64
      Alan Stern 提交于
      This patch (as1586) replaces the kernel timer used by ehci-hcd as an
      I/O watchdog with an hrtimer event.
      
      Unlike in the current code, the watchdog event is now always enabled
      whenever any isochronous URBs are active.  This will prevent bugs
      caused by the periodic schedule wrapping around with no completion
      interrupts; the watchdog handler is guaranteed to scan the isochronous
      transfers at least once during each iteration of the schedule.  The
      extra overhead will be negligible: one timer interrupt every 100 ms.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      18aafe64