From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <gnurou@gmail.com>,
Benoit Parrot <bparrot@ti.com>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
linux-gpio@vger.kernel.org, linux-sh@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [RFC] gpio: Retry deferred GPIO hogging on pin range change
Date: Tue, 16 Jun 2015 17:27:36 +0000 [thread overview]
Message-ID: <20150616172736.GH11732@lukather> (raw)
In-Reply-To: <1434458208-30600-1-git-send-email-geert+renesas@glider.be>
[-- Attachment #1: Type: text/plain, Size: 2758 bytes --]
Hi Geert,
On Tue, Jun 16, 2015 at 02:36:48PM +0200, Geert Uytterhoeven wrote:
> If a GPIO driver uses gpiochip_add_pin_range() (which is usually the
> case for GPIO/PFC combos), the GPIO hogging mechanism configured from DT
> doesn't work:
>
> requesting hog GPIO lcd0 (chip r8a7740_pfc, offset 176) failed
>
> The actual error code is -517 == -EPROBE_DEFER.
>
> The problem is that PFC+GPIO registration is handled in multiple steps:
> 1. pinctrl_register(),
> 2. gpiochip_add(),
> 3. gpiochip_add_pin_range().
>
> Configuration of the hogs is handled in gpiochip_add():
>
> gpiochip_add
> of_gpiochip_add
> of_gpiochip_scan_hogs
> gpiod_hog
> gpiochip_request_own_desc
> __gpiod_request
> chip->request
> pinctrl_request_gpio
> pinctrl_get_device_gpio_range
>
> However, at this point the GPIO controller hasn't been added to
> pinctrldev_list yet, so the range can't be found, and the operation fails
> with -EPROBE_DEFER.
>
> - Exchanging the order of the calls to gpiochip_add() and
> gpiochip_add_pin_range() is not an option, as the latter depends on
> initialization done by the former.
> - Just moving the call of of_gpiochip_scan_hogs() from gpiochip_add()
> to gpiochip_add_pin_range() is also not an option, as the latter is
> optional, and thus not used by all drivers.
>
> Hence if of_gpiochip_scan_hogs() fails with -EPROBE_DEFER, call it
> again every time the pin range is changed, until it succeeded.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Questions:
> - Is there a better solution to handle this?
>
> - Should the pin ranges be configured by passing an array of data to
> gpiochip_add() instead of having calls to gpiochip_add_pin_range()?
> That would require changing all drivers.
>
> - What happens if you have multiple hogs in multiple ranges?
> The first hog(s) may be configured multiple times. Is that a problem?
>
> - In one of the threads that discussed the GPIO hogging mechanism, Maxime
> Ripard said: "Our pinctrl driver is also our GPIO driver, so they both
> share the same node."
> Maxime: Did you try GPIO hogging? Did it work?
> If yes, which driver are you using? What's different compared to sh-pfc?
> If no, did you get it to work?
I'm using pinctrl-sunxi, and no, I haven't tried it yet, so it
probably have the issue you reported :)
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-06-16 17:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-16 12:36 [PATCH] [RFC] gpio: Retry deferred GPIO hogging on pin range change Geert Uytterhoeven
2015-06-16 17:27 ` Maxime Ripard [this message]
2015-06-21 7:21 ` Alexandre Courbot
2015-06-21 8:52 ` Geert Uytterhoeven
2015-06-22 10:25 ` Geert Uytterhoeven
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=20150616172736.GH11732@lukather \
--to=maxime.ripard@free-electrons.com \
--cc=boris.brezillon@free-electrons.com \
--cc=bparrot@ti.com \
--cc=geert+renesas@glider.be \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).