Skip to contentSkip to conversation

gpio: dwapb: fix missing first irq for edgeboth irq type

PATCH 陈晓光 3 participants 5 messages Jun 5, 2017 – Jun 20, 2017 1 message not in the archive GPIO

lore
Share & tools
lore

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

陈晓光

author
#1 lore raw

Hi, Guys
Any comments for this change?

Thanks
Xiaoguang

2017-06-02 7:27 GMT+08:00 <[email protected]>:

Quoted 33 lines

From: Xiaoguang Chen <[email protected]>

dwapb_irq_set_type overwrites polarity register value for IRQ_TYPE_EDGE_BOTH case. If the polarity of one gpio is 0 by default, then it will set falling edge irq trigger. and the gpio may requires rising edge irq for the first time, and it will be missed.

Do not overwrite polarity register for IRQ_TYPE_EDGE_BOTH case can solve this issue.

---
 drivers/gpio/gpio-dwapb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpio-dwapb.c +2 -2
index f051c45..80913e4 100644
@@ -288,7 +288,8 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type)
        irq_setup_alt_chip(d, type);
 
        dwapb_write(gpio, GPIO_INTTYPE_LEVEL, level);
-       dwapb_write(gpio, GPIO_INT_POLARITY, polarity);
+       if (type != IRQ_TYPE_EDGE_BOTH)
+               dwapb_write(gpio, GPIO_INT_POLARITY, polarity);
        spin_unlock_irqrestore(&gc->bgpio_lock, flags);
 
        return 0;
--

2.8.4 (Apple Git-73)

#2 lore raw
In reply to a message not in the archive

Adding driver authors to the To: Line and top posting to get some review.

Yours,
Linus Walleij

Quoted 33 lines · On Fri, Jun 2, 2017 at 1:27 AM, <[email protected]> wrote:

From: Xiaoguang Chen <[email protected]>

dwapb_irq_set_type overwrites polarity register value for IRQ_TYPE_EDGE_BOTH case. If the polarity of one gpio is 0 by default, then it will set falling edge irq trigger. and the gpio may requires rising edge irq for the first time, and it will be missed.

Do not overwrite polarity register for IRQ_TYPE_EDGE_BOTH case can solve this issue.

---
 drivers/gpio/gpio-dwapb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpio-dwapb.c +2 -2
index f051c45..80913e4 100644
@@ -288,7 +288,8 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type)
        irq_setup_alt_chip(d, type);
 
        dwapb_write(gpio, GPIO_INTTYPE_LEVEL, level);
-       dwapb_write(gpio, GPIO_INT_POLARITY, polarity);
+       if (type != IRQ_TYPE_EDGE_BOTH)
+               dwapb_write(gpio, GPIO_INT_POLARITY, polarity);
        spin_unlock_irqrestore(&gc->bgpio_lock, flags);
 
        return 0;
--

2.8.4 (Apple Git-73)

Tested-by
#3 lore raw
Quoted 4 lines · On Fri, 9 Jun 2017 11:26:19 +0200 Linus Walleij wrote:
Quoted 2 lines · On Fri, Jun 2, 2017 at 1:27 AM, <[email protected]> wrote:

From: Xiaoguang Chen <[email protected]>

Quoted 8 lines
Quoted 8 lines

dwapb_irq_set_type overwrites polarity register value for IRQ_TYPE_EDGE_BOTH case. If the polarity of one gpio is 0 by default, then it will set falling edge irq trigger. and the gpio may requires rising edge irq for the first time, and it will be missed.

Do not overwrite polarity register for IRQ_TYPE_EDGE_BOTH case can solve this issue.

I think this is a correct fix.

Quoted 2 lines
Quoted 2 lines
Quoted 21 lines
Quoted 21 lines
---
 drivers/gpio/gpio-dwapb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpio-dwapb.c +2 -2
index f051c45..80913e4 100644
@@ -288,7 +288,8 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type)
        irq_setup_alt_chip(d, type);
 
        dwapb_write(gpio, GPIO_INTTYPE_LEVEL, level);
-       dwapb_write(gpio, GPIO_INT_POLARITY, polarity);
+       if (type != IRQ_TYPE_EDGE_BOTH)
+               dwapb_write(gpio, GPIO_INT_POLARITY, polarity);
        spin_unlock_irqrestore(&gc->bgpio_lock, flags);
 
        return 0;
--

2.8.4 (Apple Git-73)

#4 lore raw
Quoted 15 lines · On Mon, 12 Jun 2017 13:05:30 +0800 Jisheng Zhang wrote:
Quoted 4 lines · On Fri, 9 Jun 2017 11:26:19 +0200 Linus Walleij wrote:
Quoted 2 lines · On Fri, Jun 2, 2017 at 1:27 AM, <[email protected]> wrote:

From: Xiaoguang Chen <[email protected]>

Quoted 8 lines
Quoted 8 lines

dwapb_irq_set_type overwrites polarity register value for IRQ_TYPE_EDGE_BOTH case. If the polarity of one gpio is 0 by default, then it will set falling edge irq trigger. and the gpio may requires rising edge irq for the first time, and it will be missed.

Do not overwrite polarity register for IRQ_TYPE_EDGE_BOTH case can solve this issue.

Quoted 6 lines

I think this is a correct fix.

Quoted 2 lines
Quoted 2 lines

Per my test, this patch fixes the following bug:

make use of CD-GPIO mechanism. Cold boot with sdcard inserted, hot-unplug the sdcard, sometimes, kernel won't get the remove interrupt.

Thanks

#5 lore raw
In reply to a message not in the archive
Quoted 8 lines · On Fri, Jun 2, 2017 at 1:27 AM, <[email protected]> wrote:

From: Xiaoguang Chen <[email protected]>

dwapb_irq_set_type overwrites polarity register value for IRQ_TYPE_EDGE_BOTH case. If the polarity of one gpio is 0 by default, then it will set falling edge irq trigger. and the gpio may requires rising edge irq for the first time, and it will be missed.

Quoted 4 lines

Do not overwrite polarity register for IRQ_TYPE_EDGE_BOTH case can solve this issue.

Patch applied with Jisheng's tested tag.

Yours,
Linus Walleij