Commit 168d10e7 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: wm_adsp: Add locking to DSP firmware controls

Locking is currently missing from the DSP firmware controls, which can
lead to some race conditions if the controls are accessed as the DSP
powers up or down. This patch adds them to the new power lock.
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7585a5b0
...@@ -597,14 +597,19 @@ static int wm_coeff_put(struct snd_kcontrol *kctl, ...@@ -597,14 +597,19 @@ static int wm_coeff_put(struct snd_kcontrol *kctl,
{ {
struct wm_coeff_ctl *ctl = (struct wm_coeff_ctl *)kctl->private_value; struct wm_coeff_ctl *ctl = (struct wm_coeff_ctl *)kctl->private_value;
char *p = ucontrol->value.bytes.data; char *p = ucontrol->value.bytes.data;
int ret = 0;
mutex_lock(&ctl->dsp->pwr_lock);
memcpy(ctl->cache, p, ctl->len); memcpy(ctl->cache, p, ctl->len);
ctl->set = 1; ctl->set = 1;
if (!ctl->enabled) if (ctl->enabled)
return 0; ret = wm_coeff_write_control(ctl, p, ctl->len);
mutex_unlock(&ctl->dsp->pwr_lock);
return wm_coeff_write_control(ctl, p, ctl->len); return ret;
} }
static int wm_coeff_read_control(struct wm_coeff_ctl *ctl, static int wm_coeff_read_control(struct wm_coeff_ctl *ctl,
...@@ -651,17 +656,22 @@ static int wm_coeff_get(struct snd_kcontrol *kctl, ...@@ -651,17 +656,22 @@ static int wm_coeff_get(struct snd_kcontrol *kctl,
{ {
struct wm_coeff_ctl *ctl = (struct wm_coeff_ctl *)kctl->private_value; struct wm_coeff_ctl *ctl = (struct wm_coeff_ctl *)kctl->private_value;
char *p = ucontrol->value.bytes.data; char *p = ucontrol->value.bytes.data;
int ret = 0;
mutex_lock(&ctl->dsp->pwr_lock);
if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) {
if (ctl->enabled) if (ctl->enabled)
return wm_coeff_read_control(ctl, p, ctl->len); ret = wm_coeff_read_control(ctl, p, ctl->len);
else else
return -EPERM; ret = -EPERM;
} else {
memcpy(p, ctl->cache, ctl->len);
} }
memcpy(p, ctl->cache, ctl->len); mutex_unlock(&ctl->dsp->pwr_lock);
return 0; return ret;
} }
struct wmfw_ctl_work { struct wmfw_ctl_work {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment