The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/2] xhci: Fix isochronous scheduling gaps on CFC controllers
@ 2026-05-04 23:31 Nicola Lunghi
  2026-05-04 23:31 ` [PATCH 1/2] usb: xhci: fix isoc silent reschedule creating stream gap " Nicola Lunghi
  2026-05-04 23:31 ` [PATCH 2/2] usb: xhci: fix CFC sequential scheduling lost on ring drain race Nicola Lunghi
  0 siblings, 2 replies; 10+ messages in thread
From: Nicola Lunghi @ 2026-05-04 23:31 UTC (permalink / raw)
  To: mathias.nyman, michal.pecio, niklas.neronin, gregkh
  Cc: linux-usb, linux-kernel, Nicola Lunghi

This series addresses a long-standing issue where the xHCI driver introduces frame-aligned gaps in isochronous streams during timing fluctuations.
While many USB devices handle these gaps with a minor glitch, professional interfaces like the MOTU 1248 lose internal channel
synchronization when these gaps occur.  

I have identified two specific code paths in xhci-ring.c where these gaps are created:

Silent Rescheduling:
When a start frame is "late," the driver adds a +1 frame offset, creating an explicit hole in the stream.  

Ring Drain Race:
On CFC-capable controllers, the driver falls back to ASAP scheduling if the ring is momentarily empty,
resulting in a jump to a future frame instead of continuing sequentially.  

Impact on MOTU 1248:
The MOTU 1248 is particularly sensitive to stream continuity. The two situations described above cause a
shift in the output channels, where audio intended for one set of channels is routed to the wrong physical outputs until the device is reset.  

Proposed Solution:
This series modifies the xHCI driver to prefer sequential scheduling on modern CFC-capable controllers:

- Patch 1 removes the silent start_frame_id + 1 reschedule, returning -EINVAL to allow the use of the TRB_SIA (Schedule Immediate After) flag.  
- Patch 2 expands the CFC sequential condition to check if a periodic completion is in progress, covering the
          "ring drain" race where a new URB is submitted just as the previous one finishes.  

These changes build upon recent work by Michał Pecio regarding missed TD
handling. 

Link: https://bugzilla.kernel.org/show_bug.cgi?id=220748

Nicola Lunghi (2):
  usb: xhci: fix isoc silent reschedule creating stream gap on CFC
    controllers
  usb: xhci: fix CFC sequential scheduling lost on ring drain race

 drivers/usb/host/xhci-ring.c | 42 +++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 13 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] usb: xhci: fix isoc silent reschedule creating stream gap on CFC controllers
@ 2026-05-06 19:55 Dylan Robinson
  2026-05-07  2:25 ` Alan Stern
  2026-05-07 12:12 ` Mathias Nyman
  0 siblings, 2 replies; 10+ messages in thread
From: Dylan Robinson @ 2026-05-06 19:55 UTC (permalink / raw)
  To: mathias.nyman
  Cc: gregkh, linux-kernel, linux-usb, mathias.nyman, Michal Pecio,
	nick83ola, niklas.neronin

On 5/5/26 16:32, Mathias Nyman wrote:
> Agreed, setting start_frame to start_frame_id + 1 would only make sense for the very first URB, otherwise we create glitches.
>
> Looks like the whole start_frame_id calculation is incorrect.

I'd also like to call attention to the fact that index in
xhci_get_isoc_frame_id() refers to the isoc packet index within the
URB, not the position of the transfer in the overall stream. A driver
could (although probably shouldn't) submit multiple URBs, each
describing less than a microframe's worth of transfers, so index == 0
does not guarantee that the computation is for a frame-aligned
transfer.

Additionally, urb->start_frame is initially computed in
xhci_queue_isoc_tx_prepare(), and in the current implementation it is
validated, and potentially modified again in xhci_get_isoc_frame_id().
It is worth considering that xhci_queue_isoc_tx_prepare() computes a
start frame close to the current IST, and if the system is preempted
before xhci_queue_isoc_tx() runs and calls xhci_get_isoc_frame_id(),
that start frame may already fall outside the valid scheduling window.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-05-08 16:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 23:31 [PATCH 0/2] xhci: Fix isochronous scheduling gaps on CFC controllers Nicola Lunghi
2026-05-04 23:31 ` [PATCH 1/2] usb: xhci: fix isoc silent reschedule creating stream gap " Nicola Lunghi
2026-05-05 13:32   ` Mathias Nyman
2026-05-08 16:56   ` Michal Pecio
2026-05-04 23:31 ` [PATCH 2/2] usb: xhci: fix CFC sequential scheduling lost on ring drain race Nicola Lunghi
  -- strict thread matches above, loose matches on Subject: below --
2026-05-06 19:55 [PATCH 1/2] usb: xhci: fix isoc silent reschedule creating stream gap on CFC controllers Dylan Robinson
2026-05-07  2:25 ` Alan Stern
2026-05-07  9:59   ` Dylan Robinson
2026-05-07 12:12 ` Mathias Nyman
2026-05-07 16:58   ` Dylan Robinson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox