All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] gpio: altera: Use handle_level_irq when configured as a level_high
@ 2017-02-17  9:12 Phil Reid
  2017-02-17  9:23 ` Andy Shevchenko
  2017-02-23 14:52 ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Phil Reid @ 2017-02-17  9:12 UTC (permalink / raw)
  To: thloh, linus.walleij, gnurou, preid, linux-gpio, linux-kernel

When a threaded irq handler is chained attached to one of the gpio
pins when configure for level irq the altera_gpio_irq_leveL_high_handler
does not mask the interrupt while being handled by the chained irq.
This resulting in the threaded irq not getting enough cycles to complete
quickly enough before the irq was disabled as faulty.
It looks like handle_level_irq should be used in this situation
instead of handle_simple_irq.

Signed-off-by: Phil Reid <preid@electromag.com.au>
---
 drivers/gpio/gpio-altera.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
index 5bddbd5..d67dcca 100644
--- a/drivers/gpio/gpio-altera.c
+++ b/drivers/gpio/gpio-altera.c
@@ -310,7 +310,8 @@ static int altera_gpio_probe(struct platform_device *pdev)
 	altera_gc->interrupt_trigger = reg;
 
 	ret = gpiochip_irqchip_add(&altera_gc->mmchip.gc, &altera_irq_chip, 0,
-		handle_simple_irq, IRQ_TYPE_NONE);
+		altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH ?
+		handle_level_irq : handle_simple_irq, IRQ_TYPE_NONE);
 
 	if (ret) {
 		dev_err(&pdev->dev, "could not add irqchip\n");
-- 
1.8.3.1


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

* Re: [PATCH 1/1] gpio: altera: Use handle_level_irq when configured as a level_high
  2017-02-17  9:12 [PATCH 1/1] gpio: altera: Use handle_level_irq when configured as a level_high Phil Reid
@ 2017-02-17  9:23 ` Andy Shevchenko
  2017-02-17 11:32   ` Phil Reid
  2017-02-23 14:52 ` Linus Walleij
  1 sibling, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2017-02-17  9:23 UTC (permalink / raw)
  To: Phil Reid
  Cc: thloh, Linus Walleij, Alexandre Courbot, linux-gpio, linux-kernel

On Fri, Feb 17, 2017 at 11:12 AM, Phil Reid <preid@electromag.com.au> wrote:
> When a threaded irq handler is chained attached to one of the gpio
> pins when configure for level irq the altera_gpio_irq_leveL_high_handler
> does not mask the interrupt while being handled by the chained irq.
> This resulting in the threaded irq not getting enough cycles to complete
> quickly enough before the irq was disabled as faulty.
> It looks like handle_level_irq should be used in this situation
> instead of handle_simple_irq.

> @@ -310,7 +310,8 @@ static int altera_gpio_probe(struct platform_device *pdev)
>         altera_gc->interrupt_trigger = reg;
>
>         ret = gpiochip_irqchip_add(&altera_gc->mmchip.gc, &altera_irq_chip, 0,
> -               handle_simple_irq, IRQ_TYPE_NONE);
> +               altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH ?
> +               handle_level_irq : handle_simple_irq, IRQ_TYPE_NONE);

AFAIK, handle_bad_irq() should be used here.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 1/1] gpio: altera: Use handle_level_irq when configured as a level_high
  2017-02-17  9:23 ` Andy Shevchenko
@ 2017-02-17 11:32   ` Phil Reid
  2017-02-17 11:40     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Phil Reid @ 2017-02-17 11:32 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: thloh, Linus Walleij, Alexandre Courbot, linux-gpio, linux-kernel

On 17/02/2017 17:23, Andy Shevchenko wrote:
> On Fri, Feb 17, 2017 at 11:12 AM, Phil Reid <preid@electromag.com.au> wrote:
>> When a threaded irq handler is chained attached to one of the gpio
>> pins when configure for level irq the altera_gpio_irq_leveL_high_handler
>> does not mask the interrupt while being handled by the chained irq.
>> This resulting in the threaded irq not getting enough cycles to complete
>> quickly enough before the irq was disabled as faulty.
>> It looks like handle_level_irq should be used in this situation
>> instead of handle_simple_irq.
>
>> @@ -310,7 +310,8 @@ static int altera_gpio_probe(struct platform_device *pdev)
>>         altera_gc->interrupt_trigger = reg;
>>
>>         ret = gpiochip_irqchip_add(&altera_gc->mmchip.gc, &altera_irq_chip, 0,
>> -               handle_simple_irq, IRQ_TYPE_NONE);
>> +               altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH ?
>> +               handle_level_irq : handle_simple_irq, IRQ_TYPE_NONE);
>
> AFAIK, handle_bad_irq() should be used here.
>
G'day Andy

Grepping drivers/gpio find a combination of
handle_simple_irq
handle_level_irq
handle_edge_irq
handle_bad_irq
used in gpiochip_irqchip_add

The ones which use handle_bad_irq call irq_set_handler_locked in their
irq_type callback to either handle_level_irq / handle_edge_irq

So I think in this case it's correct. But I'm no expert.

-- 
Regards
Phil Reid



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

* Re: [PATCH 1/1] gpio: altera: Use handle_level_irq when configured as a level_high
  2017-02-17 11:32   ` Phil Reid
@ 2017-02-17 11:40     ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2017-02-17 11:40 UTC (permalink / raw)
  To: Phil Reid
  Cc: thloh, Linus Walleij, Alexandre Courbot, linux-gpio, linux-kernel

On Fri, Feb 17, 2017 at 1:32 PM, Phil Reid <preid@electromag.com.au> wrote:
> On 17/02/2017 17:23, Andy Shevchenko wrote:
>>
>> On Fri, Feb 17, 2017 at 11:12 AM, Phil Reid <preid@electromag.com.au>
>> wrote:
>>>
>>> When a threaded irq handler is chained attached to one of the gpio
>>> pins when configure for level irq the altera_gpio_irq_leveL_high_handler
>>> does not mask the interrupt while being handled by the chained irq.
>>> This resulting in the threaded irq not getting enough cycles to complete
>>> quickly enough before the irq was disabled as faulty.
>>> It looks like handle_level_irq should be used in this situation
>>> instead of handle_simple_irq.
>>
>>
>>> @@ -310,7 +310,8 @@ static int altera_gpio_probe(struct platform_device
>>> *pdev)
>>>         altera_gc->interrupt_trigger = reg;
>>>
>>>         ret = gpiochip_irqchip_add(&altera_gc->mmchip.gc,
>>> &altera_irq_chip, 0,
>>> -               handle_simple_irq, IRQ_TYPE_NONE);
>>> +               altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH ?
>>> +               handle_level_irq : handle_simple_irq, IRQ_TYPE_NONE);
>>
>>
>> AFAIK, handle_bad_irq() should be used here.
>>
> G'day Andy
>
> Grepping drivers/gpio find a combination of
> handle_simple_irq
> handle_level_irq
> handle_edge_irq
> handle_bad_irq
> used in gpiochip_irqchip_add

Try to add date of change and amount of use.
I bet handle_bad_irq() would be the winner.

> The ones which use handle_bad_irq call irq_set_handler_locked in their
> irq_type callback to either handle_level_irq / handle_edge_irq

Yep.

> So I think in this case it's correct. But I'm no expert.

I dunno.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 1/1] gpio: altera: Use handle_level_irq when configured as a level_high
  2017-02-17  9:12 [PATCH 1/1] gpio: altera: Use handle_level_irq when configured as a level_high Phil Reid
  2017-02-17  9:23 ` Andy Shevchenko
@ 2017-02-23 14:52 ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2017-02-23 14:52 UTC (permalink / raw)
  To: Phil Reid; +Cc: Tien Hock Loh, Alexandre Courbot, linux-gpio, linux-kernel

On Fri, Feb 17, 2017 at 10:12 AM, Phil Reid <preid@electromag.com.au> wrote:

>         ret = gpiochip_irqchip_add(&altera_gc->mmchip.gc, &altera_irq_chip, 0,
> -               handle_simple_irq, IRQ_TYPE_NONE);
> +               altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH ?
> +               handle_level_irq : handle_simple_irq, IRQ_TYPE_NONE);

I would say: set it to handle_bad_irq() for everything and then set it
to handle_level_irq() or handle_simple_irq() in the .set_type() function
using the rq_set_handler_locked() callback like everyone else,
nicely reflecting the synthesized trigger type.

I think that would work?

Yours,
Linus Walleij

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

end of thread, other threads:[~2017-02-23 14:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-17  9:12 [PATCH 1/1] gpio: altera: Use handle_level_irq when configured as a level_high Phil Reid
2017-02-17  9:23 ` Andy Shevchenko
2017-02-17 11:32   ` Phil Reid
2017-02-17 11:40     ` Andy Shevchenko
2017-02-23 14:52 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.