iommufd: Misc cleanups per iommufd iopf merging
cover iommufd: Misc cleanups per iommufd iopf merging
Hi,
Two misc patches per the iommufd iopf merging. Please feel free comment.
Regards,
Yi Liu
Yi Liu (2):
iommufd: Avoid duplicated __iommu_group_set_core_domain() call
iommu: Set iommu_attach_handle->domain in core
drivers/iommu/iommu.c | 1 + drivers/iommu/iommufd/fault.c | 1 - drivers/iommu/iommufd/iommufd_private.h | 4 +++- 3 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 iommufd: Avoid duplicated __iommu_group_set_core_domain() call
For the fault-capable hwpts, the iommufd_hwpt_detach_device() calls both iommufd_fault_domain_detach_dev() and iommu_detach_group(). This would have duplicated __iommu_group_set_core_domain() call since both functions call it in the end. This looks no harm as the __iommu_group_set_core_domain() returns if the new domain equals to the existing one. But it makes sense to avoid such duplicated calls in caller side.
--- drivers/iommu/iommufd/iommufd_private.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/iommufd/iommufd_private.h +3 -1
@@ -490,8 +490,10 @@ static inline int iommufd_hwpt_attach_device(struct iommufd_hw_pagetable *hwpt,static inline void iommufd_hwpt_detach_device (struct iommufd_hw_pagetable *hwpt,struct iommufd_device *idev) { -if (hwpt->fault) +if (hwpt->fault) {iommufd_fault_domain_detach_dev (hwpt, idev); +return ; + }iommu_detach_group (hwpt->domain, idev->igroup->group); }
Signature · 1 line
2.34.1
Re: [PATCH 1/2] iommufd: Avoid duplicated __iommu_group_set_core_domain() call
Quoted 11 lines · Yi Liu
For the fault-capable hwpts, the
iommufd_hwpt_detach_device()calls bothiommufd_fault_domain_detach_dev()andiommu_detach_group(). This would have duplicated__iommu_group_set_core_domain()call since both functions call it in the end. This looks no harm as the__iommu_group_set_core_domain()returns if the new domain equals to the existing one. But it makes sense to avoid such duplicated calls in caller side.Signed-off-by Yi Liu<[email protected]>--- drivers/iommu/iommufd/iommufd_private.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Thanks,
baolu
RE: [PATCH 1/2] iommufd: Avoid duplicated __iommu_group_set_core_domain() call
In reply to Yi LiuQuoted 11 lines
From: Liu, Yi L <[email protected]>
Sent: Sunday, September 8, 2024 7:43 PMFor the fault-capable hwpts, the
iommufd_hwpt_detach_device()calls bothiommufd_fault_domain_detach_dev()andiommu_detach_group(). This would have
duplicated__iommu_group_set_core_domain()call since both functions call it in the end. This looks no harm as the__iommu_group_set_core_domain()returns if the new domain equals to the existing one. But it makes sense to avoid such duplicated calls in caller side.
Quoted 1 line
Signed-off-by Yi Liu <[email protected]>
PATCH 2/2 iommu: Set iommu_attach_handle->domain in core
In reply to Yi LiuThe IOMMU core sets the iommu_attach_handle->domain for the iommu_attach_group_handle() path, while the iommu_replace_group_handle() sets it on the caller side. Make the two paths aligned on it.
--- drivers/iommu/iommu.c | 1 + drivers/iommu/iommufd/fault.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/iommu.c +1 -0
@@ -3578,6 +3578,7 @@ int iommu_replace_group_handle(struct iommu_group *group, ret =xa_reserve (&group->pasid_array,IOMMU_NO_PASID ,GFP_KERNEL );if (ret) goto err_unlock; + handle->domain = new_domain; } ret =__iommu_group_set_domain (group, new_domain);
drivers/iommu/iommufd/fault.c +0 -1
@@ -161,7 +161,6 @@ static int __fault_domain_replace_dev(struct iommufd_device *idev,if (!handle)return -ENOMEM ; - handle->handle.domain = hwpt->domain; handle->idev = idev; ret =iommu_replace_group_handle (idev->igroup->group, hwpt->domain, &handle->handle);
Signature · 1 line
2.34.1
Re: [PATCH 2/2] iommu: Set iommu_attach_handle->domain in core
Quoted 9 lines · Yi Liu
The IOMMU core sets the
iommu_attach_handle->domainfor theiommu_attach_group_handle()path, while theiommu_replace_group_handle()sets it on the caller side. Make the two paths aligned on it.Signed-off-by Yi Liu<[email protected]>--- drivers/iommu/iommu.c | 1 + drivers/iommu/iommufd/fault.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
Thanks,
baolu
RE: [PATCH 2/2] iommu: Set iommu_attach_handle->domain in core
In reply to Yi LiuQuoted 9 lines
From: Liu, Yi L <[email protected]>
Sent: Sunday, September 8, 2024 7:43 PMThe IOMMU core sets the
iommu_attach_handle->domainfor theiommu_attach_group_handle()path, while theiommu_replace_group_handle()
sets it on the caller side. Make the two paths aligned on it.Signed-off-by Yi Liu <[email protected]>
Quoted 10 lines · Yi Liu
Hi,
Two misc patches per the iommufd iopf merging. Please feel free comment.
Regards,
Yi LiuYi Liu (2):
iommufd: Avoid duplicated__iommu_group_set_core_domain()call
iommu: Setiommu_attach_handle->domainin core
Applied to for-next, thanks
Jason