gpio/langwell: re-read the IRQ status register after each iteration
PATCH 1/1 gpio/langwell: re-read the IRQ status register after each iteration
Spotted by Grant Likely. The IRQ status register should be re-read after each iteration. Otherwise the loop misses the interrupt if it gets raised immediately after handled.
---
This patch applies on top of my previous patch ("gpio: langwell: convert to use irq_domain").
drivers/gpio/gpio-langwell.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/gpio/gpio-langwell.c +1 -3
@@ -250,11 +250,9 @@ static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)/* check GPIO controller to check which pin triggered the interrupt */ for (base =0 ; base < lnw->chip.ngpio; base +=32 ) { gedr =gpio_reg (&lnw->chip, base,GEDR ); - pending =readl (gedr); -while (pending) { +while ((pending =readl (gedr))) { gpio =__ffs (pending); mask =BIT (gpio); - pending &= ~mask;/* Clear before handling so we can't lose an edge */ writel (mask, gedr); generic_handle_irq(irq_find_mapping(lnw->domain,
Signature · 1 line
1.7.9.1
Quoted 8 lines · Mika Westerberg
Spotted by Grant Likely. The IRQ status register should be re-read after each iteration. Otherwise the loop misses the interrupt if it gets raised immediately after handled.
Signed-off-by Mika Westerberg <[email protected]>---
This patch applies on top of my previous patch ("gpio: langwell: convert to useirq_domain").
Oh yeah that thing I recognize!
If someone has time I think it would be a good idea to conjure a cocienelle sematic patch to catch this pattern, because I suspect it might exist in more IRQ handlers.
- pending = readl(gedr);
- while (pending) {
+ while ((pending = readl(gedr))) {
gpio = __ffs(pending);
mask = BIT(gpio);- pending &= ~mask;
Yours,
Linus Walleij
Quoted 19 lines · Linus Walleij
Quoted 8 lines · Mika Westerberg
Spotted by Grant Likely. The IRQ status register should be re-read after each iteration. Otherwise the loop misses the interrupt if it gets raised immediately after handled.
Signed-off-by Mika Westerberg <[email protected]>---
This patch applies on top of my previous patch ("gpio: langwell: convert to useirq_domain").Oh yeah that thing I recognize!
Acked-by Linus Walleij <[email protected]>If someone has time I think it would be a good idea to conjure a cocienelle sematic patch to catch this pattern, because I suspect it might exist in more IRQ handlers.
drivers/gpio/gpio-langwell.c static void lnw_irq_handler(unsigned irq, struct irq_desc *desc) · line 257
Quoted 6 lines
drivers/gpio/gpio-langwell.c +1
-3- pending =readl (gedr); -while (pending) { +while ((pending =readl (gedr))) { gpio =__ffs (pending); mask =BIT (gpio); - pending &= ~mask;
I tried the following:
@@
expression pending,gedr,e1;
statement S;
@@
*pending = readl(gedr);
... when != pending = e1
while (pending) S
That is, a readl call followed by a while loop with no reassignment of pending.
Perhaps the following are suspicious:
arch/arm/mach-msm/dma.c, function msm_datamover_irq_handler drivers/gpio/gpio-msm-v1.c, function msm_gpio_irq_handler
But I am not completely sure to understand what is wanted (or not wanted).
julia
Quoted 14 lines · Julia Lawall
I tried the following:
@@
expression pending,gedr,e1;
statement S;
@@*pending = readl(gedr);
... when != pending = e1
while (pending) SThat is, a readl call followed by a while loop with no reassignment of pending.
Quoted 6 lines
Perhaps the following are suspicious:
arch/arm/mach-msm/dma.c, functionmsm_datamover_irq_handlerdrivers/gpio/gpio-msm-v1.c, functionmsm_gpio_irq_handlerBut I am not completely sure to understand what is wanted (or not wanted).
No problem, I will look at them.
Thanks Julia!
Yours,
Linus Walleij
Grant Likely
AppliedQuoted 7 lines · Linus Walleij
Quoted 4 lines · Mika Westerberg
Spotted by Grant Likely. The IRQ status register should be re-read after each iteration. Otherwise the loop misses the interrupt if it gets raised immediately after handled.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Mika Westerberg <[email protected]>---
This patch applies on top of my previous patch ("gpio: langwell: convert to useirq_domain").Oh yeah that thing I recognize!
Acked-by Linus Walleij <[email protected]>
Applied, thanks.
g.