diff options
Diffstat (limited to 'arch/x86/kernel/apic')
-rw-r--r-- | arch/x86/kernel/apic/apic.c | 97 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic_flat_64.c | 18 | ||||
-rw-r--r-- | arch/x86/kernel/apic/bigsmp_32.c | 16 | ||||
-rw-r--r-- | arch/x86/kernel/apic/es7000_32.c | 17 | ||||
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 412 | ||||
-rw-r--r-- | arch/x86/kernel/apic/nmi.c | 11 | ||||
-rw-r--r-- | arch/x86/kernel/apic/numaq_32.c | 11 | ||||
-rw-r--r-- | arch/x86/kernel/apic/probe_32.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/apic/probe_64.c | 7 | ||||
-rw-r--r-- | arch/x86/kernel/apic/summit_32.c | 21 | ||||
-rw-r--r-- | arch/x86/kernel/apic/x2apic_cluster.c | 6 | ||||
-rw-r--r-- | arch/x86/kernel/apic/x2apic_phys.c | 6 | ||||
-rw-r--r-- | arch/x86/kernel/apic/x2apic_uv_x.c | 9 |
13 files changed, 372 insertions, 262 deletions
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index f9cecdfd05c5..098ec84b8c00 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <asm/idle.h> | 46 | #include <asm/idle.h> |
47 | #include <asm/mtrr.h> | 47 | #include <asm/mtrr.h> |
48 | #include <asm/smp.h> | 48 | #include <asm/smp.h> |
49 | #include <asm/mce.h> | ||
49 | 50 | ||
50 | unsigned int num_processors; | 51 | unsigned int num_processors; |
51 | 52 | ||
@@ -808,7 +809,7 @@ void clear_local_APIC(void) | |||
808 | u32 v; | 809 | u32 v; |
809 | 810 | ||
810 | /* APIC hasn't been mapped yet */ | 811 | /* APIC hasn't been mapped yet */ |
811 | if (!apic_phys) | 812 | if (!x2apic && !apic_phys) |
812 | return; | 813 | return; |
813 | 814 | ||
814 | maxlvt = lapic_get_maxlvt(); | 815 | maxlvt = lapic_get_maxlvt(); |
@@ -842,6 +843,14 @@ void clear_local_APIC(void) | |||
842 | apic_write(APIC_LVTTHMR, v | APIC_LVT_MASKED); | 843 | apic_write(APIC_LVTTHMR, v | APIC_LVT_MASKED); |
843 | } | 844 | } |
844 | #endif | 845 | #endif |
846 | #ifdef CONFIG_X86_MCE_INTEL | ||
847 | if (maxlvt >= 6) { | ||
848 | v = apic_read(APIC_LVTCMCI); | ||
849 | if (!(v & APIC_LVT_MASKED)) | ||
850 | apic_write(APIC_LVTCMCI, v | APIC_LVT_MASKED); | ||
851 | } | ||
852 | #endif | ||
853 | |||
845 | /* | 854 | /* |
846 | * Clean APIC state for other OSs: | 855 | * Clean APIC state for other OSs: |
847 | */ | 856 | */ |
@@ -1241,6 +1250,12 @@ void __cpuinit setup_local_APIC(void) | |||
1241 | apic_write(APIC_LVT1, value); | 1250 | apic_write(APIC_LVT1, value); |
1242 | 1251 | ||
1243 | preempt_enable(); | 1252 | preempt_enable(); |
1253 | |||
1254 | #ifdef CONFIG_X86_MCE_INTEL | ||
1255 | /* Recheck CMCI information after local APIC is up on CPU #0 */ | ||
1256 | if (smp_processor_id() == 0) | ||
1257 | cmci_recheck(); | ||
1258 | #endif | ||
1244 | } | 1259 | } |
1245 | 1260 | ||
1246 | void __cpuinit end_local_APIC_setup(void) | 1261 | void __cpuinit end_local_APIC_setup(void) |
@@ -1289,6 +1304,7 @@ void __init enable_IR_x2apic(void) | |||
1289 | #ifdef CONFIG_INTR_REMAP | 1304 | #ifdef CONFIG_INTR_REMAP |
1290 | int ret; | 1305 | int ret; |
1291 | unsigned long flags; | 1306 | unsigned long flags; |
1307 | struct IO_APIC_route_entry **ioapic_entries = NULL; | ||
1292 | 1308 | ||
1293 | if (!cpu_has_x2apic) | 1309 | if (!cpu_has_x2apic) |
1294 | return; | 1310 | return; |
@@ -1319,16 +1335,23 @@ void __init enable_IR_x2apic(void) | |||
1319 | return; | 1335 | return; |
1320 | } | 1336 | } |
1321 | 1337 | ||
1322 | local_irq_save(flags); | 1338 | ioapic_entries = alloc_ioapic_entries(); |
1323 | mask_8259A(); | 1339 | if (!ioapic_entries) { |
1340 | pr_info("Allocate ioapic_entries failed: %d\n", ret); | ||
1341 | goto end; | ||
1342 | } | ||
1324 | 1343 | ||
1325 | ret = save_mask_IO_APIC_setup(); | 1344 | ret = save_IO_APIC_setup(ioapic_entries); |
1326 | if (ret) { | 1345 | if (ret) { |
1327 | pr_info("Saving IO-APIC state failed: %d\n", ret); | 1346 | pr_info("Saving IO-APIC state failed: %d\n", ret); |
1328 | goto end; | 1347 | goto end; |
1329 | } | 1348 | } |
1330 | 1349 | ||
1331 | ret = enable_intr_remapping(1); | 1350 | local_irq_save(flags); |
1351 | mask_IO_APIC_setup(ioapic_entries); | ||
1352 | mask_8259A(); | ||
1353 | |||
1354 | ret = enable_intr_remapping(EIM_32BIT_APIC_ID); | ||
1332 | 1355 | ||
1333 | if (ret && x2apic_preenabled) { | 1356 | if (ret && x2apic_preenabled) { |
1334 | local_irq_restore(flags); | 1357 | local_irq_restore(flags); |
@@ -1348,14 +1371,14 @@ end_restore: | |||
1348 | /* | 1371 | /* |
1349 | * IR enabling failed | 1372 | * IR enabling failed |
1350 | */ | 1373 | */ |
1351 | restore_IO_APIC_setup(); | 1374 | restore_IO_APIC_setup(ioapic_entries); |
1352 | else | 1375 | else |
1353 | reinit_intr_remapped_IO_APIC(x2apic_preenabled); | 1376 | reinit_intr_remapped_IO_APIC(x2apic_preenabled, ioapic_entries); |
1354 | 1377 | ||
1355 | end: | ||
1356 | unmask_8259A(); | 1378 | unmask_8259A(); |
1357 | local_irq_restore(flags); | 1379 | local_irq_restore(flags); |
1358 | 1380 | ||
1381 | end: | ||
1359 | if (!ret) { | 1382 | if (!ret) { |
1360 | if (!x2apic_preenabled) | 1383 | if (!x2apic_preenabled) |
1361 | pr_info("Enabled x2apic and interrupt-remapping\n"); | 1384 | pr_info("Enabled x2apic and interrupt-remapping\n"); |
@@ -1363,6 +1386,8 @@ end: | |||
1363 | pr_info("Enabled Interrupt-remapping\n"); | 1386 | pr_info("Enabled Interrupt-remapping\n"); |
1364 | } else | 1387 | } else |
1365 | pr_err("Failed to enable Interrupt-remapping and x2apic\n"); | 1388 | pr_err("Failed to enable Interrupt-remapping and x2apic\n"); |
1389 | if (ioapic_entries) | ||
1390 | free_ioapic_entries(ioapic_entries); | ||
1366 | #else | 1391 | #else |
1367 | if (!cpu_has_x2apic) | 1392 | if (!cpu_has_x2apic) |
1368 | return; | 1393 | return; |
@@ -1508,12 +1533,10 @@ void __init early_init_lapic_mapping(void) | |||
1508 | */ | 1533 | */ |
1509 | void __init init_apic_mappings(void) | 1534 | void __init init_apic_mappings(void) |
1510 | { | 1535 | { |
1511 | #ifdef CONFIG_X86_X2APIC | ||
1512 | if (x2apic) { | 1536 | if (x2apic) { |
1513 | boot_cpu_physical_apicid = read_apic_id(); | 1537 | boot_cpu_physical_apicid = read_apic_id(); |
1514 | return; | 1538 | return; |
1515 | } | 1539 | } |
1516 | #endif | ||
1517 | 1540 | ||
1518 | /* | 1541 | /* |
1519 | * If no local APIC can be found then set up a fake all | 1542 | * If no local APIC can be found then set up a fake all |
@@ -1940,6 +1963,10 @@ static int lapic_suspend(struct sys_device *dev, pm_message_t state) | |||
1940 | 1963 | ||
1941 | local_irq_save(flags); | 1964 | local_irq_save(flags); |
1942 | disable_local_APIC(); | 1965 | disable_local_APIC(); |
1966 | #ifdef CONFIG_INTR_REMAP | ||
1967 | if (intr_remapping_enabled) | ||
1968 | disable_intr_remapping(); | ||
1969 | #endif | ||
1943 | local_irq_restore(flags); | 1970 | local_irq_restore(flags); |
1944 | return 0; | 1971 | return 0; |
1945 | } | 1972 | } |
@@ -1950,19 +1977,42 @@ static int lapic_resume(struct sys_device *dev) | |||
1950 | unsigned long flags; | 1977 | unsigned long flags; |
1951 | int maxlvt; | 1978 | int maxlvt; |
1952 | 1979 | ||
1980 | #ifdef CONFIG_INTR_REMAP | ||
1981 | int ret; | ||
1982 | struct IO_APIC_route_entry **ioapic_entries = NULL; | ||
1983 | |||
1953 | if (!apic_pm_state.active) | 1984 | if (!apic_pm_state.active) |
1954 | return 0; | 1985 | return 0; |
1955 | 1986 | ||
1956 | maxlvt = lapic_get_maxlvt(); | ||
1957 | |||
1958 | local_irq_save(flags); | 1987 | local_irq_save(flags); |
1988 | if (x2apic) { | ||
1989 | ioapic_entries = alloc_ioapic_entries(); | ||
1990 | if (!ioapic_entries) { | ||
1991 | WARN(1, "Alloc ioapic_entries in lapic resume failed."); | ||
1992 | return -ENOMEM; | ||
1993 | } | ||
1959 | 1994 | ||
1960 | #ifdef CONFIG_X86_X2APIC | 1995 | ret = save_IO_APIC_setup(ioapic_entries); |
1996 | if (ret) { | ||
1997 | WARN(1, "Saving IO-APIC state failed: %d\n", ret); | ||
1998 | free_ioapic_entries(ioapic_entries); | ||
1999 | return ret; | ||
2000 | } | ||
2001 | |||
2002 | mask_IO_APIC_setup(ioapic_entries); | ||
2003 | mask_8259A(); | ||
2004 | enable_x2apic(); | ||
2005 | } | ||
2006 | #else | ||
2007 | if (!apic_pm_state.active) | ||
2008 | return 0; | ||
2009 | |||
2010 | local_irq_save(flags); | ||
1961 | if (x2apic) | 2011 | if (x2apic) |
1962 | enable_x2apic(); | 2012 | enable_x2apic(); |
1963 | else | ||
1964 | #endif | 2013 | #endif |
1965 | { | 2014 | |
2015 | else { | ||
1966 | /* | 2016 | /* |
1967 | * Make sure the APICBASE points to the right address | 2017 | * Make sure the APICBASE points to the right address |
1968 | * | 2018 | * |
@@ -1975,6 +2025,7 @@ static int lapic_resume(struct sys_device *dev) | |||
1975 | wrmsr(MSR_IA32_APICBASE, l, h); | 2025 | wrmsr(MSR_IA32_APICBASE, l, h); |
1976 | } | 2026 | } |
1977 | 2027 | ||
2028 | maxlvt = lapic_get_maxlvt(); | ||
1978 | apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED); | 2029 | apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED); |
1979 | apic_write(APIC_ID, apic_pm_state.apic_id); | 2030 | apic_write(APIC_ID, apic_pm_state.apic_id); |
1980 | apic_write(APIC_DFR, apic_pm_state.apic_dfr); | 2031 | apic_write(APIC_DFR, apic_pm_state.apic_dfr); |
@@ -1998,8 +2049,20 @@ static int lapic_resume(struct sys_device *dev) | |||
1998 | apic_write(APIC_ESR, 0); | 2049 | apic_write(APIC_ESR, 0); |
1999 | apic_read(APIC_ESR); | 2050 | apic_read(APIC_ESR); |
2000 | 2051 | ||
2052 | #ifdef CONFIG_INTR_REMAP | ||
2053 | if (intr_remapping_enabled) | ||
2054 | reenable_intr_remapping(EIM_32BIT_APIC_ID); | ||
2055 | |||
2056 | if (x2apic) { | ||
2057 | unmask_8259A(); | ||
2058 | restore_IO_APIC_setup(ioapic_entries); | ||
2059 | free_ioapic_entries(ioapic_entries); | ||
2060 | } | ||
2061 | #endif | ||
2062 | |||
2001 | local_irq_restore(flags); | 2063 | local_irq_restore(flags); |
2002 | 2064 | ||
2065 | |||
2003 | return 0; | 2066 | return 0; |
2004 | } | 2067 | } |
2005 | 2068 | ||
@@ -2037,7 +2100,9 @@ static int __init init_lapic_sysfs(void) | |||
2037 | error = sysdev_register(&device_lapic); | 2100 | error = sysdev_register(&device_lapic); |
2038 | return error; | 2101 | return error; |
2039 | } | 2102 | } |
2040 | device_initcall(init_lapic_sysfs); | 2103 | |
2104 | /* local apic needs to resume before other devices access its registers. */ | ||
2105 | core_initcall(init_lapic_sysfs); | ||
2041 | 2106 | ||
2042 | #else /* CONFIG_PM */ | 2107 | #else /* CONFIG_PM */ |
2043 | 2108 | ||
diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c index f933822dba18..0014714ea97b 100644 --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c | |||
@@ -159,20 +159,6 @@ static int flat_apic_id_registered(void) | |||
159 | return physid_isset(read_xapic_id(), phys_cpu_present_map); | 159 | return physid_isset(read_xapic_id(), phys_cpu_present_map); |
160 | } | 160 | } |
161 | 161 | ||
162 | static unsigned int flat_cpu_mask_to_apicid(const struct cpumask *cpumask) | ||
163 | { | ||
164 | return cpumask_bits(cpumask)[0] & APIC_ALL_CPUS; | ||
165 | } | ||
166 | |||
167 | static unsigned int flat_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | ||
168 | const struct cpumask *andmask) | ||
169 | { | ||
170 | unsigned long mask1 = cpumask_bits(cpumask)[0] & APIC_ALL_CPUS; | ||
171 | unsigned long mask2 = cpumask_bits(andmask)[0] & APIC_ALL_CPUS; | ||
172 | |||
173 | return mask1 & mask2; | ||
174 | } | ||
175 | |||
176 | static int flat_phys_pkg_id(int initial_apic_id, int index_msb) | 162 | static int flat_phys_pkg_id(int initial_apic_id, int index_msb) |
177 | { | 163 | { |
178 | return hard_smp_processor_id() >> index_msb; | 164 | return hard_smp_processor_id() >> index_msb; |
@@ -213,8 +199,8 @@ struct apic apic_flat = { | |||
213 | .set_apic_id = set_apic_id, | 199 | .set_apic_id = set_apic_id, |
214 | .apic_id_mask = 0xFFu << 24, | 200 | .apic_id_mask = 0xFFu << 24, |
215 | 201 | ||
216 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, | 202 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, |
217 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, | 203 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
218 | 204 | ||
219 | .send_IPI_mask = flat_send_IPI_mask, | 205 | .send_IPI_mask = flat_send_IPI_mask, |
220 | .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself, | 206 | .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself, |
diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c index d806ecaa948f..676cdac385c0 100644 --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c | |||
@@ -26,12 +26,12 @@ static int bigsmp_apic_id_registered(void) | |||
26 | return 1; | 26 | return 1; |
27 | } | 27 | } |
28 | 28 | ||
29 | static const cpumask_t *bigsmp_target_cpus(void) | 29 | static const struct cpumask *bigsmp_target_cpus(void) |
30 | { | 30 | { |
31 | #ifdef CONFIG_SMP | 31 | #ifdef CONFIG_SMP |
32 | return &cpu_online_map; | 32 | return cpu_online_mask; |
33 | #else | 33 | #else |
34 | return &cpumask_of_cpu(0); | 34 | return cpumask_of(0); |
35 | #endif | 35 | #endif |
36 | } | 36 | } |
37 | 37 | ||
@@ -118,9 +118,9 @@ static int bigsmp_check_phys_apicid_present(int boot_cpu_physical_apicid) | |||
118 | } | 118 | } |
119 | 119 | ||
120 | /* As we are using single CPU as destination, pick only one CPU here */ | 120 | /* As we are using single CPU as destination, pick only one CPU here */ |
121 | static unsigned int bigsmp_cpu_mask_to_apicid(const cpumask_t *cpumask) | 121 | static unsigned int bigsmp_cpu_mask_to_apicid(const struct cpumask *cpumask) |
122 | { | 122 | { |
123 | return bigsmp_cpu_to_logical_apicid(first_cpu(*cpumask)); | 123 | return bigsmp_cpu_to_logical_apicid(cpumask_first(cpumask)); |
124 | } | 124 | } |
125 | 125 | ||
126 | static unsigned int bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 126 | static unsigned int bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
@@ -188,10 +188,10 @@ static const struct dmi_system_id bigsmp_dmi_table[] = { | |||
188 | { } /* NULL entry stops DMI scanning */ | 188 | { } /* NULL entry stops DMI scanning */ |
189 | }; | 189 | }; |
190 | 190 | ||
191 | static void bigsmp_vector_allocation_domain(int cpu, cpumask_t *retmask) | 191 | static void bigsmp_vector_allocation_domain(int cpu, struct cpumask *retmask) |
192 | { | 192 | { |
193 | cpus_clear(*retmask); | 193 | cpumask_clear(retmask); |
194 | cpu_set(cpu, *retmask); | 194 | cpumask_set_cpu(cpu, retmask); |
195 | } | 195 | } |
196 | 196 | ||
197 | static int probe_bigsmp(void) | 197 | static int probe_bigsmp(void) |
diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c index 19588f2770ee..1c11b819f245 100644 --- a/arch/x86/kernel/apic/es7000_32.c +++ b/arch/x86/kernel/apic/es7000_32.c | |||
@@ -410,7 +410,7 @@ static void es7000_enable_apic_mode(void) | |||
410 | WARN(1, "Command failed, status = %x\n", mip_status); | 410 | WARN(1, "Command failed, status = %x\n", mip_status); |
411 | } | 411 | } |
412 | 412 | ||
413 | static void es7000_vector_allocation_domain(int cpu, cpumask_t *retmask) | 413 | static void es7000_vector_allocation_domain(int cpu, struct cpumask *retmask) |
414 | { | 414 | { |
415 | /* Careful. Some cpus do not strictly honor the set of cpus | 415 | /* Careful. Some cpus do not strictly honor the set of cpus |
416 | * specified in the interrupt destination when using lowest | 416 | * specified in the interrupt destination when using lowest |
@@ -420,7 +420,8 @@ static void es7000_vector_allocation_domain(int cpu, cpumask_t *retmask) | |||
420 | * deliver interrupts to the wrong hyperthread when only one | 420 | * deliver interrupts to the wrong hyperthread when only one |
421 | * hyperthread was specified in the interrupt desitination. | 421 | * hyperthread was specified in the interrupt desitination. |
422 | */ | 422 | */ |
423 | *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } }; | 423 | cpumask_clear(retmask); |
424 | cpumask_bits(retmask)[0] = APIC_ALL_CPUS; | ||
424 | } | 425 | } |
425 | 426 | ||
426 | 427 | ||
@@ -455,14 +456,14 @@ static int es7000_apic_id_registered(void) | |||
455 | return 1; | 456 | return 1; |
456 | } | 457 | } |
457 | 458 | ||
458 | static const cpumask_t *target_cpus_cluster(void) | 459 | static const struct cpumask *target_cpus_cluster(void) |
459 | { | 460 | { |
460 | return &CPU_MASK_ALL; | 461 | return cpu_all_mask; |
461 | } | 462 | } |
462 | 463 | ||
463 | static const cpumask_t *es7000_target_cpus(void) | 464 | static const struct cpumask *es7000_target_cpus(void) |
464 | { | 465 | { |
465 | return &cpumask_of_cpu(smp_processor_id()); | 466 | return cpumask_of(smp_processor_id()); |
466 | } | 467 | } |
467 | 468 | ||
468 | static unsigned long | 469 | static unsigned long |
@@ -517,7 +518,7 @@ static void es7000_setup_apic_routing(void) | |||
517 | "Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n", | 518 | "Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n", |
518 | (apic_version[apic] == 0x14) ? | 519 | (apic_version[apic] == 0x14) ? |
519 | "Physical Cluster" : "Logical Cluster", | 520 | "Physical Cluster" : "Logical Cluster", |
520 | nr_ioapics, cpus_addr(*es7000_target_cpus())[0]); | 521 | nr_ioapics, cpumask_bits(es7000_target_cpus())[0]); |
521 | } | 522 | } |
522 | 523 | ||
523 | static int es7000_apicid_to_node(int logical_apicid) | 524 | static int es7000_apicid_to_node(int logical_apicid) |
@@ -572,7 +573,7 @@ static int es7000_check_phys_apicid_present(int cpu_physical_apicid) | |||
572 | return 1; | 573 | return 1; |
573 | } | 574 | } |
574 | 575 | ||
575 | static unsigned int es7000_cpu_mask_to_apicid(const cpumask_t *cpumask) | 576 | static unsigned int es7000_cpu_mask_to_apicid(const struct cpumask *cpumask) |
576 | { | 577 | { |
577 | unsigned int round = 0; | 578 | unsigned int round = 0; |
578 | int cpu, uninitialized_var(apicid); | 579 | int cpu, uninitialized_var(apicid); |
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 00e6071cefc4..767fe7e46d68 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -389,6 +389,8 @@ struct io_apic { | |||
389 | unsigned int index; | 389 | unsigned int index; |
390 | unsigned int unused[3]; | 390 | unsigned int unused[3]; |
391 | unsigned int data; | 391 | unsigned int data; |
392 | unsigned int unused2[11]; | ||
393 | unsigned int eoi; | ||
392 | }; | 394 | }; |
393 | 395 | ||
394 | static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx) | 396 | static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx) |
@@ -397,6 +399,12 @@ static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx) | |||
397 | + (mp_ioapics[idx].apicaddr & ~PAGE_MASK); | 399 | + (mp_ioapics[idx].apicaddr & ~PAGE_MASK); |
398 | } | 400 | } |
399 | 401 | ||
402 | static inline void io_apic_eoi(unsigned int apic, unsigned int vector) | ||
403 | { | ||
404 | struct io_apic __iomem *io_apic = io_apic_base(apic); | ||
405 | writel(vector, &io_apic->eoi); | ||
406 | } | ||
407 | |||
400 | static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) | 408 | static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) |
401 | { | 409 | { |
402 | struct io_apic __iomem *io_apic = io_apic_base(apic); | 410 | struct io_apic __iomem *io_apic = io_apic_base(apic); |
@@ -546,16 +554,12 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq | |||
546 | 554 | ||
547 | apic = entry->apic; | 555 | apic = entry->apic; |
548 | pin = entry->pin; | 556 | pin = entry->pin; |
549 | #ifdef CONFIG_INTR_REMAP | ||
550 | /* | 557 | /* |
551 | * With interrupt-remapping, destination information comes | 558 | * With interrupt-remapping, destination information comes |
552 | * from interrupt-remapping table entry. | 559 | * from interrupt-remapping table entry. |
553 | */ | 560 | */ |
554 | if (!irq_remapped(irq)) | 561 | if (!irq_remapped(irq)) |
555 | io_apic_write(apic, 0x11 + pin*2, dest); | 562 | io_apic_write(apic, 0x11 + pin*2, dest); |
556 | #else | ||
557 | io_apic_write(apic, 0x11 + pin*2, dest); | ||
558 | #endif | ||
559 | reg = io_apic_read(apic, 0x10 + pin*2); | 563 | reg = io_apic_read(apic, 0x10 + pin*2); |
560 | reg &= ~IO_APIC_REDIR_VECTOR_MASK; | 564 | reg &= ~IO_APIC_REDIR_VECTOR_MASK; |
561 | reg |= vector; | 565 | reg |= vector; |
@@ -588,10 +592,12 @@ set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask) | |||
588 | if (assign_irq_vector(irq, cfg, mask)) | 592 | if (assign_irq_vector(irq, cfg, mask)) |
589 | return BAD_APICID; | 593 | return BAD_APICID; |
590 | 594 | ||
591 | cpumask_and(desc->affinity, cfg->domain, mask); | 595 | /* check that before desc->addinity get updated */ |
592 | set_extra_move_desc(desc, mask); | 596 | set_extra_move_desc(desc, mask); |
593 | 597 | ||
594 | return apic->cpu_mask_to_apicid_and(desc->affinity, cpu_online_mask); | 598 | cpumask_copy(desc->affinity, mask); |
599 | |||
600 | return apic->cpu_mask_to_apicid_and(desc->affinity, cfg->domain); | ||
595 | } | 601 | } |
596 | 602 | ||
597 | static void | 603 | static void |
@@ -845,75 +851,106 @@ __setup("pirq=", ioapic_pirq_setup); | |||
845 | #endif /* CONFIG_X86_32 */ | 851 | #endif /* CONFIG_X86_32 */ |
846 | 852 | ||
847 | #ifdef CONFIG_INTR_REMAP | 853 | #ifdef CONFIG_INTR_REMAP |
848 | /* I/O APIC RTE contents at the OS boot up */ | 854 | struct IO_APIC_route_entry **alloc_ioapic_entries(void) |
849 | static struct IO_APIC_route_entry *early_ioapic_entries[MAX_IO_APICS]; | 855 | { |
856 | int apic; | ||
857 | struct IO_APIC_route_entry **ioapic_entries; | ||
858 | |||
859 | ioapic_entries = kzalloc(sizeof(*ioapic_entries) * nr_ioapics, | ||
860 | GFP_ATOMIC); | ||
861 | if (!ioapic_entries) | ||
862 | return 0; | ||
863 | |||
864 | for (apic = 0; apic < nr_ioapics; apic++) { | ||
865 | ioapic_entries[apic] = | ||
866 | kzalloc(sizeof(struct IO_APIC_route_entry) * | ||
867 | nr_ioapic_registers[apic], GFP_ATOMIC); | ||
868 | if (!ioapic_entries[apic]) | ||
869 | goto nomem; | ||
870 | } | ||
871 | |||
872 | return ioapic_entries; | ||
873 | |||
874 | nomem: | ||
875 | while (--apic >= 0) | ||
876 | kfree(ioapic_entries[apic]); | ||
877 | kfree(ioapic_entries); | ||
878 | |||
879 | return 0; | ||
880 | } | ||
850 | 881 | ||
851 | /* | 882 | /* |
852 | * Saves and masks all the unmasked IO-APIC RTE's | 883 | * Saves all the IO-APIC RTE's |
853 | */ | 884 | */ |
854 | int save_mask_IO_APIC_setup(void) | 885 | int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries) |
855 | { | 886 | { |
856 | union IO_APIC_reg_01 reg_01; | ||
857 | unsigned long flags; | ||
858 | int apic, pin; | 887 | int apic, pin; |
859 | 888 | ||
860 | /* | 889 | if (!ioapic_entries) |
861 | * The number of IO-APIC IRQ registers (== #pins): | 890 | return -ENOMEM; |
862 | */ | 891 | |
863 | for (apic = 0; apic < nr_ioapics; apic++) { | 892 | for (apic = 0; apic < nr_ioapics; apic++) { |
864 | spin_lock_irqsave(&ioapic_lock, flags); | 893 | if (!ioapic_entries[apic]) |
865 | reg_01.raw = io_apic_read(apic, 1); | 894 | return -ENOMEM; |
866 | spin_unlock_irqrestore(&ioapic_lock, flags); | 895 | |
867 | nr_ioapic_registers[apic] = reg_01.bits.entries+1; | 896 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) |
897 | ioapic_entries[apic][pin] = | ||
898 | ioapic_read_entry(apic, pin); | ||
868 | } | 899 | } |
869 | 900 | ||
901 | return 0; | ||
902 | } | ||
903 | |||
904 | /* | ||
905 | * Mask all IO APIC entries. | ||
906 | */ | ||
907 | void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries) | ||
908 | { | ||
909 | int apic, pin; | ||
910 | |||
911 | if (!ioapic_entries) | ||
912 | return; | ||
913 | |||
870 | for (apic = 0; apic < nr_ioapics; apic++) { | 914 | for (apic = 0; apic < nr_ioapics; apic++) { |
871 | early_ioapic_entries[apic] = | 915 | if (!ioapic_entries[apic]) |
872 | kzalloc(sizeof(struct IO_APIC_route_entry) * | 916 | break; |
873 | nr_ioapic_registers[apic], GFP_KERNEL); | ||
874 | if (!early_ioapic_entries[apic]) | ||
875 | goto nomem; | ||
876 | } | ||
877 | 917 | ||
878 | for (apic = 0; apic < nr_ioapics; apic++) | ||
879 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { | 918 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { |
880 | struct IO_APIC_route_entry entry; | 919 | struct IO_APIC_route_entry entry; |
881 | 920 | ||
882 | entry = early_ioapic_entries[apic][pin] = | 921 | entry = ioapic_entries[apic][pin]; |
883 | ioapic_read_entry(apic, pin); | ||
884 | if (!entry.mask) { | 922 | if (!entry.mask) { |
885 | entry.mask = 1; | 923 | entry.mask = 1; |
886 | ioapic_write_entry(apic, pin, entry); | 924 | ioapic_write_entry(apic, pin, entry); |
887 | } | 925 | } |
888 | } | 926 | } |
889 | 927 | } | |
890 | return 0; | ||
891 | |||
892 | nomem: | ||
893 | while (apic >= 0) | ||
894 | kfree(early_ioapic_entries[apic--]); | ||
895 | memset(early_ioapic_entries, 0, | ||
896 | ARRAY_SIZE(early_ioapic_entries)); | ||
897 | |||
898 | return -ENOMEM; | ||
899 | } | 928 | } |
900 | 929 | ||
901 | void restore_IO_APIC_setup(void) | 930 | /* |
931 | * Restore IO APIC entries which was saved in ioapic_entries. | ||
932 | */ | ||
933 | int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries) | ||
902 | { | 934 | { |
903 | int apic, pin; | 935 | int apic, pin; |
904 | 936 | ||
937 | if (!ioapic_entries) | ||
938 | return -ENOMEM; | ||
939 | |||
905 | for (apic = 0; apic < nr_ioapics; apic++) { | 940 | for (apic = 0; apic < nr_ioapics; apic++) { |
906 | if (!early_ioapic_entries[apic]) | 941 | if (!ioapic_entries[apic]) |
907 | break; | 942 | return -ENOMEM; |
943 | |||
908 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) | 944 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) |
909 | ioapic_write_entry(apic, pin, | 945 | ioapic_write_entry(apic, pin, |
910 | early_ioapic_entries[apic][pin]); | 946 | ioapic_entries[apic][pin]); |
911 | kfree(early_ioapic_entries[apic]); | ||
912 | early_ioapic_entries[apic] = NULL; | ||
913 | } | 947 | } |
948 | return 0; | ||
914 | } | 949 | } |
915 | 950 | ||
916 | void reinit_intr_remapped_IO_APIC(int intr_remapping) | 951 | void reinit_intr_remapped_IO_APIC(int intr_remapping, |
952 | struct IO_APIC_route_entry **ioapic_entries) | ||
953 | |||
917 | { | 954 | { |
918 | /* | 955 | /* |
919 | * for now plain restore of previous settings. | 956 | * for now plain restore of previous settings. |
@@ -922,7 +959,17 @@ void reinit_intr_remapped_IO_APIC(int intr_remapping) | |||
922 | * table entries. for now, do a plain restore, and wait for | 959 | * table entries. for now, do a plain restore, and wait for |
923 | * the setup_IO_APIC_irqs() to do proper initialization. | 960 | * the setup_IO_APIC_irqs() to do proper initialization. |
924 | */ | 961 | */ |
925 | restore_IO_APIC_setup(); | 962 | restore_IO_APIC_setup(ioapic_entries); |
963 | } | ||
964 | |||
965 | void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries) | ||
966 | { | ||
967 | int apic; | ||
968 | |||
969 | for (apic = 0; apic < nr_ioapics; apic++) | ||
970 | kfree(ioapic_entries[apic]); | ||
971 | |||
972 | kfree(ioapic_entries); | ||
926 | } | 973 | } |
927 | #endif | 974 | #endif |
928 | 975 | ||
@@ -1411,9 +1458,7 @@ void __setup_vector_irq(int cpu) | |||
1411 | } | 1458 | } |
1412 | 1459 | ||
1413 | static struct irq_chip ioapic_chip; | 1460 | static struct irq_chip ioapic_chip; |
1414 | #ifdef CONFIG_INTR_REMAP | ||
1415 | static struct irq_chip ir_ioapic_chip; | 1461 | static struct irq_chip ir_ioapic_chip; |
1416 | #endif | ||
1417 | 1462 | ||
1418 | #define IOAPIC_AUTO -1 | 1463 | #define IOAPIC_AUTO -1 |
1419 | #define IOAPIC_EDGE 0 | 1464 | #define IOAPIC_EDGE 0 |
@@ -1452,7 +1497,6 @@ static void ioapic_register_intr(int irq, struct irq_desc *desc, unsigned long t | |||
1452 | else | 1497 | else |
1453 | desc->status &= ~IRQ_LEVEL; | 1498 | desc->status &= ~IRQ_LEVEL; |
1454 | 1499 | ||
1455 | #ifdef CONFIG_INTR_REMAP | ||
1456 | if (irq_remapped(irq)) { | 1500 | if (irq_remapped(irq)) { |
1457 | desc->status |= IRQ_MOVE_PCNTXT; | 1501 | desc->status |= IRQ_MOVE_PCNTXT; |
1458 | if (trigger) | 1502 | if (trigger) |
@@ -1464,7 +1508,7 @@ static void ioapic_register_intr(int irq, struct irq_desc *desc, unsigned long t | |||
1464 | handle_edge_irq, "edge"); | 1508 | handle_edge_irq, "edge"); |
1465 | return; | 1509 | return; |
1466 | } | 1510 | } |
1467 | #endif | 1511 | |
1468 | if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || | 1512 | if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || |
1469 | trigger == IOAPIC_LEVEL) | 1513 | trigger == IOAPIC_LEVEL) |
1470 | set_irq_chip_and_handler_name(irq, &ioapic_chip, | 1514 | set_irq_chip_and_handler_name(irq, &ioapic_chip, |
@@ -1478,14 +1522,13 @@ static void ioapic_register_intr(int irq, struct irq_desc *desc, unsigned long t | |||
1478 | int setup_ioapic_entry(int apic_id, int irq, | 1522 | int setup_ioapic_entry(int apic_id, int irq, |
1479 | struct IO_APIC_route_entry *entry, | 1523 | struct IO_APIC_route_entry *entry, |
1480 | unsigned int destination, int trigger, | 1524 | unsigned int destination, int trigger, |
1481 | int polarity, int vector) | 1525 | int polarity, int vector, int pin) |
1482 | { | 1526 | { |
1483 | /* | 1527 | /* |
1484 | * add it to the IO-APIC irq-routing table: | 1528 | * add it to the IO-APIC irq-routing table: |
1485 | */ | 1529 | */ |
1486 | memset(entry,0,sizeof(*entry)); | 1530 | memset(entry,0,sizeof(*entry)); |
1487 | 1531 | ||
1488 | #ifdef CONFIG_INTR_REMAP | ||
1489 | if (intr_remapping_enabled) { | 1532 | if (intr_remapping_enabled) { |
1490 | struct intel_iommu *iommu = map_ioapic_to_ir(apic_id); | 1533 | struct intel_iommu *iommu = map_ioapic_to_ir(apic_id); |
1491 | struct irte irte; | 1534 | struct irte irte; |
@@ -1504,7 +1547,14 @@ int setup_ioapic_entry(int apic_id, int irq, | |||
1504 | 1547 | ||
1505 | irte.present = 1; | 1548 | irte.present = 1; |
1506 | irte.dst_mode = apic->irq_dest_mode; | 1549 | irte.dst_mode = apic->irq_dest_mode; |
1507 | irte.trigger_mode = trigger; | 1550 | /* |
1551 | * Trigger mode in the IRTE will always be edge, and the | ||
1552 | * actual level or edge trigger will be setup in the IO-APIC | ||
1553 | * RTE. This will help simplify level triggered irq migration. | ||
1554 | * For more details, see the comments above explainig IO-APIC | ||
1555 | * irq migration in the presence of interrupt-remapping. | ||
1556 | */ | ||
1557 | irte.trigger_mode = 0; | ||
1508 | irte.dlvry_mode = apic->irq_delivery_mode; | 1558 | irte.dlvry_mode = apic->irq_delivery_mode; |
1509 | irte.vector = vector; | 1559 | irte.vector = vector; |
1510 | irte.dest_id = IRTE_DEST(destination); | 1560 | irte.dest_id = IRTE_DEST(destination); |
@@ -1515,18 +1565,21 @@ int setup_ioapic_entry(int apic_id, int irq, | |||
1515 | ir_entry->zero = 0; | 1565 | ir_entry->zero = 0; |
1516 | ir_entry->format = 1; | 1566 | ir_entry->format = 1; |
1517 | ir_entry->index = (index & 0x7fff); | 1567 | ir_entry->index = (index & 0x7fff); |
1518 | } else | 1568 | /* |
1519 | #endif | 1569 | * IO-APIC RTE will be configured with virtual vector. |
1520 | { | 1570 | * irq handler will do the explicit EOI to the io-apic. |
1571 | */ | ||
1572 | ir_entry->vector = pin; | ||
1573 | } else { | ||
1521 | entry->delivery_mode = apic->irq_delivery_mode; | 1574 | entry->delivery_mode = apic->irq_delivery_mode; |
1522 | entry->dest_mode = apic->irq_dest_mode; | 1575 | entry->dest_mode = apic->irq_dest_mode; |
1523 | entry->dest = destination; | 1576 | entry->dest = destination; |
1577 | entry->vector = vector; | ||
1524 | } | 1578 | } |
1525 | 1579 | ||
1526 | entry->mask = 0; /* enable IRQ */ | 1580 | entry->mask = 0; /* enable IRQ */ |
1527 | entry->trigger = trigger; | 1581 | entry->trigger = trigger; |
1528 | entry->polarity = polarity; | 1582 | entry->polarity = polarity; |
1529 | entry->vector = vector; | ||
1530 | 1583 | ||
1531 | /* Mask level triggered irqs. | 1584 | /* Mask level triggered irqs. |
1532 | * Use IRQ_DELAYED_DISABLE for edge triggered irqs. | 1585 | * Use IRQ_DELAYED_DISABLE for edge triggered irqs. |
@@ -1561,7 +1614,7 @@ static void setup_IO_APIC_irq(int apic_id, int pin, unsigned int irq, struct irq | |||
1561 | 1614 | ||
1562 | 1615 | ||
1563 | if (setup_ioapic_entry(mp_ioapics[apic_id].apicid, irq, &entry, | 1616 | if (setup_ioapic_entry(mp_ioapics[apic_id].apicid, irq, &entry, |
1564 | dest, trigger, polarity, cfg->vector)) { | 1617 | dest, trigger, polarity, cfg->vector, pin)) { |
1565 | printk("Failed to setup ioapic entry for ioapic %d, pin %d\n", | 1618 | printk("Failed to setup ioapic entry for ioapic %d, pin %d\n", |
1566 | mp_ioapics[apic_id].apicid, pin); | 1619 | mp_ioapics[apic_id].apicid, pin); |
1567 | __clear_irq_vector(irq, cfg); | 1620 | __clear_irq_vector(irq, cfg); |
@@ -1642,10 +1695,8 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic_id, unsigned int pin, | |||
1642 | { | 1695 | { |
1643 | struct IO_APIC_route_entry entry; | 1696 | struct IO_APIC_route_entry entry; |
1644 | 1697 | ||
1645 | #ifdef CONFIG_INTR_REMAP | ||
1646 | if (intr_remapping_enabled) | 1698 | if (intr_remapping_enabled) |
1647 | return; | 1699 | return; |
1648 | #endif | ||
1649 | 1700 | ||
1650 | memset(&entry, 0, sizeof(entry)); | 1701 | memset(&entry, 0, sizeof(entry)); |
1651 | 1702 | ||
@@ -2040,8 +2091,13 @@ void disable_IO_APIC(void) | |||
2040 | * If the i8259 is routed through an IOAPIC | 2091 | * If the i8259 is routed through an IOAPIC |
2041 | * Put that IOAPIC in virtual wire mode | 2092 | * Put that IOAPIC in virtual wire mode |
2042 | * so legacy interrupts can be delivered. | 2093 | * so legacy interrupts can be delivered. |
2094 | * | ||
2095 | * With interrupt-remapping, for now we will use virtual wire A mode, | ||
2096 | * as virtual wire B is little complex (need to configure both | ||
2097 | * IOAPIC RTE aswell as interrupt-remapping table entry). | ||
2098 | * As this gets called during crash dump, keep this simple for now. | ||
2043 | */ | 2099 | */ |
2044 | if (ioapic_i8259.pin != -1) { | 2100 | if (ioapic_i8259.pin != -1 && !intr_remapping_enabled) { |
2045 | struct IO_APIC_route_entry entry; | 2101 | struct IO_APIC_route_entry entry; |
2046 | 2102 | ||
2047 | memset(&entry, 0, sizeof(entry)); | 2103 | memset(&entry, 0, sizeof(entry)); |
@@ -2061,7 +2117,10 @@ void disable_IO_APIC(void) | |||
2061 | ioapic_write_entry(ioapic_i8259.apic, ioapic_i8259.pin, entry); | 2117 | ioapic_write_entry(ioapic_i8259.apic, ioapic_i8259.pin, entry); |
2062 | } | 2118 | } |
2063 | 2119 | ||
2064 | disconnect_bsp_APIC(ioapic_i8259.pin != -1); | 2120 | /* |
2121 | * Use virtual wire A mode when interrupt remapping is enabled. | ||
2122 | */ | ||
2123 | disconnect_bsp_APIC(!intr_remapping_enabled && ioapic_i8259.pin != -1); | ||
2065 | } | 2124 | } |
2066 | 2125 | ||
2067 | #ifdef CONFIG_X86_32 | 2126 | #ifdef CONFIG_X86_32 |
@@ -2303,37 +2362,24 @@ static int ioapic_retrigger_irq(unsigned int irq) | |||
2303 | #ifdef CONFIG_SMP | 2362 | #ifdef CONFIG_SMP |
2304 | 2363 | ||
2305 | #ifdef CONFIG_INTR_REMAP | 2364 | #ifdef CONFIG_INTR_REMAP |
2306 | static void ir_irq_migration(struct work_struct *work); | ||
2307 | |||
2308 | static DECLARE_DELAYED_WORK(ir_migration_work, ir_irq_migration); | ||
2309 | 2365 | ||
2310 | /* | 2366 | /* |
2311 | * Migrate the IO-APIC irq in the presence of intr-remapping. | 2367 | * Migrate the IO-APIC irq in the presence of intr-remapping. |
2312 | * | 2368 | * |
2313 | * For edge triggered, irq migration is a simple atomic update(of vector | 2369 | * For both level and edge triggered, irq migration is a simple atomic |
2314 | * and cpu destination) of IRTE and flush the hardware cache. | 2370 | * update(of vector and cpu destination) of IRTE and flush the hardware cache. |
2315 | * | ||
2316 | * For level triggered, we need to modify the io-apic RTE aswell with the update | ||
2317 | * vector information, along with modifying IRTE with vector and destination. | ||
2318 | * So irq migration for level triggered is little bit more complex compared to | ||
2319 | * edge triggered migration. But the good news is, we use the same algorithm | ||
2320 | * for level triggered migration as we have today, only difference being, | ||
2321 | * we now initiate the irq migration from process context instead of the | ||
2322 | * interrupt context. | ||
2323 | * | 2371 | * |
2324 | * In future, when we do a directed EOI (combined with cpu EOI broadcast | 2372 | * For level triggered, we eliminate the io-apic RTE modification (with the |
2325 | * suppression) to the IO-APIC, level triggered irq migration will also be | 2373 | * updated vector information), by using a virtual vector (io-apic pin number). |
2326 | * as simple as edge triggered migration and we can do the irq migration | 2374 | * Real vector that is used for interrupting cpu will be coming from |
2327 | * with a simple atomic update to IO-APIC RTE. | 2375 | * the interrupt-remapping table entry. |
2328 | */ | 2376 | */ |
2329 | static void | 2377 | static void |
2330 | migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) | 2378 | migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) |
2331 | { | 2379 | { |
2332 | struct irq_cfg *cfg; | 2380 | struct irq_cfg *cfg; |
2333 | struct irte irte; | 2381 | struct irte irte; |
2334 | int modify_ioapic_rte; | ||
2335 | unsigned int dest; | 2382 | unsigned int dest; |
2336 | unsigned long flags; | ||
2337 | unsigned int irq; | 2383 | unsigned int irq; |
2338 | 2384 | ||
2339 | if (!cpumask_intersects(mask, cpu_online_mask)) | 2385 | if (!cpumask_intersects(mask, cpu_online_mask)) |
@@ -2351,13 +2397,6 @@ migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) | |||
2351 | 2397 | ||
2352 | dest = apic->cpu_mask_to_apicid_and(cfg->domain, mask); | 2398 | dest = apic->cpu_mask_to_apicid_and(cfg->domain, mask); |
2353 | 2399 | ||
2354 | modify_ioapic_rte = desc->status & IRQ_LEVEL; | ||
2355 | if (modify_ioapic_rte) { | ||
2356 | spin_lock_irqsave(&ioapic_lock, flags); | ||
2357 | __target_IO_APIC_irq(irq, dest, cfg); | ||
2358 | spin_unlock_irqrestore(&ioapic_lock, flags); | ||
2359 | } | ||
2360 | |||
2361 | irte.vector = cfg->vector; | 2400 | irte.vector = cfg->vector; |
2362 | irte.dest_id = IRTE_DEST(dest); | 2401 | irte.dest_id = IRTE_DEST(dest); |
2363 | 2402 | ||
@@ -2372,73 +2411,12 @@ migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) | |||
2372 | cpumask_copy(desc->affinity, mask); | 2411 | cpumask_copy(desc->affinity, mask); |
2373 | } | 2412 | } |
2374 | 2413 | ||
2375 | static int migrate_irq_remapped_level_desc(struct irq_desc *desc) | ||
2376 | { | ||
2377 | int ret = -1; | ||
2378 | struct irq_cfg *cfg = desc->chip_data; | ||
2379 | |||
2380 | mask_IO_APIC_irq_desc(desc); | ||
2381 | |||
2382 | if (io_apic_level_ack_pending(cfg)) { | ||
2383 | /* | ||
2384 | * Interrupt in progress. Migrating irq now will change the | ||
2385 | * vector information in the IO-APIC RTE and that will confuse | ||
2386 | * the EOI broadcast performed by cpu. | ||
2387 | * So, delay the irq migration to the next instance. | ||
2388 | */ | ||
2389 | schedule_delayed_work(&ir_migration_work, 1); | ||
2390 | goto unmask; | ||
2391 | } | ||
2392 | |||
2393 | /* everthing is clear. we have right of way */ | ||
2394 | migrate_ioapic_irq_desc(desc, desc->pending_mask); | ||
2395 | |||
2396 | ret = 0; | ||
2397 | desc->status &= ~IRQ_MOVE_PENDING; | ||
2398 | cpumask_clear(desc->pending_mask); | ||
2399 | |||
2400 | unmask: | ||
2401 | unmask_IO_APIC_irq_desc(desc); | ||
2402 | |||
2403 | return ret; | ||
2404 | } | ||
2405 | |||
2406 | static void ir_irq_migration(struct work_struct *work) | ||
2407 | { | ||
2408 | unsigned int irq; | ||
2409 | struct irq_desc *desc; | ||
2410 | |||
2411 | for_each_irq_desc(irq, desc) { | ||
2412 | if (desc->status & IRQ_MOVE_PENDING) { | ||
2413 | unsigned long flags; | ||
2414 | |||
2415 | spin_lock_irqsave(&desc->lock, flags); | ||
2416 | if (!desc->chip->set_affinity || | ||
2417 | !(desc->status & IRQ_MOVE_PENDING)) { | ||
2418 | desc->status &= ~IRQ_MOVE_PENDING; | ||
2419 | spin_unlock_irqrestore(&desc->lock, flags); | ||
2420 | continue; | ||
2421 | } | ||
2422 | |||
2423 | desc->chip->set_affinity(irq, desc->pending_mask); | ||
2424 | spin_unlock_irqrestore(&desc->lock, flags); | ||
2425 | } | ||
2426 | } | ||
2427 | } | ||
2428 | |||
2429 | /* | 2414 | /* |
2430 | * Migrates the IRQ destination in the process context. | 2415 | * Migrates the IRQ destination in the process context. |
2431 | */ | 2416 | */ |
2432 | static void set_ir_ioapic_affinity_irq_desc(struct irq_desc *desc, | 2417 | static void set_ir_ioapic_affinity_irq_desc(struct irq_desc *desc, |
2433 | const struct cpumask *mask) | 2418 | const struct cpumask *mask) |
2434 | { | 2419 | { |
2435 | if (desc->status & IRQ_LEVEL) { | ||
2436 | desc->status |= IRQ_MOVE_PENDING; | ||
2437 | cpumask_copy(desc->pending_mask, mask); | ||
2438 | migrate_irq_remapped_level_desc(desc); | ||
2439 | return; | ||
2440 | } | ||
2441 | |||
2442 | migrate_ioapic_irq_desc(desc, mask); | 2420 | migrate_ioapic_irq_desc(desc, mask); |
2443 | } | 2421 | } |
2444 | static void set_ir_ioapic_affinity_irq(unsigned int irq, | 2422 | static void set_ir_ioapic_affinity_irq(unsigned int irq, |
@@ -2448,6 +2426,11 @@ static void set_ir_ioapic_affinity_irq(unsigned int irq, | |||
2448 | 2426 | ||
2449 | set_ir_ioapic_affinity_irq_desc(desc, mask); | 2427 | set_ir_ioapic_affinity_irq_desc(desc, mask); |
2450 | } | 2428 | } |
2429 | #else | ||
2430 | static inline void set_ir_ioapic_affinity_irq_desc(struct irq_desc *desc, | ||
2431 | const struct cpumask *mask) | ||
2432 | { | ||
2433 | } | ||
2451 | #endif | 2434 | #endif |
2452 | 2435 | ||
2453 | asmlinkage void smp_irq_move_cleanup_interrupt(void) | 2436 | asmlinkage void smp_irq_move_cleanup_interrupt(void) |
@@ -2461,6 +2444,7 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void) | |||
2461 | me = smp_processor_id(); | 2444 | me = smp_processor_id(); |
2462 | for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; vector++) { | 2445 | for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; vector++) { |
2463 | unsigned int irq; | 2446 | unsigned int irq; |
2447 | unsigned int irr; | ||
2464 | struct irq_desc *desc; | 2448 | struct irq_desc *desc; |
2465 | struct irq_cfg *cfg; | 2449 | struct irq_cfg *cfg; |
2466 | irq = __get_cpu_var(vector_irq)[vector]; | 2450 | irq = __get_cpu_var(vector_irq)[vector]; |
@@ -2480,6 +2464,18 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void) | |||
2480 | if (vector == cfg->vector && cpumask_test_cpu(me, cfg->domain)) | 2464 | if (vector == cfg->vector && cpumask_test_cpu(me, cfg->domain)) |
2481 | goto unlock; | 2465 | goto unlock; |
2482 | 2466 | ||
2467 | irr = apic_read(APIC_IRR + (vector / 32 * 0x10)); | ||
2468 | /* | ||
2469 | * Check if the vector that needs to be cleanedup is | ||
2470 | * registered at the cpu's IRR. If so, then this is not | ||
2471 | * the best time to clean it up. Lets clean it up in the | ||
2472 | * next attempt by sending another IRQ_MOVE_CLEANUP_VECTOR | ||
2473 | * to myself. | ||
2474 | */ | ||
2475 | if (irr & (1 << (vector % 32))) { | ||
2476 | apic->send_IPI_self(IRQ_MOVE_CLEANUP_VECTOR); | ||
2477 | goto unlock; | ||
2478 | } | ||
2483 | __get_cpu_var(vector_irq)[vector] = -1; | 2479 | __get_cpu_var(vector_irq)[vector] = -1; |
2484 | cfg->move_cleanup_count--; | 2480 | cfg->move_cleanup_count--; |
2485 | unlock: | 2481 | unlock: |
@@ -2528,17 +2524,51 @@ static void irq_complete_move(struct irq_desc **descp) | |||
2528 | static inline void irq_complete_move(struct irq_desc **descp) {} | 2524 | static inline void irq_complete_move(struct irq_desc **descp) {} |
2529 | #endif | 2525 | #endif |
2530 | 2526 | ||
2531 | #ifdef CONFIG_INTR_REMAP | 2527 | #ifdef CONFIG_X86_X2APIC |
2528 | static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg) | ||
2529 | { | ||
2530 | int apic, pin; | ||
2531 | struct irq_pin_list *entry; | ||
2532 | |||
2533 | entry = cfg->irq_2_pin; | ||
2534 | for (;;) { | ||
2535 | |||
2536 | if (!entry) | ||
2537 | break; | ||
2538 | |||
2539 | apic = entry->apic; | ||
2540 | pin = entry->pin; | ||
2541 | io_apic_eoi(apic, pin); | ||
2542 | entry = entry->next; | ||
2543 | } | ||
2544 | } | ||
2545 | |||
2546 | static void | ||
2547 | eoi_ioapic_irq(struct irq_desc *desc) | ||
2548 | { | ||
2549 | struct irq_cfg *cfg; | ||
2550 | unsigned long flags; | ||
2551 | unsigned int irq; | ||
2552 | |||
2553 | irq = desc->irq; | ||
2554 | cfg = desc->chip_data; | ||
2555 | |||
2556 | spin_lock_irqsave(&ioapic_lock, flags); | ||
2557 | __eoi_ioapic_irq(irq, cfg); | ||
2558 | spin_unlock_irqrestore(&ioapic_lock, flags); | ||
2559 | } | ||
2560 | |||
2532 | static void ack_x2apic_level(unsigned int irq) | 2561 | static void ack_x2apic_level(unsigned int irq) |
2533 | { | 2562 | { |
2563 | struct irq_desc *desc = irq_to_desc(irq); | ||
2534 | ack_x2APIC_irq(); | 2564 | ack_x2APIC_irq(); |
2565 | eoi_ioapic_irq(desc); | ||
2535 | } | 2566 | } |
2536 | 2567 | ||
2537 | static void ack_x2apic_edge(unsigned int irq) | 2568 | static void ack_x2apic_edge(unsigned int irq) |
2538 | { | 2569 | { |
2539 | ack_x2APIC_irq(); | 2570 | ack_x2APIC_irq(); |
2540 | } | 2571 | } |
2541 | |||
2542 | #endif | 2572 | #endif |
2543 | 2573 | ||
2544 | static void ack_apic_edge(unsigned int irq) | 2574 | static void ack_apic_edge(unsigned int irq) |
@@ -2649,6 +2679,26 @@ static void ack_apic_level(unsigned int irq) | |||
2649 | #endif | 2679 | #endif |
2650 | } | 2680 | } |
2651 | 2681 | ||
2682 | #ifdef CONFIG_INTR_REMAP | ||
2683 | static void ir_ack_apic_edge(unsigned int irq) | ||
2684 | { | ||
2685 | #ifdef CONFIG_X86_X2APIC | ||
2686 | if (x2apic_enabled()) | ||
2687 | return ack_x2apic_edge(irq); | ||
2688 | #endif | ||
2689 | return ack_apic_edge(irq); | ||
2690 | } | ||
2691 | |||
2692 | static void ir_ack_apic_level(unsigned int irq) | ||
2693 | { | ||
2694 | #ifdef CONFIG_X86_X2APIC | ||
2695 | if (x2apic_enabled()) | ||
2696 | return ack_x2apic_level(irq); | ||
2697 | #endif | ||
2698 | return ack_apic_level(irq); | ||
2699 | } | ||
2700 | #endif /* CONFIG_INTR_REMAP */ | ||
2701 | |||
2652 | static struct irq_chip ioapic_chip __read_mostly = { | 2702 | static struct irq_chip ioapic_chip __read_mostly = { |
2653 | .name = "IO-APIC", | 2703 | .name = "IO-APIC", |
2654 | .startup = startup_ioapic_irq, | 2704 | .startup = startup_ioapic_irq, |
@@ -2662,20 +2712,20 @@ static struct irq_chip ioapic_chip __read_mostly = { | |||
2662 | .retrigger = ioapic_retrigger_irq, | 2712 | .retrigger = ioapic_retrigger_irq, |
2663 | }; | 2713 | }; |
2664 | 2714 | ||
2665 | #ifdef CONFIG_INTR_REMAP | ||
2666 | static struct irq_chip ir_ioapic_chip __read_mostly = { | 2715 | static struct irq_chip ir_ioapic_chip __read_mostly = { |
2667 | .name = "IR-IO-APIC", | 2716 | .name = "IR-IO-APIC", |
2668 | .startup = startup_ioapic_irq, | 2717 | .startup = startup_ioapic_irq, |
2669 | .mask = mask_IO_APIC_irq, | 2718 | .mask = mask_IO_APIC_irq, |
2670 | .unmask = unmask_IO_APIC_irq, | 2719 | .unmask = unmask_IO_APIC_irq, |
2671 | .ack = ack_x2apic_edge, | 2720 | #ifdef CONFIG_INTR_REMAP |
2672 | .eoi = ack_x2apic_level, | 2721 | .ack = ir_ack_apic_edge, |
2722 | .eoi = ir_ack_apic_level, | ||
2673 | #ifdef CONFIG_SMP | 2723 | #ifdef CONFIG_SMP |
2674 | .set_affinity = set_ir_ioapic_affinity_irq, | 2724 | .set_affinity = set_ir_ioapic_affinity_irq, |
2675 | #endif | 2725 | #endif |
2726 | #endif | ||
2676 | .retrigger = ioapic_retrigger_irq, | 2727 | .retrigger = ioapic_retrigger_irq, |
2677 | }; | 2728 | }; |
2678 | #endif | ||
2679 | 2729 | ||
2680 | static inline void init_IO_APIC_traps(void) | 2730 | static inline void init_IO_APIC_traps(void) |
2681 | { | 2731 | { |
@@ -2901,10 +2951,8 @@ static inline void __init check_timer(void) | |||
2901 | * 8259A. | 2951 | * 8259A. |
2902 | */ | 2952 | */ |
2903 | if (pin1 == -1) { | 2953 | if (pin1 == -1) { |
2904 | #ifdef CONFIG_INTR_REMAP | ||
2905 | if (intr_remapping_enabled) | 2954 | if (intr_remapping_enabled) |
2906 | panic("BIOS bug: timer not connected to IO-APIC"); | 2955 | panic("BIOS bug: timer not connected to IO-APIC"); |
2907 | #endif | ||
2908 | pin1 = pin2; | 2956 | pin1 = pin2; |
2909 | apic1 = apic2; | 2957 | apic1 = apic2; |
2910 | no_pin1 = 1; | 2958 | no_pin1 = 1; |
@@ -2940,10 +2988,8 @@ static inline void __init check_timer(void) | |||
2940 | clear_IO_APIC_pin(0, pin1); | 2988 | clear_IO_APIC_pin(0, pin1); |
2941 | goto out; | 2989 | goto out; |
2942 | } | 2990 | } |
2943 | #ifdef CONFIG_INTR_REMAP | ||
2944 | if (intr_remapping_enabled) | 2991 | if (intr_remapping_enabled) |
2945 | panic("timer doesn't work through Interrupt-remapped IO-APIC"); | 2992 | panic("timer doesn't work through Interrupt-remapped IO-APIC"); |
2946 | #endif | ||
2947 | local_irq_disable(); | 2993 | local_irq_disable(); |
2948 | clear_IO_APIC_pin(apic1, pin1); | 2994 | clear_IO_APIC_pin(apic1, pin1); |
2949 | if (!no_pin1) | 2995 | if (!no_pin1) |
@@ -3237,9 +3283,7 @@ void destroy_irq(unsigned int irq) | |||
3237 | if (desc) | 3283 | if (desc) |
3238 | desc->chip_data = cfg; | 3284 | desc->chip_data = cfg; |
3239 | 3285 | ||
3240 | #ifdef CONFIG_INTR_REMAP | ||
3241 | free_irte(irq); | 3286 | free_irte(irq); |
3242 | #endif | ||
3243 | spin_lock_irqsave(&vector_lock, flags); | 3287 | spin_lock_irqsave(&vector_lock, flags); |
3244 | __clear_irq_vector(irq, cfg); | 3288 | __clear_irq_vector(irq, cfg); |
3245 | spin_unlock_irqrestore(&vector_lock, flags); | 3289 | spin_unlock_irqrestore(&vector_lock, flags); |
@@ -3265,7 +3309,6 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms | |||
3265 | 3309 | ||
3266 | dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); | 3310 | dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); |
3267 | 3311 | ||
3268 | #ifdef CONFIG_INTR_REMAP | ||
3269 | if (irq_remapped(irq)) { | 3312 | if (irq_remapped(irq)) { |
3270 | struct irte irte; | 3313 | struct irte irte; |
3271 | int ir_index; | 3314 | int ir_index; |
@@ -3291,10 +3334,13 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms | |||
3291 | MSI_ADDR_IR_SHV | | 3334 | MSI_ADDR_IR_SHV | |
3292 | MSI_ADDR_IR_INDEX1(ir_index) | | 3335 | MSI_ADDR_IR_INDEX1(ir_index) | |
3293 | MSI_ADDR_IR_INDEX2(ir_index); | 3336 | MSI_ADDR_IR_INDEX2(ir_index); |
3294 | } else | 3337 | } else { |
3295 | #endif | 3338 | if (x2apic_enabled()) |
3296 | { | 3339 | msg->address_hi = MSI_ADDR_BASE_HI | |
3297 | msg->address_hi = MSI_ADDR_BASE_HI; | 3340 | MSI_ADDR_EXT_DEST_ID(dest); |
3341 | else | ||
3342 | msg->address_hi = MSI_ADDR_BASE_HI; | ||
3343 | |||
3298 | msg->address_lo = | 3344 | msg->address_lo = |
3299 | MSI_ADDR_BASE_LO | | 3345 | MSI_ADDR_BASE_LO | |
3300 | ((apic->irq_dest_mode == 0) ? | 3346 | ((apic->irq_dest_mode == 0) ? |
@@ -3394,15 +3440,16 @@ static struct irq_chip msi_chip = { | |||
3394 | .retrigger = ioapic_retrigger_irq, | 3440 | .retrigger = ioapic_retrigger_irq, |
3395 | }; | 3441 | }; |
3396 | 3442 | ||
3397 | #ifdef CONFIG_INTR_REMAP | ||
3398 | static struct irq_chip msi_ir_chip = { | 3443 | static struct irq_chip msi_ir_chip = { |
3399 | .name = "IR-PCI-MSI", | 3444 | .name = "IR-PCI-MSI", |
3400 | .unmask = unmask_msi_irq, | 3445 | .unmask = unmask_msi_irq, |
3401 | .mask = mask_msi_irq, | 3446 | .mask = mask_msi_irq, |
3402 | .ack = ack_x2apic_edge, | 3447 | #ifdef CONFIG_INTR_REMAP |
3448 | .ack = ir_ack_apic_edge, | ||
3403 | #ifdef CONFIG_SMP | 3449 | #ifdef CONFIG_SMP |
3404 | .set_affinity = ir_set_msi_irq_affinity, | 3450 | .set_affinity = ir_set_msi_irq_affinity, |
3405 | #endif | 3451 | #endif |
3452 | #endif | ||
3406 | .retrigger = ioapic_retrigger_irq, | 3453 | .retrigger = ioapic_retrigger_irq, |
3407 | }; | 3454 | }; |
3408 | 3455 | ||
@@ -3432,7 +3479,6 @@ static int msi_alloc_irte(struct pci_dev *dev, int irq, int nvec) | |||
3432 | } | 3479 | } |
3433 | return index; | 3480 | return index; |
3434 | } | 3481 | } |
3435 | #endif | ||
3436 | 3482 | ||
3437 | static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq) | 3483 | static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq) |
3438 | { | 3484 | { |
@@ -3446,7 +3492,6 @@ static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq) | |||
3446 | set_irq_msi(irq, msidesc); | 3492 | set_irq_msi(irq, msidesc); |
3447 | write_msi_msg(irq, &msg); | 3493 | write_msi_msg(irq, &msg); |
3448 | 3494 | ||
3449 | #ifdef CONFIG_INTR_REMAP | ||
3450 | if (irq_remapped(irq)) { | 3495 | if (irq_remapped(irq)) { |
3451 | struct irq_desc *desc = irq_to_desc(irq); | 3496 | struct irq_desc *desc = irq_to_desc(irq); |
3452 | /* | 3497 | /* |
@@ -3455,7 +3500,6 @@ static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq) | |||
3455 | desc->status |= IRQ_MOVE_PCNTXT; | 3500 | desc->status |= IRQ_MOVE_PCNTXT; |
3456 | set_irq_chip_and_handler_name(irq, &msi_ir_chip, handle_edge_irq, "edge"); | 3501 | set_irq_chip_and_handler_name(irq, &msi_ir_chip, handle_edge_irq, "edge"); |
3457 | } else | 3502 | } else |
3458 | #endif | ||
3459 | set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge"); | 3503 | set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge"); |
3460 | 3504 | ||
3461 | dev_printk(KERN_DEBUG, &dev->dev, "irq %d for MSI/MSI-X\n", irq); | 3505 | dev_printk(KERN_DEBUG, &dev->dev, "irq %d for MSI/MSI-X\n", irq); |
@@ -3469,11 +3513,12 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | |||
3469 | int ret, sub_handle; | 3513 | int ret, sub_handle; |
3470 | struct msi_desc *msidesc; | 3514 | struct msi_desc *msidesc; |
3471 | unsigned int irq_want; | 3515 | unsigned int irq_want; |
3472 | 3516 | struct intel_iommu *iommu = NULL; | |
3473 | #ifdef CONFIG_INTR_REMAP | ||
3474 | struct intel_iommu *iommu = 0; | ||
3475 | int index = 0; | 3517 | int index = 0; |
3476 | #endif | 3518 | |
3519 | /* x86 doesn't support multiple MSI yet */ | ||
3520 | if (type == PCI_CAP_ID_MSI && nvec > 1) | ||
3521 | return 1; | ||
3477 | 3522 | ||
3478 | irq_want = nr_irqs_gsi; | 3523 | irq_want = nr_irqs_gsi; |
3479 | sub_handle = 0; | 3524 | sub_handle = 0; |
@@ -3482,7 +3527,6 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | |||
3482 | if (irq == 0) | 3527 | if (irq == 0) |
3483 | return -1; | 3528 | return -1; |
3484 | irq_want = irq + 1; | 3529 | irq_want = irq + 1; |
3485 | #ifdef CONFIG_INTR_REMAP | ||
3486 | if (!intr_remapping_enabled) | 3530 | if (!intr_remapping_enabled) |
3487 | goto no_ir; | 3531 | goto no_ir; |
3488 | 3532 | ||
@@ -3510,7 +3554,6 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | |||
3510 | set_irte_irq(irq, iommu, index, sub_handle); | 3554 | set_irte_irq(irq, iommu, index, sub_handle); |
3511 | } | 3555 | } |
3512 | no_ir: | 3556 | no_ir: |
3513 | #endif | ||
3514 | ret = setup_msi_irq(dev, msidesc, irq); | 3557 | ret = setup_msi_irq(dev, msidesc, irq); |
3515 | if (ret < 0) | 3558 | if (ret < 0) |
3516 | goto error; | 3559 | goto error; |
@@ -3528,7 +3571,7 @@ void arch_teardown_msi_irq(unsigned int irq) | |||
3528 | destroy_irq(irq); | 3571 | destroy_irq(irq); |
3529 | } | 3572 | } |
3530 | 3573 | ||
3531 | #ifdef CONFIG_DMAR | 3574 | #if defined (CONFIG_DMAR) || defined (CONFIG_INTR_REMAP) |
3532 | #ifdef CONFIG_SMP | 3575 | #ifdef CONFIG_SMP |
3533 | static void dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask) | 3576 | static void dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask) |
3534 | { | 3577 | { |
@@ -3609,7 +3652,7 @@ static void hpet_msi_set_affinity(unsigned int irq, const struct cpumask *mask) | |||
3609 | 3652 | ||
3610 | #endif /* CONFIG_SMP */ | 3653 | #endif /* CONFIG_SMP */ |
3611 | 3654 | ||
3612 | struct irq_chip hpet_msi_type = { | 3655 | static struct irq_chip hpet_msi_type = { |
3613 | .name = "HPET_MSI", | 3656 | .name = "HPET_MSI", |
3614 | .unmask = hpet_msi_unmask, | 3657 | .unmask = hpet_msi_unmask, |
3615 | .mask = hpet_msi_mask, | 3658 | .mask = hpet_msi_mask, |
@@ -4045,11 +4088,9 @@ void __init setup_ioapic_dest(void) | |||
4045 | else | 4088 | else |
4046 | mask = apic->target_cpus(); | 4089 | mask = apic->target_cpus(); |
4047 | 4090 | ||
4048 | #ifdef CONFIG_INTR_REMAP | ||
4049 | if (intr_remapping_enabled) | 4091 | if (intr_remapping_enabled) |
4050 | set_ir_ioapic_affinity_irq_desc(desc, mask); | 4092 | set_ir_ioapic_affinity_irq_desc(desc, mask); |
4051 | else | 4093 | else |
4052 | #endif | ||
4053 | set_ioapic_affinity_irq_desc(desc, mask); | 4094 | set_ioapic_affinity_irq_desc(desc, mask); |
4054 | } | 4095 | } |
4055 | 4096 | ||
@@ -4142,9 +4183,12 @@ static int __init ioapic_insert_resources(void) | |||
4142 | struct resource *r = ioapic_resources; | 4183 | struct resource *r = ioapic_resources; |
4143 | 4184 | ||
4144 | if (!r) { | 4185 | if (!r) { |
4145 | printk(KERN_ERR | 4186 | if (nr_ioapics > 0) { |
4146 | "IO APIC resources could be not be allocated.\n"); | 4187 | printk(KERN_ERR |
4147 | return -1; | 4188 | "IO APIC resources couldn't be allocated.\n"); |
4189 | return -1; | ||
4190 | } | ||
4191 | return 0; | ||
4148 | } | 4192 | } |
4149 | 4193 | ||
4150 | for (i = 0; i < nr_ioapics; i++) { | 4194 | for (i = 0; i < nr_ioapics; i++) { |
diff --git a/arch/x86/kernel/apic/nmi.c b/arch/x86/kernel/apic/nmi.c index bdfad80c3cf1..d6bd62407152 100644 --- a/arch/x86/kernel/apic/nmi.c +++ b/arch/x86/kernel/apic/nmi.c | |||
@@ -39,7 +39,7 @@ | |||
39 | int unknown_nmi_panic; | 39 | int unknown_nmi_panic; |
40 | int nmi_watchdog_enabled; | 40 | int nmi_watchdog_enabled; |
41 | 41 | ||
42 | static cpumask_t backtrace_mask = CPU_MASK_NONE; | 42 | static cpumask_var_t backtrace_mask; |
43 | 43 | ||
44 | /* nmi_active: | 44 | /* nmi_active: |
45 | * >0: the lapic NMI watchdog is active, but can be disabled | 45 | * >0: the lapic NMI watchdog is active, but can be disabled |
@@ -138,6 +138,7 @@ int __init check_nmi_watchdog(void) | |||
138 | if (!prev_nmi_count) | 138 | if (!prev_nmi_count) |
139 | goto error; | 139 | goto error; |
140 | 140 | ||
141 | alloc_cpumask_var(&backtrace_mask, GFP_KERNEL); | ||
141 | printk(KERN_INFO "Testing NMI watchdog ... "); | 142 | printk(KERN_INFO "Testing NMI watchdog ... "); |
142 | 143 | ||
143 | #ifdef CONFIG_SMP | 144 | #ifdef CONFIG_SMP |
@@ -413,14 +414,14 @@ nmi_watchdog_tick(struct pt_regs *regs, unsigned reason) | |||
413 | touched = 1; | 414 | touched = 1; |
414 | } | 415 | } |
415 | 416 | ||
416 | if (cpu_isset(cpu, backtrace_mask)) { | 417 | if (cpumask_test_cpu(cpu, backtrace_mask)) { |
417 | static DEFINE_SPINLOCK(lock); /* Serialise the printks */ | 418 | static DEFINE_SPINLOCK(lock); /* Serialise the printks */ |
418 | 419 | ||
419 | spin_lock(&lock); | 420 | spin_lock(&lock); |
420 | printk(KERN_WARNING "NMI backtrace for cpu %d\n", cpu); | 421 | printk(KERN_WARNING "NMI backtrace for cpu %d\n", cpu); |
421 | dump_stack(); | 422 | dump_stack(); |
422 | spin_unlock(&lock); | 423 | spin_unlock(&lock); |
423 | cpu_clear(cpu, backtrace_mask); | 424 | cpumask_clear_cpu(cpu, backtrace_mask); |
424 | } | 425 | } |
425 | 426 | ||
426 | /* Could check oops_in_progress here too, but it's safer not to */ | 427 | /* Could check oops_in_progress here too, but it's safer not to */ |
@@ -554,10 +555,10 @@ void __trigger_all_cpu_backtrace(void) | |||
554 | { | 555 | { |
555 | int i; | 556 | int i; |
556 | 557 | ||
557 | backtrace_mask = cpu_online_map; | 558 | cpumask_copy(backtrace_mask, cpu_online_mask); |
558 | /* Wait for up to 10 seconds for all CPUs to do the backtrace */ | 559 | /* Wait for up to 10 seconds for all CPUs to do the backtrace */ |
559 | for (i = 0; i < 10 * 1000; i++) { | 560 | for (i = 0; i < 10 * 1000; i++) { |
560 | if (cpus_empty(backtrace_mask)) | 561 | if (cpumask_empty(backtrace_mask)) |
561 | break; | 562 | break; |
562 | mdelay(1); | 563 | mdelay(1); |
563 | } | 564 | } |
diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c index ba2fc6465534..533e59c6fc82 100644 --- a/arch/x86/kernel/apic/numaq_32.c +++ b/arch/x86/kernel/apic/numaq_32.c | |||
@@ -334,9 +334,9 @@ static inline void numaq_smp_callin_clear_local_apic(void) | |||
334 | clear_local_APIC(); | 334 | clear_local_APIC(); |
335 | } | 335 | } |
336 | 336 | ||
337 | static inline const cpumask_t *numaq_target_cpus(void) | 337 | static inline const struct cpumask *numaq_target_cpus(void) |
338 | { | 338 | { |
339 | return &CPU_MASK_ALL; | 339 | return cpu_all_mask; |
340 | } | 340 | } |
341 | 341 | ||
342 | static inline unsigned long | 342 | static inline unsigned long |
@@ -427,7 +427,7 @@ static inline int numaq_check_phys_apicid_present(int boot_cpu_physical_apicid) | |||
427 | * We use physical apicids here, not logical, so just return the default | 427 | * We use physical apicids here, not logical, so just return the default |
428 | * physical broadcast to stop people from breaking us | 428 | * physical broadcast to stop people from breaking us |
429 | */ | 429 | */ |
430 | static inline unsigned int numaq_cpu_mask_to_apicid(const cpumask_t *cpumask) | 430 | static unsigned int numaq_cpu_mask_to_apicid(const struct cpumask *cpumask) |
431 | { | 431 | { |
432 | return 0x0F; | 432 | return 0x0F; |
433 | } | 433 | } |
@@ -462,7 +462,7 @@ static int probe_numaq(void) | |||
462 | return found_numaq; | 462 | return found_numaq; |
463 | } | 463 | } |
464 | 464 | ||
465 | static void numaq_vector_allocation_domain(int cpu, cpumask_t *retmask) | 465 | static void numaq_vector_allocation_domain(int cpu, struct cpumask *retmask) |
466 | { | 466 | { |
467 | /* Careful. Some cpus do not strictly honor the set of cpus | 467 | /* Careful. Some cpus do not strictly honor the set of cpus |
468 | * specified in the interrupt destination when using lowest | 468 | * specified in the interrupt destination when using lowest |
@@ -472,7 +472,8 @@ static void numaq_vector_allocation_domain(int cpu, cpumask_t *retmask) | |||
472 | * deliver interrupts to the wrong hyperthread when only one | 472 | * deliver interrupts to the wrong hyperthread when only one |
473 | * hyperthread was specified in the interrupt desitination. | 473 | * hyperthread was specified in the interrupt desitination. |
474 | */ | 474 | */ |
475 | *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } }; | 475 | cpumask_clear(retmask); |
476 | cpumask_bits(retmask)[0] = APIC_ALL_CPUS; | ||
476 | } | 477 | } |
477 | 478 | ||
478 | static void numaq_setup_portio_remap(void) | 479 | static void numaq_setup_portio_remap(void) |
diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c index 141c99a1c264..01eda2ac65e4 100644 --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c | |||
@@ -83,7 +83,8 @@ static void default_vector_allocation_domain(int cpu, struct cpumask *retmask) | |||
83 | * deliver interrupts to the wrong hyperthread when only one | 83 | * deliver interrupts to the wrong hyperthread when only one |
84 | * hyperthread was specified in the interrupt desitination. | 84 | * hyperthread was specified in the interrupt desitination. |
85 | */ | 85 | */ |
86 | *retmask = (cpumask_t) { { [0] = APIC_ALL_CPUS } }; | 86 | cpumask_clear(retmask); |
87 | cpumask_bits(retmask)[0] = APIC_ALL_CPUS; | ||
87 | } | 88 | } |
88 | 89 | ||
89 | /* should be called last. */ | 90 | /* should be called last. */ |
diff --git a/arch/x86/kernel/apic/probe_64.c b/arch/x86/kernel/apic/probe_64.c index 8d7748efe6a8..1783652bb0e5 100644 --- a/arch/x86/kernel/apic/probe_64.c +++ b/arch/x86/kernel/apic/probe_64.c | |||
@@ -68,6 +68,13 @@ void __init default_setup_apic_routing(void) | |||
68 | apic = &apic_physflat; | 68 | apic = &apic_physflat; |
69 | printk(KERN_INFO "Setting APIC routing to %s\n", apic->name); | 69 | printk(KERN_INFO "Setting APIC routing to %s\n", apic->name); |
70 | } | 70 | } |
71 | |||
72 | /* | ||
73 | * Now that apic routing model is selected, configure the | ||
74 | * fault handling for intr remapping. | ||
75 | */ | ||
76 | if (intr_remapping_enabled) | ||
77 | enable_drhd_fault_handling(); | ||
71 | } | 78 | } |
72 | 79 | ||
73 | /* Same for both flat and physical. */ | 80 | /* Same for both flat and physical. */ |
diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c index aac52fa873ff..9cfe1f415d81 100644 --- a/arch/x86/kernel/apic/summit_32.c +++ b/arch/x86/kernel/apic/summit_32.c | |||
@@ -53,23 +53,19 @@ static unsigned summit_get_apic_id(unsigned long x) | |||
53 | return (x >> 24) & 0xFF; | 53 | return (x >> 24) & 0xFF; |
54 | } | 54 | } |
55 | 55 | ||
56 | static inline void summit_send_IPI_mask(const cpumask_t *mask, int vector) | 56 | static inline void summit_send_IPI_mask(const struct cpumask *mask, int vector) |
57 | { | 57 | { |
58 | default_send_IPI_mask_sequence_logical(mask, vector); | 58 | default_send_IPI_mask_sequence_logical(mask, vector); |
59 | } | 59 | } |
60 | 60 | ||
61 | static void summit_send_IPI_allbutself(int vector) | 61 | static void summit_send_IPI_allbutself(int vector) |
62 | { | 62 | { |
63 | cpumask_t mask = cpu_online_map; | 63 | default_send_IPI_mask_allbutself_logical(cpu_online_mask, vector); |
64 | cpu_clear(smp_processor_id(), mask); | ||
65 | |||
66 | if (!cpus_empty(mask)) | ||
67 | summit_send_IPI_mask(&mask, vector); | ||
68 | } | 64 | } |
69 | 65 | ||
70 | static void summit_send_IPI_all(int vector) | 66 | static void summit_send_IPI_all(int vector) |
71 | { | 67 | { |
72 | summit_send_IPI_mask(&cpu_online_map, vector); | 68 | summit_send_IPI_mask(cpu_online_mask, vector); |
73 | } | 69 | } |
74 | 70 | ||
75 | #include <asm/tsc.h> | 71 | #include <asm/tsc.h> |
@@ -186,13 +182,13 @@ static inline int is_WPEG(struct rio_detail *rio){ | |||
186 | 182 | ||
187 | #define SUMMIT_APIC_DFR_VALUE (APIC_DFR_CLUSTER) | 183 | #define SUMMIT_APIC_DFR_VALUE (APIC_DFR_CLUSTER) |
188 | 184 | ||
189 | static const cpumask_t *summit_target_cpus(void) | 185 | static const struct cpumask *summit_target_cpus(void) |
190 | { | 186 | { |
191 | /* CPU_MASK_ALL (0xff) has undefined behaviour with | 187 | /* CPU_MASK_ALL (0xff) has undefined behaviour with |
192 | * dest_LowestPrio mode logical clustered apic interrupt routing | 188 | * dest_LowestPrio mode logical clustered apic interrupt routing |
193 | * Just start on cpu 0. IRQ balancing will spread load | 189 | * Just start on cpu 0. IRQ balancing will spread load |
194 | */ | 190 | */ |
195 | return &cpumask_of_cpu(0); | 191 | return cpumask_of(0); |
196 | } | 192 | } |
197 | 193 | ||
198 | static unsigned long summit_check_apicid_used(physid_mask_t bitmap, int apicid) | 194 | static unsigned long summit_check_apicid_used(physid_mask_t bitmap, int apicid) |
@@ -289,7 +285,7 @@ static int summit_check_phys_apicid_present(int boot_cpu_physical_apicid) | |||
289 | return 1; | 285 | return 1; |
290 | } | 286 | } |
291 | 287 | ||
292 | static unsigned int summit_cpu_mask_to_apicid(const cpumask_t *cpumask) | 288 | static unsigned int summit_cpu_mask_to_apicid(const struct cpumask *cpumask) |
293 | { | 289 | { |
294 | unsigned int round = 0; | 290 | unsigned int round = 0; |
295 | int cpu, apicid = 0; | 291 | int cpu, apicid = 0; |
@@ -346,7 +342,7 @@ static int probe_summit(void) | |||
346 | return 0; | 342 | return 0; |
347 | } | 343 | } |
348 | 344 | ||
349 | static void summit_vector_allocation_domain(int cpu, cpumask_t *retmask) | 345 | static void summit_vector_allocation_domain(int cpu, struct cpumask *retmask) |
350 | { | 346 | { |
351 | /* Careful. Some cpus do not strictly honor the set of cpus | 347 | /* Careful. Some cpus do not strictly honor the set of cpus |
352 | * specified in the interrupt destination when using lowest | 348 | * specified in the interrupt destination when using lowest |
@@ -356,7 +352,8 @@ static void summit_vector_allocation_domain(int cpu, cpumask_t *retmask) | |||
356 | * deliver interrupts to the wrong hyperthread when only one | 352 | * deliver interrupts to the wrong hyperthread when only one |
357 | * hyperthread was specified in the interrupt desitination. | 353 | * hyperthread was specified in the interrupt desitination. |
358 | */ | 354 | */ |
359 | *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } }; | 355 | cpumask_clear(retmask); |
356 | cpumask_bits(retmask)[0] = APIC_ALL_CPUS; | ||
360 | } | 357 | } |
361 | 358 | ||
362 | #ifdef CONFIG_X86_SUMMIT_NUMA | 359 | #ifdef CONFIG_X86_SUMMIT_NUMA |
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c index 8fb87b6dd633..4a903e2f0d17 100644 --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c | |||
@@ -57,6 +57,8 @@ static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) | |||
57 | unsigned long query_cpu; | 57 | unsigned long query_cpu; |
58 | unsigned long flags; | 58 | unsigned long flags; |
59 | 59 | ||
60 | x2apic_wrmsr_fence(); | ||
61 | |||
60 | local_irq_save(flags); | 62 | local_irq_save(flags); |
61 | for_each_cpu(query_cpu, mask) { | 63 | for_each_cpu(query_cpu, mask) { |
62 | __x2apic_send_IPI_dest( | 64 | __x2apic_send_IPI_dest( |
@@ -73,6 +75,8 @@ static void | |||
73 | unsigned long query_cpu; | 75 | unsigned long query_cpu; |
74 | unsigned long flags; | 76 | unsigned long flags; |
75 | 77 | ||
78 | x2apic_wrmsr_fence(); | ||
79 | |||
76 | local_irq_save(flags); | 80 | local_irq_save(flags); |
77 | for_each_cpu(query_cpu, mask) { | 81 | for_each_cpu(query_cpu, mask) { |
78 | if (query_cpu == this_cpu) | 82 | if (query_cpu == this_cpu) |
@@ -90,6 +94,8 @@ static void x2apic_send_IPI_allbutself(int vector) | |||
90 | unsigned long query_cpu; | 94 | unsigned long query_cpu; |
91 | unsigned long flags; | 95 | unsigned long flags; |
92 | 96 | ||
97 | x2apic_wrmsr_fence(); | ||
98 | |||
93 | local_irq_save(flags); | 99 | local_irq_save(flags); |
94 | for_each_online_cpu(query_cpu) { | 100 | for_each_online_cpu(query_cpu) { |
95 | if (query_cpu == this_cpu) | 101 | if (query_cpu == this_cpu) |
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c index 23625b9f98b2..a284359627e7 100644 --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c | |||
@@ -58,6 +58,8 @@ static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) | |||
58 | unsigned long query_cpu; | 58 | unsigned long query_cpu; |
59 | unsigned long flags; | 59 | unsigned long flags; |
60 | 60 | ||
61 | x2apic_wrmsr_fence(); | ||
62 | |||
61 | local_irq_save(flags); | 63 | local_irq_save(flags); |
62 | for_each_cpu(query_cpu, mask) { | 64 | for_each_cpu(query_cpu, mask) { |
63 | __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), | 65 | __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), |
@@ -73,6 +75,8 @@ static void | |||
73 | unsigned long query_cpu; | 75 | unsigned long query_cpu; |
74 | unsigned long flags; | 76 | unsigned long flags; |
75 | 77 | ||
78 | x2apic_wrmsr_fence(); | ||
79 | |||
76 | local_irq_save(flags); | 80 | local_irq_save(flags); |
77 | for_each_cpu(query_cpu, mask) { | 81 | for_each_cpu(query_cpu, mask) { |
78 | if (query_cpu != this_cpu) | 82 | if (query_cpu != this_cpu) |
@@ -89,6 +93,8 @@ static void x2apic_send_IPI_allbutself(int vector) | |||
89 | unsigned long query_cpu; | 93 | unsigned long query_cpu; |
90 | unsigned long flags; | 94 | unsigned long flags; |
91 | 95 | ||
96 | x2apic_wrmsr_fence(); | ||
97 | |||
92 | local_irq_save(flags); | 98 | local_irq_save(flags); |
93 | for_each_online_cpu(query_cpu) { | 99 | for_each_online_cpu(query_cpu) { |
94 | if (query_cpu == this_cpu) | 100 | if (query_cpu == this_cpu) |
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index 1bd6da1f8fad..1248318436e8 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c | |||
@@ -118,17 +118,12 @@ static int uv_wakeup_secondary(int phys_apicid, unsigned long start_rip) | |||
118 | 118 | ||
119 | static void uv_send_IPI_one(int cpu, int vector) | 119 | static void uv_send_IPI_one(int cpu, int vector) |
120 | { | 120 | { |
121 | unsigned long val, apicid; | 121 | unsigned long apicid; |
122 | int pnode; | 122 | int pnode; |
123 | 123 | ||
124 | apicid = per_cpu(x86_cpu_to_apicid, cpu); | 124 | apicid = per_cpu(x86_cpu_to_apicid, cpu); |
125 | pnode = uv_apicid_to_pnode(apicid); | 125 | pnode = uv_apicid_to_pnode(apicid); |
126 | 126 | uv_hub_send_ipi(pnode, apicid, vector); | |
127 | val = (1UL << UVH_IPI_INT_SEND_SHFT) | | ||
128 | (apicid << UVH_IPI_INT_APIC_ID_SHFT) | | ||
129 | (vector << UVH_IPI_INT_VECTOR_SHFT); | ||
130 | |||
131 | uv_write_global_mmr64(pnode, UVH_IPI_INT, val); | ||
132 | } | 127 | } |
133 | 128 | ||
134 | static void uv_send_IPI_mask(const struct cpumask *mask, int vector) | 129 | static void uv_send_IPI_mask(const struct cpumask *mask, int vector) |