FAILED: patch "[PATCH] ALSA: hwdep: Serialize DSP load requests" failed to apply to 5.15-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x aee83c204f80d56b4d55f53acdb8594308ddcd4a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From aee83c204f80d56b4d55f53acdb8594308ddcd4a Mon Sep 17 00:00:00 2001
From: YuanZhe Liu <[email protected]>
Date: Thu, 29 Oct 2026 16:48:09 +0800
Subject: [PATCH] ALSA: hwdep: Serialize DSP load requests
The check of the loaded DSP indices and the call of the driver's dsp_load callback in snd_hwdep_dsp_load() are not serialized. A hwdep file descriptor can be shared among threads, or inherited across fork, so two SNDRV_HWDEP_IOCTL_DSP_LOAD requests for the same index can both observe the index as unloaded and enter the driver's callback concurrently, even though the device itself is opened exclusively.
This breaks the assumption behind hw->dsp_loaded that a firmware index is loaded only once. For example, snd-usb-usx2y hits WARN_ON(usx2y->as04.buffer) in usx2y_async_seq04_init() and may allocate the US-428 sequence URBs twice.
Serialize the check, the callback invocation and the bookkeeping with a per-hwdep mutex, so that the second request returns -EBUSY.
--- include/sound/hwdep.h | 1 + sound/core/hwdep.c | 2 ++ 2 files changed, 3 insertions(+)
include/sound/hwdep.h +1 -0
@@ -57,6 +57,7 @@ struct snd_hwdep {struct mutex open_mutex;int used;/* reference counter */ +struct mutex dsp_mutex;/* serializes DSP load requests */ unsigned int dsp_loaded;/* bit fields of loaded dsp indices */ unsigned int exclusive:1; /* exclusive access mode */ };
sound/core/hwdep.c +2 -0
@@ -212,6 +212,7 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,return -ENXIO ;if (info->index >=32 )return -EINVAL ; +guard (mutex)(&hw->dsp_mutex);/* check whether the dsp was already loaded */ if (hw->dsp_loaded & (1u << info->index))return -EBUSY ;
@@ -380,6 +381,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,init_waitqueue_head (&hwdep->open_wait);mutex_init (&hwdep->open_mutex); +mutex_init (&hwdep->dsp_mutex); hwdep->card = card; hwdep->device = device;if (id)
Signature · 1 line
2.53.0
PATCH 1/1 ALSA: hwdep: Serialize DSP load requests
The check of the loaded DSP indices and the call of the driver's dsp_load callback in snd_hwdep_dsp_load() are not serialized. A hwdep file descriptor can be shared among threads, or inherited across fork, so two SNDRV_HWDEP_IOCTL_DSP_LOAD requests for the same index can both observe the index as unloaded and enter the driver's callback concurrently, even though the device itself is opened exclusively.
This breaks the assumption behind hw->dsp_loaded that a firmware index is loaded only once. For example, snd-usb-usx2y hits WARN_ON(usx2y->as04.buffer) in usx2y_async_seq04_init() and may allocate the US-428 sequence URBs twice.
Serialize the check, the callback invocation and the bookkeeping with a per-hwdep mutex, so that the second request returns -EBUSY.
--- include/sound/hwdep.h | 1 + sound/core/hwdep.c | 2 ++ 2 files changed, 3 insertions(+)
include/sound/hwdep.h +1 -0
@@ -57,6 +57,7 @@ struct snd_hwdep {struct mutex open_mutex;int used;/* reference counter */ +struct mutex dsp_mutex;/* serializes DSP load requests */ unsigned int dsp_loaded;/* bit fields of loaded dsp indices */ unsigned int exclusive:1; /* exclusive access mode */ };
sound/core/hwdep.c +2 -0
@@ -212,6 +212,7 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,return -ENXIO ;if (info->index >=32 )return -EINVAL ; +guard (mutex)(&hw->dsp_mutex);/* check whether the dsp was already loaded */ if (hw->dsp_loaded & (1u << info->index))return -EBUSY ;
@@ -377,6 +378,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,init_waitqueue_head (&hwdep->open_wait);mutex_init (&hwdep->open_mutex); +mutex_init (&hwdep->dsp_mutex); hwdep->card = card; hwdep->device = device;if (id)
Signature · 1 line
2.34.1