All of lore.kernel.org
 help / color / mirror / Atom feed
* Requesting as a GPIO a pin already used through pinctrl
@ 2016-09-16 13:58 Maxime Ripard
  2016-09-18 11:30 ` Linus Walleij
  0 siblings, 1 reply; 15+ messages in thread
From: Maxime Ripard @ 2016-09-16 13:58 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot
  Cc: linux-gpio, Alexandre Belloni, Nicolas Ferre, Boris Brezillon

[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]

Hi,

I just came across an interesting issue on our Allwinner SoCs.

We have, like most of the SoCs these days, a bunch of boards that go
through pinctrl to ensure their exclusive usage for a particular
device. If a second pinctrl user comes in and tries to request one of
those pins, it gets an error. Everything works fine.

However, things are getting weird when you have that requested pin
assigned to one device, and you try to export the GPIO on that pin
(through sysfs for example, but given the implementation, I think that
it would work alike by calling gpiod_request).

In this case, you get no error, and the GPIO is indeed exported,
allowing the user to change the direction and / or value of the pin,
taking away that pin from its device.

It seems from a look at the code that the request and
gpio_request_enable callbacks in the pinmux_ops, called in
pin_request, were meant to prevent such a thing.

But looking at all the drivers around, no one seems to take that case
into consideration, and this has been confirmed on an AT91 (which uses
an entirely different driver).

I have the feeling that the core should prevent that, making sure that
the gpiod_request returns EBUSY in such a case, but I'm not really
sure whether it's the case or not, and if it is, where that check is
happening.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2016-11-06 10:11 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-16 13:58 Requesting as a GPIO a pin already used through pinctrl Maxime Ripard
2016-09-18 11:30 ` Linus Walleij
2016-09-21 19:51   ` Maxime Ripard
2016-09-21 20:34     ` Michael Welling
2016-09-22 10:48       ` Maxime Ripard
2016-09-22 15:46         ` Michael Welling
2016-09-23 13:22     ` Linus Walleij
2016-09-23 15:24       ` Vladimir Zapolskiy
2016-09-23 21:34         ` Maxime Ripard
2016-09-30 16:26         ` Linus Walleij
2016-09-23 21:05       ` Maxime Ripard
2016-10-26 15:49         ` Maxime Ripard
2016-10-27 12:12           ` Linus Walleij
2016-11-02 21:31             ` Maxime Ripard
2016-11-06 10:11               ` 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.