Skip to contentSkip to conversation

gpio: rcar: handle pm_runtime_get_sync failure case

PATCH In review Navid Emamdoost 4 participants 10 messages Jun 5, 2020 – Jun 23, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: rcar: handle pm_runtime_get_sync failure case

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.

---
 drivers/gpio/gpio-rcar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-rcar.c +3 -1
index 7284473c9fe3..eac1582c70da 100644
@@ -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)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 14 lines · 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.

---
 drivers/gpio/gpio-rcar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-rcar.c +0 -0
index 7284473c9fe3..eac1582c70da 100644

drivers/gpio/gpio-rcar.c static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) · line 256

Quoted 8 lines
drivers/gpio/gpio-rcar.c +3 -1
@@ -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

#2 lore raw

Hi Linus,

Quoted 18 lines · Linus Walleij
Quoted 16 lines · 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.

---
 drivers/gpio/gpio-rcar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-rcar.c +0 -0
index 7284473c9fe3..eac1582c70da 100644
@@ -250,8 +250,10 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
        int error;
 
Quoted 8 lines

drivers/gpio/gpio-rcar.c static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) · line 256

Quoted 6 lines
drivers/gpio/gpio-rcar.c +3 -1
        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/[email protected]/

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

#3 lore raw
In reply to Navid Emamdoost

Hi Navid,

Quoted 5 lines · 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.

Thanks for your patch!

drivers/gpio/gpio-rcar.c static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) · line 254

Quoted 9 lines
drivers/gpio/gpio-rcar.c +2 -1
@@ -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

drivers/gpio/gpio-rcar.c static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) · line 259

Quoted 5 lines
drivers/gpio/gpio-rcar.c +1 -0
                return error;
+       }
 
        error = pinctrl_gpio_request(chip->base + offset);
        if (error)

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#4 lore raw

PATCH v2 1/1 gpio: rcar: handle pm_runtime_get_sync failure case

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.

---
Changes in v2:
- use pm_runtime_put_noidle

---
 drivers/gpio/gpio-rcar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-rcar.c +3 -1
index 7284473c9fe3..8fb9079a1d60 100644
@@ -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)
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#5 lore raw
Quoted 5 lines · 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.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#7 lore raw

Hi Bartosz,

Quoted 7 lines · Bartosz Golaszewski

śr., 17 cze 2020 o 09:43 Geert Uytterhoeven <[email protected]> napisał(a):

Quoted 6 lines
Quoted 4 lines · 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.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Is this stable material?

No, it cannot happen anyway.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#8 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Quoted 18 lines · Geert Uytterhoeven

Hi Navid,

Quoted 5 lines · 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.

Thanks for your patch!

Quoted 5 lines
drivers/gpio/gpio-rcar.c +0 -0
@@ -250,8 +250,10 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
        int error;
 
Quoted 6 lines

drivers/gpio/gpio-rcar.c static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) · line 254

Quoted 4 lines
drivers/gpio/gpio-rcar.c +2 -1
        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.

Quoted 19 lines

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

drivers/gpio/gpio-rcar.c static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) · line 259

Quoted 5 lines
drivers/gpio/gpio-rcar.c +1 -0
                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 -- [email protected]

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

Signature · 1 line
Navid.
#9 lore raw
In reply to Navid Emamdoost

pt., 5 cze 2020 o 04:49 Navid Emamdoost <[email protected]> napisał(a):

Quoted 27 lines

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.

---
 drivers/gpio/gpio-rcar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-rcar.c +3 -2
index 7284473c9fe3..eac1582c70da 100644
@@ -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)
--
Quoted 2 lines

2.17.1

Hi Navid!

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

Bart