Commit 7eb9ae0799b1e9f0b77733b432bc5f6f055b020b

Authored by Suresh Siddha
Committed by Ingo Molnar
1 parent 879060d574

irq/apic: Use config_enabled(CONFIG_SMP) checks to clean up irq_set_affinity() for UP

Move the ->irq_set_affinity() routines out of the #ifdef CONFIG_SMP
sections and use config_enabled(CONFIG_SMP) checks inside those
routines. Thus making those routines simple null stubs for
!CONFIG_SMP and retaining those routines with no additional
runtime overhead for CONFIG_SMP kernels.

Cleans up the ifdef CONFIG_SMP in and around routines related to
irq_set_affinity in io_apic and irq_remapping subsystems.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: torvalds@linux-foundation.org
Cc: joerg.roedel@amd.com
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Link: http://lkml.kernel.org/r/1339723729.3475.63.camel@sbsiddha-desk.sc.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

Showing 5 changed files with 86 additions and 110 deletions Side-by-side Diff

arch/x86/kernel/apic/io_apic.c
... ... @@ -2224,81 +2224,6 @@
2224 2224 cfg->move_in_progress = 0;
2225 2225 }
2226 2226  
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   - unsigned int irq = data->irq;
2261   - int err;
2262   -
2263   - if (!cpumask_intersects(mask, cpu_online_mask))
2264   - return -EINVAL;
2265   -
2266   - err = assign_irq_vector(irq, cfg, mask);
2267   - if (err)
2268   - return err;
2269   -
2270   - err = apic->cpu_mask_to_apicid_and(mask, cfg->domain, dest_id);
2271   - if (err) {
2272   - if (assign_irq_vector(irq, cfg, data->affinity))
2273   - pr_err("Failed to recover vector for irq %d\n", irq);
2274   - return err;
2275   - }
2276   -
2277   - cpumask_copy(data->affinity, mask);
2278   -
2279   - return 0;
2280   -}
2281   -
2282   -static int
2283   -ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
2284   - bool force)
2285   -{
2286   - unsigned int dest, irq = data->irq;
2287   - unsigned long flags;
2288   - int ret;
2289   -
2290   - raw_spin_lock_irqsave(&ioapic_lock, flags);
2291   - ret = __ioapic_set_affinity(data, mask, &dest);
2292   - if (!ret) {
2293   - /* Only the high 8 bits are valid. */
2294   - dest = SET_APIC_LOGICAL_ID(dest);
2295   - __target_IO_APIC_irq(irq, dest, data->chip_data);
2296   - ret = IRQ_SET_MASK_OK_NOCOPY;
2297   - }
2298   - raw_spin_unlock_irqrestore(&ioapic_lock, flags);
2299   - return ret;
2300   -}
2301   -
2302 2227 asmlinkage void smp_irq_move_cleanup_interrupt(void)
2303 2228 {
2304 2229 unsigned vector, me;
... ... @@ -2386,6 +2311,87 @@
2386 2311 static inline void irq_complete_move(struct irq_cfg *cfg) { }
2387 2312 #endif
2388 2313  
  2314 +static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq_cfg *cfg)
  2315 +{
  2316 + int apic, pin;
  2317 + struct irq_pin_list *entry;
  2318 + u8 vector = cfg->vector;
  2319 +
  2320 + for_each_irq_pin(entry, cfg->irq_2_pin) {
  2321 + unsigned int reg;
  2322 +
  2323 + apic = entry->apic;
  2324 + pin = entry->pin;
  2325 + /*
  2326 + * With interrupt-remapping, destination information comes
  2327 + * from interrupt-remapping table entry.
  2328 + */
  2329 + if (!irq_remapped(cfg))
  2330 + io_apic_write(apic, 0x11 + pin*2, dest);
  2331 + reg = io_apic_read(apic, 0x10 + pin*2);
  2332 + reg &= ~IO_APIC_REDIR_VECTOR_MASK;
  2333 + reg |= vector;
  2334 + io_apic_modify(apic, 0x10 + pin*2, reg);
  2335 + }
  2336 +}
  2337 +
  2338 +/*
  2339 + * Either sets data->affinity to a valid value, and returns
  2340 + * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and
  2341 + * leaves data->affinity untouched.
  2342 + */
  2343 +int __ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
  2344 + unsigned int *dest_id)
  2345 +{
  2346 + struct irq_cfg *cfg = data->chip_data;
  2347 + unsigned int irq = data->irq;
  2348 + int err;
  2349 +
  2350 + if (!config_enabled(CONFIG_SMP))
  2351 + return -1;
  2352 +
  2353 + if (!cpumask_intersects(mask, cpu_online_mask))
  2354 + return -EINVAL;
  2355 +
  2356 + err = assign_irq_vector(irq, cfg, mask);
  2357 + if (err)
  2358 + return err;
  2359 +
  2360 + err = apic->cpu_mask_to_apicid_and(mask, cfg->domain, dest_id);
  2361 + if (err) {
  2362 + if (assign_irq_vector(irq, cfg, data->affinity))
  2363 + pr_err("Failed to recover vector for irq %d\n", irq);
  2364 + return err;
  2365 + }
  2366 +
  2367 + cpumask_copy(data->affinity, mask);
  2368 +
  2369 + return 0;
  2370 +}
  2371 +
  2372 +static int
  2373 +ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
  2374 + bool force)
  2375 +{
  2376 + unsigned int dest, irq = data->irq;
  2377 + unsigned long flags;
  2378 + int ret;
  2379 +
  2380 + if (!config_enabled(CONFIG_SMP))
  2381 + return -1;
  2382 +
  2383 + raw_spin_lock_irqsave(&ioapic_lock, flags);
  2384 + ret = __ioapic_set_affinity(data, mask, &dest);
  2385 + if (!ret) {
  2386 + /* Only the high 8 bits are valid. */
  2387 + dest = SET_APIC_LOGICAL_ID(dest);
  2388 + __target_IO_APIC_irq(irq, dest, data->chip_data);
  2389 + ret = IRQ_SET_MASK_OK_NOCOPY;
  2390 + }
  2391 + raw_spin_unlock_irqrestore(&ioapic_lock, flags);
  2392 + return ret;
  2393 +}
  2394 +
2389 2395 static void ack_apic_edge(struct irq_data *data)
2390 2396 {
2391 2397 irq_complete_move(data->chip_data);
2392 2398  
... ... @@ -2565,9 +2571,7 @@
2565 2571 chip->irq_ack = ir_ack_apic_edge;
2566 2572 chip->irq_eoi = ir_ack_apic_level;
2567 2573  
2568   -#ifdef CONFIG_SMP
2569 2574 chip->irq_set_affinity = set_remapped_irq_affinity;
2570   -#endif
2571 2575 }
2572 2576 #endif /* CONFIG_IRQ_REMAP */
2573 2577  
2574 2578  
... ... @@ -2578,9 +2582,7 @@
2578 2582 .irq_unmask = unmask_ioapic_irq,
2579 2583 .irq_ack = ack_apic_edge,
2580 2584 .irq_eoi = ack_apic_level,
2581   -#ifdef CONFIG_SMP
2582 2585 .irq_set_affinity = ioapic_set_affinity,
2583   -#endif
2584 2586 .irq_retrigger = ioapic_retrigger_irq,
2585 2587 };
2586 2588  
... ... @@ -3099,7 +3101,6 @@
3099 3101 return err;
3100 3102 }
3101 3103  
3102   -#ifdef CONFIG_SMP
3103 3104 static int
3104 3105 msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)
3105 3106 {
... ... @@ -3121,7 +3122,6 @@
3121 3122  
3122 3123 return IRQ_SET_MASK_OK_NOCOPY;
3123 3124 }
3124   -#endif /* CONFIG_SMP */
3125 3125  
3126 3126 /*
3127 3127 * IRQ Chip for MSI PCI/PCI-X/PCI-Express Devices,
3128 3128  
... ... @@ -3132,9 +3132,7 @@
3132 3132 .irq_unmask = unmask_msi_irq,
3133 3133 .irq_mask = mask_msi_irq,
3134 3134 .irq_ack = ack_apic_edge,
3135   -#ifdef CONFIG_SMP
3136 3135 .irq_set_affinity = msi_set_affinity,
3137   -#endif
3138 3136 .irq_retrigger = ioapic_retrigger_irq,
3139 3137 };
3140 3138  
... ... @@ -3219,7 +3217,6 @@
3219 3217 }
3220 3218  
3221 3219 #ifdef CONFIG_DMAR_TABLE
3222   -#ifdef CONFIG_SMP
3223 3220 static int
3224 3221 dmar_msi_set_affinity(struct irq_data *data, const struct cpumask *mask,
3225 3222 bool force)
3226 3223  
3227 3224  
... ... @@ -3244,16 +3241,12 @@
3244 3241 return IRQ_SET_MASK_OK_NOCOPY;
3245 3242 }
3246 3243  
3247   -#endif /* CONFIG_SMP */
3248   -
3249 3244 static struct irq_chip dmar_msi_type = {
3250 3245 .name = "DMAR_MSI",
3251 3246 .irq_unmask = dmar_msi_unmask,
3252 3247 .irq_mask = dmar_msi_mask,
3253 3248 .irq_ack = ack_apic_edge,
3254   -#ifdef CONFIG_SMP
3255 3249 .irq_set_affinity = dmar_msi_set_affinity,
3256   -#endif
3257 3250 .irq_retrigger = ioapic_retrigger_irq,
3258 3251 };
3259 3252  
... ... @@ -3274,7 +3267,6 @@
3274 3267  
3275 3268 #ifdef CONFIG_HPET_TIMER
3276 3269  
3277   -#ifdef CONFIG_SMP
3278 3270 static int hpet_msi_set_affinity(struct irq_data *data,
3279 3271 const struct cpumask *mask, bool force)
3280 3272 {
3281 3273  
3282 3274  
... ... @@ -3297,16 +3289,12 @@
3297 3289 return IRQ_SET_MASK_OK_NOCOPY;
3298 3290 }
3299 3291  
3300   -#endif /* CONFIG_SMP */
3301   -
3302 3292 static struct irq_chip hpet_msi_type = {
3303 3293 .name = "HPET_MSI",
3304 3294 .irq_unmask = hpet_msi_unmask,
3305 3295 .irq_mask = hpet_msi_mask,
3306 3296 .irq_ack = ack_apic_edge,
3307   -#ifdef CONFIG_SMP
3308 3297 .irq_set_affinity = hpet_msi_set_affinity,
3309   -#endif
3310 3298 .irq_retrigger = ioapic_retrigger_irq,
3311 3299 };
3312 3300  
... ... @@ -3341,8 +3329,6 @@
3341 3329 */
3342 3330 #ifdef CONFIG_HT_IRQ
3343 3331  
3344   -#ifdef CONFIG_SMP
3345   -
3346 3332 static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector)
3347 3333 {
3348 3334 struct ht_irq_msg msg;
3349 3335  
3350 3336  
... ... @@ -3370,16 +3356,12 @@
3370 3356 return IRQ_SET_MASK_OK_NOCOPY;
3371 3357 }
3372 3358  
3373   -#endif
3374   -
3375 3359 static struct irq_chip ht_irq_chip = {
3376 3360 .name = "PCI-HT",
3377 3361 .irq_mask = mask_ht_irq,
3378 3362 .irq_unmask = unmask_ht_irq,
3379 3363 .irq_ack = ack_apic_edge,
3380   -#ifdef CONFIG_SMP
3381 3364 .irq_set_affinity = ht_set_affinity,
3382   -#endif
3383 3365 .irq_retrigger = ioapic_retrigger_irq,
3384 3366 };
3385 3367  
drivers/iommu/intel_irq_remapping.c
... ... @@ -902,7 +902,6 @@
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 *
... ... @@ -926,6 +925,9 @@
926 925 struct irte irte;
927 926 int err;
928 927  
  928 + if (!config_enabled(CONFIG_SMP))
  929 + return -EINVAL;
  930 +
929 931 if (!cpumask_intersects(mask, cpu_online_mask))
930 932 return -EINVAL;
931 933  
... ... @@ -963,7 +965,6 @@
963 965 cpumask_copy(data->affinity, mask);
964 966 return 0;
965 967 }
966   -#endif
967 968  
968 969 static void intel_compose_msi_msg(struct pci_dev *pdev,
969 970 unsigned int irq, unsigned int dest,
970 971  
... ... @@ -1065,9 +1066,7 @@
1065 1066 .reenable = reenable_irq_remapping,
1066 1067 .enable_faulting = enable_drhd_fault_handling,
1067 1068 .setup_ioapic_entry = intel_setup_ioapic_entry,
1068   -#ifdef CONFIG_SMP
1069 1069 .set_affinity = intel_ioapic_set_affinity,
1070   -#endif
1071 1070 .free_irq = free_irte,
1072 1071 .compose_msi_msg = intel_compose_msi_msg,
1073 1072 .msi_alloc_irq = intel_msi_alloc_irq,
drivers/iommu/irq_remapping.c
... ... @@ -111,16 +111,15 @@
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 {
drivers/iommu/irq_remapping.h
... ... @@ -59,11 +59,9 @@
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);
... ... @@ -150,9 +150,7 @@
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 /*