All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] Issue with GPIO hog when using a pinctrl driver
@ 2017-02-15 21:24 Florian Vaussard
  0 siblings, 0 replies; only message in thread
From: Florian Vaussard @ 2017-02-15 21:24 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot; +Cc: linux-gpio, Maxime Ripard

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-15 21:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-15 21:24 [RFC] Issue with GPIO hog when using a pinctrl driver Florian Vaussard

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.