* [PATCH v2 0/2] ALSA: usb-audio: Fix Solid State Logic SSL 12 192 kHz duplex
@ 2026-12-05 19:29 Lee Volkov
2026-12-05 19:29 ` [PATCH v2 1/2] ALSA: usb-audio: Filter invalid capture rates on Solid State Logic SSL 12 Lee Volkov
2026-12-05 19:29 ` [PATCH v2 2/2] ALSA: usb-audio: Reuse active sync endpoint format for implicit feedback Lee Volkov
0 siblings, 2 replies; 4+ messages in thread
From: Lee Volkov @ 2026-12-05 19:29 UTC (permalink / raw)
To: Takashi Iwai, Jaroslav Kysela; +Cc: linux-sound, linux-kernel, Lee Volkov
This two-patch series fixes 176.4/192 kHz full-duplex operation with
implicit feedback on the Solid State Logic SSL 12 (USB ID 31e9:0005):
1. Filter out sample rates above 96 kHz for capture Altsets 1 (16 ch)
and 2 (12 ch), whose 1024-byte wMaxPacketSize cannot fit 176.4/192 kHz
microframes, leaving Altset 3 (10 ch, 1000 B) and playback (Altset 1,
8 ch, 800 B) able to operate up to 192 kHz.
2. Reuse an already opened compatible cur_audiofmt on the shared sync
endpoint in snd_usb_find_implicit_fb_sync_format() so starting
playback while 10ch Altset 3 capture is open at 48/96/192 kHz keeps
implicit feedback enabled instead of failing with -EINVAL.
Tested on SSL 12 (31e9:0005) on Linux 7.2.10 with direct ALSA duplex
(both stream open orders at 192 kHz (10ch) and 48/96 kHz (16ch), and
capture-first duplex at 48/96 kHz (10ch)) and PipeWire/WirePlumber
rate transitions (192000 <-> 48000 <-> 96000 Hz) with implicit feedback
active and no xHCI/USB errors.
Changes in v2:
- Patch 2: drop superfluous #include <linux/cleanup.h> (Takashi Iwai).
- Patch 2: pass subs->sync_endpoint (ref_ep) to
snd_usb_find_implicit_fb_sync_format() and check
(ep != ref_ep || ep->opened > 1) before reusing ep->cur_audiofmt so
a repeated hw_params() call without hw_free() cannot pin a stale
sync format (Sashiko AI review / Takashi Iwai).
- Patch 1: unchanged.
Lee Volkov (2):
ALSA: usb-audio: Filter invalid capture rates on Solid State Logic SSL
12
ALSA: usb-audio: Reuse active sync endpoint format for implicit
feedback
sound/usb/format.c | 30 ++++++++++++++++++++++++++++++
sound/usb/implicit.c | 25 ++++++++++++++++++++++++-
sound/usb/implicit.h | 6 +++++-
sound/usb/pcm.c | 1 +
4 files changed, 60 insertions(+), 2 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2 1/2] ALSA: usb-audio: Filter invalid capture rates on Solid State Logic SSL 12 2026-12-05 19:29 [PATCH v2 0/2] ALSA: usb-audio: Fix Solid State Logic SSL 12 192 kHz duplex Lee Volkov @ 2026-12-05 19:29 ` Lee Volkov 2026-12-05 19:29 ` [PATCH v2 2/2] ALSA: usb-audio: Reuse active sync endpoint format for implicit feedback Lee Volkov 1 sibling, 0 replies; 4+ messages in thread From: Lee Volkov @ 2026-12-05 19:29 UTC (permalink / raw) To: Takashi Iwai, Jaroslav Kysela Cc: linux-sound, linux-kernel, Lee Volkov, stable The Solid State Logic SSL 12 (USB ID 31e9:0005) exposes three capture altsettings on interface 2 (EP 0x81 IN, bInterval 1, 32-bit PCM), all sharing the same UAC2 clock source that advertises sample rates up to 192 kHz: Altset 1: 16 channels, wMaxPacketSize 0x0400 (1x 1024 bytes) Altset 2: 12 channels, wMaxPacketSize 0x0400 (1x 1024 bytes) Altset 3: 10 channels, wMaxPacketSize 0x03e8 (1x 1000 bytes) On a 125 us high-speed microframe, 176.4/192 kHz requires 22-25 frames per microframe. At 4 bytes per sample, 16 channels need 1408-1600 bytes and 12 channels need 1056-1200 bytes, exceeding wMaxPacketSize (1024 B) and causing xHCI buffer overruns and stream failures when Altset 1 or 2 is opened above 96 kHz. Only Altset 3 (10 channels, up to 1000 bytes at 25 frames) fits 176.4/192 kHz. Playback (interface 1, Altset 1, EP 0x01 OUT, 8 channels, wMaxPacketSize 800 bytes) supports all rates up to 192 kHz. Filter out sample rates above 96 kHz for capture Altsets 1 and 2 on SSL 12 using the existing skip_rate path, leaving Altset 3 and playback able to use the full rate range up to 192 kHz. Cc: stable@vger.kernel.org Signed-off-by: Lee Volkov <voilthuman@gmail.com> --- sound/usb/format.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sound/usb/format.c b/sound/usb/format.c index e2219aeb9..51e60928f 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -309,6 +309,31 @@ static bool s1810c_valid_sample_rate(struct audioformat *fp, return false; } +/* + * Solid State Logic SSL 12 reports all sample rates (up to 192 kHz) for every + * capture altsetting, even though Altset 1 (16 ch, wMaxPacketSize 1024) and + * Altset 2 (12 ch, wMaxPacketSize 1024) exceed their 125 us microframe packet + * limit above 96 kHz. Only Altset 3 (10 ch, wMaxPacketSize 1000) fits + * 176.4/192 kHz. Playback (EP 0x01, 8 ch, wMaxPacketSize 800) supports all + * rates up to 192 kHz. + */ +static bool ssl12_valid_sample_rate(const struct audioformat *fp, + unsigned int rate) +{ + if (fp->endpoint != (USB_DIR_IN | 1)) + return true; + + switch (fp->altsetting) { + case 1: + case 2: + return rate <= 96000; + case 3: + return true; + default: + return false; + } +} + /* * Focusrite devices use rate pairs: 44100/48000, 88200/96000, and * 176400/192000. Return true if rate is in the pair for max_rate. @@ -470,6 +495,11 @@ static int parse_uac2_sample_rate_range(struct snd_usb_audio *chip, !focusrite_valid_sample_rate(chip, fp, rate)) goto skip_rate; + /* Filter out invalid rates on Solid State Logic SSL 12 */ + if (chip->usb_id == USB_ID(0x31e9, 0x0005) && + !ssl12_valid_sample_rate(fp, rate)) + goto skip_rate; + if (fp->rate_table) fp->rate_table[nr_rates] = rate; nr_rates++; -- 2.55.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] ALSA: usb-audio: Reuse active sync endpoint format for implicit feedback 2026-12-05 19:29 [PATCH v2 0/2] ALSA: usb-audio: Fix Solid State Logic SSL 12 192 kHz duplex Lee Volkov 2026-12-05 19:29 ` [PATCH v2 1/2] ALSA: usb-audio: Filter invalid capture rates on Solid State Logic SSL 12 Lee Volkov @ 2026-12-05 19:29 ` Lee Volkov 2026-12-05 19:53 ` sashiko-bot 1 sibling, 1 reply; 4+ messages in thread From: Lee Volkov @ 2026-12-05 19:29 UTC (permalink / raw) To: Takashi Iwai, Jaroslav Kysela Cc: linux-sound, linux-kernel, Lee Volkov, stable On devices where implicit feedback shares a capture endpoint with multiple altsettings (such as Solid State Logic SSL 12, where 16/12ch capture altsets support up to 96 kHz and 10ch Altset 3 supports up to 192 kHz), opening capture on a non-first altsetting (e.g. Altset 3 at 48 or 96 kHz) and then starting playback triggers a failure: snd_usb_find_implicit_fb_sync_format() scans subs->fmt_list from the first entry and picks Altset 1 because it also matches the rate and channel-agnostic check, ignoring that the shared sync endpoint is already open in Altset 3. snd_usb_endpoint_open() then rejects the mismatch in endpoint_compatible() and fails playback with -EINVAL ("Incompatible EP setup for 0x81"). Pass the caller's current subs->sync_endpoint (ref_ep) so we look up the live sync endpoint with snd_usb_get_endpoint() under chip->mutex and only reuse ep->cur_audiofmt when it is in use by another stream (ep != ref_ep || ep->opened > 1). This prevents a repeated hw_params() call without hw_free() from pinning the sync endpoint to the caller's own about-to-be-closed format. Fixes: 5d15f1eb4560 ("ALSA: usb-audio: Choose audioformat of a counter-part substream") Cc: stable@vger.kernel.org Signed-off-by: Lee Volkov <voilthuman@gmail.com> --- Changes in v2: - Drop superfluous #include <linux/cleanup.h> (Takashi Iwai). - Pass subs->sync_endpoint as ref_ep from snd_usb_hw_params() and check (ep != ref_ep || ep->opened > 1) before reusing ep->cur_audiofmt so a repeated hw_params() call without hw_free() does not reuse the caller's own about-to-be-closed sync format (Sashiko AI review). sound/usb/implicit.c | 25 ++++++++++++++++++++++++- sound/usb/implicit.h | 6 +++++- sound/usb/pcm.c | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/sound/usb/implicit.c b/sound/usb/implicit.c index bd4d569a8..755df2b1d 100644 --- a/sound/usb/implicit.c +++ b/sound/usb/implicit.c @@ -16,6 +16,7 @@ #include "card.h" #include "helper.h" #include "pcm.h" +#include "endpoint.h" #include "implicit.h" enum { @@ -459,10 +460,12 @@ snd_usb_find_implicit_fb_sync_format(struct snd_usb_audio *chip, const struct audioformat *target, const struct snd_pcm_hw_params *params, int stream, + const struct snd_usb_endpoint *ref_ep, bool *fixed_rate) { struct snd_usb_substream *subs; - const struct audioformat *fp, *sync_fmt = NULL; + struct snd_usb_endpoint *ep; + const struct audioformat *fp, *sync_fmt = NULL, *active_fmt = NULL; int score, high_score; /* Use the original audioformat as fallback for the shared altset */ @@ -475,6 +478,26 @@ snd_usb_find_implicit_fb_sync_format(struct snd_usb_audio *chip, if (!subs) goto end; + /* + * If the shared sync endpoint is already open by another stream in a + * compatible format, reuse that active audioformat instead of picking + * another altsetting and failing endpoint_compatible() later. + */ + scoped_guard(mutex, &chip->mutex) { + ep = snd_usb_get_endpoint(chip, target->sync_ep); + if (ep && ep->opened && ep->cur_audiofmt && + (ep != ref_ep || ep->opened > 1) && + match_endpoint_audioformats(subs, ep->cur_audiofmt, + params_rate(params), + params_channels(params), + params_format(params))) + active_fmt = ep->cur_audiofmt; + } + if (active_fmt) { + sync_fmt = active_fmt; + goto end; + } + high_score = 0; list_for_each_entry(fp, &subs->fmt_list, list) { score = match_endpoint_audioformats(subs, fp, diff --git a/sound/usb/implicit.h b/sound/usb/implicit.h index 7f1577b6c..554f70a77 100644 --- a/sound/usb/implicit.h +++ b/sound/usb/implicit.h @@ -5,10 +5,14 @@ int snd_usb_parse_implicit_fb_quirk(struct snd_usb_audio *chip, struct audioformat *fmt, struct usb_host_interface *alts); +struct snd_usb_endpoint; + const struct audioformat * snd_usb_find_implicit_fb_sync_format(struct snd_usb_audio *chip, const struct audioformat *target, const struct snd_pcm_hw_params *params, - int stream, bool *fixed_rate); + int stream, + const struct snd_usb_endpoint *ref_ep, + bool *fixed_rate); #endif /* __USBAUDIO_IMPLICIT_H */ diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 57a26492d..5f19cbf25 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -507,6 +507,7 @@ int snd_usb_hw_params(struct snd_usb_substream *subs, sync_fmt = snd_usb_find_implicit_fb_sync_format(chip, fmt, hw_params, !subs->direction, + subs->sync_endpoint, &sync_fixed_rate); if (!sync_fmt) { usb_audio_dbg(chip, -- 2.55.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] ALSA: usb-audio: Reuse active sync endpoint format for implicit feedback 2026-12-05 19:29 ` [PATCH v2 2/2] ALSA: usb-audio: Reuse active sync endpoint format for implicit feedback Lee Volkov @ 2026-12-05 19:53 ` sashiko-bot 0 siblings, 0 replies; 4+ messages in thread From: sashiko-bot @ 2026-12-05 19:53 UTC (permalink / raw) To: Lee Volkov; +Cc: linux-sound Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] ALSA: usb-audio: active sync_fmt reuse may open wrong endpoint - [Medium] ALSA: usb-audio: active sync_fmt reuse allows conflicting shared iface altsets - [Medium] sound/usb: TOCTOU between sync format lookup and snd_usb_endpoint_open() - [Low] ALSA: usb-audio: Fixes tag should cite bf6313a0ff76 instead of 5d15f1eb4560 - [Low] ALSA: usb-audio: unlocked read of subs->sync_endpoint in snd_usb_hw_params() -- commit 53b72b9d9802712afce88d75226c95a44262bed2 Author: Lee Volkov <voilthuman@gmail.com> > ALSA: usb-audio: Reuse active sync endpoint format for implicit feedback > > On devices where implicit feedback shares a capture endpoint with > multiple altsettings (such as Solid State Logic SSL 12, where 16/12ch > capture altsets support up to 96 kHz and 10ch Altset 3 supports up to > 192 kHz), opening capture on a non-first altsetting (e.g. Altset 3 at > 48 or 96 kHz) and then starting playback triggers a failure: > > snd_usb_find_implicit_fb_sync_format() scans subs->fmt_list from the > first entry and picks Altset 1 because it also matches the rate and > channel-agnostic check, ignoring that the shared sync endpoint is > already open in Altset 3. snd_usb_endpoint_open() then rejects the > mismatch in endpoint_compatible() and fails playback with -EINVAL > ("Incompatible EP setup for 0x81"). > > Pass the caller's current subs->sync_endpoint (ref_ep) so we look up the > live sync endpoint with snd_usb_get_endpoint() under chip->mutex and > only reuse ep->cur_audiofmt when it is in use by another stream > (ep != ref_ep || ep->opened > 1). This prevents a repeated hw_params() > call without hw_free() from pinning the sync endpoint to the caller's > own about-to-be-closed format. > > Fixes: 5d15f1eb4560 ("ALSA: usb-audio: Choose audioformat of a counter-part substream") > Cc: stable@vger.kernel.org > Signed-off-by: Lee Volkov <voilthuman@gmail.com> [Severity: Low] Should the Fixes tag cite bf6313a0ff76 ("ALSA: usb-audio: Refactor endpoint management") instead of 5d15f1eb4560 ("ALSA: usb-audio: Choose audioformat of a counter-part substream")? Commit 5d15f1eb4560 only changed the shared-altset fallback branch in snd_usb_find_implicit_fb_sync_format(). Scanning subs->fmt_list without checking the active sync endpoint format and rejecting mismatches in endpoint_compatible() was introduced by bf6313a0ff76 and later factored out into sound/usb/implicit.c by 9fddc15e8039 ("ALSA: usb-audio: Factor out the implicit feedback quirk code"). > diff --git a/sound/usb/implicit.c b/sound/usb/implicit.c > index bd4d569a8190c..755df2b1d2e53 100644 > --- a/sound/usb/implicit.c > +++ b/sound/usb/implicit.c [ ... ] > @@ -475,6 +478,26 @@ snd_usb_find_implicit_fb_sync_format(struct snd_usb_audio *chip, > if (!subs) > goto end; > > + /* > + * If the shared sync endpoint is already open by another stream in a > + * compatible format, reuse that active audioformat instead of picking > + * another altsetting and failing endpoint_compatible() later. > + */ > + scoped_guard(mutex, &chip->mutex) { > + ep = snd_usb_get_endpoint(chip, target->sync_ep); > + if (ep && ep->opened && ep->cur_audiofmt && > + (ep != ref_ep || ep->opened > 1) && > + match_endpoint_audioformats(subs, ep->cur_audiofmt, > + params_rate(params), > + params_channels(params), > + params_format(params))) > + active_fmt = ep->cur_audiofmt; > + } > + if (active_fmt) { > + sync_fmt = active_fmt; > + goto end; > + } [Severity: Medium] Can returning ep->cur_audiofmt without checking membership in subs->fmt_list cause snd_usb_hw_params() to open the wrong endpoint? snd_usb_hw_params() calls snd_usb_endpoint_open() with is_sync_ep set to (fmt == sync_fmt), which selects fp->endpoint when false: sound/usb/endpoint.c:snd_usb_endpoint_open() { ... int ep_num = is_sync_ep ? fp->sync_ep : fp->endpoint; ... } If another stream already opened target->sync_ep with is_sync_ep = true (for example via the shared-altset fallback or explicit sync), ep->cur_audiofmt points to that stream's format (fmt1) where fmt1->endpoint is its data endpoint rather than target->sync_ep. Returning fmt1 makes fmt == sync_fmt false, so snd_usb_endpoint_open() opens fmt1->endpoint and binds the other stream's outbound endpoint as sync_source, stalling implicit-feedback playback. This also bypasses find_matching_substream()'s fmt_type filter when another fmt_type stream holds target->sync_ep. Snapshotting active_fmt = ep->cur_audiofmt under chip->mutex and matching fp == active_fmt inside the existing subs->fmt_list loop would guarantee both endpoint and fmt_type match. [Severity: Medium] Can reusing ep->cur_audiofmt allow playback and capture to open different altsettings on a shared USB interface? On devices where playback and capture share one USB interface with multiple altsettings, capture can open Altset 2 while playback later requests Altset 1 at the same sample rate and PCM format. Because match_endpoint_audioformats() still returns non-zero when channels differ, this returns capture's Altset 2 format instead of letting endpoint_compatible() reject the mismatch with -EINVAL. snd_usb_endpoint_open() increments iface_ref->opened without checking for altsetting mismatches, and snd_usb_endpoint_prepare() skips endpoint_set_interface() once iface_ref->need_setup is false, leaving the interface in Altset 2 while playback submits Altset 1 URBs. Reusing ep->cur_audiofmt only when ep->cur_audiofmt->iface != target->iface || ep->cur_audiofmt->altsetting == target->altsetting avoids this. [Severity: Medium] Can a concurrent capture hw_params() race with this lookup and still fail playback with -EINVAL? snd_usb_hw_params() drops chip->mutex here and then runs blocking USB autoresume, power-domain, stop/drain, and close_endpoints() operations before opening subs->sync_endpoint under a separate chip->mutex acquisition: CPU0 (playback) CPU1 (capture) snd_usb_hw_params() snd_usb_find_implicit_fb_sync_format() lock(&chip->mutex) ep->opened == 0 -> Altset 1 unlock(&chip->mutex) snd_usb_lock_shutdown() snd_usb_autoresume() (blocks) snd_usb_hw_params() ... snd_usb_endpoint_open() ep->cur_audiofmt = Altset 3 snd_usb_endpoint_open(Altset 1) endpoint_compatible() <-- fails with -EINVAL The same window affects repeated playback hw_params() without hw_free() if capture opens ep before close_endpoints() runs. Resolving the active format under the same chip->mutex acquisition that opens subs->sync_endpoint (after close_endpoints()) would eliminate this race. [ ... ] > diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > index 57a26492dd614..5f19cbf2557c5 100644 > --- a/sound/usb/pcm.c > +++ b/sound/usb/pcm.c > @@ -507,6 +507,7 @@ int snd_usb_hw_params(struct snd_usb_substream *subs, > sync_fmt = snd_usb_find_implicit_fb_sync_format(chip, fmt, > hw_params, > !subs->direction, > + subs->sync_endpoint, > &sync_fixed_rate); > if (!sync_fmt) { > usb_audio_dbg(chip, [Severity: Low] Does reading subs->sync_endpoint here race with snd_usb_stream_disconnect() under KCSAN? snd_usb_hw_params() has not yet called snd_usb_lock_shutdown(chip) at this point, while __usb_audio_disconnect() clears subs->sync_endpoint under register_mutex without holding runtime->buffer_mutex: CPU0 CPU1 snd_usb_hw_params() __usb_audio_disconnect() atomic_inc_return(&chip->shutdown) snd_refcount_sync(&chip->usage_count) read subs->sync_endpoint snd_usb_stream_disconnect() subs->sync_endpoint = NULL <-- data race snd_usb_lock_shutdown() ref_ep is only compared by pointer value and snd_usb_lock_shutdown() later aborts with -EIO, so this is a benign KCSAN data race on repeated hw_params() during disconnect. Moving the lookup under snd_usb_lock_shutdown(chip) or using READ_ONCE()/WRITE_ONCE() avoids it. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261205192928.27775-1-voilthuman@gmail.com?part=2 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-05 19:53 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-05 19:29 [PATCH v2 0/2] ALSA: usb-audio: Fix Solid State Logic SSL 12 192 kHz duplex Lee Volkov 2026-12-05 19:29 ` [PATCH v2 1/2] ALSA: usb-audio: Filter invalid capture rates on Solid State Logic SSL 12 Lee Volkov 2026-12-05 19:29 ` [PATCH v2 2/2] ALSA: usb-audio: Reuse active sync endpoint format for implicit feedback Lee Volkov 2026-12-05 19:53 ` sashiko-bot
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.