From: Brian Norris <briannorris@chromium.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Linux PM <linux-pm@vger.kernel.org>,
Linux Driver Core Development <driver-core@lists.linux.dev>,
Ulf Hansson <ulf.hansson@oss.qualcomm.com>
Subject: Re: [PATCH v1] PM: runtime: Check refcount value in pm_runtime_release_supplier()
Date: Fri, 4 Dec 2026 11:38:09 -0800 [thread overview]
Message-ID: <axMWoYeF52j6xcP_@google.com> (raw)
In-Reply-To: <6056379.DvuYhMxLoT@rafael.j.wysocki>
On Fri, Dec 04, 2026 at 05:05:44PM +0100, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> If the device link's rpm_active refcount becomes saturated or
> underflows, the loop in pm_runtime_release_supplier() will continue
> until the supplier's usage_count goes down to 0, but that may allow
> the supplier to suspend when it is in use for reasons other than the
> consumer dependency.
>
> To avoid that, check the refcount value, expected to always be greater
> than 0 when read as an int, and break out of the loop immediately when
> it becomes invalid, instead of checking the supplier's usage counter.
So, erring on the side of "hold reference forever", instead of premature
drop? Seems OK, especially for something that should be extremely
difficult to hit.
Reviewed-by: Brian Norris <briannorris@chromium.org>
BTW, I still think all this rpm_active logic is very strange. We
shouldn't ever need to increase the rpm_active refcount larger than a
small handful (approximately on the scale of how many DL_FLAG_RPM_ACTIVE
links are created with the same consumer/supplier pair), but...
...we actually can dynamically increase rpm_active forever simply by
calling pm_runtime_set_active() repeatedly.
This feels less like a refcount and more like a bandaid over poor code
structure.
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/base/power/runtime.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -334,13 +334,13 @@ void pm_runtime_release_supplier(struct
> pm_runtime_mark_last_busy(supplier);
>
> /*
> - * The additional power.usage_count check is a safety net in case
> - * the rpm_active refcount becomes saturated, in which case
> - * refcount_dec_not_one() would return true forever, but it is not
> - * strictly necessary.
> + * The rpm_active refcount value check is a safety net in
> + * case it becomes saturated or underflows, which would cause
> + * refcount_dec_not_one() to return true forever. A valid
> + * rpm_active value cast to an int is always greater than 0.
> */
> while (refcount_dec_not_one(&link->rpm_active) &&
> - atomic_read(&supplier->power.usage_count) > 0)
> + (int)refcount_read(&link->rpm_active) > 0)
> pm_runtime_put_noidle(supplier);
> }
>
>
>
>
next prev parent reply other threads:[~2026-12-04 19:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 16:05 [PATCH v1] PM: runtime: Check refcount value in pm_runtime_release_supplier() Rafael J. Wysocki
2026-12-04 19:38 ` Brian Norris [this message]
2026-12-04 20:19 ` Rafael J. Wysocki (Intel)
2026-12-04 20:51 ` Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=axMWoYeF52j6xcP_@google.com \
--to=briannorris@chromium.org \
--cc=driver-core@lists.linux.dev \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=ulf.hansson@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox