[PATCH v4 13/13] iommu/arm-smmu-v3-sva: Add check when enabling sva
From: Michael Shavit
Date: Wed Jun 21 2023 - 02:47:05 EST
SVA domains can only be attached when the master's STEs have a stage 1
domain.
Signed-off-by: Michael Shavit <mshavit@xxxxxxxxxx>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
index b615a85e6a54e..e2a91f20f0906 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
@@ -499,9 +499,15 @@ int arm_smmu_master_enable_sva(struct arm_smmu_master *master)
int ret;
mutex_lock(&sva_lock);
+
+ if (!master->s1_cfg) {
+ ret = -EBUSY;
+ goto unlock;
+ }
ret = arm_smmu_master_sva_enable_iopf(master);
if (!ret)
master->sva_enabled = true;
+unlock:
mutex_unlock(&sva_lock);
return ret;
--
2.41.0.162.gfafddb0af9-goog