xref: /linux-6.15/include/linux/suspend.h (revision bc88528c)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_SUSPEND_H
3 #define _LINUX_SUSPEND_H
4 
5 #include <linux/swap.h>
6 #include <linux/notifier.h>
7 #include <linux/init.h>
8 #include <linux/pm.h>
9 #include <linux/mm.h>
10 #include <linux/freezer.h>
11 #include <asm/errno.h>
12 
13 #ifdef CONFIG_VT
14 extern void pm_set_vt_switch(int);
15 #else
16 static inline void pm_set_vt_switch(int do_switch)
17 {
18 }
19 #endif
20 
21 #ifdef CONFIG_VT_CONSOLE_SLEEP
22 extern void pm_prepare_console(void);
23 extern void pm_restore_console(void);
24 #else
25 static inline void pm_prepare_console(void)
26 {
27 }
28 
29 static inline void pm_restore_console(void)
30 {
31 }
32 #endif
33 
34 typedef int __bitwise suspend_state_t;
35 
36 #define PM_SUSPEND_ON		((__force suspend_state_t) 0)
37 #define PM_SUSPEND_TO_IDLE	((__force suspend_state_t) 1)
38 #define PM_SUSPEND_STANDBY	((__force suspend_state_t) 2)
39 #define PM_SUSPEND_MEM		((__force suspend_state_t) 3)
40 #define PM_SUSPEND_MIN		PM_SUSPEND_TO_IDLE
41 #define PM_SUSPEND_MAX		((__force suspend_state_t) 4)
42 
43 enum suspend_stat_step {
44 	SUSPEND_WORKING = 0,
45 	SUSPEND_FREEZE,
46 	SUSPEND_PREPARE,
47 	SUSPEND_SUSPEND,
48 	SUSPEND_SUSPEND_LATE,
49 	SUSPEND_SUSPEND_NOIRQ,
50 	SUSPEND_RESUME_NOIRQ,
51 	SUSPEND_RESUME_EARLY,
52 	SUSPEND_RESUME
53 };
54 
55 struct suspend_stats {
56 	int	success;
57 	int	fail;
58 	int	failed_freeze;
59 	int	failed_prepare;
60 	int	failed_suspend;
61 	int	failed_suspend_late;
62 	int	failed_suspend_noirq;
63 	int	failed_resume;
64 	int	failed_resume_early;
65 	int	failed_resume_noirq;
66 #define	REC_FAILED_NUM	2
67 	int	last_failed_dev;
68 	char	failed_devs[REC_FAILED_NUM][40];
69 	int	last_failed_errno;
70 	int	errno[REC_FAILED_NUM];
71 	int	last_failed_step;
72 	u64	last_hw_sleep;
73 	u64	total_hw_sleep;
74 	u64	max_hw_sleep;
75 	enum suspend_stat_step	failed_steps[REC_FAILED_NUM];
76 };
77 
78 extern struct suspend_stats suspend_stats;
79 
80 static inline void dpm_save_failed_dev(const char *name)
81 {
82 	strscpy(suspend_stats.failed_devs[suspend_stats.last_failed_dev],
83 		name,
84 		sizeof(suspend_stats.failed_devs[0]));
85 	suspend_stats.last_failed_dev++;
86 	suspend_stats.last_failed_dev %= REC_FAILED_NUM;
87 }
88 
89 static inline void dpm_save_failed_errno(int err)
90 {
91 	suspend_stats.errno[suspend_stats.last_failed_errno] = err;
92 	suspend_stats.last_failed_errno++;
93 	suspend_stats.last_failed_errno %= REC_FAILED_NUM;
94 }
95 
96 static inline void dpm_save_failed_step(enum suspend_stat_step step)
97 {
98 	suspend_stats.failed_steps[suspend_stats.last_failed_step] = step;
99 	suspend_stats.last_failed_step++;
100 	suspend_stats.last_failed_step %= REC_FAILED_NUM;
101 }
102 
103 /**
104  * struct platform_suspend_ops - Callbacks for managing platform dependent
105  *	system sleep states.
106  *
107  * @valid: Callback to determine if given system sleep state is supported by
108  *	the platform.
109  *	Valid (ie. supported) states are advertised in /sys/power/state.  Note
110  *	that it still may be impossible to enter given system sleep state if the
111  *	conditions aren't right.
112  *	There is the %suspend_valid_only_mem function available that can be
113  *	assigned to this if the platform only supports mem sleep.
114  *
115  * @begin: Initialise a transition to given system sleep state.
116  *	@begin() is executed right prior to suspending devices.  The information
117  *	conveyed to the platform code by @begin() should be disregarded by it as
118  *	soon as @end() is executed.  If @begin() fails (ie. returns nonzero),
119  *	@prepare(), @enter() and @finish() will not be called by the PM core.
120  *	This callback is optional.  However, if it is implemented, the argument
121  *	passed to @enter() is redundant and should be ignored.
122  *
123  * @prepare: Prepare the platform for entering the system sleep state indicated
124  *	by @begin().
125  *	@prepare() is called right after devices have been suspended (ie. the
126  *	appropriate .suspend() method has been executed for each device) and
127  *	before device drivers' late suspend callbacks are executed.  It returns
128  *	0 on success or a negative error code otherwise, in which case the
129  *	system cannot enter the desired sleep state (@prepare_late(), @enter(),
130  *	and @wake() will not be called in that case).
131  *
132  * @prepare_late: Finish preparing the platform for entering the system sleep
133  *	state indicated by @begin().
134  *	@prepare_late is called before disabling nonboot CPUs and after
135  *	device drivers' late suspend callbacks have been executed.  It returns
136  *	0 on success or a negative error code otherwise, in which case the
137  *	system cannot enter the desired sleep state (@enter() will not be
138  *	executed).
139  *
140  * @enter: Enter the system sleep state indicated by @begin() or represented by
141  *	the argument if @begin() is not implemented.
142  *	This callback is mandatory.  It returns 0 on success or a negative
143  *	error code otherwise, in which case the system cannot enter the desired
144  *	sleep state.
145  *
146  * @wake: Called when the system has just left a sleep state, right after
147  *	the nonboot CPUs have been enabled and before device drivers' early
148  *	resume callbacks are executed.
149  *	This callback is optional, but should be implemented by the platforms
150  *	that implement @prepare_late().  If implemented, it is always called
151  *	after @prepare_late and @enter(), even if one of them fails.
152  *
153  * @finish: Finish wake-up of the platform.
154  *	@finish is called right prior to calling device drivers' regular suspend
155  *	callbacks.
156  *	This callback is optional, but should be implemented by the platforms
157  *	that implement @prepare().  If implemented, it is always called after
158  *	@enter() and @wake(), even if any of them fails.  It is executed after
159  *	a failing @prepare.
160  *
161  * @suspend_again: Returns whether the system should suspend again (true) or
162  *	not (false). If the platform wants to poll sensors or execute some
163  *	code during suspended without invoking userspace and most of devices,
164  *	suspend_again callback is the place assuming that periodic-wakeup or
165  *	alarm-wakeup is already setup. This allows to execute some codes while
166  *	being kept suspended in the view of userland and devices.
167  *
168  * @end: Called by the PM core right after resuming devices, to indicate to
169  *	the platform that the system has returned to the working state or
170  *	the transition to the sleep state has been aborted.
171  *	This callback is optional, but should be implemented by the platforms
172  *	that implement @begin().  Accordingly, platforms implementing @begin()
173  *	should also provide a @end() which cleans up transitions aborted before
174  *	@enter().
175  *
176  * @recover: Recover the platform from a suspend failure.
177  *	Called by the PM core if the suspending of devices fails.
178  *	This callback is optional and should only be implemented by platforms
179  *	which require special recovery actions in that situation.
180  */
181 struct platform_suspend_ops {
182 	int (*valid)(suspend_state_t state);
183 	int (*begin)(suspend_state_t state);
184 	int (*prepare)(void);
185 	int (*prepare_late)(void);
186 	int (*enter)(suspend_state_t state);
187 	void (*wake)(void);
188 	void (*finish)(void);
189 	bool (*suspend_again)(void);
190 	void (*end)(void);
191 	void (*recover)(void);
192 };
193 
194 struct platform_s2idle_ops {
195 	int (*begin)(void);
196 	int (*prepare)(void);
197 	int (*prepare_late)(void);
198 	void (*check)(void);
199 	bool (*wake)(void);
200 	void (*restore_early)(void);
201 	void (*restore)(void);
202 	void (*end)(void);
203 };
204 
205 #ifdef CONFIG_SUSPEND
206 extern suspend_state_t pm_suspend_target_state;
207 extern suspend_state_t mem_sleep_current;
208 extern suspend_state_t mem_sleep_default;
209 
210 /**
211  * suspend_set_ops - set platform dependent suspend operations
212  * @ops: The new suspend operations to set.
213  */
214 extern void suspend_set_ops(const struct platform_suspend_ops *ops);
215 extern int suspend_valid_only_mem(suspend_state_t state);
216 
217 extern unsigned int pm_suspend_global_flags;
218 
219 #define PM_SUSPEND_FLAG_FW_SUSPEND	BIT(0)
220 #define PM_SUSPEND_FLAG_FW_RESUME	BIT(1)
221 #define PM_SUSPEND_FLAG_NO_PLATFORM	BIT(2)
222 
223 static inline void pm_suspend_clear_flags(void)
224 {
225 	pm_suspend_global_flags = 0;
226 }
227 
228 static inline void pm_set_suspend_via_firmware(void)
229 {
230 	pm_suspend_global_flags |= PM_SUSPEND_FLAG_FW_SUSPEND;
231 }
232 
233 static inline void pm_set_resume_via_firmware(void)
234 {
235 	pm_suspend_global_flags |= PM_SUSPEND_FLAG_FW_RESUME;
236 }
237 
238 static inline void pm_set_suspend_no_platform(void)
239 {
240 	pm_suspend_global_flags |= PM_SUSPEND_FLAG_NO_PLATFORM;
241 }
242 
243 /**
244  * pm_suspend_via_firmware - Check if platform firmware will suspend the system.
245  *
246  * To be called during system-wide power management transitions to sleep states
247  * or during the subsequent system-wide transitions back to the working state.
248  *
249  * Return 'true' if the platform firmware is going to be invoked at the end of
250  * the system-wide power management transition (to a sleep state) in progress in
251  * order to complete it, or if the platform firmware has been invoked in order
252  * to complete the last (or preceding) transition of the system to a sleep
253  * state.
254  *
255  * This matters if the caller needs or wants to carry out some special actions
256  * depending on whether or not control will be passed to the platform firmware
257  * subsequently (for example, the device may need to be reset before letting the
258  * platform firmware manipulate it, which is not necessary when the platform
259  * firmware is not going to be invoked) or when such special actions may have
260  * been carried out during the preceding transition of the system to a sleep
261  * state (as they may need to be taken into account).
262  */
263 static inline bool pm_suspend_via_firmware(void)
264 {
265 	return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_FW_SUSPEND);
266 }
267 
268 /**
269  * pm_resume_via_firmware - Check if platform firmware has woken up the system.
270  *
271  * To be called during system-wide power management transitions from sleep
272  * states.
273  *
274  * Return 'true' if the platform firmware has passed control to the kernel at
275  * the beginning of the system-wide power management transition in progress, so
276  * the event that woke up the system from sleep has been handled by the platform
277  * firmware.
278  */
279 static inline bool pm_resume_via_firmware(void)
280 {
281 	return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_FW_RESUME);
282 }
283 
284 /**
285  * pm_suspend_no_platform - Check if platform may change device power states.
286  *
287  * To be called during system-wide power management transitions to sleep states
288  * or during the subsequent system-wide transitions back to the working state.
289  *
290  * Return 'true' if the power states of devices remain under full control of the
291  * kernel throughout the system-wide suspend and resume cycle in progress (that
292  * is, if a device is put into a certain power state during suspend, it can be
293  * expected to remain in that state during resume).
294  */
295 static inline bool pm_suspend_no_platform(void)
296 {
297 	return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_NO_PLATFORM);
298 }
299 
300 /* Suspend-to-idle state machnine. */
301 enum s2idle_states {
302 	S2IDLE_STATE_NONE,      /* Not suspended/suspending. */
303 	S2IDLE_STATE_ENTER,     /* Enter suspend-to-idle. */
304 	S2IDLE_STATE_WAKE,      /* Wake up from suspend-to-idle. */
305 };
306 
307 extern enum s2idle_states __read_mostly s2idle_state;
308 
309 static inline bool idle_should_enter_s2idle(void)
310 {
311 	return unlikely(s2idle_state == S2IDLE_STATE_ENTER);
312 }
313 
314 extern bool pm_suspend_default_s2idle(void);
315 extern void __init pm_states_init(void);
316 extern void s2idle_set_ops(const struct platform_s2idle_ops *ops);
317 extern void s2idle_wake(void);
318 
319 /**
320  * arch_suspend_disable_irqs - disable IRQs for suspend
321  *
322  * Disables IRQs (in the default case). This is a weak symbol in the common
323  * code and thus allows architectures to override it if more needs to be
324  * done. Not called for suspend to disk.
325  */
326 extern void arch_suspend_disable_irqs(void);
327 
328 /**
329  * arch_suspend_enable_irqs - enable IRQs after suspend
330  *
331  * Enables IRQs (in the default case). This is a weak symbol in the common
332  * code and thus allows architectures to override it if more needs to be
333  * done. Not called for suspend to disk.
334  */
335 extern void arch_suspend_enable_irqs(void);
336 
337 extern int pm_suspend(suspend_state_t state);
338 extern bool sync_on_suspend_enabled;
339 #else /* !CONFIG_SUSPEND */
340 #define suspend_valid_only_mem	NULL
341 
342 #define pm_suspend_target_state	(PM_SUSPEND_ON)
343 
344 static inline void pm_suspend_clear_flags(void) {}
345 static inline void pm_set_suspend_via_firmware(void) {}
346 static inline void pm_set_resume_via_firmware(void) {}
347 static inline bool pm_suspend_via_firmware(void) { return false; }
348 static inline bool pm_resume_via_firmware(void) { return false; }
349 static inline bool pm_suspend_no_platform(void) { return false; }
350 static inline bool pm_suspend_default_s2idle(void) { return false; }
351 
352 static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
353 static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
354 static inline bool sync_on_suspend_enabled(void) { return true; }
355 static inline bool idle_should_enter_s2idle(void) { return false; }
356 static inline void __init pm_states_init(void) {}
357 static inline void s2idle_set_ops(const struct platform_s2idle_ops *ops) {}
358 static inline void s2idle_wake(void) {}
359 #endif /* !CONFIG_SUSPEND */
360 
361 /* struct pbe is used for creating lists of pages that should be restored
362  * atomically during the resume from disk, because the page frames they have
363  * occupied before the suspend are in use.
364  */
365 struct pbe {
366 	void *address;		/* address of the copy */
367 	void *orig_address;	/* original address of a page */
368 	struct pbe *next;
369 };
370 
371 /**
372  * struct platform_hibernation_ops - hibernation platform support
373  *
374  * The methods in this structure allow a platform to carry out special
375  * operations required by it during a hibernation transition.
376  *
377  * All the methods below, except for @recover(), must be implemented.
378  *
379  * @begin: Tell the platform driver that we're starting hibernation.
380  *	Called right after shrinking memory and before freezing devices.
381  *
382  * @end: Called by the PM core right after resuming devices, to indicate to
383  *	the platform that the system has returned to the working state.
384  *
385  * @pre_snapshot: Prepare the platform for creating the hibernation image.
386  *	Called right after devices have been frozen and before the nonboot
387  *	CPUs are disabled (runs with IRQs on).
388  *
389  * @finish: Restore the previous state of the platform after the hibernation
390  *	image has been created *or* put the platform into the normal operation
391  *	mode after the hibernation (the same method is executed in both cases).
392  *	Called right after the nonboot CPUs have been enabled and before
393  *	thawing devices (runs with IRQs on).
394  *
395  * @prepare: Prepare the platform for entering the low power state.
396  *	Called right after the hibernation image has been saved and before
397  *	devices are prepared for entering the low power state.
398  *
399  * @enter: Put the system into the low power state after the hibernation image
400  *	has been saved to disk.
401  *	Called after the nonboot CPUs have been disabled and all of the low
402  *	level devices have been shut down (runs with IRQs off).
403  *
404  * @leave: Perform the first stage of the cleanup after the system sleep state
405  *	indicated by @set_target() has been left.
406  *	Called right after the control has been passed from the boot kernel to
407  *	the image kernel, before the nonboot CPUs are enabled and before devices
408  *	are resumed.  Executed with interrupts disabled.
409  *
410  * @pre_restore: Prepare system for the restoration from a hibernation image.
411  *	Called right after devices have been frozen and before the nonboot
412  *	CPUs are disabled (runs with IRQs on).
413  *
414  * @restore_cleanup: Clean up after a failing image restoration.
415  *	Called right after the nonboot CPUs have been enabled and before
416  *	thawing devices (runs with IRQs on).
417  *
418  * @recover: Recover the platform from a failure to suspend devices.
419  *	Called by the PM core if the suspending of devices during hibernation
420  *	fails.  This callback is optional and should only be implemented by
421  *	platforms which require special recovery actions in that situation.
422  */
423 struct platform_hibernation_ops {
424 	int (*begin)(pm_message_t stage);
425 	void (*end)(void);
426 	int (*pre_snapshot)(void);
427 	void (*finish)(void);
428 	int (*prepare)(void);
429 	int (*enter)(void);
430 	void (*leave)(void);
431 	int (*pre_restore)(void);
432 	void (*restore_cleanup)(void);
433 	void (*recover)(void);
434 };
435 
436 #ifdef CONFIG_HIBERNATION
437 /* kernel/power/snapshot.c */
438 extern void register_nosave_region(unsigned long b, unsigned long e);
439 extern int swsusp_page_is_forbidden(struct page *);
440 extern void swsusp_set_page_free(struct page *);
441 extern void swsusp_unset_page_free(struct page *);
442 extern unsigned long get_safe_page(gfp_t gfp_mask);
443 extern asmlinkage int swsusp_arch_suspend(void);
444 extern asmlinkage int swsusp_arch_resume(void);
445 
446 extern u32 swsusp_hardware_signature;
447 extern void hibernation_set_ops(const struct platform_hibernation_ops *ops);
448 extern int hibernate(void);
449 extern bool system_entering_hibernation(void);
450 extern bool hibernation_available(void);
451 asmlinkage int swsusp_save(void);
452 extern struct pbe *restore_pblist;
453 int pfn_is_nosave(unsigned long pfn);
454 
455 int hibernate_quiet_exec(int (*func)(void *data), void *data);
456 int hibernate_resume_nonboot_cpu_disable(void);
457 int arch_hibernation_header_save(void *addr, unsigned int max_size);
458 int arch_hibernation_header_restore(void *addr);
459 
460 #else /* CONFIG_HIBERNATION */
461 static inline void register_nosave_region(unsigned long b, unsigned long e) {}
462 static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
463 static inline void swsusp_set_page_free(struct page *p) {}
464 static inline void swsusp_unset_page_free(struct page *p) {}
465 
466 static inline void hibernation_set_ops(const struct platform_hibernation_ops *ops) {}
467 static inline int hibernate(void) { return -ENOSYS; }
468 static inline bool system_entering_hibernation(void) { return false; }
469 static inline bool hibernation_available(void) { return false; }
470 
471 static inline int hibernate_quiet_exec(int (*func)(void *data), void *data) {
472 	return -ENOTSUPP;
473 }
474 #endif /* CONFIG_HIBERNATION */
475 
476 int arch_resume_nosmt(void);
477 
478 #ifdef CONFIG_HIBERNATION_SNAPSHOT_DEV
479 int is_hibernate_resume_dev(dev_t dev);
480 #else
481 static inline int is_hibernate_resume_dev(dev_t dev) { return 0; }
482 #endif
483 
484 /* Hibernation and suspend events */
485 #define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
486 #define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
487 #define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
488 #define PM_POST_SUSPEND		0x0004 /* Suspend finished */
489 #define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
490 #define PM_POST_RESTORE		0x0006 /* Restore failed */
491 
492 extern struct mutex system_transition_mutex;
493 
494 #ifdef CONFIG_PM_SLEEP
495 void save_processor_state(void);
496 void restore_processor_state(void);
497 
498 /* kernel/power/main.c */
499 extern int register_pm_notifier(struct notifier_block *nb);
500 extern int unregister_pm_notifier(struct notifier_block *nb);
501 extern void ksys_sync_helper(void);
502 extern void pm_report_hw_sleep_time(u64 t);
503 extern void pm_report_max_hw_sleep(u64 t);
504 
505 #define pm_notifier(fn, pri) {				\
506 	static struct notifier_block fn##_nb =			\
507 		{ .notifier_call = fn, .priority = pri };	\
508 	register_pm_notifier(&fn##_nb);			\
509 }
510 
511 /* drivers/base/power/wakeup.c */
512 extern bool events_check_enabled;
513 
514 static inline bool pm_suspended_storage(void)
515 {
516 	return !gfp_has_io_fs(gfp_allowed_mask);
517 }
518 
519 extern bool pm_wakeup_pending(void);
520 extern void pm_system_wakeup(void);
521 extern void pm_system_cancel_wakeup(void);
522 extern void pm_wakeup_clear(unsigned int irq_number);
523 extern void pm_system_irq_wakeup(unsigned int irq_number);
524 extern unsigned int pm_wakeup_irq(void);
525 extern bool pm_get_wakeup_count(unsigned int *count, bool block);
526 extern bool pm_save_wakeup_count(unsigned int count);
527 extern void pm_wakep_autosleep_enabled(bool set);
528 extern void pm_print_active_wakeup_sources(void);
529 
530 extern unsigned int lock_system_sleep(void);
531 extern void unlock_system_sleep(unsigned int);
532 
533 #else /* !CONFIG_PM_SLEEP */
534 
535 static inline int register_pm_notifier(struct notifier_block *nb)
536 {
537 	return 0;
538 }
539 
540 static inline int unregister_pm_notifier(struct notifier_block *nb)
541 {
542 	return 0;
543 }
544 
545 static inline void pm_report_hw_sleep_time(u64 t) {};
546 static inline void pm_report_max_hw_sleep(u64 t) {};
547 
548 static inline void ksys_sync_helper(void) {}
549 
550 #define pm_notifier(fn, pri)	do { (void)(fn); } while (0)
551 
552 static inline bool pm_suspended_storage(void) { return false; }
553 static inline bool pm_wakeup_pending(void) { return false; }
554 static inline void pm_system_wakeup(void) {}
555 static inline void pm_wakeup_clear(bool reset) {}
556 static inline void pm_system_irq_wakeup(unsigned int irq_number) {}
557 
558 static inline unsigned int lock_system_sleep(void) { return 0; }
559 static inline void unlock_system_sleep(unsigned int flags) {}
560 
561 #endif /* !CONFIG_PM_SLEEP */
562 
563 #ifdef CONFIG_PM_SLEEP_DEBUG
564 extern bool pm_print_times_enabled;
565 extern bool pm_debug_messages_on;
566 extern bool pm_debug_messages_should_print(void);
567 static inline int pm_dyn_debug_messages_on(void)
568 {
569 #ifdef CONFIG_DYNAMIC_DEBUG
570 	return 1;
571 #else
572 	return 0;
573 #endif
574 }
575 #ifndef pr_fmt
576 #define pr_fmt(fmt) "PM: " fmt
577 #endif
578 #define __pm_pr_dbg(fmt, ...)					\
579 	do {							\
580 		if (pm_debug_messages_should_print())		\
581 			printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__);	\
582 		else if (pm_dyn_debug_messages_on())		\
583 			pr_debug(fmt, ##__VA_ARGS__);	\
584 	} while (0)
585 #define __pm_deferred_pr_dbg(fmt, ...)				\
586 	do {							\
587 		if (pm_debug_messages_should_print())		\
588 			printk_deferred(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__);	\
589 	} while (0)
590 #else
591 #define pm_print_times_enabled	(false)
592 #define pm_debug_messages_on	(false)
593 
594 #include <linux/printk.h>
595 
596 #define __pm_pr_dbg(fmt, ...) \
597 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
598 #define __pm_deferred_pr_dbg(fmt, ...) \
599 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
600 #endif
601 
602 /**
603  * pm_pr_dbg - print pm sleep debug messages
604  *
605  * If pm_debug_messages_on is enabled and the system is entering/leaving
606  *      suspend, print message.
607  * If pm_debug_messages_on is disabled and CONFIG_DYNAMIC_DEBUG is enabled,
608  *	print message only from instances explicitly enabled on dynamic debug's
609  *	control.
610  * If pm_debug_messages_on is disabled and CONFIG_DYNAMIC_DEBUG is disabled,
611  *	don't print message.
612  */
613 #define pm_pr_dbg(fmt, ...) \
614 	__pm_pr_dbg(fmt, ##__VA_ARGS__)
615 
616 #define pm_deferred_pr_dbg(fmt, ...) \
617 	__pm_deferred_pr_dbg(fmt, ##__VA_ARGS__)
618 
619 #ifdef CONFIG_PM_AUTOSLEEP
620 
621 /* kernel/power/autosleep.c */
622 void queue_up_suspend_work(void);
623 
624 #else /* !CONFIG_PM_AUTOSLEEP */
625 
626 static inline void queue_up_suspend_work(void) {}
627 
628 #endif /* !CONFIG_PM_AUTOSLEEP */
629 
630 #endif /* _LINUX_SUSPEND_H */
631