From: Florian Vaussard <florian.vaussard@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <gnurou@gmail.com>
Cc: linux-gpio@vger.kernel.org,
Maxime Ripard <maxime.ripard@free-electrons.com>
Subject: [RFC] Issue with GPIO hog when using a pinctrl driver
Date: Wed, 15 Feb 2017 22:24:05 +0100 [thread overview]
Message-ID: <1bb31d3d-ce27-76b3-34b5-87c22705d613@gmail.com> (raw)
Hi!
I recently had an issue when trying to use GPIO hog with a GPIO controller
backed by a pinctrl driver (specifically
drivers/pinctrl/sunxi/pinctrl-sun50i-a64.c but I believe that the issue may be
broader). The gpiochip is initialized in two steps, using gpiochip_add_data()
and then gpiochip_add_pin_range(). The GPIO hog is initialized during the call
to gpiochip_add_data():
gpiochip_add_data
-> of_gpiochip_add
-> of_gpiochip_scan_gpios
-> gpiod_hog
But gpiod_hog will fail because the GPIO mapping is not yet initialized by
gpiochip_add_pin_range(). Thus the call to pinctrl_get_device_gpio_range() will
return EPROBE_DEFER, which in turn makes the pinctrl to fail probing and this
does not end very well for the kernel...
gpiod_hog
-> gpiochip_request_own_desc
-> __gpiod_request
-> chip->request (=> gpiochip_generic_request)
-> pinctrl_request_gpio
-> pinctrl_get_device_gpio_range
To test, I did a ugly call to of_gpiochip_scan_gpios() from within the pinctrl's
probe, right after gpiochip_add_pin_range(). And indeed, the GPIO hog is
correctly performed this time. Obviously this is not the right fix. Thus my
question is how this can be fixed? It seems like a chicken and egg problem.
Maybe the call to of_gpiochip_scan_gpios should be performed by
gpiochip_add_pin_range in case the GPIO range is not dynamically assigned by
gpiochip_add_data? This seems rather complicated.
Best,
Florian
reply other threads:[~2017-02-15 21:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1bb31d3d-ce27-76b3-34b5-87c22705d613@gmail.com \
--to=florian.vaussard@gmail.com \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=maxime.ripard@free-electrons.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).