1. 04 2月, 2016 10 次提交
  2. 10 1月, 2015 2 次提交
  3. 20 10月, 2013 2 次提交
  4. 15 10月, 2013 2 次提交
    • A
      USB: EHCI: start new isochronous streams ASAP · a393a807
      Alan Stern 提交于
      This patch changes the initial delay before the startup of a newly
      scheduled isochronous stream.  Currently the stream doesn't start
      for at least 5 ms (40 microframes).  This value is just an estimate;
      it has no real justification.
      
      Instead, we can start the stream as soon as possible after the
      scheduling computations are complete.  Essentially this requires
      nothing more than reading the frame counter after the stream is
      scheduled, instead of before.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a393a807
    • A
      USB: EHCI: create per-TT bandwidth tables · b35c5009
      Alan Stern 提交于
      This patch continues the scheduling changes in ehci-hcd by adding a
      table to store the bandwidth allocation below each TT.  This will
      speed up the scheduling code, as it will no longer need to read
      through the entire schedule to compute the bandwidth currently in use.
      
      Properly speaking, the FS/LS budget calculations should be done in
      terms of full-speed bytes per microframe, as described in the USB-2
      spec.  However the driver currently uses microseconds per microframe,
      and the scheduling code isn't robust enough at this point to change
      over.  For the time being, we leave the calculations as they are.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b35c5009
  5. 12 10月, 2013 6 次提交
    • A
      USB: EHCI: use a bandwidth-allocation table · d0ce5c6b
      Alan Stern 提交于
      This patch significantly changes the scheduling code in ehci-hcd.
      Instead of calculating the current bandwidth utilization by trudging
      through the schedule and adding up the times used by the existing
      transfers, we will now maintain a table holding the time used for each
      of 64 microframes.  This will drastically speed up the bandwidth
      computations.
      
      In addition, it eliminates a theoretical bug.  An isochronous endpoint
      may have bandwidth reserved even at times when it has no transfers
      listed in the schedule.  The table will keep track of the reserved
      bandwidth, whereas adding up entries in the schedule would miss it.
      
      As a corollary, we can keep bandwidth reserved for endpoints even
      when they aren't in active use.  Eventually the bandwidth will be
      reserved when a new alternate setting is installed; for now the
      endpoint's reservation takes place when its first URB is submitted.
      
      A drawback of this approach is that transfers with an interval larger
      than 64 microframes will have to be charged for bandwidth as though
      the interval was 64.  In practice this shouldn't matter much;
      transfers with longer intervals tend to be rather short anyway (things
      like hubs or HID devices).
      
      Another minor drawback is that we will keep track of two different
      period and phase values: the actual ones and the ones used for
      bandwidth allocation (which are limited to 64).  This adds only a
      small amount of overhead: 3 bytes for each endpoint.
      
      The patch also adds a new debugfs file named "bandwidth" to display
      the information stored in the new table.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d0ce5c6b
    • A
      USB: EHCI: create a "periodic schedule info" struct · ffa0248e
      Alan Stern 提交于
      This patch begins the process of unifying the scheduling parameters
      that ehci-hcd uses for interrupt and isochronous transfers.  It
      creates an ehci_per_sched structure, which will be stored in both
      ehci_qh and ehci_iso_stream structures, and will contain the common
      scheduling information needed for both.
      
      Initially we merely create the new structure and move some existing
      fields into it.  Later patches will add more fields and utilize these
      structures in improved scheduling algorithms.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffa0248e
    • A
      USB: EHCI: use consistent NO_FRAME value · 91a99b5e
      Alan Stern 提交于
      ehci-hcd is inconsistent in the sentinel values it uses to indicate
      that no frame number has been assigned for a periodic transfer.  Some
      places it uses NO_FRAME (defined as 65535), other places it uses -1,
      and elsewhere it uses 9999.
      
      This patch defines a value for NO_FRAME which can fit in a 16-bit
      signed integer, and changes the code to use it everywhere.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      91a99b5e
    • A
      USB: EHCI: No SSPLIT allowed in uframe 7 · 8c05dc59
      Alan Stern 提交于
      The scheduling code in ehci-hcd contains an error.  For full-speed
      isochronous-OUT transfers, the EHCI spec forbids scheduling
      Start-Split transactions in H-microframe 7, but the driver allows it
      anyway.  This patch adds a check to prevent it.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c05dc59
    • A
      USB: EHCI: compute full-speed bandwidth usage correctly · 2b90f01b
      Alan Stern 提交于
      Although the bandwidth statistics maintained by ehci-hcd show up only
      in the /sys/kernel/debug/usb/devices file, they ought to be calculated
      correctly.  The calculation for full-speed isochronous endpoints is
      wrong; it mistakenly yields bytes per microframe instead of bytes per
      frame.  The "interval" value, which is in frames, should not be
      converted to microframes.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2b90f01b
    • A
      USB: EHCI: check the right uframes for CSPLIT · e24371a6
      Alan Stern 提交于
      The check_intr_schedule() routine in ehci-hcd looks at the wrong
      microframes when checking to see if a full-speed or low-speed
      interrupt endpoint will fit in the periodic schedule.  If the
      Start-Split transaction is scheduled for microframe N then the
      Complete-Split transactions get scheduled for microframes N+2, N+3, and
      N+4.  However the code considers N+1, N+2, and N+3 instead.
      
      This patch fixes the limits on the "for" loop and also improves the
      use of whitespace.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e24371a6
  6. 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
  7. 31 8月, 2013 2 次提交
  8. 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
  9. 30 5月, 2013 1 次提交
  10. 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
  11. 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
  12. 31 1月, 2013 2 次提交
  13. 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
  14. 25 10月, 2012 1 次提交
  15. 23 10月, 2012 1 次提交