summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorLiam Girdwood <lrg@slimlogic.co.uk>2010-09-22 20:51:54 +0100
committerSebastien Jan <s-jan@ti.com>2010-09-28 14:58:28 +0200
commit83f3012f5f6b235ec0e23d85c17c58089588d3aa (patch)
tree8b2d66d69a438da2886f60f19f80eabcec4e4626 /sound
parentece551356f55e5e1160cc7a552f43b67db0e927f (diff)
ASoC: ABE DAI - serialise the FE calls with a mutex.
Seems we have a potential resource race on MODEM, although I cant see this on my board atm. Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Margarita Olaya Cabrera <magi.olaya@ti.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/omap/omap-abe.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/sound/soc/omap/omap-abe.c b/sound/soc/omap/omap-abe.c
index a0b84e49f67b..f9462bb9965e 100644
--- a/sound/soc/omap/omap-abe.c
+++ b/sound/soc/omap/omap-abe.c
@@ -517,6 +517,8 @@ static int omap_abe_dai_startup(struct snd_pcm_substream *substream,
dev_dbg(dai->dev, "%s: frontend %s %d\n", __func__,
rtd->dai_link->name, dai->id);
+ mutex_lock(&fe_mutex);
+
/* only startup backends that are either sinks or sources to this frontend DAI */
for (i = 0; i < rtd->num_be; i++) {
struct snd_pcm_substream *be_substream =
@@ -547,6 +549,7 @@ static int omap_abe_dai_startup(struct snd_pcm_substream *substream,
dev_dbg(dai->dev,"%s: frontend finished %s %d\n", __func__,
rtd->dai_link->name, dai->id);
+ mutex_unlock(&fe_mutex);
return 0;
unwind:
@@ -570,6 +573,7 @@ unwind:
be_dec_active(rtd->be_rtd[i], substream->stream);
}
+ mutex_unlock(&fe_mutex);
return ret;
}
@@ -582,6 +586,8 @@ static void omap_abe_dai_shutdown(struct snd_pcm_substream *substream,
dev_dbg(dai->dev,"%s: frontend %s \n", __func__, rtd->dai_link->name);
/* only shutdown backends that are either sinks or sources to this frontend DAI */
+ mutex_lock(&fe_mutex);
+
for (i = 0; i < rtd->num_be; i++) {
struct snd_pcm_substream *be_substream =
rtd->be_rtd[i]->pcm->streams[substream->stream].substream;
@@ -606,6 +612,7 @@ static void omap_abe_dai_shutdown(struct snd_pcm_substream *substream,
abe_be_dapm(rtd, dai->id, substream->stream, SND_SOC_DAPM_STREAM_STOP);
dev_dbg(dai->dev,"%s: frontend %s completed !\n", __func__, rtd->dai_link->name);
+ mutex_unlock(&fe_mutex);
}
static int omap_abe_dai_hw_params(struct snd_pcm_substream *substream,
@@ -617,6 +624,8 @@ static int omap_abe_dai_hw_params(struct snd_pcm_substream *substream,
dev_dbg(dai->dev,"%s: frontend %s \n", __func__, rtd->dai_link->name);
+ mutex_lock(&fe_mutex);
+
// TODO: generate our own hw params for backend DAI
/* only hw_params backends that are either sinks or
* sources to this frontend DAI */
@@ -633,7 +642,7 @@ static int omap_abe_dai_hw_params(struct snd_pcm_substream *substream,
params);
if (ret < 0) {
dev_err(&rtd->dev, "%s: be hw_params failed %d\n", __func__, ret);
- return ret;
+ goto out;
}
}
}
@@ -643,6 +652,8 @@ static int omap_abe_dai_hw_params(struct snd_pcm_substream *substream,
if (ret < 0)
dev_err(dai->dev,"%s: frontend hw_params failed\n", __func__);
+out:
+ mutex_unlock(&fe_mutex);
return ret;
}
@@ -681,6 +692,8 @@ static int omap_abe_dai_prepare(struct snd_pcm_substream *substream,
/* only prepare backends that are either sinks or sources to
* this frontend DAI */
+ mutex_lock(&fe_mutex);
+
for (i = 0; i < rtd->num_be; i++) {
struct snd_pcm_substream *be_substream =
rtd->be_rtd[i]->pcm->streams[substream->stream].substream;
@@ -700,6 +713,7 @@ static int omap_abe_dai_prepare(struct snd_pcm_substream *substream,
abe_be_dapm(rtd, dai->id, substream->stream, SND_SOC_DAPM_STREAM_START);
+ mutex_unlock(&fe_mutex);
return ret;
}
@@ -715,6 +729,8 @@ static int omap_abe_dai_hw_free(struct snd_pcm_substream *substream,
/* wait on trigger completing */
wait_for_completion_timeout(&fe->trigger_done, msecs_to_jiffies(500));
+ mutex_lock(&fe_mutex);
+
/* call hw_free on the frontend */
ret = abe_fe_hw_free(substream, dai);
if (ret < 0)
@@ -733,6 +749,7 @@ static int omap_abe_dai_hw_free(struct snd_pcm_substream *substream,
snd_soc_pcm_hw_free(rtd->be_rtd[i]->pcm->streams[substream->stream].substream);
}
+ mutex_unlock(&fe_mutex);
return ret;
}