]> git.hungrycats.org Git - linux/commit
ALSA: xen-front: Connect event channel after stream prepare
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Tue, 26 May 2026 12:48:27 +0000 (09:48 -0300)
committerTakashi Iwai <tiwai@suse.de>
Wed, 27 May 2026 05:25:53 +0000 (07:25 +0200)
commit3624f0bd4af15a820b1bd88b489980fa9fd61b7a
tree8abf492011b96f007324270d6898659767098b71
parent9cd81152373c560b8aa8299b0705c4db82b103b7
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: 1cee559351a7 ("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>
sound/xen/xen_snd_front_alsa.c
sound/xen/xen_snd_front_evtchnl.c
sound/xen/xen_snd_front_evtchnl.h