2019-05-06 14:44:05

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 4.19 79/99] ASoC: wm_adsp: Correct handling of compressed streams that restart

From: Charles Keepax <[email protected]>

commit 639e5eb3c7d67e407f2a71fccd95323751398f6f upstream.

Previously support was added to allow streams to be stopped and
started again without the DSP being power cycled and this was done
by clearing the buffer state in trigger start. Another supported
use-case is using the DSP for a trigger event then opening the
compressed stream later to receive the audio, unfortunately clearing
the buffer state in trigger start destroys the data received
from such a trigger. Correct this issue by moving the call to
wm_adsp_buffer_clear to be in trigger stop instead.

Fixes: 61fc060c40e6 ("ASoC: wm_adsp: Support streams which can start/stop with DSP active")
Signed-off-by: Charles Keepax <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
sound/soc/codecs/wm_adsp.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -3441,8 +3441,6 @@ int wm_adsp_compr_trigger(struct snd_com
}
}

- wm_adsp_buffer_clear(compr->buf);
-
/* Trigger the IRQ at one fragment of data */
ret = wm_adsp_buffer_write(compr->buf,
HOST_BUFFER_FIELD(high_water_mark),
@@ -3454,6 +3452,7 @@ int wm_adsp_compr_trigger(struct snd_com
}
break;
case SNDRV_PCM_TRIGGER_STOP:
+ wm_adsp_buffer_clear(compr->buf);
break;
default:
ret = -EINVAL;



2019-05-07 08:46:08

by Nobuhiro Iwamatsu

[permalink] [raw]
Subject: Re: [PATCH 4.19 79/99] ASoC: wm_adsp: Correct handling of compressed streams that restart

Hi,

On Mon, May 06, 2019 at 04:32:52PM +0200, Greg Kroah-Hartman wrote:
> From: Charles Keepax <[email protected]>
>
> commit 639e5eb3c7d67e407f2a71fccd95323751398f6f upstream.
>
> Previously support was added to allow streams to be stopped and
> started again without the DSP being power cycled and this was done
> by clearing the buffer state in trigger start. Another supported
> use-case is using the DSP for a trigger event then opening the
> compressed stream later to receive the audio, unfortunately clearing
> the buffer state in trigger start destroys the data received
> from such a trigger. Correct this issue by moving the call to
> wm_adsp_buffer_clear to be in trigger stop instead.
>
> Fixes: 61fc060c40e6 ("ASoC: wm_adsp: Support streams which can start/stop with DSP active")
> Signed-off-by: Charles Keepax <[email protected]>
> Signed-off-by: Mark Brown <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

This commit has other problems, and it is fixed by commit 43d147be5738a9ed6cfb25c285ac50d6dd5793be.
Please apply this commit too.

commit 43d147be5738a9ed6cfb25c285ac50d6dd5793be
Author: Charles Keepax <[email protected]>
Date: Tue Apr 2 13:49:14 2019 +0100

ASoC: wm_adsp: Check for buffer in trigger stop

Trigger stop can be called in situations where trigger start failed
and as such it can't be assumed the buffer is already attached to
the compressed stream or a NULL pointer may be dereferenced.

Fixes: 639e5eb3c7d6 ("ASoC: wm_adsp: Correct handling of compressed streams that restart")
Signed-off-by: Charles Keepax <[email protected]>
Signed-off-by: Mark Brown <[email protected]>

Best regards,
Nobuhiro

2019-05-07 12:50:57

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 4.19 79/99] ASoC: wm_adsp: Correct handling of compressed streams that restart

On Tue, May 07, 2019 at 05:44:30PM +0900, Nobuhiro Iwamatsu wrote:
> Hi,
>
> On Mon, May 06, 2019 at 04:32:52PM +0200, Greg Kroah-Hartman wrote:
> > From: Charles Keepax <[email protected]>
> >
> > commit 639e5eb3c7d67e407f2a71fccd95323751398f6f upstream.
> >
> > Previously support was added to allow streams to be stopped and
> > started again without the DSP being power cycled and this was done
> > by clearing the buffer state in trigger start. Another supported
> > use-case is using the DSP for a trigger event then opening the
> > compressed stream later to receive the audio, unfortunately clearing
> > the buffer state in trigger start destroys the data received
> > from such a trigger. Correct this issue by moving the call to
> > wm_adsp_buffer_clear to be in trigger stop instead.
> >
> > Fixes: 61fc060c40e6 ("ASoC: wm_adsp: Support streams which can start/stop with DSP active")
> > Signed-off-by: Charles Keepax <[email protected]>
> > Signed-off-by: Mark Brown <[email protected]>
> > Signed-off-by: Greg Kroah-Hartman <[email protected]>
>
> This commit has other problems, and it is fixed by commit 43d147be5738a9ed6cfb25c285ac50d6dd5793be.
> Please apply this commit too.
>
> commit 43d147be5738a9ed6cfb25c285ac50d6dd5793be
> Author: Charles Keepax <[email protected]>
> Date: Tue Apr 2 13:49:14 2019 +0100
>
> ASoC: wm_adsp: Check for buffer in trigger stop
>
> Trigger stop can be called in situations where trigger start failed
> and as such it can't be assumed the buffer is already attached to
> the compressed stream or a NULL pointer may be dereferenced.
>
> Fixes: 639e5eb3c7d6 ("ASoC: wm_adsp: Correct handling of compressed streams that restart")
> Signed-off-by: Charles Keepax <[email protected]>
> Signed-off-by: Mark Brown <[email protected]>

Thank you, now queued up!

greg k-h