[PATCH v4 7/7] iommu: Remove the remove_dev_pasid op

Yi Liu
2024-11-08T12:04:42Z

The iommu drivers that supports PASID have supported attaching pasid to the
blocked_domain, hence remove the remove_dev_pasid op from the iommu_ops.

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
---
drivers/iommu/iommu.c | 17 ++++-------------
include/linux/iommu.h | 5 -----
2 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 6fd4b904f270..e970893168d8 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -3303,17 +3303,9 @@ static void iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
{
const struct iommu_ops *ops = dev_iommu_ops(dev);
struct iommu_domain *blocked_domain = ops->blocked_domain;
- int ret = 1;

- if (blocked_domain && blocked_domain->ops->set_dev_pasid) {
- ret = blocked_domain->ops->set_dev_pasid(blocked_domain,
- dev, pasid, domain);
- } else {
- ops->remove_dev_pasid(dev, pasid, domain);
- ret = 0;
- }
-
- WARN_ON(ret);
+ WARN_ON(blocked_domain->ops->set_dev_pasid(blocked_domain,
+ dev, pasid, domain));
}

static int __iommu_set_group_pasid(struct iommu_domain *domain,
@@ -3371,9 +3363,8 @@ int iommu_attach_device_pasid(struct iommu_domain *domain,
int ret;

if (!domain->ops->set_dev_pasid ||
- (!ops->remove_dev_pasid &&
- (!ops->blocked_domain ||
- !ops->blocked_domain->ops->set_dev_pasid)))
+ !ops->blocked_domain ||
+ !ops->blocked_domain->ops->set_dev_pasid)
return -EOPNOTSUPP;

if (!group)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 0c3bfb66dc7c..1d033121bf00 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -537,9 +537,6 @@ static inline int __iommu_copy_struct_from_user_array(
* - IOMMU_DOMAIN_DMA: must use a dma domain
* - 0: use the default setting
* @default_domain_ops: the default ops for domains
- * @remove_dev_pasid: Remove any translation configurations of a specific
- * pasid, so that any DMA transactions with this pasid
- * will be blocked by the hardware.
* @pgsize_bitmap: bitmap of all possible supported page sizes
* @owner: Driver module providing these ops
* @identity_domain: An always available, always attachable identity
@@ -586,8 +583,6 @@ struct iommu_ops {
struct iommu_page_response *msg);

int (*def_domain_type)(struct device *dev);
- void (*remove_dev_pasid)(struct device *dev, ioasid_t pasid,
- struct iommu_domain *domain);

const struct iommu_domain_ops *default_domain_ops;
unsigned long pgsize_bitmap;
--
2.34.1