Skip to content

Commit ecd60dc

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu: Use __iommu_group_set_domain() for __iommu_attach_group()
The error recovery here matches the recovery inside __iommu_group_set_domain(), so just use it directly. Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Tested-by: Heiko Stuebner <heiko@sntech.de> Tested-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/4-v5-1b99ae392328+44574-iommu_err_unwind_jgg@nvidia.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent dcf40ed commit ecd60dc

1 file changed

Lines changed: 1 addition & 39 deletions

File tree

drivers/iommu/iommu.c

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,52 +2159,14 @@ struct iommu_domain *iommu_get_dma_domain(struct device *dev)
21592159
return dev->iommu_group->default_domain;
21602160
}
21612161

2162-
/*
2163-
* IOMMU groups are really the natural working unit of the IOMMU, but
2164-
* the IOMMU API works on domains and devices. Bridge that gap by
2165-
* iterating over the devices in a group. Ideally we'd have a single
2166-
* device which represents the requestor ID of the group, but we also
2167-
* allow IOMMU drivers to create policy defined minimum sets, where
2168-
* the physical hardware may be able to distiguish members, but we
2169-
* wish to group them at a higher level (ex. untrusted multi-function
2170-
* PCI devices). Thus we attach each device.
2171-
*/
2172-
static int iommu_group_do_attach_device(struct device *dev, void *data)
2173-
{
2174-
struct iommu_domain *domain = data;
2175-
2176-
return __iommu_attach_device(domain, dev);
2177-
}
2178-
21792162
static int __iommu_attach_group(struct iommu_domain *domain,
21802163
struct iommu_group *group)
21812164
{
2182-
int ret;
2183-
21842165
if (group->domain && group->domain != group->default_domain &&
21852166
group->domain != group->blocking_domain)
21862167
return -EBUSY;
21872168

2188-
ret = __iommu_group_for_each_dev(group, domain,
2189-
iommu_group_do_attach_device);
2190-
if (ret == 0) {
2191-
group->domain = domain;
2192-
} else {
2193-
/*
2194-
* To recover from the case when certain device within the
2195-
* group fails to attach to the new domain, we need force
2196-
* attaching all devices back to the old domain. The old
2197-
* domain is compatible for all devices in the group,
2198-
* hence the iommu driver should always return success.
2199-
*/
2200-
struct iommu_domain *old_domain = group->domain;
2201-
2202-
group->domain = NULL;
2203-
WARN(__iommu_group_set_domain(group, old_domain),
2204-
"iommu driver failed to attach a compatible domain");
2205-
}
2206-
2207-
return ret;
2169+
return __iommu_group_set_domain(group, domain);
22082170
}
22092171

22102172
/**

0 commit comments

Comments
 (0)