xref: /linux/drivers/gpu/drm/xe/compat-i915-headers/intel_runtime_pm.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
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 intel_wakeref_t intel_runtime_pm_get(struct xe_runtime_pm *pm)
24 {
25 	struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm);
26 
27 	return xe_pm_runtime_resume_and_get(xe);
28 }
29 
30 static inline intel_wakeref_t intel_runtime_pm_get_if_in_use(struct xe_runtime_pm *pm)
31 {
32 	struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm);
33 
34 	return xe_pm_runtime_get_if_in_use(xe);
35 }
36 
37 static inline intel_wakeref_t intel_runtime_pm_get_noresume(struct xe_runtime_pm *pm)
38 {
39 	struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm);
40 
41 	xe_pm_runtime_get_noresume(xe);
42 	return true;
43 }
44 
45 static inline void intel_runtime_pm_put_unchecked(struct xe_runtime_pm *pm)
46 {
47 	struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm);
48 
49 	xe_pm_runtime_put(xe);
50 }
51 
52 static inline void intel_runtime_pm_put(struct xe_runtime_pm *pm, intel_wakeref_t wakeref)
53 {
54 	if (wakeref)
55 		intel_runtime_pm_put_unchecked(pm);
56 }
57 
58 #define intel_runtime_pm_get_raw intel_runtime_pm_get
59 #define intel_runtime_pm_put_raw intel_runtime_pm_put
60 #define assert_rpm_wakelock_held(x) do { } while (0)
61 #define assert_rpm_raw_wakeref_held(x) do { } while (0)
62 
63 #define with_intel_runtime_pm(rpm, wf) \
64 	for ((wf) = intel_runtime_pm_get(rpm); (wf); \
65 	     intel_runtime_pm_put((rpm), (wf)), (wf) = 0)
66 
67 #endif
68