This source file includes following definitions.
- frontbuffer_flush
- intel_frontbuffer_flip_prepare
- intel_frontbuffer_flip_complete
- intel_frontbuffer_flip
- __intel_fb_invalidate
- __intel_fb_flush
- frontbuffer_active
- frontbuffer_retire
- frontbuffer_release
- intel_frontbuffer_get
- intel_frontbuffer_put
- intel_frontbuffer_track
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
51
52
53
54
55
56
57
58 #include "display/intel_dp.h"
59
60 #include "i915_drv.h"
61 #include "intel_display_types.h"
62 #include "intel_fbc.h"
63 #include "intel_frontbuffer.h"
64 #include "intel_psr.h"
65
66
67
68
69
70
71
72
73
74
75
76
77
78 static void frontbuffer_flush(struct drm_i915_private *i915,
79 unsigned int frontbuffer_bits,
80 enum fb_op_origin origin)
81 {
82
83 spin_lock(&i915->fb_tracking.lock);
84 frontbuffer_bits &= ~i915->fb_tracking.busy_bits;
85 spin_unlock(&i915->fb_tracking.lock);
86
87 if (!frontbuffer_bits)
88 return;
89
90 might_sleep();
91 intel_edp_drrs_flush(i915, frontbuffer_bits);
92 intel_psr_flush(i915, frontbuffer_bits, origin);
93 intel_fbc_flush(i915, frontbuffer_bits, origin);
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107
108 void intel_frontbuffer_flip_prepare(struct drm_i915_private *i915,
109 unsigned frontbuffer_bits)
110 {
111 spin_lock(&i915->fb_tracking.lock);
112 i915->fb_tracking.flip_bits |= frontbuffer_bits;
113
114 i915->fb_tracking.busy_bits &= ~frontbuffer_bits;
115 spin_unlock(&i915->fb_tracking.lock);
116 }
117
118
119
120
121
122
123
124
125
126
127
128 void intel_frontbuffer_flip_complete(struct drm_i915_private *i915,
129 unsigned frontbuffer_bits)
130 {
131 spin_lock(&i915->fb_tracking.lock);
132
133 frontbuffer_bits &= i915->fb_tracking.flip_bits;
134 i915->fb_tracking.flip_bits &= ~frontbuffer_bits;
135 spin_unlock(&i915->fb_tracking.lock);
136
137 if (frontbuffer_bits)
138 frontbuffer_flush(i915, frontbuffer_bits, ORIGIN_FLIP);
139 }
140
141
142
143
144
145
146
147
148
149
150
151
152 void intel_frontbuffer_flip(struct drm_i915_private *i915,
153 unsigned frontbuffer_bits)
154 {
155 spin_lock(&i915->fb_tracking.lock);
156
157 i915->fb_tracking.busy_bits &= ~frontbuffer_bits;
158 spin_unlock(&i915->fb_tracking.lock);
159
160 frontbuffer_flush(i915, frontbuffer_bits, ORIGIN_FLIP);
161 }
162
163 void __intel_fb_invalidate(struct intel_frontbuffer *front,
164 enum fb_op_origin origin,
165 unsigned int frontbuffer_bits)
166 {
167 struct drm_i915_private *i915 = to_i915(front->obj->base.dev);
168
169 if (origin == ORIGIN_CS) {
170 spin_lock(&i915->fb_tracking.lock);
171 i915->fb_tracking.busy_bits |= frontbuffer_bits;
172 i915->fb_tracking.flip_bits &= ~frontbuffer_bits;
173 spin_unlock(&i915->fb_tracking.lock);
174 }
175
176 might_sleep();
177 intel_psr_invalidate(i915, frontbuffer_bits, origin);
178 intel_edp_drrs_invalidate(i915, frontbuffer_bits);
179 intel_fbc_invalidate(i915, frontbuffer_bits, origin);
180 }
181
182 void __intel_fb_flush(struct intel_frontbuffer *front,
183 enum fb_op_origin origin,
184 unsigned int frontbuffer_bits)
185 {
186 struct drm_i915_private *i915 = to_i915(front->obj->base.dev);
187
188 if (origin == ORIGIN_CS) {
189 spin_lock(&i915->fb_tracking.lock);
190
191 frontbuffer_bits &= i915->fb_tracking.busy_bits;
192 i915->fb_tracking.busy_bits &= ~frontbuffer_bits;
193 spin_unlock(&i915->fb_tracking.lock);
194 }
195
196 if (frontbuffer_bits)
197 frontbuffer_flush(i915, frontbuffer_bits, origin);
198 }
199
200 static int frontbuffer_active(struct i915_active *ref)
201 {
202 struct intel_frontbuffer *front =
203 container_of(ref, typeof(*front), write);
204
205 kref_get(&front->ref);
206 return 0;
207 }
208
209 static void frontbuffer_retire(struct i915_active *ref)
210 {
211 struct intel_frontbuffer *front =
212 container_of(ref, typeof(*front), write);
213
214 intel_frontbuffer_flush(front, ORIGIN_CS);
215 intel_frontbuffer_put(front);
216 }
217
218 static void frontbuffer_release(struct kref *ref)
219 __releases(&to_i915(front->obj->base.dev)->fb_tracking.lock)
220 {
221 struct intel_frontbuffer *front =
222 container_of(ref, typeof(*front), ref);
223
224 front->obj->frontbuffer = NULL;
225 spin_unlock(&to_i915(front->obj->base.dev)->fb_tracking.lock);
226
227 i915_gem_object_put(front->obj);
228 kfree(front);
229 }
230
231 struct intel_frontbuffer *
232 intel_frontbuffer_get(struct drm_i915_gem_object *obj)
233 {
234 struct drm_i915_private *i915 = to_i915(obj->base.dev);
235 struct intel_frontbuffer *front;
236
237 spin_lock(&i915->fb_tracking.lock);
238 front = obj->frontbuffer;
239 if (front)
240 kref_get(&front->ref);
241 spin_unlock(&i915->fb_tracking.lock);
242 if (front)
243 return front;
244
245 front = kmalloc(sizeof(*front), GFP_KERNEL);
246 if (!front)
247 return NULL;
248
249 front->obj = obj;
250 kref_init(&front->ref);
251 atomic_set(&front->bits, 0);
252 i915_active_init(i915, &front->write,
253 frontbuffer_active, frontbuffer_retire);
254
255 spin_lock(&i915->fb_tracking.lock);
256 if (obj->frontbuffer) {
257 kfree(front);
258 front = obj->frontbuffer;
259 kref_get(&front->ref);
260 } else {
261 i915_gem_object_get(obj);
262 obj->frontbuffer = front;
263 }
264 spin_unlock(&i915->fb_tracking.lock);
265
266 return front;
267 }
268
269 void intel_frontbuffer_put(struct intel_frontbuffer *front)
270 {
271 kref_put_lock(&front->ref,
272 frontbuffer_release,
273 &to_i915(front->obj->base.dev)->fb_tracking.lock);
274 }
275
276
277
278
279
280
281
282
283
284
285 void intel_frontbuffer_track(struct intel_frontbuffer *old,
286 struct intel_frontbuffer *new,
287 unsigned int frontbuffer_bits)
288 {
289
290
291
292
293
294
295
296 BUILD_BUG_ON(INTEL_FRONTBUFFER_BITS_PER_PIPE * I915_MAX_PIPES >
297 BITS_PER_TYPE(atomic_t));
298
299 if (old) {
300 WARN_ON(!(atomic_read(&old->bits) & frontbuffer_bits));
301 atomic_andnot(frontbuffer_bits, &old->bits);
302 }
303
304 if (new) {
305 WARN_ON(atomic_read(&new->bits) & frontbuffer_bits);
306 atomic_or(frontbuffer_bits, &new->bits);
307 }
308 }