PM / core: Direct DPM_FLAG_SMART_SUSPEND optimization
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sun, 10 Dec 2017 00:00:45 +0000 (01:00 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 2 Jan 2018 23:29:55 +0000 (00:29 +0100)
commit75e94645fc3b1007eacb4c7863059f8e8d098cda
treedb110b2815282374f08bf5d74509c73b9158cb68
parent4fa3061a6856cc72f3f984702145bb30f16ee40e
PM / core: Direct DPM_FLAG_SMART_SUSPEND optimization

Make the PM core avoid invoking the "late" and "noirq" system-wide
suspend (or analogous) callbacks provided by device drivers directly
for devices with DPM_FLAG_SMART_SUSPEND set that are in runtime
suspend during the "late" and "noirq" phases of system-wide suspend
(or analogous) transitions.  That is only done for devices without
any middle-layer "late" and "noirq" suspend callbacks (to avoid
confusing the middle layer if there is one).

The underlying observation is that runtime PM is disabled for devices
during the "late" and "noirq" system-wide suspend phases, so if they
remain in runtime suspend from the "late" phase forward, it doesn't
make sense to invoke the "late" and "noirq" callbacks provided by
the drivers for them (arguably, the device is already suspended and
in the right state).  Thus, if the remaining driver suspend callbacks
are to be invoked directly by the core, they can be skipped.

This change really makes it possible for, say, platform device
drivers to re-use runtime PM suspend and resume callbacks by
pointing ->suspend_late and ->resume_early, respectively (and
possibly the analogous hibernation-related callback pointers too),
to them without adding any extra "is the device already suspended?"
type of checks to the callback routines, as long as they will be
invoked directly by the core.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Documentation/driver-api/pm/devices.rst
drivers/base/power/main.c