hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/suspend.h
....@@ -8,6 +8,7 @@
88 #include <linux/pm.h>
99 #include <linux/mm.h>
1010 #include <linux/freezer.h>
11
+#include <linux/android_kabi.h>
1112 #include <asm/errno.h>
1213
1314 #ifdef CONFIG_VT
....@@ -37,10 +38,8 @@
3738 #define PM_SUSPEND_TO_IDLE ((__force suspend_state_t) 1)
3839 #define PM_SUSPEND_STANDBY ((__force suspend_state_t) 2)
3940 #define PM_SUSPEND_MEM ((__force suspend_state_t) 3)
40
-#define PM_SUSPEND_MEM_LITE ((__force suspend_state_t) 4)
41
-#define PM_SUSPEND_MEM_ULTRA ((__force suspend_state_t) 5)
4241 #define PM_SUSPEND_MIN PM_SUSPEND_TO_IDLE
43
-#define PM_SUSPEND_MAX ((__force suspend_state_t) 6)
42
+#define PM_SUSPEND_MAX ((__force suspend_state_t) 4)
4443
4544 enum suspend_stat_step {
4645 SUSPEND_FREEZE = 1,
....@@ -187,15 +186,20 @@
187186 bool (*suspend_again)(void);
188187 void (*end)(void);
189188 void (*recover)(void);
189
+
190
+ ANDROID_KABI_RESERVE(1);
190191 };
191192
192193 struct platform_s2idle_ops {
193194 int (*begin)(void);
194195 int (*prepare)(void);
195
- void (*wake)(void);
196
- void (*sync)(void);
196
+ int (*prepare_late)(void);
197
+ bool (*wake)(void);
198
+ void (*restore_early)(void);
197199 void (*restore)(void);
198200 void (*end)(void);
201
+
202
+ ANDROID_KABI_RESERVE(1);
199203 };
200204
201205 #ifdef CONFIG_SUSPEND
....@@ -211,8 +215,9 @@
211215
212216 extern unsigned int pm_suspend_global_flags;
213217
214
-#define PM_SUSPEND_FLAG_FW_SUSPEND (1 << 0)
215
-#define PM_SUSPEND_FLAG_FW_RESUME (1 << 1)
218
+#define PM_SUSPEND_FLAG_FW_SUSPEND BIT(0)
219
+#define PM_SUSPEND_FLAG_FW_RESUME BIT(1)
220
+#define PM_SUSPEND_FLAG_NO_PLATFORM BIT(2)
216221
217222 static inline void pm_suspend_clear_flags(void)
218223 {
....@@ -229,14 +234,66 @@
229234 pm_suspend_global_flags |= PM_SUSPEND_FLAG_FW_RESUME;
230235 }
231236
237
+static inline void pm_set_suspend_no_platform(void)
238
+{
239
+ pm_suspend_global_flags |= PM_SUSPEND_FLAG_NO_PLATFORM;
240
+}
241
+
242
+/**
243
+ * pm_suspend_via_firmware - Check if platform firmware will suspend the system.
244
+ *
245
+ * To be called during system-wide power management transitions to sleep states
246
+ * or during the subsequent system-wide transitions back to the working state.
247
+ *
248
+ * Return 'true' if the platform firmware is going to be invoked at the end of
249
+ * the system-wide power management transition (to a sleep state) in progress in
250
+ * order to complete it, or if the platform firmware has been invoked in order
251
+ * to complete the last (or preceding) transition of the system to a sleep
252
+ * state.
253
+ *
254
+ * This matters if the caller needs or wants to carry out some special actions
255
+ * depending on whether or not control will be passed to the platform firmware
256
+ * subsequently (for example, the device may need to be reset before letting the
257
+ * platform firmware manipulate it, which is not necessary when the platform
258
+ * firmware is not going to be invoked) or when such special actions may have
259
+ * been carried out during the preceding transition of the system to a sleep
260
+ * state (as they may need to be taken into account).
261
+ */
232262 static inline bool pm_suspend_via_firmware(void)
233263 {
234264 return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_FW_SUSPEND);
235265 }
236266
267
+/**
268
+ * pm_resume_via_firmware - Check if platform firmware has woken up the system.
269
+ *
270
+ * To be called during system-wide power management transitions from sleep
271
+ * states.
272
+ *
273
+ * Return 'true' if the platform firmware has passed control to the kernel at
274
+ * the beginning of the system-wide power management transition in progress, so
275
+ * the event that woke up the system from sleep has been handled by the platform
276
+ * firmware.
277
+ */
237278 static inline bool pm_resume_via_firmware(void)
238279 {
239280 return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_FW_RESUME);
281
+}
282
+
283
+/**
284
+ * pm_suspend_no_platform - Check if platform may change device power states.
285
+ *
286
+ * To be called during system-wide power management transitions to sleep states
287
+ * or during the subsequent system-wide transitions back to the working state.
288
+ *
289
+ * Return 'true' if the power states of devices remain under full control of the
290
+ * kernel throughout the system-wide suspend and resume cycle in progress (that
291
+ * is, if a device is put into a certain power state during suspend, it can be
292
+ * expected to remain in that state during resume).
293
+ */
294
+static inline bool pm_suspend_no_platform(void)
295
+{
296
+ return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_NO_PLATFORM);
240297 }
241298
242299 /* Suspend-to-idle state machnine. */
....@@ -253,7 +310,7 @@
253310 return unlikely(s2idle_state == S2IDLE_STATE_ENTER);
254311 }
255312
256
-extern bool pm_suspend_via_s2idle(void);
313
+extern bool pm_suspend_default_s2idle(void);
257314 extern void __init pm_states_init(void);
258315 extern void s2idle_set_ops(const struct platform_s2idle_ops *ops);
259316 extern void s2idle_wake(void);
....@@ -277,6 +334,7 @@
277334 extern void arch_suspend_enable_irqs(void);
278335
279336 extern int pm_suspend(suspend_state_t state);
337
+extern bool sync_on_suspend_enabled;
280338 #else /* !CONFIG_SUSPEND */
281339 #define suspend_valid_only_mem NULL
282340
....@@ -285,10 +343,12 @@
285343 static inline void pm_set_resume_via_firmware(void) {}
286344 static inline bool pm_suspend_via_firmware(void) { return false; }
287345 static inline bool pm_resume_via_firmware(void) { return false; }
288
-static inline bool pm_suspend_via_s2idle(void) { return false; }
346
+static inline bool pm_suspend_no_platform(void) { return false; }
347
+static inline bool pm_suspend_default_s2idle(void) { return false; }
289348
290349 static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
291350 static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
351
+static inline bool sync_on_suspend_enabled(void) { return true; }
292352 static inline bool idle_should_enter_s2idle(void) { return false; }
293353 static inline void __init pm_states_init(void) {}
294354 static inline void s2idle_set_ops(const struct platform_s2idle_ops *ops) {}
....@@ -361,7 +421,7 @@
361421 * platforms which require special recovery actions in that situation.
362422 */
363423 struct platform_hibernation_ops {
364
- int (*begin)(void);
424
+ int (*begin)(pm_message_t stage);
365425 void (*end)(void);
366426 int (*pre_snapshot)(void);
367427 void (*finish)(void);
....@@ -371,19 +431,13 @@
371431 int (*pre_restore)(void);
372432 void (*restore_cleanup)(void);
373433 void (*recover)(void);
434
+
435
+ ANDROID_KABI_RESERVE(1);
374436 };
375437
376438 #ifdef CONFIG_HIBERNATION
377439 /* kernel/power/snapshot.c */
378
-extern void __register_nosave_region(unsigned long b, unsigned long e, int km);
379
-static inline void __init register_nosave_region(unsigned long b, unsigned long e)
380
-{
381
- __register_nosave_region(b, e, 0);
382
-}
383
-static inline void __init register_nosave_region_late(unsigned long b, unsigned long e)
384
-{
385
- __register_nosave_region(b, e, 1);
386
-}
440
+extern void register_nosave_region(unsigned long b, unsigned long e);
387441 extern int swsusp_page_is_forbidden(struct page *);
388442 extern void swsusp_set_page_free(struct page *);
389443 extern void swsusp_unset_page_free(struct page *);
....@@ -397,9 +451,11 @@
397451 extern bool hibernation_available(void);
398452 asmlinkage int swsusp_save(void);
399453 extern struct pbe *restore_pblist;
454
+int pfn_is_nosave(unsigned long pfn);
455
+
456
+int hibernate_quiet_exec(int (*func)(void *data), void *data);
400457 #else /* CONFIG_HIBERNATION */
401458 static inline void register_nosave_region(unsigned long b, unsigned long e) {}
402
-static inline void register_nosave_region_late(unsigned long b, unsigned long e) {}
403459 static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
404460 static inline void swsusp_set_page_free(struct page *p) {}
405461 static inline void swsusp_unset_page_free(struct page *p) {}
....@@ -408,7 +464,17 @@
408464 static inline int hibernate(void) { return -ENOSYS; }
409465 static inline bool system_entering_hibernation(void) { return false; }
410466 static inline bool hibernation_available(void) { return false; }
467
+
468
+static inline int hibernate_quiet_exec(int (*func)(void *data), void *data) {
469
+ return -ENOTSUPP;
470
+}
411471 #endif /* CONFIG_HIBERNATION */
472
+
473
+#ifdef CONFIG_HIBERNATION_SNAPSHOT_DEV
474
+int is_hibernate_resume_dev(dev_t dev);
475
+#else
476
+static inline int is_hibernate_resume_dev(dev_t dev) { return 0; }
477
+#endif
412478
413479 /* Hibernation and suspend events */
414480 #define PM_HIBERNATION_PREPARE 0x0001 /* Going to hibernate */
....@@ -427,6 +493,7 @@
427493 /* kernel/power/main.c */
428494 extern int register_pm_notifier(struct notifier_block *nb);
429495 extern int unregister_pm_notifier(struct notifier_block *nb);
496
+extern void ksys_sync_helper(void);
430497
431498 #define pm_notifier(fn, pri) { \
432499 static struct notifier_block fn##_nb = \
....@@ -436,14 +503,14 @@
436503
437504 /* drivers/base/power/wakeup.c */
438505 extern bool events_check_enabled;
439
-extern unsigned int pm_wakeup_irq;
440506 extern suspend_state_t pm_suspend_target_state;
441507
442508 extern bool pm_wakeup_pending(void);
443509 extern void pm_system_wakeup(void);
444510 extern void pm_system_cancel_wakeup(void);
445
-extern void pm_wakeup_clear(bool reset);
511
+extern void pm_wakeup_clear(unsigned int irq_number);
446512 extern void pm_system_irq_wakeup(unsigned int irq_number);
513
+extern unsigned int pm_wakeup_irq(void);
447514 extern bool pm_get_wakeup_count(unsigned int *count, bool block);
448515 extern bool pm_save_wakeup_count(unsigned int count);
449516 extern void pm_wakep_autosleep_enabled(bool set);
....@@ -464,6 +531,8 @@
464531 {
465532 return 0;
466533 }
534
+
535
+static inline void ksys_sync_helper(void) {}
467536
468537 #define pm_notifier(fn, pri) do { (void)(fn); } while (0)
469538
....@@ -507,39 +576,5 @@
507576 static inline void queue_up_suspend_work(void) {}
508577
509578 #endif /* !CONFIG_PM_AUTOSLEEP */
510
-
511
-#ifdef CONFIG_ARCH_SAVE_PAGE_KEYS
512
-/*
513
- * The ARCH_SAVE_PAGE_KEYS functions can be used by an architecture
514
- * to save/restore additional information to/from the array of page
515
- * frame numbers in the hibernation image. For s390 this is used to
516
- * save and restore the storage key for each page that is included
517
- * in the hibernation image.
518
- */
519
-unsigned long page_key_additional_pages(unsigned long pages);
520
-int page_key_alloc(unsigned long pages);
521
-void page_key_free(void);
522
-void page_key_read(unsigned long *pfn);
523
-void page_key_memorize(unsigned long *pfn);
524
-void page_key_write(void *address);
525
-
526
-#else /* !CONFIG_ARCH_SAVE_PAGE_KEYS */
527
-
528
-static inline unsigned long page_key_additional_pages(unsigned long pages)
529
-{
530
- return 0;
531
-}
532
-
533
-static inline int page_key_alloc(unsigned long pages)
534
-{
535
- return 0;
536
-}
537
-
538
-static inline void page_key_free(void) {}
539
-static inline void page_key_read(unsigned long *pfn) {}
540
-static inline void page_key_memorize(unsigned long *pfn) {}
541
-static inline void page_key_write(void *address) {}
542
-
543
-#endif /* !CONFIG_ARCH_SAVE_PAGE_KEYS */
544579
545580 #endif /* _LINUX_SUSPEND_H */