xref: /linux/kernel/power/power.h (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds #include <linux/suspend.h>
33010f8caSRafael J. Wysocki #include <linux/suspend_ioctls.h>
41da177e4SLinus Torvalds #include <linux/utsname.h>
5b28f5081SJohannes Berg #include <linux/freezer.h>
652f5684cSGideon Israel Dsouza #include <linux/compiler.h>
723f62d7aSRafael J. Wysocki #include <linux/cpu.h>
823f62d7aSRafael J. Wysocki #include <linux/cpuidle.h>
9a06c6f5dSNikhil V #include <linux/crypto.h>
101da177e4SLinus Torvalds 
111da177e4SLinus Torvalds struct swsusp_info {
121da177e4SLinus Torvalds 	struct new_utsname	uts;
131da177e4SLinus Torvalds 	u32			version_code;
141da177e4SLinus Torvalds 	unsigned long		num_physpages;
151da177e4SLinus Torvalds 	int			cpus;
161da177e4SLinus Torvalds 	unsigned long		image_pages;
177088a5c0SRafael J. Wysocki 	unsigned long		pages;
186e1819d6SRafael J. Wysocki 	unsigned long		size;
1952f5684cSGideon Israel Dsouza } __aligned(PAGE_SIZE);
201da177e4SLinus Torvalds 
21b0cb1a19SRafael J. Wysocki #ifdef CONFIG_HIBERNATION
22ac5c24ecSRafael J. Wysocki /* kernel/power/snapshot.c */
23ddeb6487SRafael J. Wysocki extern void __init hibernate_reserved_size_init(void);
24ac5c24ecSRafael J. Wysocki extern void __init hibernate_image_size_init(void);
25ac5c24ecSRafael J. Wysocki 
26d307c4a8SRafael J. Wysocki #ifdef CONFIG_ARCH_HIBERNATION_HEADER
27d307c4a8SRafael J. Wysocki /* Maximum size of architecture specific data in a hibernation header */
28d307c4a8SRafael J. Wysocki #define MAX_ARCH_HEADER_SIZE	(sizeof(struct new_utsname) + 4)
29d307c4a8SRafael J. Wysocki 
init_header_complete(struct swsusp_info * info)30d307c4a8SRafael J. Wysocki static inline int init_header_complete(struct swsusp_info *info)
31d307c4a8SRafael J. Wysocki {
32d307c4a8SRafael J. Wysocki 	return arch_hibernation_header_save(info, MAX_ARCH_HEADER_SIZE);
33d307c4a8SRafael J. Wysocki }
34d307c4a8SRafael J. Wysocki 
check_image_kernel(struct swsusp_info * info)3502d7f400SAlexey Dobriyan static inline const char *check_image_kernel(struct swsusp_info *info)
36d307c4a8SRafael J. Wysocki {
37d307c4a8SRafael J. Wysocki 	return arch_hibernation_header_restore(info) ?
38d307c4a8SRafael J. Wysocki 			"architecture specific data" : NULL;
39d307c4a8SRafael J. Wysocki }
40d307c4a8SRafael J. Wysocki #endif /* CONFIG_ARCH_HIBERNATION_HEADER */
41d307c4a8SRafael J. Wysocki 
4256f99bcbSRafael J. Wysocki /*
4356f99bcbSRafael J. Wysocki  * Keep some memory free so that I/O operations can succeed without paging
4456f99bcbSRafael J. Wysocki  * [Might this be more than 4 MB?]
4556f99bcbSRafael J. Wysocki  */
4656f99bcbSRafael J. Wysocki #define PAGES_FOR_IO	((4096 * 1024) >> PAGE_SHIFT)
47d307c4a8SRafael J. Wysocki 
4856f99bcbSRafael J. Wysocki /*
4956f99bcbSRafael J. Wysocki  * Keep 1 MB of memory free so that device drivers can allocate some pages in
5056f99bcbSRafael J. Wysocki  * their .suspend() routines without breaking the suspend to disk.
5156f99bcbSRafael J. Wysocki  */
5256f99bcbSRafael J. Wysocki #define SPARE_PAGES	((1024 * 1024) >> PAGE_SHIFT)
531da177e4SLinus Torvalds 
5404b73469SRashika Kheria asmlinkage int swsusp_save(void);
5504b73469SRashika Kheria 
568b759b84SRafael J. Wysocki /* kernel/power/hibernate.c */
5797819a26SSrivatsa S. Bhat extern bool freezer_test_done;
58a06c6f5dSNikhil V extern char hib_comp_algo[CRYPTO_MAX_ALG_NAME];
59a06c6f5dSNikhil V 
60a06c6f5dSNikhil V /* kernel/power/swap.c */
61a06c6f5dSNikhil V extern unsigned int swsusp_header_flags;
6297819a26SSrivatsa S. Bhat 
637777fab9SRafael J. Wysocki extern int hibernation_snapshot(int platform_mode);
64a634cc10SRafael J. Wysocki extern int hibernation_restore(int platform_mode);
657777fab9SRafael J. Wysocki extern int hibernation_platform_enter(void);
66ac5c24ecSRafael J. Wysocki 
670f5bf6d0SLaura Abbott #ifdef CONFIG_STRICT_KERNEL_RWX
684c0b6c10SRafael J. Wysocki /* kernel/power/snapshot.c */
694c0b6c10SRafael J. Wysocki extern void enable_restore_image_protection(void);
704c0b6c10SRafael J. Wysocki #else
enable_restore_image_protection(void)714c0b6c10SRafael J. Wysocki static inline void enable_restore_image_protection(void) {}
720f5bf6d0SLaura Abbott #endif /* CONFIG_STRICT_KERNEL_RWX */
734c0b6c10SRafael J. Wysocki 
74ac5c24ecSRafael J. Wysocki #else /* !CONFIG_HIBERNATION */
75ac5c24ecSRafael J. Wysocki 
hibernate_reserved_size_init(void)76ddeb6487SRafael J. Wysocki static inline void hibernate_reserved_size_init(void) {}
hibernate_image_size_init(void)77ac5c24ecSRafael J. Wysocki static inline void hibernate_image_size_init(void) {}
78ac5c24ecSRafael J. Wysocki #endif /* !CONFIG_HIBERNATION */
79a6d70980SStephen Hemminger 
801da177e4SLinus Torvalds #define power_attr(_name) \
81386f275fSKay Sievers static struct kobj_attribute _name##_attr = {	\
821da177e4SLinus Torvalds 	.attr	= {				\
831da177e4SLinus Torvalds 		.name = __stringify(_name),	\
841da177e4SLinus Torvalds 		.mode = 0644,			\
851da177e4SLinus Torvalds 	},					\
861da177e4SLinus Torvalds 	.show	= _name##_show,			\
871da177e4SLinus Torvalds 	.store	= _name##_store,		\
881da177e4SLinus Torvalds }
891da177e4SLinus Torvalds 
90a1e9ca69SRafael J. Wysocki #define power_attr_ro(_name) \
91a1e9ca69SRafael J. Wysocki static struct kobj_attribute _name##_attr = {	\
92a1e9ca69SRafael J. Wysocki 	.attr	= {				\
93a1e9ca69SRafael J. Wysocki 		.name = __stringify(_name),	\
94a1e9ca69SRafael J. Wysocki 		.mode = S_IRUGO,		\
95a1e9ca69SRafael J. Wysocki 	},					\
96a1e9ca69SRafael J. Wysocki 	.show	= _name##_show,			\
97a1e9ca69SRafael J. Wysocki }
98a1e9ca69SRafael J. Wysocki 
99853609b6SRafael J. Wysocki /* Preferred image size in bytes (default 500 MB) */
100853609b6SRafael J. Wysocki extern unsigned long image_size;
101ddeb6487SRafael J. Wysocki /* Size of memory reserved for drivers (default SPARE_PAGES x PAGE_SIZE) */
102ddeb6487SRafael J. Wysocki extern unsigned long reserved_size;
103f577eb30SRafael J. Wysocki extern int in_suspend;
10461159a31SRafael J. Wysocki extern dev_t swsusp_resume_device;
1059a154d9dSRafael J. Wysocki extern sector_t swsusp_resume_block;
106f577eb30SRafael J. Wysocki 
10774dfd666SRafael J. Wysocki extern int create_basic_memory_bitmaps(void);
10874dfd666SRafael J. Wysocki extern void free_basic_memory_bitmaps(void);
10964a473cbSRafael J. Wysocki extern int hibernate_preallocate_memory(void);
110f577eb30SRafael J. Wysocki 
11103b6c9a3SVlastimil Babka extern void clear_or_poison_free_pages(void);
1121ad1410fSAnisse Astier 
113fb13a28bSRafael J. Wysocki /**
114fb13a28bSRafael J. Wysocki  *	Auxiliary structure used for reading the snapshot image data and
115fb13a28bSRafael J. Wysocki  *	metadata from and writing them to the list of page backup entries
116fb13a28bSRafael J. Wysocki  *	(PBEs) which is the main data structure of swsusp.
117fb13a28bSRafael J. Wysocki  *
118fb13a28bSRafael J. Wysocki  *	Using struct snapshot_handle we can transfer the image, including its
119fb13a28bSRafael J. Wysocki  *	metadata, as a continuous sequence of bytes with the help of
120fb13a28bSRafael J. Wysocki  *	snapshot_read_next() and snapshot_write_next().
121fb13a28bSRafael J. Wysocki  *
122fb13a28bSRafael J. Wysocki  *	The code that writes the image to a storage or transfers it to
123fb13a28bSRafael J. Wysocki  *	the user land is required to use snapshot_read_next() for this
124fb13a28bSRafael J. Wysocki  *	purpose and it should not make any assumptions regarding the internal
125fb13a28bSRafael J. Wysocki  *	structure of the image.  Similarly, the code that reads the image from
126fb13a28bSRafael J. Wysocki  *	a storage or transfers it from the user land is required to use
127fb13a28bSRafael J. Wysocki  *	snapshot_write_next().
128fb13a28bSRafael J. Wysocki  *
129fb13a28bSRafael J. Wysocki  *	This may allow us to change the internal structure of the image
130fb13a28bSRafael J. Wysocki  *	in the future with considerably less effort.
131fb13a28bSRafael J. Wysocki  */
132fb13a28bSRafael J. Wysocki 
133f577eb30SRafael J. Wysocki struct snapshot_handle {
134fb13a28bSRafael J. Wysocki 	unsigned int	cur;	/* number of the block of PAGE_SIZE bytes the
135fb13a28bSRafael J. Wysocki 				 * next operation will refer to (ie. current)
136fb13a28bSRafael J. Wysocki 				 */
137fb13a28bSRafael J. Wysocki 	void		*buffer;	/* address of the block to read from
138fb13a28bSRafael J. Wysocki 					 * or write to
139fb13a28bSRafael J. Wysocki 					 */
140fb13a28bSRafael J. Wysocki 	int		sync_read;	/* Set to one to notify the caller of
141fb13a28bSRafael J. Wysocki 					 * snapshot_write_next() that it may
142fb13a28bSRafael J. Wysocki 					 * need to call wait_on_bio_chain()
143fb13a28bSRafael J. Wysocki 					 */
144f577eb30SRafael J. Wysocki };
145f577eb30SRafael J. Wysocki 
146fb13a28bSRafael J. Wysocki /* This macro returns the address from/to which the caller of
147fb13a28bSRafael J. Wysocki  * snapshot_read_next()/snapshot_write_next() is allowed to
148fb13a28bSRafael J. Wysocki  * read/write data after the function returns
149fb13a28bSRafael J. Wysocki  */
150d3c1b24cSJiri Slaby #define data_of(handle)	((handle).buffer)
151f577eb30SRafael J. Wysocki 
152b788db79SRafael J. Wysocki extern unsigned int snapshot_additional_pages(struct zone *zone);
153af508b34SRafael J. Wysocki extern unsigned long snapshot_get_image_size(void);
154d3c1b24cSJiri Slaby extern int snapshot_read_next(struct snapshot_handle *handle);
155d3c1b24cSJiri Slaby extern int snapshot_write_next(struct snapshot_handle *handle);
156*f4311756SChristophe Leroy int snapshot_write_finalize(struct snapshot_handle *handle);
157b788db79SRafael J. Wysocki extern int snapshot_image_loaded(struct snapshot_handle *handle);
15861159a31SRafael J. Wysocki 
159ab7e9b06SDomenico Andreoli extern bool hibernate_acquire(void);
160ab7e9b06SDomenico Andreoli extern void hibernate_release(void);
1610709db60SRafael J. Wysocki 
162d1d241ccSRafael J. Wysocki extern sector_t alloc_swapdev_block(int swap);
163d1d241ccSRafael J. Wysocki extern void free_all_swap_pages(int swap);
164d1d241ccSRafael J. Wysocki extern int swsusp_swap_in_use(void);
16561159a31SRafael J. Wysocki 
166a634cc10SRafael J. Wysocki /*
167a634cc10SRafael J. Wysocki  * Flags that can be passed from the hibernatig hernel to the "boot" kernel in
168a634cc10SRafael J. Wysocki  * the image header.
169a634cc10SRafael J. Wysocki  */
1708bc29736SNikhil V #define SF_COMPRESSION_ALG_LZO	0 /* dummy, details given  below */
171a634cc10SRafael J. Wysocki #define SF_PLATFORM_MODE	1
172f996fc96SBojan Smojver #define SF_NOCOMPRESS_MODE	2
173081a9d04SBojan Smojver #define SF_CRC32_MODE	        4
17474d95555SDavid Woodhouse #define SF_HW_SIG		8
175a634cc10SRafael J. Wysocki 
1768bc29736SNikhil V /*
1778bc29736SNikhil V  * Bit to indicate the compression algorithm to be used(for LZ4). The same
1788bc29736SNikhil V  * could be checked while saving/loading image to/from disk to use the
1798bc29736SNikhil V  * corresponding algorithms.
1808bc29736SNikhil V  *
1818bc29736SNikhil V  * By default, LZO compression is enabled if SF_CRC32_MODE is set. Use
1828bc29736SNikhil V  * SF_COMPRESSION_ALG_LZ4 to override this behaviour and use LZ4.
1838bc29736SNikhil V  *
1848bc29736SNikhil V  * SF_CRC32_MODE, SF_COMPRESSION_ALG_LZO(dummy) -> Compression, LZO
1858bc29736SNikhil V  * SF_CRC32_MODE, SF_COMPRESSION_ALG_LZ4 -> Compression, LZ4
1868bc29736SNikhil V  */
1878bc29736SNikhil V #define SF_COMPRESSION_ALG_LZ4	16
1888bc29736SNikhil V 
1898b759b84SRafael J. Wysocki /* kernel/power/hibernate.c */
19040d84e19SChen Yu int swsusp_check(bool exclusive);
19174c7e2efSRandy Dunlap extern void swsusp_free(void);
192a634cc10SRafael J. Wysocki extern int swsusp_read(unsigned int *flags_p);
193a634cc10SRafael J. Wysocki extern int swsusp_write(unsigned int flags);
19493745df1SJan Kara void swsusp_close(void);
19562c552ccSBojan Smojver #ifdef CONFIG_SUSPEND
19662c552ccSBojan Smojver extern int swsusp_unmark(void);
1970c4cae1bSChris Feng #else
swsusp_unmark(void)1980c4cae1bSChris Feng static inline int swsusp_unmark(void) { return 0; }
19962c552ccSBojan Smojver #endif
2000d3a9abeSRafael J. Wysocki 
20175d319c0SArnd Bergmann struct __kernel_old_timeval;
202b10d9117SRafael J. Wysocki /* kernel/power/swsusp.c */
203db597605STina Ruchandani extern void swsusp_show_speed(ktime_t, ktime_t, unsigned int, char *);
204b10d9117SRafael J. Wysocki 
205296699deSRafael J. Wysocki #ifdef CONFIG_SUSPEND
206a9d70523SRafael J. Wysocki /* kernel/power/suspend.c */
207406e7938SRafael J. Wysocki extern const char * const pm_labels[];
208d431cbc5SRafael J. Wysocki extern const char *pm_states[];
209406e7938SRafael J. Wysocki extern const char *mem_sleep_states[];
210a9d70523SRafael J. Wysocki 
2116c961dfbSRafael J. Wysocki extern int suspend_devices_and_enter(suspend_state_t state);
212296699deSRafael J. Wysocki #else /* !CONFIG_SUSPEND */
213406e7938SRafael J. Wysocki #define mem_sleep_current	PM_SUSPEND_ON
214406e7938SRafael J. Wysocki 
suspend_devices_and_enter(suspend_state_t state)215296699deSRafael J. Wysocki static inline int suspend_devices_and_enter(suspend_state_t state)
216296699deSRafael J. Wysocki {
217296699deSRafael J. Wysocki 	return -ENOSYS;
218296699deSRafael J. Wysocki }
219296699deSRafael J. Wysocki #endif /* !CONFIG_SUSPEND */
220296699deSRafael J. Wysocki 
221a9d70523SRafael J. Wysocki #ifdef CONFIG_PM_TEST_SUSPEND
222a9d70523SRafael J. Wysocki /* kernel/power/suspend_test.c */
223a9d70523SRafael J. Wysocki extern void suspend_test_start(void);
224a9d70523SRafael J. Wysocki extern void suspend_test_finish(const char *label);
225a9d70523SRafael J. Wysocki #else /* !CONFIG_PM_TEST_SUSPEND */
suspend_test_start(void)226a9d70523SRafael J. Wysocki static inline void suspend_test_start(void) {}
suspend_test_finish(const char * label)227a9d70523SRafael J. Wysocki static inline void suspend_test_finish(const char *label) {}
228a9d70523SRafael J. Wysocki #endif /* !CONFIG_PM_TEST_SUSPEND */
229a9d70523SRafael J. Wysocki 
23082525756SAlan Stern #ifdef CONFIG_PM_SLEEP
23182525756SAlan Stern /* kernel/power/main.c */
23270d93298SPeter Zijlstra extern int pm_notifier_call_chain_robust(unsigned long val_up, unsigned long val_down);
23382525756SAlan Stern extern int pm_notifier_call_chain(unsigned long val);
23407f44ac3SKefeng Wang void pm_restrict_gfp_mask(void);
23507f44ac3SKefeng Wang void pm_restore_gfp_mask(void);
23607f44ac3SKefeng Wang #else
pm_restrict_gfp_mask(void)23707f44ac3SKefeng Wang static inline void pm_restrict_gfp_mask(void) {}
pm_restore_gfp_mask(void)23807f44ac3SKefeng Wang static inline void pm_restore_gfp_mask(void) {}
23982525756SAlan Stern #endif
2402f8ed1c6SAdrian Bunk 
2412f8ed1c6SAdrian Bunk #ifdef CONFIG_HIGHMEM
2422f8ed1c6SAdrian Bunk int restore_highmem(void);
2432f8ed1c6SAdrian Bunk #else
count_highmem_pages(void)2442f8ed1c6SAdrian Bunk static inline unsigned int count_highmem_pages(void) { return 0; }
restore_highmem(void)2452f8ed1c6SAdrian Bunk static inline int restore_highmem(void) { return 0; }
2462f8ed1c6SAdrian Bunk #endif
2470e7d56e3SRafael J. Wysocki 
2480e7d56e3SRafael J. Wysocki /*
2490e7d56e3SRafael J. Wysocki  * Suspend test levels
2500e7d56e3SRafael J. Wysocki  */
2510e7d56e3SRafael J. Wysocki enum {
2520e7d56e3SRafael J. Wysocki 	/* keep first */
2530e7d56e3SRafael J. Wysocki 	TEST_NONE,
2540e7d56e3SRafael J. Wysocki 	TEST_CORE,
2550e7d56e3SRafael J. Wysocki 	TEST_CPUS,
2560e7d56e3SRafael J. Wysocki 	TEST_PLATFORM,
2570e7d56e3SRafael J. Wysocki 	TEST_DEVICES,
2580e7d56e3SRafael J. Wysocki 	TEST_FREEZER,
2590e7d56e3SRafael J. Wysocki 	/* keep last */
2600e7d56e3SRafael J. Wysocki 	__TEST_AFTER_LAST
2610e7d56e3SRafael J. Wysocki };
2620e7d56e3SRafael J. Wysocki 
2630e7d56e3SRafael J. Wysocki #define TEST_FIRST	TEST_NONE
2640e7d56e3SRafael J. Wysocki #define TEST_MAX	(__TEST_AFTER_LAST - 1)
2654cc79776SRafael J. Wysocki 
266e516a1dbSRafael J. Wysocki #ifdef CONFIG_PM_SLEEP_DEBUG
2674cc79776SRafael J. Wysocki extern int pm_test_level;
2688e6bcd9fSRafael J. Wysocki #else
2698e6bcd9fSRafael J. Wysocki #define pm_test_level	(TEST_NONE)
2708e6bcd9fSRafael J. Wysocki #endif
271b28f5081SJohannes Berg 
272b28f5081SJohannes Berg #ifdef CONFIG_SUSPEND_FREEZER
suspend_freeze_processes(void)273b28f5081SJohannes Berg static inline int suspend_freeze_processes(void)
274b28f5081SJohannes Berg {
275379e0be8SSrivatsa S. Bhat 	int error;
276379e0be8SSrivatsa S. Bhat 
277379e0be8SSrivatsa S. Bhat 	error = freeze_processes();
278379e0be8SSrivatsa S. Bhat 	/*
279379e0be8SSrivatsa S. Bhat 	 * freeze_processes() automatically thaws every task if freezing
280379e0be8SSrivatsa S. Bhat 	 * fails. So we need not do anything extra upon error.
281379e0be8SSrivatsa S. Bhat 	 */
282379e0be8SSrivatsa S. Bhat 	if (error)
2836f585f75SRafael J. Wysocki 		return error;
284379e0be8SSrivatsa S. Bhat 
285379e0be8SSrivatsa S. Bhat 	error = freeze_kernel_threads();
286379e0be8SSrivatsa S. Bhat 	/*
287379e0be8SSrivatsa S. Bhat 	 * freeze_kernel_threads() thaws only kernel threads upon freezing
288379e0be8SSrivatsa S. Bhat 	 * failure. So we have to thaw the userspace tasks ourselves.
289379e0be8SSrivatsa S. Bhat 	 */
290379e0be8SSrivatsa S. Bhat 	if (error)
291379e0be8SSrivatsa S. Bhat 		thaw_processes();
292379e0be8SSrivatsa S. Bhat 
293379e0be8SSrivatsa S. Bhat 	return error;
294b28f5081SJohannes Berg }
295b28f5081SJohannes Berg 
suspend_thaw_processes(void)296b28f5081SJohannes Berg static inline void suspend_thaw_processes(void)
297b28f5081SJohannes Berg {
298b28f5081SJohannes Berg 	thaw_processes();
299b28f5081SJohannes Berg }
300b28f5081SJohannes Berg #else
suspend_freeze_processes(void)301b28f5081SJohannes Berg static inline int suspend_freeze_processes(void)
302b28f5081SJohannes Berg {
303b28f5081SJohannes Berg 	return 0;
304b28f5081SJohannes Berg }
305b28f5081SJohannes Berg 
suspend_thaw_processes(void)306b28f5081SJohannes Berg static inline void suspend_thaw_processes(void)
307b28f5081SJohannes Berg {
308b28f5081SJohannes Berg }
309b28f5081SJohannes Berg #endif
3107483b4a4SRafael J. Wysocki 
3117483b4a4SRafael J. Wysocki #ifdef CONFIG_PM_AUTOSLEEP
3127483b4a4SRafael J. Wysocki 
3137483b4a4SRafael J. Wysocki /* kernel/power/autosleep.c */
3147483b4a4SRafael J. Wysocki extern int pm_autosleep_init(void);
3157483b4a4SRafael J. Wysocki extern int pm_autosleep_lock(void);
3167483b4a4SRafael J. Wysocki extern void pm_autosleep_unlock(void);
3177483b4a4SRafael J. Wysocki extern suspend_state_t pm_autosleep_state(void);
3187483b4a4SRafael J. Wysocki extern int pm_autosleep_set_state(suspend_state_t state);
3197483b4a4SRafael J. Wysocki 
3207483b4a4SRafael J. Wysocki #else /* !CONFIG_PM_AUTOSLEEP */
3217483b4a4SRafael J. Wysocki 
pm_autosleep_init(void)3227483b4a4SRafael J. Wysocki static inline int pm_autosleep_init(void) { return 0; }
pm_autosleep_lock(void)3237483b4a4SRafael J. Wysocki static inline int pm_autosleep_lock(void) { return 0; }
pm_autosleep_unlock(void)3247483b4a4SRafael J. Wysocki static inline void pm_autosleep_unlock(void) {}
pm_autosleep_state(void)3257483b4a4SRafael J. Wysocki static inline suspend_state_t pm_autosleep_state(void) { return PM_SUSPEND_ON; }
3267483b4a4SRafael J. Wysocki 
3277483b4a4SRafael J. Wysocki #endif /* !CONFIG_PM_AUTOSLEEP */
328b86ff982SRafael J. Wysocki 
329b86ff982SRafael J. Wysocki #ifdef CONFIG_PM_WAKELOCKS
330b86ff982SRafael J. Wysocki 
331b86ff982SRafael J. Wysocki /* kernel/power/wakelock.c */
332b86ff982SRafael J. Wysocki extern ssize_t pm_show_wakelocks(char *buf, bool show_active);
333b86ff982SRafael J. Wysocki extern int pm_wake_lock(const char *buf);
334b86ff982SRafael J. Wysocki extern int pm_wake_unlock(const char *buf);
335b86ff982SRafael J. Wysocki 
336b86ff982SRafael J. Wysocki #endif /* !CONFIG_PM_WAKELOCKS */
33723f62d7aSRafael J. Wysocki 
pm_sleep_disable_secondary_cpus(void)33823f62d7aSRafael J. Wysocki static inline int pm_sleep_disable_secondary_cpus(void)
33923f62d7aSRafael J. Wysocki {
34023f62d7aSRafael J. Wysocki 	cpuidle_pause();
34123f62d7aSRafael J. Wysocki 	return suspend_disable_secondary_cpus();
34223f62d7aSRafael J. Wysocki }
34323f62d7aSRafael J. Wysocki 
pm_sleep_enable_secondary_cpus(void)34423f62d7aSRafael J. Wysocki static inline void pm_sleep_enable_secondary_cpus(void)
34523f62d7aSRafael J. Wysocki {
34623f62d7aSRafael J. Wysocki 	suspend_enable_secondary_cpus();
34723f62d7aSRafael J. Wysocki 	cpuidle_resume();
34823f62d7aSRafael J. Wysocki }
3499ff544faSRafael J. Wysocki 
3509ff544faSRafael J. Wysocki void dpm_save_errno(int err);
351