* [PATCH] ALSA: oxygen: use helper to activate the SPDIF PCM control
@ 2026-09-27 12:17 Runyu Xiao
2026-09-28 12:26 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Runyu Xiao @ 2026-09-27 12:17 UTC (permalink / raw)
To: Clemens Ladisch
Cc: Jaroslav Kysela, Takashi Iwai, Runyu Xiao, Jianhao Xu,
linux-sound, linux-kernel
oxygen_open() and oxygen_close() modify the SPDIF PCM control access
flags while holding chip->mutex. Direct access changes bypass the control
core locking and notification path.
Move the access transition outside the driver mutex and use
snd_ctl_activate_id(), which serializes the control update with the control
core.
Fixes: d0ce9946c52e ("[ALSA] add CMI8788 driver")
Assisted-by: LLM
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
sound/pci/oxygen/oxygen_pcm.c | 37 +++++++++++++++--------------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c
index b71635601..75efbf59a 100644
--- a/sound/pci/oxygen/oxygen_pcm.c
+++ b/sound/pci/oxygen/oxygen_pcm.c
@@ -171,16 +171,14 @@ static int oxygen_open(struct snd_pcm_substream *substream,
snd_pcm_set_sync(substream);
chip->streams[channel] = substream;
- guard(mutex)(&chip->mutex);
- chip->pcm_active |= 1 << channel;
- if (channel == PCM_SPDIF) {
- chip->spdif_pcm_bits = chip->spdif_bits;
- chip->controls[CONTROL_SPDIF_PCM]->vd[0].access &=
- ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
- snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE |
- SNDRV_CTL_EVENT_MASK_INFO,
- &chip->controls[CONTROL_SPDIF_PCM]->id);
+ scoped_guard(mutex, &chip->mutex) {
+ chip->pcm_active |= 1 << channel;
+ if (channel == PCM_SPDIF)
+ chip->spdif_pcm_bits = chip->spdif_bits;
}
+ if (channel == PCM_SPDIF)
+ snd_ctl_activate_id(chip->card,
+ &chip->controls[CONTROL_SPDIF_PCM]->id, 1);
return 0;
}
@@ -220,19 +218,16 @@ static int oxygen_close(struct snd_pcm_substream *substream)
struct oxygen *chip = snd_pcm_substream_chip(substream);
unsigned int channel = oxygen_substream_channel(substream);
- guard(mutex)(&chip->mutex);
- chip->pcm_active &= ~(1 << channel);
- if (channel == PCM_SPDIF) {
- chip->controls[CONTROL_SPDIF_PCM]->vd[0].access |=
- SNDRV_CTL_ELEM_ACCESS_INACTIVE;
- snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE |
- SNDRV_CTL_EVENT_MASK_INFO,
- &chip->controls[CONTROL_SPDIF_PCM]->id);
- }
- if (channel == PCM_SPDIF || channel == PCM_MULTICH)
- oxygen_update_spdif_source(chip);
+ scoped_guard(mutex, &chip->mutex) {
+ chip->pcm_active &= ~(1 << channel);
+ if (channel == PCM_SPDIF || channel == PCM_MULTICH)
+ oxygen_update_spdif_source(chip);
- chip->streams[channel] = NULL;
+ chip->streams[channel] = NULL;
+ }
+ if (channel == PCM_SPDIF)
+ snd_ctl_activate_id(chip->card,
+ &chip->controls[CONTROL_SPDIF_PCM]->id, 0);
return 0;
}
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] ALSA: oxygen: use helper to activate the SPDIF PCM control
2026-09-27 12:17 [PATCH] ALSA: oxygen: use helper to activate the SPDIF PCM control Runyu Xiao
@ 2026-09-28 12:26 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-09-28 12:26 UTC (permalink / raw)
To: Runyu Xiao
Cc: Clemens Ladisch, Jaroslav Kysela, Takashi Iwai, Jianhao Xu,
linux-sound, linux-kernel
On Sun, 27 Sep 2026 14:17:09 +0200,
Runyu Xiao wrote:
>
> oxygen_open() and oxygen_close() modify the SPDIF PCM control access
> flags while holding chip->mutex. Direct access changes bypass the control
> core locking and notification path.
>
> Move the access transition outside the driver mutex and use
> snd_ctl_activate_id(), which serializes the control update with the control
> core.
>
> Fixes: d0ce9946c52e ("[ALSA] add CMI8788 driver")
> Assisted-by: LLM
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
Applied to for-next branch. Thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-28 12:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-27 12:17 [PATCH] ALSA: oxygen: use helper to activate the SPDIF PCM control Runyu Xiao
2026-09-28 12:26 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®