summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMisael Lopez Cruz <misael.lopez@ti.com>2011-05-31 09:22:53 +0100
committerAndy Green <andy.green@linaro.org>2011-05-31 11:03:05 +0100
commit12f1f4f355277cb82ca83261ec8a547b4482f771 (patch)
tree1d1cf5585843ab835df5942ff77419bbe9b4d291 /sound
parent4bab10bb6102cac62221dc8a7305719ba25ea7f8 (diff)
ASoC: dapm: Fix race condition for widgets power list creation
Multiple calls to dapm_power_widgets() can create a race condition causing widget power list to be corrupted. Those scenarios can occur in multistream usecases, stream start/stop along with update power calls (mixer, mux, dapm_sync, stream_event) simultaneously. Change-Id: I197f6ec223bf4451f207842b2a7ff72f81dcd313 Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-core.c1
-rw-r--r--sound/soc/soc-dapm.c2
2 files changed, 3 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 95d91a61492..0224b0cda3a 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3507,6 +3507,7 @@ static int snd_soc_register_card(struct snd_soc_card *card)
INIT_LIST_HEAD(&card->list);
card->instantiated = 0;
mutex_init(&card->mutex);
+ mutex_init(&card->dapm_mutex);
mutex_lock(&client_mutex);
list_add(&card->list, &card_list);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a6d417945dd..f5e2e6b4eca 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1278,6 +1278,7 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
/* Check which widgets we need to power and store them in
* lists indicating if they should be powered up or down.
*/
+ mutex_lock(&card->dapm_mutex);
list_for_each_entry(w, &card->widgets, list) {
switch (w->id) {
case snd_soc_dapm_pre:
@@ -1312,6 +1313,7 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
break;
}
}
+ mutex_unlock(&card->dapm_mutex);
/* If there are no DAPM widgets then try to figure out power from the
* event type.