linux/sound/xen
Cássio Gabriel 3624f0bd4a ALSA: xen-front: Connect event channel after stream prepare
The request channel must be connected from ALSA .open(), because hw-rule
queries and the stream open request use it. The event channel is
different: XENSND_EVT_CUR_POS handling uses ALSA runtime buffer and
period geometry, and the corresponding Xen stream parameters are not
submitted to the backend until .prepare() sends XENSND_OP_OPEN.

Currently .open() connects both channels. A backend current-position
event, or a stale event queued for an earlier stream instance, can
therefore reach xen_snd_front_alsa_handle_cur_pos() before
runtime->buffer_size and runtime->period_size are valid.

Add a per-channel connection helper, connect only the request channel in
.open(), connect the event channel after a successful stream prepare,
and disconnect it before stream close/free. Re-check the event-channel
state after taking ring_io_lock so disconnecting the event channel
synchronizes against a threaded IRQ that passed the initial lockless
state test. Keep defensive runtime geometry checks in the position
handler.

Fixes: 1cee559351 ("ALSA: xen-front: Implement ALSA virtual sound driver")
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260526-alsa-xen-event-channel-fixes-v1-2-91d3a6a50778@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2026-05-27 07:25:53 +02:00
..
Kconfig
Makefile ALSA: misc: Use *-y instead of *-objs in Makefile 2024-05-08 18:18:13 +02:00
xen_snd_front_alsa.c ALSA: xen-front: Connect event channel after stream prepare 2026-05-27 07:25:53 +02:00
xen_snd_front_alsa.h
xen_snd_front_cfg.c ALSA: xen: Fix -Wformat-truncation warning 2023-09-15 13:21:35 +02:00
xen_snd_front_cfg.h
xen_snd_front_evtchnl.c ALSA: xen-front: Connect event channel after stream prepare 2026-05-27 07:25:53 +02:00
xen_snd_front_evtchnl.h ALSA: xen-front: Connect event channel after stream prepare 2026-05-27 07:25:53 +02:00
xen_snd_front.c ALSA: xen: Use guard() for mutex locks 2025-09-01 13:54:27 +02:00
xen_snd_front.h