linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Requesting false output GPIO as IRQ
@ 2019-02-26 10:01 Geert Uytterhoeven
  2019-02-27  9:29 ` Bartosz Golaszewski
  2019-03-01 14:45 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2019-02-26 10:01 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Yoshihiro Shimoda, open list:GPIO SUBSYSTEM, Linux-Renesas

Hi Linus, Bartosz,

If request_irq() is called on an otherwise unused GPIO that was
incorrectly configured for output by the firmware, this fails with:

    gpio gpiochip2: (e6052000.gpio): gpiochip_lock_as_irq: tried to
flag a GPIO set as output for IRQ
    gpio gpiochip2: (e6052000.gpio): unable to lock HW IRQ 22 for IRQ
    genirq: Failed to request resources for 0-0020 (irq 142) on
irqchip e6052000.gpio

This happens since commit ad817297418539b8 ("gpio: rcar: Implement
.get_direction() callback"), as the (default) input state is changed to
output by reading the hardware state.  Without that callback, the code
just continues.

While I strongly agree the firmware should be fixed not to configure
random GPIOs as outputs, shouldn't Linux just override this, if the GPIO
is not marked in use (has not been requested)?

What is your opinion on this?
Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: Requesting false output GPIO as IRQ
  2019-02-26 10:01 Requesting false output GPIO as IRQ Geert Uytterhoeven
@ 2019-02-27  9:29 ` Bartosz Golaszewski
  2019-03-01 14:45 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2019-02-27  9:29 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, Bartosz Golaszewski, Yoshihiro Shimoda,
	open list:GPIO SUBSYSTEM, Linux-Renesas

wt., 26 lut 2019 o 11:01 Geert Uytterhoeven <geert@linux-m68k.org> napisał(a):
>
> Hi Linus, Bartosz,
>
> If request_irq() is called on an otherwise unused GPIO that was
> incorrectly configured for output by the firmware, this fails with:
>
>     gpio gpiochip2: (e6052000.gpio): gpiochip_lock_as_irq: tried to
> flag a GPIO set as output for IRQ
>     gpio gpiochip2: (e6052000.gpio): unable to lock HW IRQ 22 for IRQ
>     genirq: Failed to request resources for 0-0020 (irq 142) on
> irqchip e6052000.gpio
>
> This happens since commit ad817297418539b8 ("gpio: rcar: Implement
> .get_direction() callback"), as the (default) input state is changed to
> output by reading the hardware state.  Without that callback, the code
> just continues.
>
> While I strongly agree the firmware should be fixed not to configure
> random GPIOs as outputs, shouldn't Linux just override this, if the GPIO
> is not marked in use (has not been requested)?
>
> What is your opinion on this?
> Thanks!
>

I think you're right about overriding this, because it's not only the
firmware that can change the configuration. Let's imagine user-space
that sets a GPIO, then releases it - it now stays configured as
output. We should probably force input in this case and maybe just
hint it with a pr_debug()?

Bart

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

* Re: Requesting false output GPIO as IRQ
  2019-02-26 10:01 Requesting false output GPIO as IRQ Geert Uytterhoeven
  2019-02-27  9:29 ` Bartosz Golaszewski
@ 2019-03-01 14:45 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2019-03-01 14:45 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Bartosz Golaszewski, Yoshihiro Shimoda, open list:GPIO SUBSYSTEM,
	Linux-Renesas, Grygorii Strashko

On Tue, Feb 26, 2019 at 11:01 AM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:

> While I strongly agree the firmware should be fixed not to configure
> random GPIOs as outputs, shouldn't Linux just override this, if the GPIO
> is not marked in use (has not been requested)?

commit 7e7c059cb50c7c72d5a393b2c34fc57de1b01b55
Author: Linus Walleij <linus.walleij@linaro.org>
Date:   Wed Jun 22 16:31:54 2016 +0200

    gpio: convince line to become input in irq helper

    The generic IRQ helper library just checks if the IRQ line is
    set as input before activating it for interrupts. As we
    recently started to check things better with .get_dir() it
    turns out that it's good to try to convince the line to become
    an input before attempting to lock it as IRQ.

    Reviewed-by: Björn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

led to:

commit 78456d6ff815894e593675fc524cade9844501d5
Author: Linus Walleij <linus.walleij@linaro.org>
Date:   Wed Jul 6 14:40:08 2016 +0200

    Revert "gpio: convince line to become input in irq helper"

    This reverts commit 7e7c059cb50c7c72d5a393b2c34fc57de1b01b55.

    I was wrong about trying to do this, as it breaks the
    orthogonality between gpiochips and irqchips.

    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Mainly because of Grygorii's remarks:
https://marc.info/?l=linux-gpio&m=146779605005475&w=2

Yours,
Linus Walleij

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

end of thread, other threads:[~2019-03-01 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-26 10:01 Requesting false output GPIO as IRQ Geert Uytterhoeven
2019-02-27  9:29 ` Bartosz Golaszewski
2019-03-01 14:45 ` 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).