[Intel-gfx] [PATCH] PM / runtime: Add new helper for conditional usage count incrementation
Alan Stern
stern at rowland.harvard.edu
Tue Dec 15 07:06:33 PST 2015
On Mon, 14 Dec 2015, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki at intel.com>
>
> Introduce a new runtime PM function, pm_runtime_get_if_in_use(),
> that will increment the device's runtime PM usage counter and
> return 'true' if its status is RPM_ACTIVE and its usage counter
> is greater than 0 at the same time ('false' will be returned
> otherwise).
>
> This is useful for things that should only be done if the device
> is active (from the runtime PM perspective) and used by somebody
> (as indicated by the usage counter) already and they are not worth
> bothering otherwise.
> --- linux-pm.orig/drivers/base/power/runtime.c
> +++ linux-pm/drivers/base/power/runtime.c
> @@ -966,6 +966,27 @@ int __pm_runtime_resume(struct device *d
> EXPORT_SYMBOL_GPL(__pm_runtime_resume);
>
> /**
> + * pm_runtime_get_if_in_use - Conditionally bump up the device's usage counter.
> + * @dev: Device to handle.
> + *
> + * Increment the device's runtime PM usage counter and return 'true' if its
> + * runtime PM status is RPM_ACTIVE and its usage counter is already different
> + * from zero at the same time. Otherwise, return 'false'.
The phrasing of this comment is slightly ambiguous (it's not clear
whether the "if" clause applies to both the increment and the return
or just the return). IMO it would be somewhat better to write:
If the runtime PM status is RPM_ACTIVE and the runtime PM usage
counter is nonzero, increment the counter and return 'true'.
Otherwise return false without changing the counter.
> --- linux-pm.orig/Documentation/power/runtime_pm.txt
> +++ linux-pm/Documentation/power/runtime_pm.txt
> @@ -371,6 +371,11 @@ drivers/base/power/runtime.c and include
> - increment the device's usage counter, run pm_runtime_resume(dev) and
> return its result
>
> + bool pm_runtime_get_if_in_use(struct device *dev);
> + - increment the device's usage counter and return 'true' if its runtime PM
> + status is 'active' and its usage counter is greater than 0 at the same
> + time; return 'false' otherwise
Same thing here.
Alan Stern
More information about the Intel-gfx
mailing list