aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2012-06-15 12:05:20 -0400
committerJoerg Roedel <joerg.roedel@amd.com>2012-09-28 11:30:04 -0400
commit0ea2c422bc8da99d14baa46d4789861a4f8d4ec0 (patch)
treeda722904779083287e209324b77d9b80235d2348 /drivers/iommu
parent05152a0494449f60031da683e6d4cd60d0882214 (diff)
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: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/amd_iommu_init.c16
-rw-r--r--drivers/iommu/amd_iommu_types.h9
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 073ed5d1e053..2d923fe7c2a1 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -184,6 +184,12 @@ u16 *amd_iommu_alias_table;
184struct amd_iommu **amd_iommu_rlookup_table; 184struct amd_iommu **amd_iommu_rlookup_table;
185 185
186/* 186/*
187 * This table is used to find the irq remapping table for a given device id
188 * quickly.
189 */
190struct irq_remap_table **irq_lookup_table;
191
192/*
187 * AMD IOMMU allows up to 2^16 differend protection domains. This is a bitmap 193 * AMD IOMMU allows up to 2^16 differend protection domains. This is a bitmap
188 * to know which ones are already in use. 194 * to know which ones are already in use.
189 */ 195 */
@@ -1532,9 +1538,13 @@ static struct syscore_ops amd_iommu_syscore_ops = {
1532 1538
1533static void __init free_on_init_error(void) 1539static void __init free_on_init_error(void)
1534{ 1540{
1541 free_pages((unsigned long)irq_lookup_table,
1542 get_order(rlookup_table_size));
1543
1535 if (amd_iommu_irq_cache) { 1544 if (amd_iommu_irq_cache) {
1536 kmem_cache_destroy(amd_iommu_irq_cache); 1545 kmem_cache_destroy(amd_iommu_irq_cache);
1537 amd_iommu_irq_cache = NULL; 1546 amd_iommu_irq_cache = NULL;
1547
1538 } 1548 }
1539 1549
1540 amd_iommu_uninit_devices(); 1550 amd_iommu_uninit_devices();
@@ -1687,6 +1697,12 @@ static int __init early_amd_iommu_init(void)
1687 0, NULL); 1697 0, NULL);
1688 if (!amd_iommu_irq_cache) 1698 if (!amd_iommu_irq_cache)
1689 goto out; 1699 goto out;
1700
1701 irq_lookup_table = (void *)__get_free_pages(
1702 GFP_KERNEL | __GFP_ZERO,
1703 get_order(rlookup_table_size));
1704 if (!irq_lookup_table)
1705 goto out;
1690 } 1706 }
1691 1707
1692 ret = init_memory_definitions(ivrs_base); 1708 ret = init_memory_definitions(ivrs_base);
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
index 953cea80daa7..1a7d48078d3f 100644
--- a/drivers/iommu/amd_iommu_types.h
+++ b/drivers/iommu/amd_iommu_types.h
@@ -175,6 +175,7 @@
175#define DEV_ENTRY_EX 0x67 175#define DEV_ENTRY_EX 0x67
176#define DEV_ENTRY_SYSMGT1 0x68 176#define DEV_ENTRY_SYSMGT1 0x68
177#define DEV_ENTRY_SYSMGT2 0x69 177#define DEV_ENTRY_SYSMGT2 0x69
178#define DEV_ENTRY_IRQ_TBL_EN 0x80
178#define DEV_ENTRY_INIT_PASS 0xb8 179#define DEV_ENTRY_INIT_PASS 0xb8
179#define DEV_ENTRY_EINT_PASS 0xb9 180#define DEV_ENTRY_EINT_PASS 0xb9
180#define DEV_ENTRY_NMI_PASS 0xba 181#define DEV_ENTRY_NMI_PASS 0xba
@@ -337,6 +338,14 @@ extern bool amd_iommu_iotlb_sup;
337#define MAX_IRQS_PER_TABLE 256 338#define MAX_IRQS_PER_TABLE 256
338#define IRQ_TABLE_ALIGNMENT 128 339#define IRQ_TABLE_ALIGNMENT 128
339 340
341struct irq_remap_table {
342 spinlock_t lock;
343 unsigned min_index;
344 u32 *table;
345};
346
347extern struct irq_remap_table **irq_lookup_table;
348
340/* Interrupt remapping feature used? */ 349/* Interrupt remapping feature used? */
341extern bool amd_iommu_irq_remap; 350extern bool amd_iommu_irq_remap;
342 351