[PATCH v4 11/17] iommu: Remove the assignment of group->domain during default domain alloc

Jason Gunthorpe
2023-04-12T13:52:03Z

group->domain should only be set once all the device's drivers have
had their ops->attach_dev() called. iommu_group_alloc_default_domain()
doesn't do this, so it shouldn't set the value.

The previous patches organized things so that each caller of
iommu_group_alloc_default_domain() follows up with calling
__iommu_group_set_domain_internal() that does set the group->domain.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/iommu.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index f0dcc7a559b55a..57697cc877de2f 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -430,7 +430,6 @@ int iommu_probe_device(struct device *dev)
* checked.
*/
iommu_alloc_default_domain(group, dev);
- group->domain = NULL;
if (group->default_domain) {
iommu_create_device_direct_mappings(group, dev);
ret = __iommu_group_set_domain(group,
@@ -1688,8 +1687,6 @@ static int iommu_group_alloc_default_domain(struct bus_type *bus,
return -ENOMEM;

group->default_domain = dom;
- if (!group->domain)
- group->domain = dom;
return 0;
}

@@ -1893,7 +1890,6 @@ int bus_iommu_probe(struct bus_type *bus)

iommu_group_create_direct_mappings(group);

- group->domain = NULL;
ret = __iommu_group_set_domain(group, group->default_domain);

mutex_unlock(&group->mutex);
--
2.40.0