Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * Copyright © 2019 Intel Corporation
0004  */
0005 
0006 #ifndef INTEL_GT_PM_H
0007 #define INTEL_GT_PM_H
0008 
0009 #include <linux/types.h>
0010 
0011 #include "intel_gt_types.h"
0012 #include "intel_wakeref.h"
0013 
0014 static inline bool intel_gt_pm_is_awake(const struct intel_gt *gt)
0015 {
0016     return intel_wakeref_is_active(&gt->wakeref);
0017 }
0018 
0019 static inline void intel_gt_pm_get(struct intel_gt *gt)
0020 {
0021     intel_wakeref_get(&gt->wakeref);
0022 }
0023 
0024 static inline void __intel_gt_pm_get(struct intel_gt *gt)
0025 {
0026     __intel_wakeref_get(&gt->wakeref);
0027 }
0028 
0029 static inline bool intel_gt_pm_get_if_awake(struct intel_gt *gt)
0030 {
0031     return intel_wakeref_get_if_active(&gt->wakeref);
0032 }
0033 
0034 static inline void intel_gt_pm_might_get(struct intel_gt *gt)
0035 {
0036     intel_wakeref_might_get(&gt->wakeref);
0037 }
0038 
0039 static inline void intel_gt_pm_put(struct intel_gt *gt)
0040 {
0041     intel_wakeref_put(&gt->wakeref);
0042 }
0043 
0044 static inline void intel_gt_pm_put_async(struct intel_gt *gt)
0045 {
0046     intel_wakeref_put_async(&gt->wakeref);
0047 }
0048 
0049 static inline void intel_gt_pm_might_put(struct intel_gt *gt)
0050 {
0051     intel_wakeref_might_put(&gt->wakeref);
0052 }
0053 
0054 #define with_intel_gt_pm(gt, tmp) \
0055     for (tmp = 1, intel_gt_pm_get(gt); tmp; \
0056          intel_gt_pm_put(gt), tmp = 0)
0057 
0058 #define with_intel_gt_pm_if_awake(gt, wf) \
0059     for (wf = intel_gt_pm_get_if_awake(gt); wf; intel_gt_pm_put_async(gt), wf = 0)
0060 
0061 static inline int intel_gt_pm_wait_for_idle(struct intel_gt *gt)
0062 {
0063     return intel_wakeref_wait_for_idle(&gt->wakeref);
0064 }
0065 
0066 void intel_gt_pm_init_early(struct intel_gt *gt);
0067 void intel_gt_pm_init(struct intel_gt *gt);
0068 void intel_gt_pm_fini(struct intel_gt *gt);
0069 
0070 void intel_gt_suspend_prepare(struct intel_gt *gt);
0071 void intel_gt_suspend_late(struct intel_gt *gt);
0072 int intel_gt_resume(struct intel_gt *gt);
0073 
0074 void intel_gt_runtime_suspend(struct intel_gt *gt);
0075 int intel_gt_runtime_resume(struct intel_gt *gt);
0076 
0077 ktime_t intel_gt_get_awake_time(const struct intel_gt *gt);
0078 
0079 static inline bool is_mock_gt(const struct intel_gt *gt)
0080 {
0081     return I915_SELFTEST_ONLY(gt->awake == -ENODEV);
0082 }
0083 
0084 #endif /* INTEL_GT_PM_H */