提交 0ea2c422 编写于 作者: J Joerg Roedel

iommu/amd: Allocate data structures to keep track of irq remapping tables

To easily map device ids to interrupt remapping table
entries a new lookup table is necessary.
Signed-off-by: NJoerg Roedel <joerg.roedel@amd.com>
上级 05152a04
...@@ -183,6 +183,12 @@ u16 *amd_iommu_alias_table; ...@@ -183,6 +183,12 @@ u16 *amd_iommu_alias_table;
*/ */
struct amd_iommu **amd_iommu_rlookup_table; struct amd_iommu **amd_iommu_rlookup_table;
/*
* This table is used to find the irq remapping table for a given device id
* quickly.
*/
struct irq_remap_table **irq_lookup_table;
/* /*
* AMD IOMMU allows up to 2^16 differend protection domains. This is a bitmap * AMD IOMMU allows up to 2^16 differend protection domains. This is a bitmap
* to know which ones are already in use. * to know which ones are already in use.
...@@ -1532,9 +1538,13 @@ static struct syscore_ops amd_iommu_syscore_ops = { ...@@ -1532,9 +1538,13 @@ static struct syscore_ops amd_iommu_syscore_ops = {
static void __init free_on_init_error(void) static void __init free_on_init_error(void)
{ {
free_pages((unsigned long)irq_lookup_table,
get_order(rlookup_table_size));
if (amd_iommu_irq_cache) { if (amd_iommu_irq_cache) {
kmem_cache_destroy(amd_iommu_irq_cache); kmem_cache_destroy(amd_iommu_irq_cache);
amd_iommu_irq_cache = NULL; amd_iommu_irq_cache = NULL;
} }
amd_iommu_uninit_devices(); amd_iommu_uninit_devices();
...@@ -1687,6 +1697,12 @@ static int __init early_amd_iommu_init(void) ...@@ -1687,6 +1697,12 @@ static int __init early_amd_iommu_init(void)
0, NULL); 0, NULL);
if (!amd_iommu_irq_cache) if (!amd_iommu_irq_cache)
goto out; goto out;
irq_lookup_table = (void *)__get_free_pages(
GFP_KERNEL | __GFP_ZERO,
get_order(rlookup_table_size));
if (!irq_lookup_table)
goto out;
} }
ret = init_memory_definitions(ivrs_base); ret = init_memory_definitions(ivrs_base);
......
...@@ -175,6 +175,7 @@ ...@@ -175,6 +175,7 @@
#define DEV_ENTRY_EX 0x67 #define DEV_ENTRY_EX 0x67
#define DEV_ENTRY_SYSMGT1 0x68 #define DEV_ENTRY_SYSMGT1 0x68
#define DEV_ENTRY_SYSMGT2 0x69 #define DEV_ENTRY_SYSMGT2 0x69
#define DEV_ENTRY_IRQ_TBL_EN 0x80
#define DEV_ENTRY_INIT_PASS 0xb8 #define DEV_ENTRY_INIT_PASS 0xb8
#define DEV_ENTRY_EINT_PASS 0xb9 #define DEV_ENTRY_EINT_PASS 0xb9
#define DEV_ENTRY_NMI_PASS 0xba #define DEV_ENTRY_NMI_PASS 0xba
...@@ -337,6 +338,14 @@ extern bool amd_iommu_iotlb_sup; ...@@ -337,6 +338,14 @@ extern bool amd_iommu_iotlb_sup;
#define MAX_IRQS_PER_TABLE 256 #define MAX_IRQS_PER_TABLE 256
#define IRQ_TABLE_ALIGNMENT 128 #define IRQ_TABLE_ALIGNMENT 128
struct irq_remap_table {
spinlock_t lock;
unsigned min_index;
u32 *table;
};
extern struct irq_remap_table **irq_lookup_table;
/* Interrupt remapping feature used? */ /* Interrupt remapping feature used? */
extern bool amd_iommu_irq_remap; extern bool amd_iommu_irq_remap;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册