]>
Commit | Line | Data |
---|---|---|
b10d9117 | 1 | Suspend notifiers |
91e7c75b RW |
2 | (C) 2007-2011 Rafael J. Wysocki <rjw@sisk.pl>, GPL |
3 | ||
4 | There are some operations that subsystems or drivers may want to carry out | |
5 | before hibernation/suspend or after restore/resume, but they require the system | |
6 | to be fully functional, so the drivers' and subsystems' .suspend() and .resume() | |
7 | or even .prepare() and .complete() callbacks are not suitable for this purpose. | |
8 | For example, device drivers may want to upload firmware to their devices after | |
9 | resume/restore, but they cannot do it by calling request_firmware() from their | |
10 | .resume() or .complete() routines (user land processes are frozen at these | |
11 | points). The solution may be to load the firmware into memory before processes | |
12 | are frozen and upload it from there in the .resume() routine. | |
13 | A suspend/hibernation notifier may be used for this purpose. | |
14 | ||
15 | The subsystems or drivers having such needs can register suspend notifiers that | |
16 | will be called upon the following events by the PM core: | |
b10d9117 RW |
17 | |
18 | PM_HIBERNATION_PREPARE The system is going to hibernate or suspend, tasks will | |
19 | be frozen immediately. | |
20 | ||
21 | PM_POST_HIBERNATION The system memory state has been restored from a | |
91e7c75b RW |
22 | hibernation image or an error occurred during |
23 | hibernation. Device drivers' restore callbacks have | |
b10d9117 RW |
24 | been executed and tasks have been thawed. |
25 | ||
c3e94d89 | 26 | PM_RESTORE_PREPARE The system is going to restore a hibernation image. |
91e7c75b | 27 | If all goes well, the restored kernel will issue a |
c3e94d89 AS |
28 | PM_POST_HIBERNATION notification. |
29 | ||
91e7c75b RW |
30 | PM_POST_RESTORE An error occurred during restore from hibernation. |
31 | Device drivers' restore callbacks have been executed | |
c3e94d89 AS |
32 | and tasks have been thawed. |
33 | ||
91e7c75b | 34 | PM_SUSPEND_PREPARE The system is preparing for suspend. |
b10d9117 | 35 | |
25985edc | 36 | PM_POST_SUSPEND The system has just resumed or an error occurred during |
91e7c75b RW |
37 | suspend. Device drivers' resume callbacks have been |
38 | executed and tasks have been thawed. | |
b10d9117 RW |
39 | |
40 | It is generally assumed that whatever the notifiers do for | |
41 | PM_HIBERNATION_PREPARE, should be undone for PM_POST_HIBERNATION. Analogously, | |
42 | operations performed for PM_SUSPEND_PREPARE should be reversed for | |
43 | PM_POST_SUSPEND. Additionally, all of the notifiers are called for | |
44 | PM_POST_HIBERNATION if one of them fails for PM_HIBERNATION_PREPARE, and | |
45 | all of the notifiers are called for PM_POST_SUSPEND if one of them fails for | |
46 | PM_SUSPEND_PREPARE. | |
47 | ||
48 | The hibernation and suspend notifiers are called with pm_mutex held. They are | |
49 | defined in the usual way, but their last argument is meaningless (it is always | |
50 | NULL). To register and/or unregister a suspend notifier use the functions | |
51 | register_pm_notifier() and unregister_pm_notifier(), respectively, defined in | |
52 | include/linux/suspend.h . If you don't need to unregister the notifier, you can | |
53 | also use the pm_notifier() macro defined in include/linux/suspend.h . |