Skip to content

Commit 46ee964

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6: PM: PM QOS update fix Freezer / cgroup freezer: Update stale locking comments PM / platform_bus: Allow runtime PM by default i2c: Fix bus-level power management callbacks PM QOS update PM / Hibernate: Fix block_io.c printk warning PM / Hibernate: Group swap ops PM / Hibernate: Move the first_sector out of swsusp_write PM / Hibernate: Separate block_io PM / Hibernate: Snapshot cleanup FS / libfs: Implement simple_write_to_buffer PM / Hibernate: document open(/dev/snapshot) side effects PM / Runtime: Add sysfs debug files PM: Improve device power management document PM: Update device power management document PM: Allow runtime_suspend methods to call pm_schedule_suspend() PM: pm_wakeup - switch to using bool
2 parents fa5312d + 25f3a5a commit 46ee964

31 files changed

Lines changed: 1251 additions & 949 deletions

File tree

‎Documentation/power/devices.txt‎

Lines changed: 483 additions & 364 deletions
Large diffs are not rendered by default.

‎Documentation/power/pm_qos_interface.txt‎

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,46 @@ and pm_qos_params.h. This is done because having the available parameters
1818
being runtime configurable or changeable from a driver was seen as too easy to
1919
abuse.
2020

21-
For each parameter a list of performance requirements is maintained along with
21+
For each parameter a list of performance requests is maintained along with
2222
an aggregated target value. The aggregated target value is updated with
23-
changes to the requirement list or elements of the list. Typically the
24-
aggregated target value is simply the max or min of the requirement values held
23+
changes to the request list or elements of the list. Typically the
24+
aggregated target value is simply the max or min of the request values held
2525
in the parameter list elements.
2626

2727
From kernel mode the use of this interface is simple:
28-
pm_qos_add_requirement(param_id, name, target_value):
29-
Will insert a named element in the list for that identified PM_QOS parameter
30-
with the target value. Upon change to this list the new target is recomputed
31-
and any registered notifiers are called only if the target value is now
32-
different.
3328

34-
pm_qos_update_requirement(param_id, name, new_target_value):
35-
Will search the list identified by the param_id for the named list element and
36-
then update its target value, calling the notification tree if the aggregated
37-
target is changed. with that name is already registered.
29+
handle = pm_qos_add_request(param_class, target_value):
30+
Will insert an element into the list for that identified PM_QOS class with the
31+
target value. Upon change to this list the new target is recomputed and any
32+
registered notifiers are called only if the target value is now different.
33+
Clients of pm_qos need to save the returned handle.
3834

39-
pm_qos_remove_requirement(param_id, name):
40-
Will search the identified list for the named element and remove it, after
41-
removal it will update the aggregate target and call the notification tree if
42-
the target was changed as a result of removing the named requirement.
35+
void pm_qos_update_request(handle, new_target_value):
36+
Will update the list element pointed to by the handle with the new target value
37+
and recompute the new aggregated target, calling the notification tree if the
38+
target is changed.
39+
40+
void pm_qos_remove_request(handle):
41+
Will remove the element. After removal it will update the aggregate target and
42+
call the notification tree if the target was changed as a result of removing
43+
the request.
4344

4445

4546
From user mode:
46-
Only processes can register a pm_qos requirement. To provide for automatic
47-
cleanup for process the interface requires the process to register its
48-
parameter requirements in the following way:
47+
Only processes can register a pm_qos request. To provide for automatic
48+
cleanup of a process, the interface requires the process to register its
49+
parameter requests in the following way:
4950

5051
To register the default pm_qos target for the specific parameter, the process
5152
must open one of /dev/[cpu_dma_latency, network_latency, network_throughput]
5253

5354
As long as the device node is held open that process has a registered
54-
requirement on the parameter. The name of the requirement is "process_<PID>"
55-
derived from the current->pid from within the open system call.
55+
request on the parameter.
5656

57-
To change the requested target value the process needs to write a s32 value to
58-
the open device node. This translates to a pm_qos_update_requirement call.
57+
To change the requested target value the process needs to write an s32 value to
58+
the open device node. Alternatively the user mode program could write a hex
59+
string for the value using 10 char long format e.g. "0x12345678". This
60+
translates to a pm_qos_update_request call.
5961

6062
To remove the user mode request for a target value simply close the device
6163
node.

‎Documentation/power/userland-swsusp.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ assumed to be in the resume mode. The device cannot be open for simultaneous
2424
reading and writing. It is also impossible to have the device open more than
2525
once at a time.
2626

27+
Even opening the device has side effects. Data structures are
28+
allocated, and PM_HIBERNATION_PREPARE / PM_RESTORE_PREPARE chains are
29+
called.
30+
2731
The ioctl() commands recognized by the device are:
2832

2933
SNAPSHOT_FREEZE - freeze user space processes (the current process is

‎drivers/acpi/processor_idle.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
698698
"max_cstate: C%d\n"
699699
"maximum allowed latency: %d usec\n",
700700
pr->power.state ? pr->power.state - pr->power.states : 0,
701-
max_cstate, pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY));
701+
max_cstate, pm_qos_request(PM_QOS_CPU_DMA_LATENCY));
702702

703703
seq_puts(seq, "states:\n");
704704

‎drivers/base/platform.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -967,17 +967,17 @@ static int platform_pm_restore_noirq(struct device *dev)
967967

968968
int __weak platform_pm_runtime_suspend(struct device *dev)
969969
{
970-
return -ENOSYS;
970+
return pm_generic_runtime_suspend(dev);
971971
};
972972

973973
int __weak platform_pm_runtime_resume(struct device *dev)
974974
{
975-
return -ENOSYS;
975+
return pm_generic_runtime_resume(dev);
976976
};
977977

978978
int __weak platform_pm_runtime_idle(struct device *dev)
979979
{
980-
return -ENOSYS;
980+
return pm_generic_runtime_idle(dev);
981981
};
982982

983983
#else /* !CONFIG_PM_RUNTIME */

‎drivers/base/power/runtime.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,16 @@ int __pm_runtime_suspend(struct device *dev, bool from_wq)
229229

230230
if (retval) {
231231
dev->power.runtime_status = RPM_ACTIVE;
232-
pm_runtime_cancel_pending(dev);
233-
234232
if (retval == -EAGAIN || retval == -EBUSY) {
235-
notify = true;
233+
if (dev->power.timer_expires == 0)
234+
notify = true;
236235
dev->power.runtime_error = 0;
236+
} else {
237+
pm_runtime_cancel_pending(dev);
237238
}
238239
} else {
239240
dev->power.runtime_status = RPM_SUSPENDED;
241+
pm_runtime_deactivate_timer(dev);
240242

241243
if (dev->parent) {
242244
parent = dev->parent;
@@ -659,8 +661,6 @@ int pm_schedule_suspend(struct device *dev, unsigned int delay)
659661

660662
if (dev->power.runtime_status == RPM_SUSPENDED)
661663
retval = 1;
662-
else if (dev->power.runtime_status == RPM_SUSPENDING)
663-
retval = -EINPROGRESS;
664664
else if (atomic_read(&dev->power.usage_count) > 0
665665
|| dev->power.disable_depth > 0)
666666
retval = -EAGAIN;

‎drivers/base/power/sysfs.c‎

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/device.h>
66
#include <linux/string.h>
77
#include <linux/pm_runtime.h>
8+
#include <asm/atomic.h>
89
#include "power.h"
910

1011
/*
@@ -143,7 +144,59 @@ wake_store(struct device * dev, struct device_attribute *attr,
143144

144145
static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store);
145146

146-
#ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG
147+
#ifdef CONFIG_PM_ADVANCED_DEBUG
148+
#ifdef CONFIG_PM_RUNTIME
149+
150+
static ssize_t rtpm_usagecount_show(struct device *dev,
151+
struct device_attribute *attr, char *buf)
152+
{
153+
return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count));
154+
}
155+
156+
static ssize_t rtpm_children_show(struct device *dev,
157+
struct device_attribute *attr, char *buf)
158+
{
159+
return sprintf(buf, "%d\n", dev->power.ignore_children ?
160+
0 : atomic_read(&dev->power.child_count));
161+
}
162+
163+
static ssize_t rtpm_enabled_show(struct device *dev,
164+
struct device_attribute *attr, char *buf)
165+
{
166+
if ((dev->power.disable_depth) && (dev->power.runtime_auto == false))
167+
return sprintf(buf, "disabled & forbidden\n");
168+
else if (dev->power.disable_depth)
169+
return sprintf(buf, "disabled\n");
170+
else if (dev->power.runtime_auto == false)
171+
return sprintf(buf, "forbidden\n");
172+
return sprintf(buf, "enabled\n");
173+
}
174+
175+
static ssize_t rtpm_status_show(struct device *dev,
176+
struct device_attribute *attr, char *buf)
177+
{
178+
if (dev->power.runtime_error)
179+
return sprintf(buf, "error\n");
180+
switch (dev->power.runtime_status) {
181+
case RPM_SUSPENDED:
182+
return sprintf(buf, "suspended\n");
183+
case RPM_SUSPENDING:
184+
return sprintf(buf, "suspending\n");
185+
case RPM_RESUMING:
186+
return sprintf(buf, "resuming\n");
187+
case RPM_ACTIVE:
188+
return sprintf(buf, "active\n");
189+
}
190+
return -EIO;
191+
}
192+
193+
static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
194+
static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
195+
static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
196+
static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
197+
198+
#endif
199+
147200
static ssize_t async_show(struct device *dev, struct device_attribute *attr,
148201
char *buf)
149202
{
@@ -170,15 +223,21 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr,
170223
}
171224

172225
static DEVICE_ATTR(async, 0644, async_show, async_store);
173-
#endif /* CONFIG_PM_SLEEP_ADVANCED_DEBUG */
226+
#endif /* CONFIG_PM_ADVANCED_DEBUG */
174227

175228
static struct attribute * power_attrs[] = {
176229
#ifdef CONFIG_PM_RUNTIME
177230
&dev_attr_control.attr,
178231
#endif
179232
&dev_attr_wakeup.attr,
180-
#ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG
233+
#ifdef CONFIG_PM_ADVANCED_DEBUG
181234
&dev_attr_async.attr,
235+
#ifdef CONFIG_PM_RUNTIME
236+
&dev_attr_runtime_usage.attr,
237+
&dev_attr_runtime_active_kids.attr,
238+
&dev_attr_runtime_status.attr,
239+
&dev_attr_runtime_enabled.attr,
240+
#endif
182241
#endif
183242
NULL,
184243
};

‎drivers/cpuidle/governors/ladder.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static int ladder_select_state(struct cpuidle_device *dev)
6767
struct ladder_device *ldev = &__get_cpu_var(ladder_devices);
6868
struct ladder_device_state *last_state;
6969
int last_residency, last_idx = ldev->last_state_idx;
70-
int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY);
70+
int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
7171

7272
/* Special case when user has set very strict latency requirement */
7373
if (unlikely(latency_req == 0)) {

‎drivers/cpuidle/governors/menu.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static u64 div_round64(u64 dividend, u32 divisor)
182182
static int menu_select(struct cpuidle_device *dev)
183183
{
184184
struct menu_device *data = &__get_cpu_var(menu_devices);
185-
int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY);
185+
int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
186186
int i;
187187
int multiplier;
188188

0 commit comments

Comments
 (0)