1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2023 Intel Corporation 4 */ 5 6 #ifndef __INTEL_RUNTIME_PM_H__ 7 #define __INTEL_RUNTIME_PM_H__ 8 9 #include "intel_wakeref.h" 10 #include "xe_device_types.h" 11 #include "xe_pm.h" 12 13 #define intel_runtime_pm xe_runtime_pm 14 15 static inline void disable_rpm_wakeref_asserts(void *rpm) 16 { 17 } 18 19 static inline void enable_rpm_wakeref_asserts(void *rpm) 20 { 21 } 22 23 static inline bool 24 intel_runtime_pm_suspended(struct xe_runtime_pm *pm) 25 { 26 struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm); 27 28 return pm_runtime_suspended(xe->drm.dev); 29 } 30 31 static inline intel_wakeref_t intel_runtime_pm_get(struct xe_runtime_pm *pm) 32 { 33 struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm); 34 35 return xe_pm_runtime_resume_and_get(xe) ? INTEL_WAKEREF_DEF : NULL; 36 } 37 38 static inline intel_wakeref_t intel_runtime_pm_get_if_in_use(struct xe_runtime_pm *pm) 39 { 40 struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm); 41 42 return xe_pm_runtime_get_if_in_use(xe) ? INTEL_WAKEREF_DEF : NULL; 43 } 44 45 static inline intel_wakeref_t intel_runtime_pm_get_noresume(struct xe_runtime_pm *pm) 46 { 47 struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm); 48 49 xe_pm_runtime_get_noresume(xe); 50 51 return INTEL_WAKEREF_DEF; 52 } 53 54 static inline void intel_runtime_pm_put_unchecked(struct xe_runtime_pm *pm) 55 { 56 struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm); 57 58 xe_pm_runtime_put(xe); 59 } 60 61 static inline void intel_runtime_pm_put(struct xe_runtime_pm *pm, intel_wakeref_t wakeref) 62 { 63 if (wakeref) 64 intel_runtime_pm_put_unchecked(pm); 65 } 66 67 #define intel_runtime_pm_get_raw intel_runtime_pm_get 68 #define intel_runtime_pm_put_raw intel_runtime_pm_put 69 #define assert_rpm_wakelock_held(x) do { } while (0) 70 #define assert_rpm_raw_wakeref_held(x) do { } while (0) 71 72 #define with_intel_runtime_pm(rpm, wf) \ 73 for ((wf) = intel_runtime_pm_get(rpm); (wf); \ 74 intel_runtime_pm_put((rpm), (wf)), (wf) = NULL) 75 76 #endif 77