Skip to contentSkip to conversation

rb532: check irq number when handling GPIO interrupts

PATCH Applied Florian Fainelli 3 participants 4 messages May 21, 2009 – May 22, 2009 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 rb532: check irq number when handling GPIO interrupts

This patch makes sure that we are not going to clear or change the interrupt status of a GPIO interrupt superior to 13 as this is the maximum number of GPIO interrupt source (p.232 of the RC32434 reference manual).

---

arch/mips/rb532/irq.c +3 -2
index 53eeb5e..afdcafc 100644
@@ -151,7 +151,8 @@ static void rb532_disable_irq(unsigned int irq_nr)
 		mask |= intr_bit;
 		WRITE_MASK(addr, mask);
 
-		if (group == GPIO_MAPPED_IRQ_GROUP)
+		/* There is a maximum of 13 GPIO interrupts */
+		if (group == GPIO_MAPPED_IRQ_GROUP && irq_nr <= (GROUP4_IRQ_BASE + 13))
 			rb532_gpio_set_istat(0, irq_nr - GPIO_MAPPED_IRQ_BASE);
 
 		/*
@@ -174,7 +175,7 @@ static int rb532_set_type(unsigned int irq_nr, unsigned type)
 	int gpio = irq_nr - GPIO_MAPPED_IRQ_BASE;
 	int group = irq_to_group(irq_nr);
 
-	if (group != GPIO_MAPPED_IRQ_GROUP)
+	if (group != GPIO_MAPPED_IRQ_GROUP || irq_nr > (GROUP4_IRQ_BASE + 13))
 		return (type == IRQ_TYPE_LEVEL_HIGH) ? 0 : -EINVAL;
 
 	switch (type) {
#1 lore raw

Hello.

Quoted 12 lines · Florian Fainelli

This patch makes sure that we are not going to clear or change the interrupt status of a GPIO interrupt superior to 13 as this is the maximum number of GPIO interrupt source (p.232 of the RC32434 reference manual).

---

arch/mips/rb532/irq.c +0 -0
index 53eeb5e..afdcafc 100644

arch/mips/rb532/irq.c static void rb532_disable_irq(unsigned int irq_nr) · line 155

Quoted 6 lines
arch/mips/rb532/irq.c +2 -1
@@ -151,7 +151,8 @@ static void rb532_disable_irq(unsigned int irq_nr)
 		mask |= intr_bit;
 		WRITE_MASK(addr, mask);
 
-		if (group == GPIO_MAPPED_IRQ_GROUP)
+		/* There is a maximum of 13 GPIO interrupts */
+		if (group == GPIO_MAPPED_IRQ_GROUP && irq_nr <= (GROUP4_IRQ_BASE + 13))

So, 13 or 14? The code seem to allow 14. Probably it should be <, not <=
here...

arch/mips/rb532/irq.c static int rb532_set_type(unsigned int irq_nr, unsigned type) · line 178

Quoted 9 lines
arch/mips/rb532/irq.c +1 -1
 			rb532_gpio_set_istat(0, irq_nr - GPIO_MAPPED_IRQ_BASE);
 
 		/*
@@ -174,7 +175,7 @@ static int rb532_set_type(unsigned int irq_nr, unsigned type)
 	int gpio = irq_nr - GPIO_MAPPED_IRQ_BASE;
 	int group = irq_to_group(irq_nr);
 
-	if (group != GPIO_MAPPED_IRQ_GROUP)
+	if (group != GPIO_MAPPED_IRQ_GROUP || irq_nr > (GROUP4_IRQ_BASE + 13))

... and >= here.

arch/mips/rb532/irq.c static int rb532_set_type(unsigned int irq_nr, unsigned type) · line 181

Quoted 3 lines
arch/mips/rb532/irq.c +0 -0
 		return (type == IRQ_TYPE_LEVEL_HIGH) ? 0 : -EINVAL;
 
 	switch (type) {

WBR, Sergei

#2 lore raw

Le Thursday 21 May 2009 20:52:13 Sergei Shtylyov, vous avez écrit :

Quoted 18 lines

Hello.

Quoted 15 lines · Florian Fainelli

This patch makes sure that we are not going to clear or change the interrupt status of a GPIO interrupt superior to 13 as this is the maximum number of GPIO interrupt source (p.232 of the RC32434 reference manual).

---

arch/mips/rb532/irq.c +0 -0
index 53eeb5e..afdcafc 100644
@@ -151,7 +151,8 @@ static void rb532_disable_irq(unsigned int irq_nr)
 		mask |= intr_bit;
 		WRITE_MASK(addr, mask);
 
Quoted 7 lines

arch/mips/rb532/irq.c static void rb532_disable_irq(unsigned int irq_nr)

Quoted 4 lines
arch/mips/rb532/irq.c +2 -1
-		if (group == GPIO_MAPPED_IRQ_GROUP)
+		/* There is a maximum of 13 GPIO interrupts */
+		if (group == GPIO_MAPPED_IRQ_GROUP && irq_nr <= (GROUP4_IRQ_BASE +
 13))

So, 13 or 14? The code seem to allow 14. Probably it should be <, not
<= here...

That's actually 14, numbering starting from 0, I should learn how to count. Ralf, do you want me to resubmit that one with the proper message / descriptions ?

Quoted 18 lines

arch/mips/rb532/irq.c static int rb532_set_type(unsigned int irq_nr, · line 178

Quoted 10 lines
arch/mips/rb532/irq.c +0 -0
 			rb532_gpio_set_istat(0, irq_nr - GPIO_MAPPED_IRQ_BASE);
 
arch/mips/rb532/irq.c +1 -1
 		/*
@@ -174,7 +175,7 @@ static int rb532_set_type(unsigned int irq_nr,
 unsigned type) int gpio = irq_nr - GPIO_MAPPED_IRQ_BASE;
 	int group = irq_to_group(irq_nr);
 
-	if (group != GPIO_MAPPED_IRQ_GROUP)
+	if (group != GPIO_MAPPED_IRQ_GROUP || irq_nr > (GROUP4_IRQ_BASE + 13))
    ... and >= here.

arch/mips/rb532/irq.c static int rb532_set_type(unsigned int irq_nr, unsigned type) · line 181

Quoted 3 lines
arch/mips/rb532/irq.c +0 -0
 		return (type == IRQ_TYPE_LEVEL_HIGH) ? 0 : -EINVAL;
 
 	switch (type) {

WBR, Sergei

Signature · 4 lines
Best regards, Florian Fainelli
Email : [email protected]
http://openwrt.org
-------------------------------
Applied
#3 lore raw
Quoted 20 lines · Florian Fainelli

That's actually 14, numbering starting from 0, I should learn how to count. Ralf, do you want me to resubmit that one with the proper message / descriptions ?

Quoted 16 lines

arch/mips/rb532/irq.c static int rb532_set_type(unsigned int irq_nr, · line 178

Quoted 10 lines
arch/mips/rb532/irq.c +1 -1
 			rb532_gpio_set_istat(0, irq_nr - GPIO_MAPPED_IRQ_BASE);
 
 		/*
@@ -174,7 +175,7 @@ static int rb532_set_type(unsigned int irq_nr,
 unsigned type) int gpio = irq_nr - GPIO_MAPPED_IRQ_BASE;
 	int group = irq_to_group(irq_nr);
 
-	if (group != GPIO_MAPPED_IRQ_GROUP)
+	if (group != GPIO_MAPPED_IRQ_GROUP || irq_nr > (GROUP4_IRQ_BASE + 13))
    ... and >= here.
Quoted 3 lines
arch/mips/rb532/irq.c +0 -0
 		return (type == IRQ_TYPE_LEVEL_HIGH) ? 0 : -EINVAL;
 
 	switch (type) {

Queued for 2.6.31 with the comment fix and the change from > to >=.

Thanks,

Ralf