aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/suspend.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/suspend.h')
-rw-r--r--include/linux/suspend.h95
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
12extern 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);
15#else 13#else
16static inline void pm_set_vt_switch(int do_switch) 14static inline void pm_set_vt_switch(int do_switch)
17{ 15{
18} 16}
17#endif
19 18
19#ifdef CONFIG_VT_CONSOLE_SLEEP
20extern int pm_prepare_console(void);
21extern void pm_restore_console(void);
22#else
20static inline int pm_prepare_console(void) 23static 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
40enum 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
49struct 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
67extern struct suspend_stats suspend_stats;
68
69static 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
78static 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
85static 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 */
400unsigned long page_key_additional_pages(unsigned long pages);
401int page_key_alloc(unsigned long pages);
402void page_key_free(void);
403void page_key_read(unsigned long *pfn);
404void page_key_memorize(unsigned long *pfn);
405void page_key_write(void *address);
406
407#else /* !CONFIG_ARCH_SAVE_PAGE_KEYS */
408
409static inline unsigned long page_key_additional_pages(unsigned long pages)
410{
411 return 0;
412}
413
414static inline int page_key_alloc(unsigned long pages)
415{
416 return 0;
417}
418
419static inline void page_key_free(void) {}
420static inline void page_key_read(unsigned long *pfn) {}
421static inline void page_key_memorize(unsigned long *pfn) {}
422static 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 */