Skip to content

Commit

Permalink
iommu/amd: Split irq_lookup_table out of the amd_iommu_devtable_lock
Browse files Browse the repository at this point in the history
The function get_irq_table() reads/writes irq_lookup_table while holding
the amd_iommu_devtable_lock. It also modifies
amd_iommu_dev_table[].data[2].
set_dte_entry() is using amd_iommu_dev_table[].data[0|1] (under the
domain->lock) so it should be okay. The access to the iommu is
serialized with its own (iommu's) lock.

So split out get_irq_table() out of amd_iommu_devtable_lock's lock.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Sebastian Andrzej Siewior authored and Joerg Roedel committed Mar 29, 2018
1 parent 2bc0018 commit ea6166f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/iommu/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@

static DEFINE_RWLOCK(amd_iommu_devtable_lock);
static DEFINE_SPINLOCK(pd_bitmap_lock);
static DEFINE_SPINLOCK(iommu_table_lock);

/* List of all available dev_data structures */
static LLIST_HEAD(dev_data_list);
Expand Down Expand Up @@ -3623,7 +3624,7 @@ static struct irq_remap_table *alloc_irq_table(u16 devid, bool ioapic)
unsigned long flags;
u16 alias;

write_lock_irqsave(&amd_iommu_devtable_lock, flags);
spin_lock_irqsave(&iommu_table_lock, flags);

iommu = amd_iommu_rlookup_table[devid];
if (!iommu)
Expand Down Expand Up @@ -3688,7 +3689,7 @@ static struct irq_remap_table *alloc_irq_table(u16 devid, bool ioapic)
iommu_completion_wait(iommu);

out_unlock:
write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
spin_unlock_irqrestore(&iommu_table_lock, flags);

return table;
}
Expand Down

0 comments on commit ea6166f

Please sign in to comment.