Skip to content

Commit b45a377

Browse files
yiliu1765joergroedel
authored andcommitted
iommu: Pass old domain to set_dev_pasid op
To support domain replacement for pasid, the underlying iommu driver needs to know the old domain hence be able to clean up the existing attachment. It would be much convenient for iommu layer to pass down the old domain. Otherwise, iommu drivers would need to track domain for pasids by themselves, this would duplicate code among the iommu drivers. Or iommu drivers would rely group->pasid_array to get domain, which may not always the correct one. Suggested-by: Jason Gunthorpe <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Reviewed-by: Lu Baolu <[email protected]> Reviewed-by: Nicolin Chen <[email protected]> Reviewed-by: Vasant Hegde <[email protected]> Signed-off-by: Yi Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent c43e1cc commit b45a377

File tree

8 files changed

+17
-9
lines changed

8 files changed

+17
-9
lines changed

drivers/iommu/amd/amd_iommu.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ struct iommu_domain *amd_iommu_domain_alloc_sva(struct device *dev,
5252
struct mm_struct *mm);
5353
void amd_iommu_domain_free(struct iommu_domain *dom);
5454
int iommu_sva_set_dev_pasid(struct iommu_domain *domain,
55-
struct device *dev, ioasid_t pasid);
55+
struct device *dev, ioasid_t pasid,
56+
struct iommu_domain *old);
5657
void amd_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
5758
struct iommu_domain *domain);
5859

drivers/iommu/amd/pasid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ static const struct mmu_notifier_ops sva_mn = {
100100
};
101101

102102
int iommu_sva_set_dev_pasid(struct iommu_domain *domain,
103-
struct device *dev, ioasid_t pasid)
103+
struct device *dev, ioasid_t pasid,
104+
struct iommu_domain *old)
104105
{
105106
struct pdom_dev_data *pdom_dev_data;
106107
struct protection_domain *sva_pdom = to_pdomain(domain);

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ void arm_smmu_sva_notifier_synchronize(void)
332332
}
333333

334334
static int arm_smmu_sva_set_dev_pasid(struct iommu_domain *domain,
335-
struct device *dev, ioasid_t id)
335+
struct device *dev, ioasid_t id,
336+
struct iommu_domain *old)
336337
{
337338
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
338339
struct arm_smmu_master *master = dev_iommu_priv_get(dev);

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2856,7 +2856,8 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
28562856
}
28572857

28582858
static int arm_smmu_s1_set_dev_pasid(struct iommu_domain *domain,
2859-
struct device *dev, ioasid_t id)
2859+
struct device *dev, ioasid_t id,
2860+
struct iommu_domain *old)
28602861
{
28612862
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
28622863
struct arm_smmu_master *master = dev_iommu_priv_get(dev);

drivers/iommu/intel/iommu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,7 +4070,8 @@ static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
40704070
}
40714071

40724072
static int intel_iommu_set_dev_pasid(struct iommu_domain *domain,
4073-
struct device *dev, ioasid_t pasid)
4073+
struct device *dev, ioasid_t pasid,
4074+
struct iommu_domain *old)
40744075
{
40754076
struct device_domain_info *info = dev_iommu_priv_get(dev);
40764077
struct dmar_domain *dmar_domain = to_dmar_domain(domain);
@@ -4356,7 +4357,8 @@ static int identity_domain_attach_dev(struct iommu_domain *domain, struct device
43564357
}
43574358

43584359
static int identity_domain_set_dev_pasid(struct iommu_domain *domain,
4359-
struct device *dev, ioasid_t pasid)
4360+
struct device *dev, ioasid_t pasid,
4361+
struct iommu_domain *old)
43604362
{
43614363
struct device_domain_info *info = dev_iommu_priv_get(dev);
43624364
struct intel_iommu *iommu = info->iommu;

drivers/iommu/intel/svm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ static const struct mmu_notifier_ops intel_mmuops = {
111111
};
112112

113113
static int intel_svm_set_dev_pasid(struct iommu_domain *domain,
114-
struct device *dev, ioasid_t pasid)
114+
struct device *dev, ioasid_t pasid,
115+
struct iommu_domain *old)
115116
{
116117
struct device_domain_info *info = dev_iommu_priv_get(dev);
117118
struct dmar_domain *dmar_domain = to_dmar_domain(domain);

drivers/iommu/iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3331,7 +3331,8 @@ static int __iommu_set_group_pasid(struct iommu_domain *domain,
33313331
int ret;
33323332

33333333
for_each_group_device(group, device) {
3334-
ret = domain->ops->set_dev_pasid(domain, device->dev, pasid);
3334+
ret = domain->ops->set_dev_pasid(domain, device->dev,
3335+
pasid, NULL);
33353336
if (ret)
33363337
goto err_revert;
33373338
}

include/linux/iommu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ struct iommu_ops {
642642
struct iommu_domain_ops {
643643
int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
644644
int (*set_dev_pasid)(struct iommu_domain *domain, struct device *dev,
645-
ioasid_t pasid);
645+
ioasid_t pasid, struct iommu_domain *old);
646646

647647
int (*map_pages)(struct iommu_domain *domain, unsigned long iova,
648648
phys_addr_t paddr, size_t pgsize, size_t pgcount,

0 commit comments

Comments
 (0)