Skip to contentSkip to conversation

Fix Shikra q6apm DAI under KVM/EL2

PATCH Superseded Mohit Sharma 2 participants 11 messages Nov 19 – Nov 27

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

cover Fix Shikra q6apm DAI under KVM/EL2

Shikra's q6apm DAI is hosted on the modem DSP. In the hypervisor configuration its shared memory is assigned directly, but when Linux runs at EL2 it owns the apps SMMU and the audio stream must be described and mapped there. Using the normal translating domain causes context faults because the firmware consumes SID-tagged physical addresses.

Select an identity domain for the Shikra q6apm DAI. Also allow modem-domain q6apm DAIs carrying an IOMMU specifier to use the DMA/IOMMU path, while retaining SCM assignment for modem-domain DAIs without an IOMMU.

The series is ordered as follows:

1. Add the Shikra-specific q6apm DAI compatible to the binding.
2. Select an identity domain for that compatible.
3. Add the compatible to the Shikra q6apm DAI node.
4. Select SCM or IOMMU operation from the presence of an IOMMU stream.

The Shikra EL2 overlay is expected to provide the q6apm DAI SMMU stream description. That overlay change is maintained separately from this series.

Validated on a Shikra EVK booted under KVM/EL2. The q6apm DAI probes through the IOMMU path without the previous SCM/IOMMU mutual-exclusion failure, and playback and capture use the per-stream identity domain.

Mohit Sharma (4):
dt-bindings: sound: qcom,q6apm-dai: allow Shikra compatible
iommu: arm-smmu-qcom: use identity domain for Shikra q6apm DAI
arm64: dts: qcom: shikra: add q6apm DAI compatible
ASoC: qcom: q6apm-dai: allow the mDSP IOMMU path

 .../devicetree/bindings/sound/qcom,q6apm-dai.yaml        | 6 +++++-
 arch/arm64/boot/dts/qcom/shikra.dtsi                     | 3 ++-
 drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c               | 1 +
 sound/soc/qcom/qdsp6/q6apm-dai.c                         | 9 ++-------
 4 files changed, 10 insertions(+), 9 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 dt-bindings: sound: qcom,q6apm-dai: allow Shikra compatible

Shikra's q6apm DAI needs a SoC-specific compatible so that the Qualcomm SMMU implementation can select the identity domain required by its firmware ABI. The ASoC driver continues to bind using the generic fallback compatible.

Allow the Shikra compatible followed by the existing generic compatible.

Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml +5 -1
index c1f9fc9eab64..c5eea6698ab6 100644
@@ -14,7 +14,11 @@ description: |
 
 properties:
   compatible:
-    const: qcom,q6apm-dais
+    oneOf:
+      - const: qcom,q6apm-dais
+      - items:
+          - const: qcom,shikra-q6apm-dais
+          - const: qcom,q6apm-dais
 
   iommus:
     minItems: 1
Signature · 1 line
2.34.1
maintainer
#2 lore raw

Re: [PATCH 1/4] dt-bindings: sound: qcom,q6apm-dai: allow Shikra compatible

Quoted 4 lines · Mohit Sharma

Shikra's q6apm DAI needs a SoC-specific compatible so that the Qualcomm SMMU implementation can select the identity domain required by its firmware ABI. The ASoC driver continues to bind using the generic fallback compatible.

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.

#3 lore raw

PATCH 2/4 iommu: arm-smmu-qcom: use identity domain for Shikra q6apm DAI

In reply to Mohit Sharma

Shikra's q6apm DAI is hosted on the modem DSP under SMMU stream ID 0x1cc. Its firmware consumes the SID-tagged shared-memory addresses as physical addresses, so a translating domain leaves those addresses unmapped and causes context faults when Linux owns the SMMU under EL2.

Add the Shikra q6apm DAI compatible to the Qualcomm SMMU client match table. This selects an identity domain for this stream while retaining an SMMU mapping scoped to its own stream ID.

drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +1 -0
index a0550740185f..b340ca5f5117 100644
@@ -435,6 +435,7 @@ static const struct of_device_id qcom_smmu_client_of_match[] __maybe_unused = {
 	{ .compatible = "qcom,sdm670-mdss" },
 	{ .compatible = "qcom,sdm845-mdss" },
 	{ .compatible = "qcom,sdm845-mss-pil" },
+	{ .compatible = "qcom,shikra-q6apm-dais" },
 	{ .compatible = "qcom,sm6115-mdss" },
 	{ .compatible = "qcom,sm6350-mdss" },
 	{ .compatible = "qcom,sm6375-mdss" },
Signature · 1 line
2.34.1
#4 lore raw

PATCH 3/4 arm64: dts: qcom: shikra: add q6apm DAI compatible

In reply to Mohit Sharma

Add the Shikra-specific compatible to the q6apm DAI node while retaining the generic fallback used by the ASoC driver. The specific compatible lets arm-smmu-qcom select the identity domain required by the firmware ABI when the EL2 overlay describes this stream to the SMMU.

The EL2 stream description is part of the prerequisite Shikra EL2 overlay series.

arch/arm64/boot/dts/qcom/shikra.dtsi +2 -1
index f096469fb984..09b268af9eef 100644
@@ -2983,7 +2983,8 @@ q6apmbedai: bedais {
 						};
 
 						q6apmdai: dais {
-							compatible = "qcom,q6apm-dais";
+							compatible = "qcom,shikra-q6apm-dais",
+								     "qcom,q6apm-dais";
 							memory-region = <&audio_heap_mem
 									 &audio_mdsp_carveout_mem>;
 						};
Signature · 1 line
2.34.1
#5 lore raw

PATCH 4/4 ASoC: qcom: q6apm-dai: allow the mDSP IOMMU path

In reply to Mohit Sharma

The q6apm DAI currently selects SCM buffer assignment solely from the GPR domain. This prevents an mDSP-backed DAI from using an IOMMU, even when the device tree provides an iommus property for environments where the mDSP stream is routed through the apps SMMU.

Use the parsed stream ID to distinguish the two memory access models. An mDSP DAI without an IOMMU continues to use SCM-assigned buffers, while an mDSP DAI with an IOMMU follows the existing DMA/IOMMU path. This also avoids requiring SCM availability for the IOMMU configuration.

Fixes bb8afd437d79 ("ASoC: qcom: q6apm-dai: add SCM buffer assignment for mDSP platforms")
sound/soc/qcom/qdsp6/q6apm-dai.c +2 -7
index c1f0af93e808..a29fe4241776 100644
@@ -1218,16 +1218,11 @@ static int q6apm_dai_probe(struct platform_device *pdev)
 		pdata->sid = args.args[0] & SID_MASK_DEFAULT;
 
 	if (apm && apm->gdev &&
-	    apm->gdev->domain_id == GPR_DOMAIN_ID_MODEM) {
+	    apm->gdev->domain_id == GPR_DOMAIN_ID_MODEM &&
+	    pdata->sid < 0) {
 		if (!qcom_scm_is_available())
 			return -EPROBE_DEFER;
 
-		if (pdata->sid >= 0) {
-			dev_err(dev,
-				"iommus and mDSP SCM path are mutually exclusive\n");
-			return -EINVAL;
-		}
-
 		pdata->use_scm_assign = true;
 
 		rc = devm_add_action_or_reset(dev, q6apm_dai_scm_cleanup,
Signature · 1 line
2.34.1
#6 lore raw

v2 cover Fix Shikra q6apm DAI under KVM/EL2

In reply to Mohit Sharma

Shikra's q6apm DAI is hosted on the modem DSP. In the hypervisor configuration its shared memory is assigned directly, but when Linux runs at EL2 it owns the apps SMMU and the audio stream must be described and mapped there. Using the normal translating domain causes context faults because the firmware consumes SID-tagged physical addresses.

Shikra also retains its reserved-memory carveout as the backing pool for the audio DMA heap. The EL2 overlay adds an IOMMU description over the base DTB, so the resulting DAI node contains both memory-region and iommus. Allow both properties while continuing to require at least one.

Select an identity domain for the Shikra q6apm DAI. Also allow modem-domain q6apm DAIs carrying an IOMMU specifier to use the DMA/IOMMU path, while retaining SCM assignment for modem-domain DAIs without an IOMMU.

The series is ordered as follows:

1. Add the Shikra-specific compatible and allow both memory properties.
2. Select an identity domain for that compatible.
3. Add the compatible to the Shikra q6apm DAI node.
4. Select SCM or IOMMU operation from the presence of an IOMMU stream.

The Shikra EL2 overlay is expected to provide the q6apm DAI SMMU stream description. That overlay change is maintained separately from this series.

Validated on a Shikra EVK booted under KVM/EL2. The q6apm DAI probes through the IOMMU path without the previous SCM/IOMMU mutual-exclusion failure, and playback and capture use the per-stream identity domain.

Changes in v2:
- Follow the established subject-line style for each subsystem.
- Permit memory-region and iommus together for the Shikra EL2 audio path.

Mohit Sharma (4):
ASoC: dt-bindings: qcom,q6apm-dai: Add Shikra support iommu/arm-smmu-qcom: Use identity domain for Shikra q6apm DAI
arm64: dts: qcom: shikra: Add q6apm DAI compatible
ASoC: qcom: q6apm-dai: Allow the mDSP IOMMU path

 .../devicetree/bindings/sound/qcom,q6apm-dai.yaml        | 8 ++++++--
 arch/arm64/boot/dts/qcom/shikra.dtsi                     | 3 ++-
 drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c               | 1 +
 sound/soc/qcom/qdsp6/q6apm-dai.c                         | 9 ++-------
 4 files changed, 11 insertions(+), 10 deletions(-)
Signature · 1 line
2.34.1
#7 lore raw

PATCH v2 1/4 ASoC: dt-bindings: qcom,q6apm-dai: Add Shikra support

Shikra's q6apm DAI needs a SoC-specific compatible so that the Qualcomm SMMU implementation can select the identity domain required by its firmware ABI. The ASoC driver continues to bind using the generic fallback compatible.

Shikra uses a reserved-memory carveout as the backing pool for its audio DMA heap. When Linux runs under KVM/EL2, it also owns the apps SMMU and the EL2 overlay adds an iommus property to the DAI node. The resulting tree contains both memory-region and iommus, describing the allocation pool and the mDSP address translation respectively.

Allow the Shikra compatible followed by the existing generic compatible. Replace oneOf with anyOf so at least one memory description remains required while permitting both properties in the Shikra EL2 tree.

---
 .../devicetree/bindings/sound/qcom,q6apm-dai.yaml         | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/sound/qcom,q6apm-dai.yaml +6 -2
index c1f9fc9eab64..8ad20f95c814 100644
@@ -14,7 +14,11 @@ description: |
 
 properties:
   compatible:
-    const: qcom,q6apm-dais
+    oneOf:
+      - const: qcom,q6apm-dais
+      - items:
+          - const: qcom,shikra-q6apm-dais
+          - const: qcom,q6apm-dais
 
   iommus:
     minItems: 1
@@ -33,7 +37,7 @@ properties:
 required:
   - compatible
 
-oneOf:
+anyOf:
   - required:
       - iommus
   - required:
Signature · 1 line
2.34.1
#8 lore raw

PATCH v2 2/4 iommu/arm-smmu-qcom: Use identity domain for Shikra q6apm DAI

In reply to Mohit Sharma

Shikra's q6apm DAI is hosted on the modem DSP under SMMU stream ID 0x1cc. Its firmware consumes the SID-tagged shared-memory addresses as physical addresses, so a translating domain leaves those addresses unmapped and causes context faults when Linux owns the SMMU under EL2.

Add the Shikra q6apm DAI compatible to the Qualcomm SMMU client match table. This selects an identity domain for this stream while retaining an SMMU mapping scoped to its own stream ID.

---
 drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +1 -0
index 795e8ec7e8fa..09ea293052b2 100644
@@ -420,6 +420,7 @@ static const struct of_device_id qcom_smmu_client_of_match[] __maybe_unused = {
 	{ .compatible = "qcom,sdm670-mdss" },
 	{ .compatible = "qcom,sdm845-mdss" },
 	{ .compatible = "qcom,sdm845-mss-pil" },
+	{ .compatible = "qcom,shikra-q6apm-dais" },
 	{ .compatible = "qcom,sm6115-mdss" },
 	{ .compatible = "qcom,sm6350-mdss" },
 	{ .compatible = "qcom,sm6375-mdss" },
Signature · 1 line
2.34.1
#9 lore raw

PATCH v2 3/4 arm64: dts: qcom: shikra: Add q6apm DAI compatible

In reply to Mohit Sharma

Add the Shikra-specific compatible to the q6apm DAI node while retaining the generic fallback used by the ASoC driver. The specific compatible lets arm-smmu-qcom select the identity domain required by the firmware ABI when the EL2 overlay describes this stream to the SMMU.

The EL2 stream description is part of the prerequisite Shikra EL2 overlay series.

---
 arch/arm64/boot/dts/qcom/shikra.dtsi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/shikra.dtsi +2 -1
index 0a95ad5a5582..796d5225d161 100644
@@ -2358,7 +2358,8 @@ q6apmbedai: bedais {
 						};
 
 						q6apmdai: dais {
-							compatible = "qcom,q6apm-dais";
+							compatible = "qcom,shikra-q6apm-dais",
+								     "qcom,q6apm-dais";
 							memory-region = <&audio_heap_mem
 									 &audio_mdsp_carveout_mem>;
 						};
Signature · 1 line
2.34.1
#10 lore raw

PATCH v2 4/4 ASoC: qcom: q6apm-dai: Allow the mDSP IOMMU path

In reply to Mohit Sharma

The q6apm DAI currently selects SCM buffer assignment solely from the GPR domain. This prevents an mDSP-backed DAI from using an IOMMU, even when the device tree provides an iommus property for environments where the mDSP stream is routed through the apps SMMU.

Use the parsed stream ID to distinguish the two memory access models. An mDSP DAI without an IOMMU continues to use SCM-assigned buffers, while an mDSP DAI with an IOMMU follows the existing DMA/IOMMU path. This also avoids requiring SCM availability for the IOMMU configuration.

Fixes bb8afd437d79 ("ASoC: qcom: q6apm-dai: add SCM buffer assignment for mDSP platforms")
---
 sound/soc/qcom/qdsp6/q6apm-dai.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
sound/soc/qcom/qdsp6/q6apm-dai.c +2 -7
index afa4bb095e09..94302837b93b 100644
@@ -1221,16 +1221,11 @@ static int q6apm_dai_probe(struct platform_device *pdev)
 	}
 
 	if (apm && apm->gdev &&
-	    apm->gdev->domain_id == GPR_DOMAIN_ID_MODEM) {
+	    apm->gdev->domain_id == GPR_DOMAIN_ID_MODEM &&
+	    pdata->sid < 0) {
 		if (!qcom_scm_is_available())
 			return -EPROBE_DEFER;
 
-		if (pdata->sid >= 0) {
-			dev_err(dev,
-				"iommus and mDSP SCM path are mutually exclusive\n");
-			return -EINVAL;
-		}
-
 		pdata->use_scm_assign = true;
 
 		rc = devm_add_action_or_reset(dev, q6apm_dai_scm_cleanup,
Signature · 1 line
2.34.1