aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2018-03-22 11:22:35 -0400
committerJoerg Roedel <jroedel@suse.de>2018-03-29 04:38:15 -0400
commit2bc00180890427dcc092b2f2b0d03c904bcade29 (patch)
tree5cf7d4442c55b5b062e928a0d85aeea69d9d8ac2
parent779da73273fc4c4c6f41579a95e4fb7880a1720e (diff)
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>
-rw-r--r--drivers/iommu/amd_iommu.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index d4c2b1a11924..fcfdce70707d 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -81,6 +81,7 @@
81#define AMD_IOMMU_PGSIZES ((~0xFFFUL) & ~(2ULL << 38)) 81#define AMD_IOMMU_PGSIZES ((~0xFFFUL) & ~(2ULL << 38))
82 82
83static DEFINE_RWLOCK(amd_iommu_devtable_lock); 83static DEFINE_RWLOCK(amd_iommu_devtable_lock);
84static DEFINE_SPINLOCK(pd_bitmap_lock);
84 85
85/* List of all available dev_data structures */ 86/* List of all available dev_data structures */
86static LLIST_HEAD(dev_data_list); 87static LLIST_HEAD(dev_data_list);
@@ -1600,29 +1601,26 @@ static void del_domain_from_list(struct protection_domain *domain)
1600 1601
1601static u16 domain_id_alloc(void) 1602static u16 domain_id_alloc(void)
1602{ 1603{
1603 unsigned long flags;
1604 int id; 1604 int id;
1605 1605
1606 write_lock_irqsave(&amd_iommu_devtable_lock, flags); 1606 spin_lock(&pd_bitmap_lock);
1607 id = find_first_zero_bit(amd_iommu_pd_alloc_bitmap, MAX_DOMAIN_ID); 1607 id = find_first_zero_bit(amd_iommu_pd_alloc_bitmap, MAX_DOMAIN_ID);
1608 BUG_ON(id == 0); 1608 BUG_ON(id == 0);
1609 if (id > 0 && id < MAX_DOMAIN_ID) 1609 if (id > 0 && id < MAX_DOMAIN_ID)
1610 __set_bit(id, amd_iommu_pd_alloc_bitmap); 1610 __set_bit(id, amd_iommu_pd_alloc_bitmap);
1611 else 1611 else
1612 id = 0; 1612 id = 0;
1613 write_unlock_irqrestore(&amd_iommu_devtable_lock, flags); 1613 spin_unlock(&pd_bitmap_lock);
1614 1614
1615 return id; 1615 return id;
1616} 1616}
1617 1617
1618static void domain_id_free(int id) 1618static void domain_id_free(int id)
1619{ 1619{
1620 unsigned long flags; 1620 spin_lock(&pd_bitmap_lock);
1621
1622 write_lock_irqsave(&amd_iommu_devtable_lock, flags);
1623 if (id > 0 && id < MAX_DOMAIN_ID) 1621 if (id > 0 && id < MAX_DOMAIN_ID)
1624 __clear_bit(id, amd_iommu_pd_alloc_bitmap); 1622 __clear_bit(id, amd_iommu_pd_alloc_bitmap);
1625 write_unlock_irqrestore(&amd_iommu_devtable_lock, flags); 1623 spin_unlock(&pd_bitmap_lock);
1626} 1624}
1627 1625
1628#define DEFINE_FREE_PT_FN(LVL, FN) \ 1626#define DEFINE_FREE_PT_FN(LVL, FN) \