Skip to content

Commit 0046a43

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu: Remove iommu_group_do_dma_first_attach() from iommu_group_add_device()
This function is only used to construct the groups, it should not be operating the iommu driver. External callers in VFIO and POWER do not have any iommu drivers on the devices so group->domain will be NULL. The only internal caller is from iommu_probe_device() which already calls iommu_group_do_dma_first_attach(), meaning we are calling it twice in the only case it matters. Since iommu_probe_device() is the logical place to sort out the group's domain, remove the call from iommu_group_add_device(). Reviewed-by: Kevin Tian <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Tested-by: Niklas Schnelle <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent d257344 commit 0046a43

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

drivers/iommu/iommu.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,25 +1080,13 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev)
10801080

10811081
mutex_lock(&group->mutex);
10821082
list_add_tail(&device->list, &group->devices);
1083-
if (group->domain)
1084-
ret = iommu_group_do_dma_first_attach(dev, group->domain);
10851083
mutex_unlock(&group->mutex);
1086-
if (ret)
1087-
goto err_put_group;
1088-
10891084
trace_add_device_to_group(group->id, dev);
10901085

10911086
dev_info(dev, "Adding to iommu group %d\n", group->id);
10921087

10931088
return 0;
10941089

1095-
err_put_group:
1096-
mutex_lock(&group->mutex);
1097-
list_del(&device->list);
1098-
mutex_unlock(&group->mutex);
1099-
dev->iommu_group = NULL;
1100-
kobject_put(group->devices_kobj);
1101-
sysfs_remove_link(group->devices_kobj, device->name);
11021090
err_free_name:
11031091
kfree(device->name);
11041092
err_remove_link:

0 commit comments

Comments
 (0)