Now we have four copies of this code, Linus "suggested" it was about time we stopped copying it and turned it into a helper.
Signed-off-by: David Woodhouse <[email protected]> --- We can still kill a lot more duplication by consolidating the DMA API and IOMMU API code. The only real difference is that the DMA API gets to allocate its own virtual addresses for things, which could be done externally (and that again would reduce duplication because we wouldn't need a separate allocator for each IOMMU. drivers/iommu/intel-iommu.c | 29 +++++++++++++---------------- 1 files changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 5fda348..67969bb 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -1906,6 +1906,15 @@ static void iommu_detach_dev(struct intel_iommu *iommu, u8 bus, u8 devfn) iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH); } +static inline void unlink_domain_info(struct device_domain_info *info) +{ + assert_spin_locked(&device_domain_lock); + list_del(&info->link); + list_del(&info->global); + if (info->dev) + info->dev->dev.archdata.iommu = NULL; +} + static void domain_remove_dev_info(struct dmar_domain *domain) { struct device_domain_info *info; @@ -1916,10 +1925,7 @@ static void domain_remove_dev_info(struct dmar_domain *domain) while (!list_empty(&domain->devices)) { info = list_entry(domain->devices.next, struct device_domain_info, link); - list_del(&info->link); - list_del(&info->global); - if (info->dev) - info->dev->dev.archdata.iommu = NULL; + unlink_domain_info(info); spin_unlock_irqrestore(&device_domain_lock, flags); iommu_disable_dev_iotlb(info); @@ -2301,9 +2307,7 @@ static int domain_add_dev_info(struct dmar_domain *domain, ret = domain_context_mapping(domain, pdev, translation); if (ret) { spin_lock_irqsave(&device_domain_lock, flags); - list_del(&info->link); - list_del(&info->global); - pdev->dev.archdata.iommu = NULL; + unlink_domain_info(info); spin_unlock_irqrestore(&device_domain_lock, flags); free_devinfo_mem(info); return ret; @@ -3732,10 +3736,7 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain, if (info->segment == pci_domain_nr(pdev->bus) && info->bus == pdev->bus->number && info->devfn == pdev->devfn) { - list_del(&info->link); - list_del(&info->global); - if (info->dev) - info->dev->dev.archdata.iommu = NULL; + unlink_domain_info(info); spin_unlock_irqrestore(&device_domain_lock, flags); iommu_disable_dev_iotlb(info); @@ -3790,11 +3791,7 @@ static void vm_domain_remove_all_dev_info(struct dmar_domain *domain) while (!list_empty(&domain->devices)) { info = list_entry(domain->devices.next, struct device_domain_info, link); - list_del(&info->link); - list_del(&info->global); - if (info->dev) - info->dev->dev.archdata.iommu = NULL; - + unlink_domain_info(info); spin_unlock_irqrestore(&device_domain_lock, flags1); iommu_disable_dev_iotlb(info); -- 1.7.7.6
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
