Skip to content

Commit 040a3c3

Browse files
committed
Merge tag 'iommu-fixes-v5.5-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: - Two fixes for VT-d and generic IOMMU code to fix teardown on error handling code paths. - Patch for the Intel VT-d driver to fix handling of non-PCI devices - Fix W=1 compile warning in dma-iommu code * tag 'iommu-fixes-v5.5-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/dma: fix variable 'cookie' set but not used iommu/vt-d: Unlink device if failed to add to group iommu: Remove device link to group on failure iommu/vt-d: Fix adding non-PCI devices to Intel IOMMU
2 parents 6327edc + 55817b3 commit 040a3c3

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

drivers/iommu/dma-iommu.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,6 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
12031203
{
12041204
struct device *dev = msi_desc_to_dev(desc);
12051205
struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
1206-
struct iommu_dma_cookie *cookie;
12071206
struct iommu_dma_msi_page *msi_page;
12081207
static DEFINE_MUTEX(msi_prepare_lock); /* see below */
12091208

@@ -1212,8 +1211,6 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
12121211
return 0;
12131212
}
12141213

1215-
cookie = domain->iova_cookie;
1216-
12171214
/*
12181215
* In fact the whole prepare operation should already be serialised by
12191216
* irq_domain_mutex further up the callchain, but that's pretty subtle

drivers/iommu/intel-iommu.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5624,8 +5624,10 @@ static int intel_iommu_add_device(struct device *dev)
56245624

56255625
group = iommu_group_get_for_dev(dev);
56265626

5627-
if (IS_ERR(group))
5628-
return PTR_ERR(group);
5627+
if (IS_ERR(group)) {
5628+
ret = PTR_ERR(group);
5629+
goto unlink;
5630+
}
56295631

56305632
iommu_group_put(group);
56315633

@@ -5651,7 +5653,8 @@ static int intel_iommu_add_device(struct device *dev)
56515653
if (!get_private_domain_for_dev(dev)) {
56525654
dev_warn(dev,
56535655
"Failed to get a private domain.\n");
5654-
return -ENOMEM;
5656+
ret = -ENOMEM;
5657+
goto unlink;
56555658
}
56565659

56575660
dev_info(dev,
@@ -5666,6 +5669,10 @@ static int intel_iommu_add_device(struct device *dev)
56665669
}
56675670

56685671
return 0;
5672+
5673+
unlink:
5674+
iommu_device_unlink(&iommu->iommu, dev);
5675+
return ret;
56695676
}
56705677

56715678
static void intel_iommu_remove_device(struct device *dev)
@@ -5817,6 +5824,13 @@ static void intel_iommu_apply_resv_region(struct device *dev,
58175824
WARN_ON_ONCE(!reserve_iova(&dmar_domain->iovad, start, end));
58185825
}
58195826

5827+
static struct iommu_group *intel_iommu_device_group(struct device *dev)
5828+
{
5829+
if (dev_is_pci(dev))
5830+
return pci_device_group(dev);
5831+
return generic_device_group(dev);
5832+
}
5833+
58205834
#ifdef CONFIG_INTEL_IOMMU_SVM
58215835
struct intel_iommu *intel_svm_device_to_iommu(struct device *dev)
58225836
{
@@ -5989,7 +6003,7 @@ const struct iommu_ops intel_iommu_ops = {
59896003
.get_resv_regions = intel_iommu_get_resv_regions,
59906004
.put_resv_regions = intel_iommu_put_resv_regions,
59916005
.apply_resv_region = intel_iommu_apply_resv_region,
5992-
.device_group = pci_device_group,
6006+
.device_group = intel_iommu_device_group,
59936007
.dev_has_feat = intel_iommu_dev_has_feat,
59946008
.dev_feat_enabled = intel_iommu_dev_feat_enabled,
59956009
.dev_enable_feat = intel_iommu_dev_enable_feat,

drivers/iommu/iommu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev)
751751
mutex_unlock(&group->mutex);
752752
dev->iommu_group = NULL;
753753
kobject_put(group->devices_kobj);
754+
sysfs_remove_link(group->devices_kobj, device->name);
754755
err_free_name:
755756
kfree(device->name);
756757
err_remove_link:

0 commit comments

Comments
 (0)