From: bugzilla-daemon@kernel.org
To: linux-usb@vger.kernel.org
Subject: [Bug 220748] usb: xhci_queue_isoc_tx_prepare ignore start_frame and always assumes URB_ISO_ASAP is set
Date: Tue, 05 May 2026 09:59:55 +0000 [thread overview]
Message-ID: <bug-220748-208809-lAJJBzltMC@https.bugzilla.kernel.org/> (raw)
In-Reply-To: <bug-220748-208809@https.bugzilla.kernel.org/>
https://bugzilla.kernel.org/show_bug.cgi?id=220748
--- Comment #21 from Michał Pecio (michal.pecio@gmail.com) ---
Thanks for taking the time to explain.
(In reply to dylan_robinson from comment #20)
> The issue, as it relates to the MOTU devices mentioned here, is that after
> enabling a non-zero alternate setting with usb_set_interface(), once a
> transfer is sent in a service interval (zero-length or otherwise), there
> must be a transfer in every subsequent service interval. If, for any reason,
> a service interval is missed, the alternate setting must be toggled back to
> zero and then re-enabled, and the stream restarted.
That would be something for snd-usb-audio to do.
Does the same apply to missed service on IN endpoints?
Or IN endpoints with lost/corrupted packets?
And for the record, are you saying there is no hope to predict what the HW
expects to send and receive in the next interval and handle it right? Users say
that streams go out of sync but the HW continues to function in some manner.
> MOTU's drivers on Windows and macOS take advantage of the ability on those
> platforms to schedule the start frame of isochronous streams sufficiently
> far into the future to ensure that enough URBs can be submitted before the
> first URB completes.
>
> On Linux, I have found that with snd-usb-audio, it is fairly typical for
> streams to "stutter start." Because of the ASAP/SIA behavior discussed
> above, when the first URB is submitted, it can sometimes complete before
> subsequent URBs are enqueued. This creates a gap in the stream and causes
> the device buffers to fall out of sync.
I remember noticing this tendency to restart streams (unlink and resubmit URBs)
during startup with short buffers/low latency, presumably without going through
altsetting 0. So I can see how this can be a problem. IIRC it was at least
partly due xhci-hcd scheduling too far into the future. I will try to find some
time to look into it again.
> At one point, I investigated monitoring the start_frame in the completion
> handler, but on non-CFC controllers it was not reliable (there were many
> duplicated frame numbers or gaps that did not reflect reality).
These fields are filled by xhci-hcd so they may be bogus due to bugs.
For reliable information it's better to log "Frame ID" written to Isoch TDs and
MFINDEX register in process_isoc_td() (sensitive only to IRQ latency).
IIRC, on non-CFC even if things are initially right, they may fall out of sync
due to missed service, with the MSE event being the only sign of trouble.
> Although more recent MOTU devices have improved buffer management and won't
> fall out of sync due to missed intervals, the ability to specify a start
> frame is still important for reasoning about the timing relationship between
> IN and OUT streams, which helps guarantee consistent round-trip latency.
The "Linux way" appears to be guaranteeing two things to drivers:
- start_frame in completed URBs accurately reflects the time of execution
- streams are always continuous - even if an interval is missed, the next URB
frame reliably completes (or is missed) in the next interval
For continuity, class driver only needs to ensure that the URB is resubmitted
from its completion handler. If that happens several ms later, the URB is
expected to immediately "complete in the past" with EXDEV.
AFAIK that's how ehci-hcd does it, but xhci-hcd doesn't and maybe should.
Wouldn't this be enough to make IN/OUT synchronization work?
What's people's experience using MOTU HW and audio in general on ehci-hcd?
> > I wonder if this could be the reason for some weird snd-usb-audio behavior
> > reported in the past (repeatedly unlinking and retrying URBs for unclear
> > reason when running full-duplex with very low latency). But it's just a
> wild
> > guess.
>
> This sounds like an issue I just started investigating. I am exploring the
> possibility that when an isochronous endpoint is restarted quickly on a CFC
> host (all URBs are killed and immediately then resubmitted), if the new URBs
> are submitted before all TRBs have been dequeued, their start_frame values
> may be set as if they were contiguous with the canceled TRBs. This might be
> causing the entire batch to fail with missed service intervals. This then
> happens over and over again.
IIRC the repeated unlink/resubmit cycles during startup were due to
snd-usb-audio getting some "xrun" callback from ALSA core for some reason. Then
it would unlink everything and try again. I didn't know why it happens.
New URBs may be contiguous with past ones if you don't wait for them to
complete
after usb_unlink_urb(). OTOH, usb_kill_urb() is synchronous. Once all URBs are
killed synchronously or completed (including due to unlink) and the queue is
empty, then submitting a new URB should schedule it far enough into the future
to ensure no missed service. That's the theory.
See usb_submit_urb() and usb_unlink_urb() comments in drivers/usb/core/urb.c
--
You may reply to this email to add a comment.
You are receiving this mail because:
You are watching the assignee of the bug.
next prev parent reply other threads:[~2026-05-05 9:59 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 21:25 [Bug 220748] New: usb: xhci_queue_isoc_tx_prepare ignore start_frame and always assumes URB_ISO_ASAP is set bugzilla-daemon
2025-11-05 8:40 ` [Bug 220748] " bugzilla-daemon
2025-11-05 8:48 ` bugzilla-daemon
2025-11-05 8:53 ` bugzilla-daemon
2025-11-05 9:06 ` bugzilla-daemon
2025-11-05 15:47 ` bugzilla-daemon
2025-11-05 18:28 ` bugzilla-daemon
2025-11-05 18:30 ` bugzilla-daemon
2025-11-05 20:16 ` bugzilla-daemon
2025-11-05 21:18 ` bugzilla-daemon
2025-11-06 3:52 ` bugzilla-daemon
2025-11-06 8:27 ` bugzilla-daemon
2025-11-06 8:35 ` bugzilla-daemon
2025-11-06 15:03 ` bugzilla-daemon
2025-11-08 10:33 ` bugzilla-daemon
2025-11-08 16:09 ` bugzilla-daemon
2025-11-10 10:23 ` bugzilla-daemon
2025-11-10 10:42 ` bugzilla-daemon
2026-05-04 23:53 ` bugzilla-daemon
2026-05-04 23:54 ` bugzilla-daemon
2026-05-05 1:14 ` bugzilla-daemon
2026-05-05 9:59 ` bugzilla-daemon [this message]
2026-05-05 17:09 ` bugzilla-daemon
2026-05-05 17:10 ` bugzilla-daemon
2026-05-05 17:10 ` bugzilla-daemon
2026-05-05 17:13 ` bugzilla-daemon
2026-05-06 13:32 ` bugzilla-daemon
2026-05-06 15:03 ` bugzilla-daemon
2026-05-07 2:38 ` Alan Stern
2026-05-07 16:17 ` Dylan Robinson
2026-05-07 17:24 ` Alan Stern
2026-05-07 21:16 ` Dylan Robinson
2026-05-08 3:02 ` Alan Stern
2026-05-08 17:20 ` Dylan Robinson
2026-05-09 1:25 ` Alan Stern
2026-05-09 22:12 ` Michal Pecio
2026-05-10 12:39 ` Dylan Robinson
2026-05-11 19:21 ` [RFT PATCH] xhci: fix frame id calculation for isoc transfer Mathias Nyman
2026-05-11 19:36 ` Mathias Nyman
2026-05-07 21:54 ` [Bug 220748] usb: xhci_queue_isoc_tx_prepare ignore start_frame and always assumes URB_ISO_ASAP is set Michal Pecio
2026-05-08 3:09 ` Alan Stern
2026-05-08 9:41 ` Michal Pecio
2026-05-08 14:54 ` Alan Stern
2026-05-08 21:39 ` Dylan Robinson
2026-05-09 11:10 ` Michal Pecio
2026-05-09 20:18 ` Dylan Robinson
2026-05-11 19:15 ` bugzilla-daemon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-220748-208809-lAJJBzltMC@https.bugzilla.kernel.org/ \
--to=bugzilla-daemon@kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox