From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Linux PM <linux-pm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Alex Elder <elder@linaro.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: [PATCH v1] PM: runtime: Take active children into account in pm_runtime_get_if_in_use()
Date: Tue, 15 Jul 2025 07:24:54 +0000 [thread overview]
Message-ID: <aHYCRvz0ohgi2xUk@kekkonen.localdomain> (raw)
In-Reply-To: <12700973.O9o76ZdvQC@rjwysocki.net>
Hi Rafael,
Thanks for the patch.
On Wed, Jul 09, 2025 at 12:41:45PM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> For all practical purposes, there is no difference between the situation
> in which a given device is not ignoring children and its active child
> count is nonzero and the situation in which its runtime PM usage counter
> is nonzero. However, pm_runtime_get_if_in_use() will only increment the
> device's usage counter and return 1 in the latter case.
>
> For consistency, make it do so in the former case either by adjusting
> pm_runtime_get_conditional() and update the related kerneldoc comments
> accordingly.
>
> Fixes: c0ef3df8dbae ("PM: runtime: Simplify pm_runtime_get_if_active() usage")
I guess this should be:
Fixes: c111566bea7c ("PM: runtime: Add pm_runtime_get_if_active()")
Should this also be cc'd to stable?
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/base/power/runtime.c | 27 ++++++++++++++++++---------
> 1 file changed, 18 insertions(+), 9 deletions(-)
>
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -1203,10 +1203,12 @@
> *
> * Return -EINVAL if runtime PM is disabled for @dev.
> *
> - * Otherwise, if the runtime PM status of @dev is %RPM_ACTIVE and either
> - * @ign_usage_count is %true or the runtime PM usage counter of @dev is not
> - * zero, increment the usage counter of @dev and return 1. Otherwise, return 0
> - * without changing the usage counter.
> + * Otherwise, if its runtime PM status is %RPM_ACTIVE and (1) @ign_usage_count
> + * is set, or (2) @dev is not ignoring children and its active child count is
> + * nonero, or (3) the runtime PM usage counter of @dev is not zero, increment
> + * the usage counter of @dev and return 1.
> + *
> + * Otherwise, return 0 without changing the usage counter.
> *
> * If @ign_usage_count is %true, this function can be used to prevent suspending
> * the device when its runtime PM status is %RPM_ACTIVE.
> @@ -1228,7 +1230,8 @@
> retval = -EINVAL;
> } else if (dev->power.runtime_status != RPM_ACTIVE) {
> retval = 0;
> - } else if (ign_usage_count) {
> + } else if (ign_usage_count || (!dev->power.ignore_children &&
> + atomic_read(&dev->power.child_count) > 0)) {
> retval = 1;
> atomic_inc(&dev->power.usage_count);
> } else {
> @@ -1261,10 +1264,16 @@
> * @dev: Target device.
> *
> * Increment the runtime PM usage counter of @dev if its runtime PM status is
> - * %RPM_ACTIVE and its runtime PM usage counter is greater than 0, in which case
> - * it returns 1. If the device is in a different state or its usage_count is 0,
> - * 0 is returned. -EINVAL is returned if runtime PM is disabled for the device,
> - * in which case also the usage_count will remain unmodified.
> + * %RPM_ACTIVE and its runtime PM usage counter is greater than 0 or it is not
> + * ignoring children and its active child count is nonzero. 1 is returned in
> + * this case.
> + *
> + * If @dev is in a different state or it is not in use (that is, its usage
> + * counter is 0, or it is ignoring children, or its active child count is 0),
> + * 0 is returned.
> + *
> + * -EINVAL is returned if runtime PM is disabled for the device, in which case
> + * also the usage counter of @dev is not updated.
> */
> int pm_runtime_get_if_in_use(struct device *dev)
> {
>
>
--
Kind regards,
Sakari Ailus
next prev parent reply other threads:[~2025-07-15 7:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 10:41 Rafael J. Wysocki
2025-07-09 11:46 ` Ulf Hansson
2025-07-09 12:06 ` Rafael J. Wysocki
2025-07-09 12:48 ` Rafael J. Wysocki
2025-07-09 13:24 ` Ulf Hansson
2025-07-15 7:24 ` Sakari Ailus [this message]
2025-07-15 12:46 ` Rafael J. Wysocki
2025-07-15 13:18 ` Sakari Ailus
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=aHYCRvz0ohgi2xUk@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=elder@linaro.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=ulf.hansson@linaro.org \
/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
all inboxes | Powered by JetHome®