Re: RFC: a failing pm_runtime_get increases the refcnt?

From: Andy Shevchenko
Date: Sun Jun 14 2020 - 05:35:05 EST


On Sun, Jun 14, 2020 at 12:10 PM Wolfram Sang <wsa@xxxxxxxxxx> wrote:
> both in the I2C subsystem and also for Renesas drivers I maintain, I am
> starting to get boilerplate patches doing some pm_runtime_put_* variant
> because a failing pm_runtime_get is supposed to increase the ref
> counters? Really? This feels wrong and unintuitive to me.

Yeah, that is a well known issue with PM (I even have for a long time
a coccinelle script, when I realized myself that there are a lot of
cases like this, but someone else discovered this recently, like
opening a can of worms).

> I expect there
> has been a discussion around it but I couldn't find it.

Rafael explained (again) recently this. I can't find it quickly, unfortunately.

> I wonder why we
> don't fix the code where the incremented refcount is expected for some
> reason.

The main idea behind API that a lot of drivers do *not* check error
codes from runtime PM, so, we need to keep balance in case of

pm_runtime_get(...);
...
pm_runtime_put(...);

> Can I have some pointers please?

--
With Best Regards,
Andy Shevchenko