On 9/26/23 5:26 PM, Yi Liu wrote:
Most of the core logic before conducting the actual device attach/
replace operation can be shared with pasid attach/replace. Create
a new structure so more information (e.g. pasid) can be later added
along with the attach_fn.
Signed-off-by: Kevin Tian<kevin.tian@xxxxxxxxx>
Signed-off-by: Yi Liu<yi.l.liu@xxxxxxxxx>
---
drivers/iommu/iommufd/device.c | 35 ++++++++++++++++---------
drivers/iommu/iommufd/iommufd_private.h | 8 ++++++
2 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 645ab5d290fe..4fa4153c5df7 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -597,8 +597,11 @@ iommufd_device_do_replace(struct iommufd_device *idev,
return ERR_PTR(rc);
}
-typedef struct iommufd_hw_pagetable *(*attach_fn)(
- struct iommufd_device *idev, struct iommufd_hw_pagetable *hwpt);
+static struct iommufd_hw_pagetable *do_attach(struct iommufd_device *idev,
+ struct iommufd_hw_pagetable *hwpt, struct attach_data *data)
+{
+ return data->attach_fn(idev, hwpt);
+}
I assume that this change was made because we need to pass the pasid
value to the attach_fn() callback.
If so, how about passing it directly to attach_fn() function?
typedef struct iommufd_hw_pagetable *(*attach_fn)(
struct iommufd_device *idev,
struct iommufd_hw_pagetable *hwpt,
ioasid_t pasid);
In no pasid case, use IOMMU_NO_PASID.
Best regards,
baolu