Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Zhang Heng <zhangheng@kylinos.cn>
Cc: Takashi Iwai <tiwai@suse.de>,
	Gordon Chen <chengordon326@gmail.com>,
	perex@perex.cz, tiwai@suse.com, kees@kernel.org,
	jussi@sonarnerd.net, hulianqin@vivo.com, i@rong.moe, g@b4.vu,
	cryolitia@uniontech.com, pav@iki.fi, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb-audio: Fix boot-time crackling for Generic USB Audio device
Date: Sun, 19 Jul 2026 10:54:50 +0200	[thread overview]
Message-ID: <878q77s6jp.wl-tiwai@suse.de> (raw)
In-Reply-To: <d77254b3-1e6f-483e-8c03-b8f1e033d7a0@kylinos.cn>

On Tue, 14 Jul 2026 15:09:46 +0200,
Zhang Heng wrote:
> 
> 
> From 11c25cb49a0a233fda643b2eb6c0bca7bc726d37 Mon Sep 17 00:00:00 2001
> From: Zhang Heng <zhangheng@kylinos.cn>
> Date: Tue, 14 Jul 2026 17:55:54 +0800
> Subject: [PATCH] ALSA: usb-audio: Fix boot-time crackling for Generic USB
>  Audio device
> 
> 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:
> [    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 indicate that xhci_get_isoc_frame_id() returns -EINVAL for
> TDs at index > 0 because their calculated Frame IDs become stale before
> validation completes. This causes a fallback to SIA mode for those TDs,
> while index=0 TD uses direct Frame ID. The resulting mixed scheduling within
> the same data endpoint causes audio data misalignment and crackling.
> 
> Fix by adding QUIRK_FLAG_ISO_ASAP and setting URB_ISO_ASAP flag for the
> data endpoint. This ensures all TDs use consistent SIA scheduling. Also add
> a quirk to skip the first 4 sync packets, as some devices send incorrect
> feedback data during stream startup.
> 
> Using the quirk mechanism keeps endpoint.c device-agnostic and allows easy
> addition of new devices with the same symptom.
> 
> Signed-off-by: Zhang Heng <zhangheng@kylinos.cn>
> ---
> v1->v2:
>  
> - Replace hardcoded USB ID check in endpoint.c with QUIRK_FLAG_ISO_ASAP
> - Add QUIRK_TYPE_ISO_ASAP = 31 enum and QUIRK_FLAG_ISO_ASAP macro in usbaudio.h
> - Add device entry to quirk_flags_table in quirks.c for Generic USB Audio (0x1e0b:d01e)
> - Add ISO_ASAP string entry to snd_usb_audio_quirk_flag_names
> - Add documentation comment for QUIRK_FLAG_ISO_ASAP in usbaudio.h
> - Keep endpoint.c device-agnostic, allowing easy addition of new devices
> 
>  sound/usb/endpoint.c | 2 ++
>  sound/usb/quirks.c   | 8 ++++++++
>  sound/usb/usbaudio.h | 8 ++++++++
>  3 files changed, 18 insertions(+)
> 
> diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
> index 24cd7692bd01..155b3858dac9 100644
> --- a/sound/usb/endpoint.c
> +++ b/sound/usb/endpoint.c
> @@ -1256,6 +1256,8 @@ 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;
> +		if (ep->chip->quirk_flags & QUIRK_FLAG_ISO_ASAP)
> +			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..f5e5b662bfd3 100644
> --- a/sound/usb/quirks.c
> +++ b/sound/usb/quirks.c
> @@ -1938,6 +1938,10 @@ void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep)
>  	    ep->type == SND_USB_ENDPOINT_TYPE_SYNC)
>  		ep->skip_packets = 4;
>  
> +	if (ep->chip->usb_id == USB_ID(0x1e0b, 0xd01e) &&
> +	    ep->type == SND_USB_ENDPOINT_TYPE_SYNC)
> +		ep->skip_packets = 4;
> +

Please add some comment why the device needs this workaround.
IIUC, the reason is different from the others in your case.

Also, please verify that the problem is reproduced in the latest
upstream kernel, and the workaround works as expected there, too.


thanks,

Takashi

  reply	other threads:[~2026-07-19  8:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-19  8:54       ` Takashi Iwai [this message]
2026-07-20  2:23         ` Zhang Heng
2026-07-20  6:39           ` Takashi Iwai
2026-07-20  9:34             ` Zhang Heng
2026-07-20  9:40             ` Zhang Heng
2026-07-20  9:58             ` 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

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=878q77s6jp.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=chengordon326@gmail.com \
    --cc=cryolitia@uniontech.com \
    --cc=g@b4.vu \
    --cc=hulianqin@vivo.com \
    --cc=i@rong.moe \
    --cc=jussi@sonarnerd.net \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=pav@iki.fi \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=zhangheng@kylinos.cn \
    /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