From: Venkatraman S venkat@linaro.org
If SPARSE_IRQ is defined, NR_IRQS will not necessarily be relevant. Use the number populated in machine descriptor.
Note: HARDIRQ_BITS is defined as a constant independent of NR_IRQS. Needs review if this assumption makes sense.
Signed-off-by: Venkatraman S venkat@linaro.org --- arch/arm/common/gic.c | 8 ++++---- arch/arm/include/asm/hardirq.h | 6 ++++++ arch/arm/kernel/irq.c | 8 +++++++- 3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c index 4ddd0a6..6fb5fa4 100644 --- a/arch/arm/common/gic.c +++ b/arch/arm/common/gic.c @@ -28,7 +28,7 @@ #include <linux/smp.h> #include <linux/cpumask.h> #include <linux/io.h> - +#include <linux/irqnr.h> #include <asm/irq.h> #include <asm/mach/irq.h> #include <asm/hardware/gic.h> @@ -231,7 +231,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc) goto out;
cascade_irq = gic_irq + chip_data->irq_offset; - if (unlikely(gic_irq < 32 || gic_irq > 1020 || cascade_irq >= NR_IRQS)) + if (unlikely(gic_irq < 32 || gic_irq > 1020 || cascade_irq >= nr_irqs)) do_bad_IRQ(cascade_irq, desc); else generic_handle_irq(cascade_irq); @@ -312,8 +312,8 @@ static void __init gic_dist_init(struct gic_chip_data *gic, * Limit number of interrupts registered to the platform maximum */ irq_limit = gic->irq_offset + gic_irqs; - if (WARN_ON(irq_limit > NR_IRQS)) - irq_limit = NR_IRQS; + if (WARN_ON(irq_limit > nr_irqs)) + irq_limit = nr_irqs;
/* * Setup the Linux IRQ subsystem. diff --git a/arch/arm/include/asm/hardirq.h b/arch/arm/include/asm/hardirq.h index 89ad180..4bea5c0 100644 --- a/arch/arm/include/asm/hardirq.h +++ b/arch/arm/include/asm/hardirq.h @@ -30,6 +30,10 @@ u64 smp_irq_stat_cpu(unsigned int cpu);
#define arch_irq_stat_cpu smp_irq_stat_cpu
+#ifndef NR_IRQS +/* FIXME: Need a better way to derive HARDIRQ_BITS */ +#define HARDIRQ_BITS 10 +#else #if NR_IRQS > 512 #define HARDIRQ_BITS 10 #elif NR_IRQS > 256 @@ -47,6 +51,8 @@ u64 smp_irq_stat_cpu(unsigned int cpu); # error HARDIRQ_BITS is too low! #endif
+#endif + #define __ARCH_IRQ_EXIT_IRQS_DISABLED 1
#endif /* __ASM_HARDIRQ_H */ diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c index 83bbad0..12ffa9d 100644 --- a/arch/arm/kernel/irq.c +++ b/arch/arm/kernel/irq.c @@ -124,7 +124,13 @@ void __init init_IRQ(void) #ifdef CONFIG_SPARSE_IRQ int __init arch_probe_nr_irqs(void) { - nr_irqs = machine_desc->nr_irqs ? machine_desc->nr_irqs : NR_IRQS; + if (machine_desc->nr_irqs) + nr_irqs = machine_desc->nr_irqs; + #ifdef NR_IRQS + else + nr_irqs = NR_IRQS; + #endif + WARN_ON(nr_irqs); return nr_irqs; } #endif