From nobody Fri Sep 25 00:41:18 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 559994FC8F1 for ; Fri, 18 Sep 2026 13:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789739409; cv=none; b=erY74I917me7wXTMTufyXEt+mfA5c8if1LpTfDs6D2Z1QIc21VqzOUsXFVYLY3T97tJXMFwhsvBxo4YwCqJ9vwvwj+U36V2FxPotxHoM1WLH7YyKGX9WkLs3/dxplggnbDU2O45kS4VW32iISxGWavjm8q+/NkyKrSCOe1hCuig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789739409; c=relaxed/simple; bh=3zPDkuCDmQ38oUL9/eF9wJT7+qJydWJzTsR5SSVPT00=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=arYbXCQCQ2Lx1V+1e6dJRiipm554ZgLZS5gZHc3OdUkeOngy5p4Gr6wflc534TkRm/IwOMyuv+q2lzy+rbLZ4AUBYEvS4n7LYkvToGV8r3I8JCACtRAuQ0Xi2ek2c3crnLzIVR3/mrnsXCMSnHh+RKxqPSGPCZJiYPg0czhnBRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=QgDK1/CH; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=b4NkAV8k; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="QgDK1/CH"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="b4NkAV8k" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68IDP8er046645 for ; Fri, 18 Sep 2026 13:50:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= oDQV9EtK+HUfHaV7DcliO9oX+WewlHGg2nJCScj03wk=; b=QgDK1/CHfX1G/gL4 S2I6jAuWNMUTvi3gKzzUZBr2Cy4aLUUx8s1bpU537HyOiPV0E617cKVhDtOwTTNA ZogziqhCjhuF8+puWTskpneB+fTnPgcGCzQyN69JIWnto/HYxEjKX+2Jzgh6EEI3 T1Phzl2wsx82cwa2mTehDk0ju1gnoP1s87f74Y0T1Y7kkmTBplDB81SczXkdot17 H3wky8I2Bo8p95CDN4KgtiB+X9w/JmDAbtvNHnueU/dwD0M18TzXOmhSr8D9ZI3x kPdxZZ7+MT4lnP1z+qe+UOA9nj9+WUf8D/c7i/oMWzanNArFPsvzJSDbonwr75TI nyuccQ== Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4grmv5me9f-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 18 Sep 2026 13:50:07 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cc21bc2923fso724580a12.2 for ; Fri, 18 Sep 2026 06:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1789739407; x=1790344207; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oDQV9EtK+HUfHaV7DcliO9oX+WewlHGg2nJCScj03wk=; b=b4NkAV8kis2ZYikazsxk3lIx6pMovHhGGjeJ0kVddugQjK845Cm20MIdjsm0oOMRKv ZaLVwTkcaJ3ZzsSojCfSa4vQXU9d86yg0F3iAl00tDTNZ/ROxpLCo5fDchjjAwvLrePz wjNwQoFKMIEKbY/MpWl53KvVQKdCnIlEzXPhLp8qcX1JGyE16TAwvex4nVFFCWYFG36h pM2hunhx/il9wZuzTU4U0TB0qkMW/6eIRqBuaaMQSgpgipC3KMwxQy7WKvX6lK7Apt5T aQbtnc8IbeCGSzQQP6g5/FXSFBnrjcTDdS5faAkj1pCP3Vlh3kossvg2OLhd0FS3iMGd 4Tsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789739407; x=1790344207; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=oDQV9EtK+HUfHaV7DcliO9oX+WewlHGg2nJCScj03wk=; b=mnZIBu1bIXqd5JivHLZWkQK1dTFYn7/fwYg6QYcVlFwRAA3jXIbAv7uuDbiRg2vuQo 0cfSakqt2rBifVfcN9LVH5SR6IDPwO5ZSfiME2NjfC630lv9xlyPGu2oDEo35Q1AUdn+ SAs9Cdh0MSjcO/pzGOt9f5+9OMqHPVFBPLHOWhvPaOvYDvaTx8aXBAZqHhyO49DLQJ3F H+Fq1IPL4Kam9RFYuaxAK8MfRUsCXlsSv+mWXp/7dAvB4sS6+cHQyl9s3IYl0e50DE63 DRXv6S5RUUUXz8hFhTyNLqxzuK9QOgDtdrGQKh/qubFYkZsf/c856yhM6s/ARsyMVaLS b0ew== X-Forwarded-Encrypted: i=1; AKwUvBz8Lg5IQ3S1Qja33SoB1aKnVCBSqYuOxbDyHLf+qFL9GjQ5se5nx8SlOpxO1CIbr+tL6SGzk21OPPdoZfM=@vger.kernel.org X-Gm-Message-State: AFuF++kfFtO0e5KG7y17t5qRSsr0BhIhxeCPQM8AEuuPHUjF52Ryax2c JXU6JuzGxClwGzB7qHORRxahyOnKtiV2qkoLPIRVwLQrLjOUP2SZdOvHTx/l0H6+4FzQ+cfV/ST f8OOzTYVycVwRV9Hl9FuKv1LDfydWJM3Kk9jsu7amRVqAGbv2yrJrlLZOL3/iHjIpuy9c0PyPlW g= X-Gm-Gg: AYBFou2mAMQC55V+j6KmJr97fhi7x5fLjGQOcE8+uVEUGy6LDNkqd5FoMbMmY5Roo+i pkOh5BDjugTtWdOSDD0syblCxVwDFsDZ3hoPtCLtprV3U8F9Cv1laMmWurF4ROJ3r5NxTDyqGBY kMRCJgnE/Cm3WmMt78MVF75AWNdIBfBHWkGpxQiR1FhcaffPAY+R10Qbkb0cQ6mY0W/y2GM/mOu JUDa71JhPgEVXuHmdBEveY1aLoK/IRosIClipSfXEqXp4wasAmX1vwPh3tCxPnVhyUHtZUbJaTC EqED+ZOyYbAa6vDaNja0igHPKfZPWcC6pC0fOB+jqxZ0KbHoS3Bm0h3uouroDYWHP2wY//xXsKO o+ANNbun3XEQ0J2W4uTzvbq9HjMc= X-Received: by 2002:a05:6a21:1b81:b0:3cd:8bba:824f with SMTP id adf61e73a8af0-3dd8c3d3acfmr6221628637.4.1789739406879; Fri, 18 Sep 2026 06:50:06 -0700 (PDT) X-Received: by 2002:a05:6a21:1b81:b0:3cd:8bba:824f with SMTP id adf61e73a8af0-3dd8c3d3acfmr6221581637.4.1789739406436; Fri, 18 Sep 2026 06:50:06 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cc5c50e9fbesm1013934a12.32.2026.09.18.06.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 06:50:06 -0700 (PDT) From: Ajay Kumar Nandam Date: Fri, 18 Sep 2026 19:19:35 +0530 Subject: [PATCH v3 1/3] ASoC: qcom: q6apm: clear g_apm on driver removal Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260918-vmid-v3-v3-1-f1cbf47bf173@oss.qualcomm.com> References: <20260918-vmid-v3-v3-0-f1cbf47bf173@oss.qualcomm.com> In-Reply-To: <20260918-vmid-v3-v3-0-f1cbf47bf173@oss.qualcomm.com> To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Pierre-Louis Bossart , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Mohit Sharma , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Ajay Kumar Nandam X-Mailer: b4 0.15.0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTE4MDE5NiBTYWx0ZWRfX3KXyZ32tR0J+ BdQSOZaAI/+VNLAzvDh0o1fr4NgZ1iV6rYuTJoDkQTX355vbIHEKAs5msugsL8RWAPweoVybKET +lKGMqEsBTpFvdSceEcAZrn3gxtr0U41B2Ru0UHyjrBeHzwenYVj3qTu0ulkGmQqlLWcQ16/nQ9 9P0AkOkEbLNoaUUsnSISC0dpjQDdklnCIzMAs7z1eh8M9b06EEnxtTblF9g13diu4/FXKKrEq2p eoaGjGQRljSscjHjhke/lQkdocgf8mGqS6mkCMbMTLQRBx222riDO0x80cmhMYCHNNHtY6WmQ3i zYSq9iAwAQvbr6h4CwruK8rywFoNMGkMuC/7V0TqQy/5OUdkNxW7m6goNXZqR1HE/hLGx6ankB9 wuxnM6VwsoyefWjyt4X7hhUNh/DOVGomOyqxYk7hWkhzU/n0puW/iDJoL5J/CKFzRvCQG2Xx/hT 9PiYYutwpikleFwQrxQ== X-Authority-Analysis: v=2.4 cv=E+5YNqdl c=1 sm=1 tr=0 ts=6aad418f cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=i9zpEd1wrD5FINdKp7YA:9 a=QEXdDO2ut3YA:10 a=_Vgx9l1VpLgwpw_dHYaR:22 X-Proofpoint-ORIG-GUID: m_dfk55Rmo2HEqGXzAZRi8t4bEX9yzF5 X-Proofpoint-GUID: m_dfk55Rmo2HEqGXzAZRi8t4bEX9yzF5 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTE4MDE5NiBTYWx0ZWRfX5aZrNyeZbZKV nKHFLtCgW5+IRysQjB1PX9H1daVhW7g5dqUIirXMLjhZkCmF8Hn6OHLj3Vsof9mIMVI4ut1RGFc 2Pa1HkinsUhjoz/NpsGfM5ZchwFDWiE= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-18_04,2026-09-16_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 impostorscore=0 spamscore=0 phishscore=0 adultscore=0 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609180196 The global g_apm pointer is set during apm_probe() but never cleared in apm_remove(). After the driver is removed the devm-managed struct q6apm is freed, leaving g_apm dangling. A subsequent call to q6apm_is_adsp_ready() dereferences the freed pointer. Clear g_apm in apm_remove() before the component is unregistered so that q6apm_is_adsp_ready() returns false instead of triggering a use-after-free. Fixes: 5477518b8a0e ("ASoC: qdsp6: audioreach: add q6apm support") Signed-off-by: Ajay Kumar Nandam --- sound/soc/qcom/qdsp6/q6apm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 641d6d243229..12c6dfe4c58e 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -894,6 +894,7 @@ static int apm_probe(gpr_device_t *gdev) =20 static void apm_remove(gpr_device_t *gdev) { + g_apm =3D NULL; of_platform_depopulate(&gdev->dev); snd_soc_unregister_component(&gdev->dev); } --=20 2.34.1 From nobody Fri Sep 25 00:41:18 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 024654E532D for ; Fri, 18 Sep 2026 13:50:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789739416; cv=none; b=mb2yG8ZKYw5S2gEN9Vmxt2MEj07pSJYy43Kx4CQ0vghUPrpW5DLzZIk/vGLdxfIYHYDFX53tbpYDPCNoobT1jvuyTcIfRjNkoAsEETo3MM4FAT/aQn4Funl7LedisV7ygVVkslP3WXUSK58N0mirZoNoY/wQ2cVeyS+726pohVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789739416; c=relaxed/simple; bh=R6WhnRn3OYIVaQbRG/LcPLmBEV8zvrqFCWDo5EgDbKo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T7vW20KWGQ1dGvyl9uVqbLP/QnU8yJxzeUhC3aloZGsjEcrZtgvjnlcOfMjojg4LkshnT6iDKoQTpIQcJ9zBV2UhqMtEOtXobba/wlb9TPOAq22g5HiX/U6xSyUCyOloL3Ia+jyWHlJ6wPdT2auLpSg5AwYxPi13Cemf1wyXuog= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=Se3oGCAz; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=X/D9o+2I; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="Se3oGCAz"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="X/D9o+2I" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68IDOigl745944 for ; Fri, 18 Sep 2026 13:50:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 362TzmWCoKZ0VSlCRZr3hytW7UtSJaVQd8dVIrPrWIk=; b=Se3oGCAzWN0dWOxC RjBYGLDdPHO7Fsns9w2aoKiNE3a2fcuDJ24LM+PCC36YZXz/Nmjk/zYxYYWX6QfC 7I68iCo3/6JkGTBBBj46hAOQGYDtrrRPEA7ZS42LG4wzKkzBX3zeDxxTr9VGmw8G wQxT67Jrw6k5ue0gOeqMLgP4cP73/8WskoBTCmz9cTUSw14l5VFHXF/3cTE3781H M7lsi2w/bycKxmFbSvtjmqC0MUPF+xTZZljNvH5Pv605zsbQ35xrczNuw57TRNcX yZ3tw9jxbuv/3NAYK1ZeDEGfr9nbH7mWZkoBmsTwVEj8ofztc80tySu/vgyY5GKt MVWnWA== Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gs23915hu-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 18 Sep 2026 13:50:13 +0000 (GMT) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-86b4048367cso1073057b3a.2 for ; Fri, 18 Sep 2026 06:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1789739412; x=1790344212; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=362TzmWCoKZ0VSlCRZr3hytW7UtSJaVQd8dVIrPrWIk=; b=X/D9o+2ISkCjeel5ACB/zWQv9wO8uv/NW42ApRdmq7H7PjEQkx/2CW6tTi+0nO33cz fyrXfcOg5NxlobSamlvLAU9zew/UUvqVJhFXukJzhI2IlOgJGY6sWyG0Pz1rFt7FOzLo WFAy0AGd94eE+ddOlEXr88cwwG/O1sVPo/U5pbRcq9NDKZIeOY41PqTKaqbQeWDnzu7k Z/TkvXIjkVwowIQRKDsMvo+ffhxEj3GQSKvfGKfiyN7lShbmAVEDtwF3uc4cybeYlBsy lDNqRSxHqiEEY+U0Z+/epWRsbFN+jKqq86SjneYeMYFiu5K4kkraU/BuXTI6gd3mmfcE aDhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789739412; x=1790344212; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=362TzmWCoKZ0VSlCRZr3hytW7UtSJaVQd8dVIrPrWIk=; b=20PrXbHwITu7xBnnV/XVZga32RjXH+EDxiwKPChQOkz8kEBR5/Mgu8FaVWQAoaQwNz ZFwYJQbONHoP9ri/gDge+0YxOGPSykVGmxUHJHIuYwh5Y9yGrPb5M9hlpN8GzDkDAeyx rk+JicjDt1cNkvQKEd7bElAUoAc0BYVYMLFd1h+y/Z4vgDbmhmKAiJxJvFKRS96iqwQf kpp/ih3KTAjxEZM8aOpCj7U0v/qO64hM6CSwukpB2B4q9YThXkS+vXypd9EEsAErZIn9 8Ic2ToB0i9Wp/yfoWbHtLjFgUYHqN+wLINZzsKnNvD9VSGb4lgeEp6x1FzbTq34mwMcJ gP1A== X-Forwarded-Encrypted: i=1; AKwUvBzabIwWzZIVWGa0skTgA5PuIr3ny/GhBRQYW0MosZzett2M2tLKedw7OdmtjMugkWuU5gNvC0DK8XlYQKo=@vger.kernel.org X-Gm-Message-State: AFuF++mwp8TXLVDeAdcx4Pqom2Ay5u4dz8D+Yt6sxeLCsZZEZHrc2kD0 LXcLc/39J8kSXKobTL8jc95Zxf/tdOwpQoIkMiJVctqVexe3opF8CfqarVQsBsW+B+pWm4r9dn1 lRaku2a3GRql+UX9EHtACYe8kZPqhu395lgiaq1Rqbxn2lin0l1KCOVYIin3cvWymK6g= X-Gm-Gg: AYBFou0JGIOq0dDI9BGYPGzvHbPeGhPN5+pveHq5D8JEESj/wfSogPQQOF3p6A5HWr3 bRCAVDukSDKCukJ973Bb00EQoIYukzbK7mVc0mX8hZEza2P3oCea08tA7c0+amF6N3rG4h616si 0UNeR0Ma6PugK9Cep/HUVZQMIbyPKcBR4hEKFRY5AoYHgG05/3/xv39a34uEX2+fCUBegz01RMm FL8jmhERCbLDMioEV9XvemKQO9DwawDZug1e2ChjlJexYSVCtDOQmn0/tVLJmS2aM1zcAJk7FwC Xz//icceuYqwDn2W8xPXZN1kaU5cfhI5jAw+7pq4ZkPNtWcSkkxTzHolG4BfzB650xHB30R/twK yt047JxzIxUcwxAKJo0Hwbw2mdC8= X-Received: by 2002:a05:6a00:f87:b0:86d:7462:414a with SMTP id d2e1a72fcca58-874db8eb145mr5747822b3a.7.1789739412430; Fri, 18 Sep 2026 06:50:12 -0700 (PDT) X-Received: by 2002:a05:6a00:f87:b0:86d:7462:414a with SMTP id d2e1a72fcca58-874db8eb145mr5747731b3a.7.1789739411803; Fri, 18 Sep 2026 06:50:11 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cc5c50e9fbesm1013934a12.32.2026.09.18.06.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 06:50:11 -0700 (PDT) From: Ajay Kumar Nandam Date: Fri, 18 Sep 2026 19:19:36 +0530 Subject: [PATCH v3 2/3] ASoC: qcom: qdsp6: generalize GPR service domain Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260918-vmid-v3-v3-2-f1cbf47bf173@oss.qualcomm.com> References: <20260918-vmid-v3-v3-0-f1cbf47bf173@oss.qualcomm.com> In-Reply-To: <20260918-vmid-v3-v3-0-f1cbf47bf173@oss.qualcomm.com> To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Pierre-Louis Bossart , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Mohit Sharma , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Ajay Kumar Nandam , Pratyush Meduri X-Mailer: b4 0.15.0 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTE4MDE5NiBTYWx0ZWRfX5od0mvzX/fER aeSSmuR7fJUVYi0E0PC8CC/f4Ldpdqa5nOQ08GQ3eO2K87BQwsRo+J3QnSIfOT3rlgmJuoX8eMv 8mmD83zgCDbKz1oyWLEReQeRvjG3BSA= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTE4MDE5NiBTYWx0ZWRfX4r1tFb/QOzSp O15BMIec2FvydBFVf8/KFFSBxoySCHzDXCU0zhFQ5D68aoMKLJ62ZWY3K0oEetQ/RNjCHA0nfph TUZVarwx2Od2CiPyyrSgKNyeTGk1z20yg9kfBcUMw1Av10LmpOv9PHew+6YCKfBt3T50cGayGJc 4qc/MEmhr8pV1dlibkTo9lJdoLpHv019cmHeIKzr6MYjsO/UQOhzFMu9RR/nEI7fDSPSlItzIAC xEzNLr8hLyOY78feX4FF/psihC4k/FRej6CGsoMfBpN4SWxPcQSSH79ThSbpqCpelNjKq84cyVH wFNYJJd3Sl1jynTg4JZWax5IQa0wV5XdIewhnMBCe6WL87OT+D96OSoQHntuMrsMkADEETz5WDa nAUnYbOooAm0Q0cB8IIjIysEe9OKywmEvfieuZZ4FxNLtOwkYLkIo6yymr92F3GZ2eKVWFhfLOe bMeGcyE0sLni54lBmrw== X-Proofpoint-ORIG-GUID: hnBmC3uSttv1WIzllQHc-OFWR30UZL25 X-Authority-Analysis: v=2.4 cv=I7zw19gg c=1 sm=1 tr=0 ts=6aad4195 cx=c_pps a=WW5sKcV1LcKqjgzy2JUPuA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=06UwNDcAWG1pVACfRQkA:9 a=QEXdDO2ut3YA:10 a=OpyuDcXvxspvyRM73sMx:22 X-Proofpoint-GUID: hnBmC3uSttv1WIzllQHc-OFWR30UZL25 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-18_04,2026-09-16_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609180196 AudioReach builds APM and PRM command packets with the GPR destination domain hardcoded to GPR_DOMAIN_ID_ADSP. This assumes audio is always served by the ADSP, which is true for all currently supported targets. On platforms such as Qualcomm Shikra, audio is served by the modem DSP (mDSP) instead. The GPR node in DT already describes which DSP backs the service via its qcom,domain property (e.g. GPR_DOMAIN_ID_MODEM), and the GPR core exposes it as gdev->domain_id. But the AudioReach packet builders ignore this and always target the ADSP, so every APM/PRM command is routed to the wrong DSP on mDSP targets and audio does not function. Fix this by reading the GPR destination domain from gdev->domain_id and stamping it in the send helpers (q6apm_send_cmd_sync, audioreach_graph_send_cmd_sync, q6prm_send_cmd_sync) just before dispatch. This centralizes the domain decision at the send layer rather than threading it through every packet-allocation call site. For the small number of async data-path sends that bypass the sync helpers (write, read, compr, EOS), the domain is stamped inline before gpr_send_port_pkt(). When no domain is available the helper falls back to GPR_DOMAIN_ID_ADSP, so all existing ADSP targets remain unchanged. Co-developed-by: Pratyush Meduri Signed-off-by: Pratyush Meduri Signed-off-by: Ajay Kumar Nandam --- sound/soc/qcom/qdsp6/audioreach.c | 12 +++++++++--- sound/soc/qcom/qdsp6/audioreach.h | 22 +++++++++++++++------- sound/soc/qcom/qdsp6/q6apm.c | 8 +++++++- sound/soc/qcom/qdsp6/q6apm.h | 2 +- sound/soc/qcom/qdsp6/q6prm.c | 2 ++ 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audio= reach.c index e6e9eb2e85aa..f7ae6d0db7e7 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -579,10 +579,10 @@ EXPORT_SYMBOL_GPL(audioreach_alloc_graph_pkt); int audioreach_send_cmd_sync(struct device *dev, gpr_device_t *gdev, struct gpr_ibasic_rsp_result_t *result, struct mutex *cmd_lock, gpr_port_t *port, wait_queue_head_t *cmd_wait, - const struct gpr_pkt *pkt, uint32_t rsp_opcode) + struct gpr_pkt *pkt, uint32_t rsp_opcode) { =20 - const struct gpr_hdr *hdr =3D &pkt->hdr; + struct gpr_hdr *hdr =3D &pkt->hdr; int rc; =20 mutex_lock(cmd_lock); @@ -622,10 +622,12 @@ int audioreach_send_cmd_sync(struct device *dev, gpr_= device_t *gdev, } EXPORT_SYMBOL_GPL(audioreach_send_cmd_sync); =20 -int audioreach_graph_send_cmd_sync(struct q6apm_graph *graph, const struct= gpr_pkt *pkt, +int audioreach_graph_send_cmd_sync(struct q6apm_graph *graph, struct gpr_p= kt *pkt, uint32_t rsp_opcode) { =20 + pkt->hdr.dest_domain =3D audioreach_gpr_dest_domain(graph->apm->gdev); + return audioreach_send_cmd_sync(graph->dev, NULL, &graph->result, &graph= ->lock, graph->port, &graph->cmd_wait, pkt, rsp_opcode); } @@ -970,6 +972,8 @@ int audioreach_compr_set_param(struct q6apm_graph *grap= h, if (rc) return rc; =20 + pkt->hdr.dest_domain =3D audioreach_gpr_dest_domain(graph->apm->gdev); + return gpr_send_port_pkt(graph->port, pkt); } EXPORT_SYMBOL_GPL(audioreach_compr_set_param); @@ -1489,6 +1493,8 @@ int audioreach_shared_memory_send_eos(struct q6apm_gr= aph *graph) =20 eos->policy =3D WR_SH_MEM_EP_EOS_POLICY_LAST; =20 + pkt->hdr.dest_domain =3D audioreach_gpr_dest_domain(graph->apm->gdev); + return gpr_send_port_pkt(graph->port, pkt); } EXPORT_SYMBOL_GPL(audioreach_shared_memory_send_eos); diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audio= reach.h index 62a2fd79bbcb..2ae7b402a137 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -912,14 +912,19 @@ struct audioreach_module_config { }; =20 /* Packet Allocation routines */ -void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t - token); +static inline u16 audioreach_gpr_dest_domain(gpr_device_t *gdev) +{ + return gdev && gdev->domain_id ? gdev->domain_id : GPR_DOMAIN_ID_ADSP; +} + +void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, + uint32_t token); void audioreach_set_default_channel_mapping(u8 *ch_map, int num_channels); void *audioreach_alloc_cmd_pkt(int payload_size, uint32_t opcode, uint32_t token, uint32_t src_port, uint32_t dest_port); void *audioreach_alloc_apm_pkt(int pkt_size, uint32_t opcode, uint32_t tok= en, - uint32_t src_port); + uint32_t src_port); void *audioreach_alloc_pkt(int payload_size, uint32_t opcode, uint32_t token, uint32_t src_port, uint32_t dest_port); @@ -930,10 +935,13 @@ int audioreach_tplg_init(struct snd_soc_component *co= mponent); =20 /* Module specific */ void audioreach_graph_free_buf(struct q6apm_graph *graph); -int audioreach_send_cmd_sync(struct device *dev, gpr_device_t *gdev, struc= t gpr_ibasic_rsp_result_t *result, - struct mutex *cmd_lock, gpr_port_t *port, wait_queue_head_t *cmd_w= ait, - const struct gpr_pkt *pkt, uint32_t rsp_opcode); -int audioreach_graph_send_cmd_sync(struct q6apm_graph *graph, const struct= gpr_pkt *pkt, +int audioreach_send_cmd_sync(struct device *dev, gpr_device_t *gdev, + struct gpr_ibasic_rsp_result_t *result, + struct mutex *cmd_lock, gpr_port_t *port, + wait_queue_head_t *cmd_wait, + struct gpr_pkt *pkt, uint32_t rsp_opcode); +int audioreach_graph_send_cmd_sync(struct q6apm_graph *graph, + struct gpr_pkt *pkt, uint32_t rsp_opcode); int audioreach_set_media_format(struct q6apm_graph *graph, const struct audioreach_module *module, diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 12c6dfe4c58e..1845eb7b5739 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -29,11 +29,13 @@ struct apm_graph_mgmt_cmd { =20 static struct q6apm *g_apm; =20 -int q6apm_send_cmd_sync(struct q6apm *apm, const struct gpr_pkt *pkt, +int q6apm_send_cmd_sync(struct q6apm *apm, struct gpr_pkt *pkt, uint32_t rsp_opcode) { gpr_device_t *gdev =3D apm->gdev; =20 + pkt->hdr.dest_domain =3D audioreach_gpr_dest_domain(gdev); + return audioreach_send_cmd_sync(&gdev->dev, gdev, &apm->result, &apm->loc= k, NULL, &apm->wait, pkt, rsp_opcode); } @@ -502,6 +504,8 @@ int q6apm_write_async(struct q6apm_graph *graph, uint32= _t len, uint32_t msw_ts, =20 mutex_unlock(&graph->lock); =20 + pkt->hdr.dest_domain =3D audioreach_gpr_dest_domain(graph->apm->gdev); + return gpr_send_port_pkt(graph->port, pkt); } EXPORT_SYMBOL_GPL(q6apm_write_async); @@ -536,6 +540,8 @@ int q6apm_read(struct q6apm_graph *graph) =20 mutex_unlock(&graph->lock); =20 + pkt->hdr.dest_domain =3D audioreach_gpr_dest_domain(graph->apm->gdev); + return gpr_send_port_pkt(graph->port, pkt); } EXPORT_SYMBOL_GPL(q6apm_read); diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index 5cb51ca491dc..9092359ccf90 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -147,7 +147,7 @@ int q6apm_alloc_fragments(struct q6apm_graph *graph, int q6apm_free_fragments(struct q6apm_graph *graph, unsigned int dir); int q6apm_unmap_memory_fixed_region(struct device *dev, unsigned int graph= _id); /* Helpers */ -int q6apm_send_cmd_sync(struct q6apm *apm, const struct gpr_pkt *pkt, +int q6apm_send_cmd_sync(struct q6apm *apm, struct gpr_pkt *pkt, uint32_t rsp_opcode); =20 /* Callback for graph specific */ diff --git a/sound/soc/qcom/qdsp6/q6prm.c b/sound/soc/qcom/qdsp6/q6prm.c index 04892fb4423f..f93383078eb1 100644 --- a/sound/soc/qcom/qdsp6/q6prm.c +++ b/sound/soc/qcom/qdsp6/q6prm.c @@ -51,6 +51,8 @@ struct prm_cmd_release_rsc { =20 static int q6prm_send_cmd_sync(struct q6prm *prm, struct gpr_pkt *pkt, uin= t32_t rsp_opcode) { + pkt->hdr.dest_domain =3D audioreach_gpr_dest_domain(prm->gdev); + return audioreach_send_cmd_sync(prm->dev, prm->gdev, &prm->result, &prm->= lock, NULL, &prm->wait, pkt, rsp_opcode); } --=20 2.34.1 From nobody Fri Sep 25 00:41:18 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 409CD4FE2CE for ; Fri, 18 Sep 2026 13:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789739421; cv=none; b=p3D4SO0S/bRPz/Kmt3HJ1vOGJK5RNwElFtZjoKMrc7UpGRq9uM7DGKPZpt18ej5NIs8up9HUMPF9KT4FDG2aYQx7b4GT0PEwVSxWYRDdSgqkDZaXWzHVMqBwae2MQl2BOf1Iy/qrPJ0jsm9EuiF8euY9XAVwRBZJYzkEQdb1F24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789739421; c=relaxed/simple; bh=p6sGUJQDw/v2WEkFBKyNsaSEI1rEoinvPgLiO4jk3cQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UgS2TwkJ0WDUzIT1q8AEOiqBgzNy10bQrZEeNkI6j8cVHvNx1a+/XH3umtD/SWI804Y99fzZtvQ+MbhY8dz7hIQeDhrwtp+iT7X53ADrZET2mXb0otSIle1QFEwtLCJ3na2MrEItlvjqJmz8U3ibXh6bGLjzOWsysMKFTTVph/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=REaraZBt; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=XNiOa2Sy; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="REaraZBt"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="XNiOa2Sy" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68IDOY1U882168 for ; Fri, 18 Sep 2026 13:50:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= xf6tR09RZeKBwJ8QYQsyPe97UrBuN0pxSc2WuBhgy6g=; b=REaraZBtIQOvBurH Bx3yKujkcJhNVSBspJzafyj9qye8oPrWH7gIWDlG59pCVNmoDkDWtctVOFKVv+c4 iK4ucVU15mGPt+hDASvsqdU8rmh7SVF1FPYnRKE56lntcnZYCl2CcLmzIkEEYrH7 RXS0QbGYlgYPuVqXFhTea53YOmgZ7fTw+196Hagj6As8PKN7+e9igi01gkBgXYn8 IS927vYYJhDebqMS6TKG4MLYiIXS3ZEQy1t8cq2uFJgAKP5iGId5UE+gjvyLmxtz dRxr3nLBMObIB6me4Za9YeWhvO56g8z2xR2OzzEvHpdAq6gj763HFu47eGNStcHs U2Jbzw== Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4grwxrt6va-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 18 Sep 2026 13:50:18 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-cc4922b7c31so819511a12.1 for ; Fri, 18 Sep 2026 06:50:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1789739418; x=1790344218; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xf6tR09RZeKBwJ8QYQsyPe97UrBuN0pxSc2WuBhgy6g=; b=XNiOa2SypACgH4T7bszmVf4A8lmx68+HhgY3Nn3JhJ94TSw02+64WBHVQfGdXbdPMD uvmVbRyOaBGXLVGDdEqqC1mDP4pikKDk+N86Jx4QRNtaijqoCcWD566goR73DBDtEbVE SxnmyCy5vbe6wU7wg3BicmYWC6M1rVRze7LuiPWR260F5l1EV6uiaSzHG/P4nDUzlx3B WS2V3k0UJoJOu+xKMrkktebrQus+X4HV0fo+LBD8kk2hPv7z9rY/OUCzLiX16N9Fz+QZ xbtmQZPyu4dr9XfbUdjdyPVnW5IIzdlt0ijceeUQl1Lx6+mFI+nJuyxdX3u2cvGKyg2H Si0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789739418; x=1790344218; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xf6tR09RZeKBwJ8QYQsyPe97UrBuN0pxSc2WuBhgy6g=; b=njOnum4fHBdqFMwdufp8pTyoWX6Dxho/x6sLspQ/oIqoRPCH47S1IH73/JM919b4LK RkzCAsYAmghkgI2mxS0zXgGpdOwbHQcxha6rWuaZuPdkRDiznkS6ZxLHLSfonS5MOrkl lfwyDL5XmP2Qc8cmW/nSMgpGsjVEbQxFvLq2min7KgOxoZlPGiyMIGrowWkjKX405eEX O6h7EFiBmAtIA3IdXPMFdQnoPWj5VxPv35uDEG4eQwyxgABpU0QKhbzuC1K1uaaqRBxv Q/KKLa1rAaPkZEiv+M75MVm3aQbaGIqJC2l6R4bMxqtuRYM5aS5PnZjCrQFkV7mNeh40 3cfw== X-Forwarded-Encrypted: i=1; AKwUvByswL+14eJ2HI96m+4aO3SgNDtPlPB/83oaeiawOpHsjMWoh7lpW6orO+4QSp8tlRWXyJYUyOvgabAM7LQ=@vger.kernel.org X-Gm-Message-State: AFuF++nog7Qj6p00YrIUTBc4A3SMT47q2igGa7WsuUGFqv2iIJ/jWebo 19WeH9+3wCskPL+fWlG/RA/dsFca2OW6ljQAdWej7gWCDRrJFeplqrvwMvcHuua9MoUmM8vtDEh lKK4d88QLSfH5lFXsdrDVJ4TlaZmn32WDzWTfU+kpAXwvSQHzxLtr/owjaa3/HkXxPYA= X-Gm-Gg: AYBFou3WLE5YNcwRX/jZqiDsJAR0JhNnBUaeF7OP1oCi43mHlV6c2ewTJDU70NWEtM7 ZvvXIEqueCDG3ymc1xNglOSTZq9nibahKw7DEbJjP0AKGwz5uMPDOwl3T6o1TZBJ3pNFBGdKTQn SgQB4znrMD6Vq1GDqKwuQDbpoK6eVqw5nGkwzBuk4Q30cAUWtaUzGL+3y/leUrpu/GcZABHj7KJ 3p2B0yhvXVhB9Dt0gISKKxI0rMwML4rD7Ycb1ZEDx/3IpPaqlTkC8lkMZaOWsB9N8kY3eywnWzA yda7q6ChkxVFyZ/TbFL6s8vKL4l4pbFNKmldr+CAv4QZKjwxfWCO0iSnoG4k1PLb5YYdtx+MtId PQQCzG21c4VquSCWv6Urv+HmjsEc= X-Received: by 2002:a05:6a21:2989:b0:3d3:adbf:7783 with SMTP id adf61e73a8af0-3dd8c41a7f9mr4999195637.24.1789739417395; Fri, 18 Sep 2026 06:50:17 -0700 (PDT) X-Received: by 2002:a05:6a21:2989:b0:3d3:adbf:7783 with SMTP id adf61e73a8af0-3dd8c41a7f9mr4999110637.24.1789739416766; Fri, 18 Sep 2026 06:50:16 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cc5c50e9fbesm1013934a12.32.2026.09.18.06.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 06:50:16 -0700 (PDT) From: Ajay Kumar Nandam Date: Fri, 18 Sep 2026 19:19:37 +0530 Subject: [PATCH v3 3/3] ASoC: qcom: q6apm-dai: add SCM buffer assignment for mDSP platforms Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260918-vmid-v3-v3-3-f1cbf47bf173@oss.qualcomm.com> References: <20260918-vmid-v3-v3-0-f1cbf47bf173@oss.qualcomm.com> In-Reply-To: <20260918-vmid-v3-v3-0-f1cbf47bf173@oss.qualcomm.com> To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Pierre-Louis Bossart , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Mohit Sharma , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Ajay Kumar Nandam X-Mailer: b4 0.15.0 X-Authority-Analysis: v=2.4 cv=EMWTQFZC c=1 sm=1 tr=0 ts=6aad419a cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=P3I-59MgXInoGZ6QZ0AA:9 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTE4MDE5NiBTYWx0ZWRfX7Fx1Bpw9Z6Zl LjbmyNcDcBfiCi4Alnp+/o5zttyqU8nkNKVo+Pm9kUrjU5Pic+QQJ2wXS78DKSyKuYRtrxufEcv ZOZqg1dNgHLlyFeTeBjqpvoSKzHMAW5+tsJPxIRxG+JOUQ0WzPI8d6AlnOGSV4G2iebcPDESuUG JqlE/9F3WO4vOg7eB5OcsDBc2o5we1FXbtsbv63zc7GCixVCCyzmwvptX7JmXAHfyYKn/UUNUKr p2C3mkvxZpg1ccAhlifinfMgReWwQ6Yq1F+QGbGdReFinVEwl3pVtXjAO8O40V4onstFcAzEmTO hgPcF7cR07huiiMo3c4aYm7NYXqblPeOZocMQYXvlM87qQmbhOtj39Z5XPkStgDgOTwdyXlJhdK yMRb7HSW4es2QSOZL11RcndxKm6j0NKzrecZ5zU5cdm7OCibqqFjd1gesHrBovaJ4YT/a+3Ni1r DcyYgIzaO6f9JkxukXQ== X-Proofpoint-GUID: E4F9EmACyCvPis7JrlIcxsDVdvFbFvyD X-Proofpoint-ORIG-GUID: E4F9EmACyCvPis7JrlIcxsDVdvFbFvyD X-Proofpoint-Spam-Info: AW1haW4tMjYwOTE4MDE5NiBTYWx0ZWRfX6YFzFwoBQWcF /3Bgg1FoyTJK4mJaqy/ndoZ5JOo5wCkf4KF8RUV8B15BZo+u8DRZ/89DgTejNiQiGcXDJI3onl8 bQ/9vSnpv98tRlx4hF7OkZpkSV6doMk= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-18_04,2026-09-16_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 adultscore=0 spamscore=0 malwarescore=0 impostorscore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609180196 On platforms such as Qualcomm Shikra, audio is served by the modem DSP (mDSP) which runs in a stage-2 protected context. Unlike ADSP targets where SMMU-mapped system RAM is directly accessible, the mDSP cannot reach the PCM buffers unless they are explicitly SCM-assigned to the appropriate Virtual Machine IDs (VMIDs). Without this assignment, audio does not function on these platforms. At probe time, the driver reads the GPR domain_id from the parent APM device to determine which DSP serves audio. When domain_id matches GPR_DOMAIN_ID_ADSP the existing SMMU/iommus path is taken and no new code is exercised. When domain_id matches GPR_DOMAIN_ID_MODEM, the driver verifies that qcom_scm is available (deferring otherwise) and that iommus is absent (the two mechanisms are mutually exclusive), then enables the SCM assignment path. In the SCM path the driver parses the optional memory-region entries in DT. The first entry (memory-region[0] / audio_heap_mem) is the control-path carveout used by the DSP firmware for command traffic; since the mDSP operates on stage-2 protected memory, this carveout must be SCM-assigned at probe time itself for the firmware to function. It is SCM-assigned to HLOS (retained as source owner, RW) plus MSS_MSA and LPASS (consumer VMIDs, both RW) and restored to HLOS-only ownership via devm_add_action_or_reset() at device removal. The second entry (memory-region[1]) is the data-path buffer pool from which per-stream DMA buffers are carved out. This pool is attached via of_reserved_mem_device_init_by_idx() so that PCM buffers allocate directly from the carveout instead of system RAM. Individual buffer slices are SCM-assigned in pcm_new() after allocation and unassigned in pcm_free(), so only the actively used slices are shared with the modem and unused carveout memory remains HLOS-owned. The VMIDs are static per SoC and hardcoded in the driver (HLOS, MSS_MSA, LPASS) rather than read from DT, following the upstream pattern used by rmtfs_mem and qcom_q6v5_pas. Buffer constraints are capped at reserved_buf_size when the data-path pool is present, and snd_pcm_set_fixed_buffer_all() is used for both paths so the carveout is not subject to the preallocate_dma module parameter. The DT binding is updated to add an optional memory-region property (1-2 entries) and to make iommus optional (removed from the required list), since mDSP platforms have neither IOMMU nor VMID DT properties. All new code paths are gated on use_scm_assign (false when domain_id is not GPR_DOMAIN_ID_MODEM), ensuring existing ADSP/iommus targets are completely unaffected. Signed-off-by: Ajay Kumar Nandam --- .../devicetree/bindings/sound/qcom,q6apm-dai.yaml | 12 +- sound/soc/qcom/Kconfig | 1 + sound/soc/qcom/qdsp6/q6apm-dai.c | 260 +++++++++++++++++= ++-- 3 files changed, 252 insertions(+), 21 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml b/= Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml index 9e5b30d9c6e6..7d0415f2463a 100644 --- a/Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml @@ -20,9 +20,19 @@ properties: minItems: 1 maxItems: 2 =20 + memory-region: + minItems: 1 + maxItems: 2 + items: + - description: + Control-path buffer (audio_heap_mem) for platforms where the DSP + runs in a stage-2 protected context (e.g. modem-DSP). + - description: + Data-path buffer pool from which per-stream DMA buffers are + allocated. + required: - compatible - - iommus =20 additionalProperties: false =20 diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index e6e24f3b9922..991feb317940 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -102,6 +102,7 @@ config SND_SOC_QDSP6_ASM_DAI config SND_SOC_QDSP6_APM_DAI tristate select SND_SOC_COMPRESS + select QCOM_SCM =20 config SND_SOC_QDSP6_APM_LPASS_DAI tristate diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-= dai.c index bf1f872a09f4..24f920a7c60d 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -1,20 +1,24 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2021, Linaro Limited =20 -#include +#include +#include +#include #include +#include +#include #include #include +#include #include #include -#include -#include #include #include +#include +#include +#include #include #include -#include -#include #include "q6apm.h" =20 #define DRV_NAME "q6apm-dai" @@ -36,6 +40,16 @@ #define COMPR_PLAYBACK_MIN_NUM_FRAGMENTS (4) #define SID_MASK_DEFAULT 0xF =20 +#define Q6APM_MAX_SCM_REGIONS 16 +#define Q6APM_POOL_MAX_STREAMS 8 + +struct q6apm_scm_region { + phys_addr_t addr; + size_t size; + u64 src_perms; + bool assigned; +}; + static const struct snd_compr_codec_caps q6apm_compr_caps =3D { .num_descriptors =3D 1, .descriptor[0].max_ch =3D 2, @@ -84,9 +98,88 @@ struct q6apm_dai_rtd { }; =20 struct q6apm_dai_data { + struct device *dev; long long sid; + bool use_scm_assign; + bool has_reserved_mem; + size_t reserved_buf_size; + struct q6apm_scm_region scm_regions[Q6APM_MAX_SCM_REGIONS]; + int num_scm_regions; }; =20 +static int q6apm_dai_scm_assign(struct q6apm_dai_data *pdata, + phys_addr_t addr, size_t size) +{ + struct qcom_scm_vmperm dst[] =3D { + { .vmid =3D QCOM_SCM_VMID_HLOS, .perm =3D QCOM_SCM_PERM_RW }, + { .vmid =3D QCOM_SCM_VMID_MSS_MSA, .perm =3D QCOM_SCM_PERM_RW }, + { .vmid =3D QCOM_SCM_VMID_LPASS, .perm =3D QCOM_SCM_PERM_RW }, + }; + struct q6apm_scm_region *r; + u64 src =3D BIT(QCOM_SCM_VMID_HLOS); + int ret; + + if (pdata->num_scm_regions >=3D Q6APM_MAX_SCM_REGIONS) + return -ENOSPC; + + ret =3D qcom_scm_assign_mem(addr, size, &src, dst, ARRAY_SIZE(dst)); + if (ret) + return ret; + + r =3D &pdata->scm_regions[pdata->num_scm_regions++]; + r->addr =3D addr; + r->size =3D size; + r->src_perms =3D src; + r->assigned =3D true; + + return 0; +} + +static void q6apm_dai_scm_unassign(struct q6apm_dai_data *pdata, + phys_addr_t addr) +{ + struct qcom_scm_vmperm hlos =3D { + .vmid =3D QCOM_SCM_VMID_HLOS, + .perm =3D QCOM_SCM_PERM_RW, + }; + int i; + + for (i =3D 0; i < pdata->num_scm_regions; i++) { + if (pdata->scm_regions[i].addr !=3D addr || + !pdata->scm_regions[i].assigned) + continue; + + if (qcom_scm_assign_mem(addr, pdata->scm_regions[i].size, + &pdata->scm_regions[i].src_perms, + &hlos, 1)) { + dev_err(pdata->dev, "SCM unassign %pa failed\n", &addr); + return; + } + + pdata->scm_regions[i].assigned =3D false; + pdata->num_scm_regions--; + pdata->scm_regions[i] =3D pdata->scm_regions[pdata->num_scm_regions]; + return; + } +} + +static void q6apm_dai_scm_cleanup(void *data) +{ + struct q6apm_dai_data *pdata =3D data; + int i; + + for (i =3D pdata->num_scm_regions - 1; i >=3D 0; i--) { + if (pdata->scm_regions[i].assigned) + q6apm_dai_scm_unassign(pdata, + pdata->scm_regions[i].addr); + } +} + +static void q6apm_dai_reserved_mem_release(void *data) +{ + of_reserved_mem_device_release(data); +} + static const struct snd_pcm_hardware q6apm_dai_hardware_capture =3D { .info =3D (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_BLOCK_TRA= NSFER | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -409,8 +502,11 @@ static int q6apm_dai_open(struct snd_soc_component *co= mponent, } =20 if (substream->stream =3D=3D SNDRV_PCM_STREAM_PLAYBACK) { + size_t buf_max =3D pdata->has_reserved_mem ? pdata->reserved_buf_size : + BUFFER_BYTES_MAX; + ret =3D snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_= BYTES, - BUFFER_BYTES_MIN, BUFFER_BYTES_MAX); + BUFFER_BYTES_MIN, buf_max); if (ret < 0) { dev_err(dev, "constraint for buffer bytes min max ret =3D %d\n", ret); goto err; @@ -431,17 +527,20 @@ static int q6apm_dai_open(struct snd_soc_component *c= omponent, } =20 runtime->private_data =3D prtd; - runtime->dma_bytes =3D BUFFER_BYTES_MAX; + runtime->dma_bytes =3D pdata->has_reserved_mem ? pdata->reserved_buf_size= : + BUFFER_BYTES_MAX; if (pdata->sid < 0) prtd->phys =3D substream->dma_buffer.addr; else prtd->phys =3D substream->dma_buffer.addr | (pdata->sid << 32); =20 if (q6apm_is_graph_in_push_pull_mode(prtd->graph)) { + size_t buf_max =3D pdata->has_reserved_mem ? pdata->reserved_buf_size : + BUFFER_BYTES_MAX; void *pos_buffer; =20 - prtd->pos_phys =3D prtd->phys + BUFFER_BYTES_MAX; - pos_buffer =3D (void *)(substream->dma_buffer.area + BUFFER_BYTES_MAX); + prtd->pos_phys =3D prtd->phys + buf_max; + pos_buffer =3D (void *)(substream->dma_buffer.area + buf_max); prtd->pos_buffer =3D (struct sh_mem_pull_push_mode_position_buffer *)(po= s_buffer); } =20 @@ -535,6 +634,7 @@ static int q6apm_dai_memory_map(struct snd_soc_componen= t *component, { struct q6apm_dai_data *pdata; struct device *dev =3D component->dev; + size_t buf_max; phys_addr_t phys; int ret; =20 @@ -544,20 +644,23 @@ static int q6apm_dai_memory_map(struct snd_soc_compon= ent *component, return -EINVAL; } =20 + buf_max =3D pdata->has_reserved_mem ? pdata->reserved_buf_size : + BUFFER_BYTES_MAX; + if (pdata->sid < 0) phys =3D substream->dma_buffer.addr; else phys =3D substream->dma_buffer.addr | (pdata->sid << 32); =20 - ret =3D q6apm_map_memory_fixed_region(dev, graph_id, phys, BUFFER_BYTES_M= AX); + ret =3D q6apm_map_memory_fixed_region(dev, graph_id, phys, buf_max); if (ret < 0) dev_err(dev, "Audio Start: Buffer Allocation failed rc =3D %d\n", ret); =20 if (is_push_pull) { if (pdata->sid < 0) - phys =3D substream->dma_buffer.addr + BUFFER_BYTES_MAX; + phys =3D substream->dma_buffer.addr + buf_max; else - phys =3D (substream->dma_buffer.addr + BUFFER_BYTES_MAX) | (pdata->sid = << 32); + phys =3D (substream->dma_buffer.addr + buf_max) | (pdata->sid << 32); =20 ret =3D q6apm_map_pos_buffer(dev, graph_id, phys, POS_BUFFER_BYTES); if (ret < 0) @@ -572,20 +675,22 @@ static int q6apm_dai_memory_map(struct snd_soc_compon= ent *component, static int q6apm_dai_pcm_new(struct snd_soc_component *component, struct s= nd_soc_pcm_runtime *rtd) { struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); + struct q6apm_dai_data *pdata; struct snd_pcm *pcm =3D rtd->pcm; - /* - * Allocate one extra page as a workaround for a DSP bug where 32-bit - * address arithmetic can overflow when the buffer is placed near the - * end of the addressable range. - */ int size =3D BUFFER_BYTES_MAX + PAGE_SIZE; int graph_id, ret; bool is_push_pull; struct snd_pcm_substream *substream =3D NULL; =20 + pdata =3D snd_soc_component_get_drvdata(component); + if (!pdata) + return -EINVAL; + + if (pdata->has_reserved_mem) + size =3D pdata->reserved_buf_size + PAGE_SIZE; + graph_id =3D cpu_dai->driver->id; =20 - /* Note: DSP backend dais are uni-directional ONLY(either playback or cap= ture) */ if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) substream =3D pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; else if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) @@ -603,6 +708,17 @@ static int q6apm_dai_pcm_new(struct snd_soc_component = *component, struct snd_soc if (ret) return ret; =20 + if (pdata->use_scm_assign) { + ret =3D q6apm_dai_scm_assign(pdata, + substream->dma_buffer.addr, + ALIGN(size, PAGE_SIZE)); + if (ret) { + dev_err(component->dev, + "SCM assign buffer failed: %d\n", ret); + return ret; + } + } + ret =3D q6apm_dai_memory_map(component, substream, graph_id, is_push_pul= l); if (ret) return ret; @@ -635,15 +751,26 @@ static void q6apm_dai_memory_unmap(struct snd_soc_com= ponent *component, =20 static void q6apm_dai_pcm_free(struct snd_soc_component *component, struct= snd_pcm *pcm) { + struct q6apm_dai_data *pdata; struct snd_pcm_substream *substream; =20 + pdata =3D snd_soc_component_get_drvdata(component); + substream =3D pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; - if (substream) + if (substream) { q6apm_dai_memory_unmap(component, substream); + if (pdata && pdata->use_scm_assign) + q6apm_dai_scm_unassign(pdata, + substream->dma_buffer.addr); + } =20 substream =3D pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; - if (substream) + if (substream) { q6apm_dai_memory_unmap(component, substream); + if (pdata && pdata->use_scm_assign) + q6apm_dai_scm_unassign(pdata, + substream->dma_buffer.addr); + } } =20 static int q6apm_dai_compr_open(struct snd_soc_component *component, @@ -1021,6 +1148,7 @@ static int q6apm_dai_probe(struct platform_device *pd= ev) { struct device *dev =3D &pdev->dev; struct device_node *node =3D dev->of_node; + struct q6apm *apm =3D dev_get_drvdata(dev->parent); struct q6apm_dai_data *pdata; struct of_phandle_args args; int rc; @@ -1029,12 +1157,104 @@ static int q6apm_dai_probe(struct platform_device = *pdev) if (!pdata) return -ENOMEM; =20 + pdata->dev =3D dev; + rc =3D of_parse_phandle_with_fixed_args(node, "iommus", 1, 0, &args); if (rc < 0) pdata->sid =3D -1; else pdata->sid =3D args.args[0] & SID_MASK_DEFAULT; =20 + if (apm && apm->gdev && + apm->gdev->domain_id =3D=3D GPR_DOMAIN_ID_MODEM) { + if (!qcom_scm_is_available()) + return -EPROBE_DEFER; + + if (pdata->sid >=3D 0) { + dev_err(dev, + "iommus and mDSP SCM path are mutually exclusive\n"); + return -EINVAL; + } + + pdata->use_scm_assign =3D true; + + rc =3D devm_add_action_or_reset(dev, q6apm_dai_scm_cleanup, + pdata); + if (rc) + return rc; + } + + if (pdata->use_scm_assign) { + int mem_count; + + mem_count =3D of_count_phandle_with_args(node, "memory-region", + NULL); + if (mem_count >=3D 1) { + struct device_node *mem_node; + struct reserved_mem *rmem; + + mem_node =3D of_parse_phandle(node, "memory-region", 0); + rmem =3D of_reserved_mem_lookup(mem_node); + of_node_put(mem_node); + if (!rmem) { + dev_err(dev, + "memory-region[0]: lookup failed\n"); + return -ENODEV; + } + + rc =3D q6apm_dai_scm_assign(pdata, rmem->base, + ALIGN(rmem->size, PAGE_SIZE)); + if (rc) { + dev_err(dev, + "SCM assign memory-region[0] failed: %d\n", + rc); + return rc; + } + } + + if (mem_count >=3D 2) { + struct device_node *mem_node; + struct reserved_mem *rmem; + size_t per_stream; + + mem_node =3D of_parse_phandle(node, "memory-region", 1); + rmem =3D of_reserved_mem_lookup(mem_node); + of_node_put(mem_node); + if (!rmem) { + dev_err(dev, + "memory-region[1]: lookup failed\n"); + return -ENODEV; + } + + per_stream =3D rmem->size / Q6APM_POOL_MAX_STREAMS; + if (per_stream <=3D POS_BUFFER_BYTES) { + dev_err(dev, + "reserved-memory pool too small: %llu bytes\n", + (u64)rmem->size); + return -EINVAL; + } + + rc =3D of_reserved_mem_device_init_by_idx(dev, node, 1); + if (rc) { + dev_err(dev, + "reserved-memory pool init failed: %d\n", + rc); + return rc; + } + + rc =3D devm_add_action_or_reset(dev, + q6apm_dai_reserved_mem_release, + dev); + if (rc) + return rc; + + pdata->reserved_buf_size =3D + min_t(size_t, per_stream - POS_BUFFER_BYTES, + BUFFER_BYTES_MAX); + pdata->has_reserved_mem =3D true; + } + } + dev_set_drvdata(dev, pdata); =20 return devm_snd_soc_register_component(dev, &q6apm_fe_dai_component, NULL= , 0); --=20 2.34.1