linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>
Cc: linux-gpio@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>
Subject: Requesting as a GPIO a pin already used through pinctrl
Date: Fri, 16 Sep 2016 15:58:08 +0200	[thread overview]
Message-ID: <20160916135808.GA17518@lukather> (raw)

[-- 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 --]

             reply	other threads:[~2016-09-16 13:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-16 13:58 Maxime Ripard [this message]
2016-09-18 11:30 ` Requesting as a GPIO a pin already used through pinctrl 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160916135808.GA17518@lukather \
    --to=maxime.ripard@free-electrons.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).