* [PATCH 1/8] ASoC: ab8500-codec: Move control lock to the driver level
2014-11-09 16:00 [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex Lars-Peter Clausen
@ 2014-11-09 16:00 ` Lars-Peter Clausen
2014-11-09 16:00 ` [PATCH 2/8] ASoC: max98095: Move mutex " Lars-Peter Clausen
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lars-Peter Clausen @ 2014-11-09 16:00 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: Charles Keepax, patches, alsa-devel, Lars-Peter Clausen,
Tushar Behera
The ab8500 driver uses a driver specific lock to protect concurrent access
to some of the control put/get handlers and uses the snd_soc_codec mutex for
some others. This patch updates the driver to consistently use the driver
specific lock for all controls. This will allow us to eventually remove the
snd_soc_codec mutex.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
sound/soc/codecs/ab8500-codec.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c
index fd43827..7dfbc99 100644
--- a/sound/soc/codecs/ab8500-codec.c
+++ b/sound/soc/codecs/ab8500-codec.c
@@ -126,13 +126,13 @@ struct ab8500_codec_drvdata_dbg {
/* Private data for AB8500 device-driver */
struct ab8500_codec_drvdata {
struct regmap *regmap;
+ struct mutex ctrl_lock;
/* Sidetone */
long *sid_fir_values;
enum sid_state sid_status;
/* ANC */
- struct mutex anc_lock;
long *anc_fir_values;
long *anc_iir_values;
enum anc_state anc_status;
@@ -1129,9 +1129,9 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol,
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
- mutex_lock(&codec->mutex);
+ mutex_lock(&drvdata->ctrl_lock);
ucontrol->value.integer.value[0] = drvdata->sid_status;
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&drvdata->ctrl_lock);
return 0;
}
@@ -1154,7 +1154,7 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol,
return -EIO;
}
- mutex_lock(&codec->mutex);
+ mutex_lock(&drvdata->ctrl_lock);
sidconf = snd_soc_read(codec, AB8500_SIDFIRCONF);
if (((sidconf & BIT(AB8500_SIDFIRCONF_FIRSIDBUSY)) != 0)) {
@@ -1185,7 +1185,7 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol,
drvdata->sid_status = SID_FIR_CONFIGURED;
out:
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&drvdata->ctrl_lock);
dev_dbg(codec->dev, "%s: Exit\n", __func__);
@@ -1198,9 +1198,9 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol,
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
- mutex_lock(&codec->mutex);
+ mutex_lock(&drvdata->ctrl_lock);
ucontrol->value.integer.value[0] = drvdata->anc_status;
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&drvdata->ctrl_lock);
return 0;
}
@@ -1217,7 +1217,7 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol,
dev_dbg(dev, "%s: Enter.\n", __func__);
- mutex_lock(&drvdata->anc_lock);
+ mutex_lock(&drvdata->ctrl_lock);
req = ucontrol->value.integer.value[0];
if (req >= ARRAY_SIZE(enum_anc_state)) {
@@ -1244,9 +1244,7 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol,
}
snd_soc_dapm_sync(&codec->dapm);
- mutex_lock(&codec->mutex);
anc_configure(codec, apply_fir, apply_iir);
- mutex_unlock(&codec->mutex);
if (apply_fir) {
if (drvdata->anc_status == ANC_IIR_CONFIGURED)
@@ -1265,7 +1263,7 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol,
snd_soc_dapm_sync(&codec->dapm);
cleanup:
- mutex_unlock(&drvdata->anc_lock);
+ mutex_unlock(&drvdata->ctrl_lock);
if (status < 0)
dev_err(dev, "%s: Unable to configure ANC! (status = %d)\n",
@@ -1294,14 +1292,15 @@ static int filter_control_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+ struct ab8500_codec_drvdata *drvdata = snd_soc_codec_get_drvdata(codec);
struct filter_control *fc =
(struct filter_control *)kcontrol->private_value;
unsigned int i;
- mutex_lock(&codec->mutex);
+ mutex_lock(&drvdata->ctrl_lock);
for (i = 0; i < fc->count; i++)
ucontrol->value.integer.value[i] = fc->value[i];
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&drvdata->ctrl_lock);
return 0;
}
@@ -1310,14 +1309,15 @@ static int filter_control_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+ struct ab8500_codec_drvdata *drvdata = snd_soc_codec_get_drvdata(codec);
struct filter_control *fc =
(struct filter_control *)kcontrol->private_value;
unsigned int i;
- mutex_lock(&codec->mutex);
+ mutex_lock(&drvdata->ctrl_lock);
for (i = 0; i < fc->count; i++)
fc->value[i] = ucontrol->value.integer.value[i];
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&drvdata->ctrl_lock);
return 0;
}
@@ -2545,7 +2545,7 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
(void)snd_soc_dapm_disable_pin(&codec->dapm, "ANC Configure Input");
- mutex_init(&drvdata->anc_lock);
+ mutex_init(&drvdata->ctrl_lock);
return status;
}
--
1.8.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 2/8] ASoC: max98095: Move mutex to the driver level
2014-11-09 16:00 [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex Lars-Peter Clausen
2014-11-09 16:00 ` [PATCH 1/8] ASoC: ab8500-codec: Move control lock to the driver level Lars-Peter Clausen
@ 2014-11-09 16:00 ` Lars-Peter Clausen
2014-11-09 16:00 ` [PATCH 3/8] ASoC: wm5102: Move ultrasonic response settings lock " Lars-Peter Clausen
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lars-Peter Clausen @ 2014-11-09 16:00 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: Charles Keepax, patches, alsa-devel, Lars-Peter Clausen,
Tushar Behera
The max98095 uses the snd_soc_codec mutex to protect against concurrent
access in some of its control put handlers. Move this mutex to the driver
level so we can eventually remove the snd_soc_codec mutex.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
sound/soc/codecs/max98095.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index 0ee6797..01f3cc9 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -16,6 +16,7 @@
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/clk.h>
+#include <linux/mutex.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -57,6 +58,7 @@ struct max98095_priv {
unsigned int mic2pre;
struct snd_soc_jack *headphone_jack;
struct snd_soc_jack *mic_jack;
+ struct mutex lock;
};
static const struct reg_default max98095_reg_def[] = {
@@ -1803,7 +1805,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
regsave = snd_soc_read(codec, M98095_088_CFG_LEVEL);
snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, 0);
- mutex_lock(&codec->mutex);
+ mutex_lock(&max98095->lock);
snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG);
m98095_eq_band(codec, channel, 0, coef_set->band1);
m98095_eq_band(codec, channel, 1, coef_set->band2);
@@ -1811,7 +1813,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
m98095_eq_band(codec, channel, 3, coef_set->band4);
m98095_eq_band(codec, channel, 4, coef_set->band5);
snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, 0);
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&max98095->lock);
/* Restore the original on/off state */
snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, regsave);
@@ -1957,12 +1959,12 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
regsave = snd_soc_read(codec, M98095_088_CFG_LEVEL);
snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, 0);
- mutex_lock(&codec->mutex);
+ mutex_lock(&max98095->lock);
snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG);
m98095_biquad_band(codec, channel, 0, coef_set->band1);
m98095_biquad_band(codec, channel, 1, coef_set->band2);
snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, 0);
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&max98095->lock);
/* Restore the original on/off state */
snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, regsave);
@@ -2395,6 +2397,8 @@ static int max98095_i2c_probe(struct i2c_client *i2c,
if (max98095 == NULL)
return -ENOMEM;
+ mutex_init(&max98095->lock);
+
max98095->regmap = devm_regmap_init_i2c(i2c, &max98095_regmap);
if (IS_ERR(max98095->regmap)) {
ret = PTR_ERR(max98095->regmap);
--
1.8.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 3/8] ASoC: wm5102: Move ultrasonic response settings lock to the driver level
2014-11-09 16:00 [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex Lars-Peter Clausen
2014-11-09 16:00 ` [PATCH 1/8] ASoC: ab8500-codec: Move control lock to the driver level Lars-Peter Clausen
2014-11-09 16:00 ` [PATCH 2/8] ASoC: max98095: Move mutex " Lars-Peter Clausen
@ 2014-11-09 16:00 ` Lars-Peter Clausen
2014-11-09 16:01 ` [PATCH 4/8] ASoC: wm8731: Move the deemph " Lars-Peter Clausen
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lars-Peter Clausen @ 2014-11-09 16:00 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: Charles Keepax, patches, alsa-devel, Lars-Peter Clausen,
Tushar Behera
The wm5102 driver currently uses the snd_soc_codec mutex to protect its
ultrasonic response settings from concurrent access. This patch moves this
lock to the driver level. This will allow us to eventually remove the
snd_soc_codec mutex.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
include/linux/mfd/arizona/core.h | 1 +
sound/soc/codecs/arizona.c | 4 ++--
sound/soc/codecs/wm5102.c | 16 ++++++++--------
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
index f34723f..910e3aa 100644
--- a/include/linux/mfd/arizona/core.h
+++ b/include/linux/mfd/arizona/core.h
@@ -141,6 +141,7 @@ struct arizona {
uint16_t dac_comp_coeff;
uint8_t dac_comp_enabled;
+ struct mutex dac_comp_lock;
};
int arizona_clk32k_enable(struct arizona *arizona);
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 0c05e7a..730636c 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1164,13 +1164,13 @@ static void arizona_wm5102_set_dac_comp(struct snd_soc_codec *codec,
{ 0x80, 0x0 },
};
- mutex_lock(&codec->mutex);
+ mutex_lock(&arizona->dac_comp_lock);
dac_comp[1].def = arizona->dac_comp_coeff;
if (rate >= 176400)
dac_comp[2].def = arizona->dac_comp_enabled;
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&arizona->dac_comp_lock);
regmap_multi_reg_write(arizona->regmap,
dac_comp,
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index f602349..1f75534 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -619,10 +619,10 @@ static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
uint16_t data;
- mutex_lock(&codec->mutex);
+ mutex_lock(&arizona->dac_comp_lock);
data = cpu_to_be16(arizona->dac_comp_coeff);
memcpy(ucontrol->value.bytes.data, &data, sizeof(data));
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&arizona->dac_comp_lock);
return 0;
}
@@ -633,11 +633,11 @@ static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol,
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
- mutex_lock(&codec->mutex);
+ mutex_lock(&arizona->dac_comp_lock);
memcpy(&arizona->dac_comp_coeff, ucontrol->value.bytes.data,
sizeof(arizona->dac_comp_coeff));
arizona->dac_comp_coeff = be16_to_cpu(arizona->dac_comp_coeff);
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&arizona->dac_comp_lock);
return 0;
}
@@ -648,9 +648,9 @@ static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol,
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
- mutex_lock(&codec->mutex);
+ mutex_lock(&arizona->dac_comp_lock);
ucontrol->value.integer.value[0] = arizona->dac_comp_enabled;
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&arizona->dac_comp_lock);
return 0;
}
@@ -661,9 +661,9 @@ static int wm5102_out_comp_switch_put(struct snd_kcontrol *kcontrol,
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
- mutex_lock(&codec->mutex);
+ mutex_lock(&arizona->dac_comp_lock);
arizona->dac_comp_enabled = ucontrol->value.integer.value[0];
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&arizona->dac_comp_lock);
return 0;
}
--
1.8.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 4/8] ASoC: wm8731: Move the deemph lock to the driver level
2014-11-09 16:00 [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex Lars-Peter Clausen
` (2 preceding siblings ...)
2014-11-09 16:00 ` [PATCH 3/8] ASoC: wm5102: Move ultrasonic response settings lock " Lars-Peter Clausen
@ 2014-11-09 16:01 ` Lars-Peter Clausen
2014-11-09 16:01 ` [PATCH 5/8] ASoC: wm8903: " Lars-Peter Clausen
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lars-Peter Clausen @ 2014-11-09 16:01 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: Charles Keepax, patches, alsa-devel, Lars-Peter Clausen,
Tushar Behera
The wm8731 uses the snd_soc_codec mutex to protect its deemph settings from
concurrent access. This patch moves this lock to the driver level. This will
allow us to eventually remove the snd_soc_codec mutex.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
sound/soc/codecs/wm8731.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index eebb328..5dae9a6 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -24,6 +24,7 @@
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>
#include <linux/of_device.h>
+#include <linux/mutex.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -50,6 +51,8 @@ struct wm8731_priv {
int sysclk_type;
int playback_fs;
bool deemph;
+
+ struct mutex lock;
};
@@ -138,7 +141,7 @@ static int wm8731_put_deemph(struct snd_kcontrol *kcontrol,
if (deemph > 1)
return -EINVAL;
- mutex_lock(&codec->mutex);
+ mutex_lock(&wm8731->lock);
if (wm8731->deemph != deemph) {
wm8731->deemph = deemph;
@@ -146,7 +149,7 @@ static int wm8731_put_deemph(struct snd_kcontrol *kcontrol,
ret = 1;
}
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&wm8731->lock);
return ret;
}
@@ -685,6 +688,8 @@ static int wm8731_spi_probe(struct spi_device *spi)
if (wm8731 == NULL)
return -ENOMEM;
+ mutex_init(&wm8731->lock);
+
wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap);
if (IS_ERR(wm8731->regmap)) {
ret = PTR_ERR(wm8731->regmap);
--
1.8.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 5/8] ASoC: wm8903: Move the deemph lock to the driver level
2014-11-09 16:00 [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex Lars-Peter Clausen
` (3 preceding siblings ...)
2014-11-09 16:01 ` [PATCH 4/8] ASoC: wm8731: Move the deemph " Lars-Peter Clausen
@ 2014-11-09 16:01 ` Lars-Peter Clausen
2014-11-09 16:01 ` [PATCH 6/8] ASoC: wm8958: Move DSP firmware lock to " Lars-Peter Clausen
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lars-Peter Clausen @ 2014-11-09 16:01 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: Charles Keepax, patches, alsa-devel, Lars-Peter Clausen,
Tushar Behera
The wm8903 uses the snd_soc_codec mutex to protect its deemph settings from
concurrent access. This patch moves this lock to the driver level. This will
allow us to eventually remove the snd_soc_codec mutex.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
sound/soc/codecs/wm8903.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index c038b3e..ffbe6df 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -26,6 +26,7 @@
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/irq.h>
+#include <linux/mutex.h>
#include <sound/core.h>
#include <sound/jack.h>
#include <sound/pcm.h>
@@ -123,6 +124,7 @@ struct wm8903_priv {
int sysclk;
int irq;
+ struct mutex lock;
int fs;
int deemph;
@@ -457,7 +459,7 @@ static int wm8903_put_deemph(struct snd_kcontrol *kcontrol,
if (deemph > 1)
return -EINVAL;
- mutex_lock(&codec->mutex);
+ mutex_lock(&wm8903->lock);
if (wm8903->deemph != deemph) {
wm8903->deemph = deemph;
@@ -465,7 +467,7 @@ static int wm8903_put_deemph(struct snd_kcontrol *kcontrol,
ret = 1;
}
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&wm8903->lock);
return ret;
}
@@ -2023,6 +2025,8 @@ static int wm8903_i2c_probe(struct i2c_client *i2c,
GFP_KERNEL);
if (wm8903 == NULL)
return -ENOMEM;
+
+ mutex_init(&wm8903->lock);
wm8903->dev = &i2c->dev;
wm8903->regmap = devm_regmap_init_i2c(i2c, &wm8903_regmap);
--
1.8.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 6/8] ASoC: wm8958: Move DSP firmware lock to driver level
2014-11-09 16:00 [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex Lars-Peter Clausen
` (4 preceding siblings ...)
2014-11-09 16:01 ` [PATCH 5/8] ASoC: wm8903: " Lars-Peter Clausen
@ 2014-11-09 16:01 ` Lars-Peter Clausen
2014-11-09 16:01 ` [PATCH 7/8] ASoC: wm8962: Move DSP enable lock to the " Lars-Peter Clausen
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lars-Peter Clausen @ 2014-11-09 16:01 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: Charles Keepax, patches, alsa-devel, Lars-Peter Clausen,
Tushar Behera
The wm8958 driver uses the snd_soc_codec mutex to protect the various
firmware pointers from concurrent assignment. This patch moves this lock to
the driver level. This will allow us to eventually remove the snd_soc_codec
mutex.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
To be honest I'm not sure what this lock actually protects against. The
assignments should be atomic already.
---
sound/soc/codecs/wm8958-dsp2.c | 12 ++++++------
sound/soc/codecs/wm8994.c | 2 ++
sound/soc/codecs/wm8994.h | 2 ++
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c
index 0dada7f..3cbc82b 100644
--- a/sound/soc/codecs/wm8958-dsp2.c
+++ b/sound/soc/codecs/wm8958-dsp2.c
@@ -867,9 +867,9 @@ static void wm8958_enh_eq_loaded(const struct firmware *fw, void *context)
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
if (fw && (wm8958_dsp2_fw(codec, "ENH_EQ", fw, true) == 0)) {
- mutex_lock(&codec->mutex);
+ mutex_lock(&wm8994->fw_lock);
wm8994->enh_eq = fw;
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&wm8994->fw_lock);
}
}
@@ -879,9 +879,9 @@ static void wm8958_mbc_vss_loaded(const struct firmware *fw, void *context)
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
if (fw && (wm8958_dsp2_fw(codec, "MBC+VSS", fw, true) == 0)) {
- mutex_lock(&codec->mutex);
+ mutex_lock(&wm8994->fw_lock);
wm8994->mbc_vss = fw;
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&wm8994->fw_lock);
}
}
@@ -891,9 +891,9 @@ static void wm8958_mbc_loaded(const struct firmware *fw, void *context)
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
if (fw && (wm8958_dsp2_fw(codec, "MBC", fw, true) == 0)) {
- mutex_lock(&codec->mutex);
+ mutex_lock(&wm8994->fw_lock);
wm8994->mbc = fw;
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&wm8994->fw_lock);
}
}
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 1fcb9f3..dbca6e0 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -4457,6 +4457,8 @@ static int wm8994_probe(struct platform_device *pdev)
return -ENOMEM;
platform_set_drvdata(pdev, wm8994);
+ mutex_init(&wm8994->fw_lock);
+
wm8994->wm8994 = dev_get_drvdata(pdev->dev.parent);
pm_runtime_enable(&pdev->dev);
diff --git a/sound/soc/codecs/wm8994.h b/sound/soc/codecs/wm8994.h
index 6536f8d..dd73387 100644
--- a/sound/soc/codecs/wm8994.h
+++ b/sound/soc/codecs/wm8994.h
@@ -13,6 +13,7 @@
#include <linux/firmware.h>
#include <linux/completion.h>
#include <linux/workqueue.h>
+#include <linux/mutex.h>
#include "wm_hubs.h"
@@ -156,6 +157,7 @@ struct wm8994_priv {
unsigned int aif1clk_disable:1;
unsigned int aif2clk_disable:1;
+ struct mutex fw_lock;
int dsp_active;
const struct firmware *cur_fw;
const struct firmware *mbc;
--
1.8.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 7/8] ASoC: wm8962: Move DSP enable lock to the driver level
2014-11-09 16:00 [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex Lars-Peter Clausen
` (5 preceding siblings ...)
2014-11-09 16:01 ` [PATCH 6/8] ASoC: wm8958: Move DSP firmware lock to " Lars-Peter Clausen
@ 2014-11-09 16:01 ` Lars-Peter Clausen
2014-11-09 16:01 ` [PATCH 8/8] ASoC: Remove CODEC mutex Lars-Peter Clausen
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lars-Peter Clausen @ 2014-11-09 16:01 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: Charles Keepax, patches, alsa-devel, Lars-Peter Clausen,
Tushar Behera
The wm8962 uses the snd_soc_codec mutex to protect the wm8962_dsp2_ena_put()
function from concurrent execution. This patch moves that lock to the driver
level. This will allow us to eventually remove the snd_soc_codec mutex.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
sound/soc/codecs/wm8962.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 9077411..61ca4a7 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -26,6 +26,7 @@
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
+#include <linux/mutex.h>
#include <sound/core.h>
#include <sound/jack.h>
#include <sound/pcm.h>
@@ -67,6 +68,7 @@ struct wm8962_priv {
int fll_fref;
int fll_fout;
+ struct mutex dsp2_ena_lock;
u16 dsp2_ena;
struct delayed_work mic_work;
@@ -1570,7 +1572,7 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol,
int dsp2_running = snd_soc_read(codec, WM8962_DSP2_POWER_MANAGEMENT) &
WM8962_DSP2_ENA;
- mutex_lock(&codec->mutex);
+ mutex_lock(&wm8962->dsp2_ena_lock);
if (ucontrol->value.integer.value[0])
wm8962->dsp2_ena |= 1 << shift;
@@ -1590,7 +1592,7 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol,
}
out:
- mutex_unlock(&codec->mutex);
+ mutex_unlock(&wm8962->dsp2_ena_lock);
return ret;
}
@@ -3557,6 +3559,8 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
if (wm8962 == NULL)
return -ENOMEM;
+ mutex_init(&wm8962->dsp2_ena_lock);
+
i2c_set_clientdata(i2c, wm8962);
INIT_DELAYED_WORK(&wm8962->mic_work, wm8962_mic_work);
--
1.8.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 8/8] ASoC: Remove CODEC mutex
2014-11-09 16:00 [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex Lars-Peter Clausen
` (6 preceding siblings ...)
2014-11-09 16:01 ` [PATCH 7/8] ASoC: wm8962: Move DSP enable lock to the " Lars-Peter Clausen
@ 2014-11-09 16:01 ` Lars-Peter Clausen
2014-11-10 8:49 ` [PATCH 0/8] ASoC: Replace remaining users of the " Charles Keepax
2014-11-10 19:08 ` Mark Brown
9 siblings, 0 replies; 11+ messages in thread
From: Lars-Peter Clausen @ 2014-11-09 16:01 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: Charles Keepax, patches, alsa-devel, Lars-Peter Clausen,
Tushar Behera
The CODEC mutex is now unused and can be removed.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
include/sound/soc.h | 1 -
sound/soc/soc-core.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 7ba7130..5c91b06 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -780,7 +780,6 @@ struct snd_soc_codec {
struct device *dev;
const struct snd_soc_codec_driver *driver;
- struct mutex mutex;
struct list_head list;
struct list_head card_list;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 4c8f8a2..cc7bb7a 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4362,7 +4362,6 @@ int snd_soc_register_codec(struct device *dev,
codec->dev = dev;
codec->driver = codec_drv;
codec->component.val_bytes = codec_drv->reg_word_size;
- mutex_init(&codec->mutex);
#ifdef CONFIG_DEBUG_FS
codec->component.init_debugfs = soc_init_codec_debugfs;
--
1.8.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex
2014-11-09 16:00 [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex Lars-Peter Clausen
` (7 preceding siblings ...)
2014-11-09 16:01 ` [PATCH 8/8] ASoC: Remove CODEC mutex Lars-Peter Clausen
@ 2014-11-10 8:49 ` Charles Keepax
2014-11-10 19:08 ` Mark Brown
9 siblings, 0 replies; 11+ messages in thread
From: Charles Keepax @ 2014-11-10 8:49 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: patches, alsa-devel, Mark Brown, Liam Girdwood, Tushar Behera
On Sun, Nov 09, 2014 at 05:00:56PM +0100, Lars-Peter Clausen wrote:
> We've stopped using the snd_soc_codec mutex in the ASoC core itself a while
> ago. There is still a handful of drivers which use the mutex to protect some
> of their data structures. This patch moves the lock for the remaining users
> to the drivers private data struct and then removes it from the
> snd_soc_codec struct.
>
> - Lars
>
> Lars-Peter Clausen (8):
> ASoC: ab8500-codec: Move control lock to the driver level
> ASoC: max98095: Move mutex to the driver level
> ASoC: wm5102: Move ultrasonic response settings lock to the driver
> level
> ASoC: wm8731: Move the deemph lock to the driver level
> ASoC: wm8903: Move the deemph lock to the driver level
> ASoC: wm8958: Move DSP firmware lock to driver level
> ASoC: wm8962: Move DSP enable lock to the driver level
> ASoC: Remove CODEC mutex
>
> include/linux/mfd/arizona/core.h | 1 +
> include/sound/soc.h | 1 -
> sound/soc/codecs/ab8500-codec.c | 32 ++++++++++++++++----------------
> sound/soc/codecs/arizona.c | 4 ++--
> sound/soc/codecs/max98095.c | 12 ++++++++----
> sound/soc/codecs/wm5102.c | 16 ++++++++--------
> sound/soc/codecs/wm8731.c | 9 +++++++--
> sound/soc/codecs/wm8903.c | 8 ++++++--
> sound/soc/codecs/wm8958-dsp2.c | 12 ++++++------
> sound/soc/codecs/wm8962.c | 8 ++++++--
> sound/soc/codecs/wm8994.c | 2 ++
> sound/soc/codecs/wm8994.h | 2 ++
> sound/soc/soc-core.c | 1 -
> 13 files changed, 64 insertions(+), 44 deletions(-)
>
> --
> 1.8.0
>
For the Wolfson parts:
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex
2014-11-09 16:00 [PATCH 0/8] ASoC: Replace remaining users of the CODEC mutex Lars-Peter Clausen
` (8 preceding siblings ...)
2014-11-10 8:49 ` [PATCH 0/8] ASoC: Replace remaining users of the " Charles Keepax
@ 2014-11-10 19:08 ` Mark Brown
9 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2014-11-10 19:08 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Charles Keepax, patches, Liam Girdwood, alsa-devel, Tushar Behera
[-- Attachment #1.1: Type: text/plain, Size: 415 bytes --]
On Sun, Nov 09, 2014 at 05:00:56PM +0100, Lars-Peter Clausen wrote:
> We've stopped using the snd_soc_codec mutex in the ASoC core itself a while
> ago. There is still a handful of drivers which use the mutex to protect some
> of their data structures. This patch moves the lock for the remaining users
> to the drivers private data struct and then removes it from the
> snd_soc_codec struct.
Applied all, thanks.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread