From nobody Sat Sep 26 01:07:15 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 B0B3450B8A5 for ; Mon, 21 Sep 2026 19:08:37 +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=1790017719; cv=none; b=JnCijt5fA8cWA7mqvVPuK4aBKqXDvub2pZ10OIfOSpx9vjyjJipbZ380N7oWnZX+wTVZjv9nRfxIN2g7D+BEelD2HAIi5/IUGUcUj5pHwsc5mjmhkRXWtamgr0Ubj/20UoQ5WZ20t1loaUjfE6fe1g05rJ6cAAkJgP316pGsM/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790017719; c=relaxed/simple; bh=3zPDkuCDmQ38oUL9/eF9wJT7+qJydWJzTsR5SSVPT00=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bzcmwdc8DMGSFo6N6gWlP5NoQml9ykC07SWwJAVWyZt6z6RheOq+6KRO4TykLinL7k52xxXL2UCZQBa+zmHFYPOhlfQEAPV8ROOWIZERhC5y/2umt50tx4dDv/aalk/18xgjaaf603BaLwh1BhbU87wmqMBW6FCGpdZiO8zgUhk= 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=fTb35840; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Rl4NPf1B; 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="fTb35840"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Rl4NPf1B" 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 68LFAEZK1677364 for ; Mon, 21 Sep 2026 19:08:37 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=fTb35840f89+kg4e OC1/lIA6e28VpD5gcyCFeXWPMSky34I0fZAaRYZrKjpTWiDr65wucgyuXP+ZibbW wQ3DpcptFE9ZLpN/xS3xU/2JmzbvDn9FU8WqeVPqFmKL79k6y/d/bwxRLbPEzqxS YphUu7qQaSdr+/kk8ml/iC2A931Zrzt+xuIWxikuTgHMAE8Tq/9BnjZYyjXxXxZp I0X9wRXKx0vvnY0pYmlCMChU4PjuEy8lOVnToQv67b4uXYa/hwJfHQa7n/aktEFv QKItee4xpjDXFUaFbGvMsi/AKLvEUMuJPwDW+3HNYlfZBFlMJD2r2eKqaq9ztaPp 1VpIfQ== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gu3csj1k2-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 21 Sep 2026 19:08:36 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-39e25a5f6e8so6131726a91.0 for ; Mon, 21 Sep 2026 12:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790017716; x=1790622516; 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=Rl4NPf1Bll78rWPV28VEtvxHsX/aXCLQ5SPaPGf4bwhGLSrwi/yi1PtcLS3JqtFexf KOkR++EvPd+Vbuko15rI1xzgNBtJ7efcr3mpP+gX272AxgZwVvSFZe6J2sMZzjzzVkNp awObjJyoI9pzSuTBdbtgX6PBV+OBJUmKPRsv7o3R6VNa7vAdtkIj+v+OOfEnv7Kn1Qpi w6uiolZaw08OYj6rEP7DPncU4e5XJUCppBQFU/pvcOQceGy8WVuyUa/SqG5DmZ8Q+m/I 8sMK+BUZrIZGa8yUr6O/YSiOv67VYq5d3Uv5hoKpHSfAkaAdoJKKjF4Gbjb/oprO7wKN /Z6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790017716; x=1790622516; 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=wNZca106Sy1Lqkfb0wAV5PPMuDOCUlN5x46CO43TyEd8D7SPfAC9mYfu3UC2cr6wzQ 4AF1pkjFLE0ZI9Wb16LSVvxxbLOmlIvYJeeRCAPRNk2HwaaJOzbSIISUP3cAebeNfnkF 6FvBy3VFm9iYTWk2RfAieiVSZguDbygDbD8gyJlW5hYMTOEJ/8grIWUbYYdpblFziQnJ BQ76P74AVKs7sQ1ccKTaCine9i1qLRpG63Y+5u2rJsQCFoJ1cFXhxm636diq3SEbG7EW MR+nlrkSrGmhCRW0JVrUpp1qgFGjTZQ0c+TQzvXyaMusfxSnBdsxQL18rd0wkEY9GGZY uu3A== X-Forwarded-Encrypted: i=1; AKwUvBzReYQK/Opf5JbIGAc23sBighAVKX6AnMD+ljTjq1rvOD0TQH1mlTFtLFthhBxGCLUZfuVptjYYtE68v3w=@vger.kernel.org X-Gm-Message-State: AFuF++lbuHSF5ZPRsrI9zj6xoUs+aiRq6pv7mUpM/0h8D5IPyG5+K226 QLfHJdM1WDixwr+LfY1bnBz4NuQ9teUBINjgRduSz4jNiHva20/YRH9zshg44D8BuSvsrcC0ezN iGD7R91OJofVum8Ub0xi9fRIhhzZcklK5ePUy+e1b2rYeaWlqNbtZwMwTmkGxb4Be7bw= X-Gm-Gg: AYBFou1z2UTe7Y81vWeNxOmy96uh5Wo/iYmmdfArJldknO8uHCo/YP0rN94mRNU7zBa ni6awfOaAwksBqOM2HbEmBuOxhh8EtfClmdko5rFOBJOatOX96a7g9exwFpy66acYZlYk5oPn9m kLDV4rCEOLUxnxuBHegWW9b1ga8stv3TAqrqDOXdYTjWcVewk9C3gVksWBGB++FuB0fmIvXqmsh ddmAFvwc0kDCHj5jcNdnKnUlDNStBzT0a17UQxr9KmnmqAg24+eS7XZ5fq3p6hWQ/RHysctJS8P 7aAOErh4hiKHsPTgoTSCz/gQvxgSDyCDVmy6FvhV7maQw+MMBt9tU8tIBzh3GzbJ7Fd/XG4gmdg SeunhgOgS/8OtanUiEQtQjVv0vi95 X-Received: by 2002:a17:90b:4d91:b0:39e:6c69:34db with SMTP id 98e67ed59e1d1-39e6c6936e9mr10092007a91.63.1790017716157; Mon, 21 Sep 2026 12:08:36 -0700 (PDT) X-Received: by 2002:a17:90b:4d91:b0:39e:6c69:34db with SMTP id 98e67ed59e1d1-39e6c6936e9mr10091983a91.63.1790017715589; Mon, 21 Sep 2026 12:08:35 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33e5ec6ea45sm25855eec.30.2026.09.21.12.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2026 12:08:35 -0700 (PDT) From: Ajay Kumar Nandam Date: Tue, 22 Sep 2026 00:38:09 +0530 Subject: [PATCH v5 1/4] 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: <20260922-vmid-v4-v5-1-e79cfd7af5b3@oss.qualcomm.com> References: <20260922-vmid-v4-v5-0-e79cfd7af5b3@oss.qualcomm.com> In-Reply-To: <20260922-vmid-v4-v5-0-e79cfd7af5b3@oss.qualcomm.com> To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Pierre-Louis Bossart , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: ajay.nandam@oss.qualcomm.com, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org X-Mailer: b4 0.15.0 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTIxMDI3OSBTYWx0ZWRfX2w4VGSdHZOTi egP8yU+FvXFMNfqawzpGWhSRExTbHwM8rlSEjPjXBotBI0Telp8eTgBKI9RHEP+ShUzpqEu5iOO ScmdQ0cqRBPfIqbpjYJEPrec4l71klU= X-Proofpoint-GUID: I4RkqH35QXV1pBxFNfHRXYXq1JfRlHXm X-Authority-Analysis: v=2.4 cv=QovLTlyd c=1 sm=1 tr=0 ts=6ab180b4 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==: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=i9zpEd1wrD5FINdKp7YA:9 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTIxMDI3OSBTYWx0ZWRfX/mVZG7W41AJu nLiKjusLoK8vyVCHtEq3c+H8D2lPOeOg9tSumggQ4lpVsA9Psn1g4xujdeeQTXHtHz/QThRglf/ HlHYouG/CCzWa0VZ3EAni77YefvJMO6pTm/l3I293JEQ8DcuNOr12LiLjlkZuozHqCcijyqed2x F0OJzr1Q6WT9Lwq273QwaK1YETX63PAJlGdFMhfEEEWfpzpwEpwNV1drYF8o5o09pSl2Rg02Qxc 9rnXijMACHKZEuQaYtlqKZzuN1vVKKNbRL8KRogyogIX9C6bfiO2gnrEP1Tl41RBFf2syTrOl5m Z/KCBi2AYQl5V134CPfn30hP9daQ8U1XocT+0gDGsxnP7hXemVTP6ETIjQK/BagvJA5K06UcTqH iSNRgSZCAvVtsrsxmqQmnHVP5Kp8J/MUwd6g2FORjp0XUXvHr8bgLv2qSaL5OIHICOr8m/nEAKS KPXRBasVO+Lt0JXAeGg== X-Proofpoint-ORIG-GUID: I4RkqH35QXV1pBxFNfHRXYXq1JfRlHXm 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-21_05,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609210279 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 Sat Sep 26 01:07:15 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 CDDDC50B433 for ; Mon, 21 Sep 2026 19:08:43 +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=1790017726; cv=none; b=Wq5+/SbeBeRD70W7r519XoblZAl36NBNKi1WAFk8ExeIHUQ8/H158c0ke7UAqI27G6s/eZh0bmmVjoVo/i7wp2xDmjzSIQDUsketjrZZCbHGup6cXss3HmVqtMPsA4mTkL6epZKXuw+lH0X/Ilxl0ZorunGIv9FRa6kR3Ss1czQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790017726; c=relaxed/simple; bh=R6WhnRn3OYIVaQbRG/LcPLmBEV8zvrqFCWDo5EgDbKo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WFww0jQVDDRdN9mrb4xTtHGgaPM16toNe3OMTD1eKDx6tLlsGV+p3p4hANFcen6JGVz4fczAsePxrHVNq2Wk+JTIyawwDPxB5QSpd2demxyAEbUh2Mbualvn1OxKP0leklUsGHWRv40d/h3ROvrSb2Dnfnb/iap5pPfHFkmrJXY= 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=HbktcvE2; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Uuv6TALc; 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="HbktcvE2"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Uuv6TALc" 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 68LHKVXU1821697 for ; Mon, 21 Sep 2026 19:08:42 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=HbktcvE2fHAPjFwp nVUbz5k8+jIXAewsojT+7BW4+AcMFvjuSWwsgyLG9+7M7zh4ScYnV3O3dtKWA8VV pkBo/X/pn1PJuSiqf5wQHGzndmmNPu3CqlY62eFVC1vT7EBDFpR17Zwyg6IEO9Sd x86VjYoJ1LvIYhCTM6H0nA4e+RLlANs0J6/TCq8jk7xgaGCXSJE/jY6iZ7+Fl2Fd 5uxxh3DFvoII0Dk/qBTyos1tRx1tdXG4+u4Y+Jz3dxmwv1WL6ygz88U39yaVeWIA CMNUOMp8ARYci2/Eg8qvwsonQjdJRwDdZU3bj45v1o+CoUN9/3BrNTIlyoChbEhz cPo7QQ== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gu8w78d9r-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 21 Sep 2026 19:08:42 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2ce7dff6253so1849155ad.1 for ; Mon, 21 Sep 2026 12:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790017721; x=1790622521; 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=Uuv6TALcK5xDD35dsSyBV3j8dPvvnz8KMjg7ffPJSObdgulnBNKVOShYJRYAv9aOMx BF+/OPNfH9VHZouw6Dxx9JjzYW5aFOq7+tSQc4eKMTKFq4JZZHRRbSoxVT9nSaaJi3Zk NOkRV8f2kKOLQQrTUJzp1avMWdVn0NutNhg/oSKVchzFSfQO8eaBz2MOfLotE/H3roHh dT8LyJCUs5qVJRE6L+Rh/hHyraVmMbydg1VDrdT9g7U1uC28XXhZBFfJurAqA17BG2ng symhgaEvpMQSYVg+BS+SNZtBDFlQlGX70sxpITPari17aQCB4UWqG9VP+2uabJ/hDh9y VxUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790017721; x=1790622521; 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=d0ifMitj0RR921TRyZ4r2HiYAJ9LzeweQxVzxpAqZO8xVo5+OhOvBkGkR7dIMqKhnQ jYKxKdHgIZFY1NdILqTGd7tGnP+LU5nwMny0cuRUYh7JkjJBBPeVS3mio0htODIti8Ar DZ7QYOqM/ltRtmNJA91gWZOWDKK36uer7ME1iDqCC+7PHfAPdf6ob7G84C1evkM4NBwq 6vivRpgzdpw4Gw5w/2tIUoVfKB0i89E9AQStsc1Gw7nF4pCURCtBvDG1a7UclUXkUFAx bcjFX39xMdQG6nW6mKe0DE8dB6knXbvCR99GlXi0wnqPfHSCf3+JvlM6WgRqIOrGoTVe Etsg== X-Forwarded-Encrypted: i=1; AKwUvBxx8ZcBjlLqMkAbOhRSTN/u5W118+86bW558vW6gsbnQUukff1OLGz+Bn6JhBTETeZeBPSsvRiZDt1vGUg=@vger.kernel.org X-Gm-Message-State: AFuF++nUEQ1vULCNr+qrxsBd6vPtJQNbl74yz5Gr13QS3CIiLvPI1wyJ RAHeMztH4F/S3dQmR8Tn/k6uLR5+2Oki7Ok8e1KrVGrknD6M5YhXhokNp/gcSkb7CkUx8qfgPH+ 9ZFVDjGZ2IJOVAu8Uv5e1WNVIWseCiwP0yUozqOYZyYXwIzXud0kcg5x/C7SBrM/v18w= X-Gm-Gg: AYBFou2OtBBWY4LzfjKk0nJYvqUjQsoLLmSUY67cOI9ff+jb3K0F2aqtBk1EWw6sIWB pBGvxLbBOVKqU0C3ZvmzFPojpYd+0rxgYrT4gf/Uk2hsOKnq/8koSXtY0gJM+sTIfnOI/Wdtd+j 0ih+iUTeEb+hCQlVqTtqV+4iIGsGxNngMnY66m6z+kHguIqNtLGrPxmgesUVz+jZNQIvEWt4ApB 0X2WdCaf8F62fBNRNoB/6rbudLAqMxpBTfA645lW+ueoDria947X774cTunpyzhigyN5pg83Yzr 8ZwQRMB+l16fd6N1FA0Sf4IvgYOzFc/DiutBPnDkdVFs+97X9hrqwamIxr9AtnaKNxC/RfyK2IX 7uNtUllo9si1w5Jvg9S+CCEwhPlJ0 X-Received: by 2002:a17:902:f68a:b0:2dd:4438:4290 with SMTP id d9443c01a7336-2df5968c9aemr4408195ad.3.1790017721493; Mon, 21 Sep 2026 12:08:41 -0700 (PDT) X-Received: by 2002:a17:902:f68a:b0:2dd:4438:4290 with SMTP id d9443c01a7336-2df5968c9aemr4407895ad.3.1790017720832; Mon, 21 Sep 2026 12:08:40 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33e5ec6ea45sm25855eec.30.2026.09.21.12.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2026 12:08:40 -0700 (PDT) From: Ajay Kumar Nandam Date: Tue, 22 Sep 2026 00:38:10 +0530 Subject: [PATCH v5 2/4] 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: <20260922-vmid-v4-v5-2-e79cfd7af5b3@oss.qualcomm.com> References: <20260922-vmid-v4-v5-0-e79cfd7af5b3@oss.qualcomm.com> In-Reply-To: <20260922-vmid-v4-v5-0-e79cfd7af5b3@oss.qualcomm.com> To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Pierre-Louis Bossart , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: ajay.nandam@oss.qualcomm.com, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Pratyush Meduri X-Mailer: b4 0.15.0 X-Proofpoint-GUID: VZItjyReyxIAy3AMYuoL7CFhwSrm3Qiz X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTIxMDI3OSBTYWx0ZWRfX6WK4FhnQuUXf IRdbNPNOVoWZTy+nIgGdBzWW3K5z6zXQTtGStJDTcISK+Nniz4vvxv38zvlgGChErWMDw/M2UP0 Mq8nkSf1jXB6dw96OyO104QK/JLwZAnjqnFMg9gp0DjH40ZDjJBtjeQxMG/AkrGYSKXiJd8MD1d uLHZU6TrLXeHTKxkT1WKYHGYcPR+QikDxhr7ZfTCcROYBVegfumbI3XrIUu+rXn+jhGTmv9IfEz 0k71bJW8xtGGLG5kcQ/RFYDzT9+NLGFRgCpqMdL0PlomYG38RmU3VTe30bz5wq0fCXOOhgw9WVi dkgdyJaHq1Dfacp56tFlC9NUMFhhWTXYmf1PZsgwP8bzvHiXscvm9Q7TCMMw7FpR26uxdJOZ22U 6SYbXVgRUYj04Bdj5oNX9XIiv7Q/NPB2p9Tz6sAaA1hBmdRw7ug9dfPcL+g6WPzdVJfPXT+ewqs dYgDCNuH8V8Ua+Dj6cQ== X-Proofpoint-ORIG-GUID: VZItjyReyxIAy3AMYuoL7CFhwSrm3Qiz X-Authority-Analysis: v=2.4 cv=Vqi2kO2n c=1 sm=1 tr=0 ts=6ab180ba cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==: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=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTIxMDI3OSBTYWx0ZWRfX/t5P7x6H0+85 tBCa+j5oN+WBTFDUfzHqq/cXEKZy7jz6kJBXjUqnTYhSsLdY7qf3q+WliF0mf7x/P+s+7ppSDYf gWP70xwdct9R6G/XF8EzzweZPPwIDI0= 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-21_05,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 malwarescore=0 clxscore=1015 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609210279 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 Sat Sep 26 01:07:15 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 40DD850AC0A for ; Mon, 21 Sep 2026 19:08:49 +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=1790017730; cv=none; b=BbeEqprHhEBPlllPOZ2yGMQkec2Jr4CDOkbkEmmOGSgVLO6+WUOCjkoDgOr0IIsJvwhu17TPDG3Gs+NNdRzXw07mqw1RBeqwA06tmUAPQMKoGdS46AY7UAvtXA7PFspIiHvNenv4uQLDpCLhExnC9fbVXDuJmRxBAXo4j7uJpb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790017730; c=relaxed/simple; bh=93trSbPzGcTLf7kCeG9wmsYEGv3akrfz6fUP2Eaqsh0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WHPwjCFQI+ImaX9xyVEAsPTUzaj4koPyOiqgUvfLedwaQvKQpWBM9FnzL1JD17gxVhLLC+2DhB0ebz2qZd8aHiy2IZ5/7q6Ud0QPHE+PYjp0mBNunrnRQHlOYO57+FBIk3aHGc3lqDVFJuBSAZHmdZ2VA+k69tfeeQvBG9jn70Y= 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=IIriMfa5; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=UqiAlf0S; 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="IIriMfa5"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="UqiAlf0S" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68LFANZk1817159 for ; Mon, 21 Sep 2026 19:08:48 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= +jmAQdn9jXKepq5Rmmo8OwCGEejY+0pnncnb0YnbRzs=; b=IIriMfa5nWLvB/7E ePbU7A3kIRfovsYziJYMkzdEeikLqiDlNKhb0DXw+LvXd0dzpu4jpObDGyEALBkb eSsKjEV2+Y28wF5BF4LjuP6u4Ghl/93zSogDIg2/JkZaqfjaQSQwUbar3/zNDk2u CfTubqkif1y4UKiSTzKW1xfsP5Wk8cpt9SEAevHYENOCXGu7soA6924DyXmNMQyu UiT3pHlkTUtpYw5E/MGyLjHHc8ru1pl8et8LMYwfVF4RoDZy5uXzZby3xJOOkXbv GcWazqwxLyIS3RjK/aCfN9vEp9z/X3E6S+3qgfhTTyNu2ewIxxT3EmAS6xgehetT p5t+Bg== Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gu011axdc-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 21 Sep 2026 19:08:48 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2d001671a54so62781135ad.2 for ; Mon, 21 Sep 2026 12:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790017727; x=1790622527; 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=+jmAQdn9jXKepq5Rmmo8OwCGEejY+0pnncnb0YnbRzs=; b=UqiAlf0SQyJPAkIhAGa35E2wwsmhjiBNZFuHpTym1irE40CSoVvtNFi2AaDnFZmS5+ zkW6bK8Q6kW4BLJxoaytk3CRF9OyOOurE+2KnUuiA95N04w+7HSfWcp0QYyghBzdmspb QC5MBtPZzaBX8Z3Zm4OWTC1CHrUAAZqZ00Fy0a5NVy+lw7509788U1y0N1CZq1M2T/vO bqs7NzYsTyYbdmxTa2/DrrgTtdvs4zv9f6KgmXK7AWXa1zE5WzuCFJHMP9T/R5zk5RgC mf506KE33w3ATMNOF1ZPrAc9kRbZE5fRf7lIgvKIK8fm3XMf+UjC+T5U3ZymfvNOGmz+ oyaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790017727; x=1790622527; 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=+jmAQdn9jXKepq5Rmmo8OwCGEejY+0pnncnb0YnbRzs=; b=mU4i3Ze0iyqvuN1MeLFIY5d6as55EeYi3zRNXq5DcWRr+zMUGhuo0+ppzCwZeYThhc PcLQW87sRyu7CqnZbxhkMmu2rUPPdks5vdpBgKlyeyml/5mYB8BeF6rsvG9iN/I3wyRT SkNrdoU+a2Dwf67hOfVJMN/uW0Snn5K+tV3TkXK3P2azUjlVtyHDclVzMlkdZTcQpjLe URznExgXl2ZVzwh3o++HZFyICIJTiXgoylqnMEXxQHDMnSHUowHpDxeel1e8ND3Yg5hN 7TcDWdjTkogCzNimGdcmgN8dHbxFimG1l8L1Io26Gm5KDDer3Z9UIUsrvHWXlwHOUqjJ CVhg== X-Forwarded-Encrypted: i=1; AKwUvBxzZKtlp7OV7aiU54w+yVs8e2RUE/dxejByikSbLFAaI8Iw6UUnk0TDoSHlWgx5PKfKPJZsOn99eeVG6E8=@vger.kernel.org X-Gm-Message-State: AFuF++nURczd7uA9xlUYxlKWN489fCXbHtaXx0wA9qfBWk9d2KfT9qwM ZA3EEStRXgukOPdGfKhpW7COq+iTdc78XSnFu9HZy4n0HFSH56TSFEdMlfOeVJdePbxunPTmva5 lLavP6mbGFmZRHiUL7LCtQPKuBYvSPKOZubGPJX2XdjJ3+Ry0NpzLmtuIeCyvr/evqQU= X-Gm-Gg: AYBFou3v5KjSJ9RuQKp5EHeqdqd6tJr255qfXzehwurh2WOC2RGk0TWQI6siTSjPhNW YwsmFUv2CarXs2GtE7HfcFM5LU7z0BJ5UQwrK528zt5vKPpKN9KgKNXf7u1IQJwZ0WbxrEzdKS5 fwLmcJMpriAYsJNUlWpkWXt4jIU6OIH1QLOnUag02rtkHQj9E7VUXfkrQj/Q673gVFdalvUcCth 7Bd/2QGOLtVE5fHhnd5pXW7VNvZ2AioOumO6+p2MudTvmiBL0msMNfdtDCocTY3kZh5hTHPSUjz zWz7zDIieToGqOVEYLAkizJasJSImtFZo3lhBlyNSRD6WjoNxSOKhC61/3y8og/2n1zqPlsxu4/ nk2cH1kBA+t6Lwxkc/mXQBTWVh3VL X-Received: by 2002:a17:902:ffcf:b0:2db:20fa:9443 with SMTP id d9443c01a7336-2df5b1c9d96mr974815ad.13.1790017727116; Mon, 21 Sep 2026 12:08:47 -0700 (PDT) X-Received: by 2002:a17:902:ffcf:b0:2db:20fa:9443 with SMTP id d9443c01a7336-2df5b1c9d96mr974025ad.13.1790017725796; Mon, 21 Sep 2026 12:08:45 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33e5ec6ea45sm25855eec.30.2026.09.21.12.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2026 12:08:45 -0700 (PDT) From: Ajay Kumar Nandam Date: Tue, 22 Sep 2026 00:38:11 +0530 Subject: [PATCH v5 3/4] dt-bindings: sound: qcom,q6apm-dai: add memory-region and relax iommus 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: <20260922-vmid-v4-v5-3-e79cfd7af5b3@oss.qualcomm.com> References: <20260922-vmid-v4-v5-0-e79cfd7af5b3@oss.qualcomm.com> In-Reply-To: <20260922-vmid-v4-v5-0-e79cfd7af5b3@oss.qualcomm.com> To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Pierre-Louis Bossart , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: ajay.nandam@oss.qualcomm.com, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org X-Mailer: b4 0.15.0 X-Proofpoint-GUID: IbxtkUUuSMMYw7EgkF-QKMaSxmI8Jjv7 X-Authority-Analysis: v=2.4 cv=dPczC+Zb c=1 sm=1 tr=0 ts=6ab180c0 cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=qFCY1Pm5pv70LtJwGgMA:9 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTIxMDI3OSBTYWx0ZWRfX6wi139uNx2EK YKa/iVzmtukZBelFK84WT0UwB9DyC3GYKUfdS14J2i/vZQ3Yi/prxfKaXYIcjI9h6HiUufsXHVu zMtKD1LkXH8a1avw5uMMjLNwcEDf04hDT+5lr0tzRQO6rq2hjzq8z0S2Jwd5WIO66gaeJjqI9+w IlbD0HtlqftVCkSkcjXgbKS1xmBFTWQQeYuk+lg+sawVxoOGErQATfMXDDC7uqHrtTuTMInsIJW ccLuVOTPpEgFAF2ObcgV3AydhT4tGUmTRhGZ3OuBZ/u7SppskTyjGHmonCDXaThd4iTxa8rMQ9P 3jS94cFfPtiIixl4mUeAElE4PLueAJz70lPmQ5Dca8us/xapRK2cTqtUHvWJjwvYRQj6hs2R6nI QFG6SSrX3xmHI+3BfSfESSEC0DM/3O/AyPsw/sb/TKcuQoFICtSrFGo9wzCpqR1O1IMtNqRjyNp eDcRtf6SUinK5ZZAprQ== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTIxMDI3OSBTYWx0ZWRfXwGw9z85Gb8Yz cAMTyOEiYvzRn5OOltt8BiLGlS1shkmcSPbVEmlcCTZYQL+WegdFa+KhNVukh3hhLYzHNdqy+i0 vV62Ub2LNLf1YIBt9vaKQ2eJxM8FBKM= X-Proofpoint-ORIG-GUID: IbxtkUUuSMMYw7EgkF-QKMaSxmI8Jjv7 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-21_05,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 adultscore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609210279 On modem-DSP (mDSP) platforms the DSP runs in a stage-2 protected context and cannot use the SMMU. PCM buffers must live in reserved-memory carveouts that are SCM-assigned to the appropriate VMIDs. Add an optional memory-region property (1-2 entries) for the control-path and data-path carveouts, and remove iommus from the required list since mDSP platforms have neither IOMMU nor VMID DT properties. Signed-off-by: Ajay Kumar Nandam --- Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml | 12 +++++++++= ++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 --=20 2.34.1 From nobody Sat Sep 26 01:07:15 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 E699050B8C3 for ; Mon, 21 Sep 2026 19:08:54 +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=1790017737; cv=none; b=CveDHpieCyM3XffC12se/Imbs7vBKLbKlNt8Jl5CiyAdIdIYUw1a6I0iDN9++Wy6F+MBmIkOuh85WMxXK1cKtBWw/QHjfxAUMekIfg1Wq7Fjq13jxV0UWKwlZBqRiP0h2TiSXgnsE/wXa0KFwwsn27XUX2JM1s9XkpocKtrfr60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790017737; c=relaxed/simple; bh=bCyxMrtXEmyjmNZrDqIrBuxDNziccBYFzQqAdOqOfsA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nZiaQg+pF6jXvzYlqIXSy48TCIpbIJecUHhhn4fi4SUvyVudxcQzsGzVGhBVgYpOGh4CVmQfbUNeQABUuvmz+vUXpwjH8C/FYiLhkmNB55nYj9YQklWP8Nt1+fg6CXCGw1UisteL97FhUxjA+vEU3a9YnB2apDNhD5tuyPWpEcc= 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=MmDOUPje; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=I0ecW+GA; 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="MmDOUPje"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="I0ecW+GA" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68LFAIpL2011980 for ; Mon, 21 Sep 2026 19:08:53 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= KOvH+k5AGwqT6fPt4nwdgOAAtcuG2W/Fpn6K2wHSVGA=; b=MmDOUPjeBNx466mK K1qKq408EvglCFOdOpbkcErzBlMqHaILVBMgwAtf0Lxeu2jx4wfuInGcYJFZIc4s 1vPR3EhfIVpacNzUDJBiNqEatGlFnKU3Pt2a5hsinHaERYekBJf+w3VNKdbTkI/I nqj3ZZ9KSIwwHU0UFwQ4sstlthZGQOablst+oMn5jkpDmM6yZl3oK0I1y3SD1aHY rKTLZy5qOcCrve6+L08qDH3n6IrG4cYwpUB6fkcscJYoeA+0/2Vlo5xE8nRbDQ0s LMnUW7XVPuFaHu+UchsxW/G6sTM4R9o0GAENsKXqr+CU4bhGm54zZPLqL41Fzo6i dP1Q1g== Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gu01d2w0c-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 21 Sep 2026 19:08:53 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2cee1ec30f2so47000665ad.3 for ; Mon, 21 Sep 2026 12:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790017732; x=1790622532; 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=KOvH+k5AGwqT6fPt4nwdgOAAtcuG2W/Fpn6K2wHSVGA=; b=I0ecW+GAxSZoycNrJUSkbx4LsGuGTK/1BajFGFH7/ygk7ejPc623vA1G2jwbtMjMlj lXWIjcteW1J/n4DwsJemoTFpYWMkNahScOUMaE2zk+ptQdKuEboGGz4BHzfzFvplRkVa 4R4l9WNtzEkloQBwfLYLjxtxWqYecS6OtkzBl9y0pFqaQE/3KdcSyqhZeS/4Z4vyyxc1 mY6apUWaGnseBakbBq+pWpdfyIuyw7xycneIRJ8b6CGzpzNlN/3kpSb4bGd7eqST6UVE kQjNI2jWhptlI9QvypfuqOl1i1p0Tt8hNQdkzaZlS2yp6ghFgSmCGXX+OL5Mm/s9Gekv xTNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790017732; x=1790622532; 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=KOvH+k5AGwqT6fPt4nwdgOAAtcuG2W/Fpn6K2wHSVGA=; b=fkhoEOPm7UfRK5Qn2iRkYhWWfHFMiEjcrCYxjpKNNbk/rh/nqjwQkSQ5hUqPPuHBNJ /kze+wH9WYF+x9sq9Iun5TzkTp0UnNyvF7xsrmzJnWTdiTpw3udPsYfnPgEzFYEfe+zq ZJSZC6KF7elx3ZqBcPcP5yAeaNGdDlkPEt+tLaGfFkkW1RG7cmDNBqWIZzmD0Gf3v7KH YLrmj1wsUgjPvHCg8JqwmWTMtkHmHOvaE8y7JB37+oF6s7n4oI3atTHiYt3kb3nKi84Q wp+JZTyheqkUGy9/Qf/QqdyBb/0Icaba/PI899emeIOranwCTC5rAZunJ7i3qKEukPu3 lUBg== X-Forwarded-Encrypted: i=1; AKwUvBwNpCeNSunMh8WEHV88hixe2njWyWuEW9BzNkYCLxLjmUeZL2Bf3uzcihywwURq/XIkRcwFzL7utDZDt94=@vger.kernel.org X-Gm-Message-State: AFuF++mtyPJ+kXHwtLxGtkPgTH4qt74EzYeaEaSkSeTkkc8KbJw0QepH gAYbLmk6bUtTVr/vGVqp07FJhVcrkeQ/kZsIB04zR2PYfENRfoltfiemRwHRYyYqJJhAeSsTx99 aTHknnbL99AHWx9IANVcSrfThj/RRTEps1h2zRxn1npfZN8i1Tj36VotBaZORjt1Z9dI= X-Gm-Gg: AYBFou0SjjIaS72nv1NCyc/WL0UG80RedjJKNcuLYOUuTcssBXpbCsxZXLeXVC45TbO ZoDjRn/BcgrlmYTavSniuIe+nlTwdlT+zNNEGRPQTDuoBWUw2s2V7RFyDsTc4Hsw/EdtuWc3zru ZF3bjjxoM3T07IqU0QAw82O2HDCzztYlGS/E7honsM+2rJN2F+wHyM6K2snGG564+IN8x27FOZj D01nGMBOmuZkEhsUJON/nLxaQKKA2GC+eeNBdbSgWucdqffLxhPcqPtXZBxYTCOAFZ2PLuM6UwH 2i9Testi0m+/GW5gDX1Lgbo1xcmYIQPxMAKP9OiNRjFTLQ4DrWfip9zwa++YD5ocXc6du1BxD1D LncGkasWgyi8WDKXyJpSRhfBP5ho5 X-Received: by 2002:a17:903:4b0d:b0:2dd:c100:424c with SMTP id d9443c01a7336-2ddc100456amr110512615ad.48.1790017731806; Mon, 21 Sep 2026 12:08:51 -0700 (PDT) X-Received: by 2002:a17:903:4b0d:b0:2dd:c100:424c with SMTP id d9443c01a7336-2ddc100456amr110512225ad.48.1790017731210; Mon, 21 Sep 2026 12:08:51 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33e5ec6ea45sm25855eec.30.2026.09.21.12.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2026 12:08:50 -0700 (PDT) From: Ajay Kumar Nandam Date: Tue, 22 Sep 2026 00:38:12 +0530 Subject: [PATCH v5 4/4] 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: <20260922-vmid-v4-v5-4-e79cfd7af5b3@oss.qualcomm.com> References: <20260922-vmid-v4-v5-0-e79cfd7af5b3@oss.qualcomm.com> In-Reply-To: <20260922-vmid-v4-v5-0-e79cfd7af5b3@oss.qualcomm.com> To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Pierre-Louis Bossart , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: ajay.nandam@oss.qualcomm.com, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mohit Sharma X-Mailer: b4 0.15.0 X-Proofpoint-ORIG-GUID: bNT8fxhJhyeqNs9OJNIGmn19vtt5PpUz X-Proofpoint-Spam-Info: AW1haW4tMjYwOTIxMDI3OSBTYWx0ZWRfX4UWYbAYE3Yxq 5g9C256cyUCDNsuv8R1eeI9W+55WZbt3nX5wgiWDmTLRCxhZRIjvcqiRmYHpGkyX/yVeBDLLjaE oFc8x0jL2X0FfZfpzMNAiQsUw+YTbYU= X-Proofpoint-GUID: bNT8fxhJhyeqNs9OJNIGmn19vtt5PpUz X-Authority-Analysis: v=2.4 cv=Ht7jiETS c=1 sm=1 tr=0 ts=6ab180c5 cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=dZMXeEXeUVJkk_AjZxcA:9 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTIxMDI3OSBTYWx0ZWRfX/dhzpP2atKhY AI3C3VH36pOAgmslVQc2Wc5FyDNTe2vT/sdqPecP7cnS/DeTHCVrzsQndMtUdryGcXx27JDhdET spMm4dG6zUzeXRlMcfoU0gW+F0+5hRCwE2oZq0+Tsz1ZRg5PLXpS6cKLbr8yqnSqYdYTCCNinpq obZ98Yi0HA8teUFjVpAVQXynklWJ4f9ymPVDYUJmqZ8sP+Vefix5S5+Wa68PmqoVtD0erWcmfe6 gxUDw68jkgcAnZcKkPUuCsMVlhjdeT0muH5oy0r6neY3kyJ5zWSH19FlkFDj3ndweOscS90DUwA hY7eEv+Oxe/ytnJoDcev48BWHvTbCWJ6T2goVKAxImSPqQEUFItW/ndWL+G19lArh14PcBNU1Jm 7xjshApCz3B8+5RTzbB9ZxM2nKvTdDyvEA53OVfG7Pzeyat/SJl88Rvmn1Q1lB5ZQ8hLun+YN5E +lQ/yIZHc+UnQ7BHCtQ== 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-21_05,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 spamscore=0 adultscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609210279 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. The data-path pool (memory-region[1]) is SCM-assigned to the consumer VMIDs as a single whole-pool operation at probe time, rather than per-stream in pcm_new()/compr_open(). qcom_scm_assign_mem() consumes an entry in a small fixed-size TZ memory-protection table that is shared platform-wide; assigning individual per-stream slices (up to Q6APM_POOL_MAX_STREAMS times) exhausts that table and hangs the SMC call, which was observed as a crash while bringing up the sound card on Shikra. Since the whole pool is already accessible to the mDSP once assigned, pcm_new()/pcm_free()/compr_open()/compr_free() skip the per-buffer SCM assign/unassign entirely when the data-path pool is in use (has_reserved_mem), and only fall back to per-buffer assignment when use_scm_assign is set without a data-path pool present. Compressed audio streams follow the same pattern: the DMA buffer allocated in compr_open() is SCM-assigned immediately after allocation and unassigned in compr_free() before the buffer is freed, unless it was carved from the pre-assigned data-path pool. 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. 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. Co-developed-by: Mohit Sharma Signed-off-by: Mohit Sharma Signed-off-by: Ajay Kumar Nandam --- sound/soc/qcom/Kconfig | 1 + sound/soc/qcom/qdsp6/q6apm-dai.c | 300 +++++++++++++++++++++++++++++++++++= +--- 2 files changed, 280 insertions(+), 21 deletions(-) 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..06438fedad0f 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,9 +708,24 @@ static int q6apm_dai_pcm_new(struct snd_soc_component = *component, struct snd_soc if (ret) return ret; =20 + if (pdata->use_scm_assign && !pdata->has_reserved_mem) { + 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) + if (ret) { + if (pdata->use_scm_assign && !pdata->has_reserved_mem) + q6apm_dai_scm_unassign(pdata, + substream->dma_buffer.addr); return ret; + } } =20 return 0; @@ -635,15 +755,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 && !pdata->has_reserved_mem) + 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 && !pdata->has_reserved_mem) + q6apm_dai_scm_unassign(pdata, + substream->dma_buffer.addr); + } } =20 static int q6apm_dai_compr_open(struct snd_soc_component *component, @@ -683,6 +814,17 @@ static int q6apm_dai_compr_open(struct snd_soc_compone= nt *component, if (ret) return ret; =20 + if (pdata->use_scm_assign && !pdata->has_reserved_mem) { + ret =3D q6apm_dai_scm_assign(pdata, prtd->dma_buffer.addr, + ALIGN(size, PAGE_SIZE)); + if (ret) { + dev_err(dev, "SCM assign compr buffer failed: %d\n", + ret); + snd_dma_free_pages(&prtd->dma_buffer); + return ret; + } + } + if (pdata->sid < 0) prtd->phys =3D prtd->dma_buffer.addr; else @@ -700,11 +842,16 @@ static int q6apm_dai_compr_free(struct snd_soc_compon= ent *component, { struct snd_compr_runtime *runtime =3D stream->runtime; struct q6apm_dai_rtd *prtd =3D runtime->private_data; + struct q6apm_dai_data *pdata; + + pdata =3D snd_soc_component_get_drvdata(component); =20 q6apm_graph_stop(prtd->graph); q6apm_free_fragments(prtd->graph, SNDRV_PCM_STREAM_PLAYBACK); q6apm_unmap_memory_fixed_region(component->dev, prtd->graph->id); q6apm_graph_close(prtd->graph); + if (pdata && pdata->use_scm_assign && !pdata->has_reserved_mem) + q6apm_dai_scm_unassign(pdata, prtd->dma_buffer.addr); snd_dma_free_pages(&prtd->dma_buffer); prtd->graph =3D NULL; kfree(prtd); @@ -1021,6 +1168,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 +1177,122 @@ 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 + PAGE_SIZE) { + dev_err(dev, + "reserved-memory pool too small: %llu bytes\n", + (u64)rmem->size); + return -EINVAL; + } + + /* + * Assign the whole pool to the consumer VMIDs once here, + * instead of per-stream in pcm_new()/compr_open(). Each + * qcom_scm_assign_mem() call consumes an entry in a small + * fixed-size TZ memory-protection table shared platform-wide; + * assigning per-stream-slice (up to Q6APM_POOL_MAX_STREAMS + * times) exhausts that table and hangs the SMC call. + */ + rc =3D q6apm_dai_scm_assign(pdata, rmem->base, + ALIGN(rmem->size, PAGE_SIZE)); + if (rc) { + dev_err(dev, + "SCM assign memory-region[1] failed: %d\n", + rc); + return rc; + } + + 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 - PAGE_SIZE, + 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