All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb-audio: Fix boot-time crackling for Generic USB Audio device
@ 2026-07-13  8:10 Zhang Heng
  2026-07-13 13:20 ` Gordon Chen
  0 siblings, 1 reply; 8+ messages in thread
From: Zhang Heng @ 2026-07-13  8:10 UTC (permalink / raw)
  To: perex, tiwai
  Cc: kees, chengordon326, jussi, hulianqin, i, g, cryolitia, pav,
	linux-sound, linux-kernel, Zhang Heng

The Generic USB Audio device (0x1e0b:d01e) produces crackling noise during
system boot when the boot music plays. The issue disappears once the system
has fully started.

Kernel logs show xhci-ring warnings when the device initializes:
[    2.836118] usb 1-3: New USB device found, idVendor=1e0b, idProduct=d01e
[    9.654586] xhci_hcd 0000:03:00.3: Frame ID 644 (reg 5154, index 13) beyond range (645, 1539)
[    9.654589] xhci_hcd 0000:03:00.3: Ignore frame ID field, use SIA bit instead
[    9.655053] xhci_hcd 0000:03:00.3: Frame ID 644 (reg 5158, index 14) beyond range (645, 1539)
[    9.655055] xhci_hcd 0000:03:00.3: Ignore frame ID field, use SIA bit instead

These warnings are generated by xhci_get_isoc_frame_id() in xhci-ring.c.
Data endpoints have multiple TDs per URB (number_of_packets > 1). For TD
index=0, the function adjusts start_frame to a valid range when validation
fails. However, for TD index>0, the calculated Frame IDs become stale
before validation completes, causing xhci_get_isoc_frame_id() to return
-EINVAL and trigger a fallback to SIA (Schedule Information Address) mode
for those TDs. This inconsistent scheduling between index=0 TD (direct
Frame ID) and index>0 TDs (SIA mode) within the same data endpoint causes
audio data misalignment and crackling noise during boot.

Sync endpoints have only one TD per URB (number_of_packets = 1), so they
don't suffer from this mixed scheduling issue.

Fix by setting URB_ISO_ASAP flag for the data endpoint of this specific
device. This flag causes the xHCI driver to skip Frame ID calculation
entirely and let hardware schedule via SIA bit for all TDs, ensuring
consistent scheduling within the data endpoint. Also add a quirk to skip
the first 4 packets on the sync endpoint.

Signed-off-by: Zhang Heng <zhangheng@kylinos.cn>
---
 sound/usb/endpoint.c | 3 +++
 sound/usb/quirks.c   | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 24cd7692bd01..6a6a6797ac4b 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -1256,6 +1256,9 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep)
 			goto out_of_memory;
 		u->urb->pipe = ep->pipe;
 		u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
+		/* Generic USB Audio (0x1e0b:d01e): use SIA for consistent scheduling */
+		if (ep->chip->usb_id == USB_ID(0x1e0b, 0xd01e))
+			u->urb->transfer_flags |= URB_ISO_ASAP;
 		u->urb->interval = 1 << ep->datainterval;
 		u->urb->context = u;
 		u->urb->complete = snd_complete_urb;
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 2949a0d2d961..52a4fd352ea2 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1938,6 +1938,14 @@ void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep)
 	    ep->type == SND_USB_ENDPOINT_TYPE_SYNC)
 		ep->skip_packets = 4;
 
+	/*
+	 * Generic USB Audio (0x1e0b:d01e) - skip initial sync packets
+	 * to avoid crackling noise during system boot
+	 */
+	if (ep->chip->usb_id == USB_ID(0x1e0b, 0xd01e) &&
+	    ep->type == SND_USB_ENDPOINT_TYPE_SYNC)
+		ep->skip_packets = 4;
+
 	/*
 	 * M-Audio Fast Track C400/C600 - when packets are not skipped, real
 	 * world latency varies by approx. +/- 50 frames (at 96kHz) each time
-- 
2.25.1


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

end of thread, other threads:[~2026-07-14 13:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13  8:10 [PATCH] usb-audio: Fix boot-time crackling for Generic USB Audio device Zhang Heng
2026-07-13 13:20 ` Gordon Chen
2026-07-13 15:05   ` Takashi Iwai
2026-07-14 13:09     ` Zhang Heng
2026-07-14  1:58   ` Zhang Heng
2026-07-14  7:40     ` Takashi Iwai
2026-07-14 13:02       ` Zhang Heng
2026-07-14 13:38         ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.