[RFC PATCH 2/4] ASoC: qcom: q6apm: abort prepare when stopping the graph fails

From: Zhang Jiaxi

Date: Thu Oct 08 2026 - 18:36:04 EST


From: Jiaxi Zhang <z1529105815@xxxxxxxxxxx>

PCM prepare ignores a failed STOP and frees the existing fragment table
before configuring and starting the graph again. The LPASS backend prepare
also ignores STOP failure, clears its started flag and sends new format
and PREPARE commands.

Return the STOP error immediately in both callers. Do not discard the
old fragment table or clear the backend's started flag on that path.
The existing successful prepare path is unchanged.

PCM close, compressed free and backend shutdown still perform terminal
graph cleanup. This caller correction leaves core reference accounting
unchanged and does not define recovery from a lost STOP acknowledgment,
close-time DSP recovery, retry policy or concurrent lifecycle serialization.

Based on sound.git for-next
62d9f9ffdfd44e88010412bf8f23732f0a93a9be. No target hardware result is claimed.

Signed-off-by: Jiaxi Zhang <z1529105815@xxxxxxxxxxx>

---
diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c
--- a/sound/soc/qcom/qdsp6/q6apm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6apm-dai.c
@@ -347,7 +347,9 @@
audioreach_set_default_channel_mapping(cfg.channel_map, runtime->channels);
if (prtd->state) {
/* clear the previous setup if any */
- q6apm_graph_stop(prtd->graph);
+ ret = q6apm_graph_stop(prtd->graph);
+ if (ret)
+ return ret;
q6apm_free_fragments(prtd->graph, substream->stream);
}

diff --git a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c
--- a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c
+++ b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c
@@ -234,7 +234,9 @@
int rc;

if (dai_data->is_port_started[dai->id]) {
- q6apm_graph_stop(dai_data->graph[dai->id]);
+ rc = q6apm_graph_stop(dai_data->graph[dai->id]);
+ if (rc)
+ return rc;
dai_data->is_port_started[dai->id] = false;

}