Skip to content

Commit 1ae45cf

Browse files
committed
Merge tag 'iommu-fixes-v3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull IOMMU fixes from Joerg Roedel: "The fixes include: - fix a crash in the VT-d driver when devices with a driver attached are hot-unplugged - fix a AMD IOMMU driver crash with device assignment of 32 bit PCI devices to KVM guests - fix for a copy&paste error in generic IOMMU code. Now the right function pointer is checked before calling" * tag 'iommu-fixes-v3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/core: Check for the right function pointer in iommu_map() iommu/amd: Fix cleanup_domain for mass device removal iommu/vt-d: Defer domain removal if device is assigned to a driver
2 parents 5317821 + 9db4ad9 commit 1ae45cf

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,14 +3149,16 @@ int __init amd_iommu_init_dma_ops(void)
31493149

31503150
static void cleanup_domain(struct protection_domain *domain)
31513151
{
3152-
struct iommu_dev_data *dev_data, *next;
3152+
struct iommu_dev_data *entry;
31533153
unsigned long flags;
31543154

31553155
write_lock_irqsave(&amd_iommu_devtable_lock, flags);
31563156

3157-
list_for_each_entry_safe(dev_data, next, &domain->dev_list, list) {
3158-
__detach_device(dev_data);
3159-
atomic_set(&dev_data->bind, 0);
3157+
while (!list_empty(&domain->dev_list)) {
3158+
entry = list_first_entry(&domain->dev_list,
3159+
struct iommu_dev_data, list);
3160+
__detach_device(entry);
3161+
atomic_set(&entry->bind, 0);
31603162
}
31613163

31623164
write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);

drivers/iommu/intel-iommu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3869,6 +3869,14 @@ static int device_notifier(struct notifier_block *nb,
38693869
action != BUS_NOTIFY_DEL_DEVICE)
38703870
return 0;
38713871

3872+
/*
3873+
* If the device is still attached to a device driver we can't
3874+
* tear down the domain yet as DMA mappings may still be in use.
3875+
* Wait for the BUS_NOTIFY_UNBOUND_DRIVER event to do that.
3876+
*/
3877+
if (action == BUS_NOTIFY_DEL_DEVICE && dev->driver != NULL)
3878+
return 0;
3879+
38723880
domain = find_domain(dev);
38733881
if (!domain)
38743882
return 0;

drivers/iommu/iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
995995
size_t orig_size = size;
996996
int ret = 0;
997997

998-
if (unlikely(domain->ops->unmap == NULL ||
998+
if (unlikely(domain->ops->map == NULL ||
999999
domain->ops->pgsize_bitmap == 0UL))
10001000
return -ENODEV;
10011001

0 commit comments

Comments
 (0)