Re: [PATCH] ALSA: ymfpci: avoid changing control access under spinlock
From: Takashi Iwai
Date: Mon Sep 28 2026 - 09:21:05 EST
On Sun, 27 Sep 2026 15:53:01 +0200,
Runyu Xiao wrote:
>
> The YMFPCI playback trigger changes a mixer control's access flags while
> holding reg_lock. Direct access changes are not serialized with the control
> core, and snd_ctl_activate_id() cannot be called under the spinlock because
> it may sleep.
>
> Track the desired control state under reg_lock and update it from a work
> item. Use a generation counter to serialize prepare with a pending stop.
> Cancel the work before the PCM private data is released.
>
> Assisted-by: LLM
> Fixes: 177a7cdbd1d8 ("[ALSA] ymfpci: fix volume handling of the 44.1 kHz slot")
> Signed-off-by: Runyu Xiao <runyu.xiao@xxxxxxxxxx>
Although the intention is clear, this is just an overkill. There is
no real race, and introducing the offloading work just for using
snd_ctl_activate_id() makes little sense for this old code.
If any, we should rather make snd_ctl_activate_id() to be callable
from the irq context, instead. But this would need a redesign of the
control-led layer implementation -- that's the very reason of being
sleepable context.
thanks,
Takashi