2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-22 20:23:57 +08:00

iommu/amd: Factor out setting the remap table for a devid

Setting the IRQ remap table for a specific devid (or its alias devid)
includes three steps. Those three steps are always repeated each time
this is done.
Introduce a new helper function, move those steps there and use that
function instead. The compiler can still decide if it is worth to
inline.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
Sebastian Andrzej Siewior 2018-03-22 16:22:39 +01:00 committed by Joerg Roedel
parent 4fde541c9d
commit 2fcc1e8ac4

View File

@ -3617,6 +3617,14 @@ static struct irq_remap_table *get_irq_table(u16 devid)
return table; return table;
} }
static void set_remap_table_entry(struct amd_iommu *iommu, u16 devid,
struct irq_remap_table *table)
{
irq_lookup_table[devid] = table;
set_dte_irq_entry(devid, table);
iommu_flush_dte(iommu, devid);
}
static struct irq_remap_table *alloc_irq_table(u16 devid) static struct irq_remap_table *alloc_irq_table(u16 devid)
{ {
struct irq_remap_table *table = NULL; struct irq_remap_table *table = NULL;
@ -3637,9 +3645,7 @@ static struct irq_remap_table *alloc_irq_table(u16 devid)
alias = amd_iommu_alias_table[devid]; alias = amd_iommu_alias_table[devid];
table = irq_lookup_table[alias]; table = irq_lookup_table[alias];
if (table) { if (table) {
irq_lookup_table[devid] = table; set_remap_table_entry(iommu, devid, table);
set_dte_irq_entry(devid, table);
iommu_flush_dte(iommu, devid);
goto out; goto out;
} }
@ -3666,14 +3672,9 @@ static struct irq_remap_table *alloc_irq_table(u16 devid)
(MAX_IRQS_PER_TABLE * (sizeof(u64) * 2))); (MAX_IRQS_PER_TABLE * (sizeof(u64) * 2)));
irq_lookup_table[devid] = table; set_remap_table_entry(iommu, devid, table);
set_dte_irq_entry(devid, table); if (devid != alias)
iommu_flush_dte(iommu, devid); set_remap_table_entry(iommu, alias, table);
if (devid != alias) {
irq_lookup_table[alias] = table;
set_dte_irq_entry(alias, table);
iommu_flush_dte(iommu, alias);
}
out: out:
iommu_completion_wait(iommu); iommu_completion_wait(iommu);