···306306 unsigned long (*check_apicid_used)(physid_mask_t *map, int apicid);307307 unsigned long (*check_apicid_present)(int apicid);308308309309- void (*vector_allocation_domain)(int cpu, struct cpumask *retmask);309309+ bool (*vector_allocation_domain)(int cpu, struct cpumask *retmask);310310 void (*init_apic_ldr)(void);311311312312 void (*ioapic_phys_id_map)(physid_mask_t *phys_map, physid_mask_t *retmap);···331331 unsigned long (*set_apic_id)(unsigned int id);332332 unsigned long apic_id_mask;333333334334- unsigned int (*cpu_mask_to_apicid)(const struct cpumask *cpumask);335335- unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,336336- const struct cpumask *andmask);334334+ int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,335335+ const struct cpumask *andmask,336336+ unsigned int *apicid);337337338338 /* ipi */339339 void (*send_IPI_mask)(const struct cpumask *mask, int vector);···537537#endif538538}539539540540+static inline const struct cpumask *online_target_cpus(void)541541+{542542+ return cpu_online_mask;543543+}544544+540545DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid);541546542547···591586592587#endif593588594594-static inline unsigned int595595-default_cpu_mask_to_apicid(const struct cpumask *cpumask)589589+static inline int590590+flat_cpu_mask_to_apicid_and(const struct cpumask *cpumask,591591+ const struct cpumask *andmask,592592+ unsigned int *apicid)596593{597597- return cpumask_bits(cpumask)[0] & APIC_ALL_CPUS;594594+ unsigned long cpu_mask = cpumask_bits(cpumask)[0] &595595+ cpumask_bits(andmask)[0] &596596+ cpumask_bits(cpu_online_mask)[0] &597597+ APIC_ALL_CPUS;598598+599599+ if (likely(cpu_mask)) {600600+ *apicid = (unsigned int)cpu_mask;601601+ return 0;602602+ } else {603603+ return -EINVAL;604604+ }598605}599606600600-static inline unsigned int607607+extern int601608default_cpu_mask_to_apicid_and(const struct cpumask *cpumask,602602- const struct cpumask *andmask)603603-{604604- unsigned long mask1 = cpumask_bits(cpumask)[0];605605- unsigned long mask2 = cpumask_bits(andmask)[0];606606- unsigned long mask3 = cpumask_bits(cpu_online_mask)[0];609609+ const struct cpumask *andmask,610610+ unsigned int *apicid);607611608608- return (unsigned int)(mask1 & mask2 & mask3);612612+static inline bool613613+flat_vector_allocation_domain(int cpu, struct cpumask *retmask)614614+{615615+ /* Careful. Some cpus do not strictly honor the set of cpus616616+ * specified in the interrupt destination when using lowest617617+ * priority interrupt delivery mode.618618+ *619619+ * In particular there was a hyperthreading cpu observed to620620+ * deliver interrupts to the wrong hyperthread when only one621621+ * hyperthread was specified in the interrupt desitination.622622+ */623623+ cpumask_clear(retmask);624624+ cpumask_bits(retmask)[0] = APIC_ALL_CPUS;625625+ return false;626626+}627627+628628+static inline bool629629+default_vector_allocation_domain(int cpu, struct cpumask *retmask)630630+{631631+ cpumask_copy(retmask, cpumask_of(cpu));632632+ return true;609633}610634611635static inline unsigned long default_check_apicid_used(physid_mask_t *map, int apicid)
-18
arch/x86/include/asm/x2apic.h
···99#include <asm/ipi.h>1010#include <linux/cpumask.h>11111212-/*1313- * Need to use more than cpu 0, because we need more vectors1414- * when MSI-X are used.1515- */1616-static const struct cpumask *x2apic_target_cpus(void)1717-{1818- return cpu_online_mask;1919-}2020-2112static int x2apic_apic_id_valid(int apicid)2213{2314 return 1;···1726static int x2apic_apic_id_registered(void)1827{1928 return 1;2020-}2121-2222-/*2323- * For now each logical cpu is in its own vector allocation domain.2424- */2525-static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask)2626-{2727- cpumask_clear(retmask);2828- cpumask_set_cpu(cpu, retmask);2929}30303131static void
-2
arch/x86/include/asm/x86_init.h
···156156/**157157 * struct x86_platform_ops - platform specific runtime functions158158 * @calibrate_tsc: calibrate TSC159159- * @wallclock_init: init the wallclock device160159 * @get_wallclock: get time from HW clock like RTC etc.161160 * @set_wallclock: set time back to HW clock162161 * @is_untracked_pat_range exclude from PAT logic···167168 */168169struct x86_platform_ops {169170 unsigned long (*calibrate_tsc)(void);170170- void (*wallclock_init)(void);171171 unsigned long (*get_wallclock)(void);172172 int (*set_wallclock)(unsigned long nowtime);173173 void (*iommu_shutdown)(void);
+19
arch/x86/kernel/apic/apic.c
···21232123 apic_write(APIC_LDR, val);21242124}2125212521262126+int default_cpu_mask_to_apicid_and(const struct cpumask *cpumask,21272127+ const struct cpumask *andmask,21282128+ unsigned int *apicid)21292129+{21302130+ unsigned int cpu;21312131+21322132+ for_each_cpu_and(cpu, cpumask, andmask) {21332133+ if (cpumask_test_cpu(cpu, cpu_online_mask))21342134+ break;21352135+ }21362136+21372137+ if (likely(cpu < nr_cpu_ids)) {21382138+ *apicid = per_cpu(x86_cpu_to_apicid, cpu);21392139+ return 0;21402140+ }21412141+21422142+ return -EINVAL;21432143+}21442144+21262145/*21272146 * Power management21282147 */
+6-70
arch/x86/kernel/apic/apic_flat_64.c
···3636 return 1;3737}38383939-static const struct cpumask *flat_target_cpus(void)4040-{4141- return cpu_online_mask;4242-}4343-4444-static void flat_vector_allocation_domain(int cpu, struct cpumask *retmask)4545-{4646- /* Careful. Some cpus do not strictly honor the set of cpus4747- * specified in the interrupt destination when using lowest4848- * priority interrupt delivery mode.4949- *5050- * In particular there was a hyperthreading cpu observed to5151- * deliver interrupts to the wrong hyperthread when only one5252- * hyperthread was specified in the interrupt desitination.5353- */5454- cpumask_clear(retmask);5555- cpumask_bits(retmask)[0] = APIC_ALL_CPUS;5656-}5757-5839/*5940 * Set up the logical destination ID.6041 *···7392}74937594static void7676- flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)9595+flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)7796{7897 unsigned long mask = cpumask_bits(cpumask)[0];7998 int cpu = smp_processor_id();···167186 .irq_delivery_mode = dest_LowestPrio,168187 .irq_dest_mode = 1, /* logical */169188170170- .target_cpus = flat_target_cpus,189189+ .target_cpus = online_target_cpus,171190 .disable_esr = 0,172191 .dest_logical = APIC_DEST_LOGICAL,173192 .check_apicid_used = NULL,···191210 .set_apic_id = set_apic_id,192211 .apic_id_mask = 0xFFu << 24,193212194194- .cpu_mask_to_apicid = default_cpu_mask_to_apicid,195195- .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,213213+ .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and,196214197215 .send_IPI_mask = flat_send_IPI_mask,198216 .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself,···242262 return 0;243263}244264245245-static const struct cpumask *physflat_target_cpus(void)246246-{247247- return cpu_online_mask;248248-}249249-250250-static void physflat_vector_allocation_domain(int cpu, struct cpumask *retmask)251251-{252252- cpumask_clear(retmask);253253- cpumask_set_cpu(cpu, retmask);254254-}255255-256265static void physflat_send_IPI_mask(const struct cpumask *cpumask, int vector)257266{258267 default_send_IPI_mask_sequence_phys(cpumask, vector);···263294 physflat_send_IPI_mask(cpu_online_mask, vector);264295}265296266266-static unsigned int physflat_cpu_mask_to_apicid(const struct cpumask *cpumask)267267-{268268- int cpu;269269-270270- /*271271- * We're using fixed IRQ delivery, can only return one phys APIC ID.272272- * May as well be the first.273273- */274274- cpu = cpumask_first(cpumask);275275- if ((unsigned)cpu < nr_cpu_ids)276276- return per_cpu(x86_cpu_to_apicid, cpu);277277- else278278- return BAD_APICID;279279-}280280-281281-static unsigned int282282-physflat_cpu_mask_to_apicid_and(const struct cpumask *cpumask,283283- const struct cpumask *andmask)284284-{285285- int cpu;286286-287287- /*288288- * We're using fixed IRQ delivery, can only return one phys APIC ID.289289- * May as well be the first.290290- */291291- for_each_cpu_and(cpu, cpumask, andmask) {292292- if (cpumask_test_cpu(cpu, cpu_online_mask))293293- break;294294- }295295- return per_cpu(x86_cpu_to_apicid, cpu);296296-}297297-298297static int physflat_probe(void)299298{300299 if (apic == &apic_physflat || num_possible_cpus() > 8)···282345 .irq_delivery_mode = dest_Fixed,283346 .irq_dest_mode = 0, /* physical */284347285285- .target_cpus = physflat_target_cpus,348348+ .target_cpus = online_target_cpus,286349 .disable_esr = 0,287350 .dest_logical = 0,288351 .check_apicid_used = NULL,289352 .check_apicid_present = NULL,290353291291- .vector_allocation_domain = physflat_vector_allocation_domain,354354+ .vector_allocation_domain = default_vector_allocation_domain,292355 /* not needed, but shouldn't hurt: */293356 .init_apic_ldr = flat_init_apic_ldr,294357···307370 .set_apic_id = set_apic_id,308371 .apic_id_mask = 0xFFu << 24,309372310310- .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid,311311- .cpu_mask_to_apicid_and = physflat_cpu_mask_to_apicid_and,373373+ .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,312374313375 .send_IPI_mask = physflat_send_IPI_mask,314376 .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself,
···7272 return initial_apic_id >> index_msb;7373}74747575-static const struct cpumask *numachip_target_cpus(void)7676-{7777- return cpu_online_mask;7878-}7979-8080-static void numachip_vector_allocation_domain(int cpu, struct cpumask *retmask)8181-{8282- cpumask_clear(retmask);8383- cpumask_set_cpu(cpu, retmask);8484-}8585-8675static int __cpuinit numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip)8776{8877 union numachip_csr_g3_ext_irq_gen int_gen;···146157 __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);147158}148159149149-static unsigned int numachip_cpu_mask_to_apicid(const struct cpumask *cpumask)150150-{151151- int cpu;152152-153153- /*154154- * We're using fixed IRQ delivery, can only return one phys APIC ID.155155- * May as well be the first.156156- */157157- cpu = cpumask_first(cpumask);158158- if (likely((unsigned)cpu < nr_cpu_ids))159159- return per_cpu(x86_cpu_to_apicid, cpu);160160-161161- return BAD_APICID;162162-}163163-164164-static unsigned int165165-numachip_cpu_mask_to_apicid_and(const struct cpumask *cpumask,166166- const struct cpumask *andmask)167167-{168168- int cpu;169169-170170- /*171171- * We're using fixed IRQ delivery, can only return one phys APIC ID.172172- * May as well be the first.173173- */174174- for_each_cpu_and(cpu, cpumask, andmask) {175175- if (cpumask_test_cpu(cpu, cpu_online_mask))176176- break;177177- }178178- return per_cpu(x86_cpu_to_apicid, cpu);179179-}180180-181160static int __init numachip_probe(void)182161{183162 return apic == &apic_numachip;···210253 .irq_delivery_mode = dest_Fixed,211254 .irq_dest_mode = 0, /* physical */212255213213- .target_cpus = numachip_target_cpus,256256+ .target_cpus = online_target_cpus,214257 .disable_esr = 0,215258 .dest_logical = 0,216259 .check_apicid_used = NULL,217260 .check_apicid_present = NULL,218261219219- .vector_allocation_domain = numachip_vector_allocation_domain,262262+ .vector_allocation_domain = default_vector_allocation_domain,220263 .init_apic_ldr = flat_init_apic_ldr,221264222265 .ioapic_phys_id_map = NULL,···234277 .set_apic_id = set_apic_id,235278 .apic_id_mask = 0xffU << 24,236279237237- .cpu_mask_to_apicid = numachip_cpu_mask_to_apicid,238238- .cpu_mask_to_apicid_and = numachip_cpu_mask_to_apicid_and,280280+ .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,239281240282 .send_IPI_mask = numachip_send_IPI_mask,241283 .send_IPI_mask_allbutself = numachip_send_IPI_mask_allbutself,
+3-45
arch/x86/kernel/apic/bigsmp_32.c
···2626 return 1;2727}28282929-static const struct cpumask *bigsmp_target_cpus(void)3030-{3131-#ifdef CONFIG_SMP3232- return cpu_online_mask;3333-#else3434- return cpumask_of(0);3535-#endif3636-}3737-3829static unsigned long bigsmp_check_apicid_used(physid_mask_t *map, int apicid)3930{4031 return 0;···96105 return 1;97106}981079999-/* As we are using single CPU as destination, pick only one CPU here */100100-static unsigned int bigsmp_cpu_mask_to_apicid(const struct cpumask *cpumask)101101-{102102- int cpu = cpumask_first(cpumask);103103-104104- if (cpu < nr_cpu_ids)105105- return cpu_physical_id(cpu);106106- return BAD_APICID;107107-}108108-109109-static unsigned int bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask,110110- const struct cpumask *andmask)111111-{112112- int cpu;113113-114114- /*115115- * We're using fixed IRQ delivery, can only return one phys APIC ID.116116- * May as well be the first.117117- */118118- for_each_cpu_and(cpu, cpumask, andmask) {119119- if (cpumask_test_cpu(cpu, cpu_online_mask))120120- return cpu_physical_id(cpu);121121- }122122- return BAD_APICID;123123-}124124-125108static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb)126109{127110 return cpuid_apic >> index_msb;···142177 { } /* NULL entry stops DMI scanning */143178};144179145145-static void bigsmp_vector_allocation_domain(int cpu, struct cpumask *retmask)146146-{147147- cpumask_clear(retmask);148148- cpumask_set_cpu(cpu, retmask);149149-}150150-151180static int probe_bigsmp(void)152181{153182 if (def_to_bigsmp)···164205 /* phys delivery to target CPU: */165206 .irq_dest_mode = 0,166207167167- .target_cpus = bigsmp_target_cpus,208208+ .target_cpus = default_target_cpus,168209 .disable_esr = 1,169210 .dest_logical = 0,170211 .check_apicid_used = bigsmp_check_apicid_used,171212 .check_apicid_present = bigsmp_check_apicid_present,172213173173- .vector_allocation_domain = bigsmp_vector_allocation_domain,214214+ .vector_allocation_domain = default_vector_allocation_domain,174215 .init_apic_ldr = bigsmp_init_apic_ldr,175216176217 .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map,···188229 .set_apic_id = NULL,189230 .apic_id_mask = 0xFF << 24,190231191191- .cpu_mask_to_apicid = bigsmp_cpu_mask_to_apicid,192192- .cpu_mask_to_apicid_and = bigsmp_cpu_mask_to_apicid_and,232232+ .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,193233194234 .send_IPI_mask = bigsmp_send_IPI_mask,195235 .send_IPI_mask_allbutself = NULL,
+19-32
arch/x86/kernel/apic/es7000_32.c
···394394 WARN(1, "Command failed, status = %x\n", mip_status);395395}396396397397-static void es7000_vector_allocation_domain(int cpu, struct cpumask *retmask)398398-{399399- /* Careful. Some cpus do not strictly honor the set of cpus400400- * specified in the interrupt destination when using lowest401401- * priority interrupt delivery mode.402402- *403403- * In particular there was a hyperthreading cpu observed to404404- * deliver interrupts to the wrong hyperthread when only one405405- * hyperthread was specified in the interrupt desitination.406406- */407407- cpumask_clear(retmask);408408- cpumask_bits(retmask)[0] = APIC_ALL_CPUS;409409-}410410-411411-412397static void es7000_wait_for_init_deassert(atomic_t *deassert)413398{414399 while (!atomic_read(deassert))···525540 return 1;526541}527542528528-static unsigned int es7000_cpu_mask_to_apicid(const struct cpumask *cpumask)543543+static inline int544544+es7000_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id)529545{530546 unsigned int round = 0;531531- int cpu, uninitialized_var(apicid);547547+ unsigned int cpu, uninitialized_var(apicid);532548533549 /*534550 * The cpus in the mask must all be on the apic cluster.535551 */536536- for_each_cpu(cpu, cpumask) {552552+ for_each_cpu_and(cpu, cpumask, cpu_online_mask) {537553 int new_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu);538554539555 if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) {540556 WARN(1, "Not a valid mask!");541557542542- return BAD_APICID;558558+ return -EINVAL;543559 }544544- apicid = new_apicid;560560+ apicid |= new_apicid;545561 round++;546562 }547547- return apicid;563563+ if (!round)564564+ return -EINVAL;565565+ *dest_id = apicid;566566+ return 0;548567}549568550550-static unsigned int569569+static int551570es7000_cpu_mask_to_apicid_and(const struct cpumask *inmask,552552- const struct cpumask *andmask)571571+ const struct cpumask *andmask,572572+ unsigned int *apicid)553573{554554- int apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0);555574 cpumask_var_t cpumask;575575+ *apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0);556576557577 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC))558558- return apicid;578578+ return 0;559579560580 cpumask_and(cpumask, inmask, andmask);561561- cpumask_and(cpumask, cpumask, cpu_online_mask);562562- apicid = es7000_cpu_mask_to_apicid(cpumask);581581+ es7000_cpu_mask_to_apicid(cpumask, apicid);563582564583 free_cpumask_var(cpumask);565584566566- return apicid;585585+ return 0;567586}568587569588static int es7000_phys_pkg_id(int cpuid_apic, int index_msb)···627638 .check_apicid_used = es7000_check_apicid_used,628639 .check_apicid_present = es7000_check_apicid_present,629640630630- .vector_allocation_domain = es7000_vector_allocation_domain,641641+ .vector_allocation_domain = flat_vector_allocation_domain,631642 .init_apic_ldr = es7000_init_apic_ldr_cluster,632643633644 .ioapic_phys_id_map = es7000_ioapic_phys_id_map,···645656 .set_apic_id = NULL,646657 .apic_id_mask = 0xFF << 24,647658648648- .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid,649659 .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and,650660651661 .send_IPI_mask = es7000_send_IPI_mask,···693705 .check_apicid_used = es7000_check_apicid_used,694706 .check_apicid_present = es7000_check_apicid_present,695707696696- .vector_allocation_domain = es7000_vector_allocation_domain,708708+ .vector_allocation_domain = flat_vector_allocation_domain,697709 .init_apic_ldr = es7000_init_apic_ldr,698710699711 .ioapic_phys_id_map = es7000_ioapic_phys_id_map,···711723 .set_apic_id = NULL,712724 .apic_id_mask = 0xFF << 24,713725714714- .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid,715726 .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and,716727717728 .send_IPI_mask = es7000_send_IPI_mask,
+150-138
arch/x86/kernel/apic/io_apic.c
···11121112 * 0x80, because int 0x80 is hm, kind of importantish. ;)11131113 */11141114 static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START;11151115- static int current_offset = VECTOR_OFFSET_START % 8;11151115+ static int current_offset = VECTOR_OFFSET_START % 16;11161116 unsigned int old_vector;11171117 int cpu, err;11181118 cpumask_var_t tmp_mask;···11261126 old_vector = cfg->vector;11271127 if (old_vector) {11281128 cpumask_and(tmp_mask, mask, cpu_online_mask);11291129- cpumask_and(tmp_mask, cfg->domain, tmp_mask);11301130- if (!cpumask_empty(tmp_mask)) {11291129+ if (cpumask_subset(tmp_mask, cfg->domain)) {11311130 free_cpumask_var(tmp_mask);11321131 return 0;11331132 }···11371138 for_each_cpu_and(cpu, mask, cpu_online_mask) {11381139 int new_cpu;11391140 int vector, offset;11411141+ bool more_domains;1140114211411141- apic->vector_allocation_domain(cpu, tmp_mask);11431143+ more_domains = apic->vector_allocation_domain(cpu, tmp_mask);11441144+11451145+ if (cpumask_subset(tmp_mask, cfg->domain)) {11461146+ free_cpumask_var(tmp_mask);11471147+ return 0;11481148+ }1142114911431150 vector = current_vector;11441151 offset = current_offset;11451152next:11461146- vector += 8;11531153+ vector += 16;11471154 if (vector >= first_system_vector) {11481148- /* If out of vectors on large boxen, must share them. */11491149- offset = (offset + 1) % 8;11551155+ offset = (offset + 1) % 16;11501156 vector = FIRST_EXTERNAL_VECTOR + offset;11511157 }11521152- if (unlikely(current_vector == vector))11531153- continue;11581158+11591159+ if (unlikely(current_vector == vector)) {11601160+ if (more_domains)11611161+ continue;11621162+ else11631163+ break;11641164+ }1154116511551166 if (test_bit(vector, used_vectors))11561167 goto next;···1355134613561347 if (!IO_APIC_IRQ(irq))13571348 return;13581358- /*13591359- * For legacy irqs, cfg->domain starts with cpu 0 for legacy13601360- * controllers like 8259. Now that IO-APIC can handle this irq, update13611361- * the cfg->domain.13621362- */13631363- if (irq < legacy_pic->nr_legacy_irqs && cpumask_test_cpu(0, cfg->domain))13641364- apic->vector_allocation_domain(0, cfg->domain);1365134913661350 if (assign_irq_vector(irq, cfg, apic->target_cpus()))13671351 return;1368135213691369- dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus());13531353+ if (apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus(),13541354+ &dest)) {13551355+ pr_warn("Failed to obtain apicid for ioapic %d, pin %d\n",13561356+ mpc_ioapic_id(attr->ioapic), attr->ioapic_pin);13571357+ __clear_irq_vector(irq, cfg);13581358+13591359+ return;13601360+ }1370136113711362 apic_printk(APIC_VERBOSE,KERN_DEBUG13721363 "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> "···13751366 cfg->vector, irq, attr->trigger, attr->polarity, dest);1376136713771368 if (setup_ioapic_entry(irq, &entry, dest, cfg->vector, attr)) {13781378- pr_warn("Failed to setup ioapic entry for ioapic %d, pin %d\n",13691369+ pr_warn("Failed to setup ioapic entry for ioapic %d, pin %d\n",13791370 mpc_ioapic_id(attr->ioapic), attr->ioapic_pin);13801371 __clear_irq_vector(irq, cfg);13811372···14781469 * Set up the timer pin, possibly with the 8259A-master behind.14791470 */14801471static void __init setup_timer_IRQ0_pin(unsigned int ioapic_idx,14811481- unsigned int pin, int vector)14721472+ unsigned int pin, int vector)14821473{14831474 struct IO_APIC_route_entry entry;14751475+ unsigned int dest;1484147614851477 if (irq_remapping_enabled)14861478 return;···14921482 * We use logical delivery to get the timer IRQ14931483 * to the first CPU.14941484 */14851485+ if (unlikely(apic->cpu_mask_to_apicid_and(apic->target_cpus(),14861486+ apic->target_cpus(), &dest)))14871487+ dest = BAD_APICID;14881488+14951489 entry.dest_mode = apic->irq_dest_mode;14961490 entry.mask = 0; /* don't mask IRQ for edge */14971497- entry.dest = apic->cpu_mask_to_apicid(apic->target_cpus());14911491+ entry.dest = dest;14981492 entry.delivery_mode = apic->irq_delivery_mode;14991493 entry.polarity = 0;15001494 entry.trigger = 0;···22242210 cfg->move_in_progress = 0;22252211}2226221222272227-static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq_cfg *cfg)22282228-{22292229- int apic, pin;22302230- struct irq_pin_list *entry;22312231- u8 vector = cfg->vector;22322232-22332233- for_each_irq_pin(entry, cfg->irq_2_pin) {22342234- unsigned int reg;22352235-22362236- apic = entry->apic;22372237- pin = entry->pin;22382238- /*22392239- * With interrupt-remapping, destination information comes22402240- * from interrupt-remapping table entry.22412241- */22422242- if (!irq_remapped(cfg))22432243- io_apic_write(apic, 0x11 + pin*2, dest);22442244- reg = io_apic_read(apic, 0x10 + pin*2);22452245- reg &= ~IO_APIC_REDIR_VECTOR_MASK;22462246- reg |= vector;22472247- io_apic_modify(apic, 0x10 + pin*2, reg);22482248- }22492249-}22502250-22512251-/*22522252- * Either sets data->affinity to a valid value, and returns22532253- * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and22542254- * leaves data->affinity untouched.22552255- */22562256-int __ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,22572257- unsigned int *dest_id)22582258-{22592259- struct irq_cfg *cfg = data->chip_data;22602260-22612261- if (!cpumask_intersects(mask, cpu_online_mask))22622262- return -1;22632263-22642264- if (assign_irq_vector(data->irq, data->chip_data, mask))22652265- return -1;22662266-22672267- cpumask_copy(data->affinity, mask);22682268-22692269- *dest_id = apic->cpu_mask_to_apicid_and(mask, cfg->domain);22702270- return 0;22712271-}22722272-22732273-static int22742274-ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,22752275- bool force)22762276-{22772277- unsigned int dest, irq = data->irq;22782278- unsigned long flags;22792279- int ret;22802280-22812281- raw_spin_lock_irqsave(&ioapic_lock, flags);22822282- ret = __ioapic_set_affinity(data, mask, &dest);22832283- if (!ret) {22842284- /* Only the high 8 bits are valid. */22852285- dest = SET_APIC_LOGICAL_ID(dest);22862286- __target_IO_APIC_irq(irq, dest, data->chip_data);22872287- }22882288- raw_spin_unlock_irqrestore(&ioapic_lock, flags);22892289- return ret;22902290-}22912291-22922213asmlinkage void smp_irq_move_cleanup_interrupt(void)22932214{22942215 unsigned vector, me;···23102361#else23112362static inline void irq_complete_move(struct irq_cfg *cfg) { }23122363#endif23642364+23652365+static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq_cfg *cfg)23662366+{23672367+ int apic, pin;23682368+ struct irq_pin_list *entry;23692369+ u8 vector = cfg->vector;23702370+23712371+ for_each_irq_pin(entry, cfg->irq_2_pin) {23722372+ unsigned int reg;23732373+23742374+ apic = entry->apic;23752375+ pin = entry->pin;23762376+ /*23772377+ * With interrupt-remapping, destination information comes23782378+ * from interrupt-remapping table entry.23792379+ */23802380+ if (!irq_remapped(cfg))23812381+ io_apic_write(apic, 0x11 + pin*2, dest);23822382+ reg = io_apic_read(apic, 0x10 + pin*2);23832383+ reg &= ~IO_APIC_REDIR_VECTOR_MASK;23842384+ reg |= vector;23852385+ io_apic_modify(apic, 0x10 + pin*2, reg);23862386+ }23872387+}23882388+23892389+/*23902390+ * Either sets data->affinity to a valid value, and returns23912391+ * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and23922392+ * leaves data->affinity untouched.23932393+ */23942394+int __ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,23952395+ unsigned int *dest_id)23962396+{23972397+ struct irq_cfg *cfg = data->chip_data;23982398+ unsigned int irq = data->irq;23992399+ int err;24002400+24012401+ if (!config_enabled(CONFIG_SMP))24022402+ return -1;24032403+24042404+ if (!cpumask_intersects(mask, cpu_online_mask))24052405+ return -EINVAL;24062406+24072407+ err = assign_irq_vector(irq, cfg, mask);24082408+ if (err)24092409+ return err;24102410+24112411+ err = apic->cpu_mask_to_apicid_and(mask, cfg->domain, dest_id);24122412+ if (err) {24132413+ if (assign_irq_vector(irq, cfg, data->affinity))24142414+ pr_err("Failed to recover vector for irq %d\n", irq);24152415+ return err;24162416+ }24172417+24182418+ cpumask_copy(data->affinity, mask);24192419+24202420+ return 0;24212421+}24222422+24232423+static int24242424+ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,24252425+ bool force)24262426+{24272427+ unsigned int dest, irq = data->irq;24282428+ unsigned long flags;24292429+ int ret;24302430+24312431+ if (!config_enabled(CONFIG_SMP))24322432+ return -1;24332433+24342434+ raw_spin_lock_irqsave(&ioapic_lock, flags);24352435+ ret = __ioapic_set_affinity(data, mask, &dest);24362436+ if (!ret) {24372437+ /* Only the high 8 bits are valid. */24382438+ dest = SET_APIC_LOGICAL_ID(dest);24392439+ __target_IO_APIC_irq(irq, dest, data->chip_data);24402440+ ret = IRQ_SET_MASK_OK_NOCOPY;24412441+ }24422442+ raw_spin_unlock_irqrestore(&ioapic_lock, flags);24432443+ return ret;24442444+}2313244523142446static void ack_apic_edge(struct irq_data *data)23152447{···25712541 chip->irq_ack = ir_ack_apic_edge;25722542 chip->irq_eoi = ir_ack_apic_level;2573254325742574-#ifdef CONFIG_SMP25752544 chip->irq_set_affinity = set_remapped_irq_affinity;25762576-#endif25772545}25782546#endif /* CONFIG_IRQ_REMAP */25792547···25822554 .irq_unmask = unmask_ioapic_irq,25832555 .irq_ack = ack_apic_edge,25842556 .irq_eoi = ack_apic_level,25852585-#ifdef CONFIG_SMP25862557 .irq_set_affinity = ioapic_set_affinity,25872587-#endif25882558 .irq_retrigger = ioapic_retrigger_irq,25892559};25902560···30643038 if (err)30653039 return err;3066304030673067- dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus());30413041+ err = apic->cpu_mask_to_apicid_and(cfg->domain,30423042+ apic->target_cpus(), &dest);30433043+ if (err)30443044+ return err;3068304530693046 if (irq_remapped(cfg)) {30703047 compose_remapped_msi_msg(pdev, irq, dest, msg, hpet_id);···31013072 return err;31023073}3103307431043104-#ifdef CONFIG_SMP31053075static int31063076msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)31073077{···3120309231213093 __write_msi_msg(data->msi_desc, &msg);3122309431233123- return 0;30953095+ return IRQ_SET_MASK_OK_NOCOPY;31243096}31253125-#endif /* CONFIG_SMP */3126309731273098/*31283099 * IRQ Chip for MSI PCI/PCI-X/PCI-Express Devices,···31323105 .irq_unmask = unmask_msi_irq,31333106 .irq_mask = mask_msi_irq,31343107 .irq_ack = ack_apic_edge,31353135-#ifdef CONFIG_SMP31363108 .irq_set_affinity = msi_set_affinity,31373137-#endif31383109 .irq_retrigger = ioapic_retrigger_irq,31393110};31403111···32173192}3218319332193194#ifdef CONFIG_DMAR_TABLE32203220-#ifdef CONFIG_SMP32213195static int32223196dmar_msi_set_affinity(struct irq_data *data, const struct cpumask *mask,32233197 bool force)···3238321432393215 dmar_msi_write(irq, &msg);3240321632413241- return 0;32173217+ return IRQ_SET_MASK_OK_NOCOPY;32423218}32433243-32443244-#endif /* CONFIG_SMP */3245321932463220static struct irq_chip dmar_msi_type = {32473221 .name = "DMAR_MSI",32483222 .irq_unmask = dmar_msi_unmask,32493223 .irq_mask = dmar_msi_mask,32503224 .irq_ack = ack_apic_edge,32513251-#ifdef CONFIG_SMP32523225 .irq_set_affinity = dmar_msi_set_affinity,32533253-#endif32543226 .irq_retrigger = ioapic_retrigger_irq,32553227};32563228···3267324732683248#ifdef CONFIG_HPET_TIMER3269324932703270-#ifdef CONFIG_SMP32713250static int hpet_msi_set_affinity(struct irq_data *data,32723251 const struct cpumask *mask, bool force)32733252{···3286326732873268 hpet_msi_write(data->handler_data, &msg);3288326932893289- return 0;32703270+ return IRQ_SET_MASK_OK_NOCOPY;32903271}32913291-32923292-#endif /* CONFIG_SMP */3293327232943273static struct irq_chip hpet_msi_type = {32953274 .name = "HPET_MSI",32963275 .irq_unmask = hpet_msi_unmask,32973276 .irq_mask = hpet_msi_mask,32983277 .irq_ack = ack_apic_edge,32993299-#ifdef CONFIG_SMP33003278 .irq_set_affinity = hpet_msi_set_affinity,33013301-#endif33023279 .irq_retrigger = ioapic_retrigger_irq,33033280};33043281···33293314 */33303315#ifdef CONFIG_HT_IRQ3331331633323332-#ifdef CONFIG_SMP33333333-33343317static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector)33353318{33363319 struct ht_irq_msg msg;···33533340 return -1;3354334133553342 target_ht_irq(data->irq, dest, cfg->vector);33563356- return 0;33433343+ return IRQ_SET_MASK_OK_NOCOPY;33573344}33583358-33593359-#endif3360334533613346static struct irq_chip ht_irq_chip = {33623347 .name = "PCI-HT",33633348 .irq_mask = mask_ht_irq,33643349 .irq_unmask = unmask_ht_irq,33653350 .irq_ack = ack_apic_edge,33663366-#ifdef CONFIG_SMP33673351 .irq_set_affinity = ht_set_affinity,33683368-#endif33693352 .irq_retrigger = ioapic_retrigger_irq,33703353};3371335433723355int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)33733356{33743357 struct irq_cfg *cfg;33583358+ struct ht_irq_msg msg;33593359+ unsigned dest;33753360 int err;3376336133773362 if (disable_apic)···3377336633783367 cfg = irq_cfg(irq);33793368 err = assign_irq_vector(irq, cfg, apic->target_cpus());33803380- if (!err) {33813381- struct ht_irq_msg msg;33823382- unsigned dest;33693369+ if (err)33703370+ return err;3383337133843384- dest = apic->cpu_mask_to_apicid_and(cfg->domain,33853385- apic->target_cpus());33723372+ err = apic->cpu_mask_to_apicid_and(cfg->domain,33733373+ apic->target_cpus(), &dest);33743374+ if (err)33753375+ return err;3386337633873387- msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest);33773377+ msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest);3388337833893389- msg.address_lo =33903390- HT_IRQ_LOW_BASE |33913391- HT_IRQ_LOW_DEST_ID(dest) |33923392- HT_IRQ_LOW_VECTOR(cfg->vector) |33933393- ((apic->irq_dest_mode == 0) ?33943394- HT_IRQ_LOW_DM_PHYSICAL :33953395- HT_IRQ_LOW_DM_LOGICAL) |33963396- HT_IRQ_LOW_RQEOI_EDGE |33973397- ((apic->irq_delivery_mode != dest_LowestPrio) ?33983398- HT_IRQ_LOW_MT_FIXED :33993399- HT_IRQ_LOW_MT_ARBITRATED) |34003400- HT_IRQ_LOW_IRQ_MASKED;33793379+ msg.address_lo =33803380+ HT_IRQ_LOW_BASE |33813381+ HT_IRQ_LOW_DEST_ID(dest) |33823382+ HT_IRQ_LOW_VECTOR(cfg->vector) |33833383+ ((apic->irq_dest_mode == 0) ?33843384+ HT_IRQ_LOW_DM_PHYSICAL :33853385+ HT_IRQ_LOW_DM_LOGICAL) |33863386+ HT_IRQ_LOW_RQEOI_EDGE |33873387+ ((apic->irq_delivery_mode != dest_LowestPrio) ?33883388+ HT_IRQ_LOW_MT_FIXED :33893389+ HT_IRQ_LOW_MT_ARBITRATED) |33903390+ HT_IRQ_LOW_IRQ_MASKED;3401339134023402- write_ht_irq_msg(irq, &msg);33923392+ write_ht_irq_msg(irq, &msg);3403339334043404- irq_set_chip_and_handler_name(irq, &ht_irq_chip,34053405- handle_edge_irq, "edge");33943394+ irq_set_chip_and_handler_name(irq, &ht_irq_chip,33953395+ handle_edge_irq, "edge");3406339634073407- dev_printk(KERN_DEBUG, &dev->dev, "irq %d for HT\n", irq);34083408- }34093409- return err;33973397+ dev_printk(KERN_DEBUG, &dev->dev, "irq %d for HT\n", irq);33983398+33993399+ return 0;34103400}34113401#endif /* CONFIG_HT_IRQ */34123402
+6-24
arch/x86/kernel/apic/numaq_32.c
···406406 * We use physical apicids here, not logical, so just return the default407407 * physical broadcast to stop people from breaking us408408 */409409-static unsigned int numaq_cpu_mask_to_apicid(const struct cpumask *cpumask)410410-{411411- return 0x0F;412412-}413413-414414-static inline unsigned int409409+static int415410numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask,416416- const struct cpumask *andmask)411411+ const struct cpumask *andmask,412412+ unsigned int *apicid)417413{418418- return 0x0F;414414+ *apicid = 0x0F;415415+ return 0;419416}420417421418/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */···436439{437440 /* already know from get_memcfg_numaq() */438441 return found_numaq;439439-}440440-441441-static void numaq_vector_allocation_domain(int cpu, struct cpumask *retmask)442442-{443443- /* Careful. Some cpus do not strictly honor the set of cpus444444- * specified in the interrupt destination when using lowest445445- * priority interrupt delivery mode.446446- *447447- * In particular there was a hyperthreading cpu observed to448448- * deliver interrupts to the wrong hyperthread when only one449449- * hyperthread was specified in the interrupt desitination.450450- */451451- cpumask_clear(retmask);452452- cpumask_bits(retmask)[0] = APIC_ALL_CPUS;453442}454443455444static void numaq_setup_portio_remap(void)···474491 .check_apicid_used = numaq_check_apicid_used,475492 .check_apicid_present = numaq_check_apicid_present,476493477477- .vector_allocation_domain = numaq_vector_allocation_domain,494494+ .vector_allocation_domain = flat_vector_allocation_domain,478495 .init_apic_ldr = numaq_init_apic_ldr,479496480497 .ioapic_phys_id_map = numaq_ioapic_phys_id_map,···492509 .set_apic_id = NULL,493510 .apic_id_mask = 0x0F << 24,494511495495- .cpu_mask_to_apicid = numaq_cpu_mask_to_apicid,496512 .cpu_mask_to_apicid_and = numaq_cpu_mask_to_apicid_and,497513498514 .send_IPI_mask = numaq_send_IPI_mask,
+2-18
arch/x86/kernel/apic/probe_32.c
···6666#endif6767}68686969-static void default_vector_allocation_domain(int cpu, struct cpumask *retmask)7070-{7171- /*7272- * Careful. Some cpus do not strictly honor the set of cpus7373- * specified in the interrupt destination when using lowest7474- * priority interrupt delivery mode.7575- *7676- * In particular there was a hyperthreading cpu observed to7777- * deliver interrupts to the wrong hyperthread when only one7878- * hyperthread was specified in the interrupt desitination.7979- */8080- cpumask_clear(retmask);8181- cpumask_bits(retmask)[0] = APIC_ALL_CPUS;8282-}8383-8469/* should be called last. */8570static int probe_default(void)8671{···90105 .check_apicid_used = default_check_apicid_used,91106 .check_apicid_present = default_check_apicid_present,921079393- .vector_allocation_domain = default_vector_allocation_domain,108108+ .vector_allocation_domain = flat_vector_allocation_domain,94109 .init_apic_ldr = default_init_apic_ldr,9511096111 .ioapic_phys_id_map = default_ioapic_phys_id_map,···108123 .set_apic_id = NULL,109124 .apic_id_mask = 0x0F << 24,110125111111- .cpu_mask_to_apicid = default_cpu_mask_to_apicid,112112- .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,126126+ .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and,113127114128 .send_IPI_mask = default_send_IPI_mask_logical,115129 .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical,
+18-28
arch/x86/kernel/apic/summit_32.c
···263263 return 1;264264}265265266266-static unsigned int summit_cpu_mask_to_apicid(const struct cpumask *cpumask)266266+static inline int267267+summit_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id)267268{268269 unsigned int round = 0;269269- int cpu, apicid = 0;270270+ unsigned int cpu, apicid = 0;270271271272 /*272273 * The cpus in the mask must all be on the apic cluster.273274 */274274- for_each_cpu(cpu, cpumask) {275275+ for_each_cpu_and(cpu, cpumask, cpu_online_mask) {275276 int new_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu);276277277278 if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) {278279 printk("%s: Not a valid mask!\n", __func__);279279- return BAD_APICID;280280+ return -EINVAL;280281 }281282 apicid |= new_apicid;282283 round++;283284 }284284- return apicid;285285+ if (!round)286286+ return -EINVAL;287287+ *dest_id = apicid;288288+ return 0;285289}286290287287-static unsigned int summit_cpu_mask_to_apicid_and(const struct cpumask *inmask,288288- const struct cpumask *andmask)291291+static int292292+summit_cpu_mask_to_apicid_and(const struct cpumask *inmask,293293+ const struct cpumask *andmask,294294+ unsigned int *apicid)289295{290290- int apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0);291296 cpumask_var_t cpumask;297297+ *apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0);292298293299 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC))294294- return apicid;300300+ return 0;295301296302 cpumask_and(cpumask, inmask, andmask);297297- cpumask_and(cpumask, cpumask, cpu_online_mask);298298- apicid = summit_cpu_mask_to_apicid(cpumask);303303+ summit_cpu_mask_to_apicid(cpumask, apicid);299304300305 free_cpumask_var(cpumask);301306302302- return apicid;307307+ return 0;303308}304309305310/*···323318{324319 /* probed later in mptable/ACPI hooks */325320 return 0;326326-}327327-328328-static void summit_vector_allocation_domain(int cpu, struct cpumask *retmask)329329-{330330- /* Careful. Some cpus do not strictly honor the set of cpus331331- * specified in the interrupt destination when using lowest332332- * priority interrupt delivery mode.333333- *334334- * In particular there was a hyperthreading cpu observed to335335- * deliver interrupts to the wrong hyperthread when only one336336- * hyperthread was specified in the interrupt desitination.337337- */338338- cpumask_clear(retmask);339339- cpumask_bits(retmask)[0] = APIC_ALL_CPUS;340321}341322342323#ifdef CONFIG_X86_SUMMIT_NUMA···500509 .check_apicid_used = summit_check_apicid_used,501510 .check_apicid_present = summit_check_apicid_present,502511503503- .vector_allocation_domain = summit_vector_allocation_domain,512512+ .vector_allocation_domain = flat_vector_allocation_domain,504513 .init_apic_ldr = summit_init_apic_ldr,505514506515 .ioapic_phys_id_map = summit_ioapic_phys_id_map,···518527 .set_apic_id = NULL,519528 .apic_id_mask = 0xFF << 24,520529521521- .cpu_mask_to_apicid = summit_cpu_mask_to_apicid,522530 .cpu_mask_to_apicid_and = summit_cpu_mask_to_apicid_and,523531524532 .send_IPI_mask = summit_send_IPI_mask,
+39-29
arch/x86/kernel/apic/x2apic_cluster.c
···8181}82828383static void8484- x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)8484+x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)8585{8686 __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT);8787}···9696 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC);9797}98989999-static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask)100100-{101101- /*102102- * We're using fixed IRQ delivery, can only return one logical APIC ID.103103- * May as well be the first.104104- */105105- int cpu = cpumask_first(cpumask);106106-107107- if ((unsigned)cpu < nr_cpu_ids)108108- return per_cpu(x86_cpu_to_logical_apicid, cpu);109109- else110110- return BAD_APICID;111111-}112112-113113-static unsigned int9999+static int114100x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,115115- const struct cpumask *andmask)101101+ const struct cpumask *andmask,102102+ unsigned int *apicid)116103{117117- int cpu;104104+ u32 dest = 0;105105+ u16 cluster;106106+ int i;118107119119- /*120120- * We're using fixed IRQ delivery, can only return one logical APIC ID.121121- * May as well be the first.122122- */123123- for_each_cpu_and(cpu, cpumask, andmask) {124124- if (cpumask_test_cpu(cpu, cpu_online_mask))125125- break;108108+ for_each_cpu_and(i, cpumask, andmask) {109109+ if (!cpumask_test_cpu(i, cpu_online_mask))110110+ continue;111111+ dest = per_cpu(x86_cpu_to_logical_apicid, i);112112+ cluster = x2apic_cluster(i);113113+ break;126114 }127115128128- return per_cpu(x86_cpu_to_logical_apicid, cpu);116116+ if (!dest)117117+ return -EINVAL;118118+119119+ for_each_cpu_and(i, cpumask, andmask) {120120+ if (!cpumask_test_cpu(i, cpu_online_mask))121121+ continue;122122+ if (cluster != x2apic_cluster(i))123123+ continue;124124+ dest |= per_cpu(x86_cpu_to_logical_apicid, i);125125+ }126126+127127+ *apicid = dest;128128+129129+ return 0;129130}130131131132static void init_x2apic_ldr(void)···209208 return 0;210209}211210211211+/*212212+ * Each x2apic cluster is an allocation domain.213213+ */214214+static bool cluster_vector_allocation_domain(int cpu, struct cpumask *retmask)215215+{216216+ cpumask_clear(retmask);217217+ cpumask_copy(retmask, per_cpu(cpus_in_cluster, cpu));218218+ return true;219219+}220220+212221static struct apic apic_x2apic_cluster = {213222214223 .name = "cluster x2apic",···230219 .irq_delivery_mode = dest_LowestPrio,231220 .irq_dest_mode = 1, /* logical */232221233233- .target_cpus = x2apic_target_cpus,222222+ .target_cpus = online_target_cpus,234223 .disable_esr = 0,235224 .dest_logical = APIC_DEST_LOGICAL,236225 .check_apicid_used = NULL,237226 .check_apicid_present = NULL,238227239239- .vector_allocation_domain = x2apic_vector_allocation_domain,228228+ .vector_allocation_domain = cluster_vector_allocation_domain,240229 .init_apic_ldr = init_x2apic_ldr,241230242231 .ioapic_phys_id_map = NULL,···254243 .set_apic_id = x2apic_set_apic_id,255244 .apic_id_mask = 0xFFFFFFFFu,256245257257- .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,258246 .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and,259247260248 .send_IPI_mask = x2apic_send_IPI_mask,
+3-36
arch/x86/kernel/apic/x2apic_phys.c
···7676 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC);7777}78787979-static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask)8080-{8181- /*8282- * We're using fixed IRQ delivery, can only return one phys APIC ID.8383- * May as well be the first.8484- */8585- int cpu = cpumask_first(cpumask);8686-8787- if ((unsigned)cpu < nr_cpu_ids)8888- return per_cpu(x86_cpu_to_apicid, cpu);8989- else9090- return BAD_APICID;9191-}9292-9393-static unsigned int9494-x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,9595- const struct cpumask *andmask)9696-{9797- int cpu;9898-9999- /*100100- * We're using fixed IRQ delivery, can only return one phys APIC ID.101101- * May as well be the first.102102- */103103- for_each_cpu_and(cpu, cpumask, andmask) {104104- if (cpumask_test_cpu(cpu, cpu_online_mask))105105- break;106106- }107107-108108- return per_cpu(x86_cpu_to_apicid, cpu);109109-}110110-11179static void init_x2apic_ldr(void)11280{11381}···99131 .irq_delivery_mode = dest_Fixed,100132 .irq_dest_mode = 0, /* physical */101133102102- .target_cpus = x2apic_target_cpus,134134+ .target_cpus = online_target_cpus,103135 .disable_esr = 0,104136 .dest_logical = 0,105137 .check_apicid_used = NULL,106138 .check_apicid_present = NULL,107139108108- .vector_allocation_domain = x2apic_vector_allocation_domain,140140+ .vector_allocation_domain = default_vector_allocation_domain,109141 .init_apic_ldr = init_x2apic_ldr,110142111143 .ioapic_phys_id_map = NULL,···123155 .set_apic_id = x2apic_set_apic_id,124156 .apic_id_mask = 0xFFFFFFFFu,125157126126- .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,127127- .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and,158158+ .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,128159129160 .send_IPI_mask = x2apic_send_IPI_mask,130161 .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself,
+13-32
arch/x86/kernel/apic/x2apic_uv_x.c
···185185unsigned long sn_rtc_cycles_per_second;186186EXPORT_SYMBOL(sn_rtc_cycles_per_second);187187188188-static const struct cpumask *uv_target_cpus(void)189189-{190190- return cpu_online_mask;191191-}192192-193193-static void uv_vector_allocation_domain(int cpu, struct cpumask *retmask)194194-{195195- cpumask_clear(retmask);196196- cpumask_set_cpu(cpu, retmask);197197-}198198-199188static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_rip)200189{201190#ifdef CONFIG_SMP···269280{270281}271282272272-static unsigned int uv_cpu_mask_to_apicid(const struct cpumask *cpumask)273273-{274274- /*275275- * We're using fixed IRQ delivery, can only return one phys APIC ID.276276- * May as well be the first.277277- */278278- int cpu = cpumask_first(cpumask);279279-280280- if ((unsigned)cpu < nr_cpu_ids)281281- return per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits;282282- else283283- return BAD_APICID;284284-}285285-286286-static unsigned int283283+static int287284uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,288288- const struct cpumask *andmask)285285+ const struct cpumask *andmask,286286+ unsigned int *apicid)289287{290290- int cpu;288288+ int unsigned cpu;291289292290 /*293291 * We're using fixed IRQ delivery, can only return one phys APIC ID.···284308 if (cpumask_test_cpu(cpu, cpu_online_mask))285309 break;286310 }287287- return per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits;311311+312312+ if (likely(cpu < nr_cpu_ids)) {313313+ *apicid = per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits;314314+ return 0;315315+ }316316+317317+ return -EINVAL;288318}289319290320static unsigned int x2apic_get_apic_id(unsigned long x)···344362 .irq_delivery_mode = dest_Fixed,345363 .irq_dest_mode = 0, /* physical */346364347347- .target_cpus = uv_target_cpus,365365+ .target_cpus = online_target_cpus,348366 .disable_esr = 0,349367 .dest_logical = APIC_DEST_LOGICAL,350368 .check_apicid_used = NULL,351369 .check_apicid_present = NULL,352370353353- .vector_allocation_domain = uv_vector_allocation_domain,371371+ .vector_allocation_domain = default_vector_allocation_domain,354372 .init_apic_ldr = uv_init_apic_ldr,355373356374 .ioapic_phys_id_map = NULL,···368386 .set_apic_id = set_apic_id,369387 .apic_id_mask = 0xFFFFFFFFu,370388371371- .cpu_mask_to_apicid = uv_cpu_mask_to_apicid,372389 .cpu_mask_to_apicid_and = uv_cpu_mask_to_apicid_and,373390374391 .send_IPI_mask = uv_send_IPI_mask,
+6-6
arch/x86/kernel/early_printk.c
···119119 unsigned char c;120120 unsigned divisor;121121 unsigned baud = DEFAULT_BAUD;122122- char *e;122122+ ssize_t ret;123123124124 if (*s == ',')125125 ++s;···127127 if (*s) {128128 unsigned port;129129 if (!strncmp(s, "0x", 2)) {130130- early_serial_base = simple_strtoul(s, &e, 16);130130+ ret = kstrtoint(s, 16, &early_serial_base);131131 } else {132132 static const int __initconst bases[] = { 0x3f8, 0x2f8 };133133134134 if (!strncmp(s, "ttyS", 4))135135 s += 4;136136- port = simple_strtoul(s, &e, 10);137137- if (port > 1 || s == e)136136+ ret = kstrtouint(s, 10, &port);137137+ if (ret || port > 1)138138 port = 0;139139 early_serial_base = bases[port];140140 }···149149 outb(0x3, early_serial_base + MCR); /* DTR + RTS */150150151151 if (*s) {152152- baud = simple_strtoul(s, &e, 0);153153- if (baud == 0 || s == e)152152+ ret = kstrtouint(s, 0, &baud);153153+ if (ret || baud == 0)154154 baud = DEFAULT_BAUD;155155 }156156
···5959 unsigned int, int,6060 struct io_apic_irq_attr *);61616262-#ifdef CONFIG_SMP6362 /* Set the CPU affinity of a remapped interrupt */6463 int (*set_affinity)(struct irq_data *data, const struct cpumask *mask,6564 bool force);6666-#endif67656866 /* Free an IRQ */6967 int (*free_irq)(int);