Skip to contentSkip to conversation

ASoC: soc-pcm: Fix and cleanup DPCM locking

PATCH New yixuanjiang via Alsa-devel 1 participant 1 message May 8, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: soc-pcm: Fix and cleanup DPCM locking

From: Takashi Iwai <[email protected]>

The existing locking for DPCM has several issues
a) a confusing mix of card->mutex and card->pcm_mutex.
b) a dpcm_lock spinlock added inconsistently and on paths that could be recursively taken. The use of irqsave/irqrestore was also overkill.

The suggested model is:

1) The pcm_mutex is the top-most protection of BE links in the FE. The pcm_mutex is applied always on either the top PCM callbacks or the external call from DAPM, not taken in the internal functions.

2) the FE stream lock is taken in higher levels before invoking dpcm_be_dai_trigger()

3) when adding and deleting a BE, both the pcm_mutex and FE stream lock are taken.

---
 include/sound/soc.h  |   2 -
 sound/soc/soc-core.c |   1 -
 sound/soc/soc-pcm.c  | 229 ++++++++++++++++++++++++++++---------------
 3 files changed, 152 insertions(+), 80 deletions(-)
include/sound/soc.h +0 -2
index 8e6dd8a257c5..5872a8864f3b 100644
@@ -893,8 +893,6 @@ struct snd_soc_card {
 	struct mutex pcm_mutex;
 	enum snd_soc_pcm_subclass pcm_subclass;
 
-	spinlock_t dpcm_lock;
-
 	int (*probe)(struct snd_soc_card *card);
 	int (*late_probe)(struct snd_soc_card *card);
 	int (*remove)(struct snd_soc_card *card);
sound/soc/soc-core.c +0 -1
index 1b1749b920f4..a5b3ee69fb88 100644
@@ -2339,7 +2339,6 @@ int snd_soc_register_card(struct snd_soc_card *card)
 	mutex_init(&card->mutex);
 	mutex_init(&card->dapm_mutex);
 	mutex_init(&card->pcm_mutex);
-	spin_lock_init(&card->dpcm_lock);
 
 	return snd_soc_bind_card(card);
 }
sound/soc/soc-pcm.c +152 -77

635 lines not on this page · raw message

Signature · 1 line
2.40.1.495.gc816e09b53d-goog