All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] pinctrl: can_sleep and pinctrl_gpio_direction
@ 2021-12-06 13:16 Hans Verkuil
  2021-12-06 13:16 ` [RFC PATCH 1/3] pinctrl/core: check that can_sleep is true in pinctrl_gpio_direction() Hans Verkuil
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Hans Verkuil @ 2021-12-06 13:16 UTC (permalink / raw)
  To: linux-media; +Cc: Linus Walleij, linux-gpio, Maxime Ripard, Florian Fainelli

Hi all,

Based on this discussion:

https://lore.kernel.org/linux-gpio/CACRpkdb3q4-9O3dHS6QDWnZZ5JJjXWXS9KPvwXVaowLMRhcejA@mail.gmail.com/T/#t

I propose this RFC series.

The first patch adds a check if can_sleep is true when pinctrl_gpio_direction()
is called. It does this only once per pin controller (a new field is added to
keep track if this has been checked or not). If the gpio driver set can_sleep
to false, then it makes no sense that pinctrl_gpio_direction() is called since
it takes two different mutexes. This way you get at least a warning that something
is wrong, rather than only if CONFIG_DEBUG_ATOMIC_SLEEP is set.

However, if there are gpio drivers that call pinctrl_gpio_direction() always from
non-atomic contexts (so never via gpiod_get/set_value() etc.) then I'm not sure if
this check is possible here.

The second and third patches convert the bcm2835 and sunxi pinctrl drivers to
set the direction in those drivers directly, rather than by calling
pinctrl_gpio_direction_input/output. Both set can_sleep to false, so going
through a code path that uses mutexes is not a good idea.

This series has been tested with the cec-gpio driver on a Raspberry Pi 4b and
with an A10 Cubieboard. Both pincontroller drivers set can_sleep to false, but
call pinctrl_gpio_direction_input/output().

Those last two patches look sane to me.

Regards,

	Hans

Hans Verkuil (3):
  pinctrl/core: check that can_sleep is true in pinctrl_gpio_direction()
  pinctrl-bcm2835: don't call pinctrl_gpio_direction()
  pinctrl-sunxi: don't call pinctrl_gpio_direction()

 drivers/pinctrl/bcm/pinctrl-bcm2835.c | 12 +++++++++---
 drivers/pinctrl/core.c                | 11 +++++++++++
 drivers/pinctrl/core.h                |  4 ++++
 drivers/pinctrl/sunxi/pinctrl-sunxi.c |  8 ++++++--
 4 files changed, 30 insertions(+), 5 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-02-15  0:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 13:16 [RFC PATCH 0/3] pinctrl: can_sleep and pinctrl_gpio_direction Hans Verkuil
2021-12-06 13:16 ` [RFC PATCH 1/3] pinctrl/core: check that can_sleep is true in pinctrl_gpio_direction() Hans Verkuil
2021-12-06 13:16 ` [RFC PATCH 2/3] pinctrl-bcm2835: don't call pinctrl_gpio_direction() Hans Verkuil
2021-12-06 17:29   ` Florian Fainelli
2021-12-16  2:43   ` Linus Walleij
2021-12-06 13:16 ` [RFC PATCH 3/3] pinctrl-sunxi: " Hans Verkuil
2021-12-16  2:44   ` Linus Walleij
     [not found] ` <CAHp75VcPhSvQvjA5WBO72Lb5idc6vkkodai_V=YmLWtsz-qg1A@mail.gmail.com>
2021-12-08  0:30   ` [RFC PATCH 0/3] pinctrl: can_sleep and pinctrl_gpio_direction Linus Walleij
2021-12-08  9:26     ` Hans Verkuil
2021-12-08 14:24       ` Andy Shevchenko
2022-01-26 11:02 ` [PATCH for 5.17] pinctrl-sunxi: sunxi_pinctrl_gpio_direction_in/output: use correct offset Hans Verkuil
2022-01-26 15:22   ` Corentin Labbe
2022-01-26 16:38   ` Jernej Škrabec
2022-01-28 20:40   ` Guenter Roeck
2022-02-13 20:42   ` Guenter Roeck
2022-02-14  8:44     ` Hans Verkuil
2022-02-14 21:28       ` Guenter Roeck
2022-02-15  0:19       ` Guenter Roeck

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.