aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/io_apic_32.c
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-08-19 23:50:05 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-16 10:52:29 -0400
commit08678b0841267c1d00d771fe01548d86043d065e (patch)
tree7debb21f9e9a768ced43077f7376797a0c46f8c0 /arch/x86/kernel/io_apic_32.c
parentbfea1238beac9d306eeac081c67de5ca6aec4c7a (diff)
generic: sparse irqs: use irq_desc() together with dyn_array, instead of irq_desc[]
add CONFIG_HAVE_SPARSE_IRQ to for use condensed array. Get rid of irq_desc[] array assumptions. Preallocate 32 irq_desc, and irq_desc() will try to get more. ( No change in functionality is expected anywhere, except the odd build failure where we missed a code site or where a crossing commit itroduces new irq_desc[] usage. ) v2: according to Eric, change get_irq_desc() to irq_desc() Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/io_apic_32.c')
-rw-r--r--arch/x86/kernel/io_apic_32.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/arch/x86/kernel/io_apic_32.c b/arch/x86/kernel/io_apic_32.c
index 7f2bcc3dad82..c2160cfdec9b 100644
--- a/arch/x86/kernel/io_apic_32.c
+++ b/arch/x86/kernel/io_apic_32.c
@@ -345,6 +345,7 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
345 struct irq_pin_list *entry = irq_2_pin + irq; 345 struct irq_pin_list *entry = irq_2_pin + irq;
346 unsigned int apicid_value; 346 unsigned int apicid_value;
347 cpumask_t tmp; 347 cpumask_t tmp;
348 struct irq_desc *desc;
348 349
349 cpus_and(tmp, cpumask, cpu_online_map); 350 cpus_and(tmp, cpumask, cpu_online_map);
350 if (cpus_empty(tmp)) 351 if (cpus_empty(tmp))
@@ -365,7 +366,8 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
365 break; 366 break;
366 entry = irq_2_pin + entry->next; 367 entry = irq_2_pin + entry->next;
367 } 368 }
368 irq_desc[irq].affinity = cpumask; 369 desc = irq_to_desc(irq);
370 desc->affinity = cpumask;
369 spin_unlock_irqrestore(&ioapic_lock, flags); 371 spin_unlock_irqrestore(&ioapic_lock, flags);
370} 372}
371 373
@@ -475,10 +477,12 @@ static inline void balance_irq(int cpu, int irq)
475static inline void rotate_irqs_among_cpus(unsigned long useful_load_threshold) 477static inline void rotate_irqs_among_cpus(unsigned long useful_load_threshold)
476{ 478{
477 int i, j; 479 int i, j;
480 struct irq_desc *desc;
478 481
479 for_each_online_cpu(i) { 482 for_each_online_cpu(i) {
480 for (j = 0; j < nr_irqs; j++) { 483 for (j = 0; j < nr_irqs; j++) {
481 if (!irq_desc[j].action) 484 desc = irq_to_desc(j);
485 if (!desc->action)
482 continue; 486 continue;
483 /* Is it a significant load ? */ 487 /* Is it a significant load ? */
484 if (IRQ_DELTA(CPU_TO_PACKAGEINDEX(i), j) < 488 if (IRQ_DELTA(CPU_TO_PACKAGEINDEX(i), j) <
@@ -505,6 +509,7 @@ static void do_irq_balance(void)
505 unsigned long tmp_cpu_irq; 509 unsigned long tmp_cpu_irq;
506 unsigned long imbalance = 0; 510 unsigned long imbalance = 0;
507 cpumask_t allowed_mask, target_cpu_mask, tmp; 511 cpumask_t allowed_mask, target_cpu_mask, tmp;
512 struct irq_desc *desc;
508 513
509 for_each_possible_cpu(i) { 514 for_each_possible_cpu(i) {
510 int package_index; 515 int package_index;
@@ -515,7 +520,8 @@ static void do_irq_balance(void)
515 for (j = 0; j < nr_irqs; j++) { 520 for (j = 0; j < nr_irqs; j++) {
516 unsigned long value_now, delta; 521 unsigned long value_now, delta;
517 /* Is this an active IRQ or balancing disabled ? */ 522 /* Is this an active IRQ or balancing disabled ? */
518 if (!irq_desc[j].action || irq_balancing_disabled(j)) 523 desc = irq_to_desc(j);
524 if (!desc->action || irq_balancing_disabled(j))
519 continue; 525 continue;
520 if (package_index == i) 526 if (package_index == i)
521 IRQ_DELTA(package_index, j) = 0; 527 IRQ_DELTA(package_index, j) = 0;
@@ -609,7 +615,8 @@ tryanotherirq:
609 selected_irq = -1; 615 selected_irq = -1;
610 for (j = 0; j < nr_irqs; j++) { 616 for (j = 0; j < nr_irqs; j++) {
611 /* Is this an active IRQ? */ 617 /* Is this an active IRQ? */
612 if (!irq_desc[j].action) 618 desc = irq_to_desc(j);
619 if (!desc->action)
613 continue; 620 continue;
614 if (imbalance <= IRQ_DELTA(max_loaded, j)) 621 if (imbalance <= IRQ_DELTA(max_loaded, j))
615 continue; 622 continue;
@@ -682,10 +689,12 @@ static int balanced_irq(void *unused)
682 int i; 689 int i;
683 unsigned long prev_balance_time = jiffies; 690 unsigned long prev_balance_time = jiffies;
684 long time_remaining = balanced_irq_interval; 691 long time_remaining = balanced_irq_interval;
692 struct irq_desc *desc;
685 693
686 /* push everything to CPU 0 to give us a starting point. */ 694 /* push everything to CPU 0 to give us a starting point. */
687 for (i = 0 ; i < nr_irqs ; i++) { 695 for (i = 0 ; i < nr_irqs ; i++) {
688 irq_desc[i].pending_mask = cpumask_of_cpu(0); 696 desc = irq_to_desc(i);
697 desc->pending_mask = cpumask_of_cpu(0);
689 set_pending_irq(i, cpumask_of_cpu(0)); 698 set_pending_irq(i, cpumask_of_cpu(0));
690 } 699 }
691 700
@@ -1254,13 +1263,16 @@ static struct irq_chip ioapic_chip;
1254 1263
1255static void ioapic_register_intr(int irq, int vector, unsigned long trigger) 1264static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
1256{ 1265{
1266 struct irq_desc *desc;
1267
1268 desc = irq_to_desc(irq);
1257 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || 1269 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
1258 trigger == IOAPIC_LEVEL) { 1270 trigger == IOAPIC_LEVEL) {
1259 irq_desc[irq].status |= IRQ_LEVEL; 1271 desc->status |= IRQ_LEVEL;
1260 set_irq_chip_and_handler_name(irq, &ioapic_chip, 1272 set_irq_chip_and_handler_name(irq, &ioapic_chip,
1261 handle_fasteoi_irq, "fasteoi"); 1273 handle_fasteoi_irq, "fasteoi");
1262 } else { 1274 } else {
1263 irq_desc[irq].status &= ~IRQ_LEVEL; 1275 desc->status &= ~IRQ_LEVEL;
1264 set_irq_chip_and_handler_name(irq, &ioapic_chip, 1276 set_irq_chip_and_handler_name(irq, &ioapic_chip,
1265 handle_edge_irq, "edge"); 1277 handle_edge_irq, "edge");
1266 } 1278 }
@@ -2027,6 +2039,7 @@ static struct irq_chip ioapic_chip __read_mostly = {
2027static inline void init_IO_APIC_traps(void) 2039static inline void init_IO_APIC_traps(void)
2028{ 2040{
2029 int irq; 2041 int irq;
2042 struct irq_desc *desc;
2030 2043
2031 /* 2044 /*
2032 * NOTE! The local APIC isn't very good at handling 2045 * NOTE! The local APIC isn't very good at handling
@@ -2048,9 +2061,11 @@ static inline void init_IO_APIC_traps(void)
2048 */ 2061 */
2049 if (irq < 16) 2062 if (irq < 16)
2050 make_8259A_irq(irq); 2063 make_8259A_irq(irq);
2051 else 2064 else {
2065 desc = irq_to_desc(irq);
2052 /* Strange. Oh, well.. */ 2066 /* Strange. Oh, well.. */
2053 irq_desc[irq].chip = &no_irq_chip; 2067 desc->chip = &no_irq_chip;
2068 }
2054 } 2069 }
2055 } 2070 }
2056} 2071}
@@ -2089,7 +2104,10 @@ static struct irq_chip lapic_chip __read_mostly = {
2089 2104
2090static void lapic_register_intr(int irq, int vector) 2105static void lapic_register_intr(int irq, int vector)
2091{ 2106{
2092 irq_desc[irq].status &= ~IRQ_LEVEL; 2107 struct irq_desc *desc;
2108
2109 desc = irq_to_desc(irq);
2110 desc->status &= ~IRQ_LEVEL;
2093 set_irq_chip_and_handler_name(irq, &lapic_chip, handle_edge_irq, 2111 set_irq_chip_and_handler_name(irq, &lapic_chip, handle_edge_irq,
2094 "edge"); 2112 "edge");
2095 set_intr_gate(vector, interrupt[irq]); 2113 set_intr_gate(vector, interrupt[irq]);
@@ -2556,6 +2574,7 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
2556 unsigned int dest; 2574 unsigned int dest;
2557 cpumask_t tmp; 2575 cpumask_t tmp;
2558 int vector; 2576 int vector;
2577 struct irq_desc *desc;
2559 2578
2560 cpus_and(tmp, mask, cpu_online_map); 2579 cpus_and(tmp, mask, cpu_online_map);
2561 if (cpus_empty(tmp)) 2580 if (cpus_empty(tmp))
@@ -2575,7 +2594,8 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
2575 msg.address_lo |= MSI_ADDR_DEST_ID(dest); 2594 msg.address_lo |= MSI_ADDR_DEST_ID(dest);
2576 2595
2577 write_msi_msg(irq, &msg); 2596 write_msi_msg(irq, &msg);
2578 irq_desc[irq].affinity = mask; 2597 desc = irq_to_desc(irq);
2598 desc->affinity = mask;
2579} 2599}
2580#endif /* CONFIG_SMP */ 2600#endif /* CONFIG_SMP */
2581 2601
@@ -2649,6 +2669,7 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
2649{ 2669{
2650 unsigned int dest; 2670 unsigned int dest;
2651 cpumask_t tmp; 2671 cpumask_t tmp;
2672 struct irq_desc *desc;
2652 2673
2653 cpus_and(tmp, mask, cpu_online_map); 2674 cpus_and(tmp, mask, cpu_online_map);
2654 if (cpus_empty(tmp)) 2675 if (cpus_empty(tmp))
@@ -2659,7 +2680,8 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
2659 dest = cpu_mask_to_apicid(mask); 2680 dest = cpu_mask_to_apicid(mask);
2660 2681
2661 target_ht_irq(irq, dest); 2682 target_ht_irq(irq, dest);
2662 irq_desc[irq].affinity = mask; 2683 desc = irq_to_desc(irq);
2684 desc->affinity = mask;
2663} 2685}
2664#endif 2686#endif
2665 2687