This source file includes following definitions.
- ivb_can_enable_err_int
- cpt_can_enable_serr_int
- i9xx_check_fifo_underruns
- i9xx_set_fifo_underrun_reporting
- ironlake_set_fifo_underrun_reporting
- ivybridge_check_fifo_underruns
- ivybridge_set_fifo_underrun_reporting
- broadwell_set_fifo_underrun_reporting
- ibx_set_fifo_underrun_reporting
- cpt_check_pch_fifo_underruns
- cpt_set_fifo_underrun_reporting
- __intel_set_cpu_fifo_underrun_reporting
- intel_set_cpu_fifo_underrun_reporting
- intel_set_pch_fifo_underrun_reporting
- intel_cpu_fifo_underrun_irq_handler
- intel_pch_fifo_underrun_irq_handler
- intel_check_cpu_fifo_underruns
- intel_check_pch_fifo_underruns
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 #include "i915_drv.h"
29 #include "i915_trace.h"
30 #include "intel_display_types.h"
31 #include "intel_fbc.h"
32 #include "intel_fifo_underrun.h"
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 static bool ivb_can_enable_err_int(struct drm_device *dev)
55 {
56 struct drm_i915_private *dev_priv = to_i915(dev);
57 struct intel_crtc *crtc;
58 enum pipe pipe;
59
60 lockdep_assert_held(&dev_priv->irq_lock);
61
62 for_each_pipe(dev_priv, pipe) {
63 crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
64
65 if (crtc->cpu_fifo_underrun_disabled)
66 return false;
67 }
68
69 return true;
70 }
71
72 static bool cpt_can_enable_serr_int(struct drm_device *dev)
73 {
74 struct drm_i915_private *dev_priv = to_i915(dev);
75 enum pipe pipe;
76 struct intel_crtc *crtc;
77
78 lockdep_assert_held(&dev_priv->irq_lock);
79
80 for_each_pipe(dev_priv, pipe) {
81 crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
82
83 if (crtc->pch_fifo_underrun_disabled)
84 return false;
85 }
86
87 return true;
88 }
89
90 static void i9xx_check_fifo_underruns(struct intel_crtc *crtc)
91 {
92 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
93 i915_reg_t reg = PIPESTAT(crtc->pipe);
94 u32 enable_mask;
95
96 lockdep_assert_held(&dev_priv->irq_lock);
97
98 if ((I915_READ(reg) & PIPE_FIFO_UNDERRUN_STATUS) == 0)
99 return;
100
101 enable_mask = i915_pipestat_enable_mask(dev_priv, crtc->pipe);
102 I915_WRITE(reg, enable_mask | PIPE_FIFO_UNDERRUN_STATUS);
103 POSTING_READ(reg);
104
105 trace_intel_cpu_fifo_underrun(dev_priv, crtc->pipe);
106 DRM_ERROR("pipe %c underrun\n", pipe_name(crtc->pipe));
107 }
108
109 static void i9xx_set_fifo_underrun_reporting(struct drm_device *dev,
110 enum pipe pipe,
111 bool enable, bool old)
112 {
113 struct drm_i915_private *dev_priv = to_i915(dev);
114 i915_reg_t reg = PIPESTAT(pipe);
115
116 lockdep_assert_held(&dev_priv->irq_lock);
117
118 if (enable) {
119 u32 enable_mask = i915_pipestat_enable_mask(dev_priv, pipe);
120
121 I915_WRITE(reg, enable_mask | PIPE_FIFO_UNDERRUN_STATUS);
122 POSTING_READ(reg);
123 } else {
124 if (old && I915_READ(reg) & PIPE_FIFO_UNDERRUN_STATUS)
125 DRM_ERROR("pipe %c underrun\n", pipe_name(pipe));
126 }
127 }
128
129 static void ironlake_set_fifo_underrun_reporting(struct drm_device *dev,
130 enum pipe pipe, bool enable)
131 {
132 struct drm_i915_private *dev_priv = to_i915(dev);
133 u32 bit = (pipe == PIPE_A) ?
134 DE_PIPEA_FIFO_UNDERRUN : DE_PIPEB_FIFO_UNDERRUN;
135
136 if (enable)
137 ilk_enable_display_irq(dev_priv, bit);
138 else
139 ilk_disable_display_irq(dev_priv, bit);
140 }
141
142 static void ivybridge_check_fifo_underruns(struct intel_crtc *crtc)
143 {
144 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
145 enum pipe pipe = crtc->pipe;
146 u32 err_int = I915_READ(GEN7_ERR_INT);
147
148 lockdep_assert_held(&dev_priv->irq_lock);
149
150 if ((err_int & ERR_INT_FIFO_UNDERRUN(pipe)) == 0)
151 return;
152
153 I915_WRITE(GEN7_ERR_INT, ERR_INT_FIFO_UNDERRUN(pipe));
154 POSTING_READ(GEN7_ERR_INT);
155
156 trace_intel_cpu_fifo_underrun(dev_priv, pipe);
157 DRM_ERROR("fifo underrun on pipe %c\n", pipe_name(pipe));
158 }
159
160 static void ivybridge_set_fifo_underrun_reporting(struct drm_device *dev,
161 enum pipe pipe,
162 bool enable, bool old)
163 {
164 struct drm_i915_private *dev_priv = to_i915(dev);
165 if (enable) {
166 I915_WRITE(GEN7_ERR_INT, ERR_INT_FIFO_UNDERRUN(pipe));
167
168 if (!ivb_can_enable_err_int(dev))
169 return;
170
171 ilk_enable_display_irq(dev_priv, DE_ERR_INT_IVB);
172 } else {
173 ilk_disable_display_irq(dev_priv, DE_ERR_INT_IVB);
174
175 if (old &&
176 I915_READ(GEN7_ERR_INT) & ERR_INT_FIFO_UNDERRUN(pipe)) {
177 DRM_ERROR("uncleared fifo underrun on pipe %c\n",
178 pipe_name(pipe));
179 }
180 }
181 }
182
183 static void broadwell_set_fifo_underrun_reporting(struct drm_device *dev,
184 enum pipe pipe, bool enable)
185 {
186 struct drm_i915_private *dev_priv = to_i915(dev);
187
188 if (enable)
189 bdw_enable_pipe_irq(dev_priv, pipe, GEN8_PIPE_FIFO_UNDERRUN);
190 else
191 bdw_disable_pipe_irq(dev_priv, pipe, GEN8_PIPE_FIFO_UNDERRUN);
192 }
193
194 static void ibx_set_fifo_underrun_reporting(struct drm_device *dev,
195 enum pipe pch_transcoder,
196 bool enable)
197 {
198 struct drm_i915_private *dev_priv = to_i915(dev);
199 u32 bit = (pch_transcoder == PIPE_A) ?
200 SDE_TRANSA_FIFO_UNDER : SDE_TRANSB_FIFO_UNDER;
201
202 if (enable)
203 ibx_enable_display_interrupt(dev_priv, bit);
204 else
205 ibx_disable_display_interrupt(dev_priv, bit);
206 }
207
208 static void cpt_check_pch_fifo_underruns(struct intel_crtc *crtc)
209 {
210 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
211 enum pipe pch_transcoder = crtc->pipe;
212 u32 serr_int = I915_READ(SERR_INT);
213
214 lockdep_assert_held(&dev_priv->irq_lock);
215
216 if ((serr_int & SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder)) == 0)
217 return;
218
219 I915_WRITE(SERR_INT, SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder));
220 POSTING_READ(SERR_INT);
221
222 trace_intel_pch_fifo_underrun(dev_priv, pch_transcoder);
223 DRM_ERROR("pch fifo underrun on pch transcoder %c\n",
224 pipe_name(pch_transcoder));
225 }
226
227 static void cpt_set_fifo_underrun_reporting(struct drm_device *dev,
228 enum pipe pch_transcoder,
229 bool enable, bool old)
230 {
231 struct drm_i915_private *dev_priv = to_i915(dev);
232
233 if (enable) {
234 I915_WRITE(SERR_INT,
235 SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder));
236
237 if (!cpt_can_enable_serr_int(dev))
238 return;
239
240 ibx_enable_display_interrupt(dev_priv, SDE_ERROR_CPT);
241 } else {
242 ibx_disable_display_interrupt(dev_priv, SDE_ERROR_CPT);
243
244 if (old && I915_READ(SERR_INT) &
245 SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder)) {
246 DRM_ERROR("uncleared pch fifo underrun on pch transcoder %c\n",
247 pipe_name(pch_transcoder));
248 }
249 }
250 }
251
252 static bool __intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
253 enum pipe pipe, bool enable)
254 {
255 struct drm_i915_private *dev_priv = to_i915(dev);
256 struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
257 bool old;
258
259 lockdep_assert_held(&dev_priv->irq_lock);
260
261 old = !crtc->cpu_fifo_underrun_disabled;
262 crtc->cpu_fifo_underrun_disabled = !enable;
263
264 if (HAS_GMCH(dev_priv))
265 i9xx_set_fifo_underrun_reporting(dev, pipe, enable, old);
266 else if (IS_GEN_RANGE(dev_priv, 5, 6))
267 ironlake_set_fifo_underrun_reporting(dev, pipe, enable);
268 else if (IS_GEN(dev_priv, 7))
269 ivybridge_set_fifo_underrun_reporting(dev, pipe, enable, old);
270 else if (INTEL_GEN(dev_priv) >= 8)
271 broadwell_set_fifo_underrun_reporting(dev, pipe, enable);
272
273 return old;
274 }
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292 bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
293 enum pipe pipe, bool enable)
294 {
295 unsigned long flags;
296 bool ret;
297
298 spin_lock_irqsave(&dev_priv->irq_lock, flags);
299 ret = __intel_set_cpu_fifo_underrun_reporting(&dev_priv->drm, pipe,
300 enable);
301 spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
302
303 return ret;
304 }
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320 bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
321 enum pipe pch_transcoder,
322 bool enable)
323 {
324 struct intel_crtc *crtc =
325 intel_get_crtc_for_pipe(dev_priv, pch_transcoder);
326 unsigned long flags;
327 bool old;
328
329
330
331
332
333
334
335
336
337
338 spin_lock_irqsave(&dev_priv->irq_lock, flags);
339
340 old = !crtc->pch_fifo_underrun_disabled;
341 crtc->pch_fifo_underrun_disabled = !enable;
342
343 if (HAS_PCH_IBX(dev_priv))
344 ibx_set_fifo_underrun_reporting(&dev_priv->drm,
345 pch_transcoder,
346 enable);
347 else
348 cpt_set_fifo_underrun_reporting(&dev_priv->drm,
349 pch_transcoder,
350 enable, old);
351
352 spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
353 return old;
354 }
355
356
357
358
359
360
361
362
363
364
365 void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
366 enum pipe pipe)
367 {
368 struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
369
370
371 if (crtc == NULL)
372 return;
373
374
375 if (HAS_GMCH(dev_priv) &&
376 crtc->cpu_fifo_underrun_disabled)
377 return;
378
379 if (intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false)) {
380 trace_intel_cpu_fifo_underrun(dev_priv, pipe);
381 DRM_ERROR("CPU pipe %c FIFO underrun\n",
382 pipe_name(pipe));
383 }
384
385 intel_fbc_handle_fifo_underrun_irq(dev_priv);
386 }
387
388
389
390
391
392
393
394
395
396
397 void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
398 enum pipe pch_transcoder)
399 {
400 if (intel_set_pch_fifo_underrun_reporting(dev_priv, pch_transcoder,
401 false)) {
402 trace_intel_pch_fifo_underrun(dev_priv, pch_transcoder);
403 DRM_ERROR("PCH transcoder %c FIFO underrun\n",
404 pipe_name(pch_transcoder));
405 }
406 }
407
408
409
410
411
412
413
414
415
416
417 void intel_check_cpu_fifo_underruns(struct drm_i915_private *dev_priv)
418 {
419 struct intel_crtc *crtc;
420
421 spin_lock_irq(&dev_priv->irq_lock);
422
423 for_each_intel_crtc(&dev_priv->drm, crtc) {
424 if (crtc->cpu_fifo_underrun_disabled)
425 continue;
426
427 if (HAS_GMCH(dev_priv))
428 i9xx_check_fifo_underruns(crtc);
429 else if (IS_GEN(dev_priv, 7))
430 ivybridge_check_fifo_underruns(crtc);
431 }
432
433 spin_unlock_irq(&dev_priv->irq_lock);
434 }
435
436
437
438
439
440
441
442
443
444 void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv)
445 {
446 struct intel_crtc *crtc;
447
448 spin_lock_irq(&dev_priv->irq_lock);
449
450 for_each_intel_crtc(&dev_priv->drm, crtc) {
451 if (crtc->pch_fifo_underrun_disabled)
452 continue;
453
454 if (HAS_PCH_CPT(dev_priv))
455 cpt_check_pch_fifo_underruns(crtc);
456 }
457
458 spin_unlock_irq(&dev_priv->irq_lock);
459 }