hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/linux/pm.h
....@@ -1,21 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * pm.h - Power management interface
34 *
45 * Copyright (C) 2000 Andrew Henroid
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
196 */
207
218 #ifndef _LINUX_PM_H
....@@ -26,7 +13,9 @@
2613 #include <linux/spinlock.h>
2714 #include <linux/wait.h>
2815 #include <linux/timer.h>
16
+#include <linux/hrtimer.h>
2917 #include <linux/completion.h>
18
+#include <linux/android_kabi.h>
3019
3120 /*
3221 * Callbacks for platform drivers to implement.
....@@ -283,7 +272,7 @@
283272 * actions to be performed by a device driver's callbacks generally depend on
284273 * the platform and subsystem the device belongs to.
285274 *
286
- * Refer to Documentation/power/runtime_pm.txt for more information about the
275
+ * Refer to Documentation/power/runtime_pm.rst for more information about the
287276 * role of the @runtime_suspend(), @runtime_resume() and @runtime_idle()
288277 * callbacks in device runtime power management.
289278 */
....@@ -311,6 +300,8 @@
311300 int (*runtime_suspend)(struct device *dev);
312301 int (*runtime_resume)(struct device *dev);
313302 int (*runtime_idle)(struct device *dev);
303
+
304
+ ANDROID_KABI_RESERVE(1);
314305 };
315306
316307 #ifdef CONFIG_PM_SLEEP
....@@ -363,7 +354,7 @@
363354 * to RAM and hibernation.
364355 */
365356 #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
366
-const struct dev_pm_ops name = { \
357
+const struct dev_pm_ops __maybe_unused name = { \
367358 SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
368359 }
369360
....@@ -381,10 +372,16 @@
381372 * .runtime_resume(), respectively (and analogously for hibernation).
382373 */
383374 #define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
384
-const struct dev_pm_ops name = { \
375
+const struct dev_pm_ops __maybe_unused name = { \
385376 SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
386377 SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
387378 }
379
+
380
+#ifdef CONFIG_PM
381
+#define pm_ptr(_ptr) (_ptr)
382
+#else
383
+#define pm_ptr(_ptr) NULL
384
+#endif
388385
389386 /*
390387 * PM_EVENT_ messages
....@@ -556,31 +553,17 @@
556553 * These flags can be set by device drivers at the probe time. They need not be
557554 * cleared by the drivers as the driver core will take care of that.
558555 *
559
- * NEVER_SKIP: Do not skip all system suspend/resume callbacks for the device.
560
- * SMART_PREPARE: Check the return value of the driver's ->prepare callback.
561
- * SMART_SUSPEND: No need to resume the device from runtime suspend.
562
- * LEAVE_SUSPENDED: Avoid resuming the device during system resume if possible.
556
+ * NO_DIRECT_COMPLETE: Do not apply direct-complete optimization to the device.
557
+ * SMART_PREPARE: Take the driver ->prepare callback return value into account.
558
+ * SMART_SUSPEND: Avoid resuming the device from runtime suspend.
559
+ * MAY_SKIP_RESUME: Allow driver "noirq" and "early" callbacks to be skipped.
563560 *
564
- * Setting SMART_PREPARE instructs bus types and PM domains which may want
565
- * system suspend/resume callbacks to be skipped for the device to return 0 from
566
- * their ->prepare callbacks if the driver's ->prepare callback returns 0 (in
567
- * other words, the system suspend/resume callbacks can only be skipped for the
568
- * device if its driver doesn't object against that). This flag has no effect
569
- * if NEVER_SKIP is set.
570
- *
571
- * Setting SMART_SUSPEND instructs bus types and PM domains which may want to
572
- * runtime resume the device upfront during system suspend that doing so is not
573
- * necessary from the driver's perspective. It also may cause them to skip
574
- * invocations of the ->suspend_late and ->suspend_noirq callbacks provided by
575
- * the driver if they decide to leave the device in runtime suspend.
576
- *
577
- * Setting LEAVE_SUSPENDED informs the PM core and middle-layer code that the
578
- * driver prefers the device to be left in suspend after system resume.
561
+ * See Documentation/driver-api/pm/devices.rst for details.
579562 */
580
-#define DPM_FLAG_NEVER_SKIP BIT(0)
563
+#define DPM_FLAG_NO_DIRECT_COMPLETE BIT(0)
581564 #define DPM_FLAG_SMART_PREPARE BIT(1)
582565 #define DPM_FLAG_SMART_SUSPEND BIT(2)
583
-#define DPM_FLAG_LEAVE_SUSPENDED BIT(3)
566
+#define DPM_FLAG_MAY_SKIP_RESUME BIT(3)
584567
585568 struct dev_pm_info {
586569 pm_message_t power_state;
....@@ -609,8 +592,8 @@
609592 unsigned int should_wakeup:1;
610593 #endif
611594 #ifdef CONFIG_PM
612
- struct timer_list suspend_timer;
613
- unsigned long timer_expires;
595
+ struct hrtimer suspend_timer;
596
+ u64 timer_expires;
614597 struct work_struct work;
615598 wait_queue_head_t wait_queue;
616599 struct wake_irq *wakeirq;
....@@ -620,6 +603,7 @@
620603 unsigned int idle_notification:1;
621604 unsigned int request_pending:1;
622605 unsigned int deferred_resume:1;
606
+ unsigned int needs_force_resume:1;
623607 unsigned int runtime_auto:1;
624608 bool ignore_children:1;
625609 unsigned int no_callbacks:1;
....@@ -632,17 +616,19 @@
632616 enum rpm_status runtime_status;
633617 int runtime_error;
634618 int autosuspend_delay;
635
- unsigned long last_busy;
636
- unsigned long active_jiffies;
637
- unsigned long suspended_jiffies;
638
- unsigned long accounting_timestamp;
619
+ u64 last_busy;
620
+ u64 active_time;
621
+ u64 suspended_time;
622
+ u64 accounting_timestamp;
639623 #endif
640624 struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */
641625 void (*set_latency_tolerance)(struct device *, s32);
642626 struct dev_pm_qos *qos;
627
+
628
+ ANDROID_KABI_RESERVE(1);
629
+ ANDROID_KABI_RESERVE(2);
643630 };
644631
645
-extern void update_pm_runtime_accounting(struct device *dev);
646632 extern int dev_pm_get_subsys_data(struct device *dev);
647633 extern void dev_pm_put_subsys_data(struct device *dev);
648634
....@@ -650,6 +636,7 @@
650636 * struct dev_pm_domain - power management domain representation.
651637 *
652638 * @ops: Power management operations associated with this domain.
639
+ * @start: Called when a user needs to start the device via the domain.
653640 * @detach: Called when removing a device from the domain.
654641 * @activate: Called before executing probe routines for bus types and drivers.
655642 * @sync: Called after successful driver probe.
....@@ -661,10 +648,13 @@
661648 */
662649 struct dev_pm_domain {
663650 struct dev_pm_ops ops;
651
+ int (*start)(struct device *dev);
664652 void (*detach)(struct device *dev, bool power_off);
665653 int (*activate)(struct device *dev);
666654 void (*sync)(struct device *dev);
667655 void (*dismiss)(struct device *dev);
656
+
657
+ ANDROID_KABI_RESERVE(1);
668658 };
669659
670660 /*
....@@ -725,8 +715,6 @@
725715 extern void device_pm_lock(void);
726716 extern void dpm_resume_start(pm_message_t state);
727717 extern void dpm_resume_end(pm_message_t state);
728
-extern void dpm_noirq_resume_devices(pm_message_t state);
729
-extern void dpm_noirq_end(void);
730718 extern void dpm_resume_noirq(pm_message_t state);
731719 extern void dpm_resume_early(pm_message_t state);
732720 extern void dpm_resume(pm_message_t state);
....@@ -735,8 +723,6 @@
735723 extern void device_pm_unlock(void);
736724 extern int dpm_suspend_end(pm_message_t state);
737725 extern int dpm_suspend_start(pm_message_t state);
738
-extern void dpm_noirq_begin(void);
739
-extern int dpm_noirq_suspend_devices(pm_message_t state);
740726 extern int dpm_suspend_noirq(pm_message_t state);
741727 extern int dpm_suspend_late(pm_message_t state);
742728 extern int dpm_suspend(pm_message_t state);
....@@ -773,9 +759,8 @@
773759 extern int pm_generic_poweroff(struct device *dev);
774760 extern void pm_generic_complete(struct device *dev);
775761
776
-extern void dev_pm_skip_next_resume_phases(struct device *dev);
777
-extern bool dev_pm_may_skip_resume(struct device *dev);
778
-extern bool dev_pm_smart_suspend_and_suspended(struct device *dev);
762
+extern bool dev_pm_skip_resume(struct device *dev);
763
+extern bool dev_pm_skip_suspend(struct device *dev);
779764
780765 #else /* !CONFIG_PM_SLEEP */
781766