2015-03-18 22:54:27 +08:00
|
|
|
#ifndef PM_TRACE_H
|
|
|
|
#define PM_TRACE_H
|
2006-06-25 05:27:42 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_PM_TRACE
|
2015-03-18 22:54:27 +08:00
|
|
|
#include <asm/pm-trace.h>
|
2010-10-12 06:00:25 +08:00
|
|
|
#include <linux/types.h>
|
2006-06-25 05:27:42 +08:00
|
|
|
|
2006-09-26 14:32:58 +08:00
|
|
|
extern int pm_trace_enabled;
|
|
|
|
|
PM: Asynchronous suspend and resume of devices
Theoretically, the total time of system sleep transitions (suspend
to RAM, hibernation) can be reduced by running suspend and resume
callbacks of device drivers in parallel with each other. However,
there are dependencies between devices such that we're not allowed
to suspend the parent of a device before suspending the device
itself. Analogously, we're not allowed to resume a device before
resuming its parent.
The most straightforward way to take these dependencies into accout
is to start the async threads used for suspending and resuming
devices at the core level, so that async_schedule() is called for
each suspend and resume callback supposed to be executed
asynchronously.
For this purpose, introduce a new device flag, power.async_suspend,
used to mark the devices whose suspend and resume callbacks are to be
executed asynchronously (ie. in parallel with the main suspend/resume
thread and possibly in parallel with each other) and helper function
device_enable_async_suspend() allowing one to set power.async_suspend
for given device (power.async_suspend is unset by default for all
devices). For each device with the power.async_suspend flag set the
PM core will use async_schedule() to execute its suspend and resume
callbacks.
The async threads started for different devices as a result of
calling async_schedule() are synchronized with each other and with
the main suspend/resume thread with the help of completions, in the
following way:
(1) There is a completion, power.completion, for each device object.
(2) Each device's completion is reset before calling async_schedule()
for the device or, in the case of devices with the
power.async_suspend flags unset, before executing the device's
suspend and resume callbacks.
(3) During suspend, right before running the bus type, device type
and device class suspend callbacks for the device, the PM core
waits for the completions of all the device's children to be
completed.
(4) During resume, right before running the bus type, device type and
device class resume callbacks for the device, the PM core waits
for the completion of the device's parent to be completed.
(5) The PM core completes power.completion for each device right
after the bus type, device type and device class suspend (or
resume) callbacks executed for the device have returned.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
2010-01-24 05:23:32 +08:00
|
|
|
static inline int pm_trace_is_enabled(void)
|
|
|
|
{
|
|
|
|
return pm_trace_enabled;
|
|
|
|
}
|
|
|
|
|
2006-06-25 05:27:42 +08:00
|
|
|
struct device;
|
|
|
|
extern void set_trace_device(struct device *);
|
2015-03-18 22:54:27 +08:00
|
|
|
extern void generate_pm_trace(const void *tracedata, unsigned int user);
|
2010-10-12 06:00:25 +08:00
|
|
|
extern int show_trace_dev_match(char *buf, size_t size);
|
2006-06-25 05:27:42 +08:00
|
|
|
|
2007-07-21 23:10:41 +08:00
|
|
|
#define TRACE_DEVICE(dev) do { \
|
|
|
|
if (pm_trace_enabled) \
|
|
|
|
set_trace_device(dev); \
|
|
|
|
} while(0)
|
2006-06-25 05:27:42 +08:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
PM: Asynchronous suspend and resume of devices
Theoretically, the total time of system sleep transitions (suspend
to RAM, hibernation) can be reduced by running suspend and resume
callbacks of device drivers in parallel with each other. However,
there are dependencies between devices such that we're not allowed
to suspend the parent of a device before suspending the device
itself. Analogously, we're not allowed to resume a device before
resuming its parent.
The most straightforward way to take these dependencies into accout
is to start the async threads used for suspending and resuming
devices at the core level, so that async_schedule() is called for
each suspend and resume callback supposed to be executed
asynchronously.
For this purpose, introduce a new device flag, power.async_suspend,
used to mark the devices whose suspend and resume callbacks are to be
executed asynchronously (ie. in parallel with the main suspend/resume
thread and possibly in parallel with each other) and helper function
device_enable_async_suspend() allowing one to set power.async_suspend
for given device (power.async_suspend is unset by default for all
devices). For each device with the power.async_suspend flag set the
PM core will use async_schedule() to execute its suspend and resume
callbacks.
The async threads started for different devices as a result of
calling async_schedule() are synchronized with each other and with
the main suspend/resume thread with the help of completions, in the
following way:
(1) There is a completion, power.completion, for each device object.
(2) Each device's completion is reset before calling async_schedule()
for the device or, in the case of devices with the
power.async_suspend flags unset, before executing the device's
suspend and resume callbacks.
(3) During suspend, right before running the bus type, device type
and device class suspend callbacks for the device, the PM core
waits for the completions of all the device's children to be
completed.
(4) During resume, right before running the bus type, device type and
device class resume callbacks for the device, the PM core waits
for the completion of the device's parent to be completed.
(5) The PM core completes power.completion for each device right
after the bus type, device type and device class suspend (or
resume) callbacks executed for the device have returned.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
2010-01-24 05:23:32 +08:00
|
|
|
static inline int pm_trace_is_enabled(void) { return 0; }
|
|
|
|
|
2006-06-25 05:27:42 +08:00
|
|
|
#define TRACE_DEVICE(dev) do { } while (0)
|
|
|
|
#define TRACE_RESUME(dev) do { } while (0)
|
2015-03-18 22:54:27 +08:00
|
|
|
#define TRACE_SUSPEND(dev) do { } while (0)
|
2006-06-25 05:27:42 +08:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|