Skip to contentSkip to conversation

ASoC: Lock the CODEC in PXA external jack controls

PATCH In review Mark Brown 2 participants 3 messages Nov 5, 2010 – Nov 6, 2010

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 ASoC: Lock the CODEC in PXA external jack controls

When doing anything with the system, especially DAPM, we need to hold the CODEC mutex.

---
 sound/soc/pxa/corgi.c    |    5 +++++
 sound/soc/pxa/magician.c |    4 ++++
 sound/soc/pxa/poodle.c   |    5 +++++
 sound/soc/pxa/spitz.c    |    5 +++++
 sound/soc/pxa/tosa.c     |    5 +++++
 5 files changed, 24 insertions(+), 0 deletions(-)
sound/soc/pxa/corgi.c +5 -0
index 97e9423..f451acd 100644
@@ -100,8 +100,13 @@ static int corgi_startup(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_codec *codec = rtd->codec;
 
+	mutex_lock(&codec->mutex);
+
 	/* check the jack status at stream startup */
 	corgi_ext_control(codec);
+
+	mutex_unlock(&codec->mutex);
+
 	return 0;
 }
 
sound/soc/pxa/magician.c +4 -0
index b8207ce..5ef0526 100644
@@ -72,9 +72,13 @@ static int magician_startup(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_codec *codec = rtd->codec;
 
+	mutex_lock(&codec->mutex);
+
 	/* check the jack status at stream startup */
 	magician_ext_control(codec);
 
+	mutex_unlock(&codec->mutex);
+
 	return 0;
 }
 
sound/soc/pxa/poodle.c +5 -0
index af84ee9..84edd03 100644
@@ -77,8 +77,13 @@ static int poodle_startup(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_codec *codec = rtd->codec;
 
+	mutex_lock(&codec->mutex);
+
 	/* check the jack status at stream startup */
 	poodle_ext_control(codec);
+
+	mutex_unlock(&codec->mutex);
+
 	return 0;
 }
 
sound/soc/pxa/spitz.c +5 -0
index f470f36..0b30d7d 100644
@@ -108,8 +108,13 @@ static int spitz_startup(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_codec *codec = rtd->codec;
 
+	mutex_lock(&codec->mutex);
+
 	/* check the jack status at stream startup */
 	spitz_ext_control(codec);
+
+	mutex_unlock(&codec->mutex);
+
 	return 0;
 }
 
sound/soc/pxa/tosa.c +5 -0
index 73d0edd..7b983f9 100644
@@ -81,8 +81,13 @@ static int tosa_startup(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_codec *codec = rtd->codec;
 
+	mutex_lock(&codec->mutex);
+
 	/* check the jack status at stream startup */
 	tosa_ext_control(codec);
+
+	mutex_unlock(&codec->mutex);
+
 	return 0;
 }
 
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Mark Brown

When doing anything with the system, especially DAPM, we need to hold the CODEC mutex.

I'm fine for this atm, but obviously we need to rework the DAPM locking a little as we dont want developers to have to care about locking internals.

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
author
#2 lore raw
Quoted 3 lines · Liam Girdwood

I'm fine for this atm, but obviously we need to rework the DAPM locking a little as we dont want developers to have to care about locking internals.

It's not just DAPM, either - there's the CODEC register maps as well.