This source file includes following definitions.
- intel_rpm_raw_wakeref_count
- intel_rpm_wakelock_count
- assert_rpm_device_not_suspended
- __assert_rpm_raw_wakeref_held
- __assert_rpm_wakelock_held
- assert_rpm_raw_wakeref_held
- assert_rpm_wakelock_held
- disable_rpm_wakeref_asserts
- enable_rpm_wakeref_asserts
- intel_runtime_pm_put
- print_intel_runtime_pm_wakeref
1
2
3
4
5
6 #ifndef __INTEL_RUNTIME_PM_H__
7 #define __INTEL_RUNTIME_PM_H__
8
9 #include <linux/types.h>
10
11 #include "display/intel_display.h"
12
13 #include "intel_wakeref.h"
14
15 #include "i915_utils.h"
16
17 struct device;
18 struct drm_i915_private;
19 struct drm_printer;
20
21 enum i915_drm_suspend_mode {
22 I915_DRM_SUSPEND_IDLE,
23 I915_DRM_SUSPEND_MEM,
24 I915_DRM_SUSPEND_HIBERNATE,
25 };
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 struct intel_runtime_pm {
51 atomic_t wakeref_count;
52 struct device *kdev;
53 bool available;
54 bool suspended;
55 bool irqs_enabled;
56
57 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
58
59
60
61
62
63
64
65 struct intel_runtime_pm_debug {
66 spinlock_t lock;
67
68 depot_stack_handle_t last_acquire;
69 depot_stack_handle_t last_release;
70
71 depot_stack_handle_t *owners;
72 unsigned long count;
73 } debug;
74 #endif
75 };
76
77 #define BITS_PER_WAKEREF \
78 BITS_PER_TYPE(struct_member(struct intel_runtime_pm, wakeref_count))
79 #define INTEL_RPM_WAKELOCK_SHIFT (BITS_PER_WAKEREF / 2)
80 #define INTEL_RPM_WAKELOCK_BIAS (1 << INTEL_RPM_WAKELOCK_SHIFT)
81 #define INTEL_RPM_RAW_WAKEREF_MASK (INTEL_RPM_WAKELOCK_BIAS - 1)
82
83 static inline int
84 intel_rpm_raw_wakeref_count(int wakeref_count)
85 {
86 return wakeref_count & INTEL_RPM_RAW_WAKEREF_MASK;
87 }
88
89 static inline int
90 intel_rpm_wakelock_count(int wakeref_count)
91 {
92 return wakeref_count >> INTEL_RPM_WAKELOCK_SHIFT;
93 }
94
95 static inline void
96 assert_rpm_device_not_suspended(struct intel_runtime_pm *rpm)
97 {
98 WARN_ONCE(rpm->suspended,
99 "Device suspended during HW access\n");
100 }
101
102 static inline void
103 __assert_rpm_raw_wakeref_held(struct intel_runtime_pm *rpm, int wakeref_count)
104 {
105 assert_rpm_device_not_suspended(rpm);
106 WARN_ONCE(!intel_rpm_raw_wakeref_count(wakeref_count),
107 "RPM raw-wakeref not held\n");
108 }
109
110 static inline void
111 __assert_rpm_wakelock_held(struct intel_runtime_pm *rpm, int wakeref_count)
112 {
113 __assert_rpm_raw_wakeref_held(rpm, wakeref_count);
114 WARN_ONCE(!intel_rpm_wakelock_count(wakeref_count),
115 "RPM wakelock ref not held during HW access\n");
116 }
117
118 static inline void
119 assert_rpm_raw_wakeref_held(struct intel_runtime_pm *rpm)
120 {
121 __assert_rpm_raw_wakeref_held(rpm, atomic_read(&rpm->wakeref_count));
122 }
123
124 static inline void
125 assert_rpm_wakelock_held(struct intel_runtime_pm *rpm)
126 {
127 __assert_rpm_wakelock_held(rpm, atomic_read(&rpm->wakeref_count));
128 }
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148 static inline void
149 disable_rpm_wakeref_asserts(struct intel_runtime_pm *rpm)
150 {
151 atomic_add(INTEL_RPM_WAKELOCK_BIAS + 1,
152 &rpm->wakeref_count);
153 }
154
155
156
157
158
159
160
161
162
163
164
165
166 static inline void
167 enable_rpm_wakeref_asserts(struct intel_runtime_pm *rpm)
168 {
169 atomic_sub(INTEL_RPM_WAKELOCK_BIAS + 1,
170 &rpm->wakeref_count);
171 }
172
173 void intel_runtime_pm_init_early(struct intel_runtime_pm *rpm);
174 void intel_runtime_pm_enable(struct intel_runtime_pm *rpm);
175 void intel_runtime_pm_disable(struct intel_runtime_pm *rpm);
176 void intel_runtime_pm_driver_release(struct intel_runtime_pm *rpm);
177
178 intel_wakeref_t intel_runtime_pm_get(struct intel_runtime_pm *rpm);
179 intel_wakeref_t intel_runtime_pm_get_if_in_use(struct intel_runtime_pm *rpm);
180 intel_wakeref_t intel_runtime_pm_get_noresume(struct intel_runtime_pm *rpm);
181 intel_wakeref_t intel_runtime_pm_get_raw(struct intel_runtime_pm *rpm);
182
183 #define with_intel_runtime_pm(rpm, wf) \
184 for ((wf) = intel_runtime_pm_get(rpm); (wf); \
185 intel_runtime_pm_put((rpm), (wf)), (wf) = 0)
186
187 #define with_intel_runtime_pm_if_in_use(rpm, wf) \
188 for ((wf) = intel_runtime_pm_get_if_in_use(rpm); (wf); \
189 intel_runtime_pm_put((rpm), (wf)), (wf) = 0)
190
191 void intel_runtime_pm_put_unchecked(struct intel_runtime_pm *rpm);
192 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
193 void intel_runtime_pm_put(struct intel_runtime_pm *rpm, intel_wakeref_t wref);
194 #else
195 static inline void
196 intel_runtime_pm_put(struct intel_runtime_pm *rpm, intel_wakeref_t wref)
197 {
198 intel_runtime_pm_put_unchecked(rpm);
199 }
200 #endif
201 void intel_runtime_pm_put_raw(struct intel_runtime_pm *rpm, intel_wakeref_t wref);
202
203 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
204 void print_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm,
205 struct drm_printer *p);
206 #else
207 static inline void print_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm,
208 struct drm_printer *p)
209 {
210 }
211 #endif
212
213 #endif