diff options
Diffstat (limited to 'arch/x86')
26 files changed, 1365 insertions, 112 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 96e0c2ebc388..baca55455005 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -1650,6 +1650,14 @@ config DMAR_FLOPPY_WA | |||
1650 | workaround will setup a 1:1 mapping for the first | 1650 | workaround will setup a 1:1 mapping for the first |
1651 | 16M to make floppy (an ISA device) work. | 1651 | 16M to make floppy (an ISA device) work. |
1652 | 1652 | ||
1653 | config INTR_REMAP | ||
1654 | bool "Support for Interrupt Remapping (EXPERIMENTAL)" | ||
1655 | depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI && EXPERIMENTAL | ||
1656 | help | ||
1657 | Supports Interrupt remapping for IO-APIC and MSI devices. | ||
1658 | To use x2apic mode in the CPU's which support x2APIC enhancements or | ||
1659 | to support platforms with CPU's having > 8 bit APIC ID, say Y. | ||
1660 | |||
1653 | source "drivers/pci/pcie/Kconfig" | 1661 | source "drivers/pci/pcie/Kconfig" |
1654 | 1662 | ||
1655 | source "drivers/pci/Kconfig" | 1663 | source "drivers/pci/Kconfig" |
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index da140611bb57..673f1d12b420 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile | |||
@@ -102,6 +102,8 @@ obj-$(CONFIG_OLPC) += olpc.o | |||
102 | # 64 bit specific files | 102 | # 64 bit specific files |
103 | ifeq ($(CONFIG_X86_64),y) | 103 | ifeq ($(CONFIG_X86_64),y) |
104 | obj-y += genapic_64.o genapic_flat_64.o genx2apic_uv_x.o tlb_uv.o | 104 | obj-y += genapic_64.o genapic_flat_64.o genx2apic_uv_x.o tlb_uv.o |
105 | obj-y += genx2apic_cluster.o | ||
106 | obj-y += genx2apic_phys.o | ||
105 | obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o | 107 | obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o |
106 | obj-$(CONFIG_AUDIT) += audit_64.o | 108 | obj-$(CONFIG_AUDIT) += audit_64.o |
107 | 109 | ||
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index f489d7a9be92..b41b27af33e6 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c | |||
@@ -761,7 +761,7 @@ static void __init acpi_register_lapic_address(unsigned long address) | |||
761 | 761 | ||
762 | set_fixmap_nocache(FIX_APIC_BASE, address); | 762 | set_fixmap_nocache(FIX_APIC_BASE, address); |
763 | if (boot_cpu_physical_apicid == -1U) { | 763 | if (boot_cpu_physical_apicid == -1U) { |
764 | boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); | 764 | boot_cpu_physical_apicid = read_apic_id(); |
765 | #ifdef CONFIG_X86_32 | 765 | #ifdef CONFIG_X86_32 |
766 | apic_version[boot_cpu_physical_apicid] = | 766 | apic_version[boot_cpu_physical_apicid] = |
767 | GET_APIC_VERSION(apic_read(APIC_LVR)); | 767 | GET_APIC_VERSION(apic_read(APIC_LVR)); |
@@ -1337,7 +1337,9 @@ static void __init acpi_process_madt(void) | |||
1337 | acpi_ioapic = 1; | 1337 | acpi_ioapic = 1; |
1338 | 1338 | ||
1339 | smp_found_config = 1; | 1339 | smp_found_config = 1; |
1340 | #ifdef CONFIG_X86_32 | ||
1340 | setup_apic_routing(); | 1341 | setup_apic_routing(); |
1342 | #endif | ||
1341 | } | 1343 | } |
1342 | } | 1344 | } |
1343 | if (error == -EINVAL) { | 1345 | if (error == -EINVAL) { |
diff --git a/arch/x86/kernel/apic_32.c b/arch/x86/kernel/apic_32.c index 7f30c0f3dbe4..dcb897f22aa2 100644 --- a/arch/x86/kernel/apic_32.c +++ b/arch/x86/kernel/apic_32.c | |||
@@ -145,13 +145,18 @@ static int modern_apic(void) | |||
145 | return lapic_get_version() >= 0x14; | 145 | return lapic_get_version() >= 0x14; |
146 | } | 146 | } |
147 | 147 | ||
148 | void apic_wait_icr_idle(void) | 148 | /* |
149 | * Paravirt kernels also might be using these below ops. So we still | ||
150 | * use generic apic_read()/apic_write(), which might be pointing to different | ||
151 | * ops in PARAVIRT case. | ||
152 | */ | ||
153 | void xapic_wait_icr_idle(void) | ||
149 | { | 154 | { |
150 | while (apic_read(APIC_ICR) & APIC_ICR_BUSY) | 155 | while (apic_read(APIC_ICR) & APIC_ICR_BUSY) |
151 | cpu_relax(); | 156 | cpu_relax(); |
152 | } | 157 | } |
153 | 158 | ||
154 | u32 safe_apic_wait_icr_idle(void) | 159 | u32 safe_xapic_wait_icr_idle(void) |
155 | { | 160 | { |
156 | u32 send_status; | 161 | u32 send_status; |
157 | int timeout; | 162 | int timeout; |
@@ -167,6 +172,35 @@ u32 safe_apic_wait_icr_idle(void) | |||
167 | return send_status; | 172 | return send_status; |
168 | } | 173 | } |
169 | 174 | ||
175 | void xapic_icr_write(u32 low, u32 id) | ||
176 | { | ||
177 | apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(id)); | ||
178 | apic_write_around(APIC_ICR, low); | ||
179 | } | ||
180 | |||
181 | u64 xapic_icr_read(void) | ||
182 | { | ||
183 | u32 icr1, icr2; | ||
184 | |||
185 | icr2 = apic_read(APIC_ICR2); | ||
186 | icr1 = apic_read(APIC_ICR); | ||
187 | |||
188 | return icr1 | ((u64)icr2 << 32); | ||
189 | } | ||
190 | |||
191 | static struct apic_ops xapic_ops = { | ||
192 | .read = native_apic_mem_read, | ||
193 | .write = native_apic_mem_write, | ||
194 | .write_atomic = native_apic_mem_write_atomic, | ||
195 | .icr_read = xapic_icr_read, | ||
196 | .icr_write = xapic_icr_write, | ||
197 | .wait_icr_idle = xapic_wait_icr_idle, | ||
198 | .safe_wait_icr_idle = safe_xapic_wait_icr_idle, | ||
199 | }; | ||
200 | |||
201 | struct apic_ops __read_mostly *apic_ops = &xapic_ops; | ||
202 | EXPORT_SYMBOL_GPL(apic_ops); | ||
203 | |||
170 | /** | 204 | /** |
171 | * enable_NMI_through_LVT0 - enable NMI through local vector table 0 | 205 | * enable_NMI_through_LVT0 - enable NMI through local vector table 0 |
172 | */ | 206 | */ |
@@ -1205,7 +1239,7 @@ void __init init_apic_mappings(void) | |||
1205 | * default configuration (or the MP table is broken). | 1239 | * default configuration (or the MP table is broken). |
1206 | */ | 1240 | */ |
1207 | if (boot_cpu_physical_apicid == -1U) | 1241 | if (boot_cpu_physical_apicid == -1U) |
1208 | boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); | 1242 | boot_cpu_physical_apicid = read_apic_id(); |
1209 | 1243 | ||
1210 | } | 1244 | } |
1211 | 1245 | ||
@@ -1245,7 +1279,7 @@ int __init APIC_init_uniprocessor(void) | |||
1245 | * might be zero if read from MP tables. Get it from LAPIC. | 1279 | * might be zero if read from MP tables. Get it from LAPIC. |
1246 | */ | 1280 | */ |
1247 | #ifdef CONFIG_CRASH_DUMP | 1281 | #ifdef CONFIG_CRASH_DUMP |
1248 | boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); | 1282 | boot_cpu_physical_apicid = read_apic_id(); |
1249 | #endif | 1283 | #endif |
1250 | physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); | 1284 | physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); |
1251 | 1285 | ||
diff --git a/arch/x86/kernel/apic_64.c b/arch/x86/kernel/apic_64.c index 98c70f044e19..46e612408aca 100644 --- a/arch/x86/kernel/apic_64.c +++ b/arch/x86/kernel/apic_64.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/clockchips.h> | 27 | #include <linux/clockchips.h> |
28 | #include <linux/acpi_pmtmr.h> | 28 | #include <linux/acpi_pmtmr.h> |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/dmar.h> | ||
30 | 31 | ||
31 | #include <asm/atomic.h> | 32 | #include <asm/atomic.h> |
32 | #include <asm/smp.h> | 33 | #include <asm/smp.h> |
@@ -39,6 +40,7 @@ | |||
39 | #include <asm/proto.h> | 40 | #include <asm/proto.h> |
40 | #include <asm/timex.h> | 41 | #include <asm/timex.h> |
41 | #include <asm/apic.h> | 42 | #include <asm/apic.h> |
43 | #include <asm/i8259.h> | ||
42 | 44 | ||
43 | #include <mach_ipi.h> | 45 | #include <mach_ipi.h> |
44 | #include <mach_apic.h> | 46 | #include <mach_apic.h> |
@@ -46,6 +48,11 @@ | |||
46 | static int disable_apic_timer __cpuinitdata; | 48 | static int disable_apic_timer __cpuinitdata; |
47 | static int apic_calibrate_pmtmr __initdata; | 49 | static int apic_calibrate_pmtmr __initdata; |
48 | int disable_apic; | 50 | int disable_apic; |
51 | int disable_x2apic; | ||
52 | int x2apic; | ||
53 | |||
54 | /* x2apic enabled before OS handover */ | ||
55 | int x2apic_preenabled; | ||
49 | 56 | ||
50 | /* Local APIC timer works in C2 */ | 57 | /* Local APIC timer works in C2 */ |
51 | int local_apic_timer_c2_ok; | 58 | int local_apic_timer_c2_ok; |
@@ -119,13 +126,13 @@ static int modern_apic(void) | |||
119 | return lapic_get_version() >= 0x14; | 126 | return lapic_get_version() >= 0x14; |
120 | } | 127 | } |
121 | 128 | ||
122 | void apic_wait_icr_idle(void) | 129 | void xapic_wait_icr_idle(void) |
123 | { | 130 | { |
124 | while (apic_read(APIC_ICR) & APIC_ICR_BUSY) | 131 | while (apic_read(APIC_ICR) & APIC_ICR_BUSY) |
125 | cpu_relax(); | 132 | cpu_relax(); |
126 | } | 133 | } |
127 | 134 | ||
128 | u32 safe_apic_wait_icr_idle(void) | 135 | u32 safe_xapic_wait_icr_idle(void) |
129 | { | 136 | { |
130 | u32 send_status; | 137 | u32 send_status; |
131 | int timeout; | 138 | int timeout; |
@@ -141,6 +148,71 @@ u32 safe_apic_wait_icr_idle(void) | |||
141 | return send_status; | 148 | return send_status; |
142 | } | 149 | } |
143 | 150 | ||
151 | void xapic_icr_write(u32 low, u32 id) | ||
152 | { | ||
153 | apic_write(APIC_ICR2, id << 24); | ||
154 | apic_write(APIC_ICR, low); | ||
155 | } | ||
156 | |||
157 | u64 xapic_icr_read(void) | ||
158 | { | ||
159 | u32 icr1, icr2; | ||
160 | |||
161 | icr2 = apic_read(APIC_ICR2); | ||
162 | icr1 = apic_read(APIC_ICR); | ||
163 | |||
164 | return (icr1 | ((u64)icr2 << 32)); | ||
165 | } | ||
166 | |||
167 | static struct apic_ops xapic_ops = { | ||
168 | .read = native_apic_mem_read, | ||
169 | .write = native_apic_mem_write, | ||
170 | .write_atomic = native_apic_mem_write_atomic, | ||
171 | .icr_read = xapic_icr_read, | ||
172 | .icr_write = xapic_icr_write, | ||
173 | .wait_icr_idle = xapic_wait_icr_idle, | ||
174 | .safe_wait_icr_idle = safe_xapic_wait_icr_idle, | ||
175 | }; | ||
176 | |||
177 | struct apic_ops __read_mostly *apic_ops = &xapic_ops; | ||
178 | |||
179 | EXPORT_SYMBOL_GPL(apic_ops); | ||
180 | |||
181 | static void x2apic_wait_icr_idle(void) | ||
182 | { | ||
183 | /* no need to wait for icr idle in x2apic */ | ||
184 | return; | ||
185 | } | ||
186 | |||
187 | static u32 safe_x2apic_wait_icr_idle(void) | ||
188 | { | ||
189 | /* no need to wait for icr idle in x2apic */ | ||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | void x2apic_icr_write(u32 low, u32 id) | ||
194 | { | ||
195 | wrmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), ((__u64) id) << 32 | low); | ||
196 | } | ||
197 | |||
198 | u64 x2apic_icr_read(void) | ||
199 | { | ||
200 | unsigned long val; | ||
201 | |||
202 | rdmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), val); | ||
203 | return val; | ||
204 | } | ||
205 | |||
206 | static struct apic_ops x2apic_ops = { | ||
207 | .read = native_apic_msr_read, | ||
208 | .write = native_apic_msr_write, | ||
209 | .write_atomic = native_apic_msr_write, | ||
210 | .icr_read = x2apic_icr_read, | ||
211 | .icr_write = x2apic_icr_write, | ||
212 | .wait_icr_idle = x2apic_wait_icr_idle, | ||
213 | .safe_wait_icr_idle = safe_x2apic_wait_icr_idle, | ||
214 | }; | ||
215 | |||
144 | /** | 216 | /** |
145 | * enable_NMI_through_LVT0 - enable NMI through local vector table 0 | 217 | * enable_NMI_through_LVT0 - enable NMI through local vector table 0 |
146 | */ | 218 | */ |
@@ -630,10 +702,10 @@ int __init verify_local_APIC(void) | |||
630 | /* | 702 | /* |
631 | * The ID register is read/write in a real APIC. | 703 | * The ID register is read/write in a real APIC. |
632 | */ | 704 | */ |
633 | reg0 = read_apic_id(); | 705 | reg0 = apic_read(APIC_ID); |
634 | apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0); | 706 | apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0); |
635 | apic_write(APIC_ID, reg0 ^ APIC_ID_MASK); | 707 | apic_write(APIC_ID, reg0 ^ APIC_ID_MASK); |
636 | reg1 = read_apic_id(); | 708 | reg1 = apic_read(APIC_ID); |
637 | apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg1); | 709 | apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg1); |
638 | apic_write(APIC_ID, reg0); | 710 | apic_write(APIC_ID, reg0); |
639 | if (reg1 != (reg0 ^ APIC_ID_MASK)) | 711 | if (reg1 != (reg0 ^ APIC_ID_MASK)) |
@@ -834,6 +906,125 @@ void __cpuinit end_local_APIC_setup(void) | |||
834 | apic_pm_activate(); | 906 | apic_pm_activate(); |
835 | } | 907 | } |
836 | 908 | ||
909 | void check_x2apic(void) | ||
910 | { | ||
911 | int msr, msr2; | ||
912 | |||
913 | rdmsr(MSR_IA32_APICBASE, msr, msr2); | ||
914 | |||
915 | if (msr & X2APIC_ENABLE) { | ||
916 | printk("x2apic enabled by BIOS, switching to x2apic ops\n"); | ||
917 | x2apic_preenabled = x2apic = 1; | ||
918 | apic_ops = &x2apic_ops; | ||
919 | } | ||
920 | } | ||
921 | |||
922 | void enable_x2apic(void) | ||
923 | { | ||
924 | int msr, msr2; | ||
925 | |||
926 | rdmsr(MSR_IA32_APICBASE, msr, msr2); | ||
927 | if (!(msr & X2APIC_ENABLE)) { | ||
928 | printk("Enabling x2apic\n"); | ||
929 | wrmsr(MSR_IA32_APICBASE, msr | X2APIC_ENABLE, 0); | ||
930 | } | ||
931 | } | ||
932 | |||
933 | void enable_IR_x2apic(void) | ||
934 | { | ||
935 | #ifdef CONFIG_INTR_REMAP | ||
936 | int ret; | ||
937 | unsigned long flags; | ||
938 | |||
939 | if (!cpu_has_x2apic) | ||
940 | return; | ||
941 | |||
942 | if (!x2apic_preenabled && disable_x2apic) { | ||
943 | printk(KERN_INFO | ||
944 | "Skipped enabling x2apic and Interrupt-remapping " | ||
945 | "because of nox2apic\n"); | ||
946 | return; | ||
947 | } | ||
948 | |||
949 | if (x2apic_preenabled && disable_x2apic) | ||
950 | panic("Bios already enabled x2apic, can't enforce nox2apic"); | ||
951 | |||
952 | if (!x2apic_preenabled && skip_ioapic_setup) { | ||
953 | printk(KERN_INFO | ||
954 | "Skipped enabling x2apic and Interrupt-remapping " | ||
955 | "because of skipping io-apic setup\n"); | ||
956 | return; | ||
957 | } | ||
958 | |||
959 | ret = dmar_table_init(); | ||
960 | if (ret) { | ||
961 | printk(KERN_INFO | ||
962 | "dmar_table_init() failed with %d:\n", ret); | ||
963 | |||
964 | if (x2apic_preenabled) | ||
965 | panic("x2apic enabled by bios. But IR enabling failed"); | ||
966 | else | ||
967 | printk(KERN_INFO | ||
968 | "Not enabling x2apic,Intr-remapping\n"); | ||
969 | return; | ||
970 | } | ||
971 | |||
972 | local_irq_save(flags); | ||
973 | mask_8259A(); | ||
974 | save_mask_IO_APIC_setup(); | ||
975 | |||
976 | ret = enable_intr_remapping(1); | ||
977 | |||
978 | if (ret && x2apic_preenabled) { | ||
979 | local_irq_restore(flags); | ||
980 | panic("x2apic enabled by bios. But IR enabling failed"); | ||
981 | } | ||
982 | |||
983 | if (ret) | ||
984 | goto end; | ||
985 | |||
986 | if (!x2apic) { | ||
987 | x2apic = 1; | ||
988 | apic_ops = &x2apic_ops; | ||
989 | enable_x2apic(); | ||
990 | } | ||
991 | end: | ||
992 | if (ret) | ||
993 | /* | ||
994 | * IR enabling failed | ||
995 | */ | ||
996 | restore_IO_APIC_setup(); | ||
997 | else | ||
998 | reinit_intr_remapped_IO_APIC(x2apic_preenabled); | ||
999 | |||
1000 | unmask_8259A(); | ||
1001 | local_irq_restore(flags); | ||
1002 | |||
1003 | if (!ret) { | ||
1004 | if (!x2apic_preenabled) | ||
1005 | printk(KERN_INFO | ||
1006 | "Enabled x2apic and interrupt-remapping\n"); | ||
1007 | else | ||
1008 | printk(KERN_INFO | ||
1009 | "Enabled Interrupt-remapping\n"); | ||
1010 | } else | ||
1011 | printk(KERN_ERR | ||
1012 | "Failed to enable Interrupt-remapping and x2apic\n"); | ||
1013 | #else | ||
1014 | if (!cpu_has_x2apic) | ||
1015 | return; | ||
1016 | |||
1017 | if (x2apic_preenabled) | ||
1018 | panic("x2apic enabled prior OS handover," | ||
1019 | " enable CONFIG_INTR_REMAP"); | ||
1020 | |||
1021 | printk(KERN_INFO "Enable CONFIG_INTR_REMAP for enabling intr-remapping " | ||
1022 | " and x2apic\n"); | ||
1023 | #endif | ||
1024 | |||
1025 | return; | ||
1026 | } | ||
1027 | |||
837 | /* | 1028 | /* |
838 | * Detect and enable local APICs on non-SMP boards. | 1029 | * Detect and enable local APICs on non-SMP boards. |
839 | * Original code written by Keir Fraser. | 1030 | * Original code written by Keir Fraser. |
@@ -873,7 +1064,7 @@ void __init early_init_lapic_mapping(void) | |||
873 | * Fetch the APIC ID of the BSP in case we have a | 1064 | * Fetch the APIC ID of the BSP in case we have a |
874 | * default configuration (or the MP table is broken). | 1065 | * default configuration (or the MP table is broken). |
875 | */ | 1066 | */ |
876 | boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); | 1067 | boot_cpu_physical_apicid = read_apic_id(); |
877 | } | 1068 | } |
878 | 1069 | ||
879 | /** | 1070 | /** |
@@ -881,6 +1072,11 @@ void __init early_init_lapic_mapping(void) | |||
881 | */ | 1072 | */ |
882 | void __init init_apic_mappings(void) | 1073 | void __init init_apic_mappings(void) |
883 | { | 1074 | { |
1075 | if (x2apic) { | ||
1076 | boot_cpu_physical_apicid = read_apic_id(); | ||
1077 | return; | ||
1078 | } | ||
1079 | |||
884 | /* | 1080 | /* |
885 | * If no local APIC can be found then set up a fake all | 1081 | * If no local APIC can be found then set up a fake all |
886 | * zeroes page to simulate the local APIC and another | 1082 | * zeroes page to simulate the local APIC and another |
@@ -900,7 +1096,7 @@ void __init init_apic_mappings(void) | |||
900 | * Fetch the APIC ID of the BSP in case we have a | 1096 | * Fetch the APIC ID of the BSP in case we have a |
901 | * default configuration (or the MP table is broken). | 1097 | * default configuration (or the MP table is broken). |
902 | */ | 1098 | */ |
903 | boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); | 1099 | boot_cpu_physical_apicid = read_apic_id(); |
904 | } | 1100 | } |
905 | 1101 | ||
906 | /* | 1102 | /* |
@@ -919,6 +1115,9 @@ int __init APIC_init_uniprocessor(void) | |||
919 | return -1; | 1115 | return -1; |
920 | } | 1116 | } |
921 | 1117 | ||
1118 | enable_IR_x2apic(); | ||
1119 | setup_apic_routing(); | ||
1120 | |||
922 | verify_local_APIC(); | 1121 | verify_local_APIC(); |
923 | 1122 | ||
924 | connect_bsp_APIC(); | 1123 | connect_bsp_APIC(); |
@@ -1100,6 +1299,11 @@ void __cpuinit generic_processor_info(int apicid, int version) | |||
1100 | cpu_set(cpu, cpu_present_map); | 1299 | cpu_set(cpu, cpu_present_map); |
1101 | } | 1300 | } |
1102 | 1301 | ||
1302 | int hard_smp_processor_id(void) | ||
1303 | { | ||
1304 | return read_apic_id(); | ||
1305 | } | ||
1306 | |||
1103 | /* | 1307 | /* |
1104 | * Power management | 1308 | * Power management |
1105 | */ | 1309 | */ |
@@ -1136,7 +1340,7 @@ static int lapic_suspend(struct sys_device *dev, pm_message_t state) | |||
1136 | 1340 | ||
1137 | maxlvt = lapic_get_maxlvt(); | 1341 | maxlvt = lapic_get_maxlvt(); |
1138 | 1342 | ||
1139 | apic_pm_state.apic_id = read_apic_id(); | 1343 | apic_pm_state.apic_id = apic_read(APIC_ID); |
1140 | apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI); | 1344 | apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI); |
1141 | apic_pm_state.apic_ldr = apic_read(APIC_LDR); | 1345 | apic_pm_state.apic_ldr = apic_read(APIC_LDR); |
1142 | apic_pm_state.apic_dfr = apic_read(APIC_DFR); | 1346 | apic_pm_state.apic_dfr = apic_read(APIC_DFR); |
@@ -1171,10 +1375,14 @@ static int lapic_resume(struct sys_device *dev) | |||
1171 | maxlvt = lapic_get_maxlvt(); | 1375 | maxlvt = lapic_get_maxlvt(); |
1172 | 1376 | ||
1173 | local_irq_save(flags); | 1377 | local_irq_save(flags); |
1174 | rdmsr(MSR_IA32_APICBASE, l, h); | 1378 | if (!x2apic) { |
1175 | l &= ~MSR_IA32_APICBASE_BASE; | 1379 | rdmsr(MSR_IA32_APICBASE, l, h); |
1176 | l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr; | 1380 | l &= ~MSR_IA32_APICBASE_BASE; |
1177 | wrmsr(MSR_IA32_APICBASE, l, h); | 1381 | l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr; |
1382 | wrmsr(MSR_IA32_APICBASE, l, h); | ||
1383 | } else | ||
1384 | enable_x2apic(); | ||
1385 | |||
1178 | apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED); | 1386 | apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED); |
1179 | apic_write(APIC_ID, apic_pm_state.apic_id); | 1387 | apic_write(APIC_ID, apic_pm_state.apic_id); |
1180 | apic_write(APIC_DFR, apic_pm_state.apic_dfr); | 1388 | apic_write(APIC_DFR, apic_pm_state.apic_dfr); |
@@ -1314,6 +1522,15 @@ __cpuinit int apic_is_clustered_box(void) | |||
1314 | return (clusters > 2); | 1522 | return (clusters > 2); |
1315 | } | 1523 | } |
1316 | 1524 | ||
1525 | static __init int setup_nox2apic(char *str) | ||
1526 | { | ||
1527 | disable_x2apic = 1; | ||
1528 | clear_cpu_cap(&boot_cpu_data, X86_FEATURE_X2APIC); | ||
1529 | return 0; | ||
1530 | } | ||
1531 | early_param("nox2apic", setup_nox2apic); | ||
1532 | |||
1533 | |||
1317 | /* | 1534 | /* |
1318 | * APIC command line parameters | 1535 | * APIC command line parameters |
1319 | */ | 1536 | */ |
diff --git a/arch/x86/kernel/cpu/common_64.c b/arch/x86/kernel/cpu/common_64.c index 7b8cc72feb40..c6bee77ca9e6 100644 --- a/arch/x86/kernel/cpu/common_64.c +++ b/arch/x86/kernel/cpu/common_64.c | |||
@@ -608,6 +608,8 @@ void __cpuinit cpu_init(void) | |||
608 | barrier(); | 608 | barrier(); |
609 | 609 | ||
610 | check_efer(); | 610 | check_efer(); |
611 | if (cpu != 0 && x2apic) | ||
612 | enable_x2apic(); | ||
611 | 613 | ||
612 | /* | 614 | /* |
613 | * set up and load the per-CPU TSS | 615 | * set up and load the per-CPU TSS |
diff --git a/arch/x86/kernel/cpu/feature_names.c b/arch/x86/kernel/cpu/feature_names.c index e43ad4ad4cba..0bf4d37a0483 100644 --- a/arch/x86/kernel/cpu/feature_names.c +++ b/arch/x86/kernel/cpu/feature_names.c | |||
@@ -45,7 +45,7 @@ const char * const x86_cap_flags[NCAPINTS*32] = { | |||
45 | /* Intel-defined (#2) */ | 45 | /* Intel-defined (#2) */ |
46 | "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est", | 46 | "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est", |
47 | "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL, | 47 | "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL, |
48 | NULL, NULL, "dca", "sse4_1", "sse4_2", NULL, NULL, "popcnt", | 48 | NULL, NULL, "dca", "sse4_1", "sse4_2", "x2apic", NULL, "popcnt", |
49 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | 49 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
50 | 50 | ||
51 | /* VIA/Cyrix/Centaur-defined */ | 51 | /* VIA/Cyrix/Centaur-defined */ |
diff --git a/arch/x86/kernel/genapic_64.c b/arch/x86/kernel/genapic_64.c index 1fa8be5bd217..3940d8161f8b 100644 --- a/arch/x86/kernel/genapic_64.c +++ b/arch/x86/kernel/genapic_64.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/ctype.h> | 16 | #include <linux/ctype.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/hardirq.h> | 18 | #include <linux/hardirq.h> |
19 | #include <linux/dmar.h> | ||
19 | 20 | ||
20 | #include <asm/smp.h> | 21 | #include <asm/smp.h> |
21 | #include <asm/ipi.h> | 22 | #include <asm/ipi.h> |
@@ -29,6 +30,15 @@ DEFINE_PER_CPU(int, x2apic_extra_bits); | |||
29 | 30 | ||
30 | struct genapic __read_mostly *genapic = &apic_flat; | 31 | struct genapic __read_mostly *genapic = &apic_flat; |
31 | 32 | ||
33 | static int x2apic_phys = 0; | ||
34 | |||
35 | static int set_x2apic_phys_mode(char *arg) | ||
36 | { | ||
37 | x2apic_phys = 1; | ||
38 | return 0; | ||
39 | } | ||
40 | early_param("x2apic_phys", set_x2apic_phys_mode); | ||
41 | |||
32 | static enum uv_system_type uv_system_type; | 42 | static enum uv_system_type uv_system_type; |
33 | 43 | ||
34 | /* | 44 | /* |
@@ -38,7 +48,12 @@ void __init setup_apic_routing(void) | |||
38 | { | 48 | { |
39 | if (uv_system_type == UV_NON_UNIQUE_APIC) | 49 | if (uv_system_type == UV_NON_UNIQUE_APIC) |
40 | genapic = &apic_x2apic_uv_x; | 50 | genapic = &apic_x2apic_uv_x; |
41 | else | 51 | else if (cpu_has_x2apic && intr_remapping_enabled) { |
52 | if (x2apic_phys) | ||
53 | genapic = &apic_x2apic_phys; | ||
54 | else | ||
55 | genapic = &apic_x2apic_cluster; | ||
56 | } else | ||
42 | #ifdef CONFIG_ACPI | 57 | #ifdef CONFIG_ACPI |
43 | /* | 58 | /* |
44 | * Quirk: some x86_64 machines can only use physical APIC mode | 59 | * Quirk: some x86_64 machines can only use physical APIC mode |
@@ -61,7 +76,7 @@ void __init setup_apic_routing(void) | |||
61 | 76 | ||
62 | /* Same for both flat and physical. */ | 77 | /* Same for both flat and physical. */ |
63 | 78 | ||
64 | void send_IPI_self(int vector) | 79 | void apic_send_IPI_self(int vector) |
65 | { | 80 | { |
66 | __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); | 81 | __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); |
67 | } | 82 | } |
@@ -79,17 +94,6 @@ int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id) | |||
79 | return 0; | 94 | return 0; |
80 | } | 95 | } |
81 | 96 | ||
82 | unsigned int read_apic_id(void) | ||
83 | { | ||
84 | unsigned int id; | ||
85 | |||
86 | WARN_ON(preemptible() && num_online_cpus() > 1); | ||
87 | id = apic_read(APIC_ID); | ||
88 | if (uv_system_type >= UV_X2APIC) | ||
89 | id |= __get_cpu_var(x2apic_extra_bits); | ||
90 | return id; | ||
91 | } | ||
92 | |||
93 | enum uv_system_type get_uv_system_type(void) | 97 | enum uv_system_type get_uv_system_type(void) |
94 | { | 98 | { |
95 | return uv_system_type; | 99 | return uv_system_type; |
diff --git a/arch/x86/kernel/genapic_flat_64.c b/arch/x86/kernel/genapic_flat_64.c index 1a9c68845ee8..2c973cbf054f 100644 --- a/arch/x86/kernel/genapic_flat_64.c +++ b/arch/x86/kernel/genapic_flat_64.c | |||
@@ -15,9 +15,11 @@ | |||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/ctype.h> | 16 | #include <linux/ctype.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/hardirq.h> | ||
18 | #include <asm/smp.h> | 19 | #include <asm/smp.h> |
19 | #include <asm/ipi.h> | 20 | #include <asm/ipi.h> |
20 | #include <asm/genapic.h> | 21 | #include <asm/genapic.h> |
22 | #include <mach_apicdef.h> | ||
21 | 23 | ||
22 | static cpumask_t flat_target_cpus(void) | 24 | static cpumask_t flat_target_cpus(void) |
23 | { | 25 | { |
@@ -95,9 +97,33 @@ static void flat_send_IPI_all(int vector) | |||
95 | __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL); | 97 | __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL); |
96 | } | 98 | } |
97 | 99 | ||
100 | static unsigned int get_apic_id(unsigned long x) | ||
101 | { | ||
102 | unsigned int id; | ||
103 | |||
104 | id = (((x)>>24) & 0xFFu); | ||
105 | return id; | ||
106 | } | ||
107 | |||
108 | static unsigned long set_apic_id(unsigned int id) | ||
109 | { | ||
110 | unsigned long x; | ||
111 | |||
112 | x = ((id & 0xFFu)<<24); | ||
113 | return x; | ||
114 | } | ||
115 | |||
116 | static unsigned int read_xapic_id(void) | ||
117 | { | ||
118 | unsigned int id; | ||
119 | |||
120 | id = get_apic_id(apic_read(APIC_ID)); | ||
121 | return id; | ||
122 | } | ||
123 | |||
98 | static int flat_apic_id_registered(void) | 124 | static int flat_apic_id_registered(void) |
99 | { | 125 | { |
100 | return physid_isset(GET_APIC_ID(read_apic_id()), phys_cpu_present_map); | 126 | return physid_isset(read_xapic_id(), phys_cpu_present_map); |
101 | } | 127 | } |
102 | 128 | ||
103 | static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask) | 129 | static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask) |
@@ -121,8 +147,12 @@ struct genapic apic_flat = { | |||
121 | .send_IPI_all = flat_send_IPI_all, | 147 | .send_IPI_all = flat_send_IPI_all, |
122 | .send_IPI_allbutself = flat_send_IPI_allbutself, | 148 | .send_IPI_allbutself = flat_send_IPI_allbutself, |
123 | .send_IPI_mask = flat_send_IPI_mask, | 149 | .send_IPI_mask = flat_send_IPI_mask, |
150 | .send_IPI_self = apic_send_IPI_self, | ||
124 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, | 151 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, |
125 | .phys_pkg_id = phys_pkg_id, | 152 | .phys_pkg_id = phys_pkg_id, |
153 | .get_apic_id = get_apic_id, | ||
154 | .set_apic_id = set_apic_id, | ||
155 | .apic_id_mask = (0xFFu<<24), | ||
126 | }; | 156 | }; |
127 | 157 | ||
128 | /* | 158 | /* |
@@ -185,6 +215,10 @@ struct genapic apic_physflat = { | |||
185 | .send_IPI_all = physflat_send_IPI_all, | 215 | .send_IPI_all = physflat_send_IPI_all, |
186 | .send_IPI_allbutself = physflat_send_IPI_allbutself, | 216 | .send_IPI_allbutself = physflat_send_IPI_allbutself, |
187 | .send_IPI_mask = physflat_send_IPI_mask, | 217 | .send_IPI_mask = physflat_send_IPI_mask, |
218 | .send_IPI_self = apic_send_IPI_self, | ||
188 | .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, | 219 | .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, |
189 | .phys_pkg_id = phys_pkg_id, | 220 | .phys_pkg_id = phys_pkg_id, |
221 | .get_apic_id = get_apic_id, | ||
222 | .set_apic_id = set_apic_id, | ||
223 | .apic_id_mask = (0xFFu<<24), | ||
190 | }; | 224 | }; |
diff --git a/arch/x86/kernel/genx2apic_cluster.c b/arch/x86/kernel/genx2apic_cluster.c new file mode 100644 index 000000000000..40bc0140d89f --- /dev/null +++ b/arch/x86/kernel/genx2apic_cluster.c | |||
@@ -0,0 +1,153 @@ | |||
1 | #include <linux/threads.h> | ||
2 | #include <linux/cpumask.h> | ||
3 | #include <linux/string.h> | ||
4 | #include <linux/kernel.h> | ||
5 | #include <linux/ctype.h> | ||
6 | #include <linux/init.h> | ||
7 | #include <asm/smp.h> | ||
8 | #include <asm/ipi.h> | ||
9 | #include <asm/genapic.h> | ||
10 | |||
11 | DEFINE_PER_CPU(u32, x86_cpu_to_logical_apicid); | ||
12 | |||
13 | /* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */ | ||
14 | |||
15 | static cpumask_t x2apic_target_cpus(void) | ||
16 | { | ||
17 | return cpumask_of_cpu(0); | ||
18 | } | ||
19 | |||
20 | /* | ||
21 | * for now each logical cpu is in its own vector allocation domain. | ||
22 | */ | ||
23 | static cpumask_t x2apic_vector_allocation_domain(int cpu) | ||
24 | { | ||
25 | cpumask_t domain = CPU_MASK_NONE; | ||
26 | cpu_set(cpu, domain); | ||
27 | return domain; | ||
28 | } | ||
29 | |||
30 | static void __x2apic_send_IPI_dest(unsigned int apicid, int vector, | ||
31 | unsigned int dest) | ||
32 | { | ||
33 | unsigned long cfg; | ||
34 | |||
35 | cfg = __prepare_ICR(0, vector, dest); | ||
36 | |||
37 | /* | ||
38 | * send the IPI. | ||
39 | */ | ||
40 | x2apic_icr_write(cfg, apicid); | ||
41 | } | ||
42 | |||
43 | /* | ||
44 | * for now, we send the IPI's one by one in the cpumask. | ||
45 | * TBD: Based on the cpu mask, we can send the IPI's to the cluster group | ||
46 | * at once. We have 16 cpu's in a cluster. This will minimize IPI register | ||
47 | * writes. | ||
48 | */ | ||
49 | static void x2apic_send_IPI_mask(cpumask_t mask, int vector) | ||
50 | { | ||
51 | unsigned long flags; | ||
52 | unsigned long query_cpu; | ||
53 | |||
54 | local_irq_save(flags); | ||
55 | for_each_cpu_mask(query_cpu, mask) { | ||
56 | __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_logical_apicid, query_cpu), | ||
57 | vector, APIC_DEST_LOGICAL); | ||
58 | } | ||
59 | local_irq_restore(flags); | ||
60 | } | ||
61 | |||
62 | static void x2apic_send_IPI_allbutself(int vector) | ||
63 | { | ||
64 | cpumask_t mask = cpu_online_map; | ||
65 | |||
66 | cpu_clear(smp_processor_id(), mask); | ||
67 | |||
68 | if (!cpus_empty(mask)) | ||
69 | x2apic_send_IPI_mask(mask, vector); | ||
70 | } | ||
71 | |||
72 | static void x2apic_send_IPI_all(int vector) | ||
73 | { | ||
74 | x2apic_send_IPI_mask(cpu_online_map, vector); | ||
75 | } | ||
76 | |||
77 | static int x2apic_apic_id_registered(void) | ||
78 | { | ||
79 | return 1; | ||
80 | } | ||
81 | |||
82 | static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask) | ||
83 | { | ||
84 | int cpu; | ||
85 | |||
86 | /* | ||
87 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
88 | * May as well be the first. | ||
89 | */ | ||
90 | cpu = first_cpu(cpumask); | ||
91 | if ((unsigned)cpu < NR_CPUS) | ||
92 | return per_cpu(x86_cpu_to_logical_apicid, cpu); | ||
93 | else | ||
94 | return BAD_APICID; | ||
95 | } | ||
96 | |||
97 | static unsigned int get_apic_id(unsigned long x) | ||
98 | { | ||
99 | unsigned int id; | ||
100 | |||
101 | id = x; | ||
102 | return id; | ||
103 | } | ||
104 | |||
105 | static unsigned long set_apic_id(unsigned int id) | ||
106 | { | ||
107 | unsigned long x; | ||
108 | |||
109 | x = id; | ||
110 | return x; | ||
111 | } | ||
112 | |||
113 | static unsigned int x2apic_read_id(void) | ||
114 | { | ||
115 | return apic_read(APIC_ID); | ||
116 | } | ||
117 | |||
118 | static unsigned int phys_pkg_id(int index_msb) | ||
119 | { | ||
120 | return x2apic_read_id() >> index_msb; | ||
121 | } | ||
122 | |||
123 | static void x2apic_send_IPI_self(int vector) | ||
124 | { | ||
125 | apic_write(APIC_SELF_IPI, vector); | ||
126 | } | ||
127 | |||
128 | static void init_x2apic_ldr(void) | ||
129 | { | ||
130 | int cpu = smp_processor_id(); | ||
131 | |||
132 | per_cpu(x86_cpu_to_logical_apicid, cpu) = apic_read(APIC_LDR); | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | struct genapic apic_x2apic_cluster = { | ||
137 | .name = "cluster x2apic", | ||
138 | .int_delivery_mode = dest_LowestPrio, | ||
139 | .int_dest_mode = (APIC_DEST_LOGICAL != 0), | ||
140 | .target_cpus = x2apic_target_cpus, | ||
141 | .vector_allocation_domain = x2apic_vector_allocation_domain, | ||
142 | .apic_id_registered = x2apic_apic_id_registered, | ||
143 | .init_apic_ldr = init_x2apic_ldr, | ||
144 | .send_IPI_all = x2apic_send_IPI_all, | ||
145 | .send_IPI_allbutself = x2apic_send_IPI_allbutself, | ||
146 | .send_IPI_mask = x2apic_send_IPI_mask, | ||
147 | .send_IPI_self = x2apic_send_IPI_self, | ||
148 | .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, | ||
149 | .phys_pkg_id = phys_pkg_id, | ||
150 | .get_apic_id = get_apic_id, | ||
151 | .set_apic_id = set_apic_id, | ||
152 | .apic_id_mask = (0xFFFFFFFFu), | ||
153 | }; | ||
diff --git a/arch/x86/kernel/genx2apic_phys.c b/arch/x86/kernel/genx2apic_phys.c new file mode 100644 index 000000000000..2f3c6ca19de9 --- /dev/null +++ b/arch/x86/kernel/genx2apic_phys.c | |||
@@ -0,0 +1,140 @@ | |||
1 | #include <linux/threads.h> | ||
2 | #include <linux/cpumask.h> | ||
3 | #include <linux/string.h> | ||
4 | #include <linux/kernel.h> | ||
5 | #include <linux/ctype.h> | ||
6 | #include <linux/init.h> | ||
7 | #include <asm/smp.h> | ||
8 | #include <asm/ipi.h> | ||
9 | #include <asm/genapic.h> | ||
10 | |||
11 | |||
12 | /* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */ | ||
13 | |||
14 | static cpumask_t x2apic_target_cpus(void) | ||
15 | { | ||
16 | return cpumask_of_cpu(0); | ||
17 | } | ||
18 | |||
19 | static cpumask_t x2apic_vector_allocation_domain(int cpu) | ||
20 | { | ||
21 | cpumask_t domain = CPU_MASK_NONE; | ||
22 | cpu_set(cpu, domain); | ||
23 | return domain; | ||
24 | } | ||
25 | |||
26 | static void __x2apic_send_IPI_dest(unsigned int apicid, int vector, | ||
27 | unsigned int dest) | ||
28 | { | ||
29 | unsigned long cfg; | ||
30 | |||
31 | cfg = __prepare_ICR(0, vector, dest); | ||
32 | |||
33 | /* | ||
34 | * send the IPI. | ||
35 | */ | ||
36 | x2apic_icr_write(cfg, apicid); | ||
37 | } | ||
38 | |||
39 | static void x2apic_send_IPI_mask(cpumask_t mask, int vector) | ||
40 | { | ||
41 | unsigned long flags; | ||
42 | unsigned long query_cpu; | ||
43 | |||
44 | local_irq_save(flags); | ||
45 | for_each_cpu_mask(query_cpu, mask) { | ||
46 | __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), | ||
47 | vector, APIC_DEST_PHYSICAL); | ||
48 | } | ||
49 | local_irq_restore(flags); | ||
50 | } | ||
51 | |||
52 | static void x2apic_send_IPI_allbutself(int vector) | ||
53 | { | ||
54 | cpumask_t mask = cpu_online_map; | ||
55 | |||
56 | cpu_clear(smp_processor_id(), mask); | ||
57 | |||
58 | if (!cpus_empty(mask)) | ||
59 | x2apic_send_IPI_mask(mask, vector); | ||
60 | } | ||
61 | |||
62 | static void x2apic_send_IPI_all(int vector) | ||
63 | { | ||
64 | x2apic_send_IPI_mask(cpu_online_map, vector); | ||
65 | } | ||
66 | |||
67 | static int x2apic_apic_id_registered(void) | ||
68 | { | ||
69 | return 1; | ||
70 | } | ||
71 | |||
72 | static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask) | ||
73 | { | ||
74 | int cpu; | ||
75 | |||
76 | /* | ||
77 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
78 | * May as well be the first. | ||
79 | */ | ||
80 | cpu = first_cpu(cpumask); | ||
81 | if ((unsigned)cpu < NR_CPUS) | ||
82 | return per_cpu(x86_cpu_to_apicid, cpu); | ||
83 | else | ||
84 | return BAD_APICID; | ||
85 | } | ||
86 | |||
87 | static unsigned int get_apic_id(unsigned long x) | ||
88 | { | ||
89 | unsigned int id; | ||
90 | |||
91 | id = x; | ||
92 | return id; | ||
93 | } | ||
94 | |||
95 | static unsigned long set_apic_id(unsigned int id) | ||
96 | { | ||
97 | unsigned long x; | ||
98 | |||
99 | x = id; | ||
100 | return x; | ||
101 | } | ||
102 | |||
103 | static unsigned int x2apic_read_id(void) | ||
104 | { | ||
105 | return apic_read(APIC_ID); | ||
106 | } | ||
107 | |||
108 | static unsigned int phys_pkg_id(int index_msb) | ||
109 | { | ||
110 | return x2apic_read_id() >> index_msb; | ||
111 | } | ||
112 | |||
113 | void x2apic_send_IPI_self(int vector) | ||
114 | { | ||
115 | apic_write(APIC_SELF_IPI, vector); | ||
116 | } | ||
117 | |||
118 | void init_x2apic_ldr(void) | ||
119 | { | ||
120 | return; | ||
121 | } | ||
122 | |||
123 | struct genapic apic_x2apic_phys = { | ||
124 | .name = "physical x2apic", | ||
125 | .int_delivery_mode = dest_Fixed, | ||
126 | .int_dest_mode = (APIC_DEST_PHYSICAL != 0), | ||
127 | .target_cpus = x2apic_target_cpus, | ||
128 | .vector_allocation_domain = x2apic_vector_allocation_domain, | ||
129 | .apic_id_registered = x2apic_apic_id_registered, | ||
130 | .init_apic_ldr = init_x2apic_ldr, | ||
131 | .send_IPI_all = x2apic_send_IPI_all, | ||
132 | .send_IPI_allbutself = x2apic_send_IPI_allbutself, | ||
133 | .send_IPI_mask = x2apic_send_IPI_mask, | ||
134 | .send_IPI_self = x2apic_send_IPI_self, | ||
135 | .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, | ||
136 | .phys_pkg_id = phys_pkg_id, | ||
137 | .get_apic_id = get_apic_id, | ||
138 | .set_apic_id = set_apic_id, | ||
139 | .apic_id_mask = (0xFFFFFFFFu), | ||
140 | }; | ||
diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c index 711f11c30b06..3ca29cd8c23c 100644 --- a/arch/x86/kernel/genx2apic_uv_x.c +++ b/arch/x86/kernel/genx2apic_uv_x.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/bootmem.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/hardirq.h> | ||
21 | #include <asm/smp.h> | 22 | #include <asm/smp.h> |
22 | #include <asm/ipi.h> | 23 | #include <asm/ipi.h> |
23 | #include <asm/genapic.h> | 24 | #include <asm/genapic.h> |
@@ -119,6 +120,10 @@ static int uv_apic_id_registered(void) | |||
119 | return 1; | 120 | return 1; |
120 | } | 121 | } |
121 | 122 | ||
123 | static void uv_init_apic_ldr(void) | ||
124 | { | ||
125 | } | ||
126 | |||
122 | static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask) | 127 | static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask) |
123 | { | 128 | { |
124 | int cpu; | 129 | int cpu; |
@@ -134,9 +139,34 @@ static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask) | |||
134 | return BAD_APICID; | 139 | return BAD_APICID; |
135 | } | 140 | } |
136 | 141 | ||
142 | static unsigned int get_apic_id(unsigned long x) | ||
143 | { | ||
144 | unsigned int id; | ||
145 | |||
146 | WARN_ON(preemptible() && num_online_cpus() > 1); | ||
147 | id = x | __get_cpu_var(x2apic_extra_bits); | ||
148 | |||
149 | return id; | ||
150 | } | ||
151 | |||
152 | static long set_apic_id(unsigned int id) | ||
153 | { | ||
154 | unsigned long x; | ||
155 | |||
156 | /* maskout x2apic_extra_bits ? */ | ||
157 | x = id; | ||
158 | return x; | ||
159 | } | ||
160 | |||
161 | static unsigned int uv_read_apic_id(void) | ||
162 | { | ||
163 | |||
164 | return get_apic_id(apic_read(APIC_ID)); | ||
165 | } | ||
166 | |||
137 | static unsigned int phys_pkg_id(int index_msb) | 167 | static unsigned int phys_pkg_id(int index_msb) |
138 | { | 168 | { |
139 | return GET_APIC_ID(read_apic_id()) >> index_msb; | 169 | return uv_read_apic_id() >> index_msb; |
140 | } | 170 | } |
141 | 171 | ||
142 | #ifdef ZZZ /* Needs x2apic patch */ | 172 | #ifdef ZZZ /* Needs x2apic patch */ |
@@ -153,12 +183,16 @@ struct genapic apic_x2apic_uv_x = { | |||
153 | .target_cpus = uv_target_cpus, | 183 | .target_cpus = uv_target_cpus, |
154 | .vector_allocation_domain = uv_vector_allocation_domain,/* Fixme ZZZ */ | 184 | .vector_allocation_domain = uv_vector_allocation_domain,/* Fixme ZZZ */ |
155 | .apic_id_registered = uv_apic_id_registered, | 185 | .apic_id_registered = uv_apic_id_registered, |
186 | .init_apic_ldr = uv_init_apic_ldr, | ||
156 | .send_IPI_all = uv_send_IPI_all, | 187 | .send_IPI_all = uv_send_IPI_all, |
157 | .send_IPI_allbutself = uv_send_IPI_allbutself, | 188 | .send_IPI_allbutself = uv_send_IPI_allbutself, |
158 | .send_IPI_mask = uv_send_IPI_mask, | 189 | .send_IPI_mask = uv_send_IPI_mask, |
159 | /* ZZZ.send_IPI_self = uv_send_IPI_self, */ | 190 | /* ZZZ.send_IPI_self = uv_send_IPI_self, */ |
160 | .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, | 191 | .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, |
161 | .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */ | 192 | .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */ |
193 | .get_apic_id = get_apic_id, | ||
194 | .set_apic_id = set_apic_id, | ||
195 | .apic_id_mask = (0xFFFFFFFFu), | ||
162 | }; | 196 | }; |
163 | 197 | ||
164 | static __cpuinit void set_x2apic_extra_bits(int pnode) | 198 | static __cpuinit void set_x2apic_extra_bits(int pnode) |
diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c index dc92b49d9204..4b8a53d841f7 100644 --- a/arch/x86/kernel/i8259.c +++ b/arch/x86/kernel/i8259.c | |||
@@ -282,6 +282,30 @@ static int __init i8259A_init_sysfs(void) | |||
282 | 282 | ||
283 | device_initcall(i8259A_init_sysfs); | 283 | device_initcall(i8259A_init_sysfs); |
284 | 284 | ||
285 | void mask_8259A(void) | ||
286 | { | ||
287 | unsigned long flags; | ||
288 | |||
289 | spin_lock_irqsave(&i8259A_lock, flags); | ||
290 | |||
291 | outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */ | ||
292 | outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-2 */ | ||
293 | |||
294 | spin_unlock_irqrestore(&i8259A_lock, flags); | ||
295 | } | ||
296 | |||
297 | void unmask_8259A(void) | ||
298 | { | ||
299 | unsigned long flags; | ||
300 | |||
301 | spin_lock_irqsave(&i8259A_lock, flags); | ||
302 | |||
303 | outb(cached_master_mask, PIC_MASTER_IMR); /* restore master IRQ mask */ | ||
304 | outb(cached_slave_mask, PIC_SLAVE_IMR); /* restore slave IRQ mask */ | ||
305 | |||
306 | spin_unlock_irqrestore(&i8259A_lock, flags); | ||
307 | } | ||
308 | |||
285 | void init_8259A(int auto_eoi) | 309 | void init_8259A(int auto_eoi) |
286 | { | 310 | { |
287 | unsigned long flags; | 311 | unsigned long flags; |
diff --git a/arch/x86/kernel/io_apic_32.c b/arch/x86/kernel/io_apic_32.c index de9aa0e3a9c5..98e4db5373f3 100644 --- a/arch/x86/kernel/io_apic_32.c +++ b/arch/x86/kernel/io_apic_32.c | |||
@@ -1494,7 +1494,7 @@ void /*__init*/ print_local_APIC(void *dummy) | |||
1494 | smp_processor_id(), hard_smp_processor_id()); | 1494 | smp_processor_id(), hard_smp_processor_id()); |
1495 | v = apic_read(APIC_ID); | 1495 | v = apic_read(APIC_ID); |
1496 | printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, | 1496 | printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, |
1497 | GET_APIC_ID(read_apic_id())); | 1497 | GET_APIC_ID(v)); |
1498 | v = apic_read(APIC_LVR); | 1498 | v = apic_read(APIC_LVR); |
1499 | printk(KERN_INFO "... APIC VERSION: %08x\n", v); | 1499 | printk(KERN_INFO "... APIC VERSION: %08x\n", v); |
1500 | ver = GET_APIC_VERSION(v); | 1500 | ver = GET_APIC_VERSION(v); |
@@ -1702,8 +1702,7 @@ void disable_IO_APIC(void) | |||
1702 | entry.dest_mode = 0; /* Physical */ | 1702 | entry.dest_mode = 0; /* Physical */ |
1703 | entry.delivery_mode = dest_ExtINT; /* ExtInt */ | 1703 | entry.delivery_mode = dest_ExtINT; /* ExtInt */ |
1704 | entry.vector = 0; | 1704 | entry.vector = 0; |
1705 | entry.dest.physical.physical_dest = | 1705 | entry.dest.physical.physical_dest = read_apic_id(); |
1706 | GET_APIC_ID(read_apic_id()); | ||
1707 | 1706 | ||
1708 | /* | 1707 | /* |
1709 | * Add it to the IO-APIC irq-routing table: | 1708 | * Add it to the IO-APIC irq-routing table: |
diff --git a/arch/x86/kernel/io_apic_64.c b/arch/x86/kernel/io_apic_64.c index 64a46affd858..116aac365981 100644 --- a/arch/x86/kernel/io_apic_64.c +++ b/arch/x86/kernel/io_apic_64.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <acpi/acpi_bus.h> | 37 | #include <acpi/acpi_bus.h> |
38 | #endif | 38 | #endif |
39 | #include <linux/bootmem.h> | 39 | #include <linux/bootmem.h> |
40 | #include <linux/dmar.h> | ||
40 | 41 | ||
41 | #include <asm/idle.h> | 42 | #include <asm/idle.h> |
42 | #include <asm/io.h> | 43 | #include <asm/io.h> |
@@ -49,6 +50,7 @@ | |||
49 | #include <asm/nmi.h> | 50 | #include <asm/nmi.h> |
50 | #include <asm/msidef.h> | 51 | #include <asm/msidef.h> |
51 | #include <asm/hypertransport.h> | 52 | #include <asm/hypertransport.h> |
53 | #include <asm/irq_remapping.h> | ||
52 | 54 | ||
53 | #include <mach_ipi.h> | 55 | #include <mach_ipi.h> |
54 | #include <mach_apic.h> | 56 | #include <mach_apic.h> |
@@ -108,6 +110,9 @@ DEFINE_SPINLOCK(vector_lock); | |||
108 | */ | 110 | */ |
109 | int nr_ioapic_registers[MAX_IO_APICS]; | 111 | int nr_ioapic_registers[MAX_IO_APICS]; |
110 | 112 | ||
113 | /* I/O APIC RTE contents at the OS boot up */ | ||
114 | struct IO_APIC_route_entry *early_ioapic_entries[MAX_IO_APICS]; | ||
115 | |||
111 | /* I/O APIC entries */ | 116 | /* I/O APIC entries */ |
112 | struct mp_config_ioapic mp_ioapics[MAX_IO_APICS]; | 117 | struct mp_config_ioapic mp_ioapics[MAX_IO_APICS]; |
113 | int nr_ioapics; | 118 | int nr_ioapics; |
@@ -303,7 +308,12 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, u8 vector) | |||
303 | pin = entry->pin; | 308 | pin = entry->pin; |
304 | if (pin == -1) | 309 | if (pin == -1) |
305 | break; | 310 | break; |
306 | io_apic_write(apic, 0x11 + pin*2, dest); | 311 | /* |
312 | * With interrupt-remapping, destination information comes | ||
313 | * from interrupt-remapping table entry. | ||
314 | */ | ||
315 | if (!irq_remapped(irq)) | ||
316 | io_apic_write(apic, 0x11 + pin*2, dest); | ||
307 | reg = io_apic_read(apic, 0x10 + pin*2); | 317 | reg = io_apic_read(apic, 0x10 + pin*2); |
308 | reg &= ~IO_APIC_REDIR_VECTOR_MASK; | 318 | reg &= ~IO_APIC_REDIR_VECTOR_MASK; |
309 | reg |= vector; | 319 | reg |= vector; |
@@ -440,6 +450,69 @@ static void clear_IO_APIC (void) | |||
440 | clear_IO_APIC_pin(apic, pin); | 450 | clear_IO_APIC_pin(apic, pin); |
441 | } | 451 | } |
442 | 452 | ||
453 | /* | ||
454 | * Saves and masks all the unmasked IO-APIC RTE's | ||
455 | */ | ||
456 | int save_mask_IO_APIC_setup(void) | ||
457 | { | ||
458 | union IO_APIC_reg_01 reg_01; | ||
459 | unsigned long flags; | ||
460 | int apic, pin; | ||
461 | |||
462 | /* | ||
463 | * The number of IO-APIC IRQ registers (== #pins): | ||
464 | */ | ||
465 | for (apic = 0; apic < nr_ioapics; apic++) { | ||
466 | spin_lock_irqsave(&ioapic_lock, flags); | ||
467 | reg_01.raw = io_apic_read(apic, 1); | ||
468 | spin_unlock_irqrestore(&ioapic_lock, flags); | ||
469 | nr_ioapic_registers[apic] = reg_01.bits.entries+1; | ||
470 | } | ||
471 | |||
472 | for (apic = 0; apic < nr_ioapics; apic++) { | ||
473 | early_ioapic_entries[apic] = | ||
474 | kzalloc(sizeof(struct IO_APIC_route_entry) * | ||
475 | nr_ioapic_registers[apic], GFP_KERNEL); | ||
476 | if (!early_ioapic_entries[apic]) | ||
477 | return -ENOMEM; | ||
478 | } | ||
479 | |||
480 | for (apic = 0; apic < nr_ioapics; apic++) | ||
481 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { | ||
482 | struct IO_APIC_route_entry entry; | ||
483 | |||
484 | entry = early_ioapic_entries[apic][pin] = | ||
485 | ioapic_read_entry(apic, pin); | ||
486 | if (!entry.mask) { | ||
487 | entry.mask = 1; | ||
488 | ioapic_write_entry(apic, pin, entry); | ||
489 | } | ||
490 | } | ||
491 | return 0; | ||
492 | } | ||
493 | |||
494 | void restore_IO_APIC_setup(void) | ||
495 | { | ||
496 | int apic, pin; | ||
497 | |||
498 | for (apic = 0; apic < nr_ioapics; apic++) | ||
499 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) | ||
500 | ioapic_write_entry(apic, pin, | ||
501 | early_ioapic_entries[apic][pin]); | ||
502 | } | ||
503 | |||
504 | void reinit_intr_remapped_IO_APIC(int intr_remapping) | ||
505 | { | ||
506 | /* | ||
507 | * for now plain restore of previous settings. | ||
508 | * TBD: In the case of OS enabling interrupt-remapping, | ||
509 | * IO-APIC RTE's need to be setup to point to interrupt-remapping | ||
510 | * table entries. for now, do a plain restore, and wait for | ||
511 | * the setup_IO_APIC_irqs() to do proper initialization. | ||
512 | */ | ||
513 | restore_IO_APIC_setup(); | ||
514 | } | ||
515 | |||
443 | int skip_ioapic_setup; | 516 | int skip_ioapic_setup; |
444 | int ioapic_force; | 517 | int ioapic_force; |
445 | 518 | ||
@@ -834,18 +907,98 @@ void setup_vector_irq(int cpu) | |||
834 | 907 | ||
835 | 908 | ||
836 | static struct irq_chip ioapic_chip; | 909 | static struct irq_chip ioapic_chip; |
910 | #ifdef CONFIG_INTR_REMAP | ||
911 | static struct irq_chip ir_ioapic_chip; | ||
912 | #endif | ||
837 | 913 | ||
838 | static void ioapic_register_intr(int irq, unsigned long trigger) | 914 | static void ioapic_register_intr(int irq, unsigned long trigger) |
839 | { | 915 | { |
840 | if (trigger) { | 916 | if (trigger) |
841 | irq_desc[irq].status |= IRQ_LEVEL; | 917 | irq_desc[irq].status |= IRQ_LEVEL; |
842 | set_irq_chip_and_handler_name(irq, &ioapic_chip, | 918 | else |
843 | handle_fasteoi_irq, "fasteoi"); | ||
844 | } else { | ||
845 | irq_desc[irq].status &= ~IRQ_LEVEL; | 919 | irq_desc[irq].status &= ~IRQ_LEVEL; |
920 | |||
921 | #ifdef CONFIG_INTR_REMAP | ||
922 | if (irq_remapped(irq)) { | ||
923 | irq_desc[irq].status |= IRQ_MOVE_PCNTXT; | ||
924 | if (trigger) | ||
925 | set_irq_chip_and_handler_name(irq, &ir_ioapic_chip, | ||
926 | handle_fasteoi_irq, | ||
927 | "fasteoi"); | ||
928 | else | ||
929 | set_irq_chip_and_handler_name(irq, &ir_ioapic_chip, | ||
930 | handle_edge_irq, "edge"); | ||
931 | return; | ||
932 | } | ||
933 | #endif | ||
934 | if (trigger) | ||
935 | set_irq_chip_and_handler_name(irq, &ioapic_chip, | ||
936 | handle_fasteoi_irq, | ||
937 | "fasteoi"); | ||
938 | else | ||
846 | set_irq_chip_and_handler_name(irq, &ioapic_chip, | 939 | set_irq_chip_and_handler_name(irq, &ioapic_chip, |
847 | handle_edge_irq, "edge"); | 940 | handle_edge_irq, "edge"); |
941 | } | ||
942 | |||
943 | static int setup_ioapic_entry(int apic, int irq, | ||
944 | struct IO_APIC_route_entry *entry, | ||
945 | unsigned int destination, int trigger, | ||
946 | int polarity, int vector) | ||
947 | { | ||
948 | /* | ||
949 | * add it to the IO-APIC irq-routing table: | ||
950 | */ | ||
951 | memset(entry,0,sizeof(*entry)); | ||
952 | |||
953 | #ifdef CONFIG_INTR_REMAP | ||
954 | if (intr_remapping_enabled) { | ||
955 | struct intel_iommu *iommu = map_ioapic_to_ir(apic); | ||
956 | struct irte irte; | ||
957 | struct IR_IO_APIC_route_entry *ir_entry = | ||
958 | (struct IR_IO_APIC_route_entry *) entry; | ||
959 | int index; | ||
960 | |||
961 | if (!iommu) | ||
962 | panic("No mapping iommu for ioapic %d\n", apic); | ||
963 | |||
964 | index = alloc_irte(iommu, irq, 1); | ||
965 | if (index < 0) | ||
966 | panic("Failed to allocate IRTE for ioapic %d\n", apic); | ||
967 | |||
968 | memset(&irte, 0, sizeof(irte)); | ||
969 | |||
970 | irte.present = 1; | ||
971 | irte.dst_mode = INT_DEST_MODE; | ||
972 | irte.trigger_mode = trigger; | ||
973 | irte.dlvry_mode = INT_DELIVERY_MODE; | ||
974 | irte.vector = vector; | ||
975 | irte.dest_id = IRTE_DEST(destination); | ||
976 | |||
977 | modify_irte(irq, &irte); | ||
978 | |||
979 | ir_entry->index2 = (index >> 15) & 0x1; | ||
980 | ir_entry->zero = 0; | ||
981 | ir_entry->format = 1; | ||
982 | ir_entry->index = (index & 0x7fff); | ||
983 | } else | ||
984 | #endif | ||
985 | { | ||
986 | entry->delivery_mode = INT_DELIVERY_MODE; | ||
987 | entry->dest_mode = INT_DEST_MODE; | ||
988 | entry->dest = destination; | ||
848 | } | 989 | } |
990 | |||
991 | entry->mask = 0; /* enable IRQ */ | ||
992 | entry->trigger = trigger; | ||
993 | entry->polarity = polarity; | ||
994 | entry->vector = vector; | ||
995 | |||
996 | /* Mask level triggered irqs. | ||
997 | * Use IRQ_DELAYED_DISABLE for edge triggered irqs. | ||
998 | */ | ||
999 | if (trigger) | ||
1000 | entry->mask = 1; | ||
1001 | return 0; | ||
849 | } | 1002 | } |
850 | 1003 | ||
851 | static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq, | 1004 | static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq, |
@@ -870,24 +1023,15 @@ static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq, | |||
870 | apic, mp_ioapics[apic].mp_apicid, pin, cfg->vector, | 1023 | apic, mp_ioapics[apic].mp_apicid, pin, cfg->vector, |
871 | irq, trigger, polarity); | 1024 | irq, trigger, polarity); |
872 | 1025 | ||
873 | /* | ||
874 | * add it to the IO-APIC irq-routing table: | ||
875 | */ | ||
876 | memset(&entry,0,sizeof(entry)); | ||
877 | 1026 | ||
878 | entry.delivery_mode = INT_DELIVERY_MODE; | 1027 | if (setup_ioapic_entry(mp_ioapics[apic].mp_apicid, irq, &entry, |
879 | entry.dest_mode = INT_DEST_MODE; | 1028 | cpu_mask_to_apicid(mask), trigger, polarity, |
880 | entry.dest = cpu_mask_to_apicid(mask); | 1029 | cfg->vector)) { |
881 | entry.mask = 0; /* enable IRQ */ | 1030 | printk("Failed to setup ioapic entry for ioapic %d, pin %d\n", |
882 | entry.trigger = trigger; | 1031 | mp_ioapics[apic].mp_apicid, pin); |
883 | entry.polarity = polarity; | 1032 | __clear_irq_vector(irq); |
884 | entry.vector = cfg->vector; | 1033 | return; |
885 | 1034 | } | |
886 | /* Mask level triggered irqs. | ||
887 | * Use IRQ_DELAYED_DISABLE for edge triggered irqs. | ||
888 | */ | ||
889 | if (trigger) | ||
890 | entry.mask = 1; | ||
891 | 1035 | ||
892 | ioapic_register_intr(irq, trigger); | 1036 | ioapic_register_intr(irq, trigger); |
893 | if (irq < 16) | 1037 | if (irq < 16) |
@@ -939,6 +1083,9 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic, unsigned int pin, | |||
939 | { | 1083 | { |
940 | struct IO_APIC_route_entry entry; | 1084 | struct IO_APIC_route_entry entry; |
941 | 1085 | ||
1086 | if (intr_remapping_enabled) | ||
1087 | return; | ||
1088 | |||
942 | memset(&entry, 0, sizeof(entry)); | 1089 | memset(&entry, 0, sizeof(entry)); |
943 | 1090 | ||
944 | /* | 1091 | /* |
@@ -1085,6 +1232,7 @@ static __apicdebuginit void print_APIC_bitfield (int base) | |||
1085 | void __apicdebuginit print_local_APIC(void * dummy) | 1232 | void __apicdebuginit print_local_APIC(void * dummy) |
1086 | { | 1233 | { |
1087 | unsigned int v, ver, maxlvt; | 1234 | unsigned int v, ver, maxlvt; |
1235 | unsigned long icr; | ||
1088 | 1236 | ||
1089 | if (apic_verbosity == APIC_QUIET) | 1237 | if (apic_verbosity == APIC_QUIET) |
1090 | return; | 1238 | return; |
@@ -1092,7 +1240,7 @@ void __apicdebuginit print_local_APIC(void * dummy) | |||
1092 | printk("\n" KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n", | 1240 | printk("\n" KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n", |
1093 | smp_processor_id(), hard_smp_processor_id()); | 1241 | smp_processor_id(), hard_smp_processor_id()); |
1094 | v = apic_read(APIC_ID); | 1242 | v = apic_read(APIC_ID); |
1095 | printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, GET_APIC_ID(read_apic_id())); | 1243 | printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, read_apic_id()); |
1096 | v = apic_read(APIC_LVR); | 1244 | v = apic_read(APIC_LVR); |
1097 | printk(KERN_INFO "... APIC VERSION: %08x\n", v); | 1245 | printk(KERN_INFO "... APIC VERSION: %08x\n", v); |
1098 | ver = GET_APIC_VERSION(v); | 1246 | ver = GET_APIC_VERSION(v); |
@@ -1128,10 +1276,9 @@ void __apicdebuginit print_local_APIC(void * dummy) | |||
1128 | v = apic_read(APIC_ESR); | 1276 | v = apic_read(APIC_ESR); |
1129 | printk(KERN_DEBUG "... APIC ESR: %08x\n", v); | 1277 | printk(KERN_DEBUG "... APIC ESR: %08x\n", v); |
1130 | 1278 | ||
1131 | v = apic_read(APIC_ICR); | 1279 | icr = apic_icr_read(); |
1132 | printk(KERN_DEBUG "... APIC ICR: %08x\n", v); | 1280 | printk(KERN_DEBUG "... APIC ICR: %08x\n", icr); |
1133 | v = apic_read(APIC_ICR2); | 1281 | printk(KERN_DEBUG "... APIC ICR2: %08x\n", icr >> 32); |
1134 | printk(KERN_DEBUG "... APIC ICR2: %08x\n", v); | ||
1135 | 1282 | ||
1136 | v = apic_read(APIC_LVTT); | 1283 | v = apic_read(APIC_LVTT); |
1137 | printk(KERN_DEBUG "... APIC LVTT: %08x\n", v); | 1284 | printk(KERN_DEBUG "... APIC LVTT: %08x\n", v); |
@@ -1286,7 +1433,7 @@ void disable_IO_APIC(void) | |||
1286 | entry.dest_mode = 0; /* Physical */ | 1433 | entry.dest_mode = 0; /* Physical */ |
1287 | entry.delivery_mode = dest_ExtINT; /* ExtInt */ | 1434 | entry.delivery_mode = dest_ExtINT; /* ExtInt */ |
1288 | entry.vector = 0; | 1435 | entry.vector = 0; |
1289 | entry.dest = GET_APIC_ID(read_apic_id()); | 1436 | entry.dest = read_apic_id(); |
1290 | 1437 | ||
1291 | /* | 1438 | /* |
1292 | * Add it to the IO-APIC irq-routing table: | 1439 | * Add it to the IO-APIC irq-routing table: |
@@ -1394,6 +1541,147 @@ static int ioapic_retrigger_irq(unsigned int irq) | |||
1394 | */ | 1541 | */ |
1395 | 1542 | ||
1396 | #ifdef CONFIG_SMP | 1543 | #ifdef CONFIG_SMP |
1544 | |||
1545 | #ifdef CONFIG_INTR_REMAP | ||
1546 | static void ir_irq_migration(struct work_struct *work); | ||
1547 | |||
1548 | static DECLARE_DELAYED_WORK(ir_migration_work, ir_irq_migration); | ||
1549 | |||
1550 | /* | ||
1551 | * Migrate the IO-APIC irq in the presence of intr-remapping. | ||
1552 | * | ||
1553 | * For edge triggered, irq migration is a simple atomic update(of vector | ||
1554 | * and cpu destination) of IRTE and flush the hardware cache. | ||
1555 | * | ||
1556 | * For level triggered, we need to modify the io-apic RTE aswell with the update | ||
1557 | * vector information, along with modifying IRTE with vector and destination. | ||
1558 | * So irq migration for level triggered is little bit more complex compared to | ||
1559 | * edge triggered migration. But the good news is, we use the same algorithm | ||
1560 | * for level triggered migration as we have today, only difference being, | ||
1561 | * we now initiate the irq migration from process context instead of the | ||
1562 | * interrupt context. | ||
1563 | * | ||
1564 | * In future, when we do a directed EOI (combined with cpu EOI broadcast | ||
1565 | * suppression) to the IO-APIC, level triggered irq migration will also be | ||
1566 | * as simple as edge triggered migration and we can do the irq migration | ||
1567 | * with a simple atomic update to IO-APIC RTE. | ||
1568 | */ | ||
1569 | static void migrate_ioapic_irq(int irq, cpumask_t mask) | ||
1570 | { | ||
1571 | struct irq_cfg *cfg = irq_cfg + irq; | ||
1572 | struct irq_desc *desc = irq_desc + irq; | ||
1573 | cpumask_t tmp, cleanup_mask; | ||
1574 | struct irte irte; | ||
1575 | int modify_ioapic_rte = desc->status & IRQ_LEVEL; | ||
1576 | unsigned int dest; | ||
1577 | unsigned long flags; | ||
1578 | |||
1579 | cpus_and(tmp, mask, cpu_online_map); | ||
1580 | if (cpus_empty(tmp)) | ||
1581 | return; | ||
1582 | |||
1583 | if (get_irte(irq, &irte)) | ||
1584 | return; | ||
1585 | |||
1586 | if (assign_irq_vector(irq, mask)) | ||
1587 | return; | ||
1588 | |||
1589 | cpus_and(tmp, cfg->domain, mask); | ||
1590 | dest = cpu_mask_to_apicid(tmp); | ||
1591 | |||
1592 | if (modify_ioapic_rte) { | ||
1593 | spin_lock_irqsave(&ioapic_lock, flags); | ||
1594 | __target_IO_APIC_irq(irq, dest, cfg->vector); | ||
1595 | spin_unlock_irqrestore(&ioapic_lock, flags); | ||
1596 | } | ||
1597 | |||
1598 | irte.vector = cfg->vector; | ||
1599 | irte.dest_id = IRTE_DEST(dest); | ||
1600 | |||
1601 | /* | ||
1602 | * Modified the IRTE and flushes the Interrupt entry cache. | ||
1603 | */ | ||
1604 | modify_irte(irq, &irte); | ||
1605 | |||
1606 | if (cfg->move_in_progress) { | ||
1607 | cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map); | ||
1608 | cfg->move_cleanup_count = cpus_weight(cleanup_mask); | ||
1609 | send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR); | ||
1610 | cfg->move_in_progress = 0; | ||
1611 | } | ||
1612 | |||
1613 | irq_desc[irq].affinity = mask; | ||
1614 | } | ||
1615 | |||
1616 | static int migrate_irq_remapped_level(int irq) | ||
1617 | { | ||
1618 | int ret = -1; | ||
1619 | |||
1620 | mask_IO_APIC_irq(irq); | ||
1621 | |||
1622 | if (io_apic_level_ack_pending(irq)) { | ||
1623 | /* | ||
1624 | * Interrupt in progress. Migrating irq now will change the | ||
1625 | * vector information in the IO-APIC RTE and that will confuse | ||
1626 | * the EOI broadcast performed by cpu. | ||
1627 | * So, delay the irq migration to the next instance. | ||
1628 | */ | ||
1629 | schedule_delayed_work(&ir_migration_work, 1); | ||
1630 | goto unmask; | ||
1631 | } | ||
1632 | |||
1633 | /* everthing is clear. we have right of way */ | ||
1634 | migrate_ioapic_irq(irq, irq_desc[irq].pending_mask); | ||
1635 | |||
1636 | ret = 0; | ||
1637 | irq_desc[irq].status &= ~IRQ_MOVE_PENDING; | ||
1638 | cpus_clear(irq_desc[irq].pending_mask); | ||
1639 | |||
1640 | unmask: | ||
1641 | unmask_IO_APIC_irq(irq); | ||
1642 | return ret; | ||
1643 | } | ||
1644 | |||
1645 | static void ir_irq_migration(struct work_struct *work) | ||
1646 | { | ||
1647 | int irq; | ||
1648 | |||
1649 | for (irq = 0; irq < NR_IRQS; irq++) { | ||
1650 | struct irq_desc *desc = irq_desc + irq; | ||
1651 | if (desc->status & IRQ_MOVE_PENDING) { | ||
1652 | unsigned long flags; | ||
1653 | |||
1654 | spin_lock_irqsave(&desc->lock, flags); | ||
1655 | if (!desc->chip->set_affinity || | ||
1656 | !(desc->status & IRQ_MOVE_PENDING)) { | ||
1657 | desc->status &= ~IRQ_MOVE_PENDING; | ||
1658 | spin_unlock_irqrestore(&desc->lock, flags); | ||
1659 | continue; | ||
1660 | } | ||
1661 | |||
1662 | desc->chip->set_affinity(irq, | ||
1663 | irq_desc[irq].pending_mask); | ||
1664 | spin_unlock_irqrestore(&desc->lock, flags); | ||
1665 | } | ||
1666 | } | ||
1667 | } | ||
1668 | |||
1669 | /* | ||
1670 | * Migrates the IRQ destination in the process context. | ||
1671 | */ | ||
1672 | static void set_ir_ioapic_affinity_irq(unsigned int irq, cpumask_t mask) | ||
1673 | { | ||
1674 | if (irq_desc[irq].status & IRQ_LEVEL) { | ||
1675 | irq_desc[irq].status |= IRQ_MOVE_PENDING; | ||
1676 | irq_desc[irq].pending_mask = mask; | ||
1677 | migrate_irq_remapped_level(irq); | ||
1678 | return; | ||
1679 | } | ||
1680 | |||
1681 | migrate_ioapic_irq(irq, mask); | ||
1682 | } | ||
1683 | #endif | ||
1684 | |||
1397 | asmlinkage void smp_irq_move_cleanup_interrupt(void) | 1685 | asmlinkage void smp_irq_move_cleanup_interrupt(void) |
1398 | { | 1686 | { |
1399 | unsigned vector, me; | 1687 | unsigned vector, me; |
@@ -1450,6 +1738,17 @@ static void irq_complete_move(unsigned int irq) | |||
1450 | #else | 1738 | #else |
1451 | static inline void irq_complete_move(unsigned int irq) {} | 1739 | static inline void irq_complete_move(unsigned int irq) {} |
1452 | #endif | 1740 | #endif |
1741 | #ifdef CONFIG_INTR_REMAP | ||
1742 | static void ack_x2apic_level(unsigned int irq) | ||
1743 | { | ||
1744 | ack_x2APIC_irq(); | ||
1745 | } | ||
1746 | |||
1747 | static void ack_x2apic_edge(unsigned int irq) | ||
1748 | { | ||
1749 | ack_x2APIC_irq(); | ||
1750 | } | ||
1751 | #endif | ||
1453 | 1752 | ||
1454 | static void ack_apic_edge(unsigned int irq) | 1753 | static void ack_apic_edge(unsigned int irq) |
1455 | { | 1754 | { |
@@ -1524,6 +1823,21 @@ static struct irq_chip ioapic_chip __read_mostly = { | |||
1524 | .retrigger = ioapic_retrigger_irq, | 1823 | .retrigger = ioapic_retrigger_irq, |
1525 | }; | 1824 | }; |
1526 | 1825 | ||
1826 | #ifdef CONFIG_INTR_REMAP | ||
1827 | static struct irq_chip ir_ioapic_chip __read_mostly = { | ||
1828 | .name = "IR-IO-APIC", | ||
1829 | .startup = startup_ioapic_irq, | ||
1830 | .mask = mask_IO_APIC_irq, | ||
1831 | .unmask = unmask_IO_APIC_irq, | ||
1832 | .ack = ack_x2apic_edge, | ||
1833 | .eoi = ack_x2apic_level, | ||
1834 | #ifdef CONFIG_SMP | ||
1835 | .set_affinity = set_ir_ioapic_affinity_irq, | ||
1836 | #endif | ||
1837 | .retrigger = ioapic_retrigger_irq, | ||
1838 | }; | ||
1839 | #endif | ||
1840 | |||
1527 | static inline void init_IO_APIC_traps(void) | 1841 | static inline void init_IO_APIC_traps(void) |
1528 | { | 1842 | { |
1529 | int irq; | 1843 | int irq; |
@@ -1709,6 +2023,8 @@ static inline void __init check_timer(void) | |||
1709 | * 8259A. | 2023 | * 8259A. |
1710 | */ | 2024 | */ |
1711 | if (pin1 == -1) { | 2025 | if (pin1 == -1) { |
2026 | if (intr_remapping_enabled) | ||
2027 | panic("BIOS bug: timer not connected to IO-APIC"); | ||
1712 | pin1 = pin2; | 2028 | pin1 = pin2; |
1713 | apic1 = apic2; | 2029 | apic1 = apic2; |
1714 | no_pin1 = 1; | 2030 | no_pin1 = 1; |
@@ -1735,6 +2051,8 @@ static inline void __init check_timer(void) | |||
1735 | clear_IO_APIC_pin(0, pin1); | 2051 | clear_IO_APIC_pin(0, pin1); |
1736 | goto out; | 2052 | goto out; |
1737 | } | 2053 | } |
2054 | if (intr_remapping_enabled) | ||
2055 | panic("timer doesn't work through Interrupt-remapped IO-APIC"); | ||
1738 | clear_IO_APIC_pin(apic1, pin1); | 2056 | clear_IO_APIC_pin(apic1, pin1); |
1739 | if (!no_pin1) | 2057 | if (!no_pin1) |
1740 | apic_printk(APIC_QUIET, KERN_ERR "..MP-BIOS bug: " | 2058 | apic_printk(APIC_QUIET, KERN_ERR "..MP-BIOS bug: " |
@@ -1974,6 +2292,9 @@ void destroy_irq(unsigned int irq) | |||
1974 | 2292 | ||
1975 | dynamic_irq_cleanup(irq); | 2293 | dynamic_irq_cleanup(irq); |
1976 | 2294 | ||
2295 | #ifdef CONFIG_INTR_REMAP | ||
2296 | free_irte(irq); | ||
2297 | #endif | ||
1977 | spin_lock_irqsave(&vector_lock, flags); | 2298 | spin_lock_irqsave(&vector_lock, flags); |
1978 | __clear_irq_vector(irq); | 2299 | __clear_irq_vector(irq); |
1979 | spin_unlock_irqrestore(&vector_lock, flags); | 2300 | spin_unlock_irqrestore(&vector_lock, flags); |
@@ -1992,11 +2313,42 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms | |||
1992 | 2313 | ||
1993 | tmp = TARGET_CPUS; | 2314 | tmp = TARGET_CPUS; |
1994 | err = assign_irq_vector(irq, tmp); | 2315 | err = assign_irq_vector(irq, tmp); |
1995 | if (!err) { | 2316 | if (err) |
1996 | cpus_and(tmp, cfg->domain, tmp); | 2317 | return err; |
1997 | dest = cpu_mask_to_apicid(tmp); | 2318 | |
2319 | cpus_and(tmp, cfg->domain, tmp); | ||
2320 | dest = cpu_mask_to_apicid(tmp); | ||
2321 | |||
2322 | #ifdef CONFIG_INTR_REMAP | ||
2323 | if (irq_remapped(irq)) { | ||
2324 | struct irte irte; | ||
2325 | int ir_index; | ||
2326 | u16 sub_handle; | ||
2327 | |||
2328 | ir_index = map_irq_to_irte_handle(irq, &sub_handle); | ||
2329 | BUG_ON(ir_index == -1); | ||
2330 | |||
2331 | memset (&irte, 0, sizeof(irte)); | ||
2332 | |||
2333 | irte.present = 1; | ||
2334 | irte.dst_mode = INT_DEST_MODE; | ||
2335 | irte.trigger_mode = 0; /* edge */ | ||
2336 | irte.dlvry_mode = INT_DELIVERY_MODE; | ||
2337 | irte.vector = cfg->vector; | ||
2338 | irte.dest_id = IRTE_DEST(dest); | ||
2339 | |||
2340 | modify_irte(irq, &irte); | ||
1998 | 2341 | ||
1999 | msg->address_hi = MSI_ADDR_BASE_HI; | 2342 | msg->address_hi = MSI_ADDR_BASE_HI; |
2343 | msg->data = sub_handle; | ||
2344 | msg->address_lo = MSI_ADDR_BASE_LO | MSI_ADDR_IR_EXT_INT | | ||
2345 | MSI_ADDR_IR_SHV | | ||
2346 | MSI_ADDR_IR_INDEX1(ir_index) | | ||
2347 | MSI_ADDR_IR_INDEX2(ir_index); | ||
2348 | } else | ||
2349 | #endif | ||
2350 | { | ||
2351 | msg->address_hi = MSI_ADDR_BASE_HI; | ||
2000 | msg->address_lo = | 2352 | msg->address_lo = |
2001 | MSI_ADDR_BASE_LO | | 2353 | MSI_ADDR_BASE_LO | |
2002 | ((INT_DEST_MODE == 0) ? | 2354 | ((INT_DEST_MODE == 0) ? |
@@ -2046,6 +2398,55 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask) | |||
2046 | write_msi_msg(irq, &msg); | 2398 | write_msi_msg(irq, &msg); |
2047 | irq_desc[irq].affinity = mask; | 2399 | irq_desc[irq].affinity = mask; |
2048 | } | 2400 | } |
2401 | |||
2402 | #ifdef CONFIG_INTR_REMAP | ||
2403 | /* | ||
2404 | * Migrate the MSI irq to another cpumask. This migration is | ||
2405 | * done in the process context using interrupt-remapping hardware. | ||
2406 | */ | ||
2407 | static void ir_set_msi_irq_affinity(unsigned int irq, cpumask_t mask) | ||
2408 | { | ||
2409 | struct irq_cfg *cfg = irq_cfg + irq; | ||
2410 | unsigned int dest; | ||
2411 | cpumask_t tmp, cleanup_mask; | ||
2412 | struct irte irte; | ||
2413 | |||
2414 | cpus_and(tmp, mask, cpu_online_map); | ||
2415 | if (cpus_empty(tmp)) | ||
2416 | return; | ||
2417 | |||
2418 | if (get_irte(irq, &irte)) | ||
2419 | return; | ||
2420 | |||
2421 | if (assign_irq_vector(irq, mask)) | ||
2422 | return; | ||
2423 | |||
2424 | cpus_and(tmp, cfg->domain, mask); | ||
2425 | dest = cpu_mask_to_apicid(tmp); | ||
2426 | |||
2427 | irte.vector = cfg->vector; | ||
2428 | irte.dest_id = IRTE_DEST(dest); | ||
2429 | |||
2430 | /* | ||
2431 | * atomically update the IRTE with the new destination and vector. | ||
2432 | */ | ||
2433 | modify_irte(irq, &irte); | ||
2434 | |||
2435 | /* | ||
2436 | * After this point, all the interrupts will start arriving | ||
2437 | * at the new destination. So, time to cleanup the previous | ||
2438 | * vector allocation. | ||
2439 | */ | ||
2440 | if (cfg->move_in_progress) { | ||
2441 | cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map); | ||
2442 | cfg->move_cleanup_count = cpus_weight(cleanup_mask); | ||
2443 | send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR); | ||
2444 | cfg->move_in_progress = 0; | ||
2445 | } | ||
2446 | |||
2447 | irq_desc[irq].affinity = mask; | ||
2448 | } | ||
2449 | #endif | ||
2049 | #endif /* CONFIG_SMP */ | 2450 | #endif /* CONFIG_SMP */ |
2050 | 2451 | ||
2051 | /* | 2452 | /* |
@@ -2063,26 +2464,157 @@ static struct irq_chip msi_chip = { | |||
2063 | .retrigger = ioapic_retrigger_irq, | 2464 | .retrigger = ioapic_retrigger_irq, |
2064 | }; | 2465 | }; |
2065 | 2466 | ||
2066 | int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) | 2467 | #ifdef CONFIG_INTR_REMAP |
2468 | static struct irq_chip msi_ir_chip = { | ||
2469 | .name = "IR-PCI-MSI", | ||
2470 | .unmask = unmask_msi_irq, | ||
2471 | .mask = mask_msi_irq, | ||
2472 | .ack = ack_x2apic_edge, | ||
2473 | #ifdef CONFIG_SMP | ||
2474 | .set_affinity = ir_set_msi_irq_affinity, | ||
2475 | #endif | ||
2476 | .retrigger = ioapic_retrigger_irq, | ||
2477 | }; | ||
2478 | |||
2479 | /* | ||
2480 | * Map the PCI dev to the corresponding remapping hardware unit | ||
2481 | * and allocate 'nvec' consecutive interrupt-remapping table entries | ||
2482 | * in it. | ||
2483 | */ | ||
2484 | static int msi_alloc_irte(struct pci_dev *dev, int irq, int nvec) | ||
2485 | { | ||
2486 | struct intel_iommu *iommu; | ||
2487 | int index; | ||
2488 | |||
2489 | iommu = map_dev_to_ir(dev); | ||
2490 | if (!iommu) { | ||
2491 | printk(KERN_ERR | ||
2492 | "Unable to map PCI %s to iommu\n", pci_name(dev)); | ||
2493 | return -ENOENT; | ||
2494 | } | ||
2495 | |||
2496 | index = alloc_irte(iommu, irq, nvec); | ||
2497 | if (index < 0) { | ||
2498 | printk(KERN_ERR | ||
2499 | "Unable to allocate %d IRTE for PCI %s\n", nvec, | ||
2500 | pci_name(dev)); | ||
2501 | return -ENOSPC; | ||
2502 | } | ||
2503 | return index; | ||
2504 | } | ||
2505 | #endif | ||
2506 | |||
2507 | static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc, int irq) | ||
2067 | { | 2508 | { |
2509 | int ret; | ||
2068 | struct msi_msg msg; | 2510 | struct msi_msg msg; |
2511 | |||
2512 | ret = msi_compose_msg(dev, irq, &msg); | ||
2513 | if (ret < 0) | ||
2514 | return ret; | ||
2515 | |||
2516 | set_irq_msi(irq, desc); | ||
2517 | write_msi_msg(irq, &msg); | ||
2518 | |||
2519 | #ifdef CONFIG_INTR_REMAP | ||
2520 | if (irq_remapped(irq)) { | ||
2521 | struct irq_desc *desc = irq_desc + irq; | ||
2522 | /* | ||
2523 | * irq migration in process context | ||
2524 | */ | ||
2525 | desc->status |= IRQ_MOVE_PCNTXT; | ||
2526 | set_irq_chip_and_handler_name(irq, &msi_ir_chip, handle_edge_irq, "edge"); | ||
2527 | } else | ||
2528 | #endif | ||
2529 | set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge"); | ||
2530 | |||
2531 | return 0; | ||
2532 | } | ||
2533 | |||
2534 | int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) | ||
2535 | { | ||
2069 | int irq, ret; | 2536 | int irq, ret; |
2537 | |||
2070 | irq = create_irq(); | 2538 | irq = create_irq(); |
2071 | if (irq < 0) | 2539 | if (irq < 0) |
2072 | return irq; | 2540 | return irq; |
2073 | 2541 | ||
2074 | ret = msi_compose_msg(dev, irq, &msg); | 2542 | #ifdef CONFIG_INTR_REMAP |
2543 | if (!intr_remapping_enabled) | ||
2544 | goto no_ir; | ||
2545 | |||
2546 | ret = msi_alloc_irte(dev, irq, 1); | ||
2547 | if (ret < 0) | ||
2548 | goto error; | ||
2549 | no_ir: | ||
2550 | #endif | ||
2551 | ret = setup_msi_irq(dev, desc, irq); | ||
2075 | if (ret < 0) { | 2552 | if (ret < 0) { |
2076 | destroy_irq(irq); | 2553 | destroy_irq(irq); |
2077 | return ret; | 2554 | return ret; |
2078 | } | 2555 | } |
2556 | return 0; | ||
2079 | 2557 | ||
2080 | set_irq_msi(irq, desc); | 2558 | #ifdef CONFIG_INTR_REMAP |
2081 | write_msi_msg(irq, &msg); | 2559 | error: |
2560 | destroy_irq(irq); | ||
2561 | return ret; | ||
2562 | #endif | ||
2563 | } | ||
2082 | 2564 | ||
2083 | set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge"); | 2565 | int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) |
2566 | { | ||
2567 | int irq, ret, sub_handle; | ||
2568 | struct msi_desc *desc; | ||
2569 | #ifdef CONFIG_INTR_REMAP | ||
2570 | struct intel_iommu *iommu = 0; | ||
2571 | int index = 0; | ||
2572 | #endif | ||
2084 | 2573 | ||
2574 | sub_handle = 0; | ||
2575 | list_for_each_entry(desc, &dev->msi_list, list) { | ||
2576 | irq = create_irq(); | ||
2577 | if (irq < 0) | ||
2578 | return irq; | ||
2579 | #ifdef CONFIG_INTR_REMAP | ||
2580 | if (!intr_remapping_enabled) | ||
2581 | goto no_ir; | ||
2582 | |||
2583 | if (!sub_handle) { | ||
2584 | /* | ||
2585 | * allocate the consecutive block of IRTE's | ||
2586 | * for 'nvec' | ||
2587 | */ | ||
2588 | index = msi_alloc_irte(dev, irq, nvec); | ||
2589 | if (index < 0) { | ||
2590 | ret = index; | ||
2591 | goto error; | ||
2592 | } | ||
2593 | } else { | ||
2594 | iommu = map_dev_to_ir(dev); | ||
2595 | if (!iommu) { | ||
2596 | ret = -ENOENT; | ||
2597 | goto error; | ||
2598 | } | ||
2599 | /* | ||
2600 | * setup the mapping between the irq and the IRTE | ||
2601 | * base index, the sub_handle pointing to the | ||
2602 | * appropriate interrupt remap table entry. | ||
2603 | */ | ||
2604 | set_irte_irq(irq, iommu, index, sub_handle); | ||
2605 | } | ||
2606 | no_ir: | ||
2607 | #endif | ||
2608 | ret = setup_msi_irq(dev, desc, irq); | ||
2609 | if (ret < 0) | ||
2610 | goto error; | ||
2611 | sub_handle++; | ||
2612 | } | ||
2085 | return 0; | 2613 | return 0; |
2614 | |||
2615 | error: | ||
2616 | destroy_irq(irq); | ||
2617 | return ret; | ||
2086 | } | 2618 | } |
2087 | 2619 | ||
2088 | void arch_teardown_msi_irq(unsigned int irq) | 2620 | void arch_teardown_msi_irq(unsigned int irq) |
@@ -2330,6 +2862,10 @@ void __init setup_ioapic_dest(void) | |||
2330 | setup_IO_APIC_irq(ioapic, pin, irq, | 2862 | setup_IO_APIC_irq(ioapic, pin, irq, |
2331 | irq_trigger(irq_entry), | 2863 | irq_trigger(irq_entry), |
2332 | irq_polarity(irq_entry)); | 2864 | irq_polarity(irq_entry)); |
2865 | #ifdef CONFIG_INTR_REMAP | ||
2866 | else if (intr_remapping_enabled) | ||
2867 | set_ir_ioapic_affinity_irq(irq, TARGET_CPUS); | ||
2868 | #endif | ||
2333 | else | 2869 | else |
2334 | set_ioapic_affinity_irq(irq, TARGET_CPUS); | 2870 | set_ioapic_affinity_irq(irq, TARGET_CPUS); |
2335 | } | 2871 | } |
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index 3b25e49380c6..70e1f3e287fb 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c | |||
@@ -545,7 +545,9 @@ static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early) | |||
545 | generic_bigsmp_probe(); | 545 | generic_bigsmp_probe(); |
546 | #endif | 546 | #endif |
547 | 547 | ||
548 | #ifdef CONFIG_X86_32 | ||
548 | setup_apic_routing(); | 549 | setup_apic_routing(); |
550 | #endif | ||
549 | if (!num_processors) | 551 | if (!num_processors) |
550 | printk(KERN_ERR "MPTABLE: no processors registered!\n"); | 552 | printk(KERN_ERR "MPTABLE: no processors registered!\n"); |
551 | return num_processors; | 553 | return num_processors; |
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 5d7326a60b7c..e0f139106c7e 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c | |||
@@ -360,8 +360,6 @@ struct pv_cpu_ops pv_cpu_ops = { | |||
360 | 360 | ||
361 | struct pv_apic_ops pv_apic_ops = { | 361 | struct pv_apic_ops pv_apic_ops = { |
362 | #ifdef CONFIG_X86_LOCAL_APIC | 362 | #ifdef CONFIG_X86_LOCAL_APIC |
363 | .apic_write = native_apic_write, | ||
364 | .apic_read = native_apic_read, | ||
365 | .setup_boot_clock = setup_boot_APIC_clock, | 363 | .setup_boot_clock = setup_boot_APIC_clock, |
366 | .setup_secondary_clock = setup_secondary_APIC_clock, | 364 | .setup_secondary_clock = setup_secondary_APIC_clock, |
367 | .startup_ipi_hook = paravirt_nop, | 365 | .startup_ipi_hook = paravirt_nop, |
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 531b55b8e81a..6121ffd46b9e 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -735,6 +735,8 @@ void __init setup_arch(char **cmdline_p) | |||
735 | num_physpages = max_pfn; | 735 | num_physpages = max_pfn; |
736 | 736 | ||
737 | check_efer(); | 737 | check_efer(); |
738 | if (cpu_has_x2apic) | ||
739 | check_x2apic(); | ||
738 | 740 | ||
739 | /* How many end-of-memory variables you have, grandma! */ | 741 | /* How many end-of-memory variables you have, grandma! */ |
740 | /* need this before calling reserve_initrd */ | 742 | /* need this before calling reserve_initrd */ |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index f251f5c38823..a4f2d8f06e48 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -123,7 +123,6 @@ EXPORT_PER_CPU_SYMBOL(cpu_info); | |||
123 | 123 | ||
124 | static atomic_t init_deasserted; | 124 | static atomic_t init_deasserted; |
125 | 125 | ||
126 | static int boot_cpu_logical_apicid; | ||
127 | 126 | ||
128 | /* representing cpus for which sibling maps can be computed */ | 127 | /* representing cpus for which sibling maps can be computed */ |
129 | static cpumask_t cpu_sibling_setup_map; | 128 | static cpumask_t cpu_sibling_setup_map; |
@@ -165,6 +164,8 @@ static void unmap_cpu_to_node(int cpu) | |||
165 | #endif | 164 | #endif |
166 | 165 | ||
167 | #ifdef CONFIG_X86_32 | 166 | #ifdef CONFIG_X86_32 |
167 | static int boot_cpu_logical_apicid; | ||
168 | |||
168 | u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly = | 169 | u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly = |
169 | { [0 ... NR_CPUS-1] = BAD_APICID }; | 170 | { [0 ... NR_CPUS-1] = BAD_APICID }; |
170 | 171 | ||
@@ -210,7 +211,7 @@ static void __cpuinit smp_callin(void) | |||
210 | /* | 211 | /* |
211 | * (This works even if the APIC is not enabled.) | 212 | * (This works even if the APIC is not enabled.) |
212 | */ | 213 | */ |
213 | phys_id = GET_APIC_ID(read_apic_id()); | 214 | phys_id = read_apic_id(); |
214 | cpuid = smp_processor_id(); | 215 | cpuid = smp_processor_id(); |
215 | if (cpu_isset(cpuid, cpu_callin_map)) { | 216 | if (cpu_isset(cpuid, cpu_callin_map)) { |
216 | panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__, | 217 | panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__, |
@@ -546,8 +547,7 @@ static inline void __inquire_remote_apic(int apicid) | |||
546 | printk(KERN_CONT | 547 | printk(KERN_CONT |
547 | "a previous APIC delivery may have failed\n"); | 548 | "a previous APIC delivery may have failed\n"); |
548 | 549 | ||
549 | apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(apicid)); | 550 | apic_icr_write(APIC_DM_REMRD | regs[i], apicid); |
550 | apic_write(APIC_ICR, APIC_DM_REMRD | regs[i]); | ||
551 | 551 | ||
552 | timeout = 0; | 552 | timeout = 0; |
553 | do { | 553 | do { |
@@ -579,11 +579,9 @@ wakeup_secondary_cpu(int logical_apicid, unsigned long start_eip) | |||
579 | int maxlvt; | 579 | int maxlvt; |
580 | 580 | ||
581 | /* Target chip */ | 581 | /* Target chip */ |
582 | apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(logical_apicid)); | ||
583 | |||
584 | /* Boot on the stack */ | 582 | /* Boot on the stack */ |
585 | /* Kick the second */ | 583 | /* Kick the second */ |
586 | apic_write(APIC_ICR, APIC_DM_NMI | APIC_DEST_LOGICAL); | 584 | apic_icr_write(APIC_DM_NMI | APIC_DEST_LOGICAL, logical_apicid); |
587 | 585 | ||
588 | Dprintk("Waiting for send to finish...\n"); | 586 | Dprintk("Waiting for send to finish...\n"); |
589 | send_status = safe_apic_wait_icr_idle(); | 587 | send_status = safe_apic_wait_icr_idle(); |
@@ -636,13 +634,11 @@ wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip) | |||
636 | /* | 634 | /* |
637 | * Turn INIT on target chip | 635 | * Turn INIT on target chip |
638 | */ | 636 | */ |
639 | apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid)); | ||
640 | |||
641 | /* | 637 | /* |
642 | * Send IPI | 638 | * Send IPI |
643 | */ | 639 | */ |
644 | apic_write(APIC_ICR, | 640 | apic_icr_write(APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT, |
645 | APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT); | 641 | phys_apicid); |
646 | 642 | ||
647 | Dprintk("Waiting for send to finish...\n"); | 643 | Dprintk("Waiting for send to finish...\n"); |
648 | send_status = safe_apic_wait_icr_idle(); | 644 | send_status = safe_apic_wait_icr_idle(); |
@@ -652,10 +648,8 @@ wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip) | |||
652 | Dprintk("Deasserting INIT.\n"); | 648 | Dprintk("Deasserting INIT.\n"); |
653 | 649 | ||
654 | /* Target chip */ | 650 | /* Target chip */ |
655 | apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid)); | ||
656 | |||
657 | /* Send IPI */ | 651 | /* Send IPI */ |
658 | apic_write(APIC_ICR, APIC_INT_LEVELTRIG | APIC_DM_INIT); | 652 | apic_icr_write(APIC_INT_LEVELTRIG | APIC_DM_INIT, phys_apicid); |
659 | 653 | ||
660 | Dprintk("Waiting for send to finish...\n"); | 654 | Dprintk("Waiting for send to finish...\n"); |
661 | send_status = safe_apic_wait_icr_idle(); | 655 | send_status = safe_apic_wait_icr_idle(); |
@@ -698,11 +692,10 @@ wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip) | |||
698 | */ | 692 | */ |
699 | 693 | ||
700 | /* Target chip */ | 694 | /* Target chip */ |
701 | apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid)); | ||
702 | |||
703 | /* Boot on the stack */ | 695 | /* Boot on the stack */ |
704 | /* Kick the second */ | 696 | /* Kick the second */ |
705 | apic_write(APIC_ICR, APIC_DM_STARTUP | (start_eip >> 12)); | 697 | apic_icr_write(APIC_DM_STARTUP | (start_eip >> 12), |
698 | phys_apicid); | ||
706 | 699 | ||
707 | /* | 700 | /* |
708 | * Give the other CPU some time to accept the IPI. | 701 | * Give the other CPU some time to accept the IPI. |
@@ -1136,10 +1129,17 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) | |||
1136 | * Setup boot CPU information | 1129 | * Setup boot CPU information |
1137 | */ | 1130 | */ |
1138 | smp_store_cpu_info(0); /* Final full version of the data */ | 1131 | smp_store_cpu_info(0); /* Final full version of the data */ |
1132 | #ifdef CONFIG_X86_32 | ||
1139 | boot_cpu_logical_apicid = logical_smp_processor_id(); | 1133 | boot_cpu_logical_apicid = logical_smp_processor_id(); |
1134 | #endif | ||
1140 | current_thread_info()->cpu = 0; /* needed? */ | 1135 | current_thread_info()->cpu = 0; /* needed? */ |
1141 | set_cpu_sibling_map(0); | 1136 | set_cpu_sibling_map(0); |
1142 | 1137 | ||
1138 | #ifdef CONFIG_X86_64 | ||
1139 | enable_IR_x2apic(); | ||
1140 | setup_apic_routing(); | ||
1141 | #endif | ||
1142 | |||
1143 | if (smp_sanity_check(max_cpus) < 0) { | 1143 | if (smp_sanity_check(max_cpus) < 0) { |
1144 | printk(KERN_INFO "SMP disabled\n"); | 1144 | printk(KERN_INFO "SMP disabled\n"); |
1145 | disable_smp(); | 1145 | disable_smp(); |
@@ -1147,9 +1147,9 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) | |||
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | preempt_disable(); | 1149 | preempt_disable(); |
1150 | if (GET_APIC_ID(read_apic_id()) != boot_cpu_physical_apicid) { | 1150 | if (read_apic_id() != boot_cpu_physical_apicid) { |
1151 | panic("Boot APIC ID in local APIC unexpected (%d vs %d)", | 1151 | panic("Boot APIC ID in local APIC unexpected (%d vs %d)", |
1152 | GET_APIC_ID(read_apic_id()), boot_cpu_physical_apicid); | 1152 | read_apic_id(), boot_cpu_physical_apicid); |
1153 | /* Or can we switch back to PIC here? */ | 1153 | /* Or can we switch back to PIC here? */ |
1154 | } | 1154 | } |
1155 | preempt_enable(); | 1155 | preempt_enable(); |
diff --git a/arch/x86/kernel/vmi_32.c b/arch/x86/kernel/vmi_32.c index 0a1b1a9d922d..45c27c4e2a6e 100644 --- a/arch/x86/kernel/vmi_32.c +++ b/arch/x86/kernel/vmi_32.c | |||
@@ -904,8 +904,8 @@ static inline int __init activate_vmi(void) | |||
904 | #endif | 904 | #endif |
905 | 905 | ||
906 | #ifdef CONFIG_X86_LOCAL_APIC | 906 | #ifdef CONFIG_X86_LOCAL_APIC |
907 | para_fill(pv_apic_ops.apic_read, APICRead); | 907 | para_fill(apic_ops->read, APICRead); |
908 | para_fill(pv_apic_ops.apic_write, APICWrite); | 908 | para_fill(apic_ops->write, APICWrite); |
909 | #endif | 909 | #endif |
910 | 910 | ||
911 | /* | 911 | /* |
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c index 0313a5eec412..35c4349cd668 100644 --- a/arch/x86/lguest/boot.c +++ b/arch/x86/lguest/boot.c | |||
@@ -783,14 +783,44 @@ static void lguest_wbinvd(void) | |||
783 | * code qualifies for Advanced. It will also never interrupt anything. It | 783 | * code qualifies for Advanced. It will also never interrupt anything. It |
784 | * does, however, allow us to get through the Linux boot code. */ | 784 | * does, however, allow us to get through the Linux boot code. */ |
785 | #ifdef CONFIG_X86_LOCAL_APIC | 785 | #ifdef CONFIG_X86_LOCAL_APIC |
786 | static void lguest_apic_write(unsigned long reg, u32 v) | 786 | static void lguest_apic_write(u32 reg, u32 v) |
787 | { | 787 | { |
788 | } | 788 | } |
789 | 789 | ||
790 | static u32 lguest_apic_read(unsigned long reg) | 790 | static u32 lguest_apic_read(u32 reg) |
791 | { | 791 | { |
792 | return 0; | 792 | return 0; |
793 | } | 793 | } |
794 | |||
795 | static u64 lguest_apic_icr_read(void) | ||
796 | { | ||
797 | return 0; | ||
798 | } | ||
799 | |||
800 | static void lguest_apic_icr_write(u32 low, u32 id) | ||
801 | { | ||
802 | /* Warn to see if there's any stray references */ | ||
803 | WARN_ON(1); | ||
804 | } | ||
805 | |||
806 | static void lguest_apic_wait_icr_idle(void) | ||
807 | { | ||
808 | return; | ||
809 | } | ||
810 | |||
811 | static u32 lguest_apic_safe_wait_icr_idle(void) | ||
812 | { | ||
813 | return 0; | ||
814 | } | ||
815 | |||
816 | static struct apic_ops lguest_basic_apic_ops = { | ||
817 | .read = lguest_apic_read, | ||
818 | .write = lguest_apic_write, | ||
819 | .icr_read = lguest_apic_icr_read, | ||
820 | .icr_write = lguest_apic_icr_write, | ||
821 | .wait_icr_idle = lguest_apic_wait_icr_idle, | ||
822 | .safe_wait_icr_idle = lguest_apic_safe_wait_icr_idle, | ||
823 | }; | ||
794 | #endif | 824 | #endif |
795 | 825 | ||
796 | /* STOP! Until an interrupt comes in. */ | 826 | /* STOP! Until an interrupt comes in. */ |
@@ -990,8 +1020,7 @@ __init void lguest_init(void) | |||
990 | 1020 | ||
991 | #ifdef CONFIG_X86_LOCAL_APIC | 1021 | #ifdef CONFIG_X86_LOCAL_APIC |
992 | /* apic read/write intercepts */ | 1022 | /* apic read/write intercepts */ |
993 | pv_apic_ops.apic_write = lguest_apic_write; | 1023 | apic_ops = &lguest_basic_apic_ops; |
994 | pv_apic_ops.apic_read = lguest_apic_read; | ||
995 | #endif | 1024 | #endif |
996 | 1025 | ||
997 | /* time operations */ | 1026 | /* time operations */ |
diff --git a/arch/x86/mach-generic/bigsmp.c b/arch/x86/mach-generic/bigsmp.c index 59d771714559..b31f2800638e 100644 --- a/arch/x86/mach-generic/bigsmp.c +++ b/arch/x86/mach-generic/bigsmp.c | |||
@@ -5,17 +5,16 @@ | |||
5 | #define APIC_DEFINITION 1 | 5 | #define APIC_DEFINITION 1 |
6 | #include <linux/threads.h> | 6 | #include <linux/threads.h> |
7 | #include <linux/cpumask.h> | 7 | #include <linux/cpumask.h> |
8 | #include <asm/smp.h> | ||
9 | #include <asm/mpspec.h> | 8 | #include <asm/mpspec.h> |
10 | #include <asm/genapic.h> | 9 | #include <asm/genapic.h> |
11 | #include <asm/fixmap.h> | 10 | #include <asm/fixmap.h> |
12 | #include <asm/apicdef.h> | 11 | #include <asm/apicdef.h> |
13 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
14 | #include <linux/smp.h> | ||
15 | #include <linux/init.h> | 13 | #include <linux/init.h> |
16 | #include <linux/dmi.h> | 14 | #include <linux/dmi.h> |
17 | #include <asm/mach-bigsmp/mach_apic.h> | ||
18 | #include <asm/mach-bigsmp/mach_apicdef.h> | 15 | #include <asm/mach-bigsmp/mach_apicdef.h> |
16 | #include <linux/smp.h> | ||
17 | #include <asm/mach-bigsmp/mach_apic.h> | ||
19 | #include <asm/mach-bigsmp/mach_ipi.h> | 18 | #include <asm/mach-bigsmp/mach_ipi.h> |
20 | #include <asm/mach-default/mach_mpparse.h> | 19 | #include <asm/mach-default/mach_mpparse.h> |
21 | 20 | ||
diff --git a/arch/x86/mach-generic/es7000.c b/arch/x86/mach-generic/es7000.c index 4742626f08c4..9b30547d746e 100644 --- a/arch/x86/mach-generic/es7000.c +++ b/arch/x86/mach-generic/es7000.c | |||
@@ -4,16 +4,15 @@ | |||
4 | #define APIC_DEFINITION 1 | 4 | #define APIC_DEFINITION 1 |
5 | #include <linux/threads.h> | 5 | #include <linux/threads.h> |
6 | #include <linux/cpumask.h> | 6 | #include <linux/cpumask.h> |
7 | #include <asm/smp.h> | ||
8 | #include <asm/mpspec.h> | 7 | #include <asm/mpspec.h> |
9 | #include <asm/genapic.h> | 8 | #include <asm/genapic.h> |
10 | #include <asm/fixmap.h> | 9 | #include <asm/fixmap.h> |
11 | #include <asm/apicdef.h> | 10 | #include <asm/apicdef.h> |
12 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
13 | #include <linux/string.h> | 12 | #include <linux/string.h> |
14 | #include <linux/smp.h> | ||
15 | #include <linux/init.h> | 13 | #include <linux/init.h> |
16 | #include <asm/mach-es7000/mach_apicdef.h> | 14 | #include <asm/mach-es7000/mach_apicdef.h> |
15 | #include <linux/smp.h> | ||
17 | #include <asm/mach-es7000/mach_apic.h> | 16 | #include <asm/mach-es7000/mach_apic.h> |
18 | #include <asm/mach-es7000/mach_ipi.h> | 17 | #include <asm/mach-es7000/mach_ipi.h> |
19 | #include <asm/mach-es7000/mach_mpparse.h> | 18 | #include <asm/mach-es7000/mach_mpparse.h> |
diff --git a/arch/x86/mach-generic/numaq.c b/arch/x86/mach-generic/numaq.c index 8091e68764c4..95c07efff6b7 100644 --- a/arch/x86/mach-generic/numaq.c +++ b/arch/x86/mach-generic/numaq.c | |||
@@ -4,7 +4,6 @@ | |||
4 | #define APIC_DEFINITION 1 | 4 | #define APIC_DEFINITION 1 |
5 | #include <linux/threads.h> | 5 | #include <linux/threads.h> |
6 | #include <linux/cpumask.h> | 6 | #include <linux/cpumask.h> |
7 | #include <linux/smp.h> | ||
8 | #include <asm/mpspec.h> | 7 | #include <asm/mpspec.h> |
9 | #include <asm/genapic.h> | 8 | #include <asm/genapic.h> |
10 | #include <asm/fixmap.h> | 9 | #include <asm/fixmap.h> |
@@ -12,8 +11,9 @@ | |||
12 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
13 | #include <linux/string.h> | 12 | #include <linux/string.h> |
14 | #include <linux/init.h> | 13 | #include <linux/init.h> |
15 | #include <asm/mach-numaq/mach_apic.h> | ||
16 | #include <asm/mach-numaq/mach_apicdef.h> | 14 | #include <asm/mach-numaq/mach_apicdef.h> |
15 | #include <linux/smp.h> | ||
16 | #include <asm/mach-numaq/mach_apic.h> | ||
17 | #include <asm/mach-numaq/mach_ipi.h> | 17 | #include <asm/mach-numaq/mach_ipi.h> |
18 | #include <asm/mach-numaq/mach_mpparse.h> | 18 | #include <asm/mach-numaq/mach_mpparse.h> |
19 | #include <asm/mach-numaq/mach_wakecpu.h> | 19 | #include <asm/mach-numaq/mach_wakecpu.h> |
diff --git a/arch/x86/mach-generic/summit.c b/arch/x86/mach-generic/summit.c index a97ea0f35b1e..752edd96b1bf 100644 --- a/arch/x86/mach-generic/summit.c +++ b/arch/x86/mach-generic/summit.c | |||
@@ -4,17 +4,16 @@ | |||
4 | #define APIC_DEFINITION 1 | 4 | #define APIC_DEFINITION 1 |
5 | #include <linux/threads.h> | 5 | #include <linux/threads.h> |
6 | #include <linux/cpumask.h> | 6 | #include <linux/cpumask.h> |
7 | #include <asm/smp.h> | ||
8 | #include <asm/mpspec.h> | 7 | #include <asm/mpspec.h> |
9 | #include <asm/genapic.h> | 8 | #include <asm/genapic.h> |
10 | #include <asm/fixmap.h> | 9 | #include <asm/fixmap.h> |
11 | #include <asm/apicdef.h> | 10 | #include <asm/apicdef.h> |
12 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
13 | #include <linux/string.h> | 12 | #include <linux/string.h> |
14 | #include <linux/smp.h> | ||
15 | #include <linux/init.h> | 13 | #include <linux/init.h> |
16 | #include <asm/mach-summit/mach_apic.h> | ||
17 | #include <asm/mach-summit/mach_apicdef.h> | 14 | #include <asm/mach-summit/mach_apicdef.h> |
15 | #include <linux/smp.h> | ||
16 | #include <asm/mach-summit/mach_apic.h> | ||
18 | #include <asm/mach-summit/mach_ipi.h> | 17 | #include <asm/mach-summit/mach_ipi.h> |
19 | #include <asm/mach-summit/mach_mpparse.h> | 18 | #include <asm/mach-summit/mach_mpparse.h> |
20 | 19 | ||
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 7f26c3718777..008b7b69581e 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -548,16 +548,47 @@ static void xen_io_delay(void) | |||
548 | } | 548 | } |
549 | 549 | ||
550 | #ifdef CONFIG_X86_LOCAL_APIC | 550 | #ifdef CONFIG_X86_LOCAL_APIC |
551 | static u32 xen_apic_read(unsigned long reg) | 551 | static u32 xen_apic_read(u32 reg) |
552 | { | 552 | { |
553 | return 0; | 553 | return 0; |
554 | } | 554 | } |
555 | 555 | ||
556 | static void xen_apic_write(unsigned long reg, u32 val) | 556 | static void xen_apic_write(u32 reg, u32 val) |
557 | { | 557 | { |
558 | /* Warn to see if there's any stray references */ | 558 | /* Warn to see if there's any stray references */ |
559 | WARN_ON(1); | 559 | WARN_ON(1); |
560 | } | 560 | } |
561 | |||
562 | static u64 xen_apic_icr_read(void) | ||
563 | { | ||
564 | return 0; | ||
565 | } | ||
566 | |||
567 | static void xen_apic_icr_write(u32 low, u32 id) | ||
568 | { | ||
569 | /* Warn to see if there's any stray references */ | ||
570 | WARN_ON(1); | ||
571 | } | ||
572 | |||
573 | static void xen_apic_wait_icr_idle(void) | ||
574 | { | ||
575 | return; | ||
576 | } | ||
577 | |||
578 | static u32 xen_safe_apic_wait_icr_idle(void) | ||
579 | { | ||
580 | return 0; | ||
581 | } | ||
582 | |||
583 | static struct apic_ops xen_basic_apic_ops = { | ||
584 | .read = xen_apic_read, | ||
585 | .write = xen_apic_write, | ||
586 | .icr_read = xen_apic_icr_read, | ||
587 | .icr_write = xen_apic_icr_write, | ||
588 | .wait_icr_idle = xen_apic_wait_icr_idle, | ||
589 | .safe_wait_icr_idle = xen_safe_apic_wait_icr_idle, | ||
590 | }; | ||
591 | |||
561 | #endif | 592 | #endif |
562 | 593 | ||
563 | static void xen_flush_tlb(void) | 594 | static void xen_flush_tlb(void) |
@@ -1130,8 +1161,6 @@ static const struct pv_irq_ops xen_irq_ops __initdata = { | |||
1130 | 1161 | ||
1131 | static const struct pv_apic_ops xen_apic_ops __initdata = { | 1162 | static const struct pv_apic_ops xen_apic_ops __initdata = { |
1132 | #ifdef CONFIG_X86_LOCAL_APIC | 1163 | #ifdef CONFIG_X86_LOCAL_APIC |
1133 | .apic_write = xen_apic_write, | ||
1134 | .apic_read = xen_apic_read, | ||
1135 | .setup_boot_clock = paravirt_nop, | 1164 | .setup_boot_clock = paravirt_nop, |
1136 | .setup_secondary_clock = paravirt_nop, | 1165 | .setup_secondary_clock = paravirt_nop, |
1137 | .startup_ipi_hook = paravirt_nop, | 1166 | .startup_ipi_hook = paravirt_nop, |
@@ -1293,6 +1322,13 @@ asmlinkage void __init xen_start_kernel(void) | |||
1293 | pv_apic_ops = xen_apic_ops; | 1322 | pv_apic_ops = xen_apic_ops; |
1294 | pv_mmu_ops = xen_mmu_ops; | 1323 | pv_mmu_ops = xen_mmu_ops; |
1295 | 1324 | ||
1325 | #ifdef CONFIG_X86_LOCAL_APIC | ||
1326 | /* | ||
1327 | * set up the basic apic ops. | ||
1328 | */ | ||
1329 | apic_ops = &xen_basic_apic_ops; | ||
1330 | #endif | ||
1331 | |||
1296 | if (xen_feature(XENFEAT_mmu_pt_update_preserve_ad)) { | 1332 | if (xen_feature(XENFEAT_mmu_pt_update_preserve_ad)) { |
1297 | pv_mmu_ops.ptep_modify_prot_start = xen_ptep_modify_prot_start; | 1333 | pv_mmu_ops.ptep_modify_prot_start = xen_ptep_modify_prot_start; |
1298 | pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit; | 1334 | pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit; |