Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794065432; b=QUQ70Smw5OIVDVz87vrP1KRnyo3qhM20Kbyr7rkSLB9mJYEAV5WkjOl9COhxlkiVYaW9 4VjO6CErDqTO3TuQQu7BhiQlQVe2Ry7BmJ7jCiaxEEPi9zlg7Uf+I4afqMW+/RH5GMGrN KIZwrBr+2mWbSdfBZ46YSNftRtOW0g2ZpyvqI+rgZzhA5J7e4nlQ3zLAgsjltZqH3p3VX eWwfeAAQW5zJ26X5wYM3eugDIfOtFj72DPpNLasog6kuGIUSO7lTnuf5NkmUyiVhxdkMD 30CRqXepBWc7Ka9SIU+dE4Eq4Wioau4ReeBqnSirDEdzpFb31IBti/PJpDSsbhXD5+g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794065432; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Z6do+8KN395hdDC/qxl3/QjWJHsPx/jecnxC9qpanss=; b=x4jSCeyw1kkMMOMGMGtoD2/RtKJvL7Kx6+a9CKUjdXxG02+I8Yu49MsPGiJY/uHpLb3y grctDYRwI/vB9rfdZJbYz28OZzcGx0yvuQ5KfRayPn6Q2Di2lqsfIffhzNWCDUz4B3TYn usehT5F2s9AKBvPkL8faM7vV7+OqjNfOcfQzixaRyEZETHr4D7esuCkg9DEHic2raDcnt aivygXiuFotXKLkUa0S0IbZn+nET/Sut4riA6A2/pdvSNUpkfa6AN3FK4wHQ2aLr3EKEe zSI3KHKgVMdgQ0i7QuJnQPSvCwPdtSSRiNQN7sNXsuJGRvjky4dmL013P6rlhiry+wQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0bU0nWsc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2787A606D80A; Sat, 7 Nov 2026 15:30:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0bU0nWsc Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD84E1F0089F; Sat, 7 Nov 2026 15:30:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794065432; bh=Z6do+8KN395hdDC/qxl3/QjWJHsPx/jecnxC9qpanss=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0bU0nWscCjdQYQ1+0ieKpUfI2pB/0DWL5vWXj1q3ZHtjFXR1PLM4Aghq8bnZUISCP 2P8jHh6XCE7QYiGXGTF/zZOBLiioVOpFOpafttpICAlbkwImRoeo5UQ9bD3A+dfu8x ZSXaaE1r8HVy6ofxaZpf6YIT4QA4awFEXUwb9sjY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Srinivas Kandagatla , Shawn Guo , Mark Brown , Sasha Levin Subject: [PATCH 7.3 1141/1257] ASoC: qcom: q6apm: Unmap DSP buffers before removing the topology Date: Sat, 7 Nov 2026 08:57:17 -0500 Message-ID: <20261107135010.738609503@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261107134939.434104957@linuxfoundation.org> References: <20261107134939.434104957@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shawn Guo [ Upstream commit a51c5dd7f7fc7cdf4ae28fec4a013d8418d1cb53 ] Since buffers are mapped once in pcm_new() and unmapped in pcm_free(), the unmap relies on the graph info still being registered. During card teardown, however, soc_cleanup_card_resources() removes the components before it frees the PCM runtimes. q6apm-audio's remove callback unloads the topology, which frees every audioreach_graph_info, so by the time q6apm_dai_pcm_free() runs the idr lookup fails and the unmap silently returns -ENODEV. The DSP keeps the old mapping. When the card is bound again, for example after unbinding and binding any codec on it, pcm_new() maps the same buffer once more, the DSP rejects it and the front-end PCM is not created: qcom-apm gprsvc:service:2:1: Error (1) Processing 0x0100100c cmd qcom-apm gprsvc:service:2:1: DSP returned error[100100c] 1 q6apm-dai ...: Audio Start: Buffer Allocation failed rc = -22 snd-sc8280xp sound: ASoC: can't create pcm MultiMedia1 Playback :-22 Release the circular and position buffer mappings of all graphs in q6apm_audio_remove() while the graph info still exists. The unmap helper now takes the q6apm instance directly, since it is called from the APM component rather than from a q6apm-dai child device. Fixes: 8ea6e25c8536 ("ASoC: qcom: q6apm: Add support for early buffer mapping on DSP") Cc: stable@vger.kernel.org Reviewed-by: Srinivas Kandagatla Signed-off-by: Shawn Guo Link: https://patch.msgid.link/20261021041044.2080369-4-shengchao.guo@oss.qualcomm.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/qcom/qdsp6/q6apm.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 1f8d915b5e699..a79bbb34c777e 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -320,11 +320,10 @@ int q6apm_alloc_fragments(struct q6apm_graph *graph, unsigned int dir, phys_addr } EXPORT_SYMBOL_GPL(q6apm_alloc_fragments); -static int __q6apm_unmap_memory_fixed_region(struct device *dev, unsigned int graph_id, +static int __q6apm_unmap_memory_fixed_region(struct q6apm *apm, unsigned int graph_id, bool is_pos_buf) { struct apm_cmd_shared_mem_unmap_regions *cmd; - struct q6apm *apm = dev_get_drvdata(dev->parent); struct audioreach_graph_info *info; uint32_t mem_map_handle; uint32_t pos_mask = is_pos_buf ? APM_MMAP_TOKEN_MAP_TYPE_POS_BUF : 0; @@ -356,13 +355,15 @@ static int __q6apm_unmap_memory_fixed_region(struct device *dev, unsigned int gr int q6apm_unmap_memory_fixed_region(struct device *dev, unsigned int graph_id) { - return __q6apm_unmap_memory_fixed_region(dev, graph_id, false); + return __q6apm_unmap_memory_fixed_region(dev_get_drvdata(dev->parent), + graph_id, false); } EXPORT_SYMBOL_GPL(q6apm_unmap_memory_fixed_region); int q6apm_unmap_pos_buffer(struct device *dev, unsigned int graph_id) { - return __q6apm_unmap_memory_fixed_region(dev, graph_id, true); + return __q6apm_unmap_memory_fixed_region(dev_get_drvdata(dev->parent), + graph_id, true); } EXPORT_SYMBOL_GPL(q6apm_unmap_pos_buffer); @@ -845,6 +846,21 @@ static int q6apm_audio_probe(struct snd_soc_component *component) static void q6apm_audio_remove(struct snd_soc_component *component) { + struct q6apm *apm = dev_get_drvdata(component->dev); + struct audioreach_graph_info *info; + int id; + + /* + * The card core removes components before freeing the PCMs, so + * q6apm-dai's pcm_free() runs after the topology (and graph_info) + * is gone and can no longer unmap. Release the DSP mappings here, + * otherwise the next pcm_new() fails to map the same buffer again. + */ + idr_for_each_entry(&apm->graph_info_idr, info, id) { + __q6apm_unmap_memory_fixed_region(apm, id, false); + __q6apm_unmap_memory_fixed_region(apm, id, true); + } + /* remove topology */ snd_soc_tplg_component_remove(component); } -- 2.53.0