Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'x86/apic' into irq/numa

Conflicts:
arch/x86/kernel/apic/io_apic.c

Merge reason: non-trivial interaction between ongoing work in io_apic.c
and the NUMA migration feature in the irq tree.

Signed-off-by: Ingo Molnar <mingo@elte.hu>

+488 -623
+3
Documentation/kernel-parameters.txt
··· 1565 1565 noinitrd [RAM] Tells the kernel not to load any configured 1566 1566 initial RAM disk. 1567 1567 1568 + nointremap [X86-64, Intel-IOMMU] Do not enable interrupt 1569 + remapping. 1570 + 1568 1571 nointroute [IA-64] 1569 1572 1570 1573 nojitter [IA64] Disables jitter checking for ITC timers.
+1 -1
arch/x86/Kconfig
··· 349 349 depends on X86_64 350 350 depends on X86_EXTENDED_PLATFORM 351 351 depends on NUMA 352 - select X86_X2APIC 352 + depends on X86_X2APIC 353 353 ---help--- 354 354 This option is needed in order to support SGI Ultraviolet systems. 355 355 If you don't have one of these, you should say N here.
+10 -18
arch/x86/include/asm/apic.h
··· 107 107 extern void native_apic_icr_write(u32 low, u32 id); 108 108 extern u64 native_apic_icr_read(void); 109 109 110 - #define EIM_8BIT_APIC_ID 0 111 - #define EIM_32BIT_APIC_ID 1 110 + extern int x2apic_mode; 112 111 113 112 #ifdef CONFIG_X86_X2APIC 114 113 /* ··· 165 166 return val; 166 167 } 167 168 168 - extern int x2apic, x2apic_phys; 169 + extern int x2apic_phys; 169 170 extern void check_x2apic(void); 170 171 extern void enable_x2apic(void); 171 - extern void enable_IR_x2apic(void); 172 172 extern void x2apic_icr_write(u32 low, u32 id); 173 173 static inline int x2apic_enabled(void) 174 174 { ··· 181 183 return 1; 182 184 return 0; 183 185 } 186 + 187 + #define x2apic_supported() (cpu_has_x2apic) 184 188 #else 185 189 static inline void check_x2apic(void) 186 190 { ··· 190 190 static inline void enable_x2apic(void) 191 191 { 192 192 } 193 - static inline void enable_IR_x2apic(void) 194 - { 195 - } 196 193 static inline int x2apic_enabled(void) 197 194 { 198 195 return 0; 199 196 } 200 197 201 - #define x2apic 0 202 - 198 + #define x2apic_preenabled 0 199 + #define x2apic_supported() 0 203 200 #endif 201 + 202 + extern void enable_IR_x2apic(void); 204 203 205 204 extern int get_physical_broadcast(void); 206 205 207 - #ifdef CONFIG_X86_X2APIC 208 - static inline void ack_x2APIC_irq(void) 209 - { 210 - /* Docs say use 0 for future compatibility */ 211 - native_apic_msr_write(APIC_EOI, 0); 212 - } 213 - #endif 214 - 206 + extern void apic_disable(void); 215 207 extern int lapic_get_maxlvt(void); 216 208 extern void clear_local_APIC(void); 217 209 extern void connect_bsp_APIC(void); ··· 244 252 #define local_apic_timer_c2_ok 1 245 253 static inline void init_apic_mappings(void) { } 246 254 static inline void disable_local_APIC(void) { } 247 - 255 + static inline void apic_disable(void) { } 248 256 #endif /* !CONFIG_X86_LOCAL_APIC */ 249 257 250 258 #ifdef CONFIG_X86_64
-4
arch/x86/include/asm/i8259.h
··· 60 60 extern void mask_8259A(void); 61 61 extern void unmask_8259A(void); 62 62 63 - #ifdef CONFIG_X86_32 64 - extern void init_ISA_irqs(void); 65 - #endif 66 - 67 63 #endif /* _ASM_X86_I8259_H */
-4
arch/x86/include/asm/io_apic.h
··· 161 161 extern int (*ioapic_renumber_irq)(int ioapic, int irq); 162 162 extern void ioapic_init_mappings(void); 163 163 164 - #ifdef CONFIG_X86_64 165 164 extern struct IO_APIC_route_entry **alloc_ioapic_entries(void); 166 165 extern void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries); 167 166 extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries); 168 167 extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries); 169 168 extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries); 170 - extern void reinit_intr_remapped_IO_APIC(int intr_remapping, 171 - struct IO_APIC_route_entry **ioapic_entries); 172 - #endif 173 169 174 170 extern void probe_nr_irqs_gsi(void); 175 171
+1 -1
arch/x86/include/asm/irq_remapping.h
··· 1 1 #ifndef _ASM_X86_IRQ_REMAPPING_H 2 2 #define _ASM_X86_IRQ_REMAPPING_H 3 3 4 - #define IRTE_DEST(dest) ((x2apic) ? dest : dest << 8) 4 + #define IRTE_DEST(dest) ((x2apic_mode) ? dest : dest << 8) 5 5 6 6 #endif /* _ASM_X86_IRQ_REMAPPING_H */
+1
arch/x86/include/asm/irq_vectors.h
··· 34 34 35 35 #ifdef CONFIG_X86_32 36 36 # define SYSCALL_VECTOR 0x80 37 + # define IA32_SYSCALL_VECTOR 0x80 37 38 #else 38 39 # define IA32_SYSCALL_VECTOR 0x80 39 40 #endif
-1
arch/x86/include/asm/setup.h
··· 33 33 int (*setup_ioapic_ids)(void); 34 34 }; 35 35 36 - extern void x86_quirk_pre_intr_init(void); 37 36 extern void x86_quirk_intr_init(void); 38 37 39 38 extern void x86_quirk_trap_init(void);
+1 -1
arch/x86/kernel/Makefile
··· 28 28 obj-y := process_$(BITS).o signal.o entry_$(BITS).o 29 29 obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o 30 30 obj-y += time_$(BITS).o ioport.o ldt.o dumpstack.o 31 - obj-y += setup.o i8259.o irqinit_$(BITS).o 31 + obj-y += setup.o i8259.o irqinit.o 32 32 obj-$(CONFIG_X86_VISWS) += visws_quirks.o 33 33 obj-$(CONFIG_X86_32) += probe_roms_32.o 34 34 obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
+155 -102
arch/x86/kernel/apic/apic.c
··· 98 98 /* Local APIC was disabled by the BIOS and enabled by the kernel */ 99 99 static int enabled_via_apicbase; 100 100 101 + /* 102 + * Handle interrupt mode configuration register (IMCR). 103 + * This register controls whether the interrupt signals 104 + * that reach the BSP come from the master PIC or from the 105 + * local APIC. Before entering Symmetric I/O Mode, either 106 + * the BIOS or the operating system must switch out of 107 + * PIC Mode by changing the IMCR. 108 + */ 109 + static inline void imcr_pic_to_apic(void) 110 + { 111 + /* select IMCR register */ 112 + outb(0x70, 0x22); 113 + /* NMI and 8259 INTR go through APIC */ 114 + outb(0x01, 0x23); 115 + } 116 + 117 + static inline void imcr_apic_to_pic(void) 118 + { 119 + /* select IMCR register */ 120 + outb(0x70, 0x22); 121 + /* NMI and 8259 INTR go directly to BSP */ 122 + outb(0x00, 0x23); 123 + } 101 124 #endif 102 125 103 126 #ifdef CONFIG_X86_64 ··· 134 111 __setup("apicpmtimer", setup_apicpmtimer); 135 112 #endif 136 113 114 + int x2apic_mode; 137 115 #ifdef CONFIG_X86_X2APIC 138 - int x2apic; 139 116 /* x2apic enabled before OS handover */ 140 117 static int x2apic_preenabled; 141 118 static int disable_x2apic; 142 119 static __init int setup_nox2apic(char *str) 143 120 { 121 + if (x2apic_enabled()) { 122 + pr_warning("Bios already enabled x2apic, " 123 + "can't enforce nox2apic"); 124 + return 0; 125 + } 126 + 144 127 disable_x2apic = 1; 145 128 setup_clear_cpu_cap(X86_FEATURE_X2APIC); 146 129 return 0; ··· 236 207 boot_cpu_data.x86 >= 0xf) 237 208 return 1; 238 209 return lapic_get_version() >= 0x14; 210 + } 211 + 212 + /* 213 + * bare function to substitute write operation 214 + * and it's _that_ fast :) 215 + */ 216 + void native_apic_write_dummy(u32 reg, u32 v) 217 + { 218 + WARN_ON_ONCE((cpu_has_apic || !disable_apic)); 219 + } 220 + 221 + /* 222 + * right after this call apic->write doesn't do anything 223 + * note that there is no restore operation it works one way 224 + */ 225 + void apic_disable(void) 226 + { 227 + apic->write = native_apic_write_dummy; 239 228 } 240 229 241 230 void native_apic_wait_icr_idle(void) ··· 862 815 u32 v; 863 816 864 817 /* APIC hasn't been mapped yet */ 865 - if (!x2apic && !apic_phys) 818 + if (!x2apic_mode && !apic_phys) 866 819 return; 867 820 868 821 maxlvt = lapic_get_maxlvt(); ··· 1334 1287 { 1335 1288 if (x2apic_enabled()) { 1336 1289 pr_info("x2apic enabled by BIOS, switching to x2apic ops\n"); 1337 - x2apic_preenabled = x2apic = 1; 1290 + x2apic_preenabled = x2apic_mode = 1; 1338 1291 } 1339 1292 } 1340 1293 ··· 1342 1295 { 1343 1296 int msr, msr2; 1344 1297 1345 - if (!x2apic) 1298 + if (!x2apic_mode) 1346 1299 return; 1347 1300 1348 1301 rdmsr(MSR_IA32_APICBASE, msr, msr2); ··· 1351 1304 wrmsr(MSR_IA32_APICBASE, msr | X2APIC_ENABLE, 0); 1352 1305 } 1353 1306 } 1307 + #endif /* CONFIG_X86_X2APIC */ 1354 1308 1355 1309 void __init enable_IR_x2apic(void) 1356 1310 { ··· 1360 1312 unsigned long flags; 1361 1313 struct IO_APIC_route_entry **ioapic_entries = NULL; 1362 1314 1363 - if (!cpu_has_x2apic) 1364 - return; 1365 - 1366 - if (!x2apic_preenabled && disable_x2apic) { 1367 - pr_info("Skipped enabling x2apic and Interrupt-remapping " 1368 - "because of nox2apic\n"); 1369 - return; 1370 - } 1371 - 1372 - if (x2apic_preenabled && disable_x2apic) 1373 - panic("Bios already enabled x2apic, can't enforce nox2apic"); 1374 - 1375 - if (!x2apic_preenabled && skip_ioapic_setup) { 1376 - pr_info("Skipped enabling x2apic and Interrupt-remapping " 1377 - "because of skipping io-apic setup\n"); 1378 - return; 1379 - } 1380 - 1381 1315 ret = dmar_table_init(); 1382 1316 if (ret) { 1383 - pr_info("dmar_table_init() failed with %d:\n", ret); 1317 + pr_debug("dmar_table_init() failed with %d:\n", ret); 1318 + goto ir_failed; 1319 + } 1384 1320 1385 - if (x2apic_preenabled) 1386 - panic("x2apic enabled by bios. But IR enabling failed"); 1387 - else 1388 - pr_info("Not enabling x2apic,Intr-remapping\n"); 1321 + if (!intr_remapping_supported()) { 1322 + pr_debug("intr-remapping not supported\n"); 1323 + goto ir_failed; 1324 + } 1325 + 1326 + 1327 + if (!x2apic_preenabled && skip_ioapic_setup) { 1328 + pr_info("Skipped enabling intr-remap because of skipping " 1329 + "io-apic setup\n"); 1389 1330 return; 1390 1331 } 1391 1332 ··· 1394 1357 mask_IO_APIC_setup(ioapic_entries); 1395 1358 mask_8259A(); 1396 1359 1397 - ret = enable_intr_remapping(EIM_32BIT_APIC_ID); 1398 - 1399 - if (ret && x2apic_preenabled) { 1400 - local_irq_restore(flags); 1401 - panic("x2apic enabled by bios. But IR enabling failed"); 1402 - } 1403 - 1360 + ret = enable_intr_remapping(x2apic_supported()); 1404 1361 if (ret) 1405 1362 goto end_restore; 1406 1363 1407 - if (!x2apic) { 1408 - x2apic = 1; 1364 + pr_info("Enabled Interrupt-remapping\n"); 1365 + 1366 + if (x2apic_supported() && !x2apic_mode) { 1367 + x2apic_mode = 1; 1409 1368 enable_x2apic(); 1369 + pr_info("Enabled x2apic\n"); 1410 1370 } 1411 1371 1412 1372 end_restore: ··· 1412 1378 * IR enabling failed 1413 1379 */ 1414 1380 restore_IO_APIC_setup(ioapic_entries); 1415 - else 1416 - reinit_intr_remapped_IO_APIC(x2apic_preenabled, ioapic_entries); 1417 1381 1418 1382 unmask_8259A(); 1419 1383 local_irq_restore(flags); 1420 1384 1421 1385 end: 1422 - if (!ret) { 1423 - if (!x2apic_preenabled) 1424 - pr_info("Enabled x2apic and interrupt-remapping\n"); 1425 - else 1426 - pr_info("Enabled Interrupt-remapping\n"); 1427 - } else 1428 - pr_err("Failed to enable Interrupt-remapping and x2apic\n"); 1429 1386 if (ioapic_entries) 1430 1387 free_ioapic_entries(ioapic_entries); 1388 + 1389 + if (!ret) 1390 + return; 1391 + 1392 + ir_failed: 1393 + if (x2apic_preenabled) 1394 + panic("x2apic enabled by bios. But IR enabling failed"); 1395 + else if (cpu_has_x2apic) 1396 + pr_info("Not enabling x2apic,Intr-remapping\n"); 1431 1397 #else 1432 1398 if (!cpu_has_x2apic) 1433 1399 return; 1434 1400 1435 1401 if (x2apic_preenabled) 1436 1402 panic("x2apic enabled prior OS handover," 1437 - " enable CONFIG_INTR_REMAP"); 1438 - 1439 - pr_info("Enable CONFIG_INTR_REMAP for enabling intr-remapping " 1440 - " and x2apic\n"); 1403 + " enable CONFIG_X86_X2APIC, CONFIG_INTR_REMAP"); 1441 1404 #endif 1442 1405 1443 1406 return; 1444 1407 } 1445 - #endif /* CONFIG_X86_X2APIC */ 1408 + 1446 1409 1447 1410 #ifdef CONFIG_X86_64 1448 1411 /* ··· 1570 1539 */ 1571 1540 void __init init_apic_mappings(void) 1572 1541 { 1573 - if (x2apic) { 1542 + if (x2apic_mode) { 1574 1543 boot_cpu_physical_apicid = read_apic_id(); 1575 1544 return; 1576 1545 } ··· 1596 1565 */ 1597 1566 if (boot_cpu_physical_apicid == -1U) 1598 1567 boot_cpu_physical_apicid = read_apic_id(); 1568 + 1569 + /* lets check if we may to NOP'ify apic operations */ 1570 + if (!cpu_has_apic) { 1571 + pr_info("APIC: disable apic facility\n"); 1572 + apic_disable(); 1573 + } 1599 1574 } 1600 1575 1601 1576 /* ··· 1770 1733 */ 1771 1734 apic_printk(APIC_VERBOSE, "leaving PIC mode, " 1772 1735 "enabling APIC mode.\n"); 1773 - outb(0x70, 0x22); 1774 - outb(0x01, 0x23); 1736 + imcr_pic_to_apic(); 1775 1737 } 1776 1738 #endif 1777 1739 if (apic->enable_apic_mode) ··· 1798 1762 */ 1799 1763 apic_printk(APIC_VERBOSE, "disabling APIC mode, " 1800 1764 "entering PIC mode.\n"); 1801 - outb(0x70, 0x22); 1802 - outb(0x00, 0x23); 1765 + imcr_apic_to_pic(); 1803 1766 return; 1804 1767 } 1805 1768 #endif ··· 2004 1969 2005 1970 local_irq_save(flags); 2006 1971 disable_local_APIC(); 2007 - #ifdef CONFIG_INTR_REMAP 1972 + 2008 1973 if (intr_remapping_enabled) 2009 1974 disable_intr_remapping(); 2010 - #endif 1975 + 2011 1976 local_irq_restore(flags); 2012 1977 return 0; 2013 1978 } ··· 2017 1982 unsigned int l, h; 2018 1983 unsigned long flags; 2019 1984 int maxlvt; 2020 - 2021 - #ifdef CONFIG_INTR_REMAP 2022 1985 int ret; 2023 1986 struct IO_APIC_route_entry **ioapic_entries = NULL; 2024 1987 ··· 2024 1991 return 0; 2025 1992 2026 1993 local_irq_save(flags); 2027 - if (x2apic) { 1994 + if (intr_remapping_enabled) { 2028 1995 ioapic_entries = alloc_ioapic_entries(); 2029 1996 if (!ioapic_entries) { 2030 1997 WARN(1, "Alloc ioapic_entries in lapic resume failed."); ··· 2040 2007 2041 2008 mask_IO_APIC_setup(ioapic_entries); 2042 2009 mask_8259A(); 2043 - enable_x2apic(); 2044 2010 } 2045 - #else 2046 - if (!apic_pm_state.active) 2047 - return 0; 2048 2011 2049 - local_irq_save(flags); 2050 - if (x2apic) 2012 + if (x2apic_mode) 2051 2013 enable_x2apic(); 2052 - #endif 2053 - 2054 2014 else { 2055 2015 /* 2056 2016 * Make sure the APICBASE points to the right address ··· 2081 2055 apic_write(APIC_ESR, 0); 2082 2056 apic_read(APIC_ESR); 2083 2057 2084 - #ifdef CONFIG_INTR_REMAP 2085 - if (intr_remapping_enabled) 2086 - reenable_intr_remapping(EIM_32BIT_APIC_ID); 2087 - 2088 - if (x2apic) { 2058 + if (intr_remapping_enabled) { 2059 + reenable_intr_remapping(x2apic_mode); 2089 2060 unmask_8259A(); 2090 2061 restore_IO_APIC_setup(ioapic_entries); 2091 2062 free_ioapic_entries(ioapic_entries); 2092 2063 } 2093 - #endif 2094 2064 2095 2065 local_irq_restore(flags); 2096 - 2097 2066 2098 2067 return 0; 2099 2068 } ··· 2138 2117 #endif /* CONFIG_PM */ 2139 2118 2140 2119 #ifdef CONFIG_X86_64 2141 - /* 2142 - * apic_is_clustered_box() -- Check if we can expect good TSC 2143 - * 2144 - * Thus far, the major user of this is IBM's Summit2 series: 2145 - * 2146 - * Clustered boxes may have unsynced TSC problems if they are 2147 - * multi-chassis. Use available data to take a good guess. 2148 - * If in doubt, go HPET. 2149 - */ 2150 - __cpuinit int apic_is_clustered_box(void) 2120 + 2121 + static int __cpuinit apic_cluster_num(void) 2151 2122 { 2152 2123 int i, clusters, zeros; 2153 2124 unsigned id; 2154 2125 u16 *bios_cpu_apicid; 2155 2126 DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS); 2156 - 2157 - /* 2158 - * there is not this kind of box with AMD CPU yet. 2159 - * Some AMD box with quadcore cpu and 8 sockets apicid 2160 - * will be [4, 0x23] or [8, 0x27] could be thought to 2161 - * vsmp box still need checking... 2162 - */ 2163 - if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && !is_vsmp_box()) 2164 - return 0; 2165 2127 2166 2128 bios_cpu_apicid = early_per_cpu_ptr(x86_bios_cpu_apicid); 2167 2129 bitmap_zero(clustermap, NUM_APIC_CLUSTERS); ··· 2181 2177 ++zeros; 2182 2178 } 2183 2179 2184 - /* ScaleMP vSMPowered boxes have one cluster per board and TSCs are 2185 - * not guaranteed to be synced between boards 2186 - */ 2187 - if (is_vsmp_box() && clusters > 1) 2180 + return clusters; 2181 + } 2182 + 2183 + static int __cpuinitdata multi_checked; 2184 + static int __cpuinitdata multi; 2185 + 2186 + static int __cpuinit set_multi(const struct dmi_system_id *d) 2187 + { 2188 + if (multi) 2189 + return 0; 2190 + printk(KERN_INFO "APIC: %s detected, Multi Chassis\n", d->ident); 2191 + multi = 1; 2192 + return 0; 2193 + } 2194 + 2195 + static const __cpuinitconst struct dmi_system_id multi_dmi_table[] = { 2196 + { 2197 + .callback = set_multi, 2198 + .ident = "IBM System Summit2", 2199 + .matches = { 2200 + DMI_MATCH(DMI_SYS_VENDOR, "IBM"), 2201 + DMI_MATCH(DMI_PRODUCT_NAME, "Summit2"), 2202 + }, 2203 + }, 2204 + {} 2205 + }; 2206 + 2207 + static void __cpuinit dmi_check_multi(void) 2208 + { 2209 + if (multi_checked) 2210 + return; 2211 + 2212 + dmi_check_system(multi_dmi_table); 2213 + multi_checked = 1; 2214 + } 2215 + 2216 + /* 2217 + * apic_is_clustered_box() -- Check if we can expect good TSC 2218 + * 2219 + * Thus far, the major user of this is IBM's Summit2 series: 2220 + * Clustered boxes may have unsynced TSC problems if they are 2221 + * multi-chassis. 2222 + * Use DMI to check them 2223 + */ 2224 + __cpuinit int apic_is_clustered_box(void) 2225 + { 2226 + dmi_check_multi(); 2227 + if (multi) 2188 2228 return 1; 2189 2229 2230 + if (!is_vsmp_box()) 2231 + return 0; 2232 + 2190 2233 /* 2191 - * If clusters > 2, then should be multi-chassis. 2192 - * May have to revisit this when multi-core + hyperthreaded CPUs come 2193 - * out, but AFAIK this will work even for them. 2234 + * ScaleMP vSMPowered boxes have one cluster per board and TSCs are 2235 + * not guaranteed to be synced between boards 2194 2236 */ 2195 - return (clusters > 2); 2237 + if (apic_cluster_num() > 1) 2238 + return 1; 2239 + 2240 + return 0; 2196 2241 } 2197 2242 #endif 2198 2243
+1 -1
arch/x86/kernel/apic/es7000_32.c
··· 145 145 return gsi; 146 146 } 147 147 148 - static int wakeup_secondary_cpu_via_mip(int cpu, unsigned long eip) 148 + static int __cpuinit wakeup_secondary_cpu_via_mip(int cpu, unsigned long eip) 149 149 { 150 150 unsigned long vect = 0, psaival = 0; 151 151
+150 -191
arch/x86/kernel/apic/io_apic.c
··· 489 489 spin_unlock_irqrestore(&ioapic_lock, flags); 490 490 } 491 491 492 - #ifdef CONFIG_SMP 493 - static void send_cleanup_vector(struct irq_cfg *cfg) 494 - { 495 - cpumask_var_t cleanup_mask; 496 - 497 - if (unlikely(!alloc_cpumask_var(&cleanup_mask, GFP_ATOMIC))) { 498 - unsigned int i; 499 - cfg->move_cleanup_count = 0; 500 - for_each_cpu_and(i, cfg->old_domain, cpu_online_mask) 501 - cfg->move_cleanup_count++; 502 - for_each_cpu_and(i, cfg->old_domain, cpu_online_mask) 503 - apic->send_IPI_mask(cpumask_of(i), IRQ_MOVE_CLEANUP_VECTOR); 504 - } else { 505 - cpumask_and(cleanup_mask, cfg->old_domain, cpu_online_mask); 506 - cfg->move_cleanup_count = cpumask_weight(cleanup_mask); 507 - apic->send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR); 508 - free_cpumask_var(cleanup_mask); 509 - } 510 - cfg->move_in_progress = 0; 511 - } 512 - 513 - static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq_cfg *cfg) 514 - { 515 - int apic, pin; 516 - struct irq_pin_list *entry; 517 - u8 vector = cfg->vector; 518 - 519 - entry = cfg->irq_2_pin; 520 - for (;;) { 521 - unsigned int reg; 522 - 523 - if (!entry) 524 - break; 525 - 526 - apic = entry->apic; 527 - pin = entry->pin; 528 - /* 529 - * With interrupt-remapping, destination information comes 530 - * from interrupt-remapping table entry. 531 - */ 532 - if (!irq_remapped(irq)) 533 - io_apic_write(apic, 0x11 + pin*2, dest); 534 - reg = io_apic_read(apic, 0x10 + pin*2); 535 - reg &= ~IO_APIC_REDIR_VECTOR_MASK; 536 - reg |= vector; 537 - io_apic_modify(apic, 0x10 + pin*2, reg); 538 - if (!entry->next) 539 - break; 540 - entry = entry->next; 541 - } 542 - } 543 - 544 - static int 545 - assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask); 546 - 547 - /* 548 - * Either sets desc->affinity to a valid value, and returns 549 - * ->cpu_mask_to_apicid of that, or returns BAD_APICID and 550 - * leaves desc->affinity untouched. 551 - */ 552 - static unsigned int 553 - set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask) 554 - { 555 - struct irq_cfg *cfg; 556 - unsigned int irq; 557 - 558 - if (!cpumask_intersects(mask, cpu_online_mask)) 559 - return BAD_APICID; 560 - 561 - irq = desc->irq; 562 - cfg = desc->chip_data; 563 - if (assign_irq_vector(irq, cfg, mask)) 564 - return BAD_APICID; 565 - 566 - cpumask_copy(desc->affinity, mask); 567 - 568 - return apic->cpu_mask_to_apicid_and(desc->affinity, cfg->domain); 569 - } 570 - 571 - static int 572 - set_ioapic_affinity_irq_desc(struct irq_desc *desc, const struct cpumask *mask) 573 - { 574 - struct irq_cfg *cfg; 575 - unsigned long flags; 576 - unsigned int dest; 577 - unsigned int irq; 578 - int ret = -1; 579 - 580 - irq = desc->irq; 581 - cfg = desc->chip_data; 582 - 583 - spin_lock_irqsave(&ioapic_lock, flags); 584 - dest = set_desc_affinity(desc, mask); 585 - if (dest != BAD_APICID) { 586 - /* Only the high 8 bits are valid. */ 587 - dest = SET_APIC_LOGICAL_ID(dest); 588 - __target_IO_APIC_irq(irq, dest, cfg); 589 - ret = 0; 590 - } 591 - spin_unlock_irqrestore(&ioapic_lock, flags); 592 - 593 - return ret; 594 - } 595 - 596 - static int 597 - set_ioapic_affinity_irq(unsigned int irq, const struct cpumask *mask) 598 - { 599 - struct irq_desc *desc; 600 - 601 - desc = irq_to_desc(irq); 602 - 603 - return set_ioapic_affinity_irq_desc(desc, mask); 604 - } 605 - #endif /* CONFIG_SMP */ 606 - 607 492 /* 608 493 * The common case is 1:1 IRQ<->pin mappings. Sometimes there are 609 494 * shared ISA-space IRQs, so we have to support them. We are super ··· 707 822 __setup("pirq=", ioapic_pirq_setup); 708 823 #endif /* CONFIG_X86_32 */ 709 824 710 - #ifdef CONFIG_INTR_REMAP 711 825 struct IO_APIC_route_entry **alloc_ioapic_entries(void) 712 826 { 713 827 int apic; ··· 804 920 return 0; 805 921 } 806 922 807 - void reinit_intr_remapped_IO_APIC(int intr_remapping, 808 - struct IO_APIC_route_entry **ioapic_entries) 809 - 810 - { 811 - /* 812 - * for now plain restore of previous settings. 813 - * TBD: In the case of OS enabling interrupt-remapping, 814 - * IO-APIC RTE's need to be setup to point to interrupt-remapping 815 - * table entries. for now, do a plain restore, and wait for 816 - * the setup_IO_APIC_irqs() to do proper initialization. 817 - */ 818 - restore_IO_APIC_setup(ioapic_entries); 819 - } 820 - 821 923 void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries) 822 924 { 823 925 int apic; ··· 813 943 814 944 kfree(ioapic_entries); 815 945 } 816 - #endif 817 946 818 947 /* 819 948 * Find the IRQ entry number of a certain pin. ··· 2201 2332 */ 2202 2333 2203 2334 #ifdef CONFIG_SMP 2335 + static void send_cleanup_vector(struct irq_cfg *cfg) 2336 + { 2337 + cpumask_var_t cleanup_mask; 2338 + 2339 + if (unlikely(!alloc_cpumask_var(&cleanup_mask, GFP_ATOMIC))) { 2340 + unsigned int i; 2341 + cfg->move_cleanup_count = 0; 2342 + for_each_cpu_and(i, cfg->old_domain, cpu_online_mask) 2343 + cfg->move_cleanup_count++; 2344 + for_each_cpu_and(i, cfg->old_domain, cpu_online_mask) 2345 + apic->send_IPI_mask(cpumask_of(i), IRQ_MOVE_CLEANUP_VECTOR); 2346 + } else { 2347 + cpumask_and(cleanup_mask, cfg->old_domain, cpu_online_mask); 2348 + cfg->move_cleanup_count = cpumask_weight(cleanup_mask); 2349 + apic->send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR); 2350 + free_cpumask_var(cleanup_mask); 2351 + } 2352 + cfg->move_in_progress = 0; 2353 + } 2354 + 2355 + static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq_cfg *cfg) 2356 + { 2357 + int apic, pin; 2358 + struct irq_pin_list *entry; 2359 + u8 vector = cfg->vector; 2360 + 2361 + entry = cfg->irq_2_pin; 2362 + for (;;) { 2363 + unsigned int reg; 2364 + 2365 + if (!entry) 2366 + break; 2367 + 2368 + apic = entry->apic; 2369 + pin = entry->pin; 2370 + /* 2371 + * With interrupt-remapping, destination information comes 2372 + * from interrupt-remapping table entry. 2373 + */ 2374 + if (!irq_remapped(irq)) 2375 + io_apic_write(apic, 0x11 + pin*2, dest); 2376 + reg = io_apic_read(apic, 0x10 + pin*2); 2377 + reg &= ~IO_APIC_REDIR_VECTOR_MASK; 2378 + reg |= vector; 2379 + io_apic_modify(apic, 0x10 + pin*2, reg); 2380 + if (!entry->next) 2381 + break; 2382 + entry = entry->next; 2383 + } 2384 + } 2385 + 2386 + static int 2387 + assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask); 2388 + 2389 + /* 2390 + * Either sets desc->affinity to a valid value, and returns 2391 + * ->cpu_mask_to_apicid of that, or returns BAD_APICID and 2392 + * leaves desc->affinity untouched. 2393 + */ 2394 + static unsigned int 2395 + set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask) 2396 + { 2397 + struct irq_cfg *cfg; 2398 + unsigned int irq; 2399 + 2400 + if (!cpumask_intersects(mask, cpu_online_mask)) 2401 + return BAD_APICID; 2402 + 2403 + irq = desc->irq; 2404 + cfg = desc->chip_data; 2405 + if (assign_irq_vector(irq, cfg, mask)) 2406 + return BAD_APICID; 2407 + 2408 + cpumask_copy(desc->affinity, mask); 2409 + 2410 + return apic->cpu_mask_to_apicid_and(desc->affinity, cfg->domain); 2411 + } 2412 + 2413 + static int 2414 + set_ioapic_affinity_irq_desc(struct irq_desc *desc, const struct cpumask *mask) 2415 + { 2416 + struct irq_cfg *cfg; 2417 + unsigned long flags; 2418 + unsigned int dest; 2419 + unsigned int irq; 2420 + int ret = -1; 2421 + 2422 + irq = desc->irq; 2423 + cfg = desc->chip_data; 2424 + 2425 + spin_lock_irqsave(&ioapic_lock, flags); 2426 + dest = set_desc_affinity(desc, mask); 2427 + if (dest != BAD_APICID) { 2428 + /* Only the high 8 bits are valid. */ 2429 + dest = SET_APIC_LOGICAL_ID(dest); 2430 + __target_IO_APIC_irq(irq, dest, cfg); 2431 + ret = 0; 2432 + } 2433 + spin_unlock_irqrestore(&ioapic_lock, flags); 2434 + 2435 + return ret; 2436 + } 2437 + 2438 + static int 2439 + set_ioapic_affinity_irq(unsigned int irq, const struct cpumask *mask) 2440 + { 2441 + struct irq_desc *desc; 2442 + 2443 + desc = irq_to_desc(irq); 2444 + 2445 + return set_ioapic_affinity_irq_desc(desc, mask); 2446 + } 2204 2447 2205 2448 #ifdef CONFIG_INTR_REMAP 2206 2449 ··· 2459 2478 static inline void irq_complete_move(struct irq_desc **descp) {} 2460 2479 #endif 2461 2480 2462 - static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg) 2463 - { 2464 - int apic, pin; 2465 - struct irq_pin_list *entry; 2466 - 2467 - entry = cfg->irq_2_pin; 2468 - for (;;) { 2469 - 2470 - if (!entry) 2471 - break; 2472 - 2473 - apic = entry->apic; 2474 - pin = entry->pin; 2475 - io_apic_eoi(apic, pin); 2476 - entry = entry->next; 2477 - } 2478 - } 2479 - 2480 - static void 2481 - eoi_ioapic_irq(struct irq_desc *desc) 2482 - { 2483 - struct irq_cfg *cfg; 2484 - unsigned long flags; 2485 - unsigned int irq; 2486 - 2487 - irq = desc->irq; 2488 - cfg = desc->chip_data; 2489 - 2490 - spin_lock_irqsave(&ioapic_lock, flags); 2491 - __eoi_ioapic_irq(irq, cfg); 2492 - spin_unlock_irqrestore(&ioapic_lock, flags); 2493 - } 2494 - 2495 - #ifdef CONFIG_X86_X2APIC 2496 - static void ack_x2apic_level(unsigned int irq) 2497 - { 2498 - struct irq_desc *desc = irq_to_desc(irq); 2499 - ack_x2APIC_irq(); 2500 - eoi_ioapic_irq(desc); 2501 - } 2502 - 2503 - static void ack_x2apic_edge(unsigned int irq) 2504 - { 2505 - ack_x2APIC_irq(); 2506 - } 2507 - #endif 2508 - 2509 2481 static void ack_apic_edge(unsigned int irq) 2510 2482 { 2511 2483 struct irq_desc *desc = irq_to_desc(irq); ··· 2522 2588 */ 2523 2589 ack_APIC_irq(); 2524 2590 2525 - if (irq_remapped(irq)) 2526 - eoi_ioapic_irq(desc); 2527 - 2528 2591 /* Now we can move and renable the irq */ 2529 2592 if (unlikely(do_unmask_irq)) { 2530 2593 /* Only migrate the irq if the ack has been received. ··· 2568 2637 } 2569 2638 2570 2639 #ifdef CONFIG_INTR_REMAP 2640 + static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg) 2641 + { 2642 + int apic, pin; 2643 + struct irq_pin_list *entry; 2644 + 2645 + entry = cfg->irq_2_pin; 2646 + for (;;) { 2647 + 2648 + if (!entry) 2649 + break; 2650 + 2651 + apic = entry->apic; 2652 + pin = entry->pin; 2653 + io_apic_eoi(apic, pin); 2654 + entry = entry->next; 2655 + } 2656 + } 2657 + 2658 + static void 2659 + eoi_ioapic_irq(struct irq_desc *desc) 2660 + { 2661 + struct irq_cfg *cfg; 2662 + unsigned long flags; 2663 + unsigned int irq; 2664 + 2665 + irq = desc->irq; 2666 + cfg = desc->chip_data; 2667 + 2668 + spin_lock_irqsave(&ioapic_lock, flags); 2669 + __eoi_ioapic_irq(irq, cfg); 2670 + spin_unlock_irqrestore(&ioapic_lock, flags); 2671 + } 2672 + 2571 2673 static void ir_ack_apic_edge(unsigned int irq) 2572 2674 { 2573 - #ifdef CONFIG_X86_X2APIC 2574 - if (x2apic_enabled()) 2575 - return ack_x2apic_edge(irq); 2576 - #endif 2577 - return ack_apic_edge(irq); 2675 + ack_APIC_irq(); 2578 2676 } 2579 2677 2580 2678 static void ir_ack_apic_level(unsigned int irq) 2581 2679 { 2582 - #ifdef CONFIG_X86_X2APIC 2583 - if (x2apic_enabled()) 2584 - return ack_x2apic_level(irq); 2585 - #endif 2586 - return ack_apic_level(irq); 2680 + struct irq_desc *desc = irq_to_desc(irq); 2681 + 2682 + ack_APIC_irq(); 2683 + eoi_ioapic_irq(desc); 2587 2684 } 2588 2685 #endif /* CONFIG_INTR_REMAP */ 2589 2686
+1 -1
arch/x86/kernel/apic/probe_64.c
··· 50 50 void __init default_setup_apic_routing(void) 51 51 { 52 52 #ifdef CONFIG_X86_X2APIC 53 - if (x2apic && (apic != &apic_x2apic_phys && 53 + if (x2apic_mode && (apic != &apic_x2apic_phys && 54 54 #ifdef CONFIG_X86_UV 55 55 apic != &apic_x2apic_uv_x && 56 56 #endif
-7
arch/x86/kernel/apic/summit_32.c
··· 173 173 rio->type == LookOutAWPEG || rio->type == LookOutBWPEG); 174 174 } 175 175 176 - 177 - /* In clustered mode, the high nibble of APIC ID is a cluster number. 178 - * The low nibble is a 4-bit bitmap. */ 179 - #define XAPIC_DEST_CPUS_SHIFT 4 180 - #define XAPIC_DEST_CPUS_MASK ((1u << XAPIC_DEST_CPUS_SHIFT) - 1) 181 - #define XAPIC_DEST_CLUSTER_MASK (XAPIC_DEST_CPUS_MASK << XAPIC_DEST_CPUS_SHIFT) 182 - 183 176 #define SUMMIT_APIC_DFR_VALUE (APIC_DFR_CLUSTER) 184 177 185 178 static const struct cpumask *summit_target_cpus(void)
+1 -1
arch/x86/kernel/apic/x2apic_uv_x.c
··· 105 105 cpumask_set_cpu(cpu, retmask); 106 106 } 107 107 108 - static int uv_wakeup_secondary(int phys_apicid, unsigned long start_rip) 108 + static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_rip) 109 109 { 110 110 #ifdef CONFIG_SMP 111 111 unsigned long val;
+7 -12
arch/x86/kernel/irq.c
··· 24 24 */ 25 25 void ack_bad_irq(unsigned int irq) 26 26 { 27 - printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq); 27 + if (printk_ratelimit()) 28 + pr_err("unexpected IRQ trap at vector %02x\n", irq); 28 29 29 - #ifdef CONFIG_X86_LOCAL_APIC 30 30 /* 31 31 * Currently unexpected vectors happen only on SMP and APIC. 32 32 * We _must_ ack these because every local APIC has only N ··· 36 36 * completely. 37 37 * But only ack when the APIC is enabled -AK 38 38 */ 39 - if (cpu_has_apic) 40 - ack_APIC_irq(); 41 - #endif 39 + ack_APIC_irq(); 42 40 } 43 41 44 42 #define irq_stats(x) (&per_cpu(irq_stat, x)) ··· 176 178 sum += irq_stats(cpu)->irq_thermal_count; 177 179 # ifdef CONFIG_X86_64 178 180 sum += irq_stats(cpu)->irq_threshold_count; 179 - #endif 181 + # endif 180 182 #endif 181 183 return sum; 182 184 } ··· 211 213 irq = __get_cpu_var(vector_irq)[vector]; 212 214 213 215 if (!handle_irq(irq, regs)) { 214 - #ifdef CONFIG_X86_64 215 - if (!disable_apic) 216 - ack_APIC_irq(); 217 - #endif 216 + ack_APIC_irq(); 218 217 219 218 if (printk_ratelimit()) 220 - printk(KERN_EMERG "%s: %d.%d No irq handler for vector (irq %d)\n", 221 - __func__, smp_processor_id(), vector, irq); 219 + pr_emerg("%s: %d.%d No irq handler for vector (irq %d)\n", 220 + __func__, smp_processor_id(), vector, irq); 222 221 } 223 222 224 223 irq_exit();
+109 -40
arch/x86/kernel/irqinit_32.c arch/x86/kernel/irqinit.c
··· 1 + #include <linux/linkage.h> 1 2 #include <linux/errno.h> 2 3 #include <linux/signal.h> 3 4 #include <linux/sched.h> 4 5 #include <linux/ioport.h> 5 6 #include <linux/interrupt.h> 7 + #include <linux/timex.h> 6 8 #include <linux/slab.h> 7 9 #include <linux/random.h> 10 + #include <linux/kprobes.h> 8 11 #include <linux/init.h> 9 12 #include <linux/kernel_stat.h> 10 13 #include <linux/sysdev.h> 11 14 #include <linux/bitops.h> 15 + #include <linux/acpi.h> 12 16 #include <linux/io.h> 13 17 #include <linux/delay.h> 14 18 15 19 #include <asm/atomic.h> 16 20 #include <asm/system.h> 17 21 #include <asm/timer.h> 22 + #include <asm/hw_irq.h> 18 23 #include <asm/pgtable.h> 19 24 #include <asm/desc.h> 20 25 #include <asm/apic.h> ··· 27 22 #include <asm/i8259.h> 28 23 #include <asm/traps.h> 29 24 25 + /* 26 + * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts: 27 + * (these are usually mapped to vectors 0x30-0x3f) 28 + */ 30 29 30 + /* 31 + * The IO-APIC gives us many more interrupt sources. Most of these 32 + * are unused but an SMP system is supposed to have enough memory ... 33 + * sometimes (mostly wrt. hw bugs) we get corrupted vectors all 34 + * across the spectrum, so we really want to be prepared to get all 35 + * of these. Plus, more powerful systems might have more than 64 36 + * IO-APIC registers. 37 + * 38 + * (these are usually mapped into the 0x30-0xff vector range) 39 + */ 40 + 41 + #ifdef CONFIG_X86_32 31 42 /* 32 43 * Note that on a 486, we don't want to do a SIGFPE on an irq13 33 44 * as the irq is unreliable, and exception 16 works correctly ··· 73 52 .handler = math_error_irq, 74 53 .name = "fpu", 75 54 }; 76 - 77 - void __init init_ISA_irqs(void) 78 - { 79 - int i; 80 - 81 - #ifdef CONFIG_X86_LOCAL_APIC 82 - init_bsp_APIC(); 83 55 #endif 84 - init_8259A(0); 85 - 86 - /* 87 - * 16 old-style INTA-cycle interrupts: 88 - */ 89 - for (i = 0; i < NR_IRQS_LEGACY; i++) { 90 - struct irq_desc *desc = irq_to_desc(i); 91 - 92 - desc->status = IRQ_DISABLED; 93 - desc->action = NULL; 94 - desc->depth = 1; 95 - 96 - set_irq_chip_and_handler_name(i, &i8259A_chip, 97 - handle_level_irq, "XT"); 98 - } 99 - } 100 56 101 57 /* 102 58 * IRQ2 is cascade interrupt to second interrupt controller ··· 116 118 return 0; 117 119 } 118 120 119 - /* Overridden in paravirt.c */ 120 - void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ"))); 121 - 122 - void __init native_init_IRQ(void) 121 + static void __init init_ISA_irqs(void) 123 122 { 124 123 int i; 125 124 126 - /* Execute any quirks before the call gates are initialised: */ 127 - x86_quirk_pre_intr_init(); 125 + #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC) 126 + init_bsp_APIC(); 127 + #endif 128 + init_8259A(0); 128 129 129 130 /* 130 - * Cover the whole vector space, no vector can escape 131 - * us. (some of these will be overridden and become 132 - * 'special' SMP interrupts) 131 + * 16 old-style INTA-cycle interrupts: 133 132 */ 134 - for (i = FIRST_EXTERNAL_VECTOR; i < NR_VECTORS; i++) { 135 - /* SYSCALL_VECTOR was reserved in trap_init. */ 136 - if (i != SYSCALL_VECTOR) 137 - set_intr_gate(i, interrupt[i-FIRST_EXTERNAL_VECTOR]); 133 + for (i = 0; i < NR_IRQS_LEGACY; i++) { 134 + struct irq_desc *desc = irq_to_desc(i); 135 + 136 + desc->status = IRQ_DISABLED; 137 + desc->action = NULL; 138 + desc->depth = 1; 139 + 140 + set_irq_chip_and_handler_name(i, &i8259A_chip, 141 + handle_level_irq, "XT"); 138 142 } 143 + } 139 144 145 + /* Overridden in paravirt.c */ 146 + void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ"))); 140 147 141 - #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_SMP) 148 + static void __init smp_intr_init(void) 149 + { 150 + #ifdef CONFIG_SMP 151 + #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC) 142 152 /* 143 153 * The reschedule interrupt is a CPU-to-CPU reschedule-helper 144 154 * IPI, driven by wakeup. ··· 166 160 /* IPI for generic function call */ 167 161 alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt); 168 162 169 - /* IPI for single call function */ 163 + /* IPI for generic single function call */ 170 164 alloc_intr_gate(CALL_FUNCTION_SINGLE_VECTOR, 171 - call_function_single_interrupt); 165 + call_function_single_interrupt); 172 166 173 167 /* Low priority IPI to cleanup after moving an irq */ 174 168 set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt); 175 169 set_bit(IRQ_MOVE_CLEANUP_VECTOR, used_vectors); 176 170 #endif 171 + #endif /* CONFIG_SMP */ 172 + } 177 173 178 - #ifdef CONFIG_X86_LOCAL_APIC 174 + static void __init apic_intr_init(void) 175 + { 176 + smp_intr_init(); 177 + 178 + #ifdef CONFIG_X86_64 179 + alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt); 180 + alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt); 181 + #endif 182 + 183 + #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC) 179 184 /* self generated IPI for local APIC timer */ 180 185 alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt); 181 186 ··· 196 179 /* IPI vectors for APIC spurious and error interrupts */ 197 180 alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt); 198 181 alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt); 182 + 183 + /* Performance monitoring interrupts: */ 184 + # ifdef CONFIG_PERF_COUNTERS 185 + alloc_intr_gate(LOCAL_PERF_VECTOR, perf_counter_interrupt); 186 + alloc_intr_gate(LOCAL_PENDING_VECTOR, perf_pending_interrupt); 187 + # endif 188 + 199 189 #endif 200 190 191 + #ifdef CONFIG_X86_32 201 192 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_MCE_P4THERMAL) 202 193 /* thermal monitor LVT interrupt */ 203 194 alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt); 204 195 #endif 196 + #endif 197 + } 198 + 199 + /** 200 + * x86_quirk_pre_intr_init - initialisation prior to setting up interrupt vectors 201 + * 202 + * Description: 203 + * Perform any necessary interrupt initialisation prior to setting up 204 + * the "ordinary" interrupt call gates. For legacy reasons, the ISA 205 + * interrupts should be initialised here if the machine emulates a PC 206 + * in any way. 207 + **/ 208 + static void __init x86_quirk_pre_intr_init(void) 209 + { 210 + #ifdef CONFIG_X86_32 211 + if (x86_quirks->arch_pre_intr_init) { 212 + if (x86_quirks->arch_pre_intr_init()) 213 + return; 214 + } 215 + #endif 216 + init_ISA_irqs(); 217 + } 218 + 219 + void __init native_init_IRQ(void) 220 + { 221 + int i; 222 + 223 + /* Execute any quirks before the call gates are initialised: */ 224 + x86_quirk_pre_intr_init(); 225 + 226 + apic_intr_init(); 227 + 228 + /* 229 + * Cover the whole vector space, no vector can escape 230 + * us. (some of these will be overridden and become 231 + * 'special' SMP interrupts) 232 + */ 233 + for (i = FIRST_EXTERNAL_VECTOR; i < NR_VECTORS; i++) { 234 + /* IA32_SYSCALL_VECTOR could be used in trap_init already. */ 235 + if (!test_bit(i, used_vectors)) 236 + set_intr_gate(i, interrupt[i-FIRST_EXTERNAL_VECTOR]); 237 + } 205 238 206 239 if (!acpi_ioapic) 207 240 setup_irq(2, &irq2); 208 241 242 + #ifdef CONFIG_X86_32 209 243 /* 210 244 * Call quirks after call gates are initialised (usually add in 211 245 * the architecture specific gates): ··· 271 203 setup_irq(FPU_IRQ, &fpu_irq); 272 204 273 205 irq_ctx_init(smp_processor_id()); 206 + #endif 274 207 }
-177
arch/x86/kernel/irqinit_64.c
··· 1 - #include <linux/linkage.h> 2 - #include <linux/errno.h> 3 - #include <linux/signal.h> 4 - #include <linux/sched.h> 5 - #include <linux/ioport.h> 6 - #include <linux/interrupt.h> 7 - #include <linux/timex.h> 8 - #include <linux/slab.h> 9 - #include <linux/random.h> 10 - #include <linux/init.h> 11 - #include <linux/kernel_stat.h> 12 - #include <linux/sysdev.h> 13 - #include <linux/bitops.h> 14 - #include <linux/acpi.h> 15 - #include <linux/io.h> 16 - #include <linux/delay.h> 17 - 18 - #include <asm/atomic.h> 19 - #include <asm/system.h> 20 - #include <asm/hw_irq.h> 21 - #include <asm/pgtable.h> 22 - #include <asm/desc.h> 23 - #include <asm/apic.h> 24 - #include <asm/i8259.h> 25 - 26 - /* 27 - * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts: 28 - * (these are usually mapped to vectors 0x30-0x3f) 29 - */ 30 - 31 - /* 32 - * The IO-APIC gives us many more interrupt sources. Most of these 33 - * are unused but an SMP system is supposed to have enough memory ... 34 - * sometimes (mostly wrt. hw bugs) we get corrupted vectors all 35 - * across the spectrum, so we really want to be prepared to get all 36 - * of these. Plus, more powerful systems might have more than 64 37 - * IO-APIC registers. 38 - * 39 - * (these are usually mapped into the 0x30-0xff vector range) 40 - */ 41 - 42 - /* 43 - * IRQ2 is cascade interrupt to second interrupt controller 44 - */ 45 - 46 - static struct irqaction irq2 = { 47 - .handler = no_action, 48 - .name = "cascade", 49 - }; 50 - DEFINE_PER_CPU(vector_irq_t, vector_irq) = { 51 - [0 ... IRQ0_VECTOR - 1] = -1, 52 - [IRQ0_VECTOR] = 0, 53 - [IRQ1_VECTOR] = 1, 54 - [IRQ2_VECTOR] = 2, 55 - [IRQ3_VECTOR] = 3, 56 - [IRQ4_VECTOR] = 4, 57 - [IRQ5_VECTOR] = 5, 58 - [IRQ6_VECTOR] = 6, 59 - [IRQ7_VECTOR] = 7, 60 - [IRQ8_VECTOR] = 8, 61 - [IRQ9_VECTOR] = 9, 62 - [IRQ10_VECTOR] = 10, 63 - [IRQ11_VECTOR] = 11, 64 - [IRQ12_VECTOR] = 12, 65 - [IRQ13_VECTOR] = 13, 66 - [IRQ14_VECTOR] = 14, 67 - [IRQ15_VECTOR] = 15, 68 - [IRQ15_VECTOR + 1 ... NR_VECTORS - 1] = -1 69 - }; 70 - 71 - int vector_used_by_percpu_irq(unsigned int vector) 72 - { 73 - int cpu; 74 - 75 - for_each_online_cpu(cpu) { 76 - if (per_cpu(vector_irq, cpu)[vector] != -1) 77 - return 1; 78 - } 79 - 80 - return 0; 81 - } 82 - 83 - static void __init init_ISA_irqs(void) 84 - { 85 - int i; 86 - 87 - init_bsp_APIC(); 88 - init_8259A(0); 89 - 90 - for (i = 0; i < NR_IRQS_LEGACY; i++) { 91 - struct irq_desc *desc = irq_to_desc(i); 92 - 93 - desc->status = IRQ_DISABLED; 94 - desc->action = NULL; 95 - desc->depth = 1; 96 - 97 - /* 98 - * 16 old-style INTA-cycle interrupts: 99 - */ 100 - set_irq_chip_and_handler_name(i, &i8259A_chip, 101 - handle_level_irq, "XT"); 102 - } 103 - } 104 - 105 - void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ"))); 106 - 107 - static void __init smp_intr_init(void) 108 - { 109 - #ifdef CONFIG_SMP 110 - /* 111 - * The reschedule interrupt is a CPU-to-CPU reschedule-helper 112 - * IPI, driven by wakeup. 113 - */ 114 - alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt); 115 - 116 - /* IPIs for invalidation */ 117 - alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+0, invalidate_interrupt0); 118 - alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+1, invalidate_interrupt1); 119 - alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+2, invalidate_interrupt2); 120 - alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+3, invalidate_interrupt3); 121 - alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+4, invalidate_interrupt4); 122 - alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+5, invalidate_interrupt5); 123 - alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+6, invalidate_interrupt6); 124 - alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+7, invalidate_interrupt7); 125 - 126 - /* IPI for generic function call */ 127 - alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt); 128 - 129 - /* IPI for generic single function call */ 130 - alloc_intr_gate(CALL_FUNCTION_SINGLE_VECTOR, 131 - call_function_single_interrupt); 132 - 133 - /* Low priority IPI to cleanup after moving an irq */ 134 - set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt); 135 - set_bit(IRQ_MOVE_CLEANUP_VECTOR, used_vectors); 136 - #endif 137 - } 138 - 139 - static void __init apic_intr_init(void) 140 - { 141 - smp_intr_init(); 142 - 143 - alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt); 144 - alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt); 145 - 146 - /* self generated IPI for local APIC timer */ 147 - alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt); 148 - 149 - /* generic IPI for platform specific use */ 150 - alloc_intr_gate(GENERIC_INTERRUPT_VECTOR, generic_interrupt); 151 - 152 - /* IPI vectors for APIC spurious and error interrupts */ 153 - alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt); 154 - alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt); 155 - } 156 - 157 - void __init native_init_IRQ(void) 158 - { 159 - int i; 160 - 161 - init_ISA_irqs(); 162 - /* 163 - * Cover the whole vector space, no vector can escape 164 - * us. (some of these will be overridden and become 165 - * 'special' SMP interrupts) 166 - */ 167 - for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) { 168 - int vector = FIRST_EXTERNAL_VECTOR + i; 169 - if (vector != IA32_SYSCALL_VECTOR) 170 - set_intr_gate(vector, interrupt[i]); 171 - } 172 - 173 - apic_intr_init(); 174 - 175 - if (!acpi_ioapic) 176 - setup_irq(2, &irq2); 177 - }
-18
arch/x86/kernel/setup.c
··· 997 997 #ifdef CONFIG_X86_32 998 998 999 999 /** 1000 - * x86_quirk_pre_intr_init - initialisation prior to setting up interrupt vectors 1001 - * 1002 - * Description: 1003 - * Perform any necessary interrupt initialisation prior to setting up 1004 - * the "ordinary" interrupt call gates. For legacy reasons, the ISA 1005 - * interrupts should be initialised here if the machine emulates a PC 1006 - * in any way. 1007 - **/ 1008 - void __init x86_quirk_pre_intr_init(void) 1009 - { 1010 - if (x86_quirks->arch_pre_intr_init) { 1011 - if (x86_quirks->arch_pre_intr_init()) 1012 - return; 1013 - } 1014 - init_ISA_irqs(); 1015 - } 1016 - 1017 - /** 1018 1000 * x86_quirk_intr_init - post gate setup interrupt initialisation 1019 1001 * 1020 1002 * Description:
+10 -10
arch/x86/kernel/smp.c
··· 193 193 } 194 194 195 195 struct smp_ops smp_ops = { 196 - .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu, 197 - .smp_prepare_cpus = native_smp_prepare_cpus, 198 - .smp_cpus_done = native_smp_cpus_done, 196 + .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu, 197 + .smp_prepare_cpus = native_smp_prepare_cpus, 198 + .smp_cpus_done = native_smp_cpus_done, 199 199 200 - .smp_send_stop = native_smp_send_stop, 201 - .smp_send_reschedule = native_smp_send_reschedule, 200 + .smp_send_stop = native_smp_send_stop, 201 + .smp_send_reschedule = native_smp_send_reschedule, 202 202 203 - .cpu_up = native_cpu_up, 204 - .cpu_die = native_cpu_die, 205 - .cpu_disable = native_cpu_disable, 206 - .play_dead = native_play_dead, 203 + .cpu_up = native_cpu_up, 204 + .cpu_die = native_cpu_die, 205 + .cpu_disable = native_cpu_disable, 206 + .play_dead = native_play_dead, 207 207 208 - .send_call_func_ipi = native_send_call_func_ipi, 208 + .send_call_func_ipi = native_send_call_func_ipi, 209 209 .send_call_func_single_ipi = native_send_call_func_single_ipi, 210 210 }; 211 211 EXPORT_SYMBOL_GPL(smp_ops);
+8 -6
arch/x86/kernel/smpboot.c
··· 504 504 * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this 505 505 * won't ... remember to clear down the APIC, etc later. 506 506 */ 507 - int __devinit 507 + int __cpuinit 508 508 wakeup_secondary_cpu_via_nmi(int logical_apicid, unsigned long start_eip) 509 509 { 510 510 unsigned long send_status, accept_status = 0; ··· 538 538 return (send_status | accept_status); 539 539 } 540 540 541 - int __devinit 541 + static int __cpuinit 542 542 wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) 543 543 { 544 544 unsigned long send_status, accept_status = 0; ··· 822 822 /* mark "stuck" area as not stuck */ 823 823 *((volatile unsigned long *)trampoline_base) = 0; 824 824 825 - /* 826 - * Cleanup possible dangling ends... 827 - */ 828 - smpboot_restore_warm_reset_vector(); 825 + if (get_uv_system_type() != UV_NON_UNIQUE_APIC) { 826 + /* 827 + * Cleanup possible dangling ends... 828 + */ 829 + smpboot_restore_warm_reset_vector(); 830 + } 829 831 830 832 return boot_error; 831 833 }
+1 -4
arch/x86/kernel/traps.c
··· 969 969 for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++) 970 970 set_bit(i, used_vectors); 971 971 972 - #ifdef CONFIG_X86_64 973 972 set_bit(IA32_SYSCALL_VECTOR, used_vectors); 974 - #else 975 - set_bit(SYSCALL_VECTOR, used_vectors); 976 - #endif 973 + 977 974 /* 978 975 * Should be a barrier for any external CPU state: 979 976 */
-9
drivers/pci/intel-iommu.c
··· 1968 1968 } 1969 1969 } 1970 1970 1971 - #ifdef CONFIG_INTR_REMAP 1972 - if (!intr_remapping_enabled) { 1973 - ret = enable_intr_remapping(0); 1974 - if (ret) 1975 - printk(KERN_ERR 1976 - "IOMMU: enable interrupt remapping failed\n"); 1977 - } 1978 - #endif 1979 - 1980 1971 /* 1981 1972 * For each rmrr 1982 1973 * for each dev attached to rmrr
+25 -14
drivers/pci/intr_remapping.c
··· 15 15 static int ir_ioapic_num; 16 16 int intr_remapping_enabled; 17 17 18 + static int disable_intremap; 19 + static __init int setup_nointremap(char *str) 20 + { 21 + disable_intremap = 1; 22 + return 0; 23 + } 24 + early_param("nointremap", setup_nointremap); 25 + 18 26 struct irq_2_iommu { 19 27 struct intel_iommu *iommu; 20 28 u16 irte_index; ··· 428 420 readl, (sts & DMA_GSTS_IRTPS), sts); 429 421 spin_unlock_irqrestore(&iommu->register_lock, flags); 430 422 431 - if (mode == 0) { 432 - spin_lock_irqsave(&iommu->register_lock, flags); 433 - 434 - /* enable comaptiblity format interrupt pass through */ 435 - cmd = iommu->gcmd | DMA_GCMD_CFI; 436 - iommu->gcmd |= DMA_GCMD_CFI; 437 - writel(cmd, iommu->reg + DMAR_GCMD_REG); 438 - 439 - IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, 440 - readl, (sts & DMA_GSTS_CFIS), sts); 441 - 442 - spin_unlock_irqrestore(&iommu->register_lock, flags); 443 - } 444 - 445 423 /* 446 424 * global invalidation of interrupt entry cache before enabling 447 425 * interrupt-remapping. ··· 505 511 506 512 end: 507 513 spin_unlock_irqrestore(&iommu->register_lock, flags); 514 + } 515 + 516 + int __init intr_remapping_supported(void) 517 + { 518 + struct dmar_drhd_unit *drhd; 519 + 520 + if (disable_intremap) 521 + return 0; 522 + 523 + for_each_drhd_unit(drhd) { 524 + struct intel_iommu *iommu = drhd->iommu; 525 + 526 + if (!ecap_ir_support(iommu->ecap)) 527 + return 0; 528 + } 529 + 530 + return 1; 508 531 } 509 532 510 533 int __init enable_intr_remapping(int eim)
+3
include/linux/dmar.h
··· 108 108 }; 109 109 #ifdef CONFIG_INTR_REMAP 110 110 extern int intr_remapping_enabled; 111 + extern int intr_remapping_supported(void); 111 112 extern int enable_intr_remapping(int); 112 113 extern void disable_intr_remapping(void); 113 114 extern int reenable_intr_remapping(int); ··· 158 157 } 159 158 #define irq_remapped(irq) (0) 160 159 #define enable_intr_remapping(mode) (-1) 160 + #define disable_intr_remapping() (0) 161 + #define reenable_intr_remapping(mode) (0) 161 162 #define intr_remapping_enabled (0) 162 163 #endif 163 164