Skip to content

Commit eb59c50

Browse files
committed
Merge branch 'pm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
* 'pm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (76 commits) PM / Hibernate: Implement compat_ioctl for /dev/snapshot PM / Freezer: fix return value of freezable_schedule_timeout_killable() PM / shmobile: Allow the A4R domain to be turned off at run time PM / input / touchscreen: Make st1232 use device PM QoS constraints PM / QoS: Introduce dev_pm_qos_add_ancestor_request() PM / shmobile: Remove the stay_on flag from SH7372's PM domains PM / shmobile: Don't include SH7372's INTCS in syscore suspend/resume PM / shmobile: Add support for the sh7372 A4S power domain / sleep mode PM: Drop generic_subsys_pm_ops PM / Sleep: Remove forward-only callbacks from AMBA bus type PM / Sleep: Remove forward-only callbacks from platform bus type PM: Run the driver callback directly if the subsystem one is not there PM / Sleep: Make pm_op() and pm_noirq_op() return callback pointers PM/Devfreq: Add Exynos4-bus device DVFS driver for Exynos4210/4212/4412. PM / Sleep: Merge internal functions in generic_ops.c PM / Sleep: Simplify generic system suspend callbacks PM / Hibernate: Remove deprecated hibernation snapshot ioctls PM / Sleep: Fix freezer failures due to racy usermodehelper_is_disabled() ARM: S3C64XX: Implement basic power domain support PM / shmobile: Use common always on power domain governor ... Fix up trivial conflict in fs/xfs/xfs_buf.c due to removal of unused XBT_FORCE_SLEEP bit
2 parents 1619ed8 + c233523 commit eb59c50

107 files changed

Lines changed: 3249 additions & 1530 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/feature-removal-schedule.txt‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,6 @@ Who: Robin Getz <rgetz@blackfin.uclinux.org> & Matt Mackall <mpm@selenic.com>
8585

8686
---------------------------
8787

88-
What: Deprecated snapshot ioctls
89-
When: 2.6.36
90-
91-
Why: The ioctls in kernel/power/user.c were marked as deprecated long time
92-
ago. Now they notify users about that so that they need to replace
93-
their userspace. After some more time, remove them completely.
94-
95-
Who: Jiri Slaby <jirislaby@gmail.com>
96-
97-
---------------------------
98-
9988
What: The ieee80211_regdom module parameter
10089
When: March 2010 / desktop catchup
10190

‎Documentation/power/devices.txt‎

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ The core methods to suspend and resume devices reside in struct dev_pm_ops
126126
pointed to by the ops member of struct dev_pm_domain, or by the pm member of
127127
struct bus_type, struct device_type and struct class. They are mostly of
128128
interest to the people writing infrastructure for platforms and buses, like PCI
129-
or USB, or device type and device class drivers.
129+
or USB, or device type and device class drivers. They also are relevant to the
130+
writers of device drivers whose subsystems (PM domains, device types, device
131+
classes and bus types) don't provide all power management methods.
130132

131133
Bus drivers implement these methods as appropriate for the hardware and the
132134
drivers using it; PCI works differently from USB, and so on. Not many people
@@ -268,32 +270,35 @@ various phases always run after tasks have been frozen and before they are
268270
unfrozen. Furthermore, the *_noirq phases run at a time when IRQ handlers have
269271
been disabled (except for those marked with the IRQF_NO_SUSPEND flag).
270272

271-
All phases use PM domain, bus, type, or class callbacks (that is, methods
272-
defined in dev->pm_domain->ops, dev->bus->pm, dev->type->pm, or dev->class->pm).
273-
These callbacks are regarded by the PM core as mutually exclusive. Moreover,
274-
PM domain callbacks always take precedence over bus, type and class callbacks,
275-
while type callbacks take precedence over bus and class callbacks, and class
276-
callbacks take precedence over bus callbacks. To be precise, the following
277-
rules are used to determine which callback to execute in the given phase:
273+
All phases use PM domain, bus, type, class or driver callbacks (that is, methods
274+
defined in dev->pm_domain->ops, dev->bus->pm, dev->type->pm, dev->class->pm or
275+
dev->driver->pm). These callbacks are regarded by the PM core as mutually
276+
exclusive. Moreover, PM domain callbacks always take precedence over all of the
277+
other callbacks and, for example, type callbacks take precedence over bus, class
278+
and driver callbacks. To be precise, the following rules are used to determine
279+
which callback to execute in the given phase:
278280

279-
1. If dev->pm_domain is present, the PM core will attempt to execute the
280-
callback included in dev->pm_domain->ops. If that callback is not
281-
present, no action will be carried out for the given device.
281+
1. If dev->pm_domain is present, the PM core will choose the callback
282+
included in dev->pm_domain->ops for execution
282283

283284
2. Otherwise, if both dev->type and dev->type->pm are present, the callback
284-
included in dev->type->pm will be executed.
285+
included in dev->type->pm will be chosen for execution.
285286

286287
3. Otherwise, if both dev->class and dev->class->pm are present, the
287-
callback included in dev->class->pm will be executed.
288+
callback included in dev->class->pm will be chosen for execution.
288289

289290
4. Otherwise, if both dev->bus and dev->bus->pm are present, the callback
290-
included in dev->bus->pm will be executed.
291+
included in dev->bus->pm will be chosen for execution.
291292

292293
This allows PM domains and device types to override callbacks provided by bus
293294
types or device classes if necessary.
294295

295-
These callbacks may in turn invoke device- or driver-specific methods stored in
296-
dev->driver->pm, but they don't have to.
296+
The PM domain, type, class and bus callbacks may in turn invoke device- or
297+
driver-specific methods stored in dev->driver->pm, but they don't have to do
298+
that.
299+
300+
If the subsystem callback chosen for execution is not present, the PM core will
301+
execute the corresponding method from dev->driver->pm instead if there is one.
297302

298303

299304
Entering System Suspend

‎Documentation/power/freezing-of-tasks.txt‎

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ freeze_processes() (defined in kernel/power/process.c) is called. It executes
2121
try_to_freeze_tasks() that sets TIF_FREEZE for all of the freezable tasks and
2222
either wakes them up, if they are kernel threads, or sends fake signals to them,
2323
if they are user space processes. A task that has TIF_FREEZE set, should react
24-
to it by calling the function called refrigerator() (defined in
24+
to it by calling the function called __refrigerator() (defined in
2525
kernel/freezer.c), which sets the task's PF_FROZEN flag, changes its state
2626
to TASK_UNINTERRUPTIBLE and makes it loop until PF_FROZEN is cleared for it.
2727
Then, we say that the task is 'frozen' and therefore the set of functions
2828
handling this mechanism is referred to as 'the freezer' (these functions are
2929
defined in kernel/power/process.c, kernel/freezer.c & include/linux/freezer.h).
3030
User space processes are generally frozen before kernel threads.
3131

32-
It is not recommended to call refrigerator() directly. Instead, it is
33-
recommended to use the try_to_freeze() function (defined in
34-
include/linux/freezer.h), that checks the task's TIF_FREEZE flag and makes the
35-
task enter refrigerator() if the flag is set.
32+
__refrigerator() must not be called directly. Instead, use the
33+
try_to_freeze() function (defined in include/linux/freezer.h), that checks
34+
the task's TIF_FREEZE flag and makes the task enter __refrigerator() if the
35+
flag is set.
3636

3737
For user space processes try_to_freeze() is called automatically from the
3838
signal-handling code, but the freezable kernel threads need to call it
@@ -61,13 +61,13 @@ wait_event_freezable() and wait_event_freezable_timeout() macros.
6161
After the system memory state has been restored from a hibernation image and
6262
devices have been reinitialized, the function thaw_processes() is called in
6363
order to clear the PF_FROZEN flag for each frozen task. Then, the tasks that
64-
have been frozen leave refrigerator() and continue running.
64+
have been frozen leave __refrigerator() and continue running.
6565

6666
III. Which kernel threads are freezable?
6767

6868
Kernel threads are not freezable by default. However, a kernel thread may clear
6969
PF_NOFREEZE for itself by calling set_freezable() (the resetting of PF_NOFREEZE
70-
directly is strongly discouraged). From this point it is regarded as freezable
70+
directly is not allowed). From this point it is regarded as freezable
7171
and must call try_to_freeze() in a suitable place.
7272

7373
IV. Why do we do that?
@@ -176,3 +176,28 @@ tasks, since it generally exists anyway.
176176
A driver must have all firmwares it may need in RAM before suspend() is called.
177177
If keeping them is not practical, for example due to their size, they must be
178178
requested early enough using the suspend notifier API described in notifiers.txt.
179+
180+
VI. Are there any precautions to be taken to prevent freezing failures?
181+
182+
Yes, there are.
183+
184+
First of all, grabbing the 'pm_mutex' lock to mutually exclude a piece of code
185+
from system-wide sleep such as suspend/hibernation is not encouraged.
186+
If possible, that piece of code must instead hook onto the suspend/hibernation
187+
notifiers to achieve mutual exclusion. Look at the CPU-Hotplug code
188+
(kernel/cpu.c) for an example.
189+
190+
However, if that is not feasible, and grabbing 'pm_mutex' is deemed necessary,
191+
it is strongly discouraged to directly call mutex_[un]lock(&pm_mutex) since
192+
that could lead to freezing failures, because if the suspend/hibernate code
193+
successfully acquired the 'pm_mutex' lock, and hence that other entity failed
194+
to acquire the lock, then that task would get blocked in TASK_UNINTERRUPTIBLE
195+
state. As a consequence, the freezer would not be able to freeze that task,
196+
leading to freezing failure.
197+
198+
However, the [un]lock_system_sleep() APIs are safe to use in this scenario,
199+
since they ask the freezer to skip freezing this task, since it is anyway
200+
"frozen enough" as it is blocked on 'pm_mutex', which will be released
201+
only after the entire suspend/hibernation sequence is complete.
202+
So, to summarize, use [un]lock_system_sleep() instead of directly using
203+
mutex_[un]lock(&pm_mutex). That would prevent freezing failures.

‎Documentation/power/runtime_pm.txt‎

Lines changed: 68 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -57,93 +57,99 @@ the following:
5757

5858
4. Bus type of the device, if both dev->bus and dev->bus->pm are present.
5959

60+
If the subsystem chosen by applying the above rules doesn't provide the relevant
61+
callback, the PM core will invoke the corresponding driver callback stored in
62+
dev->driver->pm directly (if present).
63+
6064
The PM core always checks which callback to use in the order given above, so the
6165
priority order of callbacks from high to low is: PM domain, device type, class
6266
and bus type. Moreover, the high-priority one will always take precedence over
6367
a low-priority one. The PM domain, bus type, device type and class callbacks
6468
are referred to as subsystem-level callbacks in what follows.
6569

6670
By default, the callbacks are always invoked in process context with interrupts
67-
enabled. However, subsystems can use the pm_runtime_irq_safe() helper function
68-
to tell the PM core that their ->runtime_suspend(), ->runtime_resume() and
69-
->runtime_idle() callbacks may be invoked in atomic context with interrupts
70-
disabled for a given device. This implies that the callback routines in
71-
question must not block or sleep, but it also means that the synchronous helper
72-
functions listed at the end of Section 4 may be used for that device within an
73-
interrupt handler or generally in an atomic context.
74-
75-
The subsystem-level suspend callback is _entirely_ _responsible_ for handling
76-
the suspend of the device as appropriate, which may, but need not include
77-
executing the device driver's own ->runtime_suspend() callback (from the
71+
enabled. However, the pm_runtime_irq_safe() helper function can be used to tell
72+
the PM core that it is safe to run the ->runtime_suspend(), ->runtime_resume()
73+
and ->runtime_idle() callbacks for the given device in atomic context with
74+
interrupts disabled. This implies that the callback routines in question must
75+
not block or sleep, but it also means that the synchronous helper functions
76+
listed at the end of Section 4 may be used for that device within an interrupt
77+
handler or generally in an atomic context.
78+
79+
The subsystem-level suspend callback, if present, is _entirely_ _responsible_
80+
for handling the suspend of the device as appropriate, which may, but need not
81+
include executing the device driver's own ->runtime_suspend() callback (from the
7882
PM core's point of view it is not necessary to implement a ->runtime_suspend()
7983
callback in a device driver as long as the subsystem-level suspend callback
8084
knows what to do to handle the device).
8185

82-
* Once the subsystem-level suspend callback has completed successfully
83-
for given device, the PM core regards the device as suspended, which need
84-
not mean that the device has been put into a low power state. It is
85-
supposed to mean, however, that the device will not process data and will
86-
not communicate with the CPU(s) and RAM until the subsystem-level resume
87-
callback is executed for it. The runtime PM status of a device after
88-
successful execution of the subsystem-level suspend callback is 'suspended'.
89-
90-
* If the subsystem-level suspend callback returns -EBUSY or -EAGAIN,
91-
the device's runtime PM status is 'active', which means that the device
92-
_must_ be fully operational afterwards.
93-
94-
* If the subsystem-level suspend callback returns an error code different
95-
from -EBUSY or -EAGAIN, the PM core regards this as a fatal error and will
96-
refuse to run the helper functions described in Section 4 for the device,
97-
until the status of it is directly set either to 'active', or to 'suspended'
98-
(the PM core provides special helper functions for this purpose).
99-
100-
In particular, if the driver requires remote wake-up capability (i.e. hardware
86+
* Once the subsystem-level suspend callback (or the driver suspend callback,
87+
if invoked directly) has completed successfully for the given device, the PM
88+
core regards the device as suspended, which need not mean that it has been
89+
put into a low power state. It is supposed to mean, however, that the
90+
device will not process data and will not communicate with the CPU(s) and
91+
RAM until the appropriate resume callback is executed for it. The runtime
92+
PM status of a device after successful execution of the suspend callback is
93+
'suspended'.
94+
95+
* If the suspend callback returns -EBUSY or -EAGAIN, the device's runtime PM
96+
status remains 'active', which means that the device _must_ be fully
97+
operational afterwards.
98+
99+
* If the suspend callback returns an error code different from -EBUSY and
100+
-EAGAIN, the PM core regards this as a fatal error and will refuse to run
101+
the helper functions described in Section 4 for the device until its status
102+
is directly set to either'active', or 'suspended' (the PM core provides
103+
special helper functions for this purpose).
104+
105+
In particular, if the driver requires remote wakeup capability (i.e. hardware
101106
mechanism allowing the device to request a change of its power state, such as
102107
PCI PME) for proper functioning and device_run_wake() returns 'false' for the
103108
device, then ->runtime_suspend() should return -EBUSY. On the other hand, if
104-
device_run_wake() returns 'true' for the device and the device is put into a low
105-
power state during the execution of the subsystem-level suspend callback, it is
106-
expected that remote wake-up will be enabled for the device. Generally, remote
107-
wake-up should be enabled for all input devices put into a low power state at
108-
run time.
109-
110-
The subsystem-level resume callback is _entirely_ _responsible_ for handling the
111-
resume of the device as appropriate, which may, but need not include executing
112-
the device driver's own ->runtime_resume() callback (from the PM core's point of
113-
view it is not necessary to implement a ->runtime_resume() callback in a device
114-
driver as long as the subsystem-level resume callback knows what to do to handle
115-
the device).
116-
117-
* Once the subsystem-level resume callback has completed successfully, the PM
118-
core regards the device as fully operational, which means that the device
119-
_must_ be able to complete I/O operations as needed. The runtime PM status
120-
of the device is then 'active'.
121-
122-
* If the subsystem-level resume callback returns an error code, the PM core
123-
regards this as a fatal error and will refuse to run the helper functions
124-
described in Section 4 for the device, until its status is directly set
125-
either to 'active' or to 'suspended' (the PM core provides special helper
126-
functions for this purpose).
127-
128-
The subsystem-level idle callback is executed by the PM core whenever the device
129-
appears to be idle, which is indicated to the PM core by two counters, the
130-
device's usage counter and the counter of 'active' children of the device.
109+
device_run_wake() returns 'true' for the device and the device is put into a
110+
low-power state during the execution of the suspend callback, it is expected
111+
that remote wakeup will be enabled for the device. Generally, remote wakeup
112+
should be enabled for all input devices put into low-power states at run time.
113+
114+
The subsystem-level resume callback, if present, is _entirely_ _responsible_ for
115+
handling the resume of the device as appropriate, which may, but need not
116+
include executing the device driver's own ->runtime_resume() callback (from the
117+
PM core's point of view it is not necessary to implement a ->runtime_resume()
118+
callback in a device driver as long as the subsystem-level resume callback knows
119+
what to do to handle the device).
120+
121+
* Once the subsystem-level resume callback (or the driver resume callback, if
122+
invoked directly) has completed successfully, the PM core regards the device
123+
as fully operational, which means that the device _must_ be able to complete
124+
I/O operations as needed. The runtime PM status of the device is then
125+
'active'.
126+
127+
* If the resume callback returns an error code, the PM core regards this as a
128+
fatal error and will refuse to run the helper functions described in Section
129+
4 for the device, until its status is directly set to either 'active', or
130+
'suspended' (by means of special helper functions provided by the PM core
131+
for this purpose).
132+
133+
The idle callback (a subsystem-level one, if present, or the driver one) is
134+
executed by the PM core whenever the device appears to be idle, which is
135+
indicated to the PM core by two counters, the device's usage counter and the
136+
counter of 'active' children of the device.
131137

132138
* If any of these counters is decreased using a helper function provided by
133139
the PM core and it turns out to be equal to zero, the other counter is
134140
checked. If that counter also is equal to zero, the PM core executes the
135-
subsystem-level idle callback with the device as an argument.
141+
idle callback with the device as its argument.
136142

137-
The action performed by a subsystem-level idle callback is totally dependent on
138-
the subsystem in question, but the expected and recommended action is to check
143+
The action performed by the idle callback is totally dependent on the subsystem
144+
(or driver) in question, but the expected and recommended action is to check
139145
if the device can be suspended (i.e. if all of the conditions necessary for
140146
suspending the device are satisfied) and to queue up a suspend request for the
141147
device in that case. The value returned by this callback is ignored by the PM
142148
core.
143149

144150
The helper functions provided by the PM core, described in Section 4, guarantee
145-
that the following constraints are met with respect to the bus type's runtime
146-
PM callbacks:
151+
that the following constraints are met with respect to runtime PM callbacks for
152+
one device:
147153

148154
(1) The callbacks are mutually exclusive (e.g. it is forbidden to execute
149155
->runtime_suspend() in parallel with ->runtime_resume() or with another

‎arch/alpha/include/asm/thread_info.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,13 @@ register struct thread_info *__current_thread_info __asm__("$8");
7979
#define TIF_UAC_SIGBUS 12 /* ! userspace part of 'osf_sysinfo' */
8080
#define TIF_MEMDIE 13 /* is terminating due to OOM killer */
8181
#define TIF_RESTORE_SIGMASK 14 /* restore signal mask in do_signal */
82-
#define TIF_FREEZE 16 /* is freezing for suspend */
8382

8483
#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
8584
#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
8685
#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
8786
#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8887
#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
8988
#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
90-
#define _TIF_FREEZE (1<<TIF_FREEZE)
9189

9290
/* Work to do on interrupt/exception return. */
9391
#define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \

‎arch/arm/include/asm/thread_info.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ extern void vfp_flush_hwstate(struct thread_info *);
142142
#define TIF_POLLING_NRFLAG 16
143143
#define TIF_USING_IWMMXT 17
144144
#define TIF_MEMDIE 18 /* is terminating due to OOM killer */
145-
#define TIF_FREEZE 19
146145
#define TIF_RESTORE_SIGMASK 20
147146
#define TIF_SECCOMP 21
148147

@@ -152,7 +151,6 @@ extern void vfp_flush_hwstate(struct thread_info *);
152151
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
153152
#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
154153
#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
155-
#define _TIF_FREEZE (1 << TIF_FREEZE)
156154
#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
157155
#define _TIF_SECCOMP (1 << TIF_SECCOMP)
158156

‎arch/arm/mach-s3c64xx/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ config PLAT_S3C64XX
88
bool
99
depends on ARCH_S3C64XX
1010
select SAMSUNG_WAKEMASK
11+
select PM_GENERIC_DOMAINS
1112
default y
1213
help
1314
Base platform code for any Samsung S3C64XX device

‎arch/arm/mach-s3c64xx/mach-crag6410.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ static void __init crag6410_machine_init(void)
706706

707707
regulator_has_full_constraints();
708708

709-
s3c_pm_init();
709+
s3c64xx_pm_init();
710710
}
711711

712712
MACHINE_START(WLF_CRAGG_6410, "Wolfson Cragganmore 6410")

0 commit comments

Comments
 (0)