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

Merge branch 'x86/apic' into x86/platform

Merge in x86/apic to solve a vector_allocation_domain() API change semantic merge conflict.

Signed-off-by: Ingo Molnar <mingo@kernel.org>

+361 -564
+48 -14
arch/x86/include/asm/apic.h
··· 306 306 unsigned long (*check_apicid_used)(physid_mask_t *map, int apicid); 307 307 unsigned long (*check_apicid_present)(int apicid); 308 308 309 - void (*vector_allocation_domain)(int cpu, struct cpumask *retmask); 309 + bool (*vector_allocation_domain)(int cpu, struct cpumask *retmask); 310 310 void (*init_apic_ldr)(void); 311 311 312 312 void (*ioapic_phys_id_map)(physid_mask_t *phys_map, physid_mask_t *retmap); ··· 331 331 unsigned long (*set_apic_id)(unsigned int id); 332 332 unsigned long apic_id_mask; 333 333 334 - unsigned int (*cpu_mask_to_apicid)(const struct cpumask *cpumask); 335 - unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask, 336 - const struct cpumask *andmask); 334 + int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask, 335 + const struct cpumask *andmask, 336 + unsigned int *apicid); 337 337 338 338 /* ipi */ 339 339 void (*send_IPI_mask)(const struct cpumask *mask, int vector); ··· 537 537 #endif 538 538 } 539 539 540 + static inline const struct cpumask *online_target_cpus(void) 541 + { 542 + return cpu_online_mask; 543 + } 544 + 540 545 DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); 541 546 542 547 ··· 591 586 592 587 #endif 593 588 594 - static inline unsigned int 595 - default_cpu_mask_to_apicid(const struct cpumask *cpumask) 589 + static inline int 590 + flat_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 591 + const struct cpumask *andmask, 592 + unsigned int *apicid) 596 593 { 597 - return cpumask_bits(cpumask)[0] & APIC_ALL_CPUS; 594 + unsigned long cpu_mask = cpumask_bits(cpumask)[0] & 595 + cpumask_bits(andmask)[0] & 596 + cpumask_bits(cpu_online_mask)[0] & 597 + APIC_ALL_CPUS; 598 + 599 + if (likely(cpu_mask)) { 600 + *apicid = (unsigned int)cpu_mask; 601 + return 0; 602 + } else { 603 + return -EINVAL; 604 + } 598 605 } 599 606 600 - static inline unsigned int 607 + extern int 601 608 default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 602 - const struct cpumask *andmask) 603 - { 604 - unsigned long mask1 = cpumask_bits(cpumask)[0]; 605 - unsigned long mask2 = cpumask_bits(andmask)[0]; 606 - unsigned long mask3 = cpumask_bits(cpu_online_mask)[0]; 609 + const struct cpumask *andmask, 610 + unsigned int *apicid); 607 611 608 - return (unsigned int)(mask1 & mask2 & mask3); 612 + static inline bool 613 + flat_vector_allocation_domain(int cpu, struct cpumask *retmask) 614 + { 615 + /* Careful. Some cpus do not strictly honor the set of cpus 616 + * specified in the interrupt destination when using lowest 617 + * priority interrupt delivery mode. 618 + * 619 + * In particular there was a hyperthreading cpu observed to 620 + * deliver interrupts to the wrong hyperthread when only one 621 + * hyperthread was specified in the interrupt desitination. 622 + */ 623 + cpumask_clear(retmask); 624 + cpumask_bits(retmask)[0] = APIC_ALL_CPUS; 625 + return false; 626 + } 627 + 628 + static inline bool 629 + default_vector_allocation_domain(int cpu, struct cpumask *retmask) 630 + { 631 + cpumask_copy(retmask, cpumask_of(cpu)); 632 + return true; 609 633 } 610 634 611 635 static inline unsigned long default_check_apicid_used(physid_mask_t *map, int apicid)
-18
arch/x86/include/asm/x2apic.h
··· 9 9 #include <asm/ipi.h> 10 10 #include <linux/cpumask.h> 11 11 12 - /* 13 - * Need to use more than cpu 0, because we need more vectors 14 - * when MSI-X are used. 15 - */ 16 - static const struct cpumask *x2apic_target_cpus(void) 17 - { 18 - return cpu_online_mask; 19 - } 20 - 21 12 static int x2apic_apic_id_valid(int apicid) 22 13 { 23 14 return 1; ··· 17 26 static int x2apic_apic_id_registered(void) 18 27 { 19 28 return 1; 20 - } 21 - 22 - /* 23 - * For now each logical cpu is in its own vector allocation domain. 24 - */ 25 - static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask) 26 - { 27 - cpumask_clear(retmask); 28 - cpumask_set_cpu(cpu, retmask); 29 29 } 30 30 31 31 static void
-2
arch/x86/include/asm/x86_init.h
··· 156 156 /** 157 157 * struct x86_platform_ops - platform specific runtime functions 158 158 * @calibrate_tsc: calibrate TSC 159 - * @wallclock_init: init the wallclock device 160 159 * @get_wallclock: get time from HW clock like RTC etc. 161 160 * @set_wallclock: set time back to HW clock 162 161 * @is_untracked_pat_range exclude from PAT logic ··· 167 168 */ 168 169 struct x86_platform_ops { 169 170 unsigned long (*calibrate_tsc)(void); 170 - void (*wallclock_init)(void); 171 171 unsigned long (*get_wallclock)(void); 172 172 int (*set_wallclock)(unsigned long nowtime); 173 173 void (*iommu_shutdown)(void);
+19
arch/x86/kernel/apic/apic.c
··· 2123 2123 apic_write(APIC_LDR, val); 2124 2124 } 2125 2125 2126 + int default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 2127 + const struct cpumask *andmask, 2128 + unsigned int *apicid) 2129 + { 2130 + unsigned int cpu; 2131 + 2132 + for_each_cpu_and(cpu, cpumask, andmask) { 2133 + if (cpumask_test_cpu(cpu, cpu_online_mask)) 2134 + break; 2135 + } 2136 + 2137 + if (likely(cpu < nr_cpu_ids)) { 2138 + *apicid = per_cpu(x86_cpu_to_apicid, cpu); 2139 + return 0; 2140 + } 2141 + 2142 + return -EINVAL; 2143 + } 2144 + 2126 2145 /* 2127 2146 * Power management 2128 2147 */
+6 -70
arch/x86/kernel/apic/apic_flat_64.c
··· 36 36 return 1; 37 37 } 38 38 39 - static const struct cpumask *flat_target_cpus(void) 40 - { 41 - return cpu_online_mask; 42 - } 43 - 44 - static void flat_vector_allocation_domain(int cpu, struct cpumask *retmask) 45 - { 46 - /* Careful. Some cpus do not strictly honor the set of cpus 47 - * specified in the interrupt destination when using lowest 48 - * priority interrupt delivery mode. 49 - * 50 - * In particular there was a hyperthreading cpu observed to 51 - * deliver interrupts to the wrong hyperthread when only one 52 - * hyperthread was specified in the interrupt desitination. 53 - */ 54 - cpumask_clear(retmask); 55 - cpumask_bits(retmask)[0] = APIC_ALL_CPUS; 56 - } 57 - 58 39 /* 59 40 * Set up the logical destination ID. 60 41 * ··· 73 92 } 74 93 75 94 static void 76 - flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) 95 + flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) 77 96 { 78 97 unsigned long mask = cpumask_bits(cpumask)[0]; 79 98 int cpu = smp_processor_id(); ··· 167 186 .irq_delivery_mode = dest_LowestPrio, 168 187 .irq_dest_mode = 1, /* logical */ 169 188 170 - .target_cpus = flat_target_cpus, 189 + .target_cpus = online_target_cpus, 171 190 .disable_esr = 0, 172 191 .dest_logical = APIC_DEST_LOGICAL, 173 192 .check_apicid_used = NULL, ··· 191 210 .set_apic_id = set_apic_id, 192 211 .apic_id_mask = 0xFFu << 24, 193 212 194 - .cpu_mask_to_apicid = default_cpu_mask_to_apicid, 195 - .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, 213 + .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, 196 214 197 215 .send_IPI_mask = flat_send_IPI_mask, 198 216 .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself, ··· 242 262 return 0; 243 263 } 244 264 245 - static const struct cpumask *physflat_target_cpus(void) 246 - { 247 - return cpu_online_mask; 248 - } 249 - 250 - static void physflat_vector_allocation_domain(int cpu, struct cpumask *retmask) 251 - { 252 - cpumask_clear(retmask); 253 - cpumask_set_cpu(cpu, retmask); 254 - } 255 - 256 265 static void physflat_send_IPI_mask(const struct cpumask *cpumask, int vector) 257 266 { 258 267 default_send_IPI_mask_sequence_phys(cpumask, vector); ··· 263 294 physflat_send_IPI_mask(cpu_online_mask, vector); 264 295 } 265 296 266 - static unsigned int physflat_cpu_mask_to_apicid(const struct cpumask *cpumask) 267 - { 268 - int cpu; 269 - 270 - /* 271 - * We're using fixed IRQ delivery, can only return one phys APIC ID. 272 - * May as well be the first. 273 - */ 274 - cpu = cpumask_first(cpumask); 275 - if ((unsigned)cpu < nr_cpu_ids) 276 - return per_cpu(x86_cpu_to_apicid, cpu); 277 - else 278 - return BAD_APICID; 279 - } 280 - 281 - static unsigned int 282 - physflat_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 283 - const struct cpumask *andmask) 284 - { 285 - int cpu; 286 - 287 - /* 288 - * We're using fixed IRQ delivery, can only return one phys APIC ID. 289 - * May as well be the first. 290 - */ 291 - for_each_cpu_and(cpu, cpumask, andmask) { 292 - if (cpumask_test_cpu(cpu, cpu_online_mask)) 293 - break; 294 - } 295 - return per_cpu(x86_cpu_to_apicid, cpu); 296 - } 297 - 298 297 static int physflat_probe(void) 299 298 { 300 299 if (apic == &apic_physflat || num_possible_cpus() > 8) ··· 282 345 .irq_delivery_mode = dest_Fixed, 283 346 .irq_dest_mode = 0, /* physical */ 284 347 285 - .target_cpus = physflat_target_cpus, 348 + .target_cpus = online_target_cpus, 286 349 .disable_esr = 0, 287 350 .dest_logical = 0, 288 351 .check_apicid_used = NULL, 289 352 .check_apicid_present = NULL, 290 353 291 - .vector_allocation_domain = physflat_vector_allocation_domain, 354 + .vector_allocation_domain = default_vector_allocation_domain, 292 355 /* not needed, but shouldn't hurt: */ 293 356 .init_apic_ldr = flat_init_apic_ldr, 294 357 ··· 307 370 .set_apic_id = set_apic_id, 308 371 .apic_id_mask = 0xFFu << 24, 309 372 310 - .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, 311 - .cpu_mask_to_apicid_and = physflat_cpu_mask_to_apicid_and, 373 + .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, 312 374 313 375 .send_IPI_mask = physflat_send_IPI_mask, 314 376 .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself,
+4 -5
arch/x86/kernel/apic/apic_noop.c
··· 100 100 return physid_isset(bit, phys_cpu_present_map); 101 101 } 102 102 103 - static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask) 103 + static bool noop_vector_allocation_domain(int cpu, struct cpumask *retmask) 104 104 { 105 105 if (cpu != 0) 106 106 pr_warning("APIC: Vector allocated for non-BSP cpu\n"); 107 - cpumask_clear(retmask); 108 - cpumask_set_cpu(cpu, retmask); 107 + cpumask_copy(retmask, cpumask_of(cpu)); 108 + return true; 109 109 } 110 110 111 111 static u32 noop_apic_read(u32 reg) ··· 159 159 .set_apic_id = NULL, 160 160 .apic_id_mask = 0x0F << 24, 161 161 162 - .cpu_mask_to_apicid = default_cpu_mask_to_apicid, 163 - .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, 162 + .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, 164 163 165 164 .send_IPI_mask = noop_send_IPI_mask, 166 165 .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself,
+3 -47
arch/x86/kernel/apic/apic_numachip.c
··· 72 72 return initial_apic_id >> index_msb; 73 73 } 74 74 75 - static const struct cpumask *numachip_target_cpus(void) 76 - { 77 - return cpu_online_mask; 78 - } 79 - 80 - static void numachip_vector_allocation_domain(int cpu, struct cpumask *retmask) 81 - { 82 - cpumask_clear(retmask); 83 - cpumask_set_cpu(cpu, retmask); 84 - } 85 - 86 75 static int __cpuinit numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip) 87 76 { 88 77 union numachip_csr_g3_ext_irq_gen int_gen; ··· 146 157 __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); 147 158 } 148 159 149 - static unsigned int numachip_cpu_mask_to_apicid(const struct cpumask *cpumask) 150 - { 151 - int cpu; 152 - 153 - /* 154 - * We're using fixed IRQ delivery, can only return one phys APIC ID. 155 - * May as well be the first. 156 - */ 157 - cpu = cpumask_first(cpumask); 158 - if (likely((unsigned)cpu < nr_cpu_ids)) 159 - return per_cpu(x86_cpu_to_apicid, cpu); 160 - 161 - return BAD_APICID; 162 - } 163 - 164 - static unsigned int 165 - numachip_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 166 - const struct cpumask *andmask) 167 - { 168 - int cpu; 169 - 170 - /* 171 - * We're using fixed IRQ delivery, can only return one phys APIC ID. 172 - * May as well be the first. 173 - */ 174 - for_each_cpu_and(cpu, cpumask, andmask) { 175 - if (cpumask_test_cpu(cpu, cpu_online_mask)) 176 - break; 177 - } 178 - return per_cpu(x86_cpu_to_apicid, cpu); 179 - } 180 - 181 160 static int __init numachip_probe(void) 182 161 { 183 162 return apic == &apic_numachip; ··· 210 253 .irq_delivery_mode = dest_Fixed, 211 254 .irq_dest_mode = 0, /* physical */ 212 255 213 - .target_cpus = numachip_target_cpus, 256 + .target_cpus = online_target_cpus, 214 257 .disable_esr = 0, 215 258 .dest_logical = 0, 216 259 .check_apicid_used = NULL, 217 260 .check_apicid_present = NULL, 218 261 219 - .vector_allocation_domain = numachip_vector_allocation_domain, 262 + .vector_allocation_domain = default_vector_allocation_domain, 220 263 .init_apic_ldr = flat_init_apic_ldr, 221 264 222 265 .ioapic_phys_id_map = NULL, ··· 234 277 .set_apic_id = set_apic_id, 235 278 .apic_id_mask = 0xffU << 24, 236 279 237 - .cpu_mask_to_apicid = numachip_cpu_mask_to_apicid, 238 - .cpu_mask_to_apicid_and = numachip_cpu_mask_to_apicid_and, 280 + .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, 239 281 240 282 .send_IPI_mask = numachip_send_IPI_mask, 241 283 .send_IPI_mask_allbutself = numachip_send_IPI_mask_allbutself,
+3 -45
arch/x86/kernel/apic/bigsmp_32.c
··· 26 26 return 1; 27 27 } 28 28 29 - static const struct cpumask *bigsmp_target_cpus(void) 30 - { 31 - #ifdef CONFIG_SMP 32 - return cpu_online_mask; 33 - #else 34 - return cpumask_of(0); 35 - #endif 36 - } 37 - 38 29 static unsigned long bigsmp_check_apicid_used(physid_mask_t *map, int apicid) 39 30 { 40 31 return 0; ··· 96 105 return 1; 97 106 } 98 107 99 - /* As we are using single CPU as destination, pick only one CPU here */ 100 - static unsigned int bigsmp_cpu_mask_to_apicid(const struct cpumask *cpumask) 101 - { 102 - int cpu = cpumask_first(cpumask); 103 - 104 - if (cpu < nr_cpu_ids) 105 - return cpu_physical_id(cpu); 106 - return BAD_APICID; 107 - } 108 - 109 - static unsigned int bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 110 - const struct cpumask *andmask) 111 - { 112 - int cpu; 113 - 114 - /* 115 - * We're using fixed IRQ delivery, can only return one phys APIC ID. 116 - * May as well be the first. 117 - */ 118 - for_each_cpu_and(cpu, cpumask, andmask) { 119 - if (cpumask_test_cpu(cpu, cpu_online_mask)) 120 - return cpu_physical_id(cpu); 121 - } 122 - return BAD_APICID; 123 - } 124 - 125 108 static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb) 126 109 { 127 110 return cpuid_apic >> index_msb; ··· 142 177 { } /* NULL entry stops DMI scanning */ 143 178 }; 144 179 145 - static void bigsmp_vector_allocation_domain(int cpu, struct cpumask *retmask) 146 - { 147 - cpumask_clear(retmask); 148 - cpumask_set_cpu(cpu, retmask); 149 - } 150 - 151 180 static int probe_bigsmp(void) 152 181 { 153 182 if (def_to_bigsmp) ··· 164 205 /* phys delivery to target CPU: */ 165 206 .irq_dest_mode = 0, 166 207 167 - .target_cpus = bigsmp_target_cpus, 208 + .target_cpus = default_target_cpus, 168 209 .disable_esr = 1, 169 210 .dest_logical = 0, 170 211 .check_apicid_used = bigsmp_check_apicid_used, 171 212 .check_apicid_present = bigsmp_check_apicid_present, 172 213 173 - .vector_allocation_domain = bigsmp_vector_allocation_domain, 214 + .vector_allocation_domain = default_vector_allocation_domain, 174 215 .init_apic_ldr = bigsmp_init_apic_ldr, 175 216 176 217 .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map, ··· 188 229 .set_apic_id = NULL, 189 230 .apic_id_mask = 0xFF << 24, 190 231 191 - .cpu_mask_to_apicid = bigsmp_cpu_mask_to_apicid, 192 - .cpu_mask_to_apicid_and = bigsmp_cpu_mask_to_apicid_and, 232 + .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, 193 233 194 234 .send_IPI_mask = bigsmp_send_IPI_mask, 195 235 .send_IPI_mask_allbutself = NULL,
+19 -32
arch/x86/kernel/apic/es7000_32.c
··· 394 394 WARN(1, "Command failed, status = %x\n", mip_status); 395 395 } 396 396 397 - static void es7000_vector_allocation_domain(int cpu, struct cpumask *retmask) 398 - { 399 - /* Careful. Some cpus do not strictly honor the set of cpus 400 - * specified in the interrupt destination when using lowest 401 - * priority interrupt delivery mode. 402 - * 403 - * In particular there was a hyperthreading cpu observed to 404 - * deliver interrupts to the wrong hyperthread when only one 405 - * hyperthread was specified in the interrupt desitination. 406 - */ 407 - cpumask_clear(retmask); 408 - cpumask_bits(retmask)[0] = APIC_ALL_CPUS; 409 - } 410 - 411 - 412 397 static void es7000_wait_for_init_deassert(atomic_t *deassert) 413 398 { 414 399 while (!atomic_read(deassert)) ··· 525 540 return 1; 526 541 } 527 542 528 - static unsigned int es7000_cpu_mask_to_apicid(const struct cpumask *cpumask) 543 + static inline int 544 + es7000_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id) 529 545 { 530 546 unsigned int round = 0; 531 - int cpu, uninitialized_var(apicid); 547 + unsigned int cpu, uninitialized_var(apicid); 532 548 533 549 /* 534 550 * The cpus in the mask must all be on the apic cluster. 535 551 */ 536 - for_each_cpu(cpu, cpumask) { 552 + for_each_cpu_and(cpu, cpumask, cpu_online_mask) { 537 553 int new_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu); 538 554 539 555 if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) { 540 556 WARN(1, "Not a valid mask!"); 541 557 542 - return BAD_APICID; 558 + return -EINVAL; 543 559 } 544 - apicid = new_apicid; 560 + apicid |= new_apicid; 545 561 round++; 546 562 } 547 - return apicid; 563 + if (!round) 564 + return -EINVAL; 565 + *dest_id = apicid; 566 + return 0; 548 567 } 549 568 550 - static unsigned int 569 + static int 551 570 es7000_cpu_mask_to_apicid_and(const struct cpumask *inmask, 552 - const struct cpumask *andmask) 571 + const struct cpumask *andmask, 572 + unsigned int *apicid) 553 573 { 554 - int apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0); 555 574 cpumask_var_t cpumask; 575 + *apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0); 556 576 557 577 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC)) 558 - return apicid; 578 + return 0; 559 579 560 580 cpumask_and(cpumask, inmask, andmask); 561 - cpumask_and(cpumask, cpumask, cpu_online_mask); 562 - apicid = es7000_cpu_mask_to_apicid(cpumask); 581 + es7000_cpu_mask_to_apicid(cpumask, apicid); 563 582 564 583 free_cpumask_var(cpumask); 565 584 566 - return apicid; 585 + return 0; 567 586 } 568 587 569 588 static int es7000_phys_pkg_id(int cpuid_apic, int index_msb) ··· 627 638 .check_apicid_used = es7000_check_apicid_used, 628 639 .check_apicid_present = es7000_check_apicid_present, 629 640 630 - .vector_allocation_domain = es7000_vector_allocation_domain, 641 + .vector_allocation_domain = flat_vector_allocation_domain, 631 642 .init_apic_ldr = es7000_init_apic_ldr_cluster, 632 643 633 644 .ioapic_phys_id_map = es7000_ioapic_phys_id_map, ··· 645 656 .set_apic_id = NULL, 646 657 .apic_id_mask = 0xFF << 24, 647 658 648 - .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid, 649 659 .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, 650 660 651 661 .send_IPI_mask = es7000_send_IPI_mask, ··· 693 705 .check_apicid_used = es7000_check_apicid_used, 694 706 .check_apicid_present = es7000_check_apicid_present, 695 707 696 - .vector_allocation_domain = es7000_vector_allocation_domain, 708 + .vector_allocation_domain = flat_vector_allocation_domain, 697 709 .init_apic_ldr = es7000_init_apic_ldr, 698 710 699 711 .ioapic_phys_id_map = es7000_ioapic_phys_id_map, ··· 711 723 .set_apic_id = NULL, 712 724 .apic_id_mask = 0xFF << 24, 713 725 714 - .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid, 715 726 .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, 716 727 717 728 .send_IPI_mask = es7000_send_IPI_mask,
+150 -138
arch/x86/kernel/apic/io_apic.c
··· 1112 1112 * 0x80, because int 0x80 is hm, kind of importantish. ;) 1113 1113 */ 1114 1114 static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START; 1115 - static int current_offset = VECTOR_OFFSET_START % 8; 1115 + static int current_offset = VECTOR_OFFSET_START % 16; 1116 1116 unsigned int old_vector; 1117 1117 int cpu, err; 1118 1118 cpumask_var_t tmp_mask; ··· 1126 1126 old_vector = cfg->vector; 1127 1127 if (old_vector) { 1128 1128 cpumask_and(tmp_mask, mask, cpu_online_mask); 1129 - cpumask_and(tmp_mask, cfg->domain, tmp_mask); 1130 - if (!cpumask_empty(tmp_mask)) { 1129 + if (cpumask_subset(tmp_mask, cfg->domain)) { 1131 1130 free_cpumask_var(tmp_mask); 1132 1131 return 0; 1133 1132 } ··· 1137 1138 for_each_cpu_and(cpu, mask, cpu_online_mask) { 1138 1139 int new_cpu; 1139 1140 int vector, offset; 1141 + bool more_domains; 1140 1142 1141 - apic->vector_allocation_domain(cpu, tmp_mask); 1143 + more_domains = apic->vector_allocation_domain(cpu, tmp_mask); 1144 + 1145 + if (cpumask_subset(tmp_mask, cfg->domain)) { 1146 + free_cpumask_var(tmp_mask); 1147 + return 0; 1148 + } 1142 1149 1143 1150 vector = current_vector; 1144 1151 offset = current_offset; 1145 1152 next: 1146 - vector += 8; 1153 + vector += 16; 1147 1154 if (vector >= first_system_vector) { 1148 - /* If out of vectors on large boxen, must share them. */ 1149 - offset = (offset + 1) % 8; 1155 + offset = (offset + 1) % 16; 1150 1156 vector = FIRST_EXTERNAL_VECTOR + offset; 1151 1157 } 1152 - if (unlikely(current_vector == vector)) 1153 - continue; 1158 + 1159 + if (unlikely(current_vector == vector)) { 1160 + if (more_domains) 1161 + continue; 1162 + else 1163 + break; 1164 + } 1154 1165 1155 1166 if (test_bit(vector, used_vectors)) 1156 1167 goto next; ··· 1355 1346 1356 1347 if (!IO_APIC_IRQ(irq)) 1357 1348 return; 1358 - /* 1359 - * For legacy irqs, cfg->domain starts with cpu 0 for legacy 1360 - * controllers like 8259. Now that IO-APIC can handle this irq, update 1361 - * the cfg->domain. 1362 - */ 1363 - if (irq < legacy_pic->nr_legacy_irqs && cpumask_test_cpu(0, cfg->domain)) 1364 - apic->vector_allocation_domain(0, cfg->domain); 1365 1349 1366 1350 if (assign_irq_vector(irq, cfg, apic->target_cpus())) 1367 1351 return; 1368 1352 1369 - dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); 1353 + if (apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus(), 1354 + &dest)) { 1355 + pr_warn("Failed to obtain apicid for ioapic %d, pin %d\n", 1356 + mpc_ioapic_id(attr->ioapic), attr->ioapic_pin); 1357 + __clear_irq_vector(irq, cfg); 1358 + 1359 + return; 1360 + } 1370 1361 1371 1362 apic_printk(APIC_VERBOSE,KERN_DEBUG 1372 1363 "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> " ··· 1375 1366 cfg->vector, irq, attr->trigger, attr->polarity, dest); 1376 1367 1377 1368 if (setup_ioapic_entry(irq, &entry, dest, cfg->vector, attr)) { 1378 - pr_warn("Failed to setup ioapic entry for ioapic %d, pin %d\n", 1369 + pr_warn("Failed to setup ioapic entry for ioapic %d, pin %d\n", 1379 1370 mpc_ioapic_id(attr->ioapic), attr->ioapic_pin); 1380 1371 __clear_irq_vector(irq, cfg); 1381 1372 ··· 1478 1469 * Set up the timer pin, possibly with the 8259A-master behind. 1479 1470 */ 1480 1471 static void __init setup_timer_IRQ0_pin(unsigned int ioapic_idx, 1481 - unsigned int pin, int vector) 1472 + unsigned int pin, int vector) 1482 1473 { 1483 1474 struct IO_APIC_route_entry entry; 1475 + unsigned int dest; 1484 1476 1485 1477 if (irq_remapping_enabled) 1486 1478 return; ··· 1492 1482 * We use logical delivery to get the timer IRQ 1493 1483 * to the first CPU. 1494 1484 */ 1485 + if (unlikely(apic->cpu_mask_to_apicid_and(apic->target_cpus(), 1486 + apic->target_cpus(), &dest))) 1487 + dest = BAD_APICID; 1488 + 1495 1489 entry.dest_mode = apic->irq_dest_mode; 1496 1490 entry.mask = 0; /* don't mask IRQ for edge */ 1497 - entry.dest = apic->cpu_mask_to_apicid(apic->target_cpus()); 1491 + entry.dest = dest; 1498 1492 entry.delivery_mode = apic->irq_delivery_mode; 1499 1493 entry.polarity = 0; 1500 1494 entry.trigger = 0; ··· 2224 2210 cfg->move_in_progress = 0; 2225 2211 } 2226 2212 2227 - static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq_cfg *cfg) 2228 - { 2229 - int apic, pin; 2230 - struct irq_pin_list *entry; 2231 - u8 vector = cfg->vector; 2232 - 2233 - for_each_irq_pin(entry, cfg->irq_2_pin) { 2234 - unsigned int reg; 2235 - 2236 - apic = entry->apic; 2237 - pin = entry->pin; 2238 - /* 2239 - * With interrupt-remapping, destination information comes 2240 - * from interrupt-remapping table entry. 2241 - */ 2242 - if (!irq_remapped(cfg)) 2243 - io_apic_write(apic, 0x11 + pin*2, dest); 2244 - reg = io_apic_read(apic, 0x10 + pin*2); 2245 - reg &= ~IO_APIC_REDIR_VECTOR_MASK; 2246 - reg |= vector; 2247 - io_apic_modify(apic, 0x10 + pin*2, reg); 2248 - } 2249 - } 2250 - 2251 - /* 2252 - * Either sets data->affinity to a valid value, and returns 2253 - * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and 2254 - * leaves data->affinity untouched. 2255 - */ 2256 - int __ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask, 2257 - unsigned int *dest_id) 2258 - { 2259 - struct irq_cfg *cfg = data->chip_data; 2260 - 2261 - if (!cpumask_intersects(mask, cpu_online_mask)) 2262 - return -1; 2263 - 2264 - if (assign_irq_vector(data->irq, data->chip_data, mask)) 2265 - return -1; 2266 - 2267 - cpumask_copy(data->affinity, mask); 2268 - 2269 - *dest_id = apic->cpu_mask_to_apicid_and(mask, cfg->domain); 2270 - return 0; 2271 - } 2272 - 2273 - static int 2274 - ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask, 2275 - bool force) 2276 - { 2277 - unsigned int dest, irq = data->irq; 2278 - unsigned long flags; 2279 - int ret; 2280 - 2281 - raw_spin_lock_irqsave(&ioapic_lock, flags); 2282 - ret = __ioapic_set_affinity(data, mask, &dest); 2283 - if (!ret) { 2284 - /* Only the high 8 bits are valid. */ 2285 - dest = SET_APIC_LOGICAL_ID(dest); 2286 - __target_IO_APIC_irq(irq, dest, data->chip_data); 2287 - } 2288 - raw_spin_unlock_irqrestore(&ioapic_lock, flags); 2289 - return ret; 2290 - } 2291 - 2292 2213 asmlinkage void smp_irq_move_cleanup_interrupt(void) 2293 2214 { 2294 2215 unsigned vector, me; ··· 2310 2361 #else 2311 2362 static inline void irq_complete_move(struct irq_cfg *cfg) { } 2312 2363 #endif 2364 + 2365 + static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq_cfg *cfg) 2366 + { 2367 + int apic, pin; 2368 + struct irq_pin_list *entry; 2369 + u8 vector = cfg->vector; 2370 + 2371 + for_each_irq_pin(entry, cfg->irq_2_pin) { 2372 + unsigned int reg; 2373 + 2374 + apic = entry->apic; 2375 + pin = entry->pin; 2376 + /* 2377 + * With interrupt-remapping, destination information comes 2378 + * from interrupt-remapping table entry. 2379 + */ 2380 + if (!irq_remapped(cfg)) 2381 + io_apic_write(apic, 0x11 + pin*2, dest); 2382 + reg = io_apic_read(apic, 0x10 + pin*2); 2383 + reg &= ~IO_APIC_REDIR_VECTOR_MASK; 2384 + reg |= vector; 2385 + io_apic_modify(apic, 0x10 + pin*2, reg); 2386 + } 2387 + } 2388 + 2389 + /* 2390 + * Either sets data->affinity to a valid value, and returns 2391 + * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and 2392 + * leaves data->affinity untouched. 2393 + */ 2394 + int __ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask, 2395 + unsigned int *dest_id) 2396 + { 2397 + struct irq_cfg *cfg = data->chip_data; 2398 + unsigned int irq = data->irq; 2399 + int err; 2400 + 2401 + if (!config_enabled(CONFIG_SMP)) 2402 + return -1; 2403 + 2404 + if (!cpumask_intersects(mask, cpu_online_mask)) 2405 + return -EINVAL; 2406 + 2407 + err = assign_irq_vector(irq, cfg, mask); 2408 + if (err) 2409 + return err; 2410 + 2411 + err = apic->cpu_mask_to_apicid_and(mask, cfg->domain, dest_id); 2412 + if (err) { 2413 + if (assign_irq_vector(irq, cfg, data->affinity)) 2414 + pr_err("Failed to recover vector for irq %d\n", irq); 2415 + return err; 2416 + } 2417 + 2418 + cpumask_copy(data->affinity, mask); 2419 + 2420 + return 0; 2421 + } 2422 + 2423 + static int 2424 + ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask, 2425 + bool force) 2426 + { 2427 + unsigned int dest, irq = data->irq; 2428 + unsigned long flags; 2429 + int ret; 2430 + 2431 + if (!config_enabled(CONFIG_SMP)) 2432 + return -1; 2433 + 2434 + raw_spin_lock_irqsave(&ioapic_lock, flags); 2435 + ret = __ioapic_set_affinity(data, mask, &dest); 2436 + if (!ret) { 2437 + /* Only the high 8 bits are valid. */ 2438 + dest = SET_APIC_LOGICAL_ID(dest); 2439 + __target_IO_APIC_irq(irq, dest, data->chip_data); 2440 + ret = IRQ_SET_MASK_OK_NOCOPY; 2441 + } 2442 + raw_spin_unlock_irqrestore(&ioapic_lock, flags); 2443 + return ret; 2444 + } 2313 2445 2314 2446 static void ack_apic_edge(struct irq_data *data) 2315 2447 { ··· 2571 2541 chip->irq_ack = ir_ack_apic_edge; 2572 2542 chip->irq_eoi = ir_ack_apic_level; 2573 2543 2574 - #ifdef CONFIG_SMP 2575 2544 chip->irq_set_affinity = set_remapped_irq_affinity; 2576 - #endif 2577 2545 } 2578 2546 #endif /* CONFIG_IRQ_REMAP */ 2579 2547 ··· 2582 2554 .irq_unmask = unmask_ioapic_irq, 2583 2555 .irq_ack = ack_apic_edge, 2584 2556 .irq_eoi = ack_apic_level, 2585 - #ifdef CONFIG_SMP 2586 2557 .irq_set_affinity = ioapic_set_affinity, 2587 - #endif 2588 2558 .irq_retrigger = ioapic_retrigger_irq, 2589 2559 }; 2590 2560 ··· 3064 3038 if (err) 3065 3039 return err; 3066 3040 3067 - dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); 3041 + err = apic->cpu_mask_to_apicid_and(cfg->domain, 3042 + apic->target_cpus(), &dest); 3043 + if (err) 3044 + return err; 3068 3045 3069 3046 if (irq_remapped(cfg)) { 3070 3047 compose_remapped_msi_msg(pdev, irq, dest, msg, hpet_id); ··· 3101 3072 return err; 3102 3073 } 3103 3074 3104 - #ifdef CONFIG_SMP 3105 3075 static int 3106 3076 msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force) 3107 3077 { ··· 3120 3092 3121 3093 __write_msi_msg(data->msi_desc, &msg); 3122 3094 3123 - return 0; 3095 + return IRQ_SET_MASK_OK_NOCOPY; 3124 3096 } 3125 - #endif /* CONFIG_SMP */ 3126 3097 3127 3098 /* 3128 3099 * IRQ Chip for MSI PCI/PCI-X/PCI-Express Devices, ··· 3132 3105 .irq_unmask = unmask_msi_irq, 3133 3106 .irq_mask = mask_msi_irq, 3134 3107 .irq_ack = ack_apic_edge, 3135 - #ifdef CONFIG_SMP 3136 3108 .irq_set_affinity = msi_set_affinity, 3137 - #endif 3138 3109 .irq_retrigger = ioapic_retrigger_irq, 3139 3110 }; 3140 3111 ··· 3217 3192 } 3218 3193 3219 3194 #ifdef CONFIG_DMAR_TABLE 3220 - #ifdef CONFIG_SMP 3221 3195 static int 3222 3196 dmar_msi_set_affinity(struct irq_data *data, const struct cpumask *mask, 3223 3197 bool force) ··· 3238 3214 3239 3215 dmar_msi_write(irq, &msg); 3240 3216 3241 - return 0; 3217 + return IRQ_SET_MASK_OK_NOCOPY; 3242 3218 } 3243 - 3244 - #endif /* CONFIG_SMP */ 3245 3219 3246 3220 static struct irq_chip dmar_msi_type = { 3247 3221 .name = "DMAR_MSI", 3248 3222 .irq_unmask = dmar_msi_unmask, 3249 3223 .irq_mask = dmar_msi_mask, 3250 3224 .irq_ack = ack_apic_edge, 3251 - #ifdef CONFIG_SMP 3252 3225 .irq_set_affinity = dmar_msi_set_affinity, 3253 - #endif 3254 3226 .irq_retrigger = ioapic_retrigger_irq, 3255 3227 }; 3256 3228 ··· 3267 3247 3268 3248 #ifdef CONFIG_HPET_TIMER 3269 3249 3270 - #ifdef CONFIG_SMP 3271 3250 static int hpet_msi_set_affinity(struct irq_data *data, 3272 3251 const struct cpumask *mask, bool force) 3273 3252 { ··· 3286 3267 3287 3268 hpet_msi_write(data->handler_data, &msg); 3288 3269 3289 - return 0; 3270 + return IRQ_SET_MASK_OK_NOCOPY; 3290 3271 } 3291 - 3292 - #endif /* CONFIG_SMP */ 3293 3272 3294 3273 static struct irq_chip hpet_msi_type = { 3295 3274 .name = "HPET_MSI", 3296 3275 .irq_unmask = hpet_msi_unmask, 3297 3276 .irq_mask = hpet_msi_mask, 3298 3277 .irq_ack = ack_apic_edge, 3299 - #ifdef CONFIG_SMP 3300 3278 .irq_set_affinity = hpet_msi_set_affinity, 3301 - #endif 3302 3279 .irq_retrigger = ioapic_retrigger_irq, 3303 3280 }; 3304 3281 ··· 3329 3314 */ 3330 3315 #ifdef CONFIG_HT_IRQ 3331 3316 3332 - #ifdef CONFIG_SMP 3333 - 3334 3317 static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector) 3335 3318 { 3336 3319 struct ht_irq_msg msg; ··· 3353 3340 return -1; 3354 3341 3355 3342 target_ht_irq(data->irq, dest, cfg->vector); 3356 - return 0; 3343 + return IRQ_SET_MASK_OK_NOCOPY; 3357 3344 } 3358 - 3359 - #endif 3360 3345 3361 3346 static struct irq_chip ht_irq_chip = { 3362 3347 .name = "PCI-HT", 3363 3348 .irq_mask = mask_ht_irq, 3364 3349 .irq_unmask = unmask_ht_irq, 3365 3350 .irq_ack = ack_apic_edge, 3366 - #ifdef CONFIG_SMP 3367 3351 .irq_set_affinity = ht_set_affinity, 3368 - #endif 3369 3352 .irq_retrigger = ioapic_retrigger_irq, 3370 3353 }; 3371 3354 3372 3355 int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev) 3373 3356 { 3374 3357 struct irq_cfg *cfg; 3358 + struct ht_irq_msg msg; 3359 + unsigned dest; 3375 3360 int err; 3376 3361 3377 3362 if (disable_apic) ··· 3377 3366 3378 3367 cfg = irq_cfg(irq); 3379 3368 err = assign_irq_vector(irq, cfg, apic->target_cpus()); 3380 - if (!err) { 3381 - struct ht_irq_msg msg; 3382 - unsigned dest; 3369 + if (err) 3370 + return err; 3383 3371 3384 - dest = apic->cpu_mask_to_apicid_and(cfg->domain, 3385 - apic->target_cpus()); 3372 + err = apic->cpu_mask_to_apicid_and(cfg->domain, 3373 + apic->target_cpus(), &dest); 3374 + if (err) 3375 + return err; 3386 3376 3387 - msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest); 3377 + msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest); 3388 3378 3389 - msg.address_lo = 3390 - HT_IRQ_LOW_BASE | 3391 - HT_IRQ_LOW_DEST_ID(dest) | 3392 - HT_IRQ_LOW_VECTOR(cfg->vector) | 3393 - ((apic->irq_dest_mode == 0) ? 3394 - HT_IRQ_LOW_DM_PHYSICAL : 3395 - HT_IRQ_LOW_DM_LOGICAL) | 3396 - HT_IRQ_LOW_RQEOI_EDGE | 3397 - ((apic->irq_delivery_mode != dest_LowestPrio) ? 3398 - HT_IRQ_LOW_MT_FIXED : 3399 - HT_IRQ_LOW_MT_ARBITRATED) | 3400 - HT_IRQ_LOW_IRQ_MASKED; 3379 + msg.address_lo = 3380 + HT_IRQ_LOW_BASE | 3381 + HT_IRQ_LOW_DEST_ID(dest) | 3382 + HT_IRQ_LOW_VECTOR(cfg->vector) | 3383 + ((apic->irq_dest_mode == 0) ? 3384 + HT_IRQ_LOW_DM_PHYSICAL : 3385 + HT_IRQ_LOW_DM_LOGICAL) | 3386 + HT_IRQ_LOW_RQEOI_EDGE | 3387 + ((apic->irq_delivery_mode != dest_LowestPrio) ? 3388 + HT_IRQ_LOW_MT_FIXED : 3389 + HT_IRQ_LOW_MT_ARBITRATED) | 3390 + HT_IRQ_LOW_IRQ_MASKED; 3401 3391 3402 - write_ht_irq_msg(irq, &msg); 3392 + write_ht_irq_msg(irq, &msg); 3403 3393 3404 - irq_set_chip_and_handler_name(irq, &ht_irq_chip, 3405 - handle_edge_irq, "edge"); 3394 + irq_set_chip_and_handler_name(irq, &ht_irq_chip, 3395 + handle_edge_irq, "edge"); 3406 3396 3407 - dev_printk(KERN_DEBUG, &dev->dev, "irq %d for HT\n", irq); 3408 - } 3409 - return err; 3397 + dev_printk(KERN_DEBUG, &dev->dev, "irq %d for HT\n", irq); 3398 + 3399 + return 0; 3410 3400 } 3411 3401 #endif /* CONFIG_HT_IRQ */ 3412 3402
+6 -24
arch/x86/kernel/apic/numaq_32.c
··· 406 406 * We use physical apicids here, not logical, so just return the default 407 407 * physical broadcast to stop people from breaking us 408 408 */ 409 - static unsigned int numaq_cpu_mask_to_apicid(const struct cpumask *cpumask) 410 - { 411 - return 0x0F; 412 - } 413 - 414 - static inline unsigned int 409 + static int 415 410 numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 416 - const struct cpumask *andmask) 411 + const struct cpumask *andmask, 412 + unsigned int *apicid) 417 413 { 418 - return 0x0F; 414 + *apicid = 0x0F; 415 + return 0; 419 416 } 420 417 421 418 /* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */ ··· 436 439 { 437 440 /* already know from get_memcfg_numaq() */ 438 441 return found_numaq; 439 - } 440 - 441 - static void numaq_vector_allocation_domain(int cpu, struct cpumask *retmask) 442 - { 443 - /* Careful. Some cpus do not strictly honor the set of cpus 444 - * specified in the interrupt destination when using lowest 445 - * priority interrupt delivery mode. 446 - * 447 - * In particular there was a hyperthreading cpu observed to 448 - * deliver interrupts to the wrong hyperthread when only one 449 - * hyperthread was specified in the interrupt desitination. 450 - */ 451 - cpumask_clear(retmask); 452 - cpumask_bits(retmask)[0] = APIC_ALL_CPUS; 453 442 } 454 443 455 444 static void numaq_setup_portio_remap(void) ··· 474 491 .check_apicid_used = numaq_check_apicid_used, 475 492 .check_apicid_present = numaq_check_apicid_present, 476 493 477 - .vector_allocation_domain = numaq_vector_allocation_domain, 494 + .vector_allocation_domain = flat_vector_allocation_domain, 478 495 .init_apic_ldr = numaq_init_apic_ldr, 479 496 480 497 .ioapic_phys_id_map = numaq_ioapic_phys_id_map, ··· 492 509 .set_apic_id = NULL, 493 510 .apic_id_mask = 0x0F << 24, 494 511 495 - .cpu_mask_to_apicid = numaq_cpu_mask_to_apicid, 496 512 .cpu_mask_to_apicid_and = numaq_cpu_mask_to_apicid_and, 497 513 498 514 .send_IPI_mask = numaq_send_IPI_mask,
+2 -18
arch/x86/kernel/apic/probe_32.c
··· 66 66 #endif 67 67 } 68 68 69 - static void default_vector_allocation_domain(int cpu, struct cpumask *retmask) 70 - { 71 - /* 72 - * Careful. Some cpus do not strictly honor the set of cpus 73 - * specified in the interrupt destination when using lowest 74 - * priority interrupt delivery mode. 75 - * 76 - * In particular there was a hyperthreading cpu observed to 77 - * deliver interrupts to the wrong hyperthread when only one 78 - * hyperthread was specified in the interrupt desitination. 79 - */ 80 - cpumask_clear(retmask); 81 - cpumask_bits(retmask)[0] = APIC_ALL_CPUS; 82 - } 83 - 84 69 /* should be called last. */ 85 70 static int probe_default(void) 86 71 { ··· 90 105 .check_apicid_used = default_check_apicid_used, 91 106 .check_apicid_present = default_check_apicid_present, 92 107 93 - .vector_allocation_domain = default_vector_allocation_domain, 108 + .vector_allocation_domain = flat_vector_allocation_domain, 94 109 .init_apic_ldr = default_init_apic_ldr, 95 110 96 111 .ioapic_phys_id_map = default_ioapic_phys_id_map, ··· 108 123 .set_apic_id = NULL, 109 124 .apic_id_mask = 0x0F << 24, 110 125 111 - .cpu_mask_to_apicid = default_cpu_mask_to_apicid, 112 - .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, 126 + .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, 113 127 114 128 .send_IPI_mask = default_send_IPI_mask_logical, 115 129 .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical,
+18 -28
arch/x86/kernel/apic/summit_32.c
··· 263 263 return 1; 264 264 } 265 265 266 - static unsigned int summit_cpu_mask_to_apicid(const struct cpumask *cpumask) 266 + static inline int 267 + summit_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id) 267 268 { 268 269 unsigned int round = 0; 269 - int cpu, apicid = 0; 270 + unsigned int cpu, apicid = 0; 270 271 271 272 /* 272 273 * The cpus in the mask must all be on the apic cluster. 273 274 */ 274 - for_each_cpu(cpu, cpumask) { 275 + for_each_cpu_and(cpu, cpumask, cpu_online_mask) { 275 276 int new_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu); 276 277 277 278 if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) { 278 279 printk("%s: Not a valid mask!\n", __func__); 279 - return BAD_APICID; 280 + return -EINVAL; 280 281 } 281 282 apicid |= new_apicid; 282 283 round++; 283 284 } 284 - return apicid; 285 + if (!round) 286 + return -EINVAL; 287 + *dest_id = apicid; 288 + return 0; 285 289 } 286 290 287 - static unsigned int summit_cpu_mask_to_apicid_and(const struct cpumask *inmask, 288 - const struct cpumask *andmask) 291 + static int 292 + summit_cpu_mask_to_apicid_and(const struct cpumask *inmask, 293 + const struct cpumask *andmask, 294 + unsigned int *apicid) 289 295 { 290 - int apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0); 291 296 cpumask_var_t cpumask; 297 + *apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0); 292 298 293 299 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC)) 294 - return apicid; 300 + return 0; 295 301 296 302 cpumask_and(cpumask, inmask, andmask); 297 - cpumask_and(cpumask, cpumask, cpu_online_mask); 298 - apicid = summit_cpu_mask_to_apicid(cpumask); 303 + summit_cpu_mask_to_apicid(cpumask, apicid); 299 304 300 305 free_cpumask_var(cpumask); 301 306 302 - return apicid; 307 + return 0; 303 308 } 304 309 305 310 /* ··· 323 318 { 324 319 /* probed later in mptable/ACPI hooks */ 325 320 return 0; 326 - } 327 - 328 - static void summit_vector_allocation_domain(int cpu, struct cpumask *retmask) 329 - { 330 - /* Careful. Some cpus do not strictly honor the set of cpus 331 - * specified in the interrupt destination when using lowest 332 - * priority interrupt delivery mode. 333 - * 334 - * In particular there was a hyperthreading cpu observed to 335 - * deliver interrupts to the wrong hyperthread when only one 336 - * hyperthread was specified in the interrupt desitination. 337 - */ 338 - cpumask_clear(retmask); 339 - cpumask_bits(retmask)[0] = APIC_ALL_CPUS; 340 321 } 341 322 342 323 #ifdef CONFIG_X86_SUMMIT_NUMA ··· 500 509 .check_apicid_used = summit_check_apicid_used, 501 510 .check_apicid_present = summit_check_apicid_present, 502 511 503 - .vector_allocation_domain = summit_vector_allocation_domain, 512 + .vector_allocation_domain = flat_vector_allocation_domain, 504 513 .init_apic_ldr = summit_init_apic_ldr, 505 514 506 515 .ioapic_phys_id_map = summit_ioapic_phys_id_map, ··· 518 527 .set_apic_id = NULL, 519 528 .apic_id_mask = 0xFF << 24, 520 529 521 - .cpu_mask_to_apicid = summit_cpu_mask_to_apicid, 522 530 .cpu_mask_to_apicid_and = summit_cpu_mask_to_apicid_and, 523 531 524 532 .send_IPI_mask = summit_send_IPI_mask,
+39 -29
arch/x86/kernel/apic/x2apic_cluster.c
··· 81 81 } 82 82 83 83 static void 84 - x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) 84 + x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) 85 85 { 86 86 __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT); 87 87 } ··· 96 96 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC); 97 97 } 98 98 99 - static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) 100 - { 101 - /* 102 - * We're using fixed IRQ delivery, can only return one logical APIC ID. 103 - * May as well be the first. 104 - */ 105 - int cpu = cpumask_first(cpumask); 106 - 107 - if ((unsigned)cpu < nr_cpu_ids) 108 - return per_cpu(x86_cpu_to_logical_apicid, cpu); 109 - else 110 - return BAD_APICID; 111 - } 112 - 113 - static unsigned int 99 + static int 114 100 x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 115 - const struct cpumask *andmask) 101 + const struct cpumask *andmask, 102 + unsigned int *apicid) 116 103 { 117 - int cpu; 104 + u32 dest = 0; 105 + u16 cluster; 106 + int i; 118 107 119 - /* 120 - * We're using fixed IRQ delivery, can only return one logical APIC ID. 121 - * May as well be the first. 122 - */ 123 - for_each_cpu_and(cpu, cpumask, andmask) { 124 - if (cpumask_test_cpu(cpu, cpu_online_mask)) 125 - break; 108 + for_each_cpu_and(i, cpumask, andmask) { 109 + if (!cpumask_test_cpu(i, cpu_online_mask)) 110 + continue; 111 + dest = per_cpu(x86_cpu_to_logical_apicid, i); 112 + cluster = x2apic_cluster(i); 113 + break; 126 114 } 127 115 128 - return per_cpu(x86_cpu_to_logical_apicid, cpu); 116 + if (!dest) 117 + return -EINVAL; 118 + 119 + for_each_cpu_and(i, cpumask, andmask) { 120 + if (!cpumask_test_cpu(i, cpu_online_mask)) 121 + continue; 122 + if (cluster != x2apic_cluster(i)) 123 + continue; 124 + dest |= per_cpu(x86_cpu_to_logical_apicid, i); 125 + } 126 + 127 + *apicid = dest; 128 + 129 + return 0; 129 130 } 130 131 131 132 static void init_x2apic_ldr(void) ··· 209 208 return 0; 210 209 } 211 210 211 + /* 212 + * Each x2apic cluster is an allocation domain. 213 + */ 214 + static bool cluster_vector_allocation_domain(int cpu, struct cpumask *retmask) 215 + { 216 + cpumask_clear(retmask); 217 + cpumask_copy(retmask, per_cpu(cpus_in_cluster, cpu)); 218 + return true; 219 + } 220 + 212 221 static struct apic apic_x2apic_cluster = { 213 222 214 223 .name = "cluster x2apic", ··· 230 219 .irq_delivery_mode = dest_LowestPrio, 231 220 .irq_dest_mode = 1, /* logical */ 232 221 233 - .target_cpus = x2apic_target_cpus, 222 + .target_cpus = online_target_cpus, 234 223 .disable_esr = 0, 235 224 .dest_logical = APIC_DEST_LOGICAL, 236 225 .check_apicid_used = NULL, 237 226 .check_apicid_present = NULL, 238 227 239 - .vector_allocation_domain = x2apic_vector_allocation_domain, 228 + .vector_allocation_domain = cluster_vector_allocation_domain, 240 229 .init_apic_ldr = init_x2apic_ldr, 241 230 242 231 .ioapic_phys_id_map = NULL, ··· 254 243 .set_apic_id = x2apic_set_apic_id, 255 244 .apic_id_mask = 0xFFFFFFFFu, 256 245 257 - .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, 258 246 .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and, 259 247 260 248 .send_IPI_mask = x2apic_send_IPI_mask,
+3 -36
arch/x86/kernel/apic/x2apic_phys.c
··· 76 76 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC); 77 77 } 78 78 79 - static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) 80 - { 81 - /* 82 - * We're using fixed IRQ delivery, can only return one phys APIC ID. 83 - * May as well be the first. 84 - */ 85 - int cpu = cpumask_first(cpumask); 86 - 87 - if ((unsigned)cpu < nr_cpu_ids) 88 - return per_cpu(x86_cpu_to_apicid, cpu); 89 - else 90 - return BAD_APICID; 91 - } 92 - 93 - static unsigned int 94 - x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 95 - const struct cpumask *andmask) 96 - { 97 - int cpu; 98 - 99 - /* 100 - * We're using fixed IRQ delivery, can only return one phys APIC ID. 101 - * May as well be the first. 102 - */ 103 - for_each_cpu_and(cpu, cpumask, andmask) { 104 - if (cpumask_test_cpu(cpu, cpu_online_mask)) 105 - break; 106 - } 107 - 108 - return per_cpu(x86_cpu_to_apicid, cpu); 109 - } 110 - 111 79 static void init_x2apic_ldr(void) 112 80 { 113 81 } ··· 99 131 .irq_delivery_mode = dest_Fixed, 100 132 .irq_dest_mode = 0, /* physical */ 101 133 102 - .target_cpus = x2apic_target_cpus, 134 + .target_cpus = online_target_cpus, 103 135 .disable_esr = 0, 104 136 .dest_logical = 0, 105 137 .check_apicid_used = NULL, 106 138 .check_apicid_present = NULL, 107 139 108 - .vector_allocation_domain = x2apic_vector_allocation_domain, 140 + .vector_allocation_domain = default_vector_allocation_domain, 109 141 .init_apic_ldr = init_x2apic_ldr, 110 142 111 143 .ioapic_phys_id_map = NULL, ··· 123 155 .set_apic_id = x2apic_set_apic_id, 124 156 .apic_id_mask = 0xFFFFFFFFu, 125 157 126 - .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, 127 - .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and, 158 + .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, 128 159 129 160 .send_IPI_mask = x2apic_send_IPI_mask, 130 161 .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself,
+13 -32
arch/x86/kernel/apic/x2apic_uv_x.c
··· 185 185 unsigned long sn_rtc_cycles_per_second; 186 186 EXPORT_SYMBOL(sn_rtc_cycles_per_second); 187 187 188 - static const struct cpumask *uv_target_cpus(void) 189 - { 190 - return cpu_online_mask; 191 - } 192 - 193 - static void uv_vector_allocation_domain(int cpu, struct cpumask *retmask) 194 - { 195 - cpumask_clear(retmask); 196 - cpumask_set_cpu(cpu, retmask); 197 - } 198 - 199 188 static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_rip) 200 189 { 201 190 #ifdef CONFIG_SMP ··· 269 280 { 270 281 } 271 282 272 - static unsigned int uv_cpu_mask_to_apicid(const struct cpumask *cpumask) 273 - { 274 - /* 275 - * We're using fixed IRQ delivery, can only return one phys APIC ID. 276 - * May as well be the first. 277 - */ 278 - int cpu = cpumask_first(cpumask); 279 - 280 - if ((unsigned)cpu < nr_cpu_ids) 281 - return per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits; 282 - else 283 - return BAD_APICID; 284 - } 285 - 286 - static unsigned int 283 + static int 287 284 uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 288 - const struct cpumask *andmask) 285 + const struct cpumask *andmask, 286 + unsigned int *apicid) 289 287 { 290 - int cpu; 288 + int unsigned cpu; 291 289 292 290 /* 293 291 * We're using fixed IRQ delivery, can only return one phys APIC ID. ··· 284 308 if (cpumask_test_cpu(cpu, cpu_online_mask)) 285 309 break; 286 310 } 287 - return per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits; 311 + 312 + if (likely(cpu < nr_cpu_ids)) { 313 + *apicid = per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits; 314 + return 0; 315 + } 316 + 317 + return -EINVAL; 288 318 } 289 319 290 320 static unsigned int x2apic_get_apic_id(unsigned long x) ··· 344 362 .irq_delivery_mode = dest_Fixed, 345 363 .irq_dest_mode = 0, /* physical */ 346 364 347 - .target_cpus = uv_target_cpus, 365 + .target_cpus = online_target_cpus, 348 366 .disable_esr = 0, 349 367 .dest_logical = APIC_DEST_LOGICAL, 350 368 .check_apicid_used = NULL, 351 369 .check_apicid_present = NULL, 352 370 353 - .vector_allocation_domain = uv_vector_allocation_domain, 371 + .vector_allocation_domain = default_vector_allocation_domain, 354 372 .init_apic_ldr = uv_init_apic_ldr, 355 373 356 374 .ioapic_phys_id_map = NULL, ··· 368 386 .set_apic_id = set_apic_id, 369 387 .apic_id_mask = 0xFFFFFFFFu, 370 388 371 - .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, 372 389 .cpu_mask_to_apicid_and = uv_cpu_mask_to_apicid_and, 373 390 374 391 .send_IPI_mask = uv_send_IPI_mask,
+6 -6
arch/x86/kernel/early_printk.c
··· 119 119 unsigned char c; 120 120 unsigned divisor; 121 121 unsigned baud = DEFAULT_BAUD; 122 - char *e; 122 + ssize_t ret; 123 123 124 124 if (*s == ',') 125 125 ++s; ··· 127 127 if (*s) { 128 128 unsigned port; 129 129 if (!strncmp(s, "0x", 2)) { 130 - early_serial_base = simple_strtoul(s, &e, 16); 130 + ret = kstrtoint(s, 16, &early_serial_base); 131 131 } else { 132 132 static const int __initconst bases[] = { 0x3f8, 0x2f8 }; 133 133 134 134 if (!strncmp(s, "ttyS", 4)) 135 135 s += 4; 136 - port = simple_strtoul(s, &e, 10); 137 - if (port > 1 || s == e) 136 + ret = kstrtouint(s, 10, &port); 137 + if (ret || port > 1) 138 138 port = 0; 139 139 early_serial_base = bases[port]; 140 140 } ··· 149 149 outb(0x3, early_serial_base + MCR); /* DTR + RTS */ 150 150 151 151 if (*s) { 152 - baud = simple_strtoul(s, &e, 0); 153 - if (baud == 0 || s == e) 152 + ret = kstrtouint(s, 0, &baud); 153 + if (ret || baud == 0) 154 154 baud = DEFAULT_BAUD; 155 155 } 156 156
-2
arch/x86/kernel/setup.c
··· 1031 1031 1032 1032 x86_init.timers.wallclock_init(); 1033 1033 1034 - x86_platform.wallclock_init(); 1035 - 1036 1034 mcheck_init(); 1037 1035 1038 1036 arch_init_ideal_nops();
-2
arch/x86/kernel/x86_init.c
··· 29 29 void __init x86_init_pgd_noop(pgd_t *unused) { } 30 30 int __init iommu_init_noop(void) { return 0; } 31 31 void iommu_shutdown_noop(void) { } 32 - void wallclock_init_noop(void) { } 33 32 34 33 /* 35 34 * The platform setup functions are preset with the default functions ··· 100 101 101 102 struct x86_platform_ops x86_platform = { 102 103 .calibrate_tsc = native_calibrate_tsc, 103 - .wallclock_init = wallclock_init_noop, 104 104 .get_wallclock = mach_get_cmos_time, 105 105 .set_wallclock = mach_set_rtc_mmss, 106 106 .iommu_shutdown = iommu_shutdown_noop,
+7 -2
arch/x86/platform/uv/uv_irq.c
··· 135 135 unsigned long mmr_value; 136 136 struct uv_IO_APIC_route_entry *entry; 137 137 int mmr_pnode, err; 138 + unsigned int dest; 138 139 139 140 BUILD_BUG_ON(sizeof(struct uv_IO_APIC_route_entry) != 140 141 sizeof(unsigned long)); 141 142 142 143 err = assign_irq_vector(irq, cfg, eligible_cpu); 144 + if (err != 0) 145 + return err; 146 + 147 + err = apic->cpu_mask_to_apicid_and(eligible_cpu, eligible_cpu, &dest); 143 148 if (err != 0) 144 149 return err; 145 150 ··· 164 159 entry->polarity = 0; 165 160 entry->trigger = 0; 166 161 entry->mask = 0; 167 - entry->dest = apic->cpu_mask_to_apicid(eligible_cpu); 162 + entry->dest = dest; 168 163 169 164 mmr_pnode = uv_blade_to_pnode(mmr_blade); 170 165 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value); ··· 227 222 if (cfg->move_in_progress) 228 223 send_cleanup_vector(cfg); 229 224 230 - return 0; 225 + return IRQ_SET_MASK_OK_NOCOPY; 231 226 } 232 227 233 228 /*
+13 -7
drivers/iommu/intel_irq_remapping.c
··· 902 902 return 0; 903 903 } 904 904 905 - #ifdef CONFIG_SMP 906 905 /* 907 906 * Migrate the IO-APIC irq in the presence of intr-remapping. 908 907 * ··· 923 924 struct irq_cfg *cfg = data->chip_data; 924 925 unsigned int dest, irq = data->irq; 925 926 struct irte irte; 927 + int err; 928 + 929 + if (!config_enabled(CONFIG_SMP)) 930 + return -EINVAL; 926 931 927 932 if (!cpumask_intersects(mask, cpu_online_mask)) 928 933 return -EINVAL; ··· 934 931 if (get_irte(irq, &irte)) 935 932 return -EBUSY; 936 933 937 - if (assign_irq_vector(irq, cfg, mask)) 938 - return -EBUSY; 934 + err = assign_irq_vector(irq, cfg, mask); 935 + if (err) 936 + return err; 939 937 940 - dest = apic->cpu_mask_to_apicid_and(cfg->domain, mask); 938 + err = apic->cpu_mask_to_apicid_and(cfg->domain, mask, &dest); 939 + if (err) { 940 + if (assign_irq_vector(irq, cfg, data->affinity)) 941 + pr_err("Failed to recover vector for irq %d\n", irq); 942 + return err; 943 + } 941 944 942 945 irte.vector = cfg->vector; 943 946 irte.dest_id = IRTE_DEST(dest); ··· 965 956 cpumask_copy(data->affinity, mask); 966 957 return 0; 967 958 } 968 - #endif 969 959 970 960 static void intel_compose_msi_msg(struct pci_dev *pdev, 971 961 unsigned int irq, unsigned int dest, ··· 1066 1058 .reenable = reenable_irq_remapping, 1067 1059 .enable_faulting = enable_drhd_fault_handling, 1068 1060 .setup_ioapic_entry = intel_setup_ioapic_entry, 1069 - #ifdef CONFIG_SMP 1070 1061 .set_affinity = intel_ioapic_set_affinity, 1071 - #endif 1072 1062 .free_irq = free_irte, 1073 1063 .compose_msi_msg = intel_compose_msi_msg, 1074 1064 .msi_alloc_irq = intel_msi_alloc_irq,
+2 -3
drivers/iommu/irq_remapping.c
··· 111 111 vector, attr); 112 112 } 113 113 114 - #ifdef CONFIG_SMP 115 114 int set_remapped_irq_affinity(struct irq_data *data, const struct cpumask *mask, 116 115 bool force) 117 116 { 118 - if (!remap_ops || !remap_ops->set_affinity) 117 + if (!config_enabled(CONFIG_SMP) || !remap_ops || 118 + !remap_ops->set_affinity) 119 119 return 0; 120 120 121 121 return remap_ops->set_affinity(data, mask, force); 122 122 } 123 - #endif 124 123 125 124 void free_remapped_irq(int irq) 126 125 {
-2
drivers/iommu/irq_remapping.h
··· 59 59 unsigned int, int, 60 60 struct io_apic_irq_attr *); 61 61 62 - #ifdef CONFIG_SMP 63 62 /* Set the CPU affinity of a remapped interrupt */ 64 63 int (*set_affinity)(struct irq_data *data, const struct cpumask *mask, 65 64 bool force); 66 - #endif 67 65 68 66 /* Free an IRQ */ 69 67 int (*free_irq)(int);
-2
include/linux/irq.h
··· 150 150 void *handler_data; 151 151 void *chip_data; 152 152 struct msi_desc *msi_desc; 153 - #ifdef CONFIG_SMP 154 153 cpumask_var_t affinity; 155 - #endif 156 154 }; 157 155 158 156 /*