diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2012-06-26 10:46:04 -0400 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2012-09-28 11:43:52 -0400 |
commit | 6b474b8224cdb473f19e8c925171e608499cc45d (patch) | |
tree | d52191a42b4b9292b1908003245abcf852c6919b /drivers/iommu | |
parent | d976195c93bce4512e990d170858d20d71c95c45 (diff) |
iommu/amd: Add initialization routines for AMD interrupt remapping
Add the six routines required to setup interrupt remapping
with the AMD IOMMU. Also put it all together into the AMD
specific irq_remap_ops.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/amd_iommu.c | 16 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_init.c | 42 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_proto.h | 8 | ||||
-rw-r--r-- | drivers/iommu/irq_remapping.h | 1 |
4 files changed, 67 insertions, 0 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index aeb890c35f7..33f144f7d67 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
@@ -45,6 +45,7 @@ | |||
45 | 45 | ||
46 | #include "amd_iommu_proto.h" | 46 | #include "amd_iommu_proto.h" |
47 | #include "amd_iommu_types.h" | 47 | #include "amd_iommu_types.h" |
48 | #include "irq_remapping.h" | ||
48 | 49 | ||
49 | #define CMD_SET_TYPE(cmd, t) ((cmd)->data[1] |= ((t) << 28)) | 50 | #define CMD_SET_TYPE(cmd, t) ((cmd)->data[1] |= ((t) << 28)) |
50 | 51 | ||
@@ -4226,4 +4227,19 @@ static int setup_hpet_msi(unsigned int irq, unsigned int id) | |||
4226 | return 0; | 4227 | return 0; |
4227 | } | 4228 | } |
4228 | 4229 | ||
4230 | struct irq_remap_ops amd_iommu_irq_ops = { | ||
4231 | .supported = amd_iommu_supported, | ||
4232 | .prepare = amd_iommu_prepare, | ||
4233 | .enable = amd_iommu_enable, | ||
4234 | .disable = amd_iommu_disable, | ||
4235 | .reenable = amd_iommu_reenable, | ||
4236 | .enable_faulting = amd_iommu_enable_faulting, | ||
4237 | .setup_ioapic_entry = setup_ioapic_entry, | ||
4238 | .set_affinity = set_affinity, | ||
4239 | .free_irq = free_irq, | ||
4240 | .compose_msi_msg = compose_msi_msg, | ||
4241 | .msi_alloc_irq = msi_alloc_irq, | ||
4242 | .msi_setup_irq = msi_setup_irq, | ||
4243 | .setup_hpet_msi = setup_hpet_msi, | ||
4244 | }; | ||
4229 | #endif | 4245 | #endif |
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 68b3305a126..d536d24b6f3 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <asm/x86_init.h> | 34 | #include <asm/x86_init.h> |
35 | #include <asm/iommu_table.h> | 35 | #include <asm/iommu_table.h> |
36 | #include <asm/io_apic.h> | 36 | #include <asm/io_apic.h> |
37 | #include <asm/irq_remapping.h> | ||
37 | 38 | ||
38 | #include "amd_iommu_proto.h" | 39 | #include "amd_iommu_proto.h" |
39 | #include "amd_iommu_types.h" | 40 | #include "amd_iommu_types.h" |
@@ -1897,7 +1898,48 @@ static int __init iommu_go_to_state(enum iommu_init_state state) | |||
1897 | return ret; | 1898 | return ret; |
1898 | } | 1899 | } |
1899 | 1900 | ||
1901 | #ifdef CONFIG_IRQ_REMAP | ||
1902 | int __init amd_iommu_prepare(void) | ||
1903 | { | ||
1904 | return iommu_go_to_state(IOMMU_ACPI_FINISHED); | ||
1905 | } | ||
1906 | |||
1907 | int __init amd_iommu_supported(void) | ||
1908 | { | ||
1909 | return amd_iommu_irq_remap ? 1 : 0; | ||
1910 | } | ||
1911 | |||
1912 | int __init amd_iommu_enable(void) | ||
1913 | { | ||
1914 | int ret; | ||
1915 | |||
1916 | ret = iommu_go_to_state(IOMMU_ENABLED); | ||
1917 | if (ret) | ||
1918 | return ret; | ||
1900 | 1919 | ||
1920 | irq_remapping_enabled = 1; | ||
1921 | |||
1922 | return 0; | ||
1923 | } | ||
1924 | |||
1925 | void amd_iommu_disable(void) | ||
1926 | { | ||
1927 | amd_iommu_suspend(); | ||
1928 | } | ||
1929 | |||
1930 | int amd_iommu_reenable(int mode) | ||
1931 | { | ||
1932 | amd_iommu_resume(); | ||
1933 | |||
1934 | return 0; | ||
1935 | } | ||
1936 | |||
1937 | int __init amd_iommu_enable_faulting(void) | ||
1938 | { | ||
1939 | /* We enable MSI later when PCI is initialized */ | ||
1940 | return 0; | ||
1941 | } | ||
1942 | #endif | ||
1901 | 1943 | ||
1902 | /* | 1944 | /* |
1903 | * This is the core init function for AMD IOMMU hardware in the system. | 1945 | * This is the core init function for AMD IOMMU hardware in the system. |
diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h index 1a7f41c6cc6..c294961bdd3 100644 --- a/drivers/iommu/amd_iommu_proto.h +++ b/drivers/iommu/amd_iommu_proto.h | |||
@@ -32,6 +32,14 @@ extern void amd_iommu_uninit_devices(void); | |||
32 | extern void amd_iommu_init_notifier(void); | 32 | extern void amd_iommu_init_notifier(void); |
33 | extern void amd_iommu_init_api(void); | 33 | extern void amd_iommu_init_api(void); |
34 | 34 | ||
35 | /* Needed for interrupt remapping */ | ||
36 | extern int amd_iommu_supported(void); | ||
37 | extern int amd_iommu_prepare(void); | ||
38 | extern int amd_iommu_enable(void); | ||
39 | extern void amd_iommu_disable(void); | ||
40 | extern int amd_iommu_reenable(int); | ||
41 | extern int amd_iommu_enable_faulting(void); | ||
42 | |||
35 | /* IOMMUv2 specific functions */ | 43 | /* IOMMUv2 specific functions */ |
36 | struct iommu_domain; | 44 | struct iommu_domain; |
37 | 45 | ||
diff --git a/drivers/iommu/irq_remapping.h b/drivers/iommu/irq_remapping.h index 624d360d9be..95363acb583 100644 --- a/drivers/iommu/irq_remapping.h +++ b/drivers/iommu/irq_remapping.h | |||
@@ -82,6 +82,7 @@ struct irq_remap_ops { | |||
82 | }; | 82 | }; |
83 | 83 | ||
84 | extern struct irq_remap_ops intel_irq_remap_ops; | 84 | extern struct irq_remap_ops intel_irq_remap_ops; |
85 | extern struct irq_remap_ops amd_iommu_irq_ops; | ||
85 | 86 | ||
86 | #else /* CONFIG_IRQ_REMAP */ | 87 | #else /* CONFIG_IRQ_REMAP */ |
87 | 88 | ||