Skip to contentSkip to conversation

arm: GIC: Do not try to register more then NR_IRQS interrupts

PATCH New Pawel Moll 3 participants 4 messages Nov 22, 2010 – Nov 23, 2010 1 message not in the archive Arm (32-bit)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Pawel Moll

author
#1 lore raw

PATCH 1/1 arm: GIC: Do not try to register more then NR_IRQS interrupts

This change limits number of GIC-originating interrupts to the platform maximum (defined by NR_IRQS) while still initialising all distributor registers.

---
 arch/arm/common/gic.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
arch/arm/common/gic.c +6 -8
index 772f95f..20e1412 100644
@@ -231,14 +231,6 @@ void __init gic_dist_init(unsigned int gic_nr, void __iomem *base,
 	max_irq = (max_irq + 1) * 32;
 
 	/*
-	 * The GIC only supports up to 1020 interrupt sources.
-	 * Limit this to either the architected maximum, or the
-	 * platform maximum.
-	 */
-	if (max_irq > max(1020, NR_IRQS))
-		max_irq = max(1020, NR_IRQS);
-
-	/*
 	 * Set all global interrupts to be level triggered, active low.
 	 */
 	for (i = 32; i < max_irq; i += 16)
@@ -264,6 +256,12 @@ void __init gic_dist_init(unsigned int gic_nr, void __iomem *base,
 		writel(0xffffffff, base + GIC_DIST_ENABLE_CLEAR + i * 4 / 32);
 
 	/*
+	 * Limit number of interrupts registered to the platform maximum
+	 */
+	WARN_ON(max_irq > NR_IRQS);
+	max_irq = min(max_irq, NR_IRQS);
+
+	/*
 	 * Setup the Linux IRQ subsystem.
 	 */
 	for (i = irq_start; i < gic_data[gic_nr].irq_offset + max_irq; i++) {
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH 1/1 arm: GIC: Do not try to register more then NR_IRQS interrupts

In reply to Pawel Moll
Quoted 29 lines · Pawel Moll

This change limits number of GIC-originating interrupts to the platform maximum (defined by NR_IRQS) while still initialising all distributor registers.

---
 arch/arm/common/gic.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
arch/arm/common/gic.c +0 -8
index 772f95f..20e1412 100644
@@ -231,14 +231,6 @@ void __init gic_dist_init(unsigned int gic_nr, void __iomem *base,
 	max_irq = (max_irq + 1) * 32;
 
 	/*
-	 * The GIC only supports up to 1020 interrupt sources.
-	 * Limit this to either the architected maximum, or the
-	 * platform maximum.
-	 */
-	if (max_irq > max(1020, NR_IRQS))
-		max_irq = max(1020, NR_IRQS);
-
-	/*
 	 * Set all global interrupts to be level triggered, active low.
 	 */
 	for (i = 32; i < max_irq; i += 16)

arch/arm/common/gic.c void __init gic_dist_init(unsigned int gic_nr, void __iomem *base, · line 264

Quoted 9 lines
arch/arm/common/gic.c +6 -0
@@ -264,6 +256,12 @@ void __init gic_dist_init(unsigned int gic_nr, void __iomem *base,
 		writel(0xffffffff, base + GIC_DIST_ENABLE_CLEAR + i * 4 / 32);
 
 	/*
+	 * Limit number of interrupts registered to the platform maximum
+	 */
+	WARN_ON(max_irq > NR_IRQS);
+	max_irq = min(max_irq, NR_IRQS);
+
+	/*

Maybe make this

	if (WARN_ON(max_irq > NR_IRQS))
		max_irq = NR_IRQS;

That said I wonder if this is correct, at least it looks wrong to me.

First (judging from the name) max_irq is used as irq number, while NR_IRQS must not be used as such (i.e. NR_IRQS - 1 is the last valid number). But maybe the variable is just (IMHO) bad.

arch/arm/common/gic.c void __init gic_dist_init(unsigned int gic_nr, void __iomem *base, · line 267

Quoted 3 lines
arch/arm/common/gic.c +0 -0
 	 * Setup the Linux IRQ subsystem.
 	 */
 	for (i = irq_start; i < gic_data[gic_nr].irq_offset + max_irq; i++) {

And further shouldn't gic_data[gic_nr].irq_offset be taken into account when limiting max_irq?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#4 lore raw

PATCH 1/1 arm: GIC: Do not try to register more then NR_IRQS interrupts

Quoted 5 lines

arch/arm/common/gic.c void __init gic_dist_init(unsigned int gic_nr, void __iomem *base, · line 262

Quoted 2 lines
arch/arm/common/gic.c +2 -0
+   WARN_ON(max_irq > NR_IRQS);
+   max_irq = min(max_irq, NR_IRQS);

Maybe make this

      if (WARN_ON(max_irq > NR_IRQS))
              max_irq = NR_IRQS;

Fine by me :-)

Quoted 3 lines

First (judging from the name) max_irq is used as irq number, while NR_IRQS must not be used as such (i.e. NR_IRQS - 1 is the last valid number). But maybe the variable is just (IMHO) bad.

Yeah, the "max_irq" is actually "gic_irqs" rather than anything else.

Quoted 6 lines
Quoted 3 lines
     * Setup the Linux IRQ subsystem.
     */
    for (i = irq_start; i < gic_data[gic_nr].irq_offset + max_irq;

i++) {
And further shouldn't gic_data[gic_nr].irq_offset be taken into account when limiting max_irq?

That's what happens if you try to make as little changes as possible ;-) I should have Done It Right (TM) immediately. A patch follows.

Cheers!

Pawe?

-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.