1. 19 Jul, 2012 2 commits
  2. 17 Jul, 2012 22 commits
  3. 16 Jul, 2012 16 commits
    • Greg Kroah-Hartman's avatar
      Merge tag 'for-usb-next-2012-07-11' of... · 6470cbc4
      Greg Kroah-Hartman authored
      Merge tag 'for-usb-next-2012-07-11' of git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci into usb-next
      
      USB: Link PM fixes and Latency Tolerance Messaging
      
      Hi Greg,
      
      Here's four bug fix patches for Link PM (LPM), which are marked for
      3.5-stable.  There's also three patches that turn on Latency Tolerance
      Messaging (LTM) for xHCI host controllers and USB 3.0 devices that support
      this low power feature.
      
      Please queue for 3.6.
      
      Sarah Sharp
      6470cbc4
    • Alan Stern's avatar
      USB: EHCI: resolve some unlikely races · 43fe3a99
      Alan Stern authored
      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: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43fe3a99
    • Alan Stern's avatar
      USB: EHCI: fix up locking · c4f34764
      Alan Stern authored
      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: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c4f34764
    • Alan Stern's avatar
      USB: EHCI: simplify isochronous scanning · f4289078
      Alan Stern authored
      This patch (as1587) simplifies ehci-hcd's scan_isoc() routine by
      eliminating some local variables, declaring boolean-valued values as
      bool rather than unsigned, changing variable names to make more sense,
      and so on.
      
      The logic at the end of the routine is cut down significantly.  The
      scanning doesn't have to catch up all the way to where the hardware
      is; it merely has to catch up to where the hardware was when the last
      interrupt occurred.  If the hardware has made more progress since then
      and issued another interrupt, a rescan will catch up to it.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f4289078
    • Alan Stern's avatar
      USB: EHCI: use hrtimer for the I/O watchdog · 18aafe64
      Alan Stern authored
      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: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      18aafe64
    • Alan Stern's avatar
      USB: EHCI: always scan each interrupt QH · 569b394f
      Alan Stern authored
      This patch (as1585) fixes a bug in ehci-hcd's scheme for scanning
      interrupt QHs.
      
      Currently a single routine takes care of scanning everything on the
      periodic schedule.  Whenever an interrupt occurs, it scans all
      isochronous and interrupt URBs scheduled for frames that have elapsed
      since the last scan.
      
      This has two disadvantages.  The first is relatively minor: An
      interrupt QH is likely to end up getting scanned multiple times,
      particularly if the last scan was not fairly recent.  (The current
      code avoids this by maintaining a periodic_stamp in each interrupt
      QH.)
      
      The second is more serious.  The periodic schedule wraps around.  If
      the last scan occurred during frame N, and the next scan occurs when
      the schedule has gone through an entire cycle and is back at frame N,
      the scanning code won't look at any frames other than N.  Consequently
      it won't see any QHs that completed during frame N-1 or earlier.
      
      The patch replaces the entire frame-based approach for scanning
      interrupt QHs with a new routine using a list-based approach, the same
      as for async QHs.  This has a slight disadvantage, because it means
      that all interrupt QHs have to be scanned every time.  But it is more
      robust than the current approach.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      569b394f
    • Alan Stern's avatar
      USB: EHCI: don't lose events during a scan · 361aabf3
      Alan Stern authored
      This patch (as1584) fixes a minor bug that has been present in
      ehci-hcd since the beginning.
      
      Scanning the schedules for URB completions is single-threaded.  If a
      completion interrupt occurs while an URB is being given back, the
      interrupt handler realizes that a scan is in progress on another CPU
      and avoids starting a new one.
      
      This means that completion events can be lost.  If an URB completes
      after it has been scanned but while a scan is still in progress, the
      driver won't notice and won't rescan the completed URB.
      
      The patch fixes the problem by adding a new flag to indicate that
      another scan is needed after the current scan is done.  The flag gets
      set whenever a completion interrupt occurs while a scan is in
      progress.  The rescan will see the completion, thus preventing it from
      getting lost.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      361aabf3
    • Alan Stern's avatar
      USB: EHCI: use hrtimer for unlinking empty async QHs · 32830f20
      Alan Stern authored
      This patch (as1583) changes ehci-hcd to use an hrtimer event for
      unlinking empty (unused) async QHs instead of using a kernel timer.
      
      The check for empty QHs is moved to a new routine, where it doesn't
      require going through an entire scan of both the async and periodic
      schedules.  And it can unlink multiple QHs at once, unlike the current
      code.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      32830f20
    • Alan Stern's avatar
      USB: EHCI: unlink multiple async QHs together · 3c273a05
      Alan Stern authored
      This patch (as1582) changes ehci-hcd's strategy for unlinking async
      QHs.  Currently the driver never unlinks more than one QH at a time.
      This can be inefficient and cause unnecessary delays, since a QH
      cannot be reused while it is waiting to be unlinked.
      
      The new strategy unlinks all the waiting QHs at once.  In practice the
      improvement won't be very big, because it's somewhat uncommon to have
      two or more QHs waiting to be unlinked at any time.  But it does
      happen, and in any case, doing things this way makes more sense IMO.
      
      The change requires the async unlinking code to be refactored
      slightly.  Now in addition to the routines for starting and ending an
      unlink, there are new routines for unlinking a single QH and starting
      an IAA cycle.  This approach is needed because there are two separate
      paths for unlinking async QHs:
      
      	When a transfer error occurs or an URB is cancelled, the QH
      	must be unlinked right away;
      
      	When a QH has been idle sufficiently long, it is unlinked
      	to avoid consuming DMA bandwidth uselessly.
      
      In the first case we want the unlink to proceed as quickly as
      possible, whereas in the second case we can afford to batch several
      QHs together and unlink them all at once.  Hence the division of
      labor.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3c273a05
    • Alan Stern's avatar
      USB: EHCI: use hrtimer for the IAA watchdog · 9d938747
      Alan Stern authored
      This patch (as1581) replaces the iaa_watchdog kernel timer used by
      ehci-hcd with an hrtimer event, in keeping with the general conversion
      to high-res timers.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9d938747
    • Alan Stern's avatar
      USB: EHCI: don't refcount iso_stream structures · 8c5bf7be
      Alan Stern authored
      This patch (as1580) makes ehci_iso_stream structures behave more like
      QHs, in that they will remain allocated until their isochronous
      endpoint is disabled.  This will come in useful in the future, when
      periodic bandwidth gets allocated as an altsetting is installed rather
      than on-the-fly.
      
      For now, the change to the ehci_iso_stream lifetimes means that each
      structure is always deallocated at exactly one spot in
      ehci_endpoint_disable() and never used again.  As a result, it is no
      longer necessary to use reference counting on these things, and the
      patch removes it.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c5bf7be
    • Alan Stern's avatar
      USB: EHCI: use hrtimer for (s)iTD deallocation · 55934eb3
      Alan Stern authored
      This patch (as1579) adds an hrtimer event to handle deallocation of
      iTDs and siTDs in ehci-hcd.
      
      Because of the frame-oriented approach used by the EHCI periodic
      schedule, the hardware can continue to access the Transfer Descriptor
      for isochronous (or split-isochronous) transactions for up to a
      millisecond after the transaction completes.  The iTD (or siTD) must
      not be reused before then.
      
      The strategy currently used involves putting completed iTDs on a list
      of cached entries and every so often returning them to the endpoint's
      free list.  The new strategy reduces overhead by putting completed
      iTDs back on the free list immediately, although they are not reused
      until it is safe to do so.
      
      When the isochronous endpoint stops (its queue becomes empty), the
      iTDs on its free list get moved to a global list, from which they will
      be deallocated after a minimum of 2 ms.  This delay is what the new
      hrtimer event is for.
      
      Overall this may not be a tremendous improvement over the current
      code, but to me it seems a lot more clear and logical.  In addition,
      it removes the need for each iTD to keep a reference to the
      ehci_iso_stream it belongs to, since the iTD never needs to be moved
      back to the stream's free list from the global list.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55934eb3
    • Alan Stern's avatar
      USB: EHCI: use hrtimer for controller death · bf6387bc
      Alan Stern authored
      This patch (as1578) adds an hrtimer event to handle the death of an
      EHCI controller.  When a controller dies, it doesn't necessarily stop
      running right away.  The new event polls at 1-ms intervals to see when
      all activity has safely stopped.  This replaces a busy-wait polling
      loop in the current code.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bf6387bc
    • Alan Stern's avatar
      USB: EHCI: use hrtimer for interrupt QH unlink · df202255
      Alan Stern authored
      This patch (as1577) adds hrtimer support for unlinking interrupt QHs
      in ehci-hcd.  The current code relies on a fixed delay of either 2 or
      55 us, which is not always adequate and in any case is totally bogus.
      Thanks to internal caching, the EHCI hardware may continue to access
      an interrupt QH for more than a millisecond after it has been unlinked.
      
      In fact, the EHCI spec doesn't say how long to wait before using an
      unlinked interrupt QH.  The patch sets the delay to 9 microframes
      minimum, which ought to be adequate.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df202255
    • Alan Stern's avatar
      USB: EHCI: use hrtimer for async schedule · 31446610
      Alan Stern authored
      This patch (as1576) adds hrtimer support for managing ehci-hcd's
      async schedule.  Just as with the earlier change to the periodic
      schedule management, two new hrtimer events take care of everything.
      
      One event polls at 1-ms intervals to see when the Asynchronous
      Schedule Status (ASS) flag matches the Asynchronous Schedule Enable
      (ASE) value; the schedule's state must not be changed until it does.
      The other event delays for 15 ms after the async schedule becomes
      empty before turning it off.
      
      The new events replace a busy-wait poll and a kernel timer usage.
      They also replace the rather illogical method currently used for
      indicating the async schedule should be turned off: attempting to
      unlink the dedicated QH at the head of the async list.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      31446610
    • Alan Stern's avatar
      USB: EHCI: remove PS3 status polling · 9671cd7a
      Alan Stern authored
      This patch (as1575) removes special code added for status polling of
      the EHCI controller in PS3 systems.  While the controller is running,
      the polling is now carried out by an hrtimer handler.  When the
      controller is suspending or stopping, we use the same polling routine
      as the old code -- but in neither case do we need to conclude that the
      controller has died if the polling goes on for too long.
      
      As a result the entire handshake_on_error_set_halt() routine is now
      unused, so it is removed from the driver.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9671cd7a