diff options
Diffstat (limited to 'include/linux/suspend.h')
| -rw-r--r-- | include/linux/suspend.h | 95 |
1 files changed, 92 insertions, 3 deletions
diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 6bbcef22e105..57a692432f8a 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h | |||
| @@ -8,15 +8,18 @@ | |||
| 8 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
| 9 | #include <asm/errno.h> | 9 | #include <asm/errno.h> |
| 10 | 10 | ||
| 11 | #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE) | 11 | #ifdef CONFIG_VT |
| 12 | extern void pm_set_vt_switch(int); | 12 | extern void pm_set_vt_switch(int); |
| 13 | extern int pm_prepare_console(void); | ||
| 14 | extern void pm_restore_console(void); | ||
| 15 | #else | 13 | #else |
| 16 | static inline void pm_set_vt_switch(int do_switch) | 14 | static inline void pm_set_vt_switch(int do_switch) |
| 17 | { | 15 | { |
| 18 | } | 16 | } |
| 17 | #endif | ||
| 19 | 18 | ||
| 19 | #ifdef CONFIG_VT_CONSOLE_SLEEP | ||
| 20 | extern int pm_prepare_console(void); | ||
| 21 | extern void pm_restore_console(void); | ||
| 22 | #else | ||
| 20 | static inline int pm_prepare_console(void) | 23 | static inline int pm_prepare_console(void) |
| 21 | { | 24 | { |
| 22 | return 0; | 25 | return 0; |
| @@ -34,6 +37,58 @@ typedef int __bitwise suspend_state_t; | |||
| 34 | #define PM_SUSPEND_MEM ((__force suspend_state_t) 3) | 37 | #define PM_SUSPEND_MEM ((__force suspend_state_t) 3) |
| 35 | #define PM_SUSPEND_MAX ((__force suspend_state_t) 4) | 38 | #define PM_SUSPEND_MAX ((__force suspend_state_t) 4) |
| 36 | 39 | ||
| 40 | enum suspend_stat_step { | ||
| 41 | SUSPEND_FREEZE = 1, | ||
| 42 | SUSPEND_PREPARE, | ||
| 43 | SUSPEND_SUSPEND, | ||
| 44 | SUSPEND_SUSPEND_NOIRQ, | ||
| 45 | SUSPEND_RESUME_NOIRQ, | ||
| 46 | SUSPEND_RESUME | ||
| 47 | }; | ||
| 48 | |||
| 49 | struct suspend_stats { | ||
| 50 | int success; | ||
| 51 | int fail; | ||
| 52 | int failed_freeze; | ||
| 53 | int failed_prepare; | ||
| 54 | int failed_suspend; | ||
| 55 | int failed_suspend_noirq; | ||
| 56 | int failed_resume; | ||
| 57 | int failed_resume_noirq; | ||
| 58 | #define REC_FAILED_NUM 2 | ||
| 59 | int last_failed_dev; | ||
| 60 | char failed_devs[REC_FAILED_NUM][40]; | ||
| 61 | int last_failed_errno; | ||
| 62 | int errno[REC_FAILED_NUM]; | ||
| 63 | int last_failed_step; | ||
| 64 | enum suspend_stat_step failed_steps[REC_FAILED_NUM]; | ||
| 65 | }; | ||
| 66 | |||
| 67 | extern struct suspend_stats suspend_stats; | ||
| 68 | |||
| 69 | static inline void dpm_save_failed_dev(const char *name) | ||
| 70 | { | ||
| 71 | strlcpy(suspend_stats.failed_devs[suspend_stats.last_failed_dev], | ||
| 72 | name, | ||
| 73 | sizeof(suspend_stats.failed_devs[0])); | ||
| 74 | suspend_stats.last_failed_dev++; | ||
| 75 | suspend_stats.last_failed_dev %= REC_FAILED_NUM; | ||
| 76 | } | ||
| 77 | |||
| 78 | static inline void dpm_save_failed_errno(int err) | ||
| 79 | { | ||
| 80 | suspend_stats.errno[suspend_stats.last_failed_errno] = err; | ||
| 81 | suspend_stats.last_failed_errno++; | ||
| 82 | suspend_stats.last_failed_errno %= REC_FAILED_NUM; | ||
| 83 | } | ||
| 84 | |||
| 85 | static inline void dpm_save_failed_step(enum suspend_stat_step step) | ||
| 86 | { | ||
| 87 | suspend_stats.failed_steps[suspend_stats.last_failed_step] = step; | ||
| 88 | suspend_stats.last_failed_step++; | ||
| 89 | suspend_stats.last_failed_step %= REC_FAILED_NUM; | ||
| 90 | } | ||
| 91 | |||
| 37 | /** | 92 | /** |
| 38 | * struct platform_suspend_ops - Callbacks for managing platform dependent | 93 | * struct platform_suspend_ops - Callbacks for managing platform dependent |
| 39 | * system sleep states. | 94 | * system sleep states. |
| @@ -334,4 +389,38 @@ static inline void unlock_system_sleep(void) | |||
| 334 | } | 389 | } |
| 335 | #endif | 390 | #endif |
| 336 | 391 | ||
| 392 | #ifdef CONFIG_ARCH_SAVE_PAGE_KEYS | ||
| 393 | /* | ||
| 394 | * The ARCH_SAVE_PAGE_KEYS functions can be used by an architecture | ||
| 395 | * to save/restore additional information to/from the array of page | ||
| 396 | * frame numbers in the hibernation image. For s390 this is used to | ||
| 397 | * save and restore the storage key for each page that is included | ||
| 398 | * in the hibernation image. | ||
| 399 | */ | ||
| 400 | unsigned long page_key_additional_pages(unsigned long pages); | ||
| 401 | int page_key_alloc(unsigned long pages); | ||
| 402 | void page_key_free(void); | ||
| 403 | void page_key_read(unsigned long *pfn); | ||
| 404 | void page_key_memorize(unsigned long *pfn); | ||
| 405 | void page_key_write(void *address); | ||
| 406 | |||
| 407 | #else /* !CONFIG_ARCH_SAVE_PAGE_KEYS */ | ||
| 408 | |||
| 409 | static inline unsigned long page_key_additional_pages(unsigned long pages) | ||
| 410 | { | ||
| 411 | return 0; | ||
| 412 | } | ||
| 413 | |||
| 414 | static inline int page_key_alloc(unsigned long pages) | ||
| 415 | { | ||
| 416 | return 0; | ||
| 417 | } | ||
| 418 | |||
| 419 | static inline void page_key_free(void) {} | ||
| 420 | static inline void page_key_read(unsigned long *pfn) {} | ||
| 421 | static inline void page_key_memorize(unsigned long *pfn) {} | ||
| 422 | static inline void page_key_write(void *address) {} | ||
| 423 | |||
| 424 | #endif /* !CONFIG_ARCH_SAVE_PAGE_KEYS */ | ||
| 425 | |||
| 337 | #endif /* _LINUX_SUSPEND_H */ | 426 | #endif /* _LINUX_SUSPEND_H */ |
