1. 12 10月, 2013 3 次提交
  2. 18 9月, 2013 2 次提交
    • A
      USB: EHCI: handle isochronous underruns with tasklets · 46c73d1d
      Alan Stern 提交于
      This patch updates the iso_stream_schedule() routine in ehci-sched.c
      to handle cases where an underrun causes an isochronous endpoint's
      queue to empty out, but the client driver wants to maintain
      synchronization with the device (i.e., the URB_ISO_ASAP flag is not
      set).  This could not happen until recently, when ehci-hcd switched
      over to completing URBs in a tasklet.
      
      (This may seem like an unlikely case to worry about, but underruns are
      all too common with the snd-usb-audio driver, which doesn't use
      URB_ISO_ASAP.)
      
      As part of the fix, some URBs may need to be given back when they are
      submitted.  This is necessary when the URB's scheduled slots all fall
      before the current value of ehci->last_iso_frame, and as an
      optimization we do it also when the slots all fall before the current
      frame number.
      
      As a second part of the fix, we may need to skip some but not all of
      an URB's packets.  This is necessary when some of the URB's scheduled
      slots fall before the current value of ehci->last_iso_frame and some
      of them fall after the current frame number.  A new field
      (first_packet) is added to struct ehci_iso_sched, to indicate how many
      packets should be skipped.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Ming Lei <tom.leiming@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      46c73d1d
    • A
      USB: EHCI: code rearrangement in iso_stream_schedule() · e4e18cbd
      Alan Stern 提交于
      This patch interchanges the "if" and "else" branches of the big "if"
      statement in iso_stream_schedule(), in preparation for the next patch
      in this series.  That is, it changes
      
      	if (likely(!...)) {
      		A
      	} else {
      		B
      	}
      
      to
      
      	if (unlikely(...)) {
      		B
      	} else {
      		A
      	}
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e4e18cbd
  3. 31 8月, 2013 2 次提交
  4. 13 8月, 2013 2 次提交
    • A
      USB: EHCI: accept very late isochronous URBs · 24f53137
      Alan Stern 提交于
      Since commits 4005ad43 (EHCI: implement new semantics for
      URB_ISO_ASAP) and c75c5ab5 (ALSA: USB: adjust for changed 3.8 USB
      API) became widely distributed, people have been experiencing problems
      with audio transfers.  The slightest underrun causes complete failure,
      requiring the audio stream to be restarted.
      
      It turns out that the current isochronous API doesn't handle underruns
      in the best way.  The ALSA developers would much rather have transfers
      that are submitted too late be accepted and complete in the normal
      fashion, rather than being refused outright.
      
      This patch implements the requested approach.  When an isochronous URB
      submission is so late that all its scheduled slots have already
      expired, a debugging message will be printed in the log and the URB
      will be accepted as usual.  Assuming it was submitted by a completion
      handler (which is normally the case), it will complete shortly
      thereafter with all the usb_iso_packet_descriptor status fields marked
      -EXDEV.
      
      This fixes (for ehci-hcd)
      
      	https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1191603
      
      It should be applied to all kernels that include commit 4005ad43.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Tested-by: NMaksim Boyko <maksboyko@yandex.ru>
      CC: Clemens Ladisch <clemens@ladisch.de>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      24f53137
    • 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
  5. 30 5月, 2013 1 次提交
  6. 29 5月, 2013 1 次提交
    • A
      USB: revert periodic scheduling bugfix · fdc03438
      Alan Stern 提交于
      This patch reverts commit 3e619d04
      (USB: EHCI: fix bug in scheduling periodic split transfers).  The
      commit was valid -- it fixed a real bug -- but the periodic scheduler
      in ehci-hcd is in such bad shape (especially the part that handles
      split transactions) that fixing one bug is very likely to cause
      another to surface.  That's what happened in this case; the result was
      choppy and noisy playback on certain 24-bit audio devices.
      
      The only real fix will be to rewrite this entire section of code.  My
      next project...
      
      This fixes https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1136110.
      
      Thanks to Tim Richardson for extra testing and feedback, and to Joseph
      Salisbury and Tyson Tan for tracking down the original source of the
      problem.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Joseph Salisbury <joseph.salisbury@canonical.com>
      CC: Tim Richardson <tim@tim-richardson.net>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fdc03438
  7. 26 3月, 2013 5 次提交
    • S
      USB: EHCI: fix bug in iTD/siTD DMA pool allocation · 85ecd032
      Soeren Moch 提交于
      [Description written by Alan Stern]
      
      Soeren tracked down a very difficult bug in ehci-hcd's DMA pool
      management of iTD and siTD structures.  Some background: ehci-hcd
      gives each isochronous endpoint its own set of active and free itd's
      (or sitd's for full-speed devices).  When a new itd is needed, it is
      taken from the head of the free list, if possible.  However, itd's
      must not be used twice in a single frame because the hardware
      continues to access the data structure for the entire duration of a
      frame.  Therefore if the itd at the head of the free list has its
      "frame" member equal to the current value of ehci->now_frame, it
      cannot be reused and instead a new itd is allocated from the DMA pool.
      The entries on the free list are not released back to the pool until
      the endpoint is no longer in use.
      
      The bug arises from the fact that sometimes an itd can be moved back
      onto the free list before itd->frame has been set properly.  In
      Soeren's case, this happened because ehci-hcd can allocate one more
      itd than it actually needs for an URB; the extra itd may or may not be
      required depending on how the transfer aligns with a frame boundary.
      For example, an URB with 8 isochronous packets will cause two itd's to
      be allocated.  If the URB is scheduled to start in microframe 3 of
      frame N then it will require both itds: one for microframes 3 - 7 of
      frame N and one for microframes 0 - 2 of frame N+1.  But if the URB
      had been scheduled to start in microframe 0 then it would require only
      the first itd, which could cover microframes 0 - 7 of frame N.  The
      second itd would be returned to the end of the free list.
      
      The itd allocation routine initializes the entire structure to 0, so
      the extra itd ends up on the free list with itd->frame set to 0
      instead of a meaningful value.  After a while the itd reaches the head
      of the list, and occasionally this happens when ehci->now_frame is
      equal to 0.  Then, even though it would be okay to reuse this itd, the
      driver thinks it must get another itd from the DMA pool.
      
      For as long as the isochronous endpoint remains in use, this flaw in
      the mechanism causes more and more itd's to be taken slowly from the
      DMA pool.  Since none are released back, the pool eventually becomes
      exhausted.
      
      This reuslts in memory allocation failures, which typically show up
      during a long-running audio stream.  Video might suffer the same
      effect.
      
      The fix is very simple.  To prevent allocations from the pool when
      they aren't needed, make sure that itd's sent back to the free list
      prematurely have itd->frame set to an invalid value which can never be
      equal to ehci->now_frame.
      
      This should be applied to -stable kernels going back to 3.6.
      Signed-off-by: NSoeren Moch <smoch@web.de>
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      85ecd032
    • A
      USB: EHCI: convert singly-linked lists to list_heads · 6e018751
      Alan Stern 提交于
      This patch (as1664) converts ehci-hcd's async_unlink, async_iaa, and
      intr_unlink from singly-linked lists to standard doubly-linked
      list_heads.  Originally it didn't seem necessary to use list_heads,
      because items are always added to and removed from these lists in FIFO
      order.  But now with more list processing going on, it's easier to use
      the standard routines than continue with a roll-your-own approach.
      
      I don't know if the code ends up being notably shorter, but the
      patterns will be more familiar to any kernel hacker.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6e018751
    • A
      USB: EHCI: split needs_rescan into two flags · 7bc782d7
      Alan Stern 提交于
      This patch (as1662) does some more QH-related cleanup in ehci-hcd.
      The qh->needs_rescan flag is currently used for two different
      purposes; the patch replaces it with two separate flags for greater
      clarity: qh->dequeue_during_giveback indicates that a completion
      handler dequeued an URB (implying that a rescan is needed), and
      qh->exception indicates that the QH is in an exceptional state
      requiring an unlink (either it encountered an I/O error or an unlink
      was requested).
      
      The new flags get set where the dequeue, exception, or unlink request
      occurred, rather than where the unlink is started.  This is so that in
      the future, if we need to, we will be able to tell apart unlinks that
      truly were required from those that were carried out merely because
      the QH wasn't being used.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7bc782d7
    • A
      USB: EHCI: change return value of qh_completions() · 79bcf7b0
      Alan Stern 提交于
      This patch (as1658) cleans up the usage of qh_completions() in
      ehci-hcd.  Currently the function's return value indicates whether any
      URBs were given back; the idea was that the caller can scan the QH
      over again to handle any URBs that were dequeued by a completion
      handler.  This is not necessary; when qh_completions() is ready to
      give back dequeued URBs, it does its own rescanning.
      
      Therefore the new return value will be a flag indicating whether the
      caller needs to unlink the QH.  This is more convenient than forcing
      the caller to check qh->needs_rescan, and it makes a lot more sense --
      why should "needs_rescan" imply that an unlink is needed?  The callers
      are also changed to remove the unneeded rescans.
      
      Lastly, the check for whether qh->qtd_list is non-empty is removed
      from the start of qh_completions().  Two of the callers have to make
      this test anyway, so the same test can simply be added to the other
      two callers.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      79bcf7b0
    • A
      USB: EHCI: changes related to qh_refresh() · c1fdb68e
      Alan Stern 提交于
      This patch (as1638) makes several changes to the ehci-hcd driver, all
      related to the qh_refresh() function.  This function must be called
      whenever an idle QH gets linked back into either the async or the
      periodic schedule.
      
      	Change a BUG_ON() in the qh_update routine to a WARN_ON().
      	Since this code runs in atomic context, a BUG_ON() would
      	immediately freeze the whole system.
      
      	Remove two unneeded calls to qh_refresh(), one when a QH is
      	initialized and one when a QH becomes idle.  Adjust the
      	adjacent comments accordingly.
      
      	Move the qh_refresh() and qh_link_periodic() calls for new
      	interrupt URBs to after the new TDs have been added.
      
      	As a result of the previous two changes, qh_refresh() is never
      	called when the qtd_list is empty.  The corresponding check in
      	qh_refresh() can be removed, along with an indentation level.
      
      These changes should not cause any alteration of behavior.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c1fdb68e
  8. 31 1月, 2013 2 次提交
  9. 12 11月, 2012 1 次提交
    • A
      USB: EHCI: bugfix: urb->hcpriv should not be NULL · 2656a9ab
      Alan Stern 提交于
      This patch (as1632b) fixes a bug in ehci-hcd.  The USB core uses
      urb->hcpriv to determine whether or not an URB is active; host
      controller drivers are supposed to set this pointer to a non-NULL
      value when an URB is queued.  However ehci-hcd sets it to NULL for
      isochronous URBs, which defeats the check in usbcore.
      
      In itself this isn't a big deal.  But people have recently found that
      certain sequences of actions will cause the snd-usb-audio driver to
      reuse URBs without waiting for them to complete.  In the absence of
      proper checking by usbcore, the URBs get added to their endpoint list
      twice.  This leads to list corruption and a system freeze.
      
      The patch makes ehci-hcd assign a meaningful value to urb->hcpriv for
      isochronous URBs.  Improving robustness always helps.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NArtem S. Tashkinov <t.artem@lycos.com>
      Reported-by: NChristof Meerwald <cmeerw@cmeerw.org>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2656a9ab
  10. 25 10月, 2012 1 次提交
  11. 23 10月, 2012 1 次提交
  12. 22 10月, 2012 3 次提交
    • A
      EHCI: replace mult/div with bit-mask operation · 72675479
      Alan Stern 提交于
      This patch (as1610) replaces multiplication and divison operations in
      ehci-hcd's isochronous scheduling code with a bit-mask operation,
      taking advantage of the fact that isochronous periods are always
      powers of 2.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      72675479
    • A
      EHCI: use the isochronous scheduling threshold · 98cae42d
      Alan Stern 提交于
      This patch (as1609) changes the way ehci-hcd uses the "Isochronous
      Scheduling Threshold" in its calculations.  Until now the code has
      ignored the threshold except for certain Intel PCI-based controllers.
      This violates the EHCI spec.
      
      The new code takes the threshold into account always, removing the
      need for the fs_i_thresh quirk flag.  In addition it implements the
      "full frame cache" setting more efficiently, moving forward only as
      far as the next frame boundary instead of always moving forward 8
      microframes.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      98cae42d
    • A
      EHCI: improved logic for isochronous scheduling · c3ee9b76
      Alan Stern 提交于
      This patch (as1608) reworks the logic used by ehci-hcd for scheduling
      isochronous transfers.  Now the modular calculations are all based on
      a window that starts at the last frame scanned for isochronous
      completions.  No transfer descriptors for any earlier frames can
      possibly remain on the schedule, so there can be no confusion from
      schedule wrap-around.  This removes the need for a "slop" region of
      arbitrary size.
      
      There's no need to check for URBs that are longer than the schedule
      length.  With the old code they could throw things off by wrapping
      around and appearing to end in the near future rather than the distant
      future.  Now such confusion isn't possible, and the existing test for
      submissions that extend too far into the future will also catch those
      that exceed the schedule length.  (But there still has to be an
      initial test to handle the case where the schedule already extends as
      far into the future as possible.)
      
      Delays caused by IRQ latency won't confuse the algorithm unless they
      are ridiculously long (over 250 ms); they will merely reduce how far
      into the future new transfers can be scheduled.  A few people have
      reported problems caused by delays of 50 ms or so.  Now instead of
      failing completely, isochronous transfers will experience a brief
      glitch and then continue normally.
      
      (Whether this is truly a good thing is debatable.  A latency as large
      as 50 ms generally indicates a bug is present, and complete failure of
      audio or video transfers draws people's attention pretty vividly.
      Making the transfers more robust also makes it easier for such bugs to
      remain undetected.)
      
      Finally, ehci->next_frame is renamed to ehci->last_iso_frame, because
      that better describes what it is: the last frame to have been scanned
      for isochronous completions.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c3ee9b76
  13. 17 7月, 2012 10 次提交
    • A
      USB: EHCI: simplify isochronous scanning · f4289078
      Alan Stern 提交于
      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: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f4289078
    • 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
    • A
      USB: EHCI: always scan each interrupt QH · 569b394f
      Alan Stern 提交于
      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: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      569b394f
    • A
      USB: EHCI: don't refcount iso_stream structures · 8c5bf7be
      Alan Stern 提交于
      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: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c5bf7be
    • A
      USB: EHCI: use hrtimer for (s)iTD deallocation · 55934eb3
      Alan Stern 提交于
      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: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55934eb3
    • A
      USB: EHCI: use hrtimer for interrupt QH unlink · df202255
      Alan Stern 提交于
      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: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df202255
    • A
      USB: EHCI: return void instead of 0 · b015cb79
      Alan Stern 提交于
      This patch (as1574) changes the return type of multiple functions in
      ehci-sched.c from int to void.  The values they return are now always
      0, so there's no reason for them to return any value at all.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b015cb79
    • A
      USB: EHCI: use hrtimer for the periodic schedule · 3ca9aeba
      Alan Stern 提交于
      This patch (as1573) adds hrtimer support for managing ehci-hcd's
      periodic schedule.  There are two issues to deal with.
      
      First, the schedule's state (on or off) must not be changed until the
      hardware status has caught up with the current command.  This is
      handled by an hrtimer event that polls at 1-ms intervals to see when
      the Periodic Schedule Status (PSS) flag matches the Periodic Schedule
      Enable (PSE) value.
      
      Second, the schedule should not be turned off as soon as it becomes
      empty.  Turning the schedule on and off takes time, so we want to wait
      until the schedule has been empty for a suitable period before turning
      it off.  This is handled by an hrtimer event that gets set to expire
      10 ms after the periodic schedule becomes empty.
      
      The existing code polls (for up to 1125 us and with interrupts
      disabled!) to check the status, and doesn't implement a delay before
      turning off the schedule.  Furthermore, if the polling fails then the
      driver decides that the controller has died.  This has caused problems
      for several people; some controllers can take 10 ms or more to turn
      off their periodic schedules.
      
      This patch fixes these issues.  It also makes the "broken_periodic"
      workaround unnecessary; there is no longer any danger of turning off
      the periodic schedule after it has been on for less than 1 ms.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3ca9aeba
    • A
      USB: EHCI: add new root-hub state: STOPPING · c0c53dbc
      Alan Stern 提交于
      This patch (as1571) adds a new state for ehci-hcd's root hubs:
      EHCI_RH_STOPPING.  This value is used at times when the root hub is
      being stopped and we don't know whether or not the hardware has
      finished all its DMA yet.
      
      Although the purpose may not be apparent, this distinction will come
      in useful later on.  Future patches will avoid actions that depend on
      the root hub being operational (like turning on the async or periodic
      schedules) when they see the state is EHCI_RH_STOPPING.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c0c53dbc
    • A
      USB: EHCI: don't refcount QHs · c83e1a9f
      Alan Stern 提交于
      This patch (as1567) removes ehci-hcd's reference counting of QH
      structures.  It's not necessary to refcount these things because they
      always get deallocated at exactly one spot in ehci_endpoint_disable()
      (except for two special QHs, ehci->async and ehci->dummy) and are
      never used again.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c83e1a9f
  14. 15 5月, 2012 1 次提交
    • A
      USB: EHCI: improve full-speed isochronous scheduling routine · 65b8e5cb
      Alan Stern 提交于
      This patch (as1555) improves the code ehci-hcd uses while checking the
      periodic schedule for isochronous transfers to full-speed devices.  In
      addition to making sure that a new transfer does not violate the
      restrictions on the high-speed schedule, it also has to check the
      restrictions on the full-speed part of the bus, i.e., the part beyond
      the Transaction Translator (TT).
      
      It does this by calling tt_available() (or tt_no_collision() if
      CONFIG_USB_EHCI_TT_NEWSCHED isn't enabled).  However it calls that
      routine on each pass through a loop over the frames being modified,
      which is an unnecessary expense because tt_available() (or
      tt_no_collision) already does its own loop over frames.  It is
      sufficient to do the check just once, before starting the loop.
      
      In addition, the function calls incorrectly converted the transfer's
      period from microframes to frames by doing a left shift instead of a
      right shift.  The patch fixes this while moving the calls.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      65b8e5cb
  15. 02 5月, 2012 1 次提交
  16. 24 4月, 2012 1 次提交
  17. 29 11月, 2011 1 次提交
  18. 15 11月, 2011 1 次提交
    • T
      USB: EHCI: fix HUB TT scheduling issue with iso transfer · 811c926c
      Thomas Poussevin 提交于
      The current TT scheduling doesn't allow to play and then record on a
      full-speed device connected to a high speed hub.
      
      The IN iso stream can only start on the first uframe (0-2 for a 165 us)
      because of CSPLIT transactions.
      For the OUT iso stream there no such restriction. uframe 0-5 are possible.
      
      The idea of this patch is that the first uframe are precious (for IN TT iso
      stream) and we should allocate the last uframes first if possible.
      
      For that we reverse the order of uframe allocation (last uframe first).
      
      Here an example :
      
      hid interrupt stream
      ----------------------------------------------------------------------
      uframe                |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |
      ----------------------------------------------------------------------
      max_tt_usecs          | 125 | 125 | 125 | 125 | 125 | 125 | 30  |  0  |
      ----------------------------------------------------------------------
      used usecs on a frame | 13  |  0  |  0  |  0  |  0  |  0  |  0  |  0  |
      ----------------------------------------------------------------------
      
      iso OUT stream
      ----------------------------------------------------------------------
      uframe                |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |
      ----------------------------------------------------------------------
      max_tt_usecs          | 125 | 125 | 125 | 125 | 125 | 125 | 30  |  0  |
      ----------------------------------------------------------------------
      used usecs on a frame | 13  | 125 |  39 |  0  |  0  |  0  |  0  |  0  |
      ----------------------------------------------------------------------
      
      There no place for iso IN stream  (uframe 0-2 are used) and we got "cannot
      submit datapipe for urb 0, error -28: not enough bandwidth" error.
      
      With the patch this become.
      
      iso OUT stream
      ----------------------------------------------------------------------
      uframe                |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |
      ----------------------------------------------------------------------
      max_tt_usecs          | 125 | 125 | 125 | 125 | 125 | 125 | 30  |  0  |
      ----------------------------------------------------------------------
      used usecs on a frame |  13 |  0  |  0  |  0  | 125 |  39 |  0  |  0  |
      ----------------------------------------------------------------------
      
      iso IN stream
      ----------------------------------------------------------------------
      uframe                |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |
      ----------------------------------------------------------------------
      max_tt_usecs          | 125 | 125 | 125 | 125 | 125 | 125 | 30  |  0  |
      ----------------------------------------------------------------------
      used usecs on a frame |  13 |  0  | 125 | 40  | 125 |  39 |  0  |  0  |
      ----------------------------------------------------------------------
      Signed-off-by: NMatthieu Castet <matthieu.castet@parrot.com>
      Signed-off-by: NThomas Poussevin <thomas.poussevin@parrot.com>
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      811c926c
  19. 19 10月, 2011 1 次提交
    • A
      EHCI: workaround for MosChip controller bug · 68aa95d5
      Alan Stern 提交于
      This patch (as1489) works around a hardware bug in MosChip EHCI
      controllers.  Evidently when one of these controllers increments the
      frame-index register, it changes the three low-order bits (the
      microframe counter) before changing the higher order bits (the frame
      counter).  If the register is read at just the wrong time, the value
      obtained is too low by 8.
      
      When the appropriate quirk flag is set, we work around this problem by
      reading the frame-index register a second time if the first value's
      three low-order bits are all 0.  This gives the hardware a chance to
      finish updating the register, yielding the correct value.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Tested-by: NJason N Pitt <jpitt@fhcrc.org>
      CC: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      68aa95d5