]> git.baikalelectronics.ru Git - kernel.git/commit
PM: runtime: Have devm_pm_runtime_enable() handle pm_runtime_dont_use_autosuspend()
authorDouglas Anderson <dianders@chromium.org>
Wed, 23 Feb 2022 16:34:48 +0000 (08:34 -0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 4 Mar 2022 17:26:54 +0000 (18:26 +0100)
commit781b9aa9b9dd88457321bd7772ae3af43fcf9f39
treecc126422a607ffcc5b8be093c54dc75e11b32e72
parenta4bb3615af56325e357eba8358c36083800642a8
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>
drivers/base/power/runtime.c
include/linux/pm_runtime.h