1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2019 Intel Corporation
9 #include <linux/types.h>
11 #include "intel_gt_types.h"
12 #include "intel_wakeref.h"
14 static inline bool intel_gt_pm_is_awake(const struct intel_gt *gt)
16 return intel_wakeref_is_active(>->wakeref);
19 static inline void intel_gt_pm_get(struct intel_gt *gt)
21 intel_wakeref_get(>->wakeref);
24 static inline void __intel_gt_pm_get(struct intel_gt *gt)
26 __intel_wakeref_get(>->wakeref);
29 static inline bool intel_gt_pm_get_if_awake(struct intel_gt *gt)
31 return intel_wakeref_get_if_active(>->wakeref);
34 static inline void intel_gt_pm_might_get(struct intel_gt *gt)
36 intel_wakeref_might_get(>->wakeref);
39 static inline void intel_gt_pm_put(struct intel_gt *gt)
41 intel_wakeref_put(>->wakeref);
44 static inline void intel_gt_pm_put_async(struct intel_gt *gt)
46 intel_wakeref_put_async(>->wakeref);
49 static inline void intel_gt_pm_might_put(struct intel_gt *gt)
51 intel_wakeref_might_put(>->wakeref);
54 #define with_intel_gt_pm(gt, tmp) \
55 for (tmp = 1, intel_gt_pm_get(gt); tmp; \
56 intel_gt_pm_put(gt), tmp = 0)
58 #define with_intel_gt_pm_if_awake(gt, wf) \
59 for (wf = intel_gt_pm_get_if_awake(gt); wf; intel_gt_pm_put_async(gt), wf = 0)
61 static inline int intel_gt_pm_wait_for_idle(struct intel_gt *gt)
63 return intel_wakeref_wait_for_idle(>->wakeref);
66 void intel_gt_pm_init_early(struct intel_gt *gt);
67 void intel_gt_pm_init(struct intel_gt *gt);
68 void intel_gt_pm_fini(struct intel_gt *gt);
70 void intel_gt_suspend_prepare(struct intel_gt *gt);
71 void intel_gt_suspend_late(struct intel_gt *gt);
72 int intel_gt_resume(struct intel_gt *gt);
74 void intel_gt_runtime_suspend(struct intel_gt *gt);
75 int intel_gt_runtime_resume(struct intel_gt *gt);
77 ktime_t intel_gt_get_awake_time(const struct intel_gt *gt);
79 static inline bool is_mock_gt(const struct intel_gt *gt)
81 return I915_SELFTEST_ONLY(gt->awake == -ENODEV);
84 #endif /* INTEL_GT_PM_H */