From a15c8260d9adc354fb8e4457a1205d8541579149 Mon Sep 17 00:00:00 2001 From: Satish Babu Patakokila Date: Mon, 13 Apr 2020 19:09:22 +0530 Subject: [PATCH] ASoC: compress: Avoid race condition in compress drain Revert some changes for compress offload path to avoid race condition in drain and partial-drain cases. Change-Id: I4c3e7edb56c6d85c1f4487f348fadc433a762ef0 Signed-off-by: Satish Babu Patakokila --- sound/core/compress_offload.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index bbbd5160f668..b909937ff02d 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -799,6 +799,7 @@ int snd_compr_stop_error(struct snd_compr_stream *stream, } EXPORT_SYMBOL_GPL(snd_compr_stop_error); +#ifndef CONFIG_AUDIO_QGKI static int snd_compress_wait_for_drain(struct snd_compr_stream *stream) { int ret; @@ -833,6 +834,7 @@ static int snd_compress_wait_for_drain(struct snd_compr_stream *stream) return ret; } +#endif static int snd_compr_drain(struct snd_compr_stream *stream) { @@ -851,6 +853,7 @@ static int snd_compr_drain(struct snd_compr_stream *stream) } retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN); +#ifndef CONFIG_AUDIO_QGKI if (retval) { pr_debug("SND_COMPR_TRIGGER_DRAIN failed %d\n", retval); wake_up(&stream->runtime->sleep); @@ -858,6 +861,13 @@ static int snd_compr_drain(struct snd_compr_stream *stream) } return snd_compress_wait_for_drain(stream); +#else + if (!retval) { + stream->runtime->state = SNDRV_PCM_STATE_DRAINING; + wake_up(&stream->runtime->sleep); + } + return retval; +#endif } static int snd_compr_next_track(struct snd_compr_stream *stream) @@ -911,6 +921,7 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) return -EPERM; retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN); +#ifndef CONFIG_AUDIO_QGKI if (retval) { pr_debug("Partial drain returned failure\n"); wake_up(&stream->runtime->sleep); @@ -919,6 +930,10 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) stream->next_track = false; return snd_compress_wait_for_drain(stream); +#else + stream->next_track = false; + return retval; +#endif } #ifdef CONFIG_AUDIO_QGKI