diff options
Diffstat (limited to 'kernel/power/suspend.c')
-rw-r--r-- | kernel/power/suspend.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 7335952ee473..1c41ba215419 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
@@ -22,6 +22,8 @@ | |||
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/suspend.h> | 24 | #include <linux/suspend.h> |
25 | #include <linux/syscore_ops.h> | ||
26 | #include <trace/events/power.h> | ||
25 | 27 | ||
26 | #include "power.h" | 28 | #include "power.h" |
27 | 29 | ||
@@ -30,13 +32,13 @@ const char *const pm_states[PM_SUSPEND_MAX] = { | |||
30 | [PM_SUSPEND_MEM] = "mem", | 32 | [PM_SUSPEND_MEM] = "mem", |
31 | }; | 33 | }; |
32 | 34 | ||
33 | static struct platform_suspend_ops *suspend_ops; | 35 | static const struct platform_suspend_ops *suspend_ops; |
34 | 36 | ||
35 | /** | 37 | /** |
36 | * suspend_set_ops - Set the global suspend method table. | 38 | * suspend_set_ops - Set the global suspend method table. |
37 | * @ops: Pointer to ops structure. | 39 | * @ops: Pointer to ops structure. |
38 | */ | 40 | */ |
39 | void suspend_set_ops(struct platform_suspend_ops *ops) | 41 | void suspend_set_ops(const struct platform_suspend_ops *ops) |
40 | { | 42 | { |
41 | mutex_lock(&pm_mutex); | 43 | mutex_lock(&pm_mutex); |
42 | suspend_ops = ops; | 44 | suspend_ops = ops; |
@@ -161,13 +163,13 @@ static int suspend_enter(suspend_state_t state) | |||
161 | arch_suspend_disable_irqs(); | 163 | arch_suspend_disable_irqs(); |
162 | BUG_ON(!irqs_disabled()); | 164 | BUG_ON(!irqs_disabled()); |
163 | 165 | ||
164 | error = sysdev_suspend(PMSG_SUSPEND); | 166 | error = syscore_suspend(); |
165 | if (!error) { | 167 | if (!error) { |
166 | if (!suspend_test(TEST_CORE) && pm_check_wakeup_events()) { | 168 | if (!(suspend_test(TEST_CORE) || pm_wakeup_pending())) { |
167 | error = suspend_ops->enter(state); | 169 | error = suspend_ops->enter(state); |
168 | events_check_enabled = false; | 170 | events_check_enabled = false; |
169 | } | 171 | } |
170 | sysdev_resume(); | 172 | syscore_resume(); |
171 | } | 173 | } |
172 | 174 | ||
173 | arch_suspend_enable_irqs(); | 175 | arch_suspend_enable_irqs(); |
@@ -197,18 +199,17 @@ static int suspend_enter(suspend_state_t state) | |||
197 | int suspend_devices_and_enter(suspend_state_t state) | 199 | int suspend_devices_and_enter(suspend_state_t state) |
198 | { | 200 | { |
199 | int error; | 201 | int error; |
200 | gfp_t saved_mask; | ||
201 | 202 | ||
202 | if (!suspend_ops) | 203 | if (!suspend_ops) |
203 | return -ENOSYS; | 204 | return -ENOSYS; |
204 | 205 | ||
206 | trace_machine_suspend(state); | ||
205 | if (suspend_ops->begin) { | 207 | if (suspend_ops->begin) { |
206 | error = suspend_ops->begin(state); | 208 | error = suspend_ops->begin(state); |
207 | if (error) | 209 | if (error) |
208 | goto Close; | 210 | goto Close; |
209 | } | 211 | } |
210 | suspend_console(); | 212 | suspend_console(); |
211 | saved_mask = clear_gfp_allowed_mask(GFP_IOFS); | ||
212 | suspend_test_start(); | 213 | suspend_test_start(); |
213 | error = dpm_suspend_start(PMSG_SUSPEND); | 214 | error = dpm_suspend_start(PMSG_SUSPEND); |
214 | if (error) { | 215 | if (error) { |
@@ -219,17 +220,17 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
219 | if (suspend_test(TEST_DEVICES)) | 220 | if (suspend_test(TEST_DEVICES)) |
220 | goto Recover_platform; | 221 | goto Recover_platform; |
221 | 222 | ||
222 | suspend_enter(state); | 223 | error = suspend_enter(state); |
223 | 224 | ||
224 | Resume_devices: | 225 | Resume_devices: |
225 | suspend_test_start(); | 226 | suspend_test_start(); |
226 | dpm_resume_end(PMSG_RESUME); | 227 | dpm_resume_end(PMSG_RESUME); |
227 | suspend_test_finish("resume devices"); | 228 | suspend_test_finish("resume devices"); |
228 | set_gfp_allowed_mask(saved_mask); | ||
229 | resume_console(); | 229 | resume_console(); |
230 | Close: | 230 | Close: |
231 | if (suspend_ops->end) | 231 | if (suspend_ops->end) |
232 | suspend_ops->end(); | 232 | suspend_ops->end(); |
233 | trace_machine_suspend(PWR_EVENT_EXIT); | ||
233 | return error; | 234 | return error; |
234 | 235 | ||
235 | Recover_platform: | 236 | Recover_platform: |
@@ -285,7 +286,9 @@ int enter_state(suspend_state_t state) | |||
285 | goto Finish; | 286 | goto Finish; |
286 | 287 | ||
287 | pr_debug("PM: Entering %s sleep\n", pm_states[state]); | 288 | pr_debug("PM: Entering %s sleep\n", pm_states[state]); |
289 | pm_restrict_gfp_mask(); | ||
288 | error = suspend_devices_and_enter(state); | 290 | error = suspend_devices_and_enter(state); |
291 | pm_restore_gfp_mask(); | ||
289 | 292 | ||
290 | Finish: | 293 | Finish: |
291 | pr_debug("PM: Finishing wakeup.\n"); | 294 | pr_debug("PM: Finishing wakeup.\n"); |