1 /* $NetBSD: intel_gt_pm.h,v 1.2 2021/12/18 23:45:30 riastradh Exp $ */ 2 3 /* 4 * SPDX-License-Identifier: MIT 5 * 6 * Copyright © 2019 Intel Corporation 7 */ 8 9 #ifndef INTEL_GT_PM_H 10 #define INTEL_GT_PM_H 11 12 #include <linux/types.h> 13 14 #include "intel_gt_types.h" 15 #include "intel_wakeref.h" 16 intel_gt_pm_is_awake(const struct intel_gt * gt)17static inline bool intel_gt_pm_is_awake(const struct intel_gt *gt) 18 { 19 return intel_wakeref_is_active(>->wakeref); 20 } 21 intel_gt_pm_get(struct intel_gt * gt)22static inline void intel_gt_pm_get(struct intel_gt *gt) 23 { 24 intel_wakeref_get(>->wakeref); 25 } 26 __intel_gt_pm_get(struct intel_gt * gt)27static inline void __intel_gt_pm_get(struct intel_gt *gt) 28 { 29 __intel_wakeref_get(>->wakeref); 30 } 31 intel_gt_pm_get_if_awake(struct intel_gt * gt)32static inline bool intel_gt_pm_get_if_awake(struct intel_gt *gt) 33 { 34 return intel_wakeref_get_if_active(>->wakeref); 35 } 36 intel_gt_pm_put(struct intel_gt * gt)37static inline void intel_gt_pm_put(struct intel_gt *gt) 38 { 39 intel_wakeref_put(>->wakeref); 40 } 41 intel_gt_pm_put_async(struct intel_gt * gt)42static inline void intel_gt_pm_put_async(struct intel_gt *gt) 43 { 44 intel_wakeref_put_async(>->wakeref); 45 } 46 intel_gt_pm_wait_for_idle(struct intel_gt * gt)47static inline int intel_gt_pm_wait_for_idle(struct intel_gt *gt) 48 { 49 return intel_wakeref_wait_for_idle(>->wakeref); 50 } 51 52 void intel_gt_pm_init_early(struct intel_gt *gt); 53 void intel_gt_pm_init(struct intel_gt *gt); 54 void intel_gt_pm_fini(struct intel_gt *gt); 55 56 void intel_gt_suspend_prepare(struct intel_gt *gt); 57 void intel_gt_suspend_late(struct intel_gt *gt); 58 int intel_gt_resume(struct intel_gt *gt); 59 60 void intel_gt_runtime_suspend(struct intel_gt *gt); 61 int intel_gt_runtime_resume(struct intel_gt *gt); 62 is_mock_gt(const struct intel_gt * gt)63static inline bool is_mock_gt(const struct intel_gt *gt) 64 { 65 return I915_SELFTEST_ONLY(gt->awake == -ENODEV); 66 } 67 68 #endif /* INTEL_GT_PM_H */ 69