x86: use dyn_array in io_apic_xx.c
[deliverable/linux.git] / arch / x86 / kernel / io_apic_64.c
index 02063ae042f72ae979a13b57035bd0d91f1dcb59..93a3ffabfe6a1927438459252121a061d2e2e261 100644 (file)
@@ -66,7 +66,7 @@ struct irq_cfg {
 };
 
 /* irq_cfg is indexed by the sum of all RTEs in all I/O APICs. */
-static struct irq_cfg irq_cfg[NR_IRQS] __read_mostly = {
+static struct irq_cfg irq_cfg_legacy[] __initdata = {
        [0]  = { .domain = CPU_MASK_ALL, .vector = IRQ0_VECTOR,  },
        [1]  = { .domain = CPU_MASK_ALL, .vector = IRQ1_VECTOR,  },
        [2]  = { .domain = CPU_MASK_ALL, .vector = IRQ2_VECTOR,  },
@@ -85,6 +85,17 @@ static struct irq_cfg irq_cfg[NR_IRQS] __read_mostly = {
        [15] = { .domain = CPU_MASK_ALL, .vector = IRQ15_VECTOR, },
 };
 
+static struct irq_cfg *irq_cfg;
+
+static void __init init_work(void *data)
+{
+       struct dyn_array *da = data;
+
+       memcpy(*da->name, irq_cfg_legacy, sizeof(irq_cfg_legacy));
+}
+
+DEFINE_DYN_ARRAY(irq_cfg, sizeof(struct irq_cfg), nr_irqs, PAGE_SIZE, init_work);
+
 static int assign_irq_vector(int irq, cpumask_t mask);
 
 int first_system_vector = 0xfe;
@@ -129,8 +140,8 @@ DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
  * Rough estimation of how many shared IRQs there are, can
  * be changed anytime.
  */
-#define MAX_PLUS_SHARED_IRQS NR_IRQS
-#define PIN_MAP_SIZE (MAX_PLUS_SHARED_IRQS + NR_IRQS)
+
+int pin_map_size;
 
 /*
  * This is performance-critical, we want to do it O(1)
@@ -140,8 +151,12 @@ DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
  */
 
 static struct irq_pin_list {
-       short apic, pin, next;
-} irq_2_pin[PIN_MAP_SIZE];
+       short apic, pin;
+       int next;
+} *irq_2_pin;
+
+DEFINE_DYN_ARRAY(irq_2_pin, sizeof(struct irq_pin_list), pin_map_size, sizeof(struct irq_pin_list), NULL);
+
 
 struct io_apic {
        unsigned int index;
@@ -224,7 +239,7 @@ static inline void io_apic_sync(unsigned int apic)
        int pin;                                                        \
        struct irq_pin_list *entry = irq_2_pin + irq;                   \
                                                                        \
-       BUG_ON(irq >= NR_IRQS);                                         \
+       BUG_ON(irq >= nr_irqs);                                         \
        for (;;) {                                                      \
                unsigned int reg;                                       \
                pin = entry->pin;                                       \
@@ -301,7 +316,7 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, u8 vector)
        int apic, pin;
        struct irq_pin_list *entry = irq_2_pin + irq;
 
-       BUG_ON(irq >= NR_IRQS);
+       BUG_ON(irq >= nr_irqs);
        for (;;) {
                unsigned int reg;
                apic = entry->apic;
@@ -358,19 +373,19 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t mask)
  * shared ISA-space IRQs, so we have to support them. We are super
  * fast in the common case, and fast for shared ISA-space IRQs.
  */
+int first_free_entry;
 static void add_pin_to_irq(unsigned int irq, int apic, int pin)
 {
-       static int first_free_entry = NR_IRQS;
        struct irq_pin_list *entry = irq_2_pin + irq;
 
-       BUG_ON(irq >= NR_IRQS);
+       BUG_ON(irq >= nr_irqs);
        while (entry->next)
                entry = irq_2_pin + entry->next;
 
        if (entry->pin != -1) {
                entry->next = first_free_entry;
                entry = irq_2_pin + entry->next;
-               if (++first_free_entry >= PIN_MAP_SIZE)
+               if (++first_free_entry >= pin_map_size)
                        panic("io_apic.c: ran out of irq_2_pin entries!");
        }
        entry->apic = apic;
@@ -634,7 +649,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin)
                                best_guess = irq;
                }
        }
-       BUG_ON(best_guess >= NR_IRQS);
+       BUG_ON(best_guess >= nr_irqs);
        return best_guess;
 }
 
@@ -766,7 +781,7 @@ static int pin_2_irq(int idx, int apic, int pin)
                        irq += nr_ioapic_registers[i++];
                irq += pin;
        }
-       BUG_ON(irq >= NR_IRQS);
+       BUG_ON(irq >= nr_irqs);
        return irq;
 }
 
@@ -801,7 +816,7 @@ static int __assign_irq_vector(int irq, cpumask_t mask)
        int cpu;
        struct irq_cfg *cfg;
 
-       BUG_ON((unsigned)irq >= NR_IRQS);
+       BUG_ON((unsigned)irq >= nr_irqs);
        cfg = &irq_cfg[irq];
 
        /* Only try and allocate irqs on cpus that are present */
@@ -875,7 +890,7 @@ static void __clear_irq_vector(int irq)
        cpumask_t mask;
        int cpu, vector;
 
-       BUG_ON((unsigned)irq >= NR_IRQS);
+       BUG_ON((unsigned)irq >= nr_irqs);
        cfg = &irq_cfg[irq];
        BUG_ON(!cfg->vector);
 
@@ -895,7 +910,7 @@ void __setup_vector_irq(int cpu)
        int irq, vector;
 
        /* Mark the inuse vectors */
-       for (irq = 0; irq < NR_IRQS; ++irq) {
+       for (irq = 0; irq < nr_irqs; ++irq) {
                if (!cpu_isset(cpu, irq_cfg[irq].domain))
                        continue;
                vector = irq_cfg[irq].vector;
@@ -1193,7 +1208,7 @@ __apicdebuginit(void) print_IO_APIC(void)
        }
        }
        printk(KERN_DEBUG "IRQ to pin mappings:\n");
-       for (i = 0; i < NR_IRQS; i++) {
+       for (i = 0; i < nr_irqs; i++) {
                struct irq_pin_list *entry = irq_2_pin + i;
                if (entry->pin < 0)
                        continue;
@@ -1366,7 +1381,7 @@ void __init enable_IO_APIC(void)
        int i, apic;
        unsigned long flags;
 
-       for (i = 0; i < PIN_MAP_SIZE; i++) {
+       for (i = 0; i < pin_map_size; i++) {
                irq_2_pin[i].pin = -1;
                irq_2_pin[i].next = 0;
        }
@@ -1658,7 +1673,7 @@ static void ir_irq_migration(struct work_struct *work)
 {
        int irq;
 
-       for (irq = 0; irq < NR_IRQS; irq++) {
+       for (irq = 0; irq < nr_irqs; irq++) {
                struct irq_desc *desc = irq_desc + irq;
                if (desc->status & IRQ_MOVE_PENDING) {
                        unsigned long flags;
@@ -1707,7 +1722,7 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void)
                struct irq_desc *desc;
                struct irq_cfg *cfg;
                irq = __get_cpu_var(vector_irq)[vector];
-               if (irq >= NR_IRQS)
+               if (irq >= nr_irqs)
                        continue;
 
                desc = irq_desc + irq;
@@ -1865,7 +1880,7 @@ static inline void init_IO_APIC_traps(void)
         * Also, we've got to be careful not to trash gate
         * 0x80, because int 0x80 is hm, kind of importantish. ;)
         */
-       for (irq = 0; irq < NR_IRQS ; irq++) {
+       for (irq = 0; irq < nr_irqs ; irq++) {
                if (IO_APIC_IRQ(irq) && !irq_cfg[irq].vector) {
                        /*
                         * Hmm.. We don't have an entry for this,
@@ -2279,7 +2294,7 @@ int create_irq(void)
 
        irq = -ENOSPC;
        spin_lock_irqsave(&vector_lock, flags);
-       for (new = (NR_IRQS - 1); new >= 0; new--) {
+       for (new = (nr_irqs - 1); new >= 0; new--) {
                if (platform_legacy_irq(new))
                        continue;
                if (irq_cfg[new].vector != 0)
This page took 0.034535 seconds and 5 git commands to generate.