Skip to content

Commit e52cff8

Browse files
committed
Merge branch 'pm-assorted'
* pm-assorted: PM / QoS: Add pm_qos and dev_pm_qos to events-power.txt PM / QoS: Add dev_pm_qos_request tracepoints PM / QoS: Add pm_qos_request tracepoints PM / QoS: Add pm_qos_update_target/flags tracepoints PM / QoS: Update Documentation/power/pm_qos_interface.txt PM / Sleep: Print last wakeup source on failed wakeup_count write PM / QoS: correct the valid range of pm_qos_class PM / wakeup: Adjust messaging for wake events during suspend PM / Runtime: Update .runtime_idle() callback documentation PM / Runtime: Rework the "runtime idle" helper routine PM / Hibernate: print physical addresses consistently with other parts of kernel
2 parents 405a108 + f5ce157 commit e52cff8

33 files changed

Lines changed: 315 additions & 113 deletions

File tree

‎Documentation/power/pm_qos_interface.txt‎

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ one of the parameters.
77
Two different PM QoS frameworks are available:
88
1. PM QoS classes for cpu_dma_latency, network_latency, network_throughput.
99
2. the per-device PM QoS framework provides the API to manage the per-device latency
10-
constraints.
10+
constraints and PM QoS flags.
1111

1212
Each parameters have defined units:
1313
* latency: usec
@@ -86,13 +86,17 @@ To remove the user mode request for a target value simply close the device
8686
node.
8787

8888

89-
2. PM QoS per-device latency framework
89+
2. PM QoS per-device latency and flags framework
90+
91+
For each device, there are two lists of PM QoS requests. One is maintained
92+
along with the aggregated target of latency value and the other is for PM QoS
93+
flags. Values are updated in response to changes of the request list.
94+
95+
Target latency value is simply the minimum of the request values held in the
96+
parameter list elements. The PM QoS flags aggregate value is a gather (bitwise
97+
OR) of all list elements' values. Two device PM QoS flags are defined currently:
98+
PM_QOS_FLAG_NO_POWER_OFF and PM_QOS_FLAG_REMOTE_WAKEUP.
9099

91-
For each device a list of performance requests is maintained along with
92-
an aggregated target value. The aggregated target value is updated with
93-
changes to the request list or elements of the list. Typically the
94-
aggregated target value is simply the max or min of the request values held
95-
in the parameter list elements.
96100
Note: the aggregated target value is implemented as an atomic variable so that
97101
reading the aggregated value does not require any locking mechanism.
98102

@@ -119,6 +123,38 @@ the request.
119123
s32 dev_pm_qos_read_value(device):
120124
Returns the aggregated value for a given device's constraints list.
121125

126+
enum pm_qos_flags_status dev_pm_qos_flags(device, mask)
127+
Check PM QoS flags of the given device against the given mask of flags.
128+
The meaning of the return values is as follows:
129+
PM_QOS_FLAGS_ALL: All flags from the mask are set
130+
PM_QOS_FLAGS_SOME: Some flags from the mask are set
131+
PM_QOS_FLAGS_NONE: No flags from the mask are set
132+
PM_QOS_FLAGS_UNDEFINED: The device's PM QoS structure has not been
133+
initialized or the list of requests is empty.
134+
135+
int dev_pm_qos_add_ancestor_request(dev, handle, value)
136+
Add a PM QoS request for the first direct ancestor of the given device whose
137+
power.ignore_children flag is unset.
138+
139+
int dev_pm_qos_expose_latency_limit(device, value)
140+
Add a request to the device's PM QoS list of latency constraints and create
141+
a sysfs attribute pm_qos_resume_latency_us under the device's power directory
142+
allowing user space to manipulate that request.
143+
144+
void dev_pm_qos_hide_latency_limit(device)
145+
Drop the request added by dev_pm_qos_expose_latency_limit() from the device's
146+
PM QoS list of latency constraints and remove sysfs attribute pm_qos_resume_latency_us
147+
from the device's power directory.
148+
149+
int dev_pm_qos_expose_flags(device, value)
150+
Add a request to the device's PM QoS list of flags and create sysfs attributes
151+
pm_qos_no_power_off and pm_qos_remote_wakeup under the device's power directory
152+
allowing user space to change these flags' value.
153+
154+
void dev_pm_qos_hide_flags(device)
155+
Drop the request added by dev_pm_qos_expose_flags() from the device's PM QoS list
156+
of flags and remove sysfs attributes pm_qos_no_power_off and pm_qos_remote_wakeup
157+
under the device's power directory.
122158

123159
Notification mechanisms:
124160
The per-device PM QoS framework has 2 different and distinct notification trees:

‎Documentation/power/runtime_pm.txt‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,12 @@ The action performed by the idle callback is totally dependent on the subsystem
144144
(or driver) in question, but the expected and recommended action is to check
145145
if the device can be suspended (i.e. if all of the conditions necessary for
146146
suspending the device are satisfied) and to queue up a suspend request for the
147-
device in that case. The value returned by this callback is ignored by the PM
148-
core.
147+
device in that case. If there is no idle callback, or if the callback returns
148+
0, then the PM core will attempt to carry out a runtime suspend of the device;
149+
in essence, it will call pm_runtime_suspend() directly. To prevent this (for
150+
example, if the callback routine has started a delayed suspend), the routine
151+
should return a non-zero value. Negative error return codes are ignored by the
152+
PM core.
149153

150154
The helper functions provided by the PM core, described in Section 4, guarantee
151155
that the following constraints are met with respect to runtime PM callbacks for
@@ -301,9 +305,10 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
301305
removing the device from device hierarchy
302306

303307
int pm_runtime_idle(struct device *dev);
304-
- execute the subsystem-level idle callback for the device; returns 0 on
305-
success or error code on failure, where -EINPROGRESS means that
306-
->runtime_idle() is already being executed
308+
- execute the subsystem-level idle callback for the device; returns an
309+
error code on failure, where -EINPROGRESS means that ->runtime_idle() is
310+
already being executed; if there is no callback or the callback returns 0
311+
then run pm_runtime_suspend(dev) and return its result
307312

308313
int pm_runtime_suspend(struct device *dev);
309314
- execute the subsystem-level suspend callback for the device; returns 0 on
@@ -660,11 +665,6 @@ Subsystems may wish to conserve code space by using the set of generic power
660665
management callbacks provided by the PM core, defined in
661666
driver/base/power/generic_ops.c:
662667

663-
int pm_generic_runtime_idle(struct device *dev);
664-
- invoke the ->runtime_idle() callback provided by the driver of this
665-
device, if defined, and call pm_runtime_suspend() for this device if the
666-
return value is 0 or the callback is not defined
667-
668668
int pm_generic_runtime_suspend(struct device *dev);
669669
- invoke the ->runtime_suspend() callback provided by the driver of this
670670
device and return its result, or return -EINVAL if not defined

‎Documentation/trace/events-power.txt‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,34 @@ power_domain_target "%s state=%lu cpu_id=%lu"
6363
The first parameter gives the power domain name (e.g. "mpu_pwrdm").
6464
The second parameter is the power domain target state.
6565

66+
4. PM QoS events
67+
================
68+
The PM QoS events are used for QoS add/update/remove request and for
69+
target/flags update.
70+
71+
pm_qos_add_request "pm_qos_class=%s value=%d"
72+
pm_qos_update_request "pm_qos_class=%s value=%d"
73+
pm_qos_remove_request "pm_qos_class=%s value=%d"
74+
pm_qos_update_request_timeout "pm_qos_class=%s value=%d, timeout_us=%ld"
75+
76+
The first parameter gives the QoS class name (e.g. "CPU_DMA_LATENCY").
77+
The second parameter is value to be added/updated/removed.
78+
The third parameter is timeout value in usec.
79+
80+
pm_qos_update_target "action=%s prev_value=%d curr_value=%d"
81+
pm_qos_update_flags "action=%s prev_value=0x%x curr_value=0x%x"
82+
83+
The first parameter gives the QoS action name (e.g. "ADD_REQ").
84+
The second parameter is the previous QoS value.
85+
The third parameter is the current QoS value to update.
86+
87+
And, there are also events used for device PM QoS add/update/remove request.
88+
89+
dev_pm_qos_add_request "device=%s type=%s new_value=%d"
90+
dev_pm_qos_update_request "device=%s type=%s new_value=%d"
91+
dev_pm_qos_remove_request "device=%s type=%s new_value=%d"
92+
93+
The first parameter gives the device name which tries to add/update/remove
94+
QoS requests.
95+
The second parameter gives the request type (e.g. "DEV_PM_QOS_LATENCY").
96+
The third parameter is value to be added/updated/removed.

‎arch/arm/mach-omap2/omap_device.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,6 @@ static int _od_runtime_suspend(struct device *dev)
591591
return ret;
592592
}
593593

594-
static int _od_runtime_idle(struct device *dev)
595-
{
596-
return pm_generic_runtime_idle(dev);
597-
}
598-
599594
static int _od_runtime_resume(struct device *dev)
600595
{
601596
struct platform_device *pdev = to_platform_device(dev);
@@ -653,7 +648,7 @@ static int _od_resume_noirq(struct device *dev)
653648
struct dev_pm_domain omap_device_pm_domain = {
654649
.ops = {
655650
SET_RUNTIME_PM_OPS(_od_runtime_suspend, _od_runtime_resume,
656-
_od_runtime_idle)
651+
NULL)
657652
USE_PLATFORM_PM_SLEEP_OPS
658653
.suspend_noirq = _od_suspend_noirq,
659654
.resume_noirq = _od_resume_noirq,

‎drivers/acpi/device_pm.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,6 @@ static struct dev_pm_domain acpi_general_pm_domain = {
933933
#ifdef CONFIG_PM_RUNTIME
934934
.runtime_suspend = acpi_subsys_runtime_suspend,
935935
.runtime_resume = acpi_subsys_runtime_resume,
936-
.runtime_idle = pm_generic_runtime_idle,
937936
#endif
938937
#ifdef CONFIG_PM_SLEEP
939938
.prepare = acpi_subsys_prepare,

‎drivers/amba/bus.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static const struct dev_pm_ops amba_pm = {
284284
SET_RUNTIME_PM_OPS(
285285
amba_pm_runtime_suspend,
286286
amba_pm_runtime_resume,
287-
pm_generic_runtime_idle
287+
NULL
288288
)
289289
};
290290

‎drivers/ata/libata-core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5436,7 +5436,7 @@ static int ata_port_runtime_idle(struct device *dev)
54365436
return -EBUSY;
54375437
}
54385438

5439-
return pm_runtime_suspend(dev);
5439+
return 0;
54405440
}
54415441

54425442
static int ata_port_runtime_suspend(struct device *dev)

‎drivers/base/platform.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,6 @@ int platform_pm_restore(struct device *dev)
888888
static const struct dev_pm_ops platform_dev_pm_ops = {
889889
.runtime_suspend = pm_generic_runtime_suspend,
890890
.runtime_resume = pm_generic_runtime_resume,
891-
.runtime_idle = pm_generic_runtime_idle,
892891
USE_PLATFORM_PM_SLEEP_OPS
893892
};
894893

‎drivers/base/power/domain.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2143,7 +2143,6 @@ void pm_genpd_init(struct generic_pm_domain *genpd,
21432143
genpd->max_off_time_changed = true;
21442144
genpd->domain.ops.runtime_suspend = pm_genpd_runtime_suspend;
21452145
genpd->domain.ops.runtime_resume = pm_genpd_runtime_resume;
2146-
genpd->domain.ops.runtime_idle = pm_generic_runtime_idle;
21472146
genpd->domain.ops.prepare = pm_genpd_prepare;
21482147
genpd->domain.ops.suspend = pm_genpd_suspend;
21492148
genpd->domain.ops.suspend_late = pm_genpd_suspend_late;

‎drivers/base/power/generic_ops.c‎

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,6 @@
1111
#include <linux/export.h>
1212

1313
#ifdef CONFIG_PM_RUNTIME
14-
/**
15-
* pm_generic_runtime_idle - Generic runtime idle callback for subsystems.
16-
* @dev: Device to handle.
17-
*
18-
* If PM operations are defined for the @dev's driver and they include
19-
* ->runtime_idle(), execute it and return its error code, if nonzero.
20-
* Otherwise, execute pm_runtime_suspend() for the device and return 0.
21-
*/
22-
int pm_generic_runtime_idle(struct device *dev)
23-
{
24-
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
25-
26-
if (pm && pm->runtime_idle) {
27-
int ret = pm->runtime_idle(dev);
28-
if (ret)
29-
return ret;
30-
}
31-
32-
pm_runtime_suspend(dev);
33-
return 0;
34-
}
35-
EXPORT_SYMBOL_GPL(pm_generic_runtime_idle);
36-
3714
/**
3815
* pm_generic_runtime_suspend - Generic runtime suspend callback for subsystems.
3916
* @dev: Device to suspend.

0 commit comments

Comments
 (0)