aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/suspend.h
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/linux/suspend.h
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'include/linux/suspend.h')
-rw-r--r--include/linux/suspend.h153
1 files changed, 14 insertions, 139 deletions
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 0c808d7fa57..6bbcef22e10 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -6,21 +6,17 @@
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/pm.h> 7#include <linux/pm.h>
8#include <linux/mm.h> 8#include <linux/mm.h>
9#include <linux/freezer.h>
10#include <asm/errno.h> 9#include <asm/errno.h>
11 10
12#ifdef CONFIG_VT 11#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
13extern void pm_set_vt_switch(int); 12extern void pm_set_vt_switch(int);
13extern int pm_prepare_console(void);
14extern void pm_restore_console(void);
14#else 15#else
15static inline void pm_set_vt_switch(int do_switch) 16static inline void pm_set_vt_switch(int do_switch)
16{ 17{
17} 18}
18#endif
19 19
20#ifdef CONFIG_VT_CONSOLE_SLEEP
21extern int pm_prepare_console(void);
22extern void pm_restore_console(void);
23#else
24static inline int pm_prepare_console(void) 20static inline int pm_prepare_console(void)
25{ 21{
26 return 0; 22 return 0;
@@ -38,62 +34,6 @@ typedef int __bitwise suspend_state_t;
38#define PM_SUSPEND_MEM ((__force suspend_state_t) 3) 34#define PM_SUSPEND_MEM ((__force suspend_state_t) 3)
39#define PM_SUSPEND_MAX ((__force suspend_state_t) 4) 35#define PM_SUSPEND_MAX ((__force suspend_state_t) 4)
40 36
41enum suspend_stat_step {
42 SUSPEND_FREEZE = 1,
43 SUSPEND_PREPARE,
44 SUSPEND_SUSPEND,
45 SUSPEND_SUSPEND_LATE,
46 SUSPEND_SUSPEND_NOIRQ,
47 SUSPEND_RESUME_NOIRQ,
48 SUSPEND_RESUME_EARLY,
49 SUSPEND_RESUME
50};
51
52struct suspend_stats {
53 int success;
54 int fail;
55 int failed_freeze;
56 int failed_prepare;
57 int failed_suspend;
58 int failed_suspend_late;
59 int failed_suspend_noirq;
60 int failed_resume;
61 int failed_resume_early;
62 int failed_resume_noirq;
63#define REC_FAILED_NUM 2
64 int last_failed_dev;
65 char failed_devs[REC_FAILED_NUM][40];
66 int last_failed_errno;
67 int errno[REC_FAILED_NUM];
68 int last_failed_step;
69 enum suspend_stat_step failed_steps[REC_FAILED_NUM];
70};
71
72extern struct suspend_stats suspend_stats;
73
74static inline void dpm_save_failed_dev(const char *name)
75{
76 strlcpy(suspend_stats.failed_devs[suspend_stats.last_failed_dev],
77 name,
78 sizeof(suspend_stats.failed_devs[0]));
79 suspend_stats.last_failed_dev++;
80 suspend_stats.last_failed_dev %= REC_FAILED_NUM;
81}
82
83static inline void dpm_save_failed_errno(int err)
84{
85 suspend_stats.errno[suspend_stats.last_failed_errno] = err;
86 suspend_stats.last_failed_errno++;
87 suspend_stats.last_failed_errno %= REC_FAILED_NUM;
88}
89
90static inline void dpm_save_failed_step(enum suspend_stat_step step)
91{
92 suspend_stats.failed_steps[suspend_stats.last_failed_step] = step;
93 suspend_stats.last_failed_step++;
94 suspend_stats.last_failed_step %= REC_FAILED_NUM;
95}
96
97/** 37/**
98 * struct platform_suspend_ops - Callbacks for managing platform dependent 38 * struct platform_suspend_ops - Callbacks for managing platform dependent
99 * system sleep states. 39 * system sleep states.
@@ -336,8 +276,6 @@ static inline bool system_entering_hibernation(void) { return false; }
336#define PM_RESTORE_PREPARE 0x0005 /* Going to restore a saved image */ 276#define PM_RESTORE_PREPARE 0x0005 /* Going to restore a saved image */
337#define PM_POST_RESTORE 0x0006 /* Restore failed */ 277#define PM_POST_RESTORE 0x0006 /* Restore failed */
338 278
339extern struct mutex pm_mutex;
340
341#ifdef CONFIG_PM_SLEEP 279#ifdef CONFIG_PM_SLEEP
342void save_processor_state(void); 280void save_processor_state(void);
343void restore_processor_state(void); 281void restore_processor_state(void);
@@ -356,37 +294,8 @@ extern int unregister_pm_notifier(struct notifier_block *nb);
356extern bool events_check_enabled; 294extern bool events_check_enabled;
357 295
358extern bool pm_wakeup_pending(void); 296extern bool pm_wakeup_pending(void);
359extern bool pm_get_wakeup_count(unsigned int *count, bool block); 297extern bool pm_get_wakeup_count(unsigned int *count);
360extern bool pm_save_wakeup_count(unsigned int count); 298extern bool pm_save_wakeup_count(unsigned int count);
361extern void pm_wakep_autosleep_enabled(bool set);
362
363static inline void lock_system_sleep(void)
364{
365 current->flags |= PF_FREEZER_SKIP;
366 mutex_lock(&pm_mutex);
367}
368
369static inline void unlock_system_sleep(void)
370{
371 /*
372 * Don't use freezer_count() because we don't want the call to
373 * try_to_freeze() here.
374 *
375 * Reason:
376 * Fundamentally, we just don't need it, because freezing condition
377 * doesn't come into effect until we release the pm_mutex lock,
378 * since the freezer always works with pm_mutex held.
379 *
380 * More importantly, in the case of hibernation,
381 * unlock_system_sleep() gets called in snapshot_read() and
382 * snapshot_write() when the freezing condition is still in effect.
383 * Which means, if we use try_to_freeze() here, it would make them
384 * enter the refrigerator, thus causing hibernation to lockup.
385 */
386 current->flags &= ~PF_FREEZER_SKIP;
387 mutex_unlock(&pm_mutex);
388}
389
390#else /* !CONFIG_PM_SLEEP */ 299#else /* !CONFIG_PM_SLEEP */
391 300
392static inline int register_pm_notifier(struct notifier_block *nb) 301static inline int register_pm_notifier(struct notifier_block *nb)
@@ -402,61 +311,27 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
402#define pm_notifier(fn, pri) do { (void)(fn); } while (0) 311#define pm_notifier(fn, pri) do { (void)(fn); } while (0)
403 312
404static inline bool pm_wakeup_pending(void) { return false; } 313static inline bool pm_wakeup_pending(void) { return false; }
314#endif /* !CONFIG_PM_SLEEP */
315
316extern struct mutex pm_mutex;
405 317
318#ifndef CONFIG_HIBERNATE_CALLBACKS
406static inline void lock_system_sleep(void) {} 319static inline void lock_system_sleep(void) {}
407static inline void unlock_system_sleep(void) {} 320static inline void unlock_system_sleep(void) {}
408 321
409#endif /* !CONFIG_PM_SLEEP */
410
411#ifdef CONFIG_PM_SLEEP_DEBUG
412extern bool pm_print_times_enabled;
413#else 322#else
414#define pm_print_times_enabled (false)
415#endif
416
417#ifdef CONFIG_PM_AUTOSLEEP
418
419/* kernel/power/autosleep.c */
420void queue_up_suspend_work(void);
421
422#else /* !CONFIG_PM_AUTOSLEEP */
423 323
424static inline void queue_up_suspend_work(void) {} 324/* Let some subsystems like memory hotadd exclude hibernation */
425 325
426#endif /* !CONFIG_PM_AUTOSLEEP */ 326static inline void lock_system_sleep(void)
427
428#ifdef CONFIG_ARCH_SAVE_PAGE_KEYS
429/*
430 * The ARCH_SAVE_PAGE_KEYS functions can be used by an architecture
431 * to save/restore additional information to/from the array of page
432 * frame numbers in the hibernation image. For s390 this is used to
433 * save and restore the storage key for each page that is included
434 * in the hibernation image.
435 */
436unsigned long page_key_additional_pages(unsigned long pages);
437int page_key_alloc(unsigned long pages);
438void page_key_free(void);
439void page_key_read(unsigned long *pfn);
440void page_key_memorize(unsigned long *pfn);
441void page_key_write(void *address);
442
443#else /* !CONFIG_ARCH_SAVE_PAGE_KEYS */
444
445static inline unsigned long page_key_additional_pages(unsigned long pages)
446{ 327{
447 return 0; 328 mutex_lock(&pm_mutex);
448} 329}
449 330
450static inline int page_key_alloc(unsigned long pages) 331static inline void unlock_system_sleep(void)
451{ 332{
452 return 0; 333 mutex_unlock(&pm_mutex);
453} 334}
454 335#endif
455static inline void page_key_free(void) {}
456static inline void page_key_read(unsigned long *pfn) {}
457static inline void page_key_memorize(unsigned long *pfn) {}
458static inline void page_key_write(void *address) {}
459
460#endif /* !CONFIG_ARCH_SAVE_PAGE_KEYS */
461 336
462#endif /* _LINUX_SUSPEND_H */ 337#endif /* _LINUX_SUSPEND_H */