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

From: Greg Kroah-Hartman
Date: Mon May 06 2019 - 10:43:07 EST

From: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxx>

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 <ckeepax@xxxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

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,
@@ -3454,6 +3452,7 @@ int wm_adsp_compr_trigger(struct snd_com
+ wm_adsp_buffer_clear(compr->buf);
ret = -EINVAL;