diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2012-06-15 10:53:51 -0400 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2012-09-28 11:30:03 -0400 |
commit | 05152a0494449f60031da683e6d4cd60d0882214 (patch) | |
tree | 610e4df7df61da02c2cc3ccc24aeb38896f7509e /drivers/iommu | |
parent | 6efed63bec36e260204a50cfe6878cd36b710ade (diff) |
iommu/amd: Add slab-cache for irq remapping tables
The irq remapping tables for the AMD IOMMU need to be
aligned on a 128 byte boundary. Create a seperate slab-cache
to guarantee this alignment.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/amd_iommu.c | 2 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_init.c | 23 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_types.h | 9 | ||||
-rw-r--r-- | drivers/iommu/irq_remapping.h | 5 |
4 files changed, 39 insertions, 0 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 6f514831af1f..b6a8079ff7bb 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
@@ -95,6 +95,8 @@ struct iommu_cmd { | |||
95 | u32 data[4]; | 95 | u32 data[4]; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | struct kmem_cache *amd_iommu_irq_cache; | ||
99 | |||
98 | static void update_domain(struct protection_domain *domain); | 100 | static void update_domain(struct protection_domain *domain); |
99 | static int __init alloc_passthrough_domain(void); | 101 | static int __init alloc_passthrough_domain(void); |
100 | 102 | ||
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 617985961195..073ed5d1e053 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c | |||
@@ -36,6 +36,7 @@ | |||
36 | 36 | ||
37 | #include "amd_iommu_proto.h" | 37 | #include "amd_iommu_proto.h" |
38 | #include "amd_iommu_types.h" | 38 | #include "amd_iommu_types.h" |
39 | #include "irq_remapping.h" | ||
39 | 40 | ||
40 | /* | 41 | /* |
41 | * definitions for the ACPI scanning code | 42 | * definitions for the ACPI scanning code |
@@ -127,6 +128,7 @@ struct ivmd_header { | |||
127 | } __attribute__((packed)); | 128 | } __attribute__((packed)); |
128 | 129 | ||
129 | bool amd_iommu_dump; | 130 | bool amd_iommu_dump; |
131 | bool amd_iommu_irq_remap __read_mostly; | ||
130 | 132 | ||
131 | static bool amd_iommu_detected; | 133 | static bool amd_iommu_detected; |
132 | static bool __initdata amd_iommu_disabled; | 134 | static bool __initdata amd_iommu_disabled; |
@@ -1530,6 +1532,11 @@ static struct syscore_ops amd_iommu_syscore_ops = { | |||
1530 | 1532 | ||
1531 | static void __init free_on_init_error(void) | 1533 | static void __init free_on_init_error(void) |
1532 | { | 1534 | { |
1535 | if (amd_iommu_irq_cache) { | ||
1536 | kmem_cache_destroy(amd_iommu_irq_cache); | ||
1537 | amd_iommu_irq_cache = NULL; | ||
1538 | } | ||
1539 | |||
1533 | amd_iommu_uninit_devices(); | 1540 | amd_iommu_uninit_devices(); |
1534 | 1541 | ||
1535 | free_pages((unsigned long)amd_iommu_pd_alloc_bitmap, | 1542 | free_pages((unsigned long)amd_iommu_pd_alloc_bitmap, |
@@ -1669,6 +1676,19 @@ static int __init early_amd_iommu_init(void) | |||
1669 | if (ret) | 1676 | if (ret) |
1670 | goto out; | 1677 | goto out; |
1671 | 1678 | ||
1679 | if (amd_iommu_irq_remap) { | ||
1680 | /* | ||
1681 | * Interrupt remapping enabled, create kmem_cache for the | ||
1682 | * remapping tables. | ||
1683 | */ | ||
1684 | amd_iommu_irq_cache = kmem_cache_create("irq_remap_cache", | ||
1685 | MAX_IRQS_PER_TABLE * sizeof(u32), | ||
1686 | IRQ_TABLE_ALIGNMENT, | ||
1687 | 0, NULL); | ||
1688 | if (!amd_iommu_irq_cache) | ||
1689 | goto out; | ||
1690 | } | ||
1691 | |||
1672 | ret = init_memory_definitions(ivrs_base); | 1692 | ret = init_memory_definitions(ivrs_base); |
1673 | if (ret) | 1693 | if (ret) |
1674 | goto out; | 1694 | goto out; |
@@ -1716,6 +1736,9 @@ static bool detect_ivrs(void) | |||
1716 | /* Make sure ACS will be enabled during PCI probe */ | 1736 | /* Make sure ACS will be enabled during PCI probe */ |
1717 | pci_request_acs(); | 1737 | pci_request_acs(); |
1718 | 1738 | ||
1739 | if (!disable_irq_remap) | ||
1740 | amd_iommu_irq_remap = true; | ||
1741 | |||
1719 | return true; | 1742 | return true; |
1720 | } | 1743 | } |
1721 | 1744 | ||
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index 4495b78b1296..953cea80daa7 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h | |||
@@ -334,6 +334,15 @@ extern bool amd_iommu_np_cache; | |||
334 | /* Only true if all IOMMUs support device IOTLBs */ | 334 | /* Only true if all IOMMUs support device IOTLBs */ |
335 | extern bool amd_iommu_iotlb_sup; | 335 | extern bool amd_iommu_iotlb_sup; |
336 | 336 | ||
337 | #define MAX_IRQS_PER_TABLE 256 | ||
338 | #define IRQ_TABLE_ALIGNMENT 128 | ||
339 | |||
340 | /* Interrupt remapping feature used? */ | ||
341 | extern bool amd_iommu_irq_remap; | ||
342 | |||
343 | /* kmem_cache to get tables with 128 byte alignement */ | ||
344 | extern struct kmem_cache *amd_iommu_irq_cache; | ||
345 | |||
337 | /* | 346 | /* |
338 | * Make iterating over all IOMMUs easier | 347 | * Make iterating over all IOMMUs easier |
339 | */ | 348 | */ |
diff --git a/drivers/iommu/irq_remapping.h b/drivers/iommu/irq_remapping.h index b12974cc1dfe..624d360d9be4 100644 --- a/drivers/iommu/irq_remapping.h +++ b/drivers/iommu/irq_remapping.h | |||
@@ -83,6 +83,11 @@ struct irq_remap_ops { | |||
83 | 83 | ||
84 | extern struct irq_remap_ops intel_irq_remap_ops; | 84 | extern struct irq_remap_ops intel_irq_remap_ops; |
85 | 85 | ||
86 | #else /* CONFIG_IRQ_REMAP */ | ||
87 | |||
88 | #define irq_remapping_enabled 0 | ||
89 | #define disable_irq_remap 1 | ||
90 | |||
86 | #endif /* CONFIG_IRQ_REMAP */ | 91 | #endif /* CONFIG_IRQ_REMAP */ |
87 | 92 | ||
88 | #endif /* __IRQ_REMAPPING_H */ | 93 | #endif /* __IRQ_REMAPPING_H */ |