Skip to content

Commit c2a2876

Browse files
committed
iommu/amd: Make sure dma_ops are set for hotplug devices
There is a bug introduced with commit 27c2127 that causes devices which are hot unplugged and then hot-replugged to not have per-device dma_ops set. This causes these devices to not function correctly. Fixed with this patch. Cc: [email protected] Reported-by: Andreas Degert <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 4fdc782 commit c2a2876

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,18 +2466,16 @@ static int device_change_notifier(struct notifier_block *nb,
24662466

24672467
/* allocate a protection domain if a device is added */
24682468
dma_domain = find_protection_domain(devid);
2469-
if (dma_domain)
2470-
goto out;
2471-
dma_domain = dma_ops_domain_alloc();
2472-
if (!dma_domain)
2473-
goto out;
2474-
dma_domain->target_dev = devid;
2475-
2476-
spin_lock_irqsave(&iommu_pd_list_lock, flags);
2477-
list_add_tail(&dma_domain->list, &iommu_pd_list);
2478-
spin_unlock_irqrestore(&iommu_pd_list_lock, flags);
2479-
2480-
dev_data = get_dev_data(dev);
2469+
if (!dma_domain) {
2470+
dma_domain = dma_ops_domain_alloc();
2471+
if (!dma_domain)
2472+
goto out;
2473+
dma_domain->target_dev = devid;
2474+
2475+
spin_lock_irqsave(&iommu_pd_list_lock, flags);
2476+
list_add_tail(&dma_domain->list, &iommu_pd_list);
2477+
spin_unlock_irqrestore(&iommu_pd_list_lock, flags);
2478+
}
24812479

24822480
dev->archdata.dma_ops = &amd_iommu_dma_ops;
24832481

0 commit comments

Comments
 (0)