[alsa-devel] some lock needed for flush_delayed_work ?

Takashi Iwai tiwai at suse.de
Tue Sep 3 12:28:37 CEST 2019


On Tue, 03 Sep 2019 10:00:22 +0200,
Kuninori Morimoto wrote:
> 
> 
> Hi ALSA ML
> 
> I got below error when I unbind/bind CPU DAI.
> It seems we need to have some kind of lock ?

No, this kind of error usually is due to the missing initialization of
the lock object.  In this case, the work hasn't been initialized
before calling the flush_delayed_work().

I suppose it's an error path at snd_soc_bind_card(), and the patch
like below might fix the issue.


Takashi

--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -371,6 +371,7 @@ struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
 EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream);
 
 static const struct snd_soc_ops null_snd_soc_ops;
+static void codec2codec_close_delayed_work(struct work_struct *work);
 
 static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
 	struct snd_soc_card *card, struct snd_soc_dai_link *dai_link)
@@ -382,6 +383,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
 		return NULL;
 
 	INIT_LIST_HEAD(&rtd->component_list);
+	INIT_DELAYED_WORK(&rtd->delayed_work, codec2codec_close_delayed_work);
 	rtd->card = card;
 	rtd->dai_link = dai_link;
 	if (!rtd->dai_link->ops)
@@ -1573,9 +1575,6 @@ static int soc_probe_link_dais(struct snd_soc_card *card,
 					   rtd->num_codecs, rtd);
 		if (ret < 0)
 			return ret;
-	} else {
-		INIT_DELAYED_WORK(&rtd->delayed_work,
-				  codec2codec_close_delayed_work);
 	}
 
 	return 0;


More information about the Alsa-devel mailing list