From 6beee44adb0a6fc98f849dfa4b3403291530c5a5 Mon Sep 17 00:00:00 2001 From: mcc45tr Date: Fri, 4 Sep 2026 23:58:19 +0300 Subject: [PATCH] ASoC: qcom: keep q6asm setup state through trigger stop --- sound/soc/qcom/qdsp6/q6asm-dai.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c index 1352a0b7db8f..0263a43add82 100644 --- a/sound/soc/qcom/qdsp6/q6asm-dai.c +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c @@ -188,7 +188,6 @@ static void event_handler(uint32_t opcode, uint32_t token, case ASM_CLIENT_EVENT_CMD_RUN_DONE: break; case ASM_CLIENT_EVENT_CMD_EOS_DONE: - prtd->state = Q6ASM_STREAM_STOPPED; complete_all(&prtd->eos_done); break; case ASM_CLIENT_EVENT_DATA_WRITE_DONE: @@ -229,6 +228,11 @@ static int q6asm_dai_prepare(struct snd_soc_component *component, /* rate and channels are sent to audio driver */ if (prtd->state == Q6ASM_STREAM_RUNNING) { /* clear the previous setup if any */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && + !wait_for_completion_timeout(&prtd->eos_done, + msecs_to_jiffies(1000))) + dev_warn(dev, "rendered EOS timed out before stream re-prepare\n"); + ret = q6asm_cmd(prtd->audio_client, prtd->stream_id, CMD_CLOSE); if (ret < 0) { dev_err(dev, "Failed to close q6asm stream %d\n", prtd->stream_id); @@ -351,7 +355,6 @@ static int q6asm_dai_trigger(struct snd_soc_component *component, 0, 0, 0); break; case SNDRV_PCM_TRIGGER_STOP: - prtd->state = Q6ASM_STREAM_STOPPED; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { reinit_completion(&prtd->eos_done); ret = q6asm_cmd_nowait(prtd->audio_client, @@ -402,6 +405,7 @@ static int q6asm_dai_open(struct snd_soc_component *component, prtd->substream = substream; init_completion(&prtd->eos_done); + complete_all(&prtd->eos_done); prtd->audio_client = q6asm_audio_client_alloc(dev, (q6asm_cb)event_handler, prtd, stream_id, LEGACY_PCM_MODE); @@ -477,7 +481,7 @@ static int q6asm_dai_close(struct snd_soc_component *component, if (prtd->audio_client) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && - prtd->state == Q6ASM_STREAM_STOPPED && + prtd->state == Q6ASM_STREAM_RUNNING && !wait_for_completion_timeout(&prtd->eos_done, msecs_to_jiffies(1000))) dev_warn(component->dev, -- 2.55.0