diff mbox series

[v1] PM: Rearrange documentation related to __pm_runtime_disable()

Message ID 12617588.O9o76ZdvQC@rjwysocki.net (mailing list archive)
State In Next
Delegated to: Rafael Wysocki
Headers show
Series [v1] PM: Rearrange documentation related to __pm_runtime_disable() | expand

Commit Message

Rafael J. Wysocki Feb. 17, 2025, 8:03 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

There are only two callers of __pm_runtime_disable(), one of which is
device_suspend_late() and the other is pm_runtime_disable() that has
its own kerneldoc comment and there are no plans to add any more of
them.  Since they use different values of the __pm_runtime_disable()
second parameter, the actual code behavior is different in each case,
but it is all documented in the __pm_runtime_disable() kerneldoc comment
which is not particularly straightforward.

For this reason, move the information from the __pm_runtime_disable()
kerneldoc comment to the pm_runtime_disable() one and into a separate
comment in device_suspend_late() and remove the __pm_runtime_disable()
kerneldoc comment altogether.

No functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/base/power/main.c    |    4 ++++
 drivers/base/power/runtime.c |   14 --------------
 include/linux/pm_runtime.h   |   15 +++++++++++----
 3 files changed, 15 insertions(+), 18 deletions(-)

Comments

Ulf Hansson Feb. 18, 2025, 11:09 a.m. UTC | #1
On Mon, 17 Feb 2025 at 21:03, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> There are only two callers of __pm_runtime_disable(), one of which is
> device_suspend_late() and the other is pm_runtime_disable() that has
> its own kerneldoc comment and there are no plans to add any more of
> them.  Since they use different values of the __pm_runtime_disable()
> second parameter, the actual code behavior is different in each case,
> but it is all documented in the __pm_runtime_disable() kerneldoc comment
> which is not particularly straightforward.
>
> For this reason, move the information from the __pm_runtime_disable()
> kerneldoc comment to the pm_runtime_disable() one and into a separate
> comment in device_suspend_late() and remove the __pm_runtime_disable()
> kerneldoc comment altogether.
>
> No functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Much better!

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/base/power/main.c    |    4 ++++
>  drivers/base/power/runtime.c |   14 --------------
>  include/linux/pm_runtime.h   |   15 +++++++++++----
>  3 files changed, 15 insertions(+), 18 deletions(-)
>
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -1404,6 +1404,10 @@
>         TRACE_DEVICE(dev);
>         TRACE_SUSPEND(0);
>
> +       /*
> +        * Disable runtime PM for the device without checking if there is a
> +        * pending resume request for it.
> +        */
>         __pm_runtime_disable(dev, false);
>
>         dpm_wait_for_subordinate(dev, async);
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -1460,20 +1460,6 @@
>  }
>  EXPORT_SYMBOL_GPL(pm_runtime_barrier);
>
> -/**
> - * __pm_runtime_disable - Disable runtime PM of a device.
> - * @dev: Device to handle.
> - * @check_resume: If set, check if there's a resume request for the device.
> - *
> - * Increment power.disable_depth for the device and if it was zero previously,
> - * cancel all pending runtime PM requests for the device and wait for all
> - * operations in progress to complete.  The device can be either active or
> - * suspended after its runtime PM has been disabled.
> - *
> - * If @check_resume is set and there's a resume request pending when
> - * __pm_runtime_disable() is called and power.disable_depth is zero, the
> - * function will wake up the device before disabling its runtime PM.
> - */
>  void __pm_runtime_disable(struct device *dev, bool check_resume)
>  {
>         spin_lock_irq(&dev->power.lock);
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -556,11 +556,18 @@
>   * pm_runtime_disable - Disable runtime PM for a device.
>   * @dev: Target device.
>   *
> - * Prevent the runtime PM framework from working with @dev (by incrementing its
> - * "blocking" counter).
> + * Prevent the runtime PM framework from working with @dev by incrementing its
> + * "disable" counter.
>   *
> - * For each invocation of this function for @dev there must be a matching
> - * pm_runtime_enable() call in order for runtime PM to be enabled for it.
> + * If the counter is zero when this function runs and there is a pending runtime
> + * resume request for @dev, it will be resumed.  If the counter is still zero at
> + * that point, all of the pending runtime PM requests for @dev will be canceled
> + * and all runtime PM operations in progress involving it will be waited for to
> + * complete.
> + *
> + * For each invocation of this function for @dev, there must be a matching
> + * pm_runtime_enable() call, so that runtime PM is eventually enabled for it
> + * again.
>   */
>  static inline void pm_runtime_disable(struct device *dev)
>  {
>
>
>
diff mbox series

Patch

--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1404,6 +1404,10 @@ 
 	TRACE_DEVICE(dev);
 	TRACE_SUSPEND(0);
 
+	/*
+	 * Disable runtime PM for the device without checking if there is a
+	 * pending resume request for it.
+	 */
 	__pm_runtime_disable(dev, false);
 
 	dpm_wait_for_subordinate(dev, async);
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1460,20 +1460,6 @@ 
 }
 EXPORT_SYMBOL_GPL(pm_runtime_barrier);
 
-/**
- * __pm_runtime_disable - Disable runtime PM of a device.
- * @dev: Device to handle.
- * @check_resume: If set, check if there's a resume request for the device.
- *
- * Increment power.disable_depth for the device and if it was zero previously,
- * cancel all pending runtime PM requests for the device and wait for all
- * operations in progress to complete.  The device can be either active or
- * suspended after its runtime PM has been disabled.
- *
- * If @check_resume is set and there's a resume request pending when
- * __pm_runtime_disable() is called and power.disable_depth is zero, the
- * function will wake up the device before disabling its runtime PM.
- */
 void __pm_runtime_disable(struct device *dev, bool check_resume)
 {
 	spin_lock_irq(&dev->power.lock);
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -556,11 +556,18 @@ 
  * pm_runtime_disable - Disable runtime PM for a device.
  * @dev: Target device.
  *
- * Prevent the runtime PM framework from working with @dev (by incrementing its
- * "blocking" counter).
+ * Prevent the runtime PM framework from working with @dev by incrementing its
+ * "disable" counter.
  *
- * For each invocation of this function for @dev there must be a matching
- * pm_runtime_enable() call in order for runtime PM to be enabled for it.
+ * If the counter is zero when this function runs and there is a pending runtime
+ * resume request for @dev, it will be resumed.  If the counter is still zero at
+ * that point, all of the pending runtime PM requests for @dev will be canceled
+ * and all runtime PM operations in progress involving it will be waited for to
+ * complete.
+ *
+ * For each invocation of this function for @dev, there must be a matching
+ * pm_runtime_enable() call, so that runtime PM is eventually enabled for it
+ * again.
  */
 static inline void pm_runtime_disable(struct device *dev)
 {