2020-05-25 11:08:02

by Dinghao Liu

[permalink] [raw]
Subject: [PATCH] [v2] power: supply: bq24190_charger: Fix runtime PM imbalance on error

pm_runtime_get_sync() increments the runtime PM usage counter even
it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Dinghao Liu <[email protected]>
---

Changelog:

v2: - Use pm_runtime_put_noidle() rather than
pm_runtime_put_autosuspend().
---
drivers/power/supply/bq24190_charger.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 453d6332d43a..7b24c41a2137 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -481,8 +481,10 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
return ret;

ret = pm_runtime_get_sync(bdi->dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_noidle(bdi->dev);
return ret;
+ }

ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v);
if (ret)
--
2.17.1


2020-05-25 11:12:26

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] [v2] power: supply: bq24190_charger: Fix runtime PM imbalance on error

On Mon, May 25, 2020 at 1:05 PM Dinghao Liu <[email protected]> wrote:
>
> pm_runtime_get_sync() increments the runtime PM usage counter even
> it returns an error code. Thus a pairing decrement is needed on
> the error handling path to keep the counter balanced.
>
> Signed-off-by: Dinghao Liu <[email protected]>

Better now:

Reviewed-by: Rafael J. Wysocki <[email protected]>

> ---
>
> Changelog:
>
> v2: - Use pm_runtime_put_noidle() rather than
> pm_runtime_put_autosuspend().
> ---
> drivers/power/supply/bq24190_charger.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> index 453d6332d43a..7b24c41a2137 100644
> --- a/drivers/power/supply/bq24190_charger.c
> +++ b/drivers/power/supply/bq24190_charger.c
> @@ -481,8 +481,10 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
> return ret;
>
> ret = pm_runtime_get_sync(bdi->dev);
> - if (ret < 0)
> + if (ret < 0) {
> + pm_runtime_put_noidle(bdi->dev);
> return ret;
> + }
>
> ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v);
> if (ret)
> --
> 2.17.1
>

2020-06-19 17:06:52

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH] [v2] power: supply: bq24190_charger: Fix runtime PM imbalance on error

Hi,

On Mon, May 25, 2020 at 01:09:00PM +0200, Rafael J. Wysocki wrote:
> On Mon, May 25, 2020 at 1:05 PM Dinghao Liu <[email protected]> wrote:
> >
> > pm_runtime_get_sync() increments the runtime PM usage counter even
> > it returns an error code. Thus a pairing decrement is needed on
> > the error handling path to keep the counter balanced.
> >
> > Signed-off-by: Dinghao Liu <[email protected]>
>
> Better now:
>
> Reviewed-by: Rafael J. Wysocki <[email protected]>

Thanks, queued.

-- Sebastian

> > ---
> >
> > Changelog:
> >
> > v2: - Use pm_runtime_put_noidle() rather than
> > pm_runtime_put_autosuspend().
> > ---
> > drivers/power/supply/bq24190_charger.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> > index 453d6332d43a..7b24c41a2137 100644
> > --- a/drivers/power/supply/bq24190_charger.c
> > +++ b/drivers/power/supply/bq24190_charger.c
> > @@ -481,8 +481,10 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
> > return ret;
> >
> > ret = pm_runtime_get_sync(bdi->dev);
> > - if (ret < 0)
> > + if (ret < 0) {
> > + pm_runtime_put_noidle(bdi->dev);
> > return ret;
> > + }
> >
> > ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v);
> > if (ret)
> > --
> > 2.17.1
> >


Attachments:
(No filename) (1.46 kB)
signature.asc (849.00 B)
Download all attachments