70
70
*/
71
71
#define AMD_IOMMU_PGSIZES ((~0xFFFUL) & ~(2ULL << 38))
72
72
73
- static DEFINE_SPINLOCK (amd_iommu_devtable_lock );
74
73
static DEFINE_SPINLOCK (pd_bitmap_lock );
75
74
76
75
/* List of all available dev_data structures */
@@ -2080,10 +2079,11 @@ static void do_detach(struct iommu_dev_data *dev_data)
2080
2079
static int __attach_device (struct iommu_dev_data * dev_data ,
2081
2080
struct protection_domain * domain )
2082
2081
{
2082
+ unsigned long flags ;
2083
2083
int ret ;
2084
2084
2085
2085
/* lock domain */
2086
- spin_lock (& domain -> lock );
2086
+ spin_lock_irqsave (& domain -> lock , flags );
2087
2087
2088
2088
ret = - EBUSY ;
2089
2089
if (dev_data -> domain != NULL )
@@ -2097,7 +2097,7 @@ static int __attach_device(struct iommu_dev_data *dev_data,
2097
2097
out_unlock :
2098
2098
2099
2099
/* ready */
2100
- spin_unlock (& domain -> lock );
2100
+ spin_unlock_irqrestore (& domain -> lock , flags );
2101
2101
2102
2102
return ret ;
2103
2103
}
@@ -2181,7 +2181,6 @@ static int attach_device(struct device *dev,
2181
2181
{
2182
2182
struct pci_dev * pdev ;
2183
2183
struct iommu_dev_data * dev_data ;
2184
- unsigned long flags ;
2185
2184
int ret ;
2186
2185
2187
2186
dev_data = get_dev_data (dev );
@@ -2209,9 +2208,7 @@ static int attach_device(struct device *dev,
2209
2208
}
2210
2209
2211
2210
skip_ats_check :
2212
- spin_lock_irqsave (& amd_iommu_devtable_lock , flags );
2213
2211
ret = __attach_device (dev_data , domain );
2214
- spin_unlock_irqrestore (& amd_iommu_devtable_lock , flags );
2215
2212
2216
2213
/*
2217
2214
* We might boot into a crash-kernel here. The crashed kernel
@@ -2231,14 +2228,15 @@ static int attach_device(struct device *dev,
2231
2228
static void __detach_device (struct iommu_dev_data * dev_data )
2232
2229
{
2233
2230
struct protection_domain * domain ;
2231
+ unsigned long flags ;
2234
2232
2235
2233
domain = dev_data -> domain ;
2236
2234
2237
- spin_lock (& domain -> lock );
2235
+ spin_lock_irqsave (& domain -> lock , flags );
2238
2236
2239
2237
do_detach (dev_data );
2240
2238
2241
- spin_unlock (& domain -> lock );
2239
+ spin_unlock_irqrestore (& domain -> lock , flags );
2242
2240
}
2243
2241
2244
2242
/*
@@ -2248,7 +2246,6 @@ static void detach_device(struct device *dev)
2248
2246
{
2249
2247
struct protection_domain * domain ;
2250
2248
struct iommu_dev_data * dev_data ;
2251
- unsigned long flags ;
2252
2249
2253
2250
dev_data = get_dev_data (dev );
2254
2251
domain = dev_data -> domain ;
@@ -2262,10 +2259,7 @@ static void detach_device(struct device *dev)
2262
2259
if (WARN_ON (!dev_data -> domain ))
2263
2260
return ;
2264
2261
2265
- /* lock device table */
2266
- spin_lock_irqsave (& amd_iommu_devtable_lock , flags );
2267
2262
__detach_device (dev_data );
2268
- spin_unlock_irqrestore (& amd_iommu_devtable_lock , flags );
2269
2263
2270
2264
if (!dev_is_pci (dev ))
2271
2265
return ;
@@ -2910,18 +2904,13 @@ int __init amd_iommu_init_dma_ops(void)
2910
2904
static void cleanup_domain (struct protection_domain * domain )
2911
2905
{
2912
2906
struct iommu_dev_data * entry ;
2913
- unsigned long flags ;
2914
-
2915
- spin_lock_irqsave (& amd_iommu_devtable_lock , flags );
2916
2907
2917
2908
while (!list_empty (& domain -> dev_list )) {
2918
2909
entry = list_first_entry (& domain -> dev_list ,
2919
2910
struct iommu_dev_data , list );
2920
2911
BUG_ON (!entry -> domain );
2921
2912
__detach_device (entry );
2922
2913
}
2923
-
2924
- spin_unlock_irqrestore (& amd_iommu_devtable_lock , flags );
2925
2914
}
2926
2915
2927
2916
static void protection_domain_free (struct protection_domain * domain )
0 commit comments