diff options
author | David Woodhouse <dwmw2@infradead.org> | 2012-05-25 12:43:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-25 18:50:29 -0400 |
commit | 109b9b0408e5f1dd327a44f446841a9fbe0bcd83 (patch) | |
tree | 76b7b0278ef00b388e35183bb3aaff1f8ed82be4 /drivers/iommu/intel-iommu.c | |
parent | e2ad23d04c1304431ab5176c89b7b476ded2d995 (diff) |
intel-iommu: Move duplicate list-mangling code into unlink_domain_info() helper
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 <David.Woodhouse@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/iommu/intel-iommu.c')
-rw-r--r-- | 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 abab245371ee..b12af2ff8c54 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -1907,6 +1907,15 @@ static void iommu_detach_dev(struct intel_iommu *iommu, u8 bus, u8 devfn) | |||
1907 | iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH); | 1907 | iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH); |
1908 | } | 1908 | } |
1909 | 1909 | ||
1910 | static inline void unlink_domain_info(struct device_domain_info *info) | ||
1911 | { | ||
1912 | assert_spin_locked(&device_domain_lock); | ||
1913 | list_del(&info->link); | ||
1914 | list_del(&info->global); | ||
1915 | if (info->dev) | ||
1916 | info->dev->dev.archdata.iommu = NULL; | ||
1917 | } | ||
1918 | |||
1910 | static void domain_remove_dev_info(struct dmar_domain *domain) | 1919 | static void domain_remove_dev_info(struct dmar_domain *domain) |
1911 | { | 1920 | { |
1912 | struct device_domain_info *info; | 1921 | struct device_domain_info *info; |
@@ -1917,10 +1926,7 @@ static void domain_remove_dev_info(struct dmar_domain *domain) | |||
1917 | while (!list_empty(&domain->devices)) { | 1926 | while (!list_empty(&domain->devices)) { |
1918 | info = list_entry(domain->devices.next, | 1927 | info = list_entry(domain->devices.next, |
1919 | struct device_domain_info, link); | 1928 | struct device_domain_info, link); |
1920 | list_del(&info->link); | 1929 | unlink_domain_info(info); |
1921 | list_del(&info->global); | ||
1922 | if (info->dev) | ||
1923 | info->dev->dev.archdata.iommu = NULL; | ||
1924 | spin_unlock_irqrestore(&device_domain_lock, flags); | 1930 | spin_unlock_irqrestore(&device_domain_lock, flags); |
1925 | 1931 | ||
1926 | iommu_disable_dev_iotlb(info); | 1932 | iommu_disable_dev_iotlb(info); |
@@ -2302,9 +2308,7 @@ static int domain_add_dev_info(struct dmar_domain *domain, | |||
2302 | ret = domain_context_mapping(domain, pdev, translation); | 2308 | ret = domain_context_mapping(domain, pdev, translation); |
2303 | if (ret) { | 2309 | if (ret) { |
2304 | spin_lock_irqsave(&device_domain_lock, flags); | 2310 | spin_lock_irqsave(&device_domain_lock, flags); |
2305 | list_del(&info->link); | 2311 | unlink_domain_info(info); |
2306 | list_del(&info->global); | ||
2307 | pdev->dev.archdata.iommu = NULL; | ||
2308 | spin_unlock_irqrestore(&device_domain_lock, flags); | 2312 | spin_unlock_irqrestore(&device_domain_lock, flags); |
2309 | free_devinfo_mem(info); | 2313 | free_devinfo_mem(info); |
2310 | return ret; | 2314 | return ret; |
@@ -3733,10 +3737,7 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain, | |||
3733 | if (info->segment == pci_domain_nr(pdev->bus) && | 3737 | if (info->segment == pci_domain_nr(pdev->bus) && |
3734 | info->bus == pdev->bus->number && | 3738 | info->bus == pdev->bus->number && |
3735 | info->devfn == pdev->devfn) { | 3739 | info->devfn == pdev->devfn) { |
3736 | list_del(&info->link); | 3740 | unlink_domain_info(info); |
3737 | list_del(&info->global); | ||
3738 | if (info->dev) | ||
3739 | info->dev->dev.archdata.iommu = NULL; | ||
3740 | spin_unlock_irqrestore(&device_domain_lock, flags); | 3741 | spin_unlock_irqrestore(&device_domain_lock, flags); |
3741 | 3742 | ||
3742 | iommu_disable_dev_iotlb(info); | 3743 | iommu_disable_dev_iotlb(info); |
@@ -3791,11 +3792,7 @@ static void vm_domain_remove_all_dev_info(struct dmar_domain *domain) | |||
3791 | while (!list_empty(&domain->devices)) { | 3792 | while (!list_empty(&domain->devices)) { |
3792 | info = list_entry(domain->devices.next, | 3793 | info = list_entry(domain->devices.next, |
3793 | struct device_domain_info, link); | 3794 | struct device_domain_info, link); |
3794 | list_del(&info->link); | 3795 | unlink_domain_info(info); |
3795 | list_del(&info->global); | ||
3796 | if (info->dev) | ||
3797 | info->dev->dev.archdata.iommu = NULL; | ||
3798 | |||
3799 | spin_unlock_irqrestore(&device_domain_lock, flags1); | 3796 | spin_unlock_irqrestore(&device_domain_lock, flags1); |
3800 | 3797 | ||
3801 | iommu_disable_dev_iotlb(info); | 3798 | iommu_disable_dev_iotlb(info); |