Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH] gpio: sim: mark the GPIO chip as a one that can sleep
@ 2023-08-01 19:09 Bartosz Golaszewski
  2023-08-01 19:11 ` Andy Shevchenko
  2023-08-02 22:56 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2023-08-01 19:09 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, Kent Gibson
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Simulated chips use a mutex for synchronization in driver callbacks so
they must not be called from interrupt context. Set the can_sleep field
of the GPIO chip to true to force users to only use threaded irqs.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-sim.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index cfbdade841e8..5f8723ad0048 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -429,6 +429,7 @@ static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev)
 	gc->set_config = gpio_sim_set_config;
 	gc->to_irq = gpio_sim_to_irq;
 	gc->free = gpio_sim_free;
+	gc->can_sleep = true;
 
 	ret = devm_gpiochip_add_data(dev, gc, chip);
 	if (ret)
-- 
2.39.2


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

* Re: [PATCH] gpio: sim: mark the GPIO chip as a one that can sleep
  2023-08-01 19:09 [PATCH] gpio: sim: mark the GPIO chip as a one that can sleep Bartosz Golaszewski
@ 2023-08-01 19:11 ` Andy Shevchenko
  2023-08-02  6:47   ` Bartosz Golaszewski
  2023-08-02 22:56 ` Linus Walleij
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2023-08-01 19:11 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Kent Gibson, linux-gpio, linux-kernel,
	Bartosz Golaszewski

On Tue, Aug 01, 2023 at 09:09:51PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Simulated chips use a mutex for synchronization in driver callbacks so
> they must not be called from interrupt context. Set the can_sleep field
> of the GPIO chip to true to force users to only use threaded irqs.

Ah, good catch! Doesn't it deserve a Fixes tag?

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  drivers/gpio/gpio-sim.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
> index cfbdade841e8..5f8723ad0048 100644
> --- a/drivers/gpio/gpio-sim.c
> +++ b/drivers/gpio/gpio-sim.c
> @@ -429,6 +429,7 @@ static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev)
>  	gc->set_config = gpio_sim_set_config;
>  	gc->to_irq = gpio_sim_to_irq;
>  	gc->free = gpio_sim_free;
> +	gc->can_sleep = true;
>  
>  	ret = devm_gpiochip_add_data(dev, gc, chip);
>  	if (ret)
> -- 
> 2.39.2
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] gpio: sim: mark the GPIO chip as a one that can sleep
  2023-08-01 19:11 ` Andy Shevchenko
@ 2023-08-02  6:47   ` Bartosz Golaszewski
  0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2023-08-02  6:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Kent Gibson, linux-gpio, linux-kernel,
	Bartosz Golaszewski

On Tue, Aug 1, 2023 at 9:11 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Tue, Aug 01, 2023 at 09:09:51PM +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Simulated chips use a mutex for synchronization in driver callbacks so
> > they must not be called from interrupt context. Set the can_sleep field
> > of the GPIO chip to true to force users to only use threaded irqs.
>
> Ah, good catch! Doesn't it deserve a Fixes tag?

I will add it when applying.

Bart

>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > ---
> >  drivers/gpio/gpio-sim.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
> > index cfbdade841e8..5f8723ad0048 100644
> > --- a/drivers/gpio/gpio-sim.c
> > +++ b/drivers/gpio/gpio-sim.c
> > @@ -429,6 +429,7 @@ static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev)
> >       gc->set_config = gpio_sim_set_config;
> >       gc->to_irq = gpio_sim_to_irq;
> >       gc->free = gpio_sim_free;
> > +     gc->can_sleep = true;
> >
> >       ret = devm_gpiochip_add_data(dev, gc, chip);
> >       if (ret)
> > --
> > 2.39.2
> >
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

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

* Re: [PATCH] gpio: sim: mark the GPIO chip as a one that can sleep
  2023-08-01 19:09 [PATCH] gpio: sim: mark the GPIO chip as a one that can sleep Bartosz Golaszewski
  2023-08-01 19:11 ` Andy Shevchenko
@ 2023-08-02 22:56 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2023-08-02 22:56 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andy Shevchenko, Kent Gibson, linux-gpio, linux-kernel,
	Bartosz Golaszewski

On Tue, Aug 1, 2023 at 9:10 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Simulated chips use a mutex for synchronization in driver callbacks so
> they must not be called from interrupt context. Set the can_sleep field
> of the GPIO chip to true to force users to only use threaded irqs.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Obviously correct.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

end of thread, other threads:[~2023-08-02 22:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-01 19:09 [PATCH] gpio: sim: mark the GPIO chip as a one that can sleep Bartosz Golaszewski
2023-08-01 19:11 ` Andy Shevchenko
2023-08-02  6:47   ` Bartosz Golaszewski
2023-08-02 22:56 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox