From nobody Thu Sep 24 13:41:54 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 3A8C03C13EC for ; Wed, 23 Sep 2026 16:34:06 +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=1790181250; cv=none; b=X922Ci0kjBROtykcJ2UXABXDyZVPhEgcO1gLYTt7JEhsR2t7Sh3uf8PX178/wsYaDFkHL3FnZTkpOLnS+YFKW9VyKediEwqsxCQv8aTRoIizcMRr6DFK7H0MjLyzA6Z9oN8cYbm/QL4WlmajBwhj3yw+CMJDqtjnfIBwNBT6hkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790181250; c=relaxed/simple; bh=coYj6sdykkd1PCi2KNjcYdAGy8fu1yFBf4PZfUBvnrY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CYpB3TaV9/pmNJstXIYmsIChPLFAa4K48EqfvwJemZ207A69qdNgFoU8GBslgjbkyhh8PBYDHYnRXHWilNWG7Dm8t8xHwI1o5mJ+zC0ykPAu3ved7YhZZ/j+OwZCyftcuiNzrIYQsFGWwfgAczo0kVrcUXlFcJWApo6Wv5/nvH0= 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=U2LWSuA9; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=jAZT0ooo; 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="U2LWSuA9"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="jAZT0ooo" 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 68NGTjMX3938188 for ; Wed, 23 Sep 2026 16:34:03 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= llOjDMEuBFDv+DyQdi/V2z3mxuMuRRhWgPZ4yTvTgrw=; b=U2LWSuA9ySbC9DCv oxBX5bPcUF7vpwb+ebNWmeTDI/8DmP8rIYhSSyMr/L13/5kX3Zjq4feHf/XlD4pS /1LdmbKvfDr0LkK4zyy71hJLrSUx96gJm/qXABVc9UNw4U0nx0VnFcVHM3q6ygqR J31VkBwr2MRdO9/zJX/BcUWJuQF29nQN/jHrpc95HEYpQrR69IWH+RcxNYa1GmEC CASNA1IRQfAakvJrU/ff3iqHKAsQrZ7JDg2ZTeNfEMyfDf4aaBnV2FhfCi8V5DaO w2a1xoe6qOcbZRzp38FT+9h88POIqobtecGmuoEmWlHX3mc6Nnn9mNBR/iXBsz6J BMH/xA== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gvbwm9vc5-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 23 Sep 2026 16:34:02 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2db8c152622so7307315ad.2 for ; Wed, 23 Sep 2026 09:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790181242; x=1790786042; 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=llOjDMEuBFDv+DyQdi/V2z3mxuMuRRhWgPZ4yTvTgrw=; b=jAZT0oooBgcDa9O/kLR9M5vCeODvhRctJOpVOlBafLgzIEPIDQNKyXxEOGw8LDIYdg M+CDXj6YwUhK6pW06bD966TOH8pFO7xiTw1//YwQOul1Wm4xCvpBPBG69XUHXoSO1LuK QR49Jig36y6u8BUCVLc1MxvdDiUMBuK9N9PTwtTjiR/8GU/nxof7VVUg9Rq+rLqMqryA +hCXbjXU/9UAsFXKbN4RI5Al8At0b88yGNF21x/HBru4xBijm18nOajJnqdox7G6ddWq LH3JHC58un47Aj0DbLedE02/NKEJvODUH8rDAIgE1GJbEaCscKEPdmcxhlHBy18ZJlWy jh0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790181242; x=1790786042; 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=llOjDMEuBFDv+DyQdi/V2z3mxuMuRRhWgPZ4yTvTgrw=; b=LeXTwT41PcQlp3MXY4DuMD3CvFhMVCXUxLu+gpN/GUjBOOriZEXaJ5u8lzh2iduNpi gXtAgj7Iu5NabLvkiBmNaTHimdHgJhmyEqSR+Mr8pMSBFvzNU8pFkRaTdOZ3+uLGBds1 JGVlF113LMZ4aS9jkaqJ0yavCsUwQPZTitPScJCracYXq7kwdvnGD8LQkzzegErZyKzQ O8J4PSZbb+v0/N+lsQsn6d188+32SJ2vAv+twPKlIYnc3DDNlwGo+1MpWNHxTqQgqlkp dS5Q/Mz+UluQEmIzioSU34d5/zb9Ft3xhjHtVAXrPpyFjFAUWneIenWNTFmdgzMw0dFc B68w== X-Forwarded-Encrypted: i=1; AKwUvBwjuyv/SVwD820f2Uc0tZCZ3gMEg/wZOTDj/bLpL+zIorg9H/siab9FZp6wrjshZrqM+zoprDuDaoP7Ouo=@vger.kernel.org X-Gm-Message-State: AFuF++maoommO1mAGdX/k72CNK4mgkRET61BgdNA2qlqYfw89OF6aaGy ImSR5OoEkOEmJ1CrVC5DRaJVqKDkYK6SAI5gw/IgQ/gCawck6u2rryIoHCevwquLmvi9/oRJvYS epPlDcaRjWQpyqCKEs9bFz0w96KgCy6IsKPhaWGiBM7RYd4EQxt2Oy0LYd1Zyn++t0WI= X-Gm-Gg: AYBFou1YIPwenInTk8tHW+jwR/pUKM9iVz1/rVXEF8YKoR+HaumALHHlWUKgCLajWEm TJ6c7XvVdPCYFbsG6aqR+VWrunNRj1OxAIGCysf0+HM7YgcVkZktBE2JbJkVkXSSBp+WVW3v210 FKye1y/1gViPQaOexRde4Md1/k+EtXrLS5ZUh+BzMSWxb45XelKAp45kTrHiiMf3pQmW6RluICw n2GXr1JWAJ2ZLUB4iDOp2c4duwnj9KEpi2JPzE57Ad4UwG2h2bgC6FjtQa88kPQNnsNEXcYVsJY oLpG8XHYd7ZaBzb1vyPVyNtvQLmBxsyCQowMo/FMHp+YmRBtvT3ttEpGZqokX12aXODOnuQ3K8G qssda0c61YhI/a4ngys7TIRrzgS8= X-Received: by 2002:a17:903:2f85:b0:2dd:c053:ec71 with SMTP id d9443c01a7336-2df69dc771dmr26576365ad.36.1790181241908; Wed, 23 Sep 2026 09:34:01 -0700 (PDT) X-Received: by 2002:a17:903:2f85:b0:2dd:c053:ec71 with SMTP id d9443c01a7336-2df69dc771dmr26575935ad.36.1790181241272; Wed, 23 Sep 2026 09:34:01 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2df6a5a6d35sm13994895ad.19.2026.09.23.09.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 09:34:01 -0700 (PDT) From: Ajay Kumar Nandam Date: Wed, 23 Sep 2026 22:03:38 +0530 Subject: [PATCH v6 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: <20260923-vmid-v4-v6-1-3d61a0319b1c@oss.qualcomm.com> References: <20260923-vmid-v4-v6-0-3d61a0319b1c@oss.qualcomm.com> In-Reply-To: <20260923-vmid-v4-v6-0-3d61a0319b1c@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: AW1haW4tMjYwOTIzMDA2NSBTYWx0ZWRfXzunREI5TfYn3 s8zjWNLC87bbkvy4VlGIcIP8bNCluFzdCROpuyfpqAOGlszeGvc0XM4+F2uIvYx3MdkW7+KPjti sg+Aog59RCx6wYdUiyccqN6FLDWUFK0= X-Authority-Analysis: v=2.4 cv=R/6WitRX c=1 sm=1 tr=0 ts=6ab3ff7a cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==: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=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-GUID: EbuoRfQ9aitQ0RKXr0jMexKxV2HXa1kz X-Proofpoint-ORIG-GUID: EbuoRfQ9aitQ0RKXr0jMexKxV2HXa1kz X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTIzMDA2NSBTYWx0ZWRfX867ANVS6Bkiv /dTYt1WUSxsltxcHxVRxUWHAZOLh+Dvu/hreK2FIJ8pDQlzeNxJuebq8ksig5DHH+UygXuwzHtP 0b3UMOAUarZrp/+DGdH9KJnNaGqh7OaE0cgiOueRM7OSsA2NtbXczuN0o2lo3ctkR/+xW5/woOb 5D1jOnX+55iFnWF17HO+ZELbSOSAdXsg9KdMc3upe+fxum3gyCAdiuG7GSwWq/uF8f0FZorhecq +3O4+KUM1TyBzpWSlR84eJYbJuRoy1GpiT4y7IiNQW2Xtx/VuxwM9S8TYG+xzcC98z4lntquzld P23PLAXYz7gkjil+xAtjkhuvBO1JW7/petc38SKgVSQyyB6Ep4gxTlHStj7PHtrKPutV60c3x3p R9dfE1R/RjJcLcq2+mqsn8i/KXlK0bYVDAUOnDueTydP5wcr2MXGrDqtkf0KzLRcBHnwjMyI1Nr H6J77cgINfEAr+qTPOg== 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-23_06,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609230065 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 f167b9dae3fa..eef4b496d2aa 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -900,6 +900,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 Thu Sep 24 13:41:54 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 18BB13C2BA2 for ; Wed, 23 Sep 2026 16:34: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=1790181261; cv=none; b=YtHdqrok8f2Vkvoa25RF+YbfYt4l1QjmgfesT6E5EGGToUv5u4Cv0GViDgN6EIP3+/qCZ20nUy2WT96PtX8hr+HaookubtA8B8Bop58j3OpnjzTvkPbOAJs2axP5CavGgit5v1Z6ZIpCd1qTinsR1XW+pqCm1Z0wtOAOlRXuAKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790181261; c=relaxed/simple; bh=47loNT4DhVEf9UzFy8r4935vDPnfMGM+QfqANZwjVU4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=prsAqcJUJlTVBWhzPt/i1hDSSIvnFApmg8gyZk/vhmE2dcVmPpAH2CoZ+FbtTTZW1CSmMeuCdBMZsP7J7TePIPRNDnZa2A56rwBCqxQqtd4DT9DE49X6Hq2w4GcxDs48dSXtjB4nylSMR2yN4OlJC46vhTDbvhtocEmGOYAJmt0= 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=CQ9q1ZwU; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Hg+VB9zW; 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="CQ9q1ZwU"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Hg+VB9zW" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68NGTj2B217785 for ; Wed, 23 Sep 2026 16:34:08 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= /W1G/LfLwb41fze/tokJxczt1bqU2MY41K03t9d4wwk=; b=CQ9q1ZwUMbMw17qG xv0rVQ5/eHpQnr6m+fz6qjftNssQppeiNaOV7/F+v6V/hx6sTKmYiqATN4kLS1u0 oCHh7eZIkTKKPqRRnyHYHnVtuPC2Cvf17EzLCyrcYJvERKqpowZ6rmuBJkABLnns gy7iQVA8Cupwi/VsO5et3yHtFkvf93b8RBQ3H51t6n06IivVZ3UE6g3fmgR6YKHJ SHzGhx/EgX3LlJwLezpG9NdD7jj+E5iGS419rfrEtXOlRJHdIlQl3cjefBfjxXSZ 1s4BQM+c/ylCBai/0c+d2B3yhIMmWD0s5YSwz3fwhH5v4JCOGXS3/ksIi6q5bVRV +jVl2Q== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gvdb61eye-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 23 Sep 2026 16:34:07 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2dc92350888so17716815ad.3 for ; Wed, 23 Sep 2026 09:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790181247; x=1790786047; 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=/W1G/LfLwb41fze/tokJxczt1bqU2MY41K03t9d4wwk=; b=Hg+VB9zWyLN6qMn2mlbGhT370Tpfj6mIU9OisIKxmKhf9MSSQox6+jJ9q5udBF0eSO 0G/Ju6ymb53GMuKj1Er1OSXBhCQwWI8FPpUI+TrYaG2zEguEkBzZOHJ9UWT+GG8/oZUC SURtMKLN0VYM0UW6Fyet2i4+omDX44+HUKhnPYy5b1Xgrghz0LU2dYmKNSXeaqKfmgUP kBL6C6DATkfGjqJOVhe4jnZBns0UQsZl0ezWlxlcdPAi9lm1ydxCnE/D0ugWyVEM8ezT yCjlbUMEjV5OErldauvtWuf+k+46YL4veykQCzRa23wF05FNG9UqYL+lKPz5xrZAddzv m6Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790181247; x=1790786047; 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=/W1G/LfLwb41fze/tokJxczt1bqU2MY41K03t9d4wwk=; b=z3hWOOnzICC6XFWa848ADj8chqcRASU34g5QF6A4AXno6/QBo+qFuSrn46HF6jxH5K +9kXcaJbBDZoKi6btRWQ+SLvPgAlHj4L68bZy1EQ4lOwwSgzI7ZKnHrdqPxUBJg1UN7O NqukGiWM3rb7J8pSeUbD0Suw4bPiqmMaLBTDtrBQVlhC+1vYtEWsTs0JitRBBUe5HRlQ bpZq7V+C6Pww8QmxnkxNCg3oZe5Mz54vxSFruRchuMTrncC1Y1uO8Q9FJa4opq/wGGfI 3HltHcj53UZUDIzLYW9Q/yaZ8deEGtyvECMb0M3kxvIBVjuk2hArWXk4QzAi7oiVvDeH W4bA== X-Forwarded-Encrypted: i=1; AKwUvBxYU6OnqL/5Ac4TiUtNk8f67LuDwZj4QIAH5HJqmcc4plXHYLFZm7dl20LW46Cm4ILoZExwptb7Kl0FFFk=@vger.kernel.org X-Gm-Message-State: AFuF++nbdtzl/SnvDwvvHBpDiaUxi+WzNIBdoQJWATOZdgZT1U+gRbiL ZuKALmVLD1804yhKLQkW3C6wjasdIJNKZfdc8LM3loyujozWTXk6Vb823EIke51uLGYPmAhGPzU JcoIx4hSIdpjLmp7IJFMs10C+omymVJREL6i9GuBO53E2leEBBRJZTUoruFSxf54IlR4= X-Gm-Gg: AYBFou3CCCXPY/PAdQT9c4MWZFm6PVG/CDvDUSOJ8z5gGygTN3glUgUiqkX/VHBGzhH rM3Dw0iOYcyi7kjHJcJFa8OJSiF1hgg1AkMngVsuIFsEq7Bh6ksiy/PsDL1NjVKc4CvyotUzlpJ 3joSW83bo9gM6+zTKj0hTdPXcF+hxrXGSh77AlbGOlk05pX8RoyFgUdOsaK1j36OaoTCejSJnaz vtXml0uyoz6WDeM6S3SpnKUt3yFgZmng68KoYPQEUP3X+PFSFmcUd2ud+L2pebixbNwHPnemuPZ iemMGyNX7pyI7opOxjFZXL/hlLtzsa/ymzQDvtFaDE1I79hsHIRMlHGrXnzEvZH6ixlJLYD5cMs PciCfD0onj7uBRfs+hEgSmClVk0DtnyLnN8raDQ== X-Received: by 2002:a17:903:160c:b0:2dd:c100:a5df with SMTP id d9443c01a7336-2df69e0c503mr28604905ad.51.1790181246701; Wed, 23 Sep 2026 09:34:06 -0700 (PDT) X-Received: by 2002:a17:903:160c:b0:2dd:c100:a5df with SMTP id d9443c01a7336-2df69e0c503mr28604455ad.51.1790181246206; Wed, 23 Sep 2026 09:34:06 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2df6a5a6d35sm13994895ad.19.2026.09.23.09.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 09:34:05 -0700 (PDT) From: Ajay Kumar Nandam Date: Wed, 23 Sep 2026 22:03:39 +0530 Subject: [PATCH v6 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: <20260923-vmid-v4-v6-2-3d61a0319b1c@oss.qualcomm.com> References: <20260923-vmid-v4-v6-0-3d61a0319b1c@oss.qualcomm.com> In-Reply-To: <20260923-vmid-v4-v6-0-3d61a0319b1c@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: Mybrl76r4WfZMCALqd9U9t0S6iUGptH0 X-Proofpoint-ORIG-GUID: Mybrl76r4WfZMCALqd9U9t0S6iUGptH0 X-Authority-Analysis: v=2.4 cv=QeXzLcbv c=1 sm=1 tr=0 ts=6ab3ff7f cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=06UwNDcAWG1pVACfRQkA:9 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTIzMDA2NSBTYWx0ZWRfXwfyppxfbSJa7 vSbXJLl5j4QEbsAMWZJWm+anjCwQX2azYnUhh1d3Ap7wO1w53M3TdOW0wS0yTOII7bP6bxjO4M7 mYBrQ1Jrsp9qzb9Ts28lFH3b3O9s0pU= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTIzMDA2NSBTYWx0ZWRfX0EPS4GmyoJkr IpLiDJykfRK3/eiPD5WfhcoHYhylk+YExsL8IdoCiKU5wgmVoYHQK+yeYymWluIhAdkx72sJWcB B8NNDiktl/6ItHyDEoxxJYRGgG+/1ToRdlXGDIrDp0GzNyGkrDmvbJxXNzXHwdVNU+K6AFvgxet uCFNKgq8jDm5IEPOilcXmUlwIVyDnfYWGWhZfFG6AjfZlULb7tlDWQCz+J/TavOHsGfb2+vwRLV SZVLPaowG0OR/cumUaqV9uZ0vISV9aGQ5y0rhdxTw8bTutJ6kWT/1YsrvXZqVWPq+p3J+Pnf66R vibb7VmQnF5HM02hHQUZ3SYz7jdplE0zPH4HAmmgTd12mhKeKrleeQFWWYaIa00yNPuNCQdhiPw zGrHf+Ea3idJGiOCYO8mg5RtQ3SPH2NokPPpmw/69wqCmg+e0xpromuFg/oMjl2c4kkH32iYs5J by0yuspWOu6Gj6gcqkg== 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-23_06,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 adultscore=0 clxscore=1015 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609230065 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 cce0ad31ff0c..d2dc5d37bccf 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -593,10 +593,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); @@ -636,10 +636,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); } @@ -994,6 +996,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); @@ -1609,6 +1613,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 35541b2d8c99..587f14ce71d2 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -1002,14 +1002,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); @@ -1020,10 +1025,13 @@ int audioreach_tplg_init(struct snd_soc_component *= component); =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 eef4b496d2aa..ea6680925f21 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 1f3ce4cc0837..2042ff1e8ff1 100644 --- a/sound/soc/qcom/qdsp6/q6prm.c +++ b/sound/soc/qcom/qdsp6/q6prm.c @@ -57,6 +57,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 Thu Sep 24 13:41:54 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 E6F5E448B90 for ; Wed, 23 Sep 2026 16:34:17 +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=1790181264; cv=none; b=KrnRMpP9mu9Dh8zFP2tsE/ZfQ/Gonnue0NfZWr4OnW3gjpBTr0Ha5xrVPAGx5BbcVipPRQnvmJl0NAWC48fP5JWOMdbmXsBFHot8D1MhrAddfDBb8g4Xj8cI2O3h47NMVlL2321XuWVfOrO2aToFvC7GRmgqF70hDfGQjDpKbMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790181264; c=relaxed/simple; bh=bZFCmikbhjibr37QyYsw1BYnrmuWJX2eRfQcgt38jzw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qSpbWVTZGkBJT94LUczlCwKCGWJLe6MO4FCT8NDr1QOfv5dDTAk0Dj9l17zgOd/vgyMzbB6OSoEJwyK/sxrzfSBZh+IEJ1euP1wI5MGbxWOL6nCsF6pH+qWYsLxCzdSAAPB4PoJHhUrOkDZYa3yrahiCyWdByz0pnyiQG8xyjDk= 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=nahf0l9F; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=BESC2Wq0; 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="nahf0l9F"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="BESC2Wq0" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68NGTkPV3665741 for ; Wed, 23 Sep 2026 16:34:12 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= d0pBwxzDmGvmNSPMqwBbxTyOwURg+F3QxfDPjVKyU68=; b=nahf0l9FZwqO/OFE YtKXTqp3WUrfiS6yFO7MwJoQSV+O8vg1FEkNYZZoJiPrc6kIb1vYwu0fGqql/9Wf IdZG6Q0qROLFo5bTn4CZ0hoIpWHDMRbv20dueCA+U3VZb1nYN41lsPsa6u2hLRkL 9GyOXAuRRBThbUCYjDLLZkFBFUtfYnE1SJ47+6g5ghMJzElhqvrUBOt1dnMVP0C1 Fn+bK6artLcmN0agK4NsXccxSNZnUb/DlWNOhEUFOGLkEp3T/0UIw4Bs/F9ak4e2 vAKX2XYofATsoLY07hkk7bqM20PyfqJMwAKA9dDsNOgcL49OiUOOBIgv3LgOmL+1 FA+vyA== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gvbwasvmg-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 23 Sep 2026 16:34:12 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2d6fed0652bso9547555ad.2 for ; Wed, 23 Sep 2026 09:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790181251; x=1790786051; 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=d0pBwxzDmGvmNSPMqwBbxTyOwURg+F3QxfDPjVKyU68=; b=BESC2Wq0iW/1Mp94ToovqSiBdTSZqtuYRHI9Q8+JxQUCZBzIxHnXcLiqf9w99e3l+h O1fEz+mcYxsvvZBQvylcHi/dBDAOmDSKK43fcvBXxK4R/gtNqCC8fHmi2GYqphEQBFci 56lTfLoVZyb+0nNo1WawSbIuzecm9y84AmCn6XEVg3iWC9kzIt9VZk7dtS0sVTXRI8Z7 LRPj5ARQX7pSQXRwPp68MccaaMWRVh0d1jbZQBepfrqDVsr9fc+x45SZYW0A7GA4nkhh LYICSW1rj897VA7P79Tu/hEO8D+2yAiNH0AgHVdecZKh3gYxzzLsRSpe+R2NShnh58O4 +M5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790181251; x=1790786051; 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=d0pBwxzDmGvmNSPMqwBbxTyOwURg+F3QxfDPjVKyU68=; b=VyXf+JNjvkty7sNCMjdstqyt8N2+e16XplND4cdVweDPe1KMYRvK9ib5FBvH3J3Ef/ oBQUFty507kOSdoCqrsxV0FN/uAracjHl9FEb57Ck+46S3g5Ujf5OcIo57QLQsTgdY5X UnPb8k43+rgBfstzS9bqXUrX6KRx6wbaKtsU3lDhbipDaFabQPEFmKtBEheNyUQvkl1J CUQByw7EVgp9tEG1FmRgOjpl0ibJysHZE0j0dDq1ID+WnWiXAQqL7S7y+QYVNw2+ooII wewda/guBBreyG/BCRqst0AIwMqazzlYFfOZo9ng76ZoIZmpZrY9pSUEN1oAbyE4X8yL QXGA== X-Forwarded-Encrypted: i=1; AKwUvBw66O0u0pE3bbk7C+1YRf9R72goLxjsAWwJd/mgXNA00SGqG2ZXaV1T7lJVO/dSjY7QraRuOX70F4bmJcs=@vger.kernel.org X-Gm-Message-State: AFuF++lCAFms8hez0MVLw3ME5obxsTpzORqffVQBJ+RjrNRVUeudtZVW paO4X6JtFbIDrzAfKrRG9PfoaQ5LwNj54BVHaA6FaaQZvecYTxdKRxcWmIAoaLF+hARV7Kap12N y5bagOYNDl+nDEQ9N4xi8VYbi5WYibOPpcRYLAjO4jM/5YTIBeJrdgalu+cFAnJWVtLU= X-Gm-Gg: AYBFou0JOpetQjN8uE0e9Wmdoj4Viha0PFzLsNQ3e8q9l76C4Q1+bTzbC+MDTnCVL/L KlTZHpmSD9jQNburSpysQo2lBHMygwCh36lLYEjGcxdkx3O7pdKb0Ams4G30MFmWfARdYnnF/fq aemKgjnpfQTSIHaXOLz/N2v/GqbPEqjobB9twjWHiQnf9DlDS6iDv/b9m86FjLenLUmduIRO1n5 g2oi64WEIRNCLHJsIP8ZIOjLewYO4TJk7irijk375lIlJD4HDu990on+tRnSuzQmKrRzaxIUpdH ue3a7nNtcXAaCkVrPQc88TXX3wJbTKn2xP/nG0CmLPUore3FAgez39g4ijHDYvCRfFukmTcQeln 9LvCK+hvfgWdy4kTcJ+IbgCHUo38= X-Received: by 2002:a17:903:3503:b0:2dd:c053:e0f3 with SMTP id d9443c01a7336-2df69ddf227mr25747705ad.34.1790181251372; Wed, 23 Sep 2026 09:34:11 -0700 (PDT) X-Received: by 2002:a17:903:3503:b0:2dd:c053:e0f3 with SMTP id d9443c01a7336-2df69ddf227mr25747375ad.34.1790181250803; Wed, 23 Sep 2026 09:34:10 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2df6a5a6d35sm13994895ad.19.2026.09.23.09.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 09:34:10 -0700 (PDT) From: Ajay Kumar Nandam Date: Wed, 23 Sep 2026 22:03:40 +0530 Subject: [PATCH v6 3/4] ASoC: dt-bindings: 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: <20260923-vmid-v4-v6-3-3d61a0319b1c@oss.qualcomm.com> References: <20260923-vmid-v4-v6-0-3d61a0319b1c@oss.qualcomm.com> In-Reply-To: <20260923-vmid-v4-v6-0-3d61a0319b1c@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-Details-Enc: AW1haW4tMjYwOTIzMDA2NiBTYWx0ZWRfXx8Z/+2/nmEQV myaQk3+SqrxyC0ydexOulRxyFMKSg9tzuUjjWAEX1FYy3Mh1WeOH+0MmKkI9U54B4KNaqwMedbc iHGi/bdPxDci4ey1wnxS3Hw/GF32kg9cWoBoAhG/6FTI6t93/Tu3ssbdVDlUFWwg0zoDuQI6yYa nmU0PkmtLEmMa/1g6XQUmgg2F33iGPLq+72wcL9X2f3EVkqD63Hxbw00KDYPF09Q5JLHzanKTTt KrkEctfOOZjhetX0dndFeB9oTHpSJQ7BVJF5Oesx4Pk/eQv7HADUmMq5MA9YqLS+Op20kBsJF4o RF9oZLnO2z5uhvu1sihEelzL0HxX6svEhLF3LGKMPydnSFdlQctrPM1jKFgrbYwv56K+QRw63uH 0IfKs2h81wLo02UQfShgbKxa8asiYqerO3og98hNOvLd4HPRWLzZxFWGV+w6BJo8kBIK0RMynKx +YmSilKNb0AzTALUgCA== X-Authority-Analysis: v=2.4 cv=HfuB3SE8 c=1 sm=1 tr=0 ts=6ab3ff84 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=d-o4ErlZh7ezHBmBfcwA:9 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-GUID: AEriVi1jrM8uqegSQnW7rPfYeMCbWi71 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTIzMDA2NiBTYWx0ZWRfX1Fq3pPxNmIKq mGMw433a6fgyZ4XmUegV9YAIOwM8W7gaw5UtU2vF9tlXsKfm1dni4ET3iiBVQiPE/0pgwxSGsfW okU2JcIkO2wU6cocEtVRHmgVbY6ifvw= X-Proofpoint-ORIG-GUID: AEriVi1jrM8uqegSQnW7rPfYeMCbWi71 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-23_06,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 suspectscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 adultscore=0 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609230066 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 a memory-region property (1-2 entries) for the control-path and data-path carveouts, and require q6apm-dais nodes to describe exactly one access path: iommus for SMMU-backed systems or memory-region for mDSP systems. Remove iommus from the common required list since mDSP platforms have neither IOMMU nor VMID DT properties. Signed-off-by: Ajay Kumar Nandam --- .../devicetree/bindings/sound/qcom,q6apm-dai.yaml | 17 +++++++++++++= +++- 1 file changed, 16 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..c1f9fc9eab64 100644 --- a/Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml @@ -20,9 +20,24 @@ properties: minItems: 1 maxItems: 2 =20 + memory-region: + minItems: 1 + 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 + +oneOf: + - required: + - iommus + - required: + - memory-region =20 additionalProperties: false =20 --=20 2.34.1 From nobody Thu Sep 24 13:41:54 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 A6EA44446FC for ; Wed, 23 Sep 2026 16:34:22 +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=1790181274; cv=none; b=bDuPaOFSYoMep69LxPDA2xTk0KqC84RB82IYDxXfYiw8UuG3JwAJxc1WnsFv0CDhRkPPcKYlPHuDD87cVm4AhF96Uj6eaEQuwHvGDi4v3vcnY8sx0tnR3/HYcb/GwtiTNkXITgVNakHAC3jXVecr78sgJiVDOi4NpLeknBB7ae4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790181274; c=relaxed/simple; bh=uDdbjW1wgPXLst03nu/80GZBOsK0nNDqK4JPVRaArJM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EVDeWVd4nVl02W/CNi9H68fAw7r9CMqjHv5D+93jXSLu80lF92OTuIitS1Fz9i30SAyteEj0OX7EpTF6xN6iDd69IfFs2GqJAJKCfRs7V5RZTVt6Ap04gnAWo038twbW/XNs3+Or/9j4f/hYfTbh9Wu06UI+K9z69ugD4ENOFW8= 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=f3MGHxkk; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=bUPmeTxC; 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="f3MGHxkk"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="bUPmeTxC" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68NGU6Nd741679 for ; Wed, 23 Sep 2026 16:34:17 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= YYgq8ukVkamqpLx6ueAcBUNKVzC7nymdRLqglEcoI60=; b=f3MGHxkkOZiSxEE0 qW4tPOMzJpfuDv+NvVTeQiDxGYSiBZKEmINRNOnh3BqeOqwMcxTeiiweXT6qlvlA dSGIilQ4WGuS7GJrr2ZKvtZjN7aqIfRqeGlNbZKD/5wPRJKL+JwzJYMSdgWlOPFh bvA/RYjFmShaY/3PKJlLX/mLqkQZqWSeQAJMym3BYVhglzc6xJbLBsumdu0fohPD 6bWVbLxvQnqEOMEhuEkBLXcAm6I4Vn0HnzOPt7/5jJRgjaOy1Pt008/r9Zfncqm/ 3y4xJaL3hZnVt/7d6Bc5Me+gLcQwzQcZBtEeJ0faMSbLnGWUy/kXbRK6uJyDe1m8 OP6d4w== 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 4gvfjsgwxj-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 23 Sep 2026 16:34:17 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2d6df0a1e18so10366065ad.1 for ; Wed, 23 Sep 2026 09:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790181257; x=1790786057; 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=YYgq8ukVkamqpLx6ueAcBUNKVzC7nymdRLqglEcoI60=; b=bUPmeTxCbKOKNsSoNZF+XRTjD8jK79crsfkHxG7AKM1goOSlGj6921vlFJEN4Q0Evp pODA3DdFvPPDGt9whNZWrdBGn+UBHbNcsG7FAOjoS+V16a/q4+4+2UIqG9kR4HymKY+j gQ8Ky0hUIzMsGIKSTpZymLdvpmZMsif3NIJLkBlcNAZHHsBOd4/DL+s5F3Log9vDt2FS tNpbN272rRSRN7B+g7Je9resNM1I/F8HHpyc5syz3h0wztgD5YoBR7ExytYKeaDpV+jA ccFrWUEihrtYu3EKvnajRyE62qmTeC+WsRjl0DAhxhfqmpzuC2bTdaNAkZnn6em+q/jL W/1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790181257; x=1790786057; 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=YYgq8ukVkamqpLx6ueAcBUNKVzC7nymdRLqglEcoI60=; b=0GoBjeu4nyLZtYy3Q9x4KWLBBu97AaCb1Y52Xxnw7OLHMY4yL+cJU7sriKJtk0gKxW HA3B3h866nyL1u00SLy5h/vfKN78k4TnQO702LuZmj0cW2y8ygimo9RLGwRE1VjxH6a0 3arQWcb1pcXCdX8NnU8vqdhCQe/AjGAUv0KRm6PgD1kru5OPV1oSKdZt2fb21Kld4Pca yTD5plZTiheLZiWXZcJtZkD6VPDhC1JRd2UrOOAKwA4n5ov7qEYI+KeQDtR2HXqNTMr7 0F3RJXh6ZQJgkrlIzC6XL5GhvxskgSKgVVSZ5eqXTyCCx9aXb3n9QIAaobR2J/7+n9v6 78jg== X-Forwarded-Encrypted: i=1; AKwUvByUy+WtfyjrU6JzPaaWaAv9YMPIM8NGXRrctzlLzxFpSbVuZjIU3rsZntKQaqHjipTHBYCK2/cJixjhL5I=@vger.kernel.org X-Gm-Message-State: AFuF++kkvTlxr+S/GCpDzE+bQxb74KZEof1izCDR1UTGU3iu94GPRGrG sJHo6wsa9YQhfi2ZuQnO1lgr7KL6+Wtd2m4QQH3p8EuV45KPNuq34vrzFa7XuF3+QUI64bBvpBJ vEksg2aBNe0We9Xdq6S3VwbV8FsWimT5fOo5sXCrrSnd+z2uh8JiBtd/QFDRlRwa5MF0= X-Gm-Gg: AYBFou19xVOmDY+9VqPUnN7IcasgosQn/Q+VHawFVhTnvvjLGzrIb0o5Ncj7t/4+1ag uTuYnDYlRxHi65KHVbFfGz02p39secOwD9n05xoAiGHwbgkDDNYsJhUDXDhSwNvOAEOTQuJH3rX QQIQM/OuTaHqHuX41AYZn1YWz7I42uviud2fw5PDj7YXaVvjjGTgkO09ZlW+vemZJZlTiptWUHt hyhglSnULr1NhBnepyx3MkmVnoCKxrZerp/zzj+X8+8IvaAA0OISSdbfRDONZyZnp+VYicyJbnQ 1W1MschB4lTWXSePVZhvcDCF6AlqvK3mUjzEBaHRmXTKodyuWs85zY7u2wxFAkkwGkqT6ebwB8s srhsfwUIEkqboQTlTNJTZ6vtZrk8= X-Received: by 2002:a17:902:e886:b0:2de:834b:b59e with SMTP id d9443c01a7336-2df69e097e6mr27291485ad.71.1790181256429; Wed, 23 Sep 2026 09:34:16 -0700 (PDT) X-Received: by 2002:a17:902:e886:b0:2de:834b:b59e with SMTP id d9443c01a7336-2df69e097e6mr27291085ad.71.1790181255789; Wed, 23 Sep 2026 09:34:15 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2df6a5a6d35sm13994895ad.19.2026.09.23.09.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 09:34:15 -0700 (PDT) From: Ajay Kumar Nandam Date: Wed, 23 Sep 2026 22:03:41 +0530 Subject: [PATCH v6 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: <20260923-vmid-v4-v6-4-3d61a0319b1c@oss.qualcomm.com> References: <20260923-vmid-v4-v6-0-3d61a0319b1c@oss.qualcomm.com> In-Reply-To: <20260923-vmid-v4-v6-0-3d61a0319b1c@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-Spam-Details-Enc: AW1haW4tMjYwOTIzMDA2NSBTYWx0ZWRfXzjucx9wzGGPD pNE4iq52+fTYWjDEjYvARZmzse6Cx+8Q2QrslYKdlUbB/EtX4jHbLHBfwTCXi5NG91Ut4ttRkA/ RuLWHJ7Qdjb01b3fbKv+iY37JdJlkiDhzSGfmYhhpr4aOb1a7TdiS5o2Brqe/vJWiuEnN6MVAJF naYgLxgIp6Xh3SN4cn3RtrKXB5OvNg0aT1YDuGeWvrl39SecvZAfMc+2FUP5/ix9X3BwmRhiyBc nBZIIAJ4tZmfj/JyU+pTz62tMJ+DXIU7ywCucaDl3cP1v7UGt6vRyXZhOgbCmi0HSXP6v/LdaLX Z1oFHNQsPoswp7ri1T761Ldot2ZRsnT7UAlnASPjldMpZZ+874MT5X/s1oEIJ3bvnHC2UWAprsK 0XsohqZM3uiLRxk3+aDzVSU/UuY4BZOTso2fZIlegBtUZfxVi7xprGFc1/Tnx5O8cfss+s4hOMB o4QazeSFNIH39wJkdRQ== X-Proofpoint-GUID: WvIhaKKXmyPgW3UXarW9jG7hNuadB9nF X-Proofpoint-ORIG-GUID: WvIhaKKXmyPgW3UXarW9jG7hNuadB9nF X-Authority-Analysis: v=2.4 cv=K4+3jCWI c=1 sm=1 tr=0 ts=6ab3ff89 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=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=KIwk5gsWPQ7PVTwXBQkA:9 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTIzMDA2NSBTYWx0ZWRfX2zdSHdj3I3qX qXfR2kRl89d9XNQz4gtyJ6tctxj4rGEzUb/9t/A0674LrX/gY7RxKbiuuKivWXiixYyI5gVtMIB onM1xZQ0PritwCd8SO7tzfVjj3w0h2E= 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-23_06,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 suspectscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609230065 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 | 317 +++++++++++++++++++++++++++++++++++= +--- 2 files changed, 297 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 033197bdd870..b0b10ba51c99 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -1,20 +1,25 @@ // 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 #include "q6apm.h" =20 #define DRV_NAME "q6apm-dai" @@ -36,6 +41,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 +99,103 @@ 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 mutex scm_lock; /* protects scm_regions and num_scm_regions */ + 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; + + mutex_lock(&pdata->scm_lock); + + if (pdata->num_scm_regions >=3D Q6APM_MAX_SCM_REGIONS) { + mutex_unlock(&pdata->scm_lock); + return -ENOSPC; + } + + ret =3D qcom_scm_assign_mem(addr, size, &src, dst, ARRAY_SIZE(dst)); + if (ret) { + mutex_unlock(&pdata->scm_lock); + 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; + + mutex_unlock(&pdata->scm_lock); + + 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; + + mutex_lock(&pdata->scm_lock); + + 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); + mutex_unlock(&pdata->scm_lock); + return; + } + + pdata->scm_regions[i].assigned =3D false; + pdata->num_scm_regions--; + pdata->scm_regions[i] =3D pdata->scm_regions[pdata->num_scm_regions]; + mutex_unlock(&pdata->scm_lock); + return; + } + + mutex_unlock(&pdata->scm_lock); +} + +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 +518,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 +543,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 +650,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 +660,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 +691,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 +724,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 +771,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 +830,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 +858,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 +1184,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 +1193,123 @@ static int q6apm_dai_probe(struct platform_device = *pdev) if (!pdata) return -ENOMEM; =20 + pdata->dev =3D dev; + mutex_init(&pdata->scm_lock); + 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: %pa bytes\n", + &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