Commit d9dfb5e6 authored by Yi Liu's avatar Yi Liu Committed by Jason Gunthorpe
Browse files

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.

Link: https://patch.msgid.link/r/20240908114256.979518-2-yi.l.liu@intel.com


Signed-off-by: default avatarYi Liu <yi.l.liu@intel.com>
Reviewed-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 8f688734
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -510,8 +510,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);
}