summaryrefslogtreecommitdiff
path: root/drivers/iommu/iommu.c
diff options
context:
space:
mode:
authorYi Liu <yi.l.liu@intel.com>2024-03-28 05:29:58 -0700
committerJoerg Roedel <jroedel@suse.de>2024-04-12 12:13:01 +0200
commitd2f85a263883b679f87ed8f911746105658e9c47 (patch)
tree58d21b3942f962508b82184780babb7d6397f93c /drivers/iommu/iommu.c
parentb025dea63cded0d82bccd591fa105d39efc6435d (diff)
downloadlwn-d2f85a263883b679f87ed8f911746105658e9c47.tar.gz
lwn-d2f85a263883b679f87ed8f911746105658e9c47.zip
iommu: Pass domain to remove_dev_pasid() op
Existing remove_dev_pasid() callbacks of the underlying iommu drivers get the attached domain from the group->pasid_array. However, the domain stored in group->pasid_array is not always correct in all scenarios. A wrong domain may result in failure in remove_dev_pasid() callback. To avoid such problems, it is more reliable to pass the domain to the remove_dev_pasid() op. Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Link: https://lore.kernel.org/r/20240328122958.83332-3-yi.l.liu@intel.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/iommu.c')
-rw-r--r--drivers/iommu/iommu.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 659a77f7bb83..3183b0ed4cdb 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -3335,20 +3335,21 @@ err_revert:
if (device == last_gdev)
break;
- ops->remove_dev_pasid(device->dev, pasid);
+ ops->remove_dev_pasid(device->dev, pasid, domain);
}
return ret;
}
static void __iommu_remove_group_pasid(struct iommu_group *group,
- ioasid_t pasid)
+ ioasid_t pasid,
+ struct iommu_domain *domain)
{
struct group_device *device;
const struct iommu_ops *ops;
for_each_group_device(group, device) {
ops = dev_iommu_ops(device->dev);
- ops->remove_dev_pasid(device->dev, pasid);
+ ops->remove_dev_pasid(device->dev, pasid, domain);
}
}
@@ -3418,7 +3419,7 @@ void iommu_detach_device_pasid(struct iommu_domain *domain, struct device *dev,
struct iommu_group *group = dev->iommu_group;
mutex_lock(&group->mutex);
- __iommu_remove_group_pasid(group, pasid);
+ __iommu_remove_group_pasid(group, pasid, domain);
WARN_ON(xa_erase(&group->pasid_array, pasid) != domain);
mutex_unlock(&group->mutex);
}