linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio/rockchip: handle irq before toggle trigger for edge type irq
@ 2022-08-19  1:41 Jianqun Xu
  2022-08-26  8:12 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Jianqun Xu @ 2022-08-19  1:41 UTC (permalink / raw)
  To: heiko
  Cc: linus.walleij, jeffy.chen, linux-gpio, linux-rockchip,
	linux-kernel, Jianqun Xu

The irq demux for rockchip gpio interrupts do real irq handle after loop
over the bits from int status register. Some oldder SoCs such as RK3308
has no both edge trigger type support, replaced by a soft both type
which switch trigger type once a level type triggered.

For example, a irq is set to a IRQ_TYPE_EDGE_BOTH trigger type, but the
SoC not support really both edge trigger type, use a
IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING instead.

        --------
    ____|      |______

        ^      ^
	|      |
	|      [0] the falling edge come before irq ack set by driver !
	|
        rockchip_irq_demux set to EDGE_FALLING type
	rockchip_irq_demux call generic_handle_irq
	                          -> handle_edge_irq
				    -> irq_gc_ack_set_bit

The [0] irq will lost by software on board test.

With this patch, the generic_handle_irq has been move ahead before
trigger toggle to fix the [0] lost issue.

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
---
 drivers/gpio/gpio-rockchip.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index f91e876fd969..952d628a6f7e 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -346,6 +346,7 @@ static void rockchip_irq_demux(struct irq_desc *desc)
 		}
 
 		dev_dbg(bank->dev, "handling irq %d\n", irq);
+		generic_handle_irq(virq);
 
 		/*
 		 * Triggering IRQ on both rising and falling edge
@@ -377,8 +378,6 @@ static void rockchip_irq_demux(struct irq_desc *desc)
 						     bank->gpio_regs->ext_port);
 			} while ((data & BIT(irq)) != (data_old & BIT(irq)));
 		}
-
-		generic_handle_irq(virq);
 	}
 
 	chained_irq_exit(chip, desc);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio/rockchip: handle irq before toggle trigger for edge type irq
  2022-08-19  1:41 [PATCH] gpio/rockchip: handle irq before toggle trigger for edge type irq Jianqun Xu
@ 2022-08-26  8:12 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2022-08-26  8:12 UTC (permalink / raw)
  To: Jianqun Xu; +Cc: heiko, jeffy.chen, linux-gpio, linux-rockchip, linux-kernel

On Fri, Aug 19, 2022 at 3:41 AM Jianqun Xu <jay.xu@rock-chips.com> wrote:

> The irq demux for rockchip gpio interrupts do real irq handle after loop
> over the bits from int status register. Some oldder SoCs such as RK3308
> has no both edge trigger type support, replaced by a soft both type
> which switch trigger type once a level type triggered.
>
> For example, a irq is set to a IRQ_TYPE_EDGE_BOTH trigger type, but the
> SoC not support really both edge trigger type, use a
> IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING instead.
>
>         --------
>     ____|      |______
>
>         ^      ^
>         |      |
>         |      [0] the falling edge come before irq ack set by driver !
>         |
>         rockchip_irq_demux set to EDGE_FALLING type
>         rockchip_irq_demux call generic_handle_irq
>                                   -> handle_edge_irq
>                                     -> irq_gc_ack_set_bit
>
> The [0] irq will lost by software on board test.
>
> With this patch, the generic_handle_irq has been move ahead before
> trigger toggle to fix the [0] lost issue.
>
> Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>

This looks fragile, but such is the nature of this dual-edge emulation.
If it works better in practice like this, it is better.
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-26  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-19  1:41 [PATCH] gpio/rockchip: handle irq before toggle trigger for edge type irq Jianqun Xu
2022-08-26  8:12 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).