blob: 34f93f112107b4811775c4ae64a04991560b3732 [file] [log] [blame]
Daniel Vetter47339cd2014-09-30 10:56:46 +02001/*
2 * Copyright © 2014 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Daniel Vetter <daniel.vetter@ffwll.ch>
25 *
26 */
27
28#include "i915_drv.h"
29#include "intel_drv.h"
30
Daniel Vetteref073882014-09-30 10:56:50 +020031/**
32 * DOC: fifo underrun handling
33 *
34 * The i915 driver checks for display fifo underruns using the interrupt signals
35 * provided by the hardware. This is enabled by default and fairly useful to
36 * debug display issues, especially watermark settings.
37 *
38 * If an underrun is detected this is logged into dmesg. To avoid flooding logs
39 * and occupying the cpu underrun interrupts are disabled after the first
40 * occurrence until the next modeset on a given pipe.
41 *
42 * Note that underrun detection on gmch platforms is a bit more ugly since there
43 * is no interrupt (despite that the signalling bit is in the PIPESTAT pipe
44 * interrupt register). Also on some other platforms underrun interrupts are
45 * shared, which means that if we detect an underrun we need to disable underrun
46 * reporting on all pipes.
47 *
48 * The code also supports underrun detection on the PCH transcoder.
49 */
50
Daniel Vetter47339cd2014-09-30 10:56:46 +020051static bool ivb_can_enable_err_int(struct drm_device *dev)
52{
Chris Wilsonfac5e232016-07-04 11:34:36 +010053 struct drm_i915_private *dev_priv = to_i915(dev);
Daniel Vetter47339cd2014-09-30 10:56:46 +020054 struct intel_crtc *crtc;
55 enum pipe pipe;
56
57 assert_spin_locked(&dev_priv->irq_lock);
58
59 for_each_pipe(dev_priv, pipe) {
Ville Syrjäläe2af48c2016-10-31 22:37:05 +020060 crtc = dev_priv->pipe_to_crtc_mapping[pipe];
Daniel Vetter47339cd2014-09-30 10:56:46 +020061
62 if (crtc->cpu_fifo_underrun_disabled)
63 return false;
64 }
65
66 return true;
67}
68
69static bool cpt_can_enable_serr_int(struct drm_device *dev)
70{
Chris Wilsonfac5e232016-07-04 11:34:36 +010071 struct drm_i915_private *dev_priv = to_i915(dev);
Daniel Vetter47339cd2014-09-30 10:56:46 +020072 enum pipe pipe;
73 struct intel_crtc *crtc;
74
75 assert_spin_locked(&dev_priv->irq_lock);
76
77 for_each_pipe(dev_priv, pipe) {
Ville Syrjäläe2af48c2016-10-31 22:37:05 +020078 crtc = dev_priv->pipe_to_crtc_mapping[pipe];
Daniel Vetter47339cd2014-09-30 10:56:46 +020079
80 if (crtc->pch_fifo_underrun_disabled)
81 return false;
82 }
83
84 return true;
85}
86
Ville Syrjäläaca7b682015-10-30 19:22:21 +020087static void i9xx_check_fifo_underruns(struct intel_crtc *crtc)
Daniel Vetter47339cd2014-09-30 10:56:46 +020088{
Ville Syrjäläaca7b682015-10-30 19:22:21 +020089 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
Ville Syrjäläf0f59a02015-11-18 15:33:26 +020090 i915_reg_t reg = PIPESTAT(crtc->pipe);
Ville Syrjäläaca7b682015-10-30 19:22:21 +020091 u32 pipestat = I915_READ(reg) & 0xffff0000;
Daniel Vetter47339cd2014-09-30 10:56:46 +020092
Ville Syrjäläaca7b682015-10-30 19:22:21 +020093 assert_spin_locked(&dev_priv->irq_lock);
Daniel Vetter47339cd2014-09-30 10:56:46 +020094
Ville Syrjäläaca7b682015-10-30 19:22:21 +020095 if ((pipestat & PIPE_FIFO_UNDERRUN_STATUS) == 0)
96 return;
Daniel Vetter47339cd2014-09-30 10:56:46 +020097
Ville Syrjäläaca7b682015-10-30 19:22:21 +020098 I915_WRITE(reg, pipestat | PIPE_FIFO_UNDERRUN_STATUS);
99 POSTING_READ(reg);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200100
Ville Syrjäläaca7b682015-10-30 19:22:21 +0200101 DRM_ERROR("pipe %c underrun\n", pipe_name(crtc->pipe));
Daniel Vetter47339cd2014-09-30 10:56:46 +0200102}
103
104static void i9xx_set_fifo_underrun_reporting(struct drm_device *dev,
105 enum pipe pipe,
106 bool enable, bool old)
107{
Chris Wilsonfac5e232016-07-04 11:34:36 +0100108 struct drm_i915_private *dev_priv = to_i915(dev);
Ville Syrjäläf0f59a02015-11-18 15:33:26 +0200109 i915_reg_t reg = PIPESTAT(pipe);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200110 u32 pipestat = I915_READ(reg) & 0xffff0000;
111
112 assert_spin_locked(&dev_priv->irq_lock);
113
114 if (enable) {
115 I915_WRITE(reg, pipestat | PIPE_FIFO_UNDERRUN_STATUS);
116 POSTING_READ(reg);
117 } else {
118 if (old && pipestat & PIPE_FIFO_UNDERRUN_STATUS)
119 DRM_ERROR("pipe %c underrun\n", pipe_name(pipe));
120 }
121}
122
123static void ironlake_set_fifo_underrun_reporting(struct drm_device *dev,
124 enum pipe pipe, bool enable)
125{
Chris Wilsonfac5e232016-07-04 11:34:36 +0100126 struct drm_i915_private *dev_priv = to_i915(dev);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200127 uint32_t bit = (pipe == PIPE_A) ? DE_PIPEA_FIFO_UNDERRUN :
128 DE_PIPEB_FIFO_UNDERRUN;
129
130 if (enable)
Ville Syrjäläfbdedaea2015-11-23 18:06:16 +0200131 ilk_enable_display_irq(dev_priv, bit);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200132 else
Ville Syrjäläfbdedaea2015-11-23 18:06:16 +0200133 ilk_disable_display_irq(dev_priv, bit);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200134}
135
Ville Syrjäläaca7b682015-10-30 19:22:21 +0200136static void ivybridge_check_fifo_underruns(struct intel_crtc *crtc)
137{
138 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
139 enum pipe pipe = crtc->pipe;
140 uint32_t err_int = I915_READ(GEN7_ERR_INT);
141
142 assert_spin_locked(&dev_priv->irq_lock);
143
144 if ((err_int & ERR_INT_FIFO_UNDERRUN(pipe)) == 0)
145 return;
146
147 I915_WRITE(GEN7_ERR_INT, ERR_INT_FIFO_UNDERRUN(pipe));
148 POSTING_READ(GEN7_ERR_INT);
149
150 DRM_ERROR("fifo underrun on pipe %c\n", pipe_name(pipe));
151}
152
Daniel Vetter47339cd2014-09-30 10:56:46 +0200153static void ivybridge_set_fifo_underrun_reporting(struct drm_device *dev,
154 enum pipe pipe,
155 bool enable, bool old)
156{
Chris Wilsonfac5e232016-07-04 11:34:36 +0100157 struct drm_i915_private *dev_priv = to_i915(dev);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200158 if (enable) {
159 I915_WRITE(GEN7_ERR_INT, ERR_INT_FIFO_UNDERRUN(pipe));
160
161 if (!ivb_can_enable_err_int(dev))
162 return;
163
Ville Syrjäläfbdedaea2015-11-23 18:06:16 +0200164 ilk_enable_display_irq(dev_priv, DE_ERR_INT_IVB);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200165 } else {
Ville Syrjäläfbdedaea2015-11-23 18:06:16 +0200166 ilk_disable_display_irq(dev_priv, DE_ERR_INT_IVB);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200167
168 if (old &&
169 I915_READ(GEN7_ERR_INT) & ERR_INT_FIFO_UNDERRUN(pipe)) {
170 DRM_ERROR("uncleared fifo underrun on pipe %c\n",
171 pipe_name(pipe));
172 }
173 }
174}
175
176static void broadwell_set_fifo_underrun_reporting(struct drm_device *dev,
177 enum pipe pipe, bool enable)
178{
Chris Wilsonfac5e232016-07-04 11:34:36 +0100179 struct drm_i915_private *dev_priv = to_i915(dev);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200180
Daniel Vetter47339cd2014-09-30 10:56:46 +0200181 if (enable)
Ville Syrjälä013d3752015-11-23 18:06:17 +0200182 bdw_enable_pipe_irq(dev_priv, pipe, GEN8_PIPE_FIFO_UNDERRUN);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200183 else
Ville Syrjälä013d3752015-11-23 18:06:17 +0200184 bdw_disable_pipe_irq(dev_priv, pipe, GEN8_PIPE_FIFO_UNDERRUN);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200185}
186
187static void ibx_set_fifo_underrun_reporting(struct drm_device *dev,
188 enum transcoder pch_transcoder,
189 bool enable)
190{
Chris Wilsonfac5e232016-07-04 11:34:36 +0100191 struct drm_i915_private *dev_priv = to_i915(dev);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200192 uint32_t bit = (pch_transcoder == TRANSCODER_A) ?
193 SDE_TRANSA_FIFO_UNDER : SDE_TRANSB_FIFO_UNDER;
194
195 if (enable)
196 ibx_enable_display_interrupt(dev_priv, bit);
197 else
198 ibx_disable_display_interrupt(dev_priv, bit);
199}
200
Ville Syrjäläaca7b682015-10-30 19:22:21 +0200201static void cpt_check_pch_fifo_underruns(struct intel_crtc *crtc)
202{
203 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
204 enum transcoder pch_transcoder = (enum transcoder) crtc->pipe;
205 uint32_t serr_int = I915_READ(SERR_INT);
206
207 assert_spin_locked(&dev_priv->irq_lock);
208
209 if ((serr_int & SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder)) == 0)
210 return;
211
212 I915_WRITE(SERR_INT, SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder));
213 POSTING_READ(SERR_INT);
214
Jani Nikulada205632016-03-15 21:51:10 +0200215 DRM_ERROR("pch fifo underrun on pch transcoder %s\n",
Ville Syrjäläaca7b682015-10-30 19:22:21 +0200216 transcoder_name(pch_transcoder));
217}
218
Daniel Vetter47339cd2014-09-30 10:56:46 +0200219static void cpt_set_fifo_underrun_reporting(struct drm_device *dev,
220 enum transcoder pch_transcoder,
221 bool enable, bool old)
222{
Chris Wilsonfac5e232016-07-04 11:34:36 +0100223 struct drm_i915_private *dev_priv = to_i915(dev);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200224
225 if (enable) {
226 I915_WRITE(SERR_INT,
227 SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder));
228
229 if (!cpt_can_enable_serr_int(dev))
230 return;
231
232 ibx_enable_display_interrupt(dev_priv, SDE_ERROR_CPT);
233 } else {
234 ibx_disable_display_interrupt(dev_priv, SDE_ERROR_CPT);
235
236 if (old && I915_READ(SERR_INT) &
237 SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder)) {
Jani Nikulada205632016-03-15 21:51:10 +0200238 DRM_ERROR("uncleared pch fifo underrun on pch transcoder %s\n",
Daniel Vetter47339cd2014-09-30 10:56:46 +0200239 transcoder_name(pch_transcoder));
240 }
241 }
242}
243
Daniel Vetter47339cd2014-09-30 10:56:46 +0200244static bool __intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
245 enum pipe pipe, bool enable)
246{
Chris Wilsonfac5e232016-07-04 11:34:36 +0100247 struct drm_i915_private *dev_priv = to_i915(dev);
Ville Syrjäläe2af48c2016-10-31 22:37:05 +0200248 struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
Daniel Vetter47339cd2014-09-30 10:56:46 +0200249 bool old;
250
251 assert_spin_locked(&dev_priv->irq_lock);
252
Ville Syrjäläe2af48c2016-10-31 22:37:05 +0200253 old = !crtc->cpu_fifo_underrun_disabled;
254 crtc->cpu_fifo_underrun_disabled = !enable;
Daniel Vetter47339cd2014-09-30 10:56:46 +0200255
Tvrtko Ursulin49cff962016-10-13 11:02:54 +0100256 if (HAS_GMCH_DISPLAY(dev_priv))
Daniel Vetter47339cd2014-09-30 10:56:46 +0200257 i9xx_set_fifo_underrun_reporting(dev, pipe, enable, old);
Tvrtko Ursulin5db94012016-10-13 11:03:10 +0100258 else if (IS_GEN5(dev_priv) || IS_GEN6(dev_priv))
Daniel Vetter47339cd2014-09-30 10:56:46 +0200259 ironlake_set_fifo_underrun_reporting(dev, pipe, enable);
Tvrtko Ursulin5db94012016-10-13 11:03:10 +0100260 else if (IS_GEN7(dev_priv))
Daniel Vetter47339cd2014-09-30 10:56:46 +0200261 ivybridge_set_fifo_underrun_reporting(dev, pipe, enable, old);
Tvrtko Ursulin5db94012016-10-13 11:03:10 +0100262 else if (IS_GEN8(dev_priv) || IS_GEN9(dev_priv))
Daniel Vetter47339cd2014-09-30 10:56:46 +0200263 broadwell_set_fifo_underrun_reporting(dev, pipe, enable);
264
265 return old;
266}
267
Daniel Vetteref073882014-09-30 10:56:50 +0200268/**
269 * intel_set_cpu_fifo_underrun_reporting - set cpu fifo underrrun reporting state
270 * @dev_priv: i915 device instance
271 * @pipe: (CPU) pipe to set state for
272 * @enable: whether underruns should be reported or not
273 *
274 * This function sets the fifo underrun state for @pipe. It is used in the
275 * modeset code to avoid false positives since on many platforms underruns are
276 * expected when disabling or enabling the pipe.
277 *
278 * Notice that on some platforms disabling underrun reports for one pipe
279 * disables for all due to shared interrupts. Actual reporting is still per-pipe
280 * though.
281 *
282 * Returns the previous state of underrun reporting.
283 */
Daniel Vettera72e4c92014-09-30 10:56:47 +0200284bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
Daniel Vetter47339cd2014-09-30 10:56:46 +0200285 enum pipe pipe, bool enable)
286{
Daniel Vetter47339cd2014-09-30 10:56:46 +0200287 unsigned long flags;
288 bool ret;
289
290 spin_lock_irqsave(&dev_priv->irq_lock, flags);
Chris Wilson91c8a322016-07-05 10:40:23 +0100291 ret = __intel_set_cpu_fifo_underrun_reporting(&dev_priv->drm, pipe,
Daniel Vettera72e4c92014-09-30 10:56:47 +0200292 enable);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200293 spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
294
295 return ret;
296}
297
Daniel Vetter47339cd2014-09-30 10:56:46 +0200298/**
Daniel Vetteref073882014-09-30 10:56:50 +0200299 * intel_set_pch_fifo_underrun_reporting - set PCH fifo underrun reporting state
300 * @dev_priv: i915 device instance
Daniel Vetter47339cd2014-09-30 10:56:46 +0200301 * @pch_transcoder: the PCH transcoder (same as pipe on IVB and older)
Daniel Vetteref073882014-09-30 10:56:50 +0200302 * @enable: whether underruns should be reported or not
Daniel Vetter47339cd2014-09-30 10:56:46 +0200303 *
304 * This function makes us disable or enable PCH fifo underruns for a specific
305 * PCH transcoder. Notice that on some PCHs (e.g. CPT/PPT), disabling FIFO
306 * underrun reporting for one transcoder may also disable all the other PCH
307 * error interruts for the other transcoders, due to the fact that there's just
308 * one interrupt mask/enable bit for all the transcoders.
309 *
310 * Returns the previous state of underrun reporting.
311 */
Daniel Vettera72e4c92014-09-30 10:56:47 +0200312bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
Daniel Vetter47339cd2014-09-30 10:56:46 +0200313 enum transcoder pch_transcoder,
314 bool enable)
315{
Ville Syrjäläe2af48c2016-10-31 22:37:05 +0200316 struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pch_transcoder];
Daniel Vetter47339cd2014-09-30 10:56:46 +0200317 unsigned long flags;
318 bool old;
319
320 /*
321 * NOTE: Pre-LPT has a fixed cpu pipe -> pch transcoder mapping, but LPT
322 * has only one pch transcoder A that all pipes can use. To avoid racy
323 * pch transcoder -> pipe lookups from interrupt code simply store the
324 * underrun statistics in crtc A. Since we never expose this anywhere
325 * nor use it outside of the fifo underrun code here using the "wrong"
326 * crtc on LPT won't cause issues.
327 */
328
329 spin_lock_irqsave(&dev_priv->irq_lock, flags);
330
Ville Syrjäläe2af48c2016-10-31 22:37:05 +0200331 old = !crtc->pch_fifo_underrun_disabled;
332 crtc->pch_fifo_underrun_disabled = !enable;
Daniel Vetter47339cd2014-09-30 10:56:46 +0200333
Joonas Lahtinen2d1fe072016-04-07 11:08:05 +0300334 if (HAS_PCH_IBX(dev_priv))
Chris Wilson91c8a322016-07-05 10:40:23 +0100335 ibx_set_fifo_underrun_reporting(&dev_priv->drm,
336 pch_transcoder,
Daniel Vettera72e4c92014-09-30 10:56:47 +0200337 enable);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200338 else
Chris Wilson91c8a322016-07-05 10:40:23 +0100339 cpt_set_fifo_underrun_reporting(&dev_priv->drm,
340 pch_transcoder,
Daniel Vettera72e4c92014-09-30 10:56:47 +0200341 enable, old);
Daniel Vetter47339cd2014-09-30 10:56:46 +0200342
343 spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
344 return old;
345}
Daniel Vetter1f7247c2014-09-30 10:56:48 +0200346
Daniel Vetteref073882014-09-30 10:56:50 +0200347/**
Kumar Amit Mehtacea3bf82015-01-26 17:47:32 +0100348 * intel_cpu_fifo_underrun_irq_handler - handle CPU fifo underrun interrupt
Daniel Vetteref073882014-09-30 10:56:50 +0200349 * @dev_priv: i915 device instance
350 * @pipe: (CPU) pipe to set state for
351 *
352 * This handles a CPU fifo underrun interrupt, generating an underrun warning
353 * into dmesg if underrun reporting is enabled and then disables the underrun
354 * interrupt to avoid an irq storm.
355 */
Daniel Vetter1f7247c2014-09-30 10:56:48 +0200356void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
357 enum pipe pipe)
358{
Ville Syrjäläe2af48c2016-10-31 22:37:05 +0200359 struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
Chris Wilson54fc7c12015-02-26 15:53:02 +0000360
361 /* We may be called too early in init, thanks BIOS! */
362 if (crtc == NULL)
363 return;
364
Daniel Vetter0f239f42014-09-30 10:56:49 +0200365 /* GMCH can't disable fifo underruns, filter them. */
Joonas Lahtinen2d1fe072016-04-07 11:08:05 +0300366 if (HAS_GMCH_DISPLAY(dev_priv) &&
Ville Syrjäläe2af48c2016-10-31 22:37:05 +0200367 crtc->cpu_fifo_underrun_disabled)
Daniel Vetter0f239f42014-09-30 10:56:49 +0200368 return;
369
Daniel Vetter1f7247c2014-09-30 10:56:48 +0200370 if (intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false))
371 DRM_ERROR("CPU pipe %c FIFO underrun\n",
372 pipe_name(pipe));
Paulo Zanoni61a585d2016-09-13 10:38:57 -0300373
374 intel_fbc_handle_fifo_underrun_irq(dev_priv);
Daniel Vetter1f7247c2014-09-30 10:56:48 +0200375}
376
Daniel Vetteref073882014-09-30 10:56:50 +0200377/**
378 * intel_pch_fifo_underrun_irq_handler - handle PCH fifo underrun interrupt
379 * @dev_priv: i915 device instance
380 * @pch_transcoder: the PCH transcoder (same as pipe on IVB and older)
381 *
382 * This handles a PCH fifo underrun interrupt, generating an underrun warning
383 * into dmesg if underrun reporting is enabled and then disables the underrun
384 * interrupt to avoid an irq storm.
385 */
Daniel Vetter1f7247c2014-09-30 10:56:48 +0200386void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
387 enum transcoder pch_transcoder)
388{
389 if (intel_set_pch_fifo_underrun_reporting(dev_priv, pch_transcoder,
390 false))
Jani Nikulada205632016-03-15 21:51:10 +0200391 DRM_ERROR("PCH transcoder %s FIFO underrun\n",
Daniel Vetter1f7247c2014-09-30 10:56:48 +0200392 transcoder_name(pch_transcoder));
393}
Ville Syrjäläaca7b682015-10-30 19:22:21 +0200394
395/**
396 * intel_check_cpu_fifo_underruns - check for CPU fifo underruns immediately
397 * @dev_priv: i915 device instance
398 *
399 * Check for CPU fifo underruns immediately. Useful on IVB/HSW where the shared
400 * error interrupt may have been disabled, and so CPU fifo underruns won't
401 * necessarily raise an interrupt, and on GMCH platforms where underruns never
402 * raise an interrupt.
403 */
404void intel_check_cpu_fifo_underruns(struct drm_i915_private *dev_priv)
405{
406 struct intel_crtc *crtc;
407
408 spin_lock_irq(&dev_priv->irq_lock);
409
Chris Wilson91c8a322016-07-05 10:40:23 +0100410 for_each_intel_crtc(&dev_priv->drm, crtc) {
Ville Syrjäläaca7b682015-10-30 19:22:21 +0200411 if (crtc->cpu_fifo_underrun_disabled)
412 continue;
413
414 if (HAS_GMCH_DISPLAY(dev_priv))
415 i9xx_check_fifo_underruns(crtc);
416 else if (IS_GEN7(dev_priv))
417 ivybridge_check_fifo_underruns(crtc);
418 }
419
420 spin_unlock_irq(&dev_priv->irq_lock);
421}
422
423/**
424 * intel_check_pch_fifo_underruns - check for PCH fifo underruns immediately
425 * @dev_priv: i915 device instance
426 *
427 * Check for PCH fifo underruns immediately. Useful on CPT/PPT where the shared
428 * error interrupt may have been disabled, and so PCH fifo underruns won't
429 * necessarily raise an interrupt.
430 */
431void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv)
432{
433 struct intel_crtc *crtc;
434
435 spin_lock_irq(&dev_priv->irq_lock);
436
Chris Wilson91c8a322016-07-05 10:40:23 +0100437 for_each_intel_crtc(&dev_priv->drm, crtc) {
Ville Syrjäläaca7b682015-10-30 19:22:21 +0200438 if (crtc->pch_fifo_underrun_disabled)
439 continue;
440
441 if (HAS_PCH_CPT(dev_priv))
442 cpt_check_pch_fifo_underruns(crtc);
443 }
444
445 spin_unlock_irq(&dev_priv->irq_lock);
446}