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

Changed files
+19 -7
drivers
-3
drivers/iommu/dma-iommu.c
··· 1203 1203 { 1204 1204 struct device *dev = msi_desc_to_dev(desc); 1205 1205 struct iommu_domain *domain = iommu_get_domain_for_dev(dev); 1206 - struct iommu_dma_cookie *cookie; 1207 1206 struct iommu_dma_msi_page *msi_page; 1208 1207 static DEFINE_MUTEX(msi_prepare_lock); /* see below */ 1209 1208 ··· 1210 1211 desc->iommu_cookie = NULL; 1211 1212 return 0; 1212 1213 } 1213 - 1214 - cookie = domain->iova_cookie; 1215 1214 1216 1215 /* 1217 1216 * In fact the whole prepare operation should already be serialised by
+18 -4
drivers/iommu/intel-iommu.c
··· 5624 5624 5625 5625 group = iommu_group_get_for_dev(dev); 5626 5626 5627 - if (IS_ERR(group)) 5628 - return PTR_ERR(group); 5627 + if (IS_ERR(group)) { 5628 + ret = PTR_ERR(group); 5629 + goto unlink; 5630 + } 5629 5631 5630 5632 iommu_group_put(group); 5631 5633 ··· 5653 5651 if (!get_private_domain_for_dev(dev)) { 5654 5652 dev_warn(dev, 5655 5653 "Failed to get a private domain.\n"); 5656 - return -ENOMEM; 5654 + ret = -ENOMEM; 5655 + goto unlink; 5657 5656 } 5658 5657 5659 5658 dev_info(dev, ··· 5669 5666 } 5670 5667 5671 5668 return 0; 5669 + 5670 + unlink: 5671 + iommu_device_unlink(&iommu->iommu, dev); 5672 + return ret; 5672 5673 } 5673 5674 5674 5675 static void intel_iommu_remove_device(struct device *dev) ··· 5822 5815 end = IOVA_PFN(region->start + region->length - 1); 5823 5816 5824 5817 WARN_ON_ONCE(!reserve_iova(&dmar_domain->iovad, start, end)); 5818 + } 5819 + 5820 + static struct iommu_group *intel_iommu_device_group(struct device *dev) 5821 + { 5822 + if (dev_is_pci(dev)) 5823 + return pci_device_group(dev); 5824 + return generic_device_group(dev); 5825 5825 } 5826 5826 5827 5827 #ifdef CONFIG_INTEL_IOMMU_SVM ··· 6003 5989 .get_resv_regions = intel_iommu_get_resv_regions, 6004 5990 .put_resv_regions = intel_iommu_put_resv_regions, 6005 5991 .apply_resv_region = intel_iommu_apply_resv_region, 6006 - .device_group = pci_device_group, 5992 + .device_group = intel_iommu_device_group, 6007 5993 .dev_has_feat = intel_iommu_dev_has_feat, 6008 5994 .dev_feat_enabled = intel_iommu_dev_feat_enabled, 6009 5995 .dev_enable_feat = intel_iommu_dev_enable_feat,
+1
drivers/iommu/iommu.c
··· 751 751 mutex_unlock(&group->mutex); 752 752 dev->iommu_group = NULL; 753 753 kobject_put(group->devices_kobj); 754 + sysfs_remove_link(group->devices_kobj, device->name); 754 755 err_free_name: 755 756 kfree(device->name); 756 757 err_remove_link: