summaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2023-05-11 06:42:03 +0200
committerJoerg Roedel <jroedel@suse.de>2023-05-23 08:15:52 +0200
commit4c8ad9da05662141928fe4ed001d3775fd95221c (patch)
treeb66600c2cddc195e47b98ce63553d0da9f93f798 /drivers/iommu
parentiommu: Use __iommu_group_set_domain() for __iommu_attach_group() (diff)
downloadlinux-4c8ad9da05662141928fe4ed001d3775fd95221c.tar.xz
linux-4c8ad9da05662141928fe4ed001d3775fd95221c.zip
iommu: Use __iommu_group_set_domain() in iommu_change_dev_def_domain()
This is missing re-attach error handling if the attach fails, use the common code. The ugly "group->domain = prev_domain" will be cleaned in a later patch. Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Kevin Tian <kevin.tian@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/5-v5-1b99ae392328+44574-iommu_err_unwind_jgg@nvidia.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/iommu.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index f31ba66ccb2f..e0bfb114d08d 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2946,11 +2946,12 @@ static int iommu_change_dev_def_domain(struct iommu_group *group,
if (ret)
goto restore_old_domain;
- ret = iommu_group_create_direct_mappings(group);
+ group->domain = prev_dom;
+ ret = iommu_create_device_direct_mappings(group, dev);
if (ret)
goto free_new_domain;
- ret = __iommu_attach_group(group->default_domain, group);
+ ret = __iommu_group_set_domain(group, group->default_domain);
if (ret)
goto free_new_domain;
@@ -2962,7 +2963,6 @@ free_new_domain:
iommu_domain_free(group->default_domain);
restore_old_domain:
group->default_domain = prev_dom;
- group->domain = prev_dom;
return ret;
}