linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: rcar: handle pm_runtime_get_sync failure case
@ 2020-06-05  2:49 Navid Emamdoost
  2020-06-10  8:52 ` Linus Walleij
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Navid Emamdoost @ 2020-06-05  2:49 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel
  Cc: emamd001, wu000273, kjlu, smccaman, Navid Emamdoost

Calling pm_runtime_get_sync increments the counter even in case of
failure, causing incorrect ref count. Call pm_runtime_put if
pm_runtime_get_sync fails.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/gpio/gpio-rcar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 7284473c9fe3..eac1582c70da 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -250,8 +250,10 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
 	int error;
 
 	error = pm_runtime_get_sync(p->dev);
-	if (error < 0)
+	if (error < 0) {
+		pm_runtime_put(p->dev);
 		return error;
+	}
 
 	error = pinctrl_gpio_request(chip->base + offset);
 	if (error)
-- 
2.17.1


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

* Re: [PATCH] gpio: rcar: handle pm_runtime_get_sync failure case
  2020-06-05  2:49 [PATCH] gpio: rcar: handle pm_runtime_get_sync failure case Navid Emamdoost
@ 2020-06-10  8:52 ` Linus Walleij
  2020-06-10 12:04   ` Geert Uytterhoeven
  2020-06-17  7:26 ` Geert Uytterhoeven
  2020-06-23  8:50 ` Bartosz Golaszewski
  2 siblings, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2020-06-10  8:52 UTC (permalink / raw)
  To: Navid Emamdoost, Geert Uytterhoeven
  Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM, linux-kernel,
	Navid Emamdoost, wu000273, Kangjie Lu, smccaman

On Fri, Jun 5, 2020 at 4:49 AM Navid Emamdoost
<navid.emamdoost@gmail.com> wrote:

> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count. Call pm_runtime_put if
> pm_runtime_get_sync fails.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/gpio/gpio-rcar.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 7284473c9fe3..eac1582c70da 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -250,8 +250,10 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
>         int error;
>
>         error = pm_runtime_get_sync(p->dev);
> -       if (error < 0)
> +       if (error < 0) {
> +               pm_runtime_put(p->dev);
>                 return error;
> +       }

I need Geert's review on this, he's usually on top of the Renesas stuff.

Yours,
Linus Walleij

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

* Re: [PATCH] gpio: rcar: handle pm_runtime_get_sync failure case
  2020-06-10  8:52 ` Linus Walleij
@ 2020-06-10 12:04   ` Geert Uytterhoeven
  0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2020-06-10 12:04 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Navid Emamdoost, Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
	linux-kernel, Navid Emamdoost, Qiushi Wu, Kangjie Lu,
	Stephen McCamant, Rafael J. Wysocki, Mark Brown, Linux PM list

Hi Linus,

On Wed, Jun 10, 2020 at 10:52 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> On Fri, Jun 5, 2020 at 4:49 AM Navid Emamdoost
> <navid.emamdoost@gmail.com> wrote:
> > Calling pm_runtime_get_sync increments the counter even in case of
> > failure, causing incorrect ref count. Call pm_runtime_put if
> > pm_runtime_get_sync fails.
> >
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> > ---
> >  drivers/gpio/gpio-rcar.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> > index 7284473c9fe3..eac1582c70da 100644
> > --- a/drivers/gpio/gpio-rcar.c
> > +++ b/drivers/gpio/gpio-rcar.c
> > @@ -250,8 +250,10 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
> >         int error;
> >
> >         error = pm_runtime_get_sync(p->dev);
> > -       if (error < 0)
> > +       if (error < 0) {
> > +               pm_runtime_put(p->dev);
> >                 return error;
> > +       }
>
> I need Geert's review on this, he's usually on top of the Renesas stuff.

TBH, I don't know anymore _which_ is the right call to make...

"Re: [PATCH] spi: spi-ti-qspi: call pm_runtime_put on pm_runtime_get failure"
https://lore.kernel.org/linux-spi/20200602095411.GB5684@sirena.org.uk/

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] gpio: rcar: handle pm_runtime_get_sync failure case
  2020-06-05  2:49 [PATCH] gpio: rcar: handle pm_runtime_get_sync failure case Navid Emamdoost
  2020-06-10  8:52 ` Linus Walleij
@ 2020-06-17  7:26 ` Geert Uytterhoeven
  2020-06-17  7:40   ` [PATCH v2] " Navid Emamdoost
  2020-06-17  7:41   ` [PATCH] " Navid Emamdoost
  2020-06-23  8:50 ` Bartosz Golaszewski
  2 siblings, 2 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2020-06-17  7:26 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: Linus Walleij, Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List, Navid Emamdoost, Qiushi Wu,
	Kangjie Lu, Stephen McCamant

Hi Navid,

On Fri, Jun 5, 2020 at 4:50 AM Navid Emamdoost
<navid.emamdoost@gmail.com> wrote:
> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count. Call pm_runtime_put if
> pm_runtime_get_sync fails.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Thanks for your patch!

> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -250,8 +250,10 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
>         int error;
>
>         error = pm_runtime_get_sync(p->dev);
> -       if (error < 0)
> +       if (error < 0) {
> +               pm_runtime_put(p->dev);

As per [1], I would like to see a call to pm_runtime_put_noidle() instead.

[1] http://lore.kernel.org/r/CAJZ5v0i87NGcy9+kxubScdPDyByr8ypQWcGgBFn+V-wDd69BHQ@mail.gmail.com

>                 return error;
> +       }
>
>         error = pinctrl_gpio_request(chip->base + offset);
>         if (error)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* [PATCH v2] gpio: rcar: handle pm_runtime_get_sync failure case
  2020-06-17  7:26 ` Geert Uytterhoeven
@ 2020-06-17  7:40   ` Navid Emamdoost
  2020-06-17  7:43     ` Geert Uytterhoeven
  2020-06-17  7:41   ` [PATCH] " Navid Emamdoost
  1 sibling, 1 reply; 10+ messages in thread
From: Navid Emamdoost @ 2020-06-17  7:40 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel
  Cc: emamd001, wu000273, kjlu, mccamant, geert, Navid Emamdoost

Calling pm_runtime_get_sync increments the counter even in case of
failure, causing incorrect ref count. Call pm_runtime_put if
pm_runtime_get_sync fails.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
Changes in v2:
	- use pm_runtime_put_noidle
---
 drivers/gpio/gpio-rcar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 7284473c9fe3..8fb9079a1d60 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -250,8 +250,10 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
 	int error;
 
 	error = pm_runtime_get_sync(p->dev);
-	if (error < 0)
+	if (error < 0) {
+		pm_runtime_put_noidle(p->dev);
 		return error;
+	}
 
 	error = pinctrl_gpio_request(chip->base + offset);
 	if (error)
-- 
2.17.1


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

* Re: [PATCH] gpio: rcar: handle pm_runtime_get_sync failure case
  2020-06-17  7:26 ` Geert Uytterhoeven
  2020-06-17  7:40   ` [PATCH v2] " Navid Emamdoost
@ 2020-06-17  7:41   ` Navid Emamdoost
  1 sibling, 0 replies; 10+ messages in thread
From: Navid Emamdoost @ 2020-06-17  7:41 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List, Navid Emamdoost, Qiushi Wu,
	Kangjie Lu, Stephen McCamant

Hi Geert,

On Wed, Jun 17, 2020 at 2:26 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Navid,
>
> On Fri, Jun 5, 2020 at 4:50 AM Navid Emamdoost
> <navid.emamdoost@gmail.com> wrote:
> > Calling pm_runtime_get_sync increments the counter even in case of
> > failure, causing incorrect ref count. Call pm_runtime_put if
> > pm_runtime_get_sync fails.
> >
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
>
> Thanks for your patch!
>
> > --- a/drivers/gpio/gpio-rcar.c
> > +++ b/drivers/gpio/gpio-rcar.c
> > @@ -250,8 +250,10 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
> >         int error;
> >
> >         error = pm_runtime_get_sync(p->dev);
> > -       if (error < 0)
> > +       if (error < 0) {
> > +               pm_runtime_put(p->dev);
>
> As per [1], I would like to see a call to pm_runtime_put_noidle() instead.

V2 was sent per your suggestion, thanks.

>
> [1] http://lore.kernel.org/r/CAJZ5v0i87NGcy9+kxubScdPDyByr8ypQWcGgBFn+V-wDd69BHQ@mail.gmail.com
>
> >                 return error;
> > +       }
> >
> >         error = pinctrl_gpio_request(chip->base + offset);
> >         if (error)
>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds



-- 
Navid.

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

* Re: [PATCH v2] gpio: rcar: handle pm_runtime_get_sync failure case
  2020-06-17  7:40   ` [PATCH v2] " Navid Emamdoost
@ 2020-06-17  7:43     ` Geert Uytterhoeven
  2020-06-22 16:54       ` Bartosz Golaszewski
  0 siblings, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2020-06-17  7:43 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: Linus Walleij, Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List, Navid Emamdoost, Qiushi Wu,
	Kangjie Lu, mccamant

On Wed, Jun 17, 2020 at 9:40 AM Navid Emamdoost
<navid.emamdoost@gmail.com> wrote:
> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count. Call pm_runtime_put if
> pm_runtime_get_sync fails.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2] gpio: rcar: handle pm_runtime_get_sync failure case
  2020-06-17  7:43     ` Geert Uytterhoeven
@ 2020-06-22 16:54       ` Bartosz Golaszewski
  2020-06-22 19:00         ` Geert Uytterhoeven
  0 siblings, 1 reply; 10+ messages in thread
From: Bartosz Golaszewski @ 2020-06-22 16:54 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Navid Emamdoost, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List, Navid Emamdoost, Qiushi Wu,
	Kangjie Lu, mccamant

śr., 17 cze 2020 o 09:43 Geert Uytterhoeven <geert@linux-m68k.org> napisał(a):
>
> On Wed, Jun 17, 2020 at 9:40 AM Navid Emamdoost
> <navid.emamdoost@gmail.com> wrote:
> > Calling pm_runtime_get_sync increments the counter even in case of
> > failure, causing incorrect ref count. Call pm_runtime_put if
> > pm_runtime_get_sync fails.
> >
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>

Is this stable material?

Bart

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

* Re: [PATCH v2] gpio: rcar: handle pm_runtime_get_sync failure case
  2020-06-22 16:54       ` Bartosz Golaszewski
@ 2020-06-22 19:00         ` Geert Uytterhoeven
  0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2020-06-22 19:00 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Navid Emamdoost, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List, Navid Emamdoost, Qiushi Wu,
	Kangjie Lu, mccamant

Hi Bartosz,

On Mon, Jun 22, 2020 at 6:54 PM Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:
> śr., 17 cze 2020 o 09:43 Geert Uytterhoeven <geert@linux-m68k.org> napisał(a):
> > On Wed, Jun 17, 2020 at 9:40 AM Navid Emamdoost
> > <navid.emamdoost@gmail.com> wrote:
> > > Calling pm_runtime_get_sync increments the counter even in case of
> > > failure, causing incorrect ref count. Call pm_runtime_put if
> > > pm_runtime_get_sync fails.
> > >
> > > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> >
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Is this stable material?

No, it cannot happen anyway.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] gpio: rcar: handle pm_runtime_get_sync failure case
  2020-06-05  2:49 [PATCH] gpio: rcar: handle pm_runtime_get_sync failure case Navid Emamdoost
  2020-06-10  8:52 ` Linus Walleij
  2020-06-17  7:26 ` Geert Uytterhoeven
@ 2020-06-23  8:50 ` Bartosz Golaszewski
  2 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2020-06-23  8:50 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: Linus Walleij, linux-gpio, LKML, Navid Emamdoost, Qiushi Wu,
	Kangjie Lu, smccaman

pt., 5 cze 2020 o 04:49 Navid Emamdoost <navid.emamdoost@gmail.com> napisał(a):
>
> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count. Call pm_runtime_put if
> pm_runtime_get_sync fails.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/gpio/gpio-rcar.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 7284473c9fe3..eac1582c70da 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -250,8 +250,10 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
>         int error;
>
>         error = pm_runtime_get_sync(p->dev);
> -       if (error < 0)
> +       if (error < 0) {
> +               pm_runtime_put(p->dev);
>                 return error;
> +       }
>
>         error = pinctrl_gpio_request(chip->base + offset);
>         if (error)
> --
> 2.17.1
>

Hi Navid!

This doesn't apply to current master. I think the previous version got
applied. Could you please rebase?

Bart

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

end of thread, other threads:[~2020-06-23  8:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05  2:49 [PATCH] gpio: rcar: handle pm_runtime_get_sync failure case Navid Emamdoost
2020-06-10  8:52 ` Linus Walleij
2020-06-10 12:04   ` Geert Uytterhoeven
2020-06-17  7:26 ` Geert Uytterhoeven
2020-06-17  7:40   ` [PATCH v2] " Navid Emamdoost
2020-06-17  7:43     ` Geert Uytterhoeven
2020-06-22 16:54       ` Bartosz Golaszewski
2020-06-22 19:00         ` Geert Uytterhoeven
2020-06-17  7:41   ` [PATCH] " Navid Emamdoost
2020-06-23  8:50 ` Bartosz Golaszewski

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).