Skip to content

Commit 152431e

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu: Do iommu_group_create_direct_mappings() before attach
The iommu_probe_device() path calls iommu_create_device_direct_mappings() after attaching the device. IOMMU_RESV_DIRECT maps need to be continually in place, so if a hotplugged device has new ranges the should have been mapped into the default domain before it is attached. Move the iommu_create_device_direct_mappings() call up. Reviewed-by: Lu Baolu <[email protected]> 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 e7f85df commit 152431e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/iommu/iommu.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ int iommu_probe_device(struct device *dev)
423423

424424
mutex_lock(&group->mutex);
425425

426+
iommu_create_device_direct_mappings(group, dev);
427+
426428
if (group->domain) {
427429
ret = __iommu_device_set_domain(group, dev, group->domain, 0);
428430
} else if (!group->default_domain) {
@@ -434,9 +436,11 @@ int iommu_probe_device(struct device *dev)
434436
*/
435437
iommu_alloc_default_domain(group, dev);
436438
group->domain = NULL;
437-
if (group->default_domain)
439+
if (group->default_domain) {
440+
iommu_create_device_direct_mappings(group, dev);
438441
ret = __iommu_group_set_domain(group,
439442
group->default_domain);
443+
}
440444

441445
/*
442446
* We assume that the iommu driver starts up the device in
@@ -447,8 +451,6 @@ int iommu_probe_device(struct device *dev)
447451
if (ret)
448452
goto err_unlock;
449453

450-
iommu_create_device_direct_mappings(group, dev);
451-
452454
mutex_unlock(&group->mutex);
453455
iommu_group_put(group);
454456

0 commit comments

Comments
 (0)