Re: [RFC PATCH v3 2/2] ALSA: usb-audio: add MIXER_STATE_REPUSH quirk flag

From: Pavel Artemev

Date: Tue Nov 17 2026 - 07:49:06 EST


Thank you for another sharp pass - all seven findings are addressed
in a v4 just sent. Mapping, with one correction:

> stale master and mute writes in snd_usb_mixer_resume()

Confirmed. restore_mixer_value() now returns early for the deferred
controls, exactly as you suggested; a resume re-pushes them through
the flush mechanism instead, which also re-asserts cached mute
switches - nothing is playing yet at that point, so the chop-on-mute-
write property of these devices is respected.

> unlocked restore_mixer_value() clobbers deferred puts

Confirmed; with restore no longer writing these controls, every
remaining writer holds the mixer lock. (The same unlocked-walk race
exists for direct puts on stock kernels; v4 leaves that untouched.)

> mutex_trylock() in snd_usb_mixer_resume() drops re-push

Confirmed, including the sharpest case: a flush whose first write
triggers the resume runs the callback on the worker thread that
holds the lock, so trylock fails and the latched-then-cleared
flush_full drops the request. Re-push requests are now lock-free
atomic bits and the worker re-checks them after every run, so a
request is never lost; no PM callback touches the mixer lock at all
now (a blocking one would self-deadlock in exactly that scenario).

> sticky master_explicit breaks volume after alsactl restore

Confirmed - a boot-time alsactl restore would pin the master
forever. Ownership is now with the last writer: an explicit master
put stops derivation for the unit until user space writes one of its
channels again.

> flush_work races with system suspend and drops mute state

Both halves confirmed. Suspend now marks the mixer and a running
flush stops before its next unit instead of issuing transfers into
an ongoing port suspend; a write that fails keeps its value pending
(previously the pending bit was cleared before the write, and the
full re-push only re-asserted volumes, so a failed mute write was
lost for good) and the resume re-push retries it.

> race re-arming flush_work in snd_usb_mixer_disconnect()

Confirmed for the put path and stream-opened (whose check sat
outside the lock); disconnect now marks the mixer under the lock
before the synchronizing cancel and every arming site holds the lock
and re-checks. One correction: the resume-path arm is not a
use-after-free window - usb_unbind_interface() autoresumes the
device before calling the driver's disconnect, so the resume
callback always completes before disconnect starts. It stays
lock-free by design, for the deadlock noted above.

> overly broad cache invalidation suppression on notify

Confirmed; the suppression is now scoped to the deferred volume/mute
controls at both sites.

--
Pavel