alias = amd_iommu_alias_table[devid];
table = irq_lookup_table[alias];
if (table) {
-------- irq_lookup_table[devid] = table;
-------- set_dte_irq_entry(devid, table);
-------- iommu_flush_dte(iommu, devid);
-------- goto out;
++++++++ set_remap_table_entry(iommu, devid, table);
++++++++ goto out_wait;
}
++++++++ spin_unlock_irqrestore(&iommu_table_lock, flags);
/* Nothing there yet, allocate new irq remapping table */
-------- table = kzalloc(sizeof(*table), GFP_ATOMIC);
-------- if (!table)
-------- goto out_unlock;
--------
-------- /* Initialize table spin-lock */
-------- spin_lock_init(&table->lock);
++++++++ new_table = __alloc_irq_table();
++++++++ if (!new_table)
++++++++ return NULL;
-------- if (ioapic)
-------- /* Keep the first 32 indexes free for IOAPIC interrupts */
-------- table->min_index = 32;
++++++++ spin_lock_irqsave(&iommu_table_lock, flags);
-------- table->table = kmem_cache_alloc(amd_iommu_irq_cache, GFP_ATOMIC);
-------- if (!table->table) {
-------- kfree(table);
-------- table = NULL;
++++++++ table = irq_lookup_table[devid];
++++++++ if (table)
goto out_unlock;
-------- }
-
- if (!AMD_IOMMU_GUEST_IR_GA(amd_iommu_guest_ir))
- memset(table->table, 0,
- MAX_IRQS_PER_TABLE * sizeof(u32));
- else
- memset(table->table, 0,
- (MAX_IRQS_PER_TABLE * (sizeof(u64) * 2)));
------- if (!AMD_IOMMU_GUEST_IR_GA(amd_iommu_guest_ir))
------- memset(table->table, 0,
------- MAX_IRQS_PER_TABLE * sizeof(u32));
------- else
------- memset(table->table, 0,
------- (MAX_IRQS_PER_TABLE * (sizeof(u64) * 2)));
-------
-------- if (ioapic) {
-------- int i;
--------
-------- for (i = 0; i < 32; ++i)
-------- iommu->irte_ops->set_allocated(table, i);
++++++++ table = irq_lookup_table[alias];
++++++++ if (table) {
++++++++ set_remap_table_entry(iommu, devid, table);
++++++++ goto out_wait;
}
-------- irq_lookup_table[devid] = table;
-------- set_dte_irq_entry(devid, table);
-------- iommu_flush_dte(iommu, devid);
-------- if (devid != alias) {
-------- irq_lookup_table[alias] = table;
-------- set_dte_irq_entry(alias, table);
-------- iommu_flush_dte(iommu, alias);
-------- }
++++++++ table = new_table;
++++++++ new_table = NULL;
--------out:
++++++++ set_remap_table_entry(iommu, devid, table);
++++++++ if (devid != alias)
++++++++ set_remap_table_entry(iommu, alias, table);
++++++++
++++++++out_wait:
iommu_completion_wait(iommu);
out_unlock: