aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2014-07-17 06:23:51 -0400
committerWill Deacon <will.deacon@arm.com>2014-09-16 14:14:37 -0400
commit844e35bdfe834fccb5def1bc4cd614ca22409d0c (patch)
tree773c0e21dfdac718fb5a3720742a3cffd1fd5b55 /drivers/iommu
parent8f68f8e28298abdf518648e794c71e534eb8841c (diff)
iommu/arm-smmu: put iommu_domain pointer in dev->archdata.iommu
In preparation for nested translation support, stick a pointer to the iommu_domain in dev->archdata.iommu. This makes it much easier to grab hold of the physical group configuration (e.g. cbndx) when dealing with vSMMU accesses from a guest. Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/arm-smmu.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 38f8d670afb3..e8d311152203 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1213,6 +1213,11 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
1213 return -ENXIO; 1213 return -ENXIO;
1214 } 1214 }
1215 1215
1216 if (dev->archdata.iommu) {
1217 dev_err(dev, "already attached to IOMMU domain\n");
1218 return -EEXIST;
1219 }
1220
1216 /* 1221 /*
1217 * Sanity check the domain. We don't support domains across 1222 * Sanity check the domain. We don't support domains across
1218 * different SMMUs. 1223 * different SMMUs.
@@ -1239,7 +1244,10 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
1239 if (!cfg) 1244 if (!cfg)
1240 return -ENODEV; 1245 return -ENODEV;
1241 1246
1242 return arm_smmu_domain_add_master(smmu_domain, cfg); 1247 ret = arm_smmu_domain_add_master(smmu_domain, cfg);
1248 if (!ret)
1249 dev->archdata.iommu = domain;
1250 return ret;
1243} 1251}
1244 1252
1245static void arm_smmu_detach_dev(struct iommu_domain *domain, struct device *dev) 1253static void arm_smmu_detach_dev(struct iommu_domain *domain, struct device *dev)
@@ -1248,8 +1256,11 @@ static void arm_smmu_detach_dev(struct iommu_domain *domain, struct device *dev)
1248 struct arm_smmu_master_cfg *cfg; 1256 struct arm_smmu_master_cfg *cfg;
1249 1257
1250 cfg = find_smmu_master_cfg(dev); 1258 cfg = find_smmu_master_cfg(dev);
1251 if (cfg) 1259 if (!cfg)
1252 arm_smmu_domain_remove_master(smmu_domain, cfg); 1260 return;
1261
1262 dev->archdata.iommu = NULL;
1263 arm_smmu_domain_remove_master(smmu_domain, cfg);
1253} 1264}
1254 1265
1255static bool arm_smmu_pte_is_contiguous_range(unsigned long addr, 1266static bool arm_smmu_pte_is_contiguous_range(unsigned long addr,