]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
x86: make 32 bit to use sparse_irq
authorYinghai Lu <yhlu.kernel@gmail.com>
Wed, 20 Aug 2008 03:50:27 +0000 (20:50 -0700)
committerIngo Molnar <mingo@elte.hu>
Thu, 16 Oct 2008 14:52:53 +0000 (16:52 +0200)
but actually irq still needs to be less than NR_IRQS, because
interrupt[NR_IRQS] in entry.S.

need to enable per_cpu vector...

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/Kconfig
arch/x86/kernel/io_apic_32.c
arch/x86/kernel/irq_32.c
arch/x86/kernel/irqinit_32.c

index 3e0eaaa1a339994cea71aac075fbc79680e7f448..b157e94637bf042619555877ac2f88962fe87fbf 100644 (file)
@@ -34,7 +34,7 @@ config X86
        select HAVE_GENERIC_DMA_COHERENT if X86_32
        select HAVE_EFFICIENT_UNALIGNED_ACCESS
        select HAVE_DYN_ARRAY
-       select HAVE_SPARSE_IRQ if X86_64
+       select HAVE_SPARSE_IRQ
 
 config ARCH_DEFCONFIG
        string
index 59d2e8a273e31ac8452a3e5df25659f71bf8d54b..66c0a91362a76cfdfb0d106e617aa7c03c5b692e 100644 (file)
@@ -595,7 +595,6 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
        struct irq_pin_list *entry;
        unsigned int apicid_value;
        cpumask_t tmp;
-       struct irq_desc *desc;
 
 
        cfg = irq_cfg(irq);
@@ -620,8 +619,7 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
                        break;
                entry = entry->next;
        }
-       desc = irq_to_desc(irq);
-       desc->affinity = cpumask;
+       irq_to_desc(irq)->affinity = cpumask;
        spin_unlock_irqrestore(&ioapic_lock, flags);
 }
 
@@ -1055,8 +1053,6 @@ static int __assign_irq_vector(int irq)
        int vector, offset;
        struct irq_cfg *cfg;
 
-       BUG_ON((unsigned)irq >= nr_irqs);
-
        cfg = irq_cfg(irq);
        if (cfg->vector > 0)
                return cfg->vector;
@@ -1103,7 +1099,12 @@ static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
 {
        struct irq_desc *desc;
 
-       desc = irq_to_desc(irq);
+       /* first time to use this irq_desc */
+       if (irq < 16)
+               desc = irq_to_desc(irq);
+       else
+               desc = irq_to_desc_alloc(irq);
+
        if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
            trigger == IOAPIC_LEVEL) {
                desc->status |= IRQ_LEVEL;
@@ -2330,16 +2331,19 @@ device_initcall(ioapic_init_sysfs);
 /*
  * Dynamic irq allocate and deallocation
  */
-int create_irq(void)
+unsigned int create_irq_nr(unsigned int irq_want)
 {
        /* Allocate an unused irq */
-       int irq, new, vector = 0;
+       unsigned int irq, new, vector = 0;
        unsigned long flags;
        struct irq_cfg *cfg_new;
 
-       irq = -ENOSPC;
+       /* only can use bus/dev/fn.. when per_cpu vector is used */
+       irq_want = nr_irqs - 1;
+
+       irq = 0;
        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;
                cfg_new = irq_cfg(new);
@@ -2354,13 +2358,18 @@ int create_irq(void)
        }
        spin_unlock_irqrestore(&vector_lock, flags);
 
-       if (irq >= 0) {
+       if (irq > 0) {
                set_intr_gate(vector, interrupt[irq]);
                dynamic_irq_init(irq);
        }
        return irq;
 }
 
+int create_irq(void)
+{
+       return create_irq_nr(nr_irqs - 1);
+}
+
 void destroy_irq(unsigned int irq)
 {
        unsigned long flags;
@@ -2415,7 +2424,6 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
        unsigned int dest;
        cpumask_t tmp;
        int vector;
-       struct irq_desc *desc;
 
        cpus_and(tmp, mask, cpu_online_map);
        if (cpus_empty(tmp))
@@ -2435,8 +2443,7 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
        msg.address_lo |= MSI_ADDR_DEST_ID(dest);
 
        write_msi_msg(irq, &msg);
-       desc = irq_to_desc(irq);
-       desc->affinity = mask;
+       irq_to_desc(irq)->affinity = mask;
 }
 #endif /* CONFIG_SMP */
 
@@ -2455,13 +2462,31 @@ static struct irq_chip msi_chip = {
        .retrigger      = ioapic_retrigger_irq,
 };
 
+static unsigned int build_irq_for_pci_dev(struct pci_dev *dev)
+{
+       unsigned int irq;
+
+       irq = dev->bus->number;
+       irq <<= 8;
+       irq |= dev->devfn;
+       irq <<= 12;
+
+       return irq;
+}
+
 int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
 {
        struct msi_msg msg;
        int irq, ret;
-       irq = create_irq();
-       if (irq < 0)
-               return irq;
+
+       unsigned int irq_want;
+
+       irq_want = build_irq_for_pci_dev(dev) + 0x100;
+
+       irq = create_irq_nr(irq_want);
+
+       if (irq == 0)
+               return -1;
 
        ret = msi_compose_msg(dev, irq, &msg);
        if (ret < 0) {
@@ -2510,7 +2535,6 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
 {
        unsigned int dest;
        cpumask_t tmp;
-       struct irq_desc *desc;
 
        cpus_and(tmp, mask, cpu_online_map);
        if (cpus_empty(tmp))
@@ -2521,8 +2545,7 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
        dest = cpu_mask_to_apicid(mask);
 
        target_ht_irq(irq, dest);
-       desc = irq_to_desc(irq);
-       desc->affinity = mask;
+       irq_to_desc(irq)->affinity = mask;
 }
 #endif
 
index 576c5df6cad807af1d14468aa4020179ae6f2f31..0a57e39159a8c4e3deec36604cab2a2cd9f135b0 100644 (file)
@@ -224,9 +224,10 @@ unsigned int do_IRQ(struct pt_regs *regs)
        struct pt_regs *old_regs;
        /* high bit used in ret_from_ code */
        int overflow, irq = ~regs->orig_ax;
-       struct irq_desc *desc = irq_to_desc(irq);
+       struct irq_desc *desc;
 
-       if (unlikely((unsigned)irq >= nr_irqs)) {
+       desc = irq_to_desc(irq);
+       if (unlikely(!desc)) {
                printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
                                        __func__, irq);
                BUG();
@@ -263,6 +264,24 @@ int show_interrupts(struct seq_file *p, void *v)
        int i = *(loff_t *) v, j;
        struct irqaction * action;
        unsigned long flags;
+       unsigned int entries;
+       struct irq_desc *desc;
+       int tail = 0;
+
+#ifdef CONFIG_HAVE_SPARSE_IRQ
+       desc = (struct irq_desc *)v;
+       entries = -1U;
+       i = desc->irq;
+       if (!desc->next)
+               tail = 1;
+#else
+       entries = nr_irqs - 1;
+       i = *(loff_t *) v;
+       if (i == nr_irqs)
+               tail = 1;
+       else
+               desc = irq_to_desc(i);
+#endif
 
        if (i == 0) {
                seq_printf(p, "           ");
@@ -271,9 +290,8 @@ int show_interrupts(struct seq_file *p, void *v)
                seq_putc(p, '\n');
        }
 
-       if (i < nr_irqs) {
+       if (i <= entries) {
                unsigned any_count = 0;
-               struct irq_desc *desc = irq_to_desc(i);
 
                spin_lock_irqsave(&desc->lock, flags);
 #ifndef CONFIG_SMP
@@ -285,7 +303,7 @@ int show_interrupts(struct seq_file *p, void *v)
                action = desc->action;
                if (!action && !any_count)
                        goto skip;
-               seq_printf(p, "%3d: ",i);
+               seq_printf(p, "%#x: ",i);
 #ifndef CONFIG_SMP
                seq_printf(p, "%10u ", kstat_irqs(i));
 #else
@@ -304,7 +322,9 @@ int show_interrupts(struct seq_file *p, void *v)
                seq_putc(p, '\n');
 skip:
                spin_unlock_irqrestore(&desc->lock, flags);
-       } else if (i == nr_irqs) {
+       }
+
+       if (tail) {
                seq_printf(p, "NMI: ");
                for_each_online_cpu(j)
                        seq_printf(p, "%10u ", nmi_count(j));
@@ -396,15 +416,14 @@ void fixup_irqs(cpumask_t map)
 {
        unsigned int irq;
        static int warned;
+       struct irq_desc *desc;
 
-       for (irq = 0; irq < nr_irqs; irq++) {
+       for_each_irq_desc(irq, desc) {
                cpumask_t mask;
-               struct irq_desc *desc;
 
                if (irq == 2)
                        continue;
 
-               desc = irq_to_desc(irq);
                cpus_and(mask, desc->affinity, map);
                if (any_online_cpu(mask) == NR_CPUS) {
                        printk("Breaking affinity for irq %i\n", irq);
index 65c1c9507707a68ad0711bd4d9e9d3578f91db32..ded09ac2642e86a1f7935d48c5dae8a66150ad8c 100644 (file)
@@ -69,6 +69,13 @@ void __init init_ISA_irqs (void)
         * 16 old-style INTA-cycle interrupts:
         */
        for (i = 0; i < 16; i++) {
+               /* first time call this irq_desc */
+               struct irq_desc *desc = irq_to_desc_alloc(i);
+
+               desc->status = IRQ_DISABLED;
+               desc->action = NULL;
+               desc->depth = 1;
+
                set_irq_chip_and_handler_name(i, &i8259A_chip,
                                              handle_level_irq, "XT");
        }