linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl/at91: Fix lockup when IRQ on PIOC and PIOD occurs
@ 2014-04-23 21:40 Alexander Stein
  2014-04-23 22:34 ` Alexander Stein
  2014-04-24 17:55 ` [PATCH v2] " Alexander Stein
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Stein @ 2014-04-23 21:40 UTC (permalink / raw)
  To: linux-arm-kernel

With commit 8d56dfcc (pinctrl/at91: convert driver to use gpiolib irqchip)
gpiochip_set_chained_irqchip is called for PIOC, PIOD and PIOE. The
associated GPIO chip for the IRQ chip is overwritten each time, because
they share the same hard IRQ line.
Thus if an IRQ occurs on PIOC or PIOD, gpio_irq_handler will only check on
PIOE (the assigned GPIO chip) where no event occured. Thus the IRQ will
not be cleared, retriggering the ISR.
Fix that (like done before) by only set the PIOC GPIO chip to the IRQ chip.

Signed-off-by: Alexander Stein <alexanders83@web.de>
---
 drivers/pinctrl/pinctrl-at91.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 64a8f8f..dd7d3e4 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1468,6 +1468,7 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
 static int at91_gpio_of_irq_setup(struct device_node *node,
 				  struct at91_gpio_chip *at91_gpio)
 {
+	struct at91_gpio_chip   *prev = NULL;
 	struct irq_data		*d = irq_get_irq_data(at91_gpio->pioc_virq);
 	int ret;
 
@@ -1493,6 +1494,17 @@ static int at91_gpio_of_irq_setup(struct device_node *node,
 		panic("at91_gpio.%d: couldn't allocate irq domain (DT).\n",
 			at91_gpio->pioc_idx);
 
+	/* Setup chained handler */
+	if (at91_gpio->pioc_idx)
+		prev = gpio_chips[at91_gpio->pioc_idx - 1];
+
+	/* The top level handler handles one bank of GPIOs, except
+	 * on some SoC it can handle up to three...
+	 * We only set up the handler for the first of the list.
+	 */
+	if (prev && prev->next == at91_gpio)
+		return 0;
+
 	/* Then register the chain on the parent IRQ */
 	gpiochip_set_chained_irqchip(&at91_gpio->chip,
 				     &gpio_irqchip,
-- 
1.9.2

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

* [PATCH] pinctrl/at91: Fix lockup when IRQ on PIOC and PIOD occurs
  2014-04-23 21:40 [PATCH] pinctrl/at91: Fix lockup when IRQ on PIOC and PIOD occurs Alexander Stein
@ 2014-04-23 22:34 ` Alexander Stein
  2014-04-24 17:55 ` [PATCH v2] " Alexander Stein
  1 sibling, 0 replies; 7+ messages in thread
From: Alexander Stein @ 2014-04-23 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

Sorry,

drop that. This one creates another issue with that linear IRQ mapping. The correct bits from the correct register is read (which is what I checked), but unfortunatly irq_find_mapping now only returns mappings for PIOC :(
I will rework that.

Alexander

On Wednesday 23 April 2014, 23:40:03 wrote Alexander Stein:
> With commit 8d56dfcc (pinctrl/at91: convert driver to use gpiolib irqchip)
> gpiochip_set_chained_irqchip is called for PIOC, PIOD and PIOE. The
> associated GPIO chip for the IRQ chip is overwritten each time, because
> they share the same hard IRQ line.
> Thus if an IRQ occurs on PIOC or PIOD, gpio_irq_handler will only check on
> PIOE (the assigned GPIO chip) where no event occured. Thus the IRQ will
> not be cleared, retriggering the ISR.
> Fix that (like done before) by only set the PIOC GPIO chip to the IRQ chip.
> 
> Signed-off-by: Alexander Stein <alexanders83@web.de>
> ---
>  drivers/pinctrl/pinctrl-at91.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index 64a8f8f..dd7d3e4 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -1468,6 +1468,7 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
>  static int at91_gpio_of_irq_setup(struct device_node *node,
>  				  struct at91_gpio_chip *at91_gpio)
>  {
> +	struct at91_gpio_chip   *prev = NULL;
>  	struct irq_data		*d = irq_get_irq_data(at91_gpio->pioc_virq);
>  	int ret;
>  
> @@ -1493,6 +1494,17 @@ static int at91_gpio_of_irq_setup(struct device_node *node,
>  		panic("at91_gpio.%d: couldn't allocate irq domain (DT).\n",
>  			at91_gpio->pioc_idx);
>  
> +	/* Setup chained handler */
> +	if (at91_gpio->pioc_idx)
> +		prev = gpio_chips[at91_gpio->pioc_idx - 1];
> +
> +	/* The top level handler handles one bank of GPIOs, except
> +	 * on some SoC it can handle up to three...
> +	 * We only set up the handler for the first of the list.
> +	 */
> +	if (prev && prev->next == at91_gpio)
> +		return 0;
> +
>  	/* Then register the chain on the parent IRQ */
>  	gpiochip_set_chained_irqchip(&at91_gpio->chip,
>  				     &gpio_irqchip,
> 

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

* [PATCH v2] pinctrl/at91: Fix lockup when IRQ on PIOC and PIOD occurs
  2014-04-23 21:40 [PATCH] pinctrl/at91: Fix lockup when IRQ on PIOC and PIOD occurs Alexander Stein
  2014-04-23 22:34 ` Alexander Stein
@ 2014-04-24 17:55 ` Alexander Stein
  2014-04-25  9:18   ` Linus Walleij
  1 sibling, 1 reply; 7+ messages in thread
From: Alexander Stein @ 2014-04-24 17:55 UTC (permalink / raw)
  To: linux-arm-kernel

With commit 80cc3732 (pinctrl/at91: convert driver to use gpiolib irqchip)
gpiochip_set_chained_irqchip is called for PIOC, PIOD and PIOE. The
associated GPIO chip for the IRQ chip is overwritten each time, because
they share the same hard IRQ line.
Thus if an IRQ occurs on PIOC or PIOD, gpio_irq_handler will only check on
PIOE (the assigned GPIO chip) where no event occured. Thus the IRQ will
not be cleared, retriggering the ISR.
Fix that (like done before) by only set the PIOC GPIO chip to the IRQ chip
and walk the list in the irq handler.

Signed-off-by: Alexander Stein <alexanders83@web.de>
---
Changes in v2:
* Fix git SHA1 in commit message (used local one)
* Switch to the next gpio_chip when walking the list

Now really tested with evtest on inputs with IRQ on PIO A, B, D and E!
I don't have any useable GPIO on PIO C though.

 drivers/pinctrl/pinctrl-at91.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 64a8f8f..d90ae02 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1453,6 +1453,7 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
 				break;
 			at91_gpio = at91_gpio->next;
 			pio = at91_gpio->regbase;
+			gpio_chip = &at91_gpio->chip;
 			continue;
 		}
 
@@ -1468,6 +1469,7 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
 static int at91_gpio_of_irq_setup(struct device_node *node,
 				  struct at91_gpio_chip *at91_gpio)
 {
+	struct at91_gpio_chip   *prev = NULL;
 	struct irq_data		*d = irq_get_irq_data(at91_gpio->pioc_virq);
 	int ret;
 
@@ -1493,6 +1495,17 @@ static int at91_gpio_of_irq_setup(struct device_node *node,
 		panic("at91_gpio.%d: couldn't allocate irq domain (DT).\n",
 			at91_gpio->pioc_idx);
 
+	/* Setup chained handler */
+	if (at91_gpio->pioc_idx)
+		prev = gpio_chips[at91_gpio->pioc_idx - 1];
+
+	/* The top level handler handles one bank of GPIOs, except
+	 * on some SoC it can handle up to three...
+	 * We only set up the handler for the first of the list.
+	 */
+	if (prev && prev->next == at91_gpio)
+		return 0;
+
 	/* Then register the chain on the parent IRQ */
 	gpiochip_set_chained_irqchip(&at91_gpio->chip,
 				     &gpio_irqchip,
-- 
1.9.2

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

* [PATCH v2] pinctrl/at91: Fix lockup when IRQ on PIOC and PIOD occurs
  2014-04-24 17:55 ` [PATCH v2] " Alexander Stein
@ 2014-04-25  9:18   ` Linus Walleij
  2014-05-09 10:23     ` Nicolas Ferre
  0 siblings, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2014-04-25  9:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 24, 2014 at 7:55 PM, Alexander Stein <alexanders83@web.de> wrote:

> With commit 80cc3732 (pinctrl/at91: convert driver to use gpiolib irqchip)
> gpiochip_set_chained_irqchip is called for PIOC, PIOD and PIOE. The
> associated GPIO chip for the IRQ chip is overwritten each time, because
> they share the same hard IRQ line.
> Thus if an IRQ occurs on PIOC or PIOD, gpio_irq_handler will only check on
> PIOE (the assigned GPIO chip) where no event occured. Thus the IRQ will
> not be cleared, retriggering the ISR.
> Fix that (like done before) by only set the PIOC GPIO chip to the IRQ chip
> and walk the list in the irq handler.
>
> Signed-off-by: Alexander Stein <alexanders83@web.de>
> ---
> Changes in v2:
> * Fix git SHA1 in commit message (used local one)
> * Switch to the next gpio_chip when walking the list

This v2 patch applied for next.

Yours,
Linus Walleij

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

* [PATCH v2] pinctrl/at91: Fix lockup when IRQ on PIOC and PIOD occurs
  2014-04-25  9:18   ` Linus Walleij
@ 2014-05-09 10:23     ` Nicolas Ferre
  2014-05-21 17:15       ` Alexandre Belloni
  2014-05-27  9:13       ` Linus Walleij
  0 siblings, 2 replies; 7+ messages in thread
From: Nicolas Ferre @ 2014-05-09 10:23 UTC (permalink / raw)
  To: linux-arm-kernel

On 25/04/2014 11:18, Linus Walleij :
> On Thu, Apr 24, 2014 at 7:55 PM, Alexander Stein <alexanders83@web.de> wrote:
> 
>> With commit 80cc3732 (pinctrl/at91: convert driver to use gpiolib irqchip)
>> gpiochip_set_chained_irqchip is called for PIOC, PIOD and PIOE. The
>> associated GPIO chip for the IRQ chip is overwritten each time, because
>> they share the same hard IRQ line.
>> Thus if an IRQ occurs on PIOC or PIOD, gpio_irq_handler will only check on
>> PIOE (the assigned GPIO chip) where no event occured. Thus the IRQ will
>> not be cleared, retriggering the ISR.
>> Fix that (like done before) by only set the PIOC GPIO chip to the IRQ chip
>> and walk the list in the irq handler.
>>
>> Signed-off-by: Alexander Stein <alexanders83@web.de>
>> ---
>> Changes in v2:
>> * Fix git SHA1 in commit message (used local one)
>> * Switch to the next gpio_chip when walking the list
> 
> This v2 patch applied for next.

Linus,

I do not see this patch in your "for-next" branch nor in linux-next. Did
I miss something?

Bye,
-- 
Nicolas Ferre

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

* [PATCH v2] pinctrl/at91: Fix lockup when IRQ on PIOC and PIOD occurs
  2014-05-09 10:23     ` Nicolas Ferre
@ 2014-05-21 17:15       ` Alexandre Belloni
  2014-05-27  9:13       ` Linus Walleij
  1 sibling, 0 replies; 7+ messages in thread
From: Alexandre Belloni @ 2014-05-21 17:15 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Linus,

On 09/05/2014 at 12:23:03 +0200, Nicolas Ferre wrote :
> On 25/04/2014 11:18, Linus Walleij :
> > On Thu, Apr 24, 2014 at 7:55 PM, Alexander Stein <alexanders83@web.de> wrote:
> > 
> >> With commit 80cc3732 (pinctrl/at91: convert driver to use gpiolib irqchip)
> >> gpiochip_set_chained_irqchip is called for PIOC, PIOD and PIOE. The
> >> associated GPIO chip for the IRQ chip is overwritten each time, because
> >> they share the same hard IRQ line.
> >> Thus if an IRQ occurs on PIOC or PIOD, gpio_irq_handler will only check on
> >> PIOE (the assigned GPIO chip) where no event occured. Thus the IRQ will
> >> not be cleared, retriggering the ISR.
> >> Fix that (like done before) by only set the PIOC GPIO chip to the IRQ chip
> >> and walk the list in the irq handler.
> >>
> >> Signed-off-by: Alexander Stein <alexanders83@web.de>
> >> ---
> >> Changes in v2:
> >> * Fix git SHA1 in commit message (used local one)
> >> * Switch to the next gpio_chip when walking the list
> > 
> > This v2 patch applied for next.
> 
> Linus,
> 
> I do not see this patch in your "for-next" branch nor in linux-next. Did
> I miss something?
> 

I don't see it either, I would prefer that we don't miss it for 3.16,
can you check ?

Thanks,

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [PATCH v2] pinctrl/at91: Fix lockup when IRQ on PIOC and PIOD occurs
  2014-05-09 10:23     ` Nicolas Ferre
  2014-05-21 17:15       ` Alexandre Belloni
@ 2014-05-27  9:13       ` Linus Walleij
  1 sibling, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2014-05-27  9:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, May 9, 2014 at 12:23 PM, Nicolas Ferre <nicolas.ferre@atmel.com> wrote:
> On 25/04/2014 11:18, Linus Walleij :
>> On Thu, Apr 24, 2014 at 7:55 PM, Alexander Stein <alexanders83@web.de> wrote:
>>
>>> With commit 80cc3732 (pinctrl/at91: convert driver to use gpiolib irqchip)
>>> gpiochip_set_chained_irqchip is called for PIOC, PIOD and PIOE. The
>>> associated GPIO chip for the IRQ chip is overwritten each time, because
>>> they share the same hard IRQ line.
>>> Thus if an IRQ occurs on PIOC or PIOD, gpio_irq_handler will only check on
>>> PIOE (the assigned GPIO chip) where no event occured. Thus the IRQ will
>>> not be cleared, retriggering the ISR.
>>> Fix that (like done before) by only set the PIOC GPIO chip to the IRQ chip
>>> and walk the list in the irq handler.
>>>
>>> Signed-off-by: Alexander Stein <alexanders83@web.de>
>>> ---
>>> Changes in v2:
>>> * Fix git SHA1 in commit message (used local one)
>>> * Switch to the next gpio_chip when walking the list
>>
>> This v2 patch applied for next.
>
> Linus,
>
> I do not see this patch in your "for-next" branch nor in linux-next. Did
> I miss something?

I screwed up somehow :-/

Patch applied *now*.

Yours,
Linus Walleij

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

end of thread, other threads:[~2014-05-27  9:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-23 21:40 [PATCH] pinctrl/at91: Fix lockup when IRQ on PIOC and PIOD occurs Alexander Stein
2014-04-23 22:34 ` Alexander Stein
2014-04-24 17:55 ` [PATCH v2] " Alexander Stein
2014-04-25  9:18   ` Linus Walleij
2014-05-09 10:23     ` Nicolas Ferre
2014-05-21 17:15       ` Alexandre Belloni
2014-05-27  9:13       ` 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).