iommu/amd: Split domain id out of amd_iommu_devtable_lock
domain_id_alloc() and domain_id_free() is used for id management. Those two function share a bitmap (amd_iommu_pd_alloc_bitmap) and set/clear bits based on id allocation. There is no need to share this with amd_iommu_devtable_lock, it can use its own lock for this operation. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
779da73273
commit
2bc0018089
|
@ -81,6 +81,7 @@
|
||||||
#define AMD_IOMMU_PGSIZES ((~0xFFFUL) & ~(2ULL << 38))
|
#define AMD_IOMMU_PGSIZES ((~0xFFFUL) & ~(2ULL << 38))
|
||||||
|
|
||||||
static DEFINE_RWLOCK(amd_iommu_devtable_lock);
|
static DEFINE_RWLOCK(amd_iommu_devtable_lock);
|
||||||
|
static DEFINE_SPINLOCK(pd_bitmap_lock);
|
||||||
|
|
||||||
/* List of all available dev_data structures */
|
/* List of all available dev_data structures */
|
||||||
static LLIST_HEAD(dev_data_list);
|
static LLIST_HEAD(dev_data_list);
|
||||||
|
@ -1600,29 +1601,26 @@ static void del_domain_from_list(struct protection_domain *domain)
|
||||||
|
|
||||||
static u16 domain_id_alloc(void)
|
static u16 domain_id_alloc(void)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
write_lock_irqsave(&amd_iommu_devtable_lock, flags);
|
spin_lock(&pd_bitmap_lock);
|
||||||
id = find_first_zero_bit(amd_iommu_pd_alloc_bitmap, MAX_DOMAIN_ID);
|
id = find_first_zero_bit(amd_iommu_pd_alloc_bitmap, MAX_DOMAIN_ID);
|
||||||
BUG_ON(id == 0);
|
BUG_ON(id == 0);
|
||||||
if (id > 0 && id < MAX_DOMAIN_ID)
|
if (id > 0 && id < MAX_DOMAIN_ID)
|
||||||
__set_bit(id, amd_iommu_pd_alloc_bitmap);
|
__set_bit(id, amd_iommu_pd_alloc_bitmap);
|
||||||
else
|
else
|
||||||
id = 0;
|
id = 0;
|
||||||
write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
|
spin_unlock(&pd_bitmap_lock);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void domain_id_free(int id)
|
static void domain_id_free(int id)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
spin_lock(&pd_bitmap_lock);
|
||||||
|
|
||||||
write_lock_irqsave(&amd_iommu_devtable_lock, flags);
|
|
||||||
if (id > 0 && id < MAX_DOMAIN_ID)
|
if (id > 0 && id < MAX_DOMAIN_ID)
|
||||||
__clear_bit(id, amd_iommu_pd_alloc_bitmap);
|
__clear_bit(id, amd_iommu_pd_alloc_bitmap);
|
||||||
write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
|
spin_unlock(&pd_bitmap_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEFINE_FREE_PT_FN(LVL, FN) \
|
#define DEFINE_FREE_PT_FN(LVL, FN) \
|
||||||
|
|
Loading…
Reference in New Issue