Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: mark.rutland@arm.com, Rob Herring <robh+dt@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	Chen-Yu Tsai <wens@csie.org>
Subject: Re: Requesting as a GPIO a pin already used through pinctrl
Date: Wed, 26 Oct 2016 17:49:28 +0200	[thread overview]
Message-ID: <20161026154928.hu6rjalw7syrvbvg@lukather> (raw)
In-Reply-To: <20160923210549.GY8719@lukather>

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

On Sat, Sep 24, 2016 at 12:05:49AM +0300, Maxime Ripard wrote:
> On Fri, Sep 23, 2016 at 03:22:53PM +0200, Linus Walleij wrote:
> > > However, it does have an unexpected side-effect. On our DT, for the
> > > GPIOs, we also set up a pinctrl node (which seem to be along the lines
> > > of the doc recommandations, section "Drivers needing both pin control
> > > and GPIOs").
> > >
> > > However, when pinctrl_select_default is called by the core, which in
> > > turns ends up calling pinmux_enable_setting, which builds the owner
> > > name using the dev_name. However, when we call gpiod_request, it ends
> > > up in pinmux_request_gpio, which build the owner string using the
> > > pinctrl device name and the pin number.
> > >
> > > This results in a mismatch of owners, and the gpiod_request fails,
> > > while the device really is the same.
> > 
> > Yeah, needing both GPIO and pinctrl on the same pin kind of
> > implies that the subsystems are poking at the same hardware and
> > that is !=strict.
> 
> My understanding was that GPIO and pinctrl were pretty much
> orthogonal, a pinctrl property would set up the muxing, and mark the
> pin as in use, while the GPIO property would just say what we use the
> pin for. In a way, that was similar to what any other controller would
> behave. You would mark the pins as exclusive, mux them, and leave the
> controller deal with its pin.
> 
> Anyway, I'll remove those properties from our DTs, and add the .strict
> flag.

So I discussed that with Mark at ELCE.

In order not to break the DT, we looked at the code of pin_request
(which is the one using the strict flag), and went to the conclusion
that it needs to be amended to check the owner based on the device
structure pointer.

Which would need just to add an extra parameter to the pin_request
function, right?

It should be quite easy, because there's basically two users of that
function: pinmux_request_gpio, and pinmux_enable_setting, which in
turn are called by pinmux_request_gpio and pinctrl_select_state,
respectively. Which are exported, and used in a significant number of
callers.

... None of them having access to the struct device
directly. pinctrl_select_state is used in 13 different
drivers. pinctrl_request_gpio by 16 of them, but in a gpio hook
(gpio_request) that do not have the calling device structure.

Which means that in order to avoid removing one property from a DT to
fix an actual bug that can cause real stability issues to Linux, we
end up reworking the gpiolib API and fixing all the users.

Mark, Rob, do you really think this is a reasonable request?
Especially when the feature in question was added more than 2 years
after our driver, leaving us no chance to actually benefit from it
without breaking that ABI?

Thanks,
Maxime

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

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

  reply	other threads:[~2016-10-26 22:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=20161026154928.hu6rjalw7syrvbvg@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=mark.rutland@arm.com \
    --cc=nicolas.ferre@atmel.com \
    --cc=robh+dt@kernel.org \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=wens@csie.org \
    /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