Re: [PATCH v2 5/6] gpiolib: switch the line state notifier to atomic

Kent Gibson
2024-10-14T02:11:45Z

On Thu, Oct 10, 2024 at 11:10:26AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> With everything else ready, we can now switch to using the atomic
> notifier for line state events which will allow us to notify user-space
> about direction changes from atomic context.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> drivers/gpio/gpiolib-cdev.c | 22 ++++++++++++++++------
> drivers/gpio/gpiolib.c | 6 +++---
> drivers/gpio/gpiolib.h | 2 +-
> 3 files changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> index 2677134b52cd..7eae0b17a1d6 100644
> --- a/drivers/gpio/gpiolib-cdev.c
> +++ b/drivers/gpio/gpiolib-cdev.c
> @@ -2673,6 +2673,16 @@ static int lineinfo_changed_notify(struct notifier_block *nb,
> if (!test_bit(gpio_chip_hwgpio(desc), cdev->watched_lines))
> return NOTIFY_DONE;
>
> + /*
> + * This is called from atomic context (with a spinlock taken by the
> + * atomic notifier chain). Any sleeping calls must be done outside of
> + * this function in process context of the dedicated workqueue.
> + *
> + * Let's gather as much info as possible from the descriptor and
> + * postpone just the call to pinctrl_gpio_can_use_line() until the work
> + * is executed.
> + */
> +

Should be in patch 4? You aren't otherwise changing that function here.

Cheers,
Kent.