Skip to contentSkip to conversation

PM: runtime: clarify pm_runtime_use_autosuspend() undo mechanism

PATCH Applied Joshua Crofts 2 participants 2 messages Oct 27

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM: runtime: clarify pm_runtime_use_autosuspend() undo mechanism

Commit d1706f9da9f4 ("PM: runtime: call pm_runtime_dont_use_autosuspend() on reinit()") introduced a pm_runtime_dont_use_autosuspend() call that is executed automatically on driver exit without making any changes to the kerneldocs.

Update the kerneldocs to clarify the current mechanism of pm_runtime_use_autosuspend() cleanup on exit.

---
Hi, would it be possible for this patch to go in a fix PR before 7.4 is released to prevent any confusion about the mechanism of pm_runtime_use_autosuspend()? Thanks!

---
 Documentation/power/runtime_pm.rst | 10 +++++-----
 include/linux/pm_runtime.h         |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)
Documentation/power/runtime_pm.rst +5 -5
index e4407b687f8b..40a5c23d5259 100644
@@ -425,11 +425,11 @@ but it also allows more flexibility in the handling of devices during the
 removal of their drivers.
 
 Drivers in ->remove() callback should undo the runtime PM changes done
-in ->probe(). Usually this means calling pm_runtime_disable(),
-pm_runtime_dont_use_autosuspend() etc. Alternatively, drivers can use
-devm_pm_runtime_enable() during probe, which automatically takes care of
-calling pm_runtime_disable() and pm_runtime_dont_use_autosuspend() upon driver
-detachment.
+in ->probe(). Usually this means calling pm_runtime_disable() etc.
+Alternatively, drivers can use devm_pm_runtime_enable() during probe, which
+automatically takes care of calling pm_runtime_disable() upon driver detachment.
+Any pm_runtime_use_autosuspend() calls in a driver will be automatically undone
+on driver exit.
 
 The user space can effectively disallow the driver of the device to power manage
 it at run time by changing the value of its /sys/devices/.../power/control
include/linux/pm_runtime.h +3 -3
index 322e3b17f987..ae68a9dc7fc5 100644
@@ -855,9 +855,9 @@ static inline void pm_runtime_disable(struct device *dev)
  * requested (or "autosuspend" will be handled as direct runtime-suspend for
  * it).
  *
- * NOTE: It's important to undo this with pm_runtime_dont_use_autosuspend()
- * at driver exit time unless your driver initially enabled pm_runtime
- * with devm_pm_runtime_enable() (which handles it for you).
+ * NOTE: This is undone automatically with pm_runtime_dont_use_autosuspend() on
+ * driver exit regardless of whether a driver uses managed devm_* functions or
+ * not.
  */
 static inline void pm_runtime_use_autosuspend(struct device *dev)
 {

base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e

Signature · 1 line
2.47.3
maintainer Applied
#1 lore raw
Quoted 57 lines · Joshua Crofts

Commit d1706f9da9f4 ("PM: runtime: call pm_runtime_dont_use_autosuspend() on reinit()") introduced a pm_runtime_dont_use_autosuspend() call that is executed automatically on driver exit without making any changes to the kerneldocs.

Update the kerneldocs to clarify the current mechanism of pm_runtime_use_autosuspend() cleanup on exit.

---
Hi, would it be possible for this patch to go in a fix PR before 7.4 is released to prevent any confusion about the mechanism of pm_runtime_use_autosuspend()? Thanks!

---
 Documentation/power/runtime_pm.rst | 10 +++++-----
 include/linux/pm_runtime.h         |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)
Documentation/power/runtime_pm.rst +5 -5
index e4407b687f8b..40a5c23d5259 100644
@@ -425,11 +425,11 @@ but it also allows more flexibility in the handling of devices during the
 removal of their drivers.
 
 Drivers in ->remove() callback should undo the runtime PM changes done
-in ->probe(). Usually this means calling pm_runtime_disable(),
-pm_runtime_dont_use_autosuspend() etc. Alternatively, drivers can use
-devm_pm_runtime_enable() during probe, which automatically takes care of
-calling pm_runtime_disable() and pm_runtime_dont_use_autosuspend() upon driver
-detachment.
+in ->probe(). Usually this means calling pm_runtime_disable() etc.
+Alternatively, drivers can use devm_pm_runtime_enable() during probe, which
+automatically takes care of calling pm_runtime_disable() upon driver detachment.
+Any pm_runtime_use_autosuspend() calls in a driver will be automatically undone
+on driver exit.
 
 The user space can effectively disallow the driver of the device to power manage
 it at run time by changing the value of its /sys/devices/.../power/control
include/linux/pm_runtime.h +3 -3
index 322e3b17f987..ae68a9dc7fc5 100644
@@ -855,9 +855,9 @@ static inline void pm_runtime_disable(struct device *dev)
  * requested (or "autosuspend" will be handled as direct runtime-suspend for
  * it).
  *
- * NOTE: It's important to undo this with pm_runtime_dont_use_autosuspend()
- * at driver exit time unless your driver initially enabled pm_runtime
- * with devm_pm_runtime_enable() (which handles it for you).
+ * NOTE: This is undone automatically with pm_runtime_dont_use_autosuspend() on
+ * driver exit regardless of whether a driver uses managed devm_* functions or
+ * not.
  */
 static inline void pm_runtime_use_autosuspend(struct device *dev)
 {
Quoted 2 lines

base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e --

Applied as 7.4-rc material, thanks!