diff options
author | Suresh Siddha <suresh.b.siddha@intel.com> | 2011-05-18 19:31:38 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-05-20 07:41:01 -0400 |
commit | c040aaeb86f66e956e147ce5f238d28308e06109 (patch) | |
tree | 18da3f866f94ef23f6216c100b12980c46bf4a0d | |
parent | d5371430840f3e8d3b8bdbc9c02867808f299449 (diff) |
x86, ioapic: Consolidate gsi routing info into 'struct ioapic'
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: daniel.blueman@gmail.com
Link: http://lkml.kernel.org/r/20110518233157.994002011@sbsiddha-MOBL3.sc.intel.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/include/asm/io_apic.h | 1 | ||||
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 38 | ||||
-rw-r--r-- | arch/x86/kernel/devicetree.c | 4 |
3 files changed, 29 insertions, 14 deletions
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h index 4f07bf637eb3..690d1cc9a877 100644 --- a/arch/x86/include/asm/io_apic.h +++ b/arch/x86/include/asm/io_apic.h | |||
@@ -108,6 +108,7 @@ extern int nr_ioapics; | |||
108 | 108 | ||
109 | extern int mpc_ioapic_id(int ioapic); | 109 | extern int mpc_ioapic_id(int ioapic); |
110 | extern unsigned int mpc_ioapic_addr(int ioapic); | 110 | extern unsigned int mpc_ioapic_addr(int ioapic); |
111 | extern struct mp_ioapic_gsi *mp_ioapic_gsi_routing(int ioapic); | ||
111 | 112 | ||
112 | #define MP_MAX_IOAPIC_PIN 127 | 113 | #define MP_MAX_IOAPIC_PIN 127 |
113 | 114 | ||
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index e91131557b79..b7dd2338502d 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -87,6 +87,8 @@ static struct ioapic { | |||
87 | struct IO_APIC_route_entry *saved_registers; | 87 | struct IO_APIC_route_entry *saved_registers; |
88 | /* I/O APIC config */ | 88 | /* I/O APIC config */ |
89 | struct mpc_ioapic mp_config; | 89 | struct mpc_ioapic mp_config; |
90 | /* IO APIC gsi routing info */ | ||
91 | struct mp_ioapic_gsi gsi_config; | ||
90 | } ioapics[MAX_IO_APICS]; | 92 | } ioapics[MAX_IO_APICS]; |
91 | 93 | ||
92 | #define mpc_ioapic_ver(id) ioapics[id].mp_config.apicver | 94 | #define mpc_ioapic_ver(id) ioapics[id].mp_config.apicver |
@@ -101,10 +103,12 @@ unsigned int mpc_ioapic_addr(int id) | |||
101 | return ioapics[id].mp_config.apicaddr; | 103 | return ioapics[id].mp_config.apicaddr; |
102 | } | 104 | } |
103 | 105 | ||
104 | int nr_ioapics; | 106 | struct mp_ioapic_gsi *mp_ioapic_gsi_routing(int id) |
107 | { | ||
108 | return &ioapics[id].gsi_config; | ||
109 | } | ||
105 | 110 | ||
106 | /* IO APIC gsi routing info */ | 111 | int nr_ioapics; |
107 | struct mp_ioapic_gsi mp_gsi_routing[MAX_IO_APICS]; | ||
108 | 112 | ||
109 | /* The one past the highest gsi number used */ | 113 | /* The one past the highest gsi number used */ |
110 | u32 gsi_top; | 114 | u32 gsi_top; |
@@ -924,6 +928,7 @@ static int pin_2_irq(int idx, int apic, int pin) | |||
924 | { | 928 | { |
925 | int irq; | 929 | int irq; |
926 | int bus = mp_irqs[idx].srcbus; | 930 | int bus = mp_irqs[idx].srcbus; |
931 | struct mp_ioapic_gsi *gsi_cfg = mp_ioapic_gsi_routing(apic); | ||
927 | 932 | ||
928 | /* | 933 | /* |
929 | * Debugging check, we are in big trouble if this message pops up! | 934 | * Debugging check, we are in big trouble if this message pops up! |
@@ -934,7 +939,7 @@ static int pin_2_irq(int idx, int apic, int pin) | |||
934 | if (test_bit(bus, mp_bus_not_pci)) { | 939 | if (test_bit(bus, mp_bus_not_pci)) { |
935 | irq = mp_irqs[idx].srcbusirq; | 940 | irq = mp_irqs[idx].srcbusirq; |
936 | } else { | 941 | } else { |
937 | u32 gsi = mp_gsi_routing[apic].gsi_base + pin; | 942 | u32 gsi = gsi_cfg->gsi_base + pin; |
938 | 943 | ||
939 | if (gsi >= NR_IRQS_LEGACY) | 944 | if (gsi >= NR_IRQS_LEGACY) |
940 | irq = gsi; | 945 | irq = gsi; |
@@ -3898,8 +3903,9 @@ int mp_find_ioapic(u32 gsi) | |||
3898 | 3903 | ||
3899 | /* Find the IOAPIC that manages this GSI. */ | 3904 | /* Find the IOAPIC that manages this GSI. */ |
3900 | for (i = 0; i < nr_ioapics; i++) { | 3905 | for (i = 0; i < nr_ioapics; i++) { |
3901 | if ((gsi >= mp_gsi_routing[i].gsi_base) | 3906 | struct mp_ioapic_gsi *gsi_cfg = mp_ioapic_gsi_routing(i); |
3902 | && (gsi <= mp_gsi_routing[i].gsi_end)) | 3907 | if ((gsi >= gsi_cfg->gsi_base) |
3908 | && (gsi <= gsi_cfg->gsi_end)) | ||
3903 | return i; | 3909 | return i; |
3904 | } | 3910 | } |
3905 | 3911 | ||
@@ -3909,12 +3915,16 @@ int mp_find_ioapic(u32 gsi) | |||
3909 | 3915 | ||
3910 | int mp_find_ioapic_pin(int ioapic, u32 gsi) | 3916 | int mp_find_ioapic_pin(int ioapic, u32 gsi) |
3911 | { | 3917 | { |
3918 | struct mp_ioapic_gsi *gsi_cfg; | ||
3919 | |||
3912 | if (WARN_ON(ioapic == -1)) | 3920 | if (WARN_ON(ioapic == -1)) |
3913 | return -1; | 3921 | return -1; |
3914 | if (WARN_ON(gsi > mp_gsi_routing[ioapic].gsi_end)) | 3922 | |
3923 | gsi_cfg = mp_ioapic_gsi_routing(ioapic); | ||
3924 | if (WARN_ON(gsi > gsi_cfg->gsi_end)) | ||
3915 | return -1; | 3925 | return -1; |
3916 | 3926 | ||
3917 | return gsi - mp_gsi_routing[ioapic].gsi_base; | 3927 | return gsi - gsi_cfg->gsi_base; |
3918 | } | 3928 | } |
3919 | 3929 | ||
3920 | static __init int bad_ioapic(unsigned long address) | 3930 | static __init int bad_ioapic(unsigned long address) |
@@ -3936,6 +3946,7 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base) | |||
3936 | { | 3946 | { |
3937 | int idx = 0; | 3947 | int idx = 0; |
3938 | int entries; | 3948 | int entries; |
3949 | struct mp_ioapic_gsi *gsi_cfg; | ||
3939 | 3950 | ||
3940 | if (bad_ioapic(address)) | 3951 | if (bad_ioapic(address)) |
3941 | return; | 3952 | return; |
@@ -3955,21 +3966,22 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base) | |||
3955 | * and to prevent reprogramming of IOAPIC pins (PCI GSIs). | 3966 | * and to prevent reprogramming of IOAPIC pins (PCI GSIs). |
3956 | */ | 3967 | */ |
3957 | entries = io_apic_get_redir_entries(idx); | 3968 | entries = io_apic_get_redir_entries(idx); |
3958 | mp_gsi_routing[idx].gsi_base = gsi_base; | 3969 | gsi_cfg = mp_ioapic_gsi_routing(idx); |
3959 | mp_gsi_routing[idx].gsi_end = gsi_base + entries - 1; | 3970 | gsi_cfg->gsi_base = gsi_base; |
3971 | gsi_cfg->gsi_end = gsi_base + entries - 1; | ||
3960 | 3972 | ||
3961 | /* | 3973 | /* |
3962 | * The number of IO-APIC IRQ registers (== #pins): | 3974 | * The number of IO-APIC IRQ registers (== #pins): |
3963 | */ | 3975 | */ |
3964 | ioapics[idx].nr_registers = entries; | 3976 | ioapics[idx].nr_registers = entries; |
3965 | 3977 | ||
3966 | if (mp_gsi_routing[idx].gsi_end >= gsi_top) | 3978 | if (gsi_cfg->gsi_end >= gsi_top) |
3967 | gsi_top = mp_gsi_routing[idx].gsi_end + 1; | 3979 | gsi_top = gsi_cfg->gsi_end + 1; |
3968 | 3980 | ||
3969 | printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%x, " | 3981 | printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%x, " |
3970 | "GSI %d-%d\n", idx, mpc_ioapic_id(idx), | 3982 | "GSI %d-%d\n", idx, mpc_ioapic_id(idx), |
3971 | mpc_ioapic_ver(idx), mpc_ioapic_addr(idx), | 3983 | mpc_ioapic_ver(idx), mpc_ioapic_addr(idx), |
3972 | mp_gsi_routing[idx].gsi_base, mp_gsi_routing[idx].gsi_end); | 3984 | gsi_cfg->gsi_base, gsi_cfg->gsi_end); |
3973 | 3985 | ||
3974 | nr_ioapics++; | 3986 | nr_ioapics++; |
3975 | } | 3987 | } |
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index f06494e93760..690bc8461835 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c | |||
@@ -369,6 +369,7 @@ static struct of_ioapic_type of_ioapic_type[] = | |||
369 | static int ioapic_xlate(struct irq_domain *id, const u32 *intspec, u32 intsize, | 369 | static int ioapic_xlate(struct irq_domain *id, const u32 *intspec, u32 intsize, |
370 | u32 *out_hwirq, u32 *out_type) | 370 | u32 *out_hwirq, u32 *out_type) |
371 | { | 371 | { |
372 | struct mp_ioapic_gsi *gsi_cfg; | ||
372 | struct io_apic_irq_attr attr; | 373 | struct io_apic_irq_attr attr; |
373 | struct of_ioapic_type *it; | 374 | struct of_ioapic_type *it; |
374 | u32 line, idx, type; | 375 | u32 line, idx, type; |
@@ -378,7 +379,8 @@ static int ioapic_xlate(struct irq_domain *id, const u32 *intspec, u32 intsize, | |||
378 | 379 | ||
379 | line = *intspec; | 380 | line = *intspec; |
380 | idx = (u32) id->priv; | 381 | idx = (u32) id->priv; |
381 | *out_hwirq = line + mp_gsi_routing[idx].gsi_base; | 382 | gsi_cfg = mp_ioapic_gsi_routing(idx); |
383 | *out_hwirq = line + gsi_cfg->gsi_base; | ||
382 | 384 | ||
383 | intspec++; | 385 | intspec++; |
384 | type = *intspec; | 386 | type = *intspec; |