public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio/langwell: re-read the IRQ status register after each iteration
@ 2012-05-10 10:01 Mika Westerberg
  2012-05-10 12:16 ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2012-05-10 10:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: grant.likely, linus.walleij, 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 <mika.westerberg@linux.intel.com>
---
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(-)

diff --git a/drivers/gpio/gpio-langwell.c b/drivers/gpio/gpio-langwell.c
index b067357..a1c8754 100644
--- a/drivers/gpio/gpio-langwell.c
+++ b/drivers/gpio/gpio-langwell.c
@@ -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,
-- 
1.7.9.1


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

* Re: [PATCH] gpio/langwell: re-read the IRQ status register after each iteration
  2012-05-10 10:01 [PATCH] gpio/langwell: re-read the IRQ status register after each iteration Mika Westerberg
@ 2012-05-10 12:16 ` Linus Walleij
  2012-05-10 20:34   ` Julia Lawall
  2012-05-10 22:35   ` Grant Likely
  0 siblings, 2 replies; 5+ messages in thread
From: Linus Walleij @ 2012-05-10 12:16 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: linux-kernel, grant.likely, linus.walleij, Julia Lawall

On Thu, May 10, 2012 at 12:01 PM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:

> 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 <mika.westerberg@linux.intel.com>
> ---
> This patch applies on top of my previous patch ("gpio: langwell: convert to
> use irq_domain").

Oh yeah that thing I recognize!
Acked-by: Linus Walleij <linus.walleij@linaro.org>

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

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

* Re: [PATCH] gpio/langwell: re-read the IRQ status register after each iteration
  2012-05-10 12:16 ` Linus Walleij
@ 2012-05-10 20:34   ` Julia Lawall
  2012-05-11 11:57     ` Linus Walleij
  2012-05-10 22:35   ` Grant Likely
  1 sibling, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2012-05-10 20:34 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Mika Westerberg, linux-kernel, grant.likely, linus.walleij

On Thu, 10 May 2012, Linus Walleij wrote:

> On Thu, May 10, 2012 at 12:01 PM, Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
>
>> 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 <mika.westerberg@linux.intel.com>
>> ---
>> This patch applies on top of my previous patch ("gpio: langwell: convert to
>> use irq_domain").
>
> Oh yeah that thing I recognize!
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>
> 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;

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

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

* Re: [PATCH] gpio/langwell: re-read the IRQ status register after each iteration
  2012-05-10 12:16 ` Linus Walleij
  2012-05-10 20:34   ` Julia Lawall
@ 2012-05-10 22:35   ` Grant Likely
  1 sibling, 0 replies; 5+ messages in thread
From: Grant Likely @ 2012-05-10 22:35 UTC (permalink / raw)
  To: Linus Walleij, Mika Westerberg; +Cc: linux-kernel, linus.walleij, Julia Lawall

On Thu, 10 May 2012 14:16:56 +0200, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Thu, May 10, 2012 at 12:01 PM, Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
> 
> > 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 <mika.westerberg@linux.intel.com>
> > ---
> > This patch applies on top of my previous patch ("gpio: langwell: convert to
> > use irq_domain").
> 
> Oh yeah that thing I recognize!
> Acked-by: Linus Walleij <linus.walleij@linaro.org>

Applied, thanks.

g.


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

* Re: [PATCH] gpio/langwell: re-read the IRQ status register after each iteration
  2012-05-10 20:34   ` Julia Lawall
@ 2012-05-11 11:57     ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2012-05-11 11:57 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Mika Westerberg, linux-kernel, grant.likely, linus.walleij

On Thu, May 10, 2012 at 10:34 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:

> 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).

No problem, I will look at them.
Thanks Julia!

Yours,
Linus Walleij

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

end of thread, other threads:[~2012-05-11 11:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-10 10:01 [PATCH] gpio/langwell: re-read the IRQ status register after each iteration Mika Westerberg
2012-05-10 12:16 ` Linus Walleij
2012-05-10 20:34   ` Julia Lawall
2012-05-11 11:57     ` Linus Walleij
2012-05-10 22:35   ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox