Skip to content

Commit

Permalink
ASoC: wm_adsp: Fix some subtle races on compressed stream
Browse files Browse the repository at this point in the history
Firstly, we should be locking the pwr_lock when we initialise the
compressed buffer. Secondly, fixup a couple of places when we should be
pulling pointers only under the pwr_lock as they may be affected by
operations that take that lock.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Charles Keepax authored and Mark Brown committed Mar 29, 2016
1 parent f55532a commit 612047f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions sound/soc/codecs/wm_adsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2240,9 +2240,13 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,
if (ret != 0)
goto err;

mutex_lock(&dsp->pwr_lock);

if (wm_adsp_fw[dsp->fw].num_caps != 0)
ret = wm_adsp_buffer_init(dsp);

mutex_unlock(&dsp->pwr_lock);

break;

case SND_SOC_DAPM_PRE_PMD:
Expand Down Expand Up @@ -2814,12 +2818,15 @@ static int wm_adsp_buffer_update_avail(struct wm_adsp_compr_buf *buf)

int wm_adsp_compr_handle_irq(struct wm_adsp *dsp)
{
struct wm_adsp_compr_buf *buf = dsp->buffer;
struct wm_adsp_compr *compr = dsp->compr;
struct wm_adsp_compr_buf *buf;
struct wm_adsp_compr *compr;
int ret = 0;

mutex_lock(&dsp->pwr_lock);

buf = dsp->buffer;
compr = dsp->compr;

if (!buf) {
ret = -ENODEV;
goto out;
Expand Down Expand Up @@ -2879,14 +2886,16 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream,
struct snd_compr_tstamp *tstamp)
{
struct wm_adsp_compr *compr = stream->runtime->private_data;
struct wm_adsp_compr_buf *buf = compr->buf;
struct wm_adsp *dsp = compr->dsp;
struct wm_adsp_compr_buf *buf;
int ret = 0;

adsp_dbg(dsp, "Pointer request\n");

mutex_lock(&dsp->pwr_lock);

buf = compr->buf;

if (!compr->buf) {
ret = -ENXIO;
goto out;
Expand Down

0 comments on commit 612047f

Please sign in to comment.