]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ASoC: dapm: Fix locking during codec shutdown
authorLiam Girdwood <lrg@ti.com>
Fri, 6 Jul 2012 15:57:05 +0000 (16:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Aug 2012 15:22:37 +0000 (08:22 -0700)
commit 01005a729a17ab419f61a366e22f3419e7a2c3fe upstream.

Codec shutdown performs a DAPM power sequence that might cause conflicts
and/or race conditions if another stream power event is running simultaneously.
Use card's dapm mutex to protect any potential race condition between them.

Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/soc/soc-dapm.c

index 89eae93445cf517e5e356297374fcbcf183529ae..11b7320ea7adf01e9dd2882fe918f97d2c9c532b 100644 (file)
@@ -3538,10 +3538,13 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_free);
 
 static void soc_dapm_shutdown_codec(struct snd_soc_dapm_context *dapm)
 {
+       struct snd_soc_card *card = dapm->card;
        struct snd_soc_dapm_widget *w;
        LIST_HEAD(down_list);
        int powerdown = 0;
 
+       mutex_lock(&card->dapm_mutex);
+
        list_for_each_entry(w, &dapm->card->widgets, list) {
                if (w->dapm != dapm)
                        continue;
@@ -3564,6 +3567,8 @@ static void soc_dapm_shutdown_codec(struct snd_soc_dapm_context *dapm)
                        snd_soc_dapm_set_bias_level(dapm,
                                                    SND_SOC_BIAS_STANDBY);
        }
+
+       mutex_unlock(&card->dapm_mutex);
 }
 
 /*