diff options
author | Will Deacon <will.deacon@arm.com> | 2014-07-17 14:23:51 +0400 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2014-09-16 22:14:37 +0400 |
commit | 844e35bdfe834fccb5def1bc4cd614ca22409d0c (patch) | |
tree | 773c0e21dfdac718fb5a3720742a3cffd1fd5b55 /drivers | |
parent | 8f68f8e28298abdf518648e794c71e534eb8841c (diff) | |
download | linux-844e35bdfe834fccb5def1bc4cd614ca22409d0c.tar.xz |
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')
-rw-r--r-- | drivers/iommu/arm-smmu.c | 17 |
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) return -ENXIO; } + if (dev->archdata.iommu) { + dev_err(dev, "already attached to IOMMU domain\n"); + return -EEXIST; + } + /* * Sanity check the domain. We don't support domains across * different SMMUs. @@ -1239,7 +1244,10 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) if (!cfg) return -ENODEV; - return arm_smmu_domain_add_master(smmu_domain, cfg); + ret = arm_smmu_domain_add_master(smmu_domain, cfg); + if (!ret) + dev->archdata.iommu = domain; + return ret; } static 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) struct arm_smmu_master_cfg *cfg; cfg = find_smmu_master_cfg(dev); - if (cfg) - arm_smmu_domain_remove_master(smmu_domain, cfg); + if (!cfg) + return; + + dev->archdata.iommu = NULL; + arm_smmu_domain_remove_master(smmu_domain, cfg); } static bool arm_smmu_pte_is_contiguous_range(unsigned long addr, |