aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iommu/amd_iommu.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index ec5faf6db570..92241ffab455 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1915,15 +1915,6 @@ static void do_detach(struct iommu_dev_data *dev_data)
1915 struct amd_iommu *iommu; 1915 struct amd_iommu *iommu;
1916 u16 alias; 1916 u16 alias;
1917 1917
1918 /*
1919 * First check if the device is still attached. It might already
1920 * be detached from its domain because the generic
1921 * iommu_detach_group code detached it and we try again here in
1922 * our alias handling.
1923 */
1924 if (!dev_data->domain)
1925 return;
1926
1927 iommu = amd_iommu_rlookup_table[dev_data->devid]; 1918 iommu = amd_iommu_rlookup_table[dev_data->devid];
1928 alias = dev_data->alias; 1919 alias = dev_data->alias;
1929 1920
@@ -2128,9 +2119,6 @@ static void __detach_device(struct iommu_dev_data *dev_data)
2128 */ 2119 */
2129 WARN_ON(!irqs_disabled()); 2120 WARN_ON(!irqs_disabled());
2130 2121
2131 if (WARN_ON(!dev_data->domain))
2132 return;
2133
2134 domain = dev_data->domain; 2122 domain = dev_data->domain;
2135 2123
2136 spin_lock(&domain->lock); 2124 spin_lock(&domain->lock);
@@ -2152,6 +2140,15 @@ static void detach_device(struct device *dev)
2152 dev_data = get_dev_data(dev); 2140 dev_data = get_dev_data(dev);
2153 domain = dev_data->domain; 2141 domain = dev_data->domain;
2154 2142
2143 /*
2144 * First check if the device is still attached. It might already
2145 * be detached from its domain because the generic
2146 * iommu_detach_group code detached it and we try again here in
2147 * our alias handling.
2148 */
2149 if (WARN_ON(!dev_data->domain))
2150 return;
2151
2155 /* lock device table */ 2152 /* lock device table */
2156 spin_lock_irqsave(&amd_iommu_devtable_lock, flags); 2153 spin_lock_irqsave(&amd_iommu_devtable_lock, flags);
2157 __detach_device(dev_data); 2154 __detach_device(dev_data);
@@ -2797,6 +2794,7 @@ static void cleanup_domain(struct protection_domain *domain)
2797 while (!list_empty(&domain->dev_list)) { 2794 while (!list_empty(&domain->dev_list)) {
2798 entry = list_first_entry(&domain->dev_list, 2795 entry = list_first_entry(&domain->dev_list,
2799 struct iommu_dev_data, list); 2796 struct iommu_dev_data, list);
2797 BUG_ON(!entry->domain);
2800 __detach_device(entry); 2798 __detach_device(entry);
2801 } 2799 }
2802 2800