aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/pm_runtime.h
diff options
context:
space:
mode:
authorDouglas Anderson <dianders@chromium.org>2022-02-23 08:34:48 -0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2022-03-04 18:26:54 +0100
commitb4060db9251f919506e4d672737c6b8ab9a84701 (patch)
treecc126422a607ffcc5b8be093c54dc75e11b32e72 /include/linux/pm_runtime.h
parentLinux 5.17-rc6 (diff)
downloadwireguard-linux-b4060db9251f919506e4d672737c6b8ab9a84701.tar.xz
wireguard-linux-b4060db9251f919506e4d672737c6b8ab9a84701.zip
PM: runtime: Have devm_pm_runtime_enable() handle pm_runtime_dont_use_autosuspend()
The PM Runtime docs say: 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. From grepping code, it's clear that many people aren't aware of the need to call pm_runtime_dont_use_autosuspend(). When brainstorming solutions, one idea that came up was to leverage the new-ish devm_pm_runtime_enable() function. The idea here is that: * When the devm action is called we know that the driver is being removed. It's the perfect time to undo the use_autosuspend. * The code of pm_runtime_dont_use_autosuspend() already handles the case of being called when autosuspend wasn't enabled. Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/linux/pm_runtime.h')
-rw-r--r--include/linux/pm_runtime.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 9f09601c465a..2bff6a10095d 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -567,6 +567,10 @@ static inline void pm_runtime_disable(struct device *dev)
* Allow the runtime PM autosuspend mechanism to be used for @dev whenever
* 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).
*/
static inline void pm_runtime_use_autosuspend(struct device *dev)
{