[PATCH AUTOSEL 7.0-5.10] ALSA: usb-audio: add clock quirk for Motu 1248

Sasha Levin posted 1 patch 4 days, 11 hours ago
sound/usb/clock.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
[PATCH AUTOSEL 7.0-5.10] ALSA: usb-audio: add clock quirk for Motu 1248
Posted by Sasha Levin 4 days, 11 hours ago
From: Nicola Lunghi <nick83ola@gmail.com>

[ Upstream commit 320e55722ca466a7d40dd69e1aea982cb6189006 ]

The Motu 1248 (and probably other older Motu AVB interfaces) take more
than 2 seconds to switch clock. During the clock switching process the
device return that the clock is not valid. This is similar to what
already implemented for the Microbook II interface. Add the Motu
1248 usb id to the existing Motu quirk.

Signed-off-by: Nicola Lunghi <nick83ola@gmail.com>
Link: https://patch.msgid.link/20260504144520.699522-2-nick83ola@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

## Phase Walkthrough

Phase 1:
- Record 1.1: Subsystem `ALSA: usb-audio`; action verb `add`; intent is
  to add Motu 1248 USB ID `07fd:0005` to an existing clock-validity
  delay quirk.
- Record 1.2: Tags: `Signed-off-by: Nicola Lunghi`, `Link:
  https://patch.msgid.link/20260504144520.699522-2-nick83ola@gmail.com`,
  `Signed-off-by: Takashi Iwai`. No `Fixes:`, `Reported-by:`, `Tested-
  by:`, `Reviewed-by:`, or `Cc: stable`.
- Record 1.3: Commit body describes Motu 1248 returning clock-invalid
  for more than 2 seconds while switching clock, causing the existing
  ALSA clock validation to fail too early. No kernel-version range
  given.
- Record 1.4: This is a hardware quirk fix, not a hidden
  memory/synchronization bug.

Phase 2:
- Record 2.1: One file changed: `sound/usb/clock.c`, `+11/-4`. Modified
  function: `uac_clock_source_is_valid_quirk()`. Single-file surgical
  hardware quirk.
- Record 2.2: Before: the 5-second retry loop applied only to
  `USB_ID(0x07fd, 0x0004)`. After: the same loop also applies to
  `USB_ID(0x07fd, 0x0005)`, with comments expanded.
- Record 2.3: Bug category is hardware workaround/device quirk.
  Mechanism: ALSA rechecks clock validity up to 50 times with
  `msleep(100)` instead of failing on the initial transient invalid
  response.
- Record 2.4: Fix quality is high: it reuses existing code and only
  widens the device match. Regression risk is very low and limited to
  MOTU product ID `0x0005`.

Phase 3:
- Record 3.1: `git blame` shows the existing MOTU retry quirk was
  introduced by `2edb84e3047b9` in 2020. Later nearby changes came from
  clock refactoring and multi-control-interface support, but the retry
  logic remains the same.
- Record 3.2: No `Fixes:` tag, so no introducing commit to follow.
- Record 3.3: Recent `sound/usb/clock.c` history shows related clock
  fixes/refactors, but this patch is standalone and only changes the
  device match.
- Record 3.4: Author has prior usb-audio quirk commits in local history;
  Takashi Iwai applied the patch and is the ALSA maintainer/committer
  for this area.
- Record 3.5: No functional dependencies found. The patch applies
  cleanly to checked pending stable branches.

Phase 4:
- Record 4.1: `b4 dig -c 320e55722ca46` found the original submission at
  the patch.msgid.link URL. `b4 dig -a` showed only `v1`; no newer
  revision found.
- Record 4.2: `b4 dig -w` showed Nicola Lunghi, Jaroslav Kysela, Takashi
  Iwai, `linux-sound`, `linux-kernel`, and `linux-usb` were included.
- Record 4.3: `b4 mbox` showed Takashi replied “Applied now. Thanks.” No
  objections or review concerns appeared in the two-message thread.
  WebFetch of lore was blocked by Anubis.
- Record 4.4: No multi-patch series or related required patches found.
- Record 4.5: Stable-list web search was blocked by Anubis; no stable-
  specific discussion was found through the available local/b4 data.

Phase 5:
- Record 5.1: Key function: `uac_clock_source_is_valid_quirk()`.
- Record 5.2: Call path verified: `uac_clock_source_is_valid()` calls
  the quirk when the device reports invalid clock;
  `__uac_clock_find_source()` and `set_sample_rate_v2v3()` call clock
  validation; setup is reached from format parsing, stream setup,
  endpoint preparation, and sample-rate initialization.
- Record 5.3: Key callees are `snd_usb_ctl_msg()`,
  `snd_usb_find_ctrl_interface()`, `snd_usb_find_clock_source()`, and
  `msleep(100)`.
- Record 5.4: Reachability is real for users of affected USB audio
  devices during sample-rate/clock setup and PCM endpoint preparation.
- Record 5.5: Similar existing pattern is the MicroBook IIc quirk for
  the same vendor and same delayed clock-validity behavior.

Phase 6:
- Record 6.1: The existing quirk code exists in checked pending stable
  branches `pending-5.4`, `pending-5.10`, `pending-5.15`, `pending-6.1`,
  `pending-6.6`, `pending-6.12`, and `pending-7.0`.
- Record 6.2: Backport difficulty is clean: `git apply --check`
  succeeded on all those pending branches.
- Record 6.3: No alternative Motu 1248 fix was found in local
  stable/current history.

Phase 7:
- Record 7.1: Subsystem is ALSA USB audio driver. Criticality: IMPORTANT
  for users of affected MOTU hardware, not core-wide.
- Record 7.2: Subsystem is active; recent history contains multiple usb-
  audio fixes and quirks.

Phase 8:
- Record 8.1: Affected users are driver/hardware-specific: Motu 1248 and
  likely related older MOTU AVB/hybrid devices with product ID `0x0005`.
- Record 8.2: Trigger is changing sample rate or clock source, or
  validation during device/audio setup. Unprivileged trigger depends on
  local audio-device permissions; I did not verify distro policy.
- Record 8.3: Failure mode is ALSA failing clock validation early,
  returning errors such as `-ENXIO` from the code path and preventing
  successful audio setup. Severity: MEDIUM for the kernel generally,
  HIGH for affected hardware usability.
- Record 8.4: Benefit is high for affected hardware; risk is very low
  because this only enables an existing quirk for one USB product ID.

Phase 9:
- Record 9.1: Evidence for backporting: real hardware quirk, existing
  stable-accepted mechanism, small single-file change, maintainer-
  applied, cleanly applies to stable branches, external CCRMA
  documentation corroborates MOTU 1248 Linux sample-rate failures that
  succeed after waiting. Evidence against: no crash/security/data-
  corruption, no explicit stable tag, and no direct reporter/tested-by
  tag.
- Record 9.2: Stable rules: obviously correct yes; fixes real user-
  visible hardware failure yes; important enough under hardware-quirk
  exception yes; small/contained yes; no new API/features yes; applies
  cleanly yes.
- Record 9.3: Exception category: hardware quirk/workaround for broken
  device timing behavior.
- Record 9.4: Decision: backport. This is exactly the kind of low-risk
  device-specific quirk stable trees routinely take.

## Verification

- Phase 1: Parsed commit `320e55722ca46` with `git show
  --format=fuller`; verified tags and message.
- Phase 2: Verified diff with `git show --find-renames` and `--numstat`:
  `sound/usb/clock.c`, `+11/-4`.
- Phase 3: Ran `git blame -L 179,240 -- sound/usb/clock.c`; identified
  existing quirk origin `2edb84e3047b9`.
- Phase 3: Checked recent file history with `git log --oneline -20 --
  sound/usb/clock.c`.
- Phase 4: Ran `b4 dig -c 320e55722ca46`, `-a`, and `-w`; confirmed v1
  patch, recipients, and lore URL.
- Phase 4: Ran `b4 mbox`; confirmed Takashi’s “Applied now” reply and no
  objections in the fetched thread.
- Phase 5: Used `rg` and file reads to trace callers through `clock.c`,
  `format.c`, `endpoint.c`, `stream.c`, and `quirks.c`.
- Phase 6: Checked quirk presence in pending stable branches and
  verified `git apply --check` cleanly on `pending-5.4`, `pending-5.10`,
  `pending-5.15`, `pending-6.1`, `pending-6.6`, `pending-6.12`, and
  `pending-7.0`.
- Phase 8: Used WebFetch of CCRMA MOTU 1248 documentation; it reports
  Linux output/sample-rate attempts may fail initially and succeed after
  5-10 seconds.
- UNVERIFIED: Exact USB ID mapping for every model listed in the new
  comment beyond the commit’s own statement.

**YES**

 sound/usb/clock.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index 842ba5b801eae..2e0c18e352812 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -208,11 +208,18 @@ static bool uac_clock_source_is_valid_quirk(struct snd_usb_audio *chip,
 	}
 
 	/*
-	 * MOTU MicroBook IIc
-	 * Sample rate changes takes more than 2 seconds for this device. Clock
-	 * validity request returns false during that period.
+	 * Quirk for older MOTU AVB / hybrid interfaces
+	 *
+	 * These devices take more than 2 seconds to switch sample rate or
+	 * clock source. During this period the clock validity request
+	 * returns false, causing ALSA to fail prematurely.
+	 *
+	 * Affected models (all use vendor 0x07fd):
+	 *   - MicroBook IIc          → 0x0004
+	 *   - 1248, 624, 8A, UltraLite AVB, 8M, 16A, ... → 0x0005
 	 */
-	if (chip->usb_id == USB_ID(0x07fd, 0x0004)) {
+	if (chip->usb_id == USB_ID(0x07fd, 0x0004) ||  /* MicroBook IIc */
+	    chip->usb_id == USB_ID(0x07fd, 0x0005)) {  /* 1248 / 624 / 8A / UltraLite AVB / ... */
 		count = 0;
 
 		while ((!ret) && (count < 50)) {
-- 
2.53.0