Re: [PATCH] gpio/msm-v1: re-read IRQ flags on each iteration

From: Grant Likely
Date: Fri May 11 2012 - 13:41:14 EST


On Fri, 11 May 2012 14:07:12 +0200, Linus Walleij <linus.walleij@xxxxxxxxxxxxxx> wrote:
> From: Linus Walleij <linus.walleij@xxxxxxxxxx>
>
> We have recently found a number or erroneous IRQ handlers in
> the kernel where the flag iterator loop miss IRQs that get
> raised when the loop is executing. This was spotted in the
> MSM v1 GPIO driver by Julia Lawall using this cocinelle
> snippet:
>
> @@
> expression pending,gedr,e1;
> statement S;
> @@
>
> *pending = readl(gedr);
> ... when != pending = e1
> while (pending) S
>
> Reported-by: Julia Lawall <julia.lawall@xxxxxxx>
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

Thanks Linus,

I'll need an ack from an msm developer before applying this.

g.

> ---
> drivers/gpio/gpio-msm-v1.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-msm-v1.c b/drivers/gpio/gpio-msm-v1.c
> index 52a4d42..68ca760 100644
> --- a/drivers/gpio/gpio-msm-v1.c
> +++ b/drivers/gpio/gpio-msm-v1.c
> @@ -567,9 +567,9 @@ static void msm_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
>
> for (i = 0; i < msm_gpio_count; i++) {
> struct msm_gpio_chip *msm_chip = &msm_gpio_chips[i];
> - val = readl(msm_chip->regs.int_status);
> - val &= msm_chip->int_enable[0];
> - while (val) {
> +
> + while (val = (readl(msm_chip->regs.int_status) &
> + msm_chip->int_enable[0])) {
> mask = val & -val;
> j = fls(mask) - 1;
> /* printk("%s %08x %08x bit %d gpio %d irq %d\n",
> --
> 1.7.9.2
>

--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/