Commit 040a3c33 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 6327edce 55817b34
...@@ -1203,7 +1203,6 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr) ...@@ -1203,7 +1203,6 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
{ {
struct device *dev = msi_desc_to_dev(desc); struct device *dev = msi_desc_to_dev(desc);
struct iommu_domain *domain = iommu_get_domain_for_dev(dev); struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
struct iommu_dma_cookie *cookie;
struct iommu_dma_msi_page *msi_page; struct iommu_dma_msi_page *msi_page;
static DEFINE_MUTEX(msi_prepare_lock); /* see below */ static DEFINE_MUTEX(msi_prepare_lock); /* see below */
...@@ -1212,8 +1211,6 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr) ...@@ -1212,8 +1211,6 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
return 0; return 0;
} }
cookie = domain->iova_cookie;
/* /*
* In fact the whole prepare operation should already be serialised by * In fact the whole prepare operation should already be serialised by
* irq_domain_mutex further up the callchain, but that's pretty subtle * irq_domain_mutex further up the callchain, but that's pretty subtle
......
...@@ -5624,8 +5624,10 @@ static int intel_iommu_add_device(struct device *dev) ...@@ -5624,8 +5624,10 @@ static int intel_iommu_add_device(struct device *dev)
group = iommu_group_get_for_dev(dev); group = iommu_group_get_for_dev(dev);
if (IS_ERR(group)) if (IS_ERR(group)) {
return PTR_ERR(group); ret = PTR_ERR(group);
goto unlink;
}
iommu_group_put(group); iommu_group_put(group);
...@@ -5651,7 +5653,8 @@ static int intel_iommu_add_device(struct device *dev) ...@@ -5651,7 +5653,8 @@ static int intel_iommu_add_device(struct device *dev)
if (!get_private_domain_for_dev(dev)) { if (!get_private_domain_for_dev(dev)) {
dev_warn(dev, dev_warn(dev,
"Failed to get a private domain.\n"); "Failed to get a private domain.\n");
return -ENOMEM; ret = -ENOMEM;
goto unlink;
} }
dev_info(dev, dev_info(dev,
...@@ -5666,6 +5669,10 @@ static int intel_iommu_add_device(struct device *dev) ...@@ -5666,6 +5669,10 @@ static int intel_iommu_add_device(struct device *dev)
} }
return 0; return 0;
unlink:
iommu_device_unlink(&iommu->iommu, dev);
return ret;
} }
static void intel_iommu_remove_device(struct device *dev) static void intel_iommu_remove_device(struct device *dev)
...@@ -5817,6 +5824,13 @@ static void intel_iommu_apply_resv_region(struct device *dev, ...@@ -5817,6 +5824,13 @@ static void intel_iommu_apply_resv_region(struct device *dev,
WARN_ON_ONCE(!reserve_iova(&dmar_domain->iovad, start, end)); WARN_ON_ONCE(!reserve_iova(&dmar_domain->iovad, start, end));
} }
static struct iommu_group *intel_iommu_device_group(struct device *dev)
{
if (dev_is_pci(dev))
return pci_device_group(dev);
return generic_device_group(dev);
}
#ifdef CONFIG_INTEL_IOMMU_SVM #ifdef CONFIG_INTEL_IOMMU_SVM
struct intel_iommu *intel_svm_device_to_iommu(struct device *dev) struct intel_iommu *intel_svm_device_to_iommu(struct device *dev)
{ {
...@@ -5989,7 +6003,7 @@ const struct iommu_ops intel_iommu_ops = { ...@@ -5989,7 +6003,7 @@ const struct iommu_ops intel_iommu_ops = {
.get_resv_regions = intel_iommu_get_resv_regions, .get_resv_regions = intel_iommu_get_resv_regions,
.put_resv_regions = intel_iommu_put_resv_regions, .put_resv_regions = intel_iommu_put_resv_regions,
.apply_resv_region = intel_iommu_apply_resv_region, .apply_resv_region = intel_iommu_apply_resv_region,
.device_group = pci_device_group, .device_group = intel_iommu_device_group,
.dev_has_feat = intel_iommu_dev_has_feat, .dev_has_feat = intel_iommu_dev_has_feat,
.dev_feat_enabled = intel_iommu_dev_feat_enabled, .dev_feat_enabled = intel_iommu_dev_feat_enabled,
.dev_enable_feat = intel_iommu_dev_enable_feat, .dev_enable_feat = intel_iommu_dev_enable_feat,
......
...@@ -751,6 +751,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev) ...@@ -751,6 +751,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev)
mutex_unlock(&group->mutex); mutex_unlock(&group->mutex);
dev->iommu_group = NULL; dev->iommu_group = NULL;
kobject_put(group->devices_kobj); kobject_put(group->devices_kobj);
sysfs_remove_link(group->devices_kobj, device->name);
err_free_name: err_free_name:
kfree(device->name); kfree(device->name);
err_remove_link: err_remove_link:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment