From nobody Mon Sep 28 05:45:35 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 D0AC4349CD6 for ; Tue, 25 Aug 2026 18:40:44 +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=1787683246; cv=none; b=hBL060ai2tE5FRt3JfFkfGhBYpw1DZ8lo5F68WXwYHksxDb8UFcfb0oOEk16h5CNn5dLGT7XijWzhyI99IN0rDGOdapU1lmdb1io/krYNwjimTSSaX0eVc/Mlhr3PhALS2zRAAXJS6JahiUkeEDp/dQmpDRMvoTYnKSFdbeZO5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787683246; c=relaxed/simple; bh=VpLeI1weNXJ08CxiM0YnVaXdUGET0/3JYvolTB/ZhUc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mNje3YK5lfnEoJ788g8EgbsX7ba5Q+K4+3mUQYZWvuPK/fbTQMLemIPaZXE1IPulRDbc7oJjyTFGgkZ6tszJr0gxaFAjhGug/51XloOJB2XWutgSng30vF4EHxq7bjk8YzGVwRzX2S9IjCl68LnCcJLJn3Y2DMel+4Znajo6Pao= 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=phC+XQzS; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=MHV18eAe; 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="phC+XQzS"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="MHV18eAe" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67PHdSCS1573024 for ; Tue, 25 Aug 2026 18:40:44 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= 1BMacg1lqDbZQnAIg1w4xJBMDzMgeAPUHcKeTyyZMqU=; b=phC+XQzSRufiFNX5 dB6OaknIe/kBPCkutk1Eoosyoq4769J7pwJj8GWQXuLZn+rtcX1fBaNuXICyfwb1 OTFOUOMui63ZijSg5IWYsrdzukITA4veGZT+hXEj5v2Y0ebmQ3I5hwg7TiJDNGyB z+alAFHkblpS5qEI+pZII1kG47F9tVG6lDPqcg/srWxyJ6NT0revKmPnLP0w8ic6 uJzcvIuwzxUo28D8zw4QsSROyFW6BGbhzVgkdIGCyGnssZJW6V2IJ9yEKBteWF9W xTXy+tTn42S9hdO5gQ8lK5mkZ+MBlFxUC20HqHU9vR8Gh/skpHyRXwSBibx2D6uQ 8BdyMQ== 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 4g9fgr89e2-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 25 Aug 2026 18:40:43 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2cfc52ddc55so2046975ad.3 for ; Tue, 25 Aug 2026 11:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787683243; x=1788288043; 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=1BMacg1lqDbZQnAIg1w4xJBMDzMgeAPUHcKeTyyZMqU=; b=MHV18eAeabV/YueXllzYawqgKWovJ8aSyJ4oxr0W68lUwqwCZXk2jPn7e35BrazJZe DDHT7XusqxfVwxMXPlVP+wzL8LBDcEOGfL2hjD590XMM+15xHIMNwJqHhk2FRPcrmHRe qBGEAPs2xw3/ZRZtr1qQpkJbMZnK3zqrRWboPA0+5Bb2/2qDZCug5R+KDTVCMdIyT7ZT sz5wG6BBZzFMDLIMqKhjIdYyjPLctrn58p0PBkmF47W2dCaFiGqSD7F3QfO61pEvci/1 PGkw/n14ipvBzLe40QoyZe3QhvvvNq8i8gc8P1tzBH4dktazAgdadwWqaJjTdZAq4lv2 cTow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787683243; x=1788288043; 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=1BMacg1lqDbZQnAIg1w4xJBMDzMgeAPUHcKeTyyZMqU=; b=PJFwyzMt9z9NuQlekyin0v0D6kGbSA4AdpTOf/OpAWiN7pex0rlZgEdMkpes6DAxT+ QUNvvL3fg5ZblWbvSqdI3REGRZOq5W/1uPvfWpjSZoRWZOZgJbxk5yJobNYZnWqcje/1 owXAF3AZRa+U5XURrE4bXNbPAjNjct85Hj5h5/zEHN0DZqcdIdt1VAuoDEPu6+moeoAy FlGMYnZTsrc8jZvklrDeNxxxgEmke1vbFZBnucIj7su8cx9gNklndWQ6YXwUffSPNiKs 5c4MYXlpaXfrC4DiucT+wltEz/7OFFFGlvBJGl7gHXcMXHfBuwVfKLEC6c1WWSXuWdOc jT5Q== X-Forwarded-Encrypted: i=1; AHgh+RrNTddCvAMidhqAy0JE+NFShiktv0sQeHg/T0tIezm7CfUa+vmrwHH6ZP7LTAzTHPZtHFrG57umJpabOns=@vger.kernel.org X-Gm-Message-State: AFuF++kvEJH1eNxOAYUjn/xgGyLGpoFsEVKQTGaOTbVbkokCskZPcSL3 3QzW3G81r7oHrzMrE+wgAwxUX2q5neEWpWL48q+I0d2N+9Zika/ENxGNMPiwNqrdEpV2xqe/iGA gGaymjIWhWkJPKwSnRqs2n1k4hCwVL3ha7/6oO0qiLmLeoJocMTUTxx7DtQzGQPw0hjM= X-Gm-Gg: AR+sD114AjiZiSfG/0GFoweYx7HbW2hLg1MdbmukE+U1b4zxqyln7+0CFijf4SMuFLE vCfkcaJnuTsOSwyBD985nLck5ZNZFvXNAaDxvlTCzCNsrXLilfNludbWHjCOQ01cgKw+LTHvzLZ dU520+fRtrBWLMoztcHi98zJygBKIx4gsTmqX/C80MKtMurFPKUB2j+pk83I/3AnnK4aPxdE/IZ hbLNolB4nYmTO8FlAW9aT1BS0tZ4Ey6nHMsKij4hABTVe84OtcMgsWEqMorovYYK+nv9z6H/SvN kWnvfIV2k0DWMZLXrJBXmhilcrt8z4sYA9y/ujkIrudp2Z6ZNIq7QtfYKNdZvkKyt1SHljbDn+c uZb11iS+CvD7rIZYZ3NTtSnVDF6PC X-Received: by 2002:a17:902:d54e:b0:2c0:b6c7:227e with SMTP id d9443c01a7336-2d707aa4b9dmr6005305ad.5.1787683241624; Tue, 25 Aug 2026 11:40:41 -0700 (PDT) X-Received: by 2002:a17:902:d54e:b0:2c0:b6c7:227e with SMTP id d9443c01a7336-2d707aa4b9dmr6003815ad.5.1787683240972; Tue, 25 Aug 2026 11:40:40 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3283fa89e8fsm256117eec.8.2026.08.25.11.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 11:40:40 -0700 (PDT) From: Ajay Kumar Nandam Date: Wed, 26 Aug 2026 00:10:12 +0530 Subject: [PATCH v2 1/3] dt-bindings: sound: qcom,q6apm-dai: add stage-2 (SCM/VMID) access model 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: <20260826-a2a-shikra-vmid-v5-v2-1-c3dc62354eee@oss.qualcomm.com> References: <20260826-a2a-shikra-vmid-v5-v2-0-c3dc62354eee@oss.qualcomm.com> In-Reply-To: <20260826-a2a-shikra-vmid-v5-v2-0-c3dc62354eee@oss.qualcomm.com> To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Ajay Kumar Nandam X-Mailer: b4 0.15.0 X-Proofpoint-GUID: xrMYMIhjEu7j1m-_Rho9BbVa4I5jzu6h X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI1MDE1OCBTYWx0ZWRfX22+v9cy0YYYO ICOptChvrTt1qS4NuPsWtQUZA6qw0TCdqaC6BOm7/RczCXiKlhaNwbHyFbS4K3FMwCRvjSh8QlD bpU3f6dDSmEJzK59gYCohroza2QB7Pgmnmb52OOQxfzvZuh0sCJU+3nwkZIMgD53SZecI0bk4cY cvVk8R9ditMGLsIxTOvJjsT/3dQXGuwvAqaFHxgz2PEhJnFd/H4kxXSoD1qi1G7s6FLGvNYqyTn wrt0zSBQ8TZjbpSU8Dq3WS4F4WSUpVqcLQezkCHZd2BlPQ0Jf15vTZS3NxLz51Ac1SSftmmx+hX DmDtLbrXCqrKiZZOurYINf1OUj/i7F5Zj7XtYybdlm3w1aYMWujm4ZdiUKsO8qfdRpK877SgSJA QVD3/Dq53HKBMQsX93DCunUzMamIop0e0W8nj6ui1ukYAYntvWYUfChYB7fvzGM2WSIJri19Tqz oU3ysoYhbAqSLDFgwtg== X-Authority-Analysis: v=2.4 cv=d8LFDxjE c=1 sm=1 tr=0 ts=6a8de1ab cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=KKAkSRfTAAAA:8 a=v26nnA4qrlwCZKXH8T8A:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: xrMYMIhjEu7j1m-_Rho9BbVa4I5jzu6h X-Proofpoint-Spam-Info: AW1haW4tMjYwODI1MDE1OCBTYWx0ZWRfXyh5pT0PaIrFS dx1B8VfXT5RjGZkLHC4HS88Xq714tBuuvpurfvrETm4vigEu/7jeCQbQfvONnDlG3y7ne0Mqg0T eu0pVmSMEDmtLF587lNT+a5uPKYgW9M= 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-08-25_05,2026-08-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 adultscore=0 spamscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608250158 The APM DAIs expose PCM buffers that the backing DSP must be able to reach. On existing targets the DSP runs in a stage-1 context and the buffers are described to the SMMU via the iommus property. On platforms such as Qualcomm Shikra, where audio is served by the modem DSP (mDSP) rather than the ADSP, the DSP runs in a stage-2 protected context and cannot use the SMMU. The buffers are reachable only after hypervisor (SCM) memory assignment to the fixed set of consumer Virtual Machine IDs (VMIDs) that own that protected context. Describe those consumers with a new qcom,vmids property. The two access models are mutually exclusive: a node carries either iommus (stage-1/SMMU) or qcom,vmids (stage-2/SCM), expressed with a oneOf constraint. iommus is therefore no longer unconditionally required. SCM assignment replaces the buffer's current owners with the supplied destination set, so the driver always adds HLOS to that set itself to retain host access; HLOS must not be listed in qcom,vmids. When qcom,vmids is present the PCM buffers must reside in reserved-memory carveouts that are SCM-assigned to the consumer VMIDs. Add an optional memory-region property listing those carveouts. The first entry is the control-path buffer and subsequent entries are data-path buffers. memory-region is only meaningful alongside qcom,vmids, enforced via dependentRequired. Signed-off-by: Ajay Kumar Nandam --- .../devicetree/bindings/sound/qcom,q6apm-dai.yaml | 72 ++++++++++++++++++= +++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml b/= Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml index 9e5b30d9c6e6..d9a6bc4a14f2 100644 --- a/Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml @@ -10,7 +10,15 @@ maintainers: - Srinivas Kandagatla =20 description: | - This binding describes the Qualcomm APM DAIs in DSP + This binding describes the Qualcomm APM DAIs in DSP. + + The DSP that runs the APM must be able to reach the PCM buffers. On + existing targets the DSP runs in a stage-1 context and the buffers are + described to the SMMU via iommus. On targets whose APM DSP runs in a + stage-2 protected context that cannot use the SMMU, the buffers are + reachable only after hypervisor (SCM) memory assignment to the fixed + set of consumer VMIDs that own that protected context, described by + qcom,vmids. The two access models are mutually exclusive. =20 properties: compatible: @@ -20,9 +28,42 @@ properties: minItems: 1 maxItems: 2 =20 + memory-region: + description: + Reserved-memory carveouts (shared-dma-pool, no-map) that hold the + PCM buffers and must be SCM-assigned to the VMIDs in qcom,vmids. + The first entry is the control-path buffer; the second entry is + the data-path buffer. Only used together with qcom,vmids. + minItems: 1 + maxItems: 2 + + qcom,vmids: + description: + Virtual Machine IDs (VMIDs) of the processors that consume the PCM + buffers and therefore must be granted access through SCM memory + assignment. Required on targets whose APM DSP runs in a stage-2 + protected context and cannot use the SMMU; mutually exclusive with + iommus. SCM assignment replaces the buffer's current owners with the + supplied set, so the driver always adds HLOS to the destination list + itself to retain host access; HLOS must not be listed here. All + listed VMIDs and HLOS receive read-write access. + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 2 + uniqueItems: true + required: - compatible - - iommus + +oneOf: + - required: + - iommus + - required: + - qcom,vmids + +dependentRequired: + memory-region: + - qcom,vmids =20 additionalProperties: false =20 @@ -32,3 +73,30 @@ examples: compatible =3D "qcom,q6apm-dais"; iommus =3D <&apps_smmu 0x1801 0x0>; }; + - | + #include + + reserved-memory { + #address-cells =3D <2>; + #size-cells =3D <2>; + ranges; + + audio_heap_mem: audio-heap@a1000000 { + compatible =3D "shared-dma-pool"; + reg =3D <0x0 0xa1000000 0x0 0x100000>; + no-map; + }; + + audio_mdsp_carveout_mem: audio-carveout@a1100000 { + compatible =3D "shared-dma-pool"; + reg =3D <0x0 0xa1100000 0x0 0x400000>; + no-map; + }; + }; + + dais { + compatible =3D "qcom,q6apm-dais"; + /* index 0: control path, index 1: data path */ + memory-region =3D <&audio_heap_mem>, <&audio_mdsp_carveout_mem>; + qcom,vmids =3D ; + }; --=20 2.34.1 From nobody Mon Sep 28 05:45:35 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 D8E0137E5D4 for ; Tue, 25 Aug 2026 18:40:47 +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=1787683250; cv=none; b=KkTT22sObUlynbPmgrZ1z7/S3IJWUlW53ZWpHKBPwdcsvHK5jWQpBDxYbszBfTngAnmKnGSIG3aIAKmpP+N22Bho7WNdlijGZ5v1Ca5YGVXvLFsxNJVzK1zFFrY5f4RkbEy77SkSqWBECYwXsqKbesCiGFrm6BpoHO0cXuc0Gu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787683250; c=relaxed/simple; bh=tBc/t2nMMd82eh3YXYtokj4gYtOHLgcMo2pRVZ++1aY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gaSiCX1GEFPM2LPccvMyoCrTLuwoKP3L6C/ALL1x0/FeR/tMRI/FL2ohpYTCERV/5JGOYPvXfYtbnuaXWGeMyjt4YaAk2aVcUJ6QEYmcS5MYcb/+Oa+2jlsKgNHAvT0GJeLlv5MlXSi71PjnT1o8x4usyOc+yZxDRgF7qCjzXhs= 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=Mibpidea; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=hC7Rshuo; 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="Mibpidea"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="hC7Rshuo" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67PHdFFf2048975 for ; Tue, 25 Aug 2026 18:40:47 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= xW9JJ31PzHxg4v0ggm/lgGaOQctNgyTdJoAgpJubpzM=; b=Mibpidearz8mBsIp k2EYd91pHNs8RdX79rIkdsdBIDa4ld+RE9f7bH1BqGSjwk4q/zw7e7hT3FrNj/MR PQT3msAb0FH9y3Rh2fvk4Xch8W5C+VHyyoyfpr710B+65YbMxqFKHsY80RZws36R MseMWX7+wBPngqA7Zlnpx20SI3yjBZBu849ZV7+FenWpTJ8sEbKs399FALAOHUcQ 0B/3eXp/wost9iMr3D5F82fan2C1UdplN+9IWfFOk2R1qGq9ebzAPGELhPlC2tP2 oMGLJKEULEJ7qsDjF+K5MFQcJpHp7bmKm9ChU9pdhQzzT+7N2vfvIpKn9NBBkjkU e729bA== Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g9fjn095b-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 25 Aug 2026 18:40:47 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cc1b8088202so42367a12.3 for ; Tue, 25 Aug 2026 11:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787683246; x=1788288046; 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=xW9JJ31PzHxg4v0ggm/lgGaOQctNgyTdJoAgpJubpzM=; b=hC7RshuoFpo6zKO7fxV7igtJDEzwd4Q7m4KyJ29i6NI4n8Ah6sg8S5vEmxd5/O5ONx Xg2caJ5GuPNBhAs5qaQ8lCLnWvZ7L6TvmYyKA0bNIXXTgVB10fog+FkG17LgP3az2vqS KOjNwrsLeXXoXFvFMDymi0I7NoqVhl09hkqUeOAAq7rlrSLsVyiviU+muDBojNAqrXHZ /vh4ZIRlrtiQP8+F7leRGWhM47SkG3BYc5IzeDsqq8ZKxY7ee0yMI6EG8Fywqa088tuM NujMsq7yFOkcGtMs1IavlYQoV8LX2J3T/yuUky9MrxFtv+9p2Tgt+c2gTbsiJEmHgkjG prNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787683246; x=1788288046; 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=xW9JJ31PzHxg4v0ggm/lgGaOQctNgyTdJoAgpJubpzM=; b=ZFDV0bk1lkKuz0VjjHnBS7Z11qBKgttMzmFX/FTF0dAi7qtWo0Myb1K2BKnYMScVzq LghSqJQ9H6qIUSN+pQ3W2s+45II0dNQq8f0y04z/aDoQoZYJFEV9fbTexQnDMLHBZydC kO9gNHJSqAk/HVLvIHyziU3ZJTj64cH6oSat+OnZ4BW5DnVIYrqanx6ALcimDqYL70DU o9vGdbdEmtWlA0a7Hcb4i6cAjqmgTGBYk4SDt3lHga8tUembRpoY9cGyzgtGncsk+kyo qppouBilQbJL08XuRIjG4Dbk+AeMnG/NlVByTbmIvXq+U4AbAMSkIR8y/CMoKh+XPbID hP3A== X-Forwarded-Encrypted: i=1; AHgh+RqiFCV4POeykdC8otcu77gsqGhufb/LAthsSA0NvHJQBBQehL3574oMUXCnbzrFvGldwkULW5sGx/I3vY0=@vger.kernel.org X-Gm-Message-State: AFuF++mmmG6RUijAQO1rj4TrhYEo14QYKxIoBz7MOy3q3U0DnhdLIk25 OQVc27fUCjmUfAsf6lAZ515JIOcgsD2I1FXTypwlIdVDKJA28IEWWSq/UhfinBlIQXkdNzRH0jm dJYu84cN0UHFIExZ/BIdPK78Rxa5BiBBoDQ7fTiRJl9GaMVkiocwvvMoN1eD5MqYqcTU= X-Gm-Gg: AR+sD10j7OLQj+5E8XzHChrCMajh8uX++BM61kpZ4aTCnfU8/D+fRR3vUGDRT3lRmxN zIDgxJlVEur1EeuIMEurfyEGVFMFlcMdkppHSvuNSpN+ZZ+PWdIi8o/ZD9SBbQyufQYQvoBYuot KytNjOyFwNbf3d3d/g+HHvO2TX4Jph0vzqusEnN6PvZ65KZLm6DVZO7SM9DrtsaRqlOvfj+LJt4 OT7LOfuHWIr1+S0xAFsaerNnma8/yvZ3vSOjrijVQTyCcFGxLJ5cUnSSQ/YIy7v3fcbpUaZPc2i G0ZnSb8jtwwpqWcKzvybSvsoiMWU/DnzlM0IIWmer3HZIF/Ypsz9SabP5r6RpF50pge1fn1hWCS KvAMEkwb+lreufNmPizhySJek1+Lp X-Received: by 2002:a05:6a20:a106:b0:3cd:1037:36d6 with SMTP id adf61e73a8af0-3cf6653a531mr1091382637.0.1787683246180; Tue, 25 Aug 2026 11:40:46 -0700 (PDT) X-Received: by 2002:a05:6a20:a106:b0:3cd:1037:36d6 with SMTP id adf61e73a8af0-3cf6653a531mr1091293637.0.1787683245623; Tue, 25 Aug 2026 11:40:45 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3283fa89e8fsm256117eec.8.2026.08.25.11.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 11:40:45 -0700 (PDT) From: Ajay Kumar Nandam Date: Wed, 26 Aug 2026 00:10:13 +0530 Subject: [PATCH v2 2/3] ASoC: qcom: q6apm-dai: add VMID-based SCM assignment for mDSP buffers 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: <20260826-a2a-shikra-vmid-v5-v2-2-c3dc62354eee@oss.qualcomm.com> References: <20260826-a2a-shikra-vmid-v5-v2-0-c3dc62354eee@oss.qualcomm.com> In-Reply-To: <20260826-a2a-shikra-vmid-v5-v2-0-c3dc62354eee@oss.qualcomm.com> To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mohit Sharma , Ajay Kumar Nandam X-Mailer: b4 0.15.0 X-Proofpoint-GUID: mvTfTUznasKuICh7THMzA9AlO4N2gKLq X-Proofpoint-Spam-Info: AW1haW4tMjYwODI1MDE1OCBTYWx0ZWRfXyNSmFeZgCBK6 amOwT3Ahr8JUajYsz/nJ70z+T0FpfQAOxoFuNXSuCP996xgm6pfbuu2dc6w6J4/QSDOS2y1VP+k vXKDqaGzO/0rZdvpbxcvkW3xX29puAQ= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI1MDE1OCBTYWx0ZWRfX0MMVv9h+XZgg IntHL3EchSN+GN2n8dQrmItO7fTXnuhJt2g2rl7P+2WvtBsuP+Cb4ESAT4taHCP1DMRX4g05HJt xnMpd+yYHOELGPx2xkyZNSVfoAlD0cS4jU3/B488v7WEhSWrAghpBt7YvxiYe5TAjFROaD1aRdv lSnnHFy96cH2zmICHHcqYAcy+5/MUW4azGwf3JSy/4tTAuQIyT6DFUpPHA1HlEDMsYvOJKKY4fo jQKKQXjWqctwKCvrVhfhkPcdDb9ScAxNzk/GU+IXFxfYNskrs27kRpasOss1Ddbg7Mv+DSOJzDT jBRNltFIpO9YFjdf0mdnnQYjLc7nX90yrumpanQgJIDfIExSJmDpUzoC4i1vQ+UWFRKtBiduYae OACC7e+IiDbrWLtEbhlUP/j6uEG97yOT314RUae+gZjUsM5PZpdBJfJbOGSf4Y9V/G+XBH+wOwa 4Ahq+LlBvZq3ksJlrtQ== X-Authority-Analysis: v=2.4 cv=ccziaHDM c=1 sm=1 tr=0 ts=6a8de1af cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=EVZQnPdvptyBUfj2O9sA:9 a=QEXdDO2ut3YA:10 a=bFCP_H2QrGi7Okbo017w:22 X-Proofpoint-ORIG-GUID: mvTfTUznasKuICh7THMzA9AlO4N2gKLq 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-08-25_05,2026-08-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 clxscore=1015 malwarescore=0 bulkscore=0 adultscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608250158 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. Parse the qcom,vmids DT property and, when present, SCM-assign all memory regions to HLOS (retained as source owner, RW) plus the listed consumer VMIDs (all RW). The two access models are mutually exclusive: a node uses the SMMU path (iommus) or the SCM path (qcom,vmids), never both. Memory assignment follows the upstream pattern used by rmtfs_mem and qcom_q6v5_pas: reserved-memory carveouts are SCM-assigned once at probe() time and restored to HLOS-only ownership via devm_add_action_or_reset() at device removal. For the non-reserved-mem path (qcom,vmids without memory-region), the fixed DMA buffer is assigned at pcm_new() time since its address is only known after allocation. When memory-region is present (has_reserved_mem), the data-path carveout is attached as a DMA pool via of_reserved_mem_device_init_by_idx() and PCM buffers allocate directly from the carveout instead of system RAM. Buffer constraints are capped at reserved_buf_size and snd_pcm_set_managed_buffer_all() replaces snd_pcm_set_fixed_buffer_all(). All new code paths are gated on use_scm_assign (false when qcom,vmids is absent), 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 | 373 +++++++++++++++++++++++++++++++++++= +--- 2 files changed, 351 insertions(+), 23 deletions(-) diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index e6e24f3b9922..82f496e53acb 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -101,6 +101,7 @@ config SND_SOC_QDSP6_ASM_DAI =20 config SND_SOC_QDSP6_APM_DAI tristate + select QCOM_SCM select SND_SOC_COMPRESS =20 config SND_SOC_QDSP6_APM_LPASS_DAI diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-= dai.c index bf1f872a09f4..19a5c62cc4e1 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -1,20 +1,22 @@ // 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 "q6apm.h" =20 #define DRV_NAME "q6apm-dai" @@ -34,6 +36,9 @@ #define COMPR_PLAYBACK_MAX_NUM_FRAGMENTS (16 * 4) #define COMPR_PLAYBACK_MIN_FRAGMENT_SIZE (8 * 1024) #define COMPR_PLAYBACK_MIN_NUM_FRAGMENTS (4) +#define Q6APM_MAX_VMIDS 2 +#define Q6APM_MAX_CARVEOUTS 2 +#define Q6APM_POOL_MAX_STREAMS 8 #define SID_MASK_DEFAULT 0xF =20 static const struct snd_compr_codec_caps q6apm_compr_caps =3D { @@ -57,6 +62,13 @@ enum stream_state { Q6APM_STREAM_RUNNING, }; =20 +struct q6apm_scm_region { + phys_addr_t addr; + size_t size; + u64 src_perms; + bool assigned; +}; + struct q6apm_dai_rtd { struct snd_pcm_substream *substream; struct snd_compr_stream *cstream; @@ -84,9 +96,123 @@ struct q6apm_dai_rtd { }; =20 struct q6apm_dai_data { + struct device *dev; long long sid; + int num_vmids; + u32 vmids[Q6APM_MAX_VMIDS]; + bool use_scm_assign; + bool has_reserved_mem; + size_t reserved_buf_size; + struct q6apm_scm_region carveout_regions[Q6APM_MAX_CARVEOUTS]; + int num_carveouts; }; =20 +static int q6apm_dai_scm_assign(struct q6apm_scm_region *region, + const struct q6apm_dai_data *pdata) +{ + struct qcom_scm_vmperm *dst; + int dst_count =3D 0; + int ret, i; + + if (region->assigned) + return 0; + + dst =3D kcalloc(pdata->num_vmids + 1, sizeof(*dst), GFP_KERNEL); + if (!dst) + return -ENOMEM; + + dst[dst_count].vmid =3D QCOM_SCM_VMID_HLOS; + dst[dst_count].perm =3D QCOM_SCM_PERM_RW; + dst_count++; + + for (i =3D 0; i < pdata->num_vmids; i++) { + if (WARN_ON_ONCE(pdata->vmids[i] =3D=3D QCOM_SCM_VMID_HLOS)) + continue; + dst[dst_count].vmid =3D pdata->vmids[i]; + dst[dst_count].perm =3D QCOM_SCM_PERM_RW; + dst_count++; + } + + if (dst_count =3D=3D 1) { + kfree(dst); + return 0; + } + + ret =3D qcom_scm_assign_mem(region->addr, region->size, + ®ion->src_perms, dst, dst_count); + kfree(dst); + if (!ret) + region->assigned =3D true; + + return ret; +} + +static void q6apm_dai_scm_unassign(struct q6apm_scm_region *region, + const struct q6apm_dai_data *pdata) +{ + struct qcom_scm_vmperm hlos =3D { + .vmid =3D QCOM_SCM_VMID_HLOS, + .perm =3D QCOM_SCM_PERM_RW, + }; + int ret; + + if (!region->assigned) + return; + + ret =3D qcom_scm_assign_mem(region->addr, region->size, + ®ion->src_perms, &hlos, 1); + if (ret) { + /* + * A failed reclaim leaves the buffer owned by the DSP VMIDs + * instead of HLOS: it must not be reused. Warn loudly and keep + * it marked assigned so it is never handed back to the pool. + */ + dev_err(pdata->dev, + "SCM unassign failed for %pa (size %zu): %d\n", + ®ion->addr, region->size, ret); + return; + } + + region->assigned =3D false; + region->src_perms =3D BIT_ULL(QCOM_SCM_VMID_HLOS); +} + +static void q6apm_dai_unassign_all(void *data) +{ + struct q6apm_dai_data *pdata =3D data; + int i; + + for (i =3D 0; i < pdata->num_carveouts; i++) + q6apm_dai_scm_unassign(&pdata->carveout_regions[i], pdata); +} + +/* + * Reclaim and drop the runtime carveout tracking the buffer at @addr. + * Only per-PCM buffers (allocated in pcm_new when there is no reserved + * memory pool) are removed this way, so tearing one PCM down never + * disturbs regions still owned by other live PCMs. + */ +static void q6apm_dai_scm_unassign_addr(struct q6apm_dai_data *pdata, + phys_addr_t addr) +{ + int i; + + for (i =3D 0; i < pdata->num_carveouts; i++) { + if (pdata->carveout_regions[i].addr !=3D addr) + continue; + + q6apm_dai_scm_unassign(&pdata->carveout_regions[i], pdata); + if (pdata->carveout_regions[i].assigned) + return; /* reclaim failed: keep tracking, warned already */ + + /* swap-remove the (now HLOS-owned) slot */ + pdata->num_carveouts--; + pdata->carveout_regions[i] =3D + pdata->carveout_regions[pdata->num_carveouts]; + return; + } +} + 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 +535,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 +560,18 @@ static int q6apm_dai_open(struct snd_soc_component *c= omponent, } =20 runtime->private_data =3D prtd; - runtime->dma_bytes =3D 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_sz =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_sz; + pos_buffer =3D (void *)(substream->dma_buffer.area + buf_sz); prtd->pos_buffer =3D (struct sh_mem_pull_push_mode_position_buffer *)(po= s_buffer); } =20 @@ -529,6 +659,9 @@ static int q6apm_dai_hw_params(struct snd_soc_component= *component, return 0; } =20 +static void q6apm_dai_memory_unmap(struct snd_soc_component *component, + struct snd_pcm_substream *substream); + static int q6apm_dai_memory_map(struct snd_soc_component *component, struct snd_pcm_substream *substream, int graph_id, bool is_push_pull) @@ -549,15 +682,21 @@ static int q6apm_dai_memory_map(struct snd_soc_compon= ent *component, 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, + pdata->has_reserved_mem ? + pdata->reserved_buf_size : + BUFFER_BYTES_MAX); if (ret < 0) dev_err(dev, "Audio Start: Buffer Allocation failed rc =3D %d\n", ret); =20 if (is_push_pull) { + size_t buf_sz =3D pdata->has_reserved_mem ? + pdata->reserved_buf_size : BUFFER_BYTES_MAX; + if (pdata->sid < 0) - phys =3D substream->dma_buffer.addr + BUFFER_BYTES_MAX; + phys =3D substream->dma_buffer.addr + buf_sz; else - phys =3D (substream->dma_buffer.addr + BUFFER_BYTES_MAX) | (pdata->sid = << 32); + phys =3D (substream->dma_buffer.addr + buf_sz) | (pdata->sid << 32); =20 ret =3D q6apm_map_pos_buffer(dev, graph_id, phys, POS_BUFFER_BYTES); if (ret < 0) @@ -572,6 +711,7 @@ static int q6apm_dai_memory_map(struct snd_soc_componen= t *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 =3D snd_soc_component_get_drvdata(component); struct snd_pcm *pcm =3D rtd->pcm; /* * Allocate one extra page as a workaround for a DSP bug where 32-bit @@ -583,15 +723,17 @@ static int q6apm_dai_pcm_new(struct snd_soc_component= *component, struct snd_soc bool is_push_pull; struct snd_pcm_substream *substream =3D NULL; =20 + if (!pdata) + return -EINVAL; + 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) + else if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) substream =3D pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; =20 - if (substream) { is_push_pull =3D q6apm_is_graph_in_push_pull_mode_from_id(component->dev, graph_id, @@ -599,13 +741,46 @@ static int q6apm_dai_pcm_new(struct snd_soc_component= *component, struct snd_soc if (is_push_pull) size +=3D POS_BUFFER_BYTES; =20 - ret =3D snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, component-= >dev, size); + if (pdata->has_reserved_mem) + ret =3D snd_pcm_set_managed_buffer_all(pcm, + SNDRV_DMA_TYPE_DEV, component->dev, + pdata->reserved_buf_size, + pdata->reserved_buf_size); + else + ret =3D snd_pcm_set_fixed_buffer_all(pcm, + SNDRV_DMA_TYPE_DEV, component->dev, + size); if (ret) return ret; =20 ret =3D q6apm_dai_memory_map(component, substream, graph_id, is_push_pul= l); if (ret) return ret; + + if (pdata->use_scm_assign && !pdata->has_reserved_mem) { + struct q6apm_scm_region *r; + + if (pdata->num_carveouts >=3D Q6APM_MAX_CARVEOUTS) { + dev_err(component->dev, + "too many SCM carveouts (max %d)\n", + Q6APM_MAX_CARVEOUTS); + q6apm_dai_memory_unmap(component, substream); + return -ENOSPC; + } + + r =3D &pdata->carveout_regions[pdata->num_carveouts]; + r->addr =3D substream->dma_buffer.addr; + r->size =3D ALIGN(size, PAGE_SIZE); + r->src_perms =3D BIT_ULL(QCOM_SCM_VMID_HLOS); + ret =3D q6apm_dai_scm_assign(r, pdata); + if (ret) { + dev_err(component->dev, + "SCM assign DMA buffer failed: %d\n", ret); + q6apm_dai_memory_unmap(component, substream); + return ret; + } + pdata->num_carveouts++; + } } =20 return 0; @@ -635,15 +810,29 @@ 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 =3D snd_soc_component_get_drvdata(component); struct snd_pcm_substream *substream; + int i; =20 - substream =3D pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; - if (substream) - q6apm_dai_memory_unmap(component, substream); + if (!pdata) + return; + + /* + * Reverse of pcm_new: unmap the buffer from the DSP first, then + * reclaim only this PCM's carveout(s) back to HLOS. Regions owned + * by other live PCMs, and the reserved-memory pool, are untouched. + */ + for (i =3D 0; i < SNDRV_PCM_STREAM_LAST + 1; i++) { + substream =3D pcm->streams[i].substream; + if (!substream) + continue; =20 - substream =3D pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; - if (substream) q6apm_dai_memory_unmap(component, substream); + + if (pdata->use_scm_assign && !pdata->has_reserved_mem) + q6apm_dai_scm_unassign_addr(pdata, + substream->dma_buffer.addr); + } } =20 static int q6apm_dai_compr_open(struct snd_soc_component *component, @@ -1017,23 +1206,161 @@ static const struct snd_soc_component_driver q6apm= _fe_dai_component =3D { .remove_order =3D SND_SOC_COMP_ORDER_EARLY, }; =20 +static void q6apm_dai_reserved_mem_release(void *data) +{ + of_reserved_mem_device_release(data); +} + static int q6apm_dai_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; struct device_node *node =3D dev->of_node; struct q6apm_dai_data *pdata; struct of_phandle_args args; - int rc; + int rc, vmids, i; =20 pdata =3D devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 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) + if (rc < 0) { pdata->sid =3D -1; - else + } else { pdata->sid =3D args.args[0] & SID_MASK_DEFAULT; + of_node_put(args.np); + } + + vmids =3D of_property_count_u32_elems(node, "qcom,vmids"); + if (vmids =3D=3D -EINVAL) { + /* no qcom,vmids: SCM assignment not used on this target */ + pdata->use_scm_assign =3D false; + } else if (vmids < 0) { + return vmids; + } else if (vmids =3D=3D 0 || vmids > Q6APM_MAX_VMIDS) { + dev_err(dev, "qcom,vmids: invalid count %d (need 1..%d)\n", + vmids, Q6APM_MAX_VMIDS); + return -EINVAL; + } else if (pdata->sid >=3D 0) { + /* + * iommus (SMMU translation) and qcom,vmids (SCM VMID + * assignment) are mutually exclusive buffer-protection + * schemes; the binding forbids both, reject them here too. + */ + dev_err(dev, "qcom,vmids and iommus are mutually exclusive\n"); + return -EINVAL; + } + + if (vmids > 0) { + rc =3D of_property_read_u32_array(node, "qcom,vmids", + pdata->vmids, vmids); + if (rc) + return rc; + + for (i =3D 0; i < vmids; i++) { + if (pdata->vmids[i] =3D=3D QCOM_SCM_VMID_HLOS) { + dev_err(dev, + "qcom,vmids must not include HLOS\n"); + return -EINVAL; + } + } + pdata->num_vmids =3D vmids; + pdata->use_scm_assign =3D true; + } + + if (pdata->use_scm_assign) { + struct device_node *mem_node; + struct reserved_mem *rmem; + + if (!qcom_scm_is_available()) + return -EPROBE_DEFER; + + mem_node =3D of_parse_phandle(node, "memory-region", 0); + if (mem_node) { + rmem =3D of_reserved_mem_lookup(mem_node); + of_node_put(mem_node); + if (rmem) { + struct q6apm_scm_region *r; + + r =3D &pdata->carveout_regions[pdata->num_carveouts++]; + r->addr =3D rmem->base; + r->size =3D ALIGN(rmem->size, PAGE_SIZE); + r->src_perms =3D BIT_ULL(QCOM_SCM_VMID_HLOS); + } + } + + mem_node =3D of_parse_phandle(node, "memory-region", 1); + if (mem_node) { + rmem =3D of_reserved_mem_lookup(mem_node); + of_node_put(mem_node); + if (rmem) { + struct q6apm_scm_region *r; + size_t per_stream; + + /* + * The data-path carveout is a shared DMA pool + * from which all PCM substreams pre-allocate. + * Divide evenly so concurrent streams fit, + * subtracting per-stream position-buffer + * overhead. Reject a pool too small to give + * each stream a usable buffer (unsigned + * arithmetic would otherwise wrap). + */ + per_stream =3D rmem->size / Q6APM_POOL_MAX_STREAMS; + if (per_stream <=3D POS_BUFFER_BYTES) { + dev_err(dev, + "reserved-memory pool too small: %llu bytes\n", + (u64)rmem->size); + return -EINVAL; + } + + rc =3D of_reserved_mem_device_init_by_idx(dev, node, 1); + if (rc) { + dev_err(dev, + "reserved-memory pool init failed: %d\n", + rc); + return rc; + } + rc =3D devm_add_action_or_reset(dev, + q6apm_dai_reserved_mem_release, + dev); + if (rc) + return rc; + + /* never exceed the per-substream buffer cap */ + pdata->reserved_buf_size =3D + min_t(size_t, + per_stream - POS_BUFFER_BYTES, + BUFFER_BYTES_MAX); + pdata->has_reserved_mem =3D true; + + r =3D &pdata->carveout_regions[pdata->num_carveouts++]; + r->addr =3D rmem->base; + r->size =3D ALIGN(rmem->size, PAGE_SIZE); + r->src_perms =3D BIT_ULL(QCOM_SCM_VMID_HLOS); + } + } + + if (pdata->num_carveouts) { + for (i =3D 0; i < pdata->num_carveouts; i++) { + rc =3D q6apm_dai_scm_assign(&pdata->carveout_regions[i], + pdata); + if (rc) { + dev_err(dev, + "SCM assign carveout[%d] failed: %d\n", + i, rc); + return rc; + } + } + rc =3D devm_add_action_or_reset(dev, + q6apm_dai_unassign_all, + pdata); + if (rc) + return rc; + } + } =20 dev_set_drvdata(dev, pdata); =20 --=20 2.34.1 From nobody Mon Sep 28 05:45:35 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 E06AA37FF40 for ; Tue, 25 Aug 2026 18:40:53 +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=1787683256; cv=none; b=XRfOrGTNq5LZ+7z5j22T/vOJjFzOoiLzA6K3A6BF+4BtlkSOqZLE5wFjBqWsHmgbSAhyrKWaOa+qatJF7x6UeZ6hiZbMHJzFVroEBtLmQWFl875Q8x6RRCKBOXWK0kwgURXLKgcMUtOZ+8zP1pUSHWyzc6ETYWwgPB7M2C2UwPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787683256; c=relaxed/simple; bh=9Tt4Zd7WmKIRLDwDs0hp3ydCtcayUg1HXRZS0NYCZ8Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C8Ha4vTEqlIPXEpj1CaRatPXp1n/IUJ6isffZQJxqVn2pZAyoNray+kPVTDcZGZu2ApVhuIsBGsRGeVBJTfPn00zlA6Ogx13N6OZVU+F3FmxwlH45Y6sZ3uxDWS63vER3dH7H8IBm0HaGD+SZ1waSew1LJnEyetYvKcmyWDE3tA= 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=nEvZ6P4a; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=GWlW96J0; 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="nEvZ6P4a"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="GWlW96J0" 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 67PHdYs92647046 for ; Tue, 25 Aug 2026 18:40: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= MftIDWqEjgh/I748USFVrQISChM77tFt9i/qUuxkS6M=; b=nEvZ6P4aRRMgH3e8 4/uAAEnwlxQ0D/KCmjJa0/x3hmIneaGWdRRLpZ3FK6rsH9Lj0hPj6n37hQEVwgRd RdefdA+9fX5QFT1paoHq7q/OxVnMwFU1g6p3K5pbCy0q86O6QHftD+GWtewiG8FK yPDgyCg0Sf4Wgr9z1KiOde/CzcYo27ePO7tEl40/ecJ93lC/a27c2YHzc6tUX6P+ 7hQ6zUBKt+RsT9HtKcFru5QU+GkeDvDlVeYM35/AuRgugdozj/9fQ9pkzvcAF7T6 761C8FJ9hd5gkiiqMJ7LqFwRUXWYoGMFPEJ33a/tbYSEkz3lL98ePDR9Il2Z8/vF 3Oe5rg== Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g9bku9h3k-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 25 Aug 2026 18:40:52 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cbedf42f199so53867a12.2 for ; Tue, 25 Aug 2026 11:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787683252; x=1788288052; 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=MftIDWqEjgh/I748USFVrQISChM77tFt9i/qUuxkS6M=; b=GWlW96J0FJoigZgHqQk4jDSp9XVK37Wqs46Fihaf+Y6SNzEAHLeKAQmS4Fj1yQ1Wkr LZzxKWtQ+u8Fx1nzxEUcCgF0xhFM7WLiPoaIj6hNvpf6lcdiyxAlTcPfSM3u/yzKeEmc DJGHDtvqMb1HckrXTfi+OyZt0ING+z5+gswVbMLaV1BRdet8BwC4YAUtB6VQJwMFce7b TMSapijrY1gwUxPLphwAhvtFHnvpp4rGxjYL4cFCUM6NXnNXzNp/Cwgj5vBf733aQGK0 sz+bVB7TbmpUkQQDa5XiD8tFlsQOpInJLTPdkvGd6aSEApxs+YYO8ZycWnp4ieVenjeZ KmJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787683252; x=1788288052; 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=MftIDWqEjgh/I748USFVrQISChM77tFt9i/qUuxkS6M=; b=EneaP2vSqM60Rk6NVq+MtWPLvE3fHgPxfSjZ06l0XZadnHbN3x4Zubu4Kw9GHDr/yB pYRby3ltHxiKgSrYaxZzCU/zUbLtcqqRFhobHM+AXCaLNrVZfr2atUTAfD/W1GzJZ2sg 3wkTDpJjPROSmXg4vpSwO12ZTFgYFQO9kRwInd7UmKqZzHVFBpVxz6e0UEIw5gaGK/zu 55JFapAJRDzA6QoYPVQg+KGHvY+32twx8I8eH66rvvVWPHEIylxozL+/7BKVpmeukJf9 x7gihHoQ+MUl4C+ms/dp2LB6BZHYyZRI+YE6FFk/K9AfuzcZHbXnksMVf7JW/IgtoHlj AR5w== X-Forwarded-Encrypted: i=1; AHgh+RqPiHXHBvEQkpy2Ssitkrydw6BG/qgpJSAOGrqqlKWANI1XI3UpTidwIRheBcSC2hNvF096D6c/anA2nSQ=@vger.kernel.org X-Gm-Message-State: AFuF++mZ2gml6h5vie67n7Vwbtr5bvQPnawsbWGj2g/D9NKwMFfyw/8s +JBf3ruTLOA2qArm9ewDXeRAg9lSLK84SL1w1v+/Fwu0uQcMNzzkkmMCwQ/R4xJtxkZoPdGEJjf 7ppXTFEsB0sHBoB8bjkvFKk2PFuxrg4A8w/4D81jvvmPXsPzWcTtp3jqkWo0ketzvYmU= X-Gm-Gg: AR+sD11Ld2Dnk1YGHiPjC6gwyTiXB8oDelK5Jpvkc4+Blrw5dUPjq9gZGlbDCBEvLD+ w9hDYxAc7K3rVVRlPG+hGt+jFC9GfMqDFBirMXrpUaTnYda07Dk5D/tp0wPTG3He1IzFfnHQlrl 0CmnibbAbM8L3sqYH8gaMd/ssoVftGGqcaKUpR2jgpsEN3xvAEvLknO8rQpZkG8j92GHaG1GgQo 7jD36Y+WndL7eWHlFpzqDOrzRtakJtg09vwIugoBEp4uLAnKqcSy6H/bPgDN3521v2QZEPqpHJ3 XZyBjXGdH7FoK06AnTCm6VQFDjTwJaTwlvGo7Y0TjXaFv3HwVZNoKrUObj2Z8YvBOVMTBpDMOF+ 4/nlUEFQCKG1shuSdFUZIruTwxJL1 X-Received: by 2002:a05:6a21:6e43:b0:3b4:605c:2163 with SMTP id adf61e73a8af0-3cf74e42efdmr1135041637.4.1787683250667; Tue, 25 Aug 2026 11:40:50 -0700 (PDT) X-Received: by 2002:a05:6a21:6e43:b0:3b4:605c:2163 with SMTP id adf61e73a8af0-3cf74e42efdmr1134941637.4.1787683250197; Tue, 25 Aug 2026 11:40:50 -0700 (PDT) Received: from hu-nandam-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3283fa89e8fsm256117eec.8.2026.08.25.11.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 11:40:49 -0700 (PDT) From: Ajay Kumar Nandam Date: Wed, 26 Aug 2026 00:10:14 +0530 Subject: [PATCH v2 3/3] ASoC: qcom: qdsp6: generalize GPR service domain Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260826-a2a-shikra-vmid-v5-v2-3-c3dc62354eee@oss.qualcomm.com> References: <20260826-a2a-shikra-vmid-v5-v2-0-c3dc62354eee@oss.qualcomm.com> In-Reply-To: <20260826-a2a-shikra-vmid-v5-v2-0-c3dc62354eee@oss.qualcomm.com> To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Pratyush Meduri , Ajay Kumar Nandam X-Mailer: b4 0.15.0 X-Proofpoint-ORIG-GUID: 8Ixjlf7z1soT4wtHYGRVYEV2nVR3Ml7v X-Proofpoint-Spam-Info: AW1haW4tMjYwODI1MDE1OCBTYWx0ZWRfX/9AwNJiQN5Wt iL06E65J3jgsNEX1ySgn6ghWkPwSR4PBhhHAQU2P3KyhsZoXga8W36k1m/rwdHFbCJZLJ2QPoAa FZ7MwefmJicxsduX43tcqoSk9hm274A= X-Authority-Analysis: v=2.4 cv=TZGmcxQh c=1 sm=1 tr=0 ts=6a8de1b4 cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=06UwNDcAWG1pVACfRQkA:9 a=QEXdDO2ut3YA:10 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-GUID: 8Ixjlf7z1soT4wtHYGRVYEV2nVR3Ml7v X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI1MDE1OCBTYWx0ZWRfX1Ar9rCGxpkS6 gEGG/EFVRB3zf5NZgVc1p5Q8JukKY7++RtvC5N5Js2p39ohbz3ORtYzvn4GsmvXINOR9Xx4x3PO A6ty4XhoCTd/h9+LNCHs2A+vU5d3R7gBX6VzfYwNGJf2d8NZVMNQg7ErktiSSmmhTP144iKfqFT kn5JBEemA4/3ZuNCDOf4smqPEnkkuKzmoDcNtYNuo5BxNCAsPlE6YoMKdwwJDo1MB7VSprHUPj3 tCrn/rYHUbJaNmYQdu1tM6cKMqJuVJO+sSdWKp6KEM/LRdQQdY5VVs5gM2azt8iu9apZUP8J3ZJ phn/MJ7bQWUL0o5Ak4MOMODOD/+l61WX5oN/bfqcjE7gUjd1EfjNKCNvhvJugj5PcyWPvqGDwz3 NBVSTuNCTg6t3k/Obj3rwv3EOD/1uaPE1QlScuHSX75wVjOfvaG66UuLkL05CqAQYGZao4xOntO lRji+yJaf/j3gQNAs3g== 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-08-25_05,2026-08-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 spamscore=0 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608250158 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 641d6d243229..e5563014fa5b 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