summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMisael Lopez Cruz <misael.lopez@ti.com>2011-04-07 08:39:02 +0100
committerAndy Green <andy.green@linaro.org>2011-04-07 08:39:02 +0100
commit721e02bfa16dccd955e17f742069b9827015283d (patch)
tree08227a41c31c182f6d8593144d2ac70dbfc194a5
parent73c9fb93d5490018d79ae2d38bba75a07c46d415 (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>
-rw-r--r--include/sound/soc.h1
-rw-r--r--sound/soc/soc-core.c1
-rw-r--r--sound/soc/soc-dapm.c2
3 files changed, 4 insertions, 0 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index bd635e93594..41b931a0c52 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -675,6 +675,7 @@ struct snd_soc_card {
struct list_head list;
struct mutex mutex;
+ struct mutex dapm_mutex;
bool instantiated;
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.