Skip to contentSkip to conversation

pinctrl: mediatek: fix dual-edge code defect

PATCH In review hongkun.cao at mediatek.com 3 participants 4 messages May 21, 2016 – May 31, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: mediatek: fix dual-edge code defect

From: "hongkun.cao" <[email protected]>

When a dual-edge irq is triggered, an incorrect irq will be reported on condition that the external signal is not stable and this incorrect irq has been registered.
Correct the register offset.

---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +3 -2
index 2bbe6f7..92ae49f 100644
@@ -1255,9 +1255,10 @@ static void mtk_eint_irq_handler(struct irq_desc *desc)
 	const struct mtk_desc_pin *pin;
 
 	chained_irq_enter(chip, desc);
-	for (eint_num = 0; eint_num < pctl->devdata->ap_num; eint_num += 32) {
+	for (eint_num = 0;
+	     eint_num < pctl->devdata->ap_num;
+	     eint_num += 32, reg += 4) {
 		status = readl(reg);
-		reg += 4;
 		while (status) {
 			offset = __ffs(status);
 			index = eint_num + offset;
Signature · 1 line
1.7.9.5
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · hongkun.cao at mediatek.com

From: "hongkun.cao" <[email protected]>

When a dual-edge irq is triggered, an incorrect irq will be reported on condition that the external signal is not stable and this incorrect irq has been registered.
Correct the register offset.

I'm not sure what you want to say. From what I can see the without this fix, the the wrong IRQ will be cleared and raised. Is this what you are addressing?

If so:

Quoted 23 lines
---
  drivers/pinctrl/mediatek/pinctrl-mtk-common.c |    5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +3 -2
index 2bbe6f7..92ae49f 100644
@@ -1255,9 +1255,10 @@ static void mtk_eint_irq_handler(struct irq_desc *desc)
  	const struct mtk_desc_pin *pin;
 
  	chained_irq_enter(chip, desc);
-	for (eint_num = 0; eint_num < pctl->devdata->ap_num; eint_num += 32) {
+	for (eint_num = 0;
+	     eint_num < pctl->devdata->ap_num;
+	     eint_num += 32, reg += 4) {
  		status = readl(reg);
-		reg += 4;
  		while (status) {
  			offset = __ffs(status);
  			index = eint_num + offset;
#2 lore raw

PATCH 1/1 pinctrl: mediatek: fix dual-edge code defect

Quoted 10 lines · Matthias Brugger
Quoted 7 lines · hongkun.cao at mediatek.com

From: "hongkun.cao" <[email protected]>

When a dual-edge irq is triggered, an incorrect irq will be reported on condition that the external signal is not stable and this incorrect irq has been registered.
Correct the register offset.

Quoted 5 lines

I'm not sure what you want to say. From what I can see the without this fix, the the wrong IRQ will be cleared and raised. Is this what you are addressing?

If so:

Hi, Matthias,
Thanks for your comments.
Yes, you are right.
Suppose there are two irqs registered in our system with special relationship, One hardware irq number is 17 with both edge trigger, and the other hardware irq number is 49(17+32),then hardware irq 49 may be reported unexpectedly if hardware irq 17 occurred.

Quoted 25 lines
Quoted 23 lines
---
  drivers/pinctrl/mediatek/pinctrl-mtk-common.c |    5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +3 -2
index 2bbe6f7..92ae49f 100644
@@ -1255,9 +1255,10 @@ static void mtk_eint_irq_handler(struct irq_desc *desc)
  	const struct mtk_desc_pin *pin;
 
  	chained_irq_enter(chip, desc);
-	for (eint_num = 0; eint_num < pctl->devdata->ap_num; eint_num += 32) {
+	for (eint_num = 0;
+	     eint_num < pctl->devdata->ap_num;
+	     eint_num += 32, reg += 4) {
  		status = readl(reg);
-		reg += 4;
  		while (status) {
  			offset = __ffs(status);
  			index = eint_num + offset;
#3 lore raw
In reply to hongkun.cao at mediatek.com
Quoted 8 lines · On Sat, May 21, 2016 at 9:23 AM, <[email protected]> wrote:

From: "hongkun.cao" <[email protected]>

When a dual-edge irq is triggered, an incorrect irq will be reported on condition that the external signal is not stable and this incorrect irq has been registered.
Correct the register offset.

Patch applied for fixes with Matthias' review tag.

Yours,
Linus Walleij