Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 1 | /* |
| 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 Vetter | ef07388 | 2014-09-30 10:56:50 +0200 | [diff] [blame] | 31 | /** |
| 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 Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 51 | static bool ivb_can_enable_err_int(struct drm_device *dev) |
| 52 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 53 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 54 | struct intel_crtc *crtc; |
| 55 | enum pipe pipe; |
| 56 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 57 | lockdep_assert_held(&dev_priv->irq_lock); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 58 | |
| 59 | for_each_pipe(dev_priv, pipe) { |
Ville Syrjälä | 9818783 | 2016-10-31 22:37:10 +0200 | [diff] [blame] | 60 | crtc = intel_get_crtc_for_pipe(dev_priv, pipe); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 61 | |
| 62 | if (crtc->cpu_fifo_underrun_disabled) |
| 63 | return false; |
| 64 | } |
| 65 | |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | static bool cpt_can_enable_serr_int(struct drm_device *dev) |
| 70 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 71 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 72 | enum pipe pipe; |
| 73 | struct intel_crtc *crtc; |
| 74 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 75 | lockdep_assert_held(&dev_priv->irq_lock); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 76 | |
| 77 | for_each_pipe(dev_priv, pipe) { |
Ville Syrjälä | 9818783 | 2016-10-31 22:37:10 +0200 | [diff] [blame] | 78 | crtc = intel_get_crtc_for_pipe(dev_priv, pipe); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 79 | |
| 80 | if (crtc->pch_fifo_underrun_disabled) |
| 81 | return false; |
| 82 | } |
| 83 | |
| 84 | return true; |
| 85 | } |
| 86 | |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 87 | static void i9xx_check_fifo_underruns(struct intel_crtc *crtc) |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 88 | { |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 89 | struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 90 | i915_reg_t reg = PIPESTAT(crtc->pipe); |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 91 | u32 enable_mask; |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 92 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 93 | lockdep_assert_held(&dev_priv->irq_lock); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 94 | |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 95 | if ((I915_READ(reg) & PIPE_FIFO_UNDERRUN_STATUS) == 0) |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 96 | return; |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 97 | |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 98 | enable_mask = i915_pipestat_enable_mask(dev_priv, crtc->pipe); |
| 99 | I915_WRITE(reg, enable_mask | PIPE_FIFO_UNDERRUN_STATUS); |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 100 | POSTING_READ(reg); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 101 | |
Ville Syrjälä | 53a7915 | 2017-03-02 19:15:08 +0200 | [diff] [blame] | 102 | trace_intel_cpu_fifo_underrun(dev_priv, crtc->pipe); |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 103 | DRM_ERROR("pipe %c underrun\n", pipe_name(crtc->pipe)); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | static void i9xx_set_fifo_underrun_reporting(struct drm_device *dev, |
| 107 | enum pipe pipe, |
| 108 | bool enable, bool old) |
| 109 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 110 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 111 | i915_reg_t reg = PIPESTAT(pipe); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 112 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 113 | lockdep_assert_held(&dev_priv->irq_lock); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 114 | |
| 115 | if (enable) { |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 116 | u32 enable_mask = i915_pipestat_enable_mask(dev_priv, pipe); |
| 117 | |
| 118 | I915_WRITE(reg, enable_mask | PIPE_FIFO_UNDERRUN_STATUS); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 119 | POSTING_READ(reg); |
| 120 | } else { |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 121 | if (old && I915_READ(reg) & PIPE_FIFO_UNDERRUN_STATUS) |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 122 | DRM_ERROR("pipe %c underrun\n", pipe_name(pipe)); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | static void ironlake_set_fifo_underrun_reporting(struct drm_device *dev, |
| 127 | enum pipe pipe, bool enable) |
| 128 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 129 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 130 | uint32_t bit = (pipe == PIPE_A) ? DE_PIPEA_FIFO_UNDERRUN : |
| 131 | DE_PIPEB_FIFO_UNDERRUN; |
| 132 | |
| 133 | if (enable) |
Ville Syrjälä | fbdedaea | 2015-11-23 18:06:16 +0200 | [diff] [blame] | 134 | ilk_enable_display_irq(dev_priv, bit); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 135 | else |
Ville Syrjälä | fbdedaea | 2015-11-23 18:06:16 +0200 | [diff] [blame] | 136 | ilk_disable_display_irq(dev_priv, bit); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 137 | } |
| 138 | |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 139 | static void ivybridge_check_fifo_underruns(struct intel_crtc *crtc) |
| 140 | { |
| 141 | struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
| 142 | enum pipe pipe = crtc->pipe; |
| 143 | uint32_t err_int = I915_READ(GEN7_ERR_INT); |
| 144 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 145 | lockdep_assert_held(&dev_priv->irq_lock); |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 146 | |
| 147 | if ((err_int & ERR_INT_FIFO_UNDERRUN(pipe)) == 0) |
| 148 | return; |
| 149 | |
| 150 | I915_WRITE(GEN7_ERR_INT, ERR_INT_FIFO_UNDERRUN(pipe)); |
| 151 | POSTING_READ(GEN7_ERR_INT); |
| 152 | |
Ville Syrjälä | 53a7915 | 2017-03-02 19:15:08 +0200 | [diff] [blame] | 153 | trace_intel_cpu_fifo_underrun(dev_priv, pipe); |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 154 | DRM_ERROR("fifo underrun on pipe %c\n", pipe_name(pipe)); |
| 155 | } |
| 156 | |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 157 | static void ivybridge_set_fifo_underrun_reporting(struct drm_device *dev, |
| 158 | enum pipe pipe, |
| 159 | bool enable, bool old) |
| 160 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 161 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 162 | if (enable) { |
| 163 | I915_WRITE(GEN7_ERR_INT, ERR_INT_FIFO_UNDERRUN(pipe)); |
| 164 | |
| 165 | if (!ivb_can_enable_err_int(dev)) |
| 166 | return; |
| 167 | |
Ville Syrjälä | fbdedaea | 2015-11-23 18:06:16 +0200 | [diff] [blame] | 168 | ilk_enable_display_irq(dev_priv, DE_ERR_INT_IVB); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 169 | } else { |
Ville Syrjälä | fbdedaea | 2015-11-23 18:06:16 +0200 | [diff] [blame] | 170 | ilk_disable_display_irq(dev_priv, DE_ERR_INT_IVB); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 171 | |
| 172 | if (old && |
| 173 | I915_READ(GEN7_ERR_INT) & ERR_INT_FIFO_UNDERRUN(pipe)) { |
| 174 | DRM_ERROR("uncleared fifo underrun on pipe %c\n", |
| 175 | pipe_name(pipe)); |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | static void broadwell_set_fifo_underrun_reporting(struct drm_device *dev, |
| 181 | enum pipe pipe, bool enable) |
| 182 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 183 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 184 | |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 185 | if (enable) |
Ville Syrjälä | 013d375 | 2015-11-23 18:06:17 +0200 | [diff] [blame] | 186 | bdw_enable_pipe_irq(dev_priv, pipe, GEN8_PIPE_FIFO_UNDERRUN); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 187 | else |
Ville Syrjälä | 013d375 | 2015-11-23 18:06:17 +0200 | [diff] [blame] | 188 | bdw_disable_pipe_irq(dev_priv, pipe, GEN8_PIPE_FIFO_UNDERRUN); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | static void ibx_set_fifo_underrun_reporting(struct drm_device *dev, |
Ville Syrjälä | 41c32e5d | 2017-09-01 17:31:23 +0300 | [diff] [blame] | 192 | enum pipe pch_transcoder, |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 193 | bool enable) |
| 194 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 195 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 41c32e5d | 2017-09-01 17:31:23 +0300 | [diff] [blame] | 196 | uint32_t bit = (pch_transcoder == PIPE_A) ? |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 197 | SDE_TRANSA_FIFO_UNDER : SDE_TRANSB_FIFO_UNDER; |
| 198 | |
| 199 | if (enable) |
| 200 | ibx_enable_display_interrupt(dev_priv, bit); |
| 201 | else |
| 202 | ibx_disable_display_interrupt(dev_priv, bit); |
| 203 | } |
| 204 | |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 205 | static void cpt_check_pch_fifo_underruns(struct intel_crtc *crtc) |
| 206 | { |
| 207 | struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
Ville Syrjälä | 41c32e5d | 2017-09-01 17:31:23 +0300 | [diff] [blame] | 208 | enum pipe pch_transcoder = crtc->pipe; |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 209 | uint32_t serr_int = I915_READ(SERR_INT); |
| 210 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 211 | lockdep_assert_held(&dev_priv->irq_lock); |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 212 | |
| 213 | if ((serr_int & SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder)) == 0) |
| 214 | return; |
| 215 | |
| 216 | I915_WRITE(SERR_INT, SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder)); |
| 217 | POSTING_READ(SERR_INT); |
| 218 | |
Ville Syrjälä | 53a7915 | 2017-03-02 19:15:08 +0200 | [diff] [blame] | 219 | trace_intel_pch_fifo_underrun(dev_priv, pch_transcoder); |
Ville Syrjälä | 41c32e5d | 2017-09-01 17:31:23 +0300 | [diff] [blame] | 220 | DRM_ERROR("pch fifo underrun on pch transcoder %c\n", |
| 221 | pipe_name(pch_transcoder)); |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 222 | } |
| 223 | |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 224 | static void cpt_set_fifo_underrun_reporting(struct drm_device *dev, |
Ville Syrjälä | 41c32e5d | 2017-09-01 17:31:23 +0300 | [diff] [blame] | 225 | enum pipe pch_transcoder, |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 226 | bool enable, bool old) |
| 227 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 228 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 229 | |
| 230 | if (enable) { |
| 231 | I915_WRITE(SERR_INT, |
| 232 | SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder)); |
| 233 | |
| 234 | if (!cpt_can_enable_serr_int(dev)) |
| 235 | return; |
| 236 | |
| 237 | ibx_enable_display_interrupt(dev_priv, SDE_ERROR_CPT); |
| 238 | } else { |
| 239 | ibx_disable_display_interrupt(dev_priv, SDE_ERROR_CPT); |
| 240 | |
| 241 | if (old && I915_READ(SERR_INT) & |
| 242 | SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder)) { |
Ville Syrjälä | 41c32e5d | 2017-09-01 17:31:23 +0300 | [diff] [blame] | 243 | DRM_ERROR("uncleared pch fifo underrun on pch transcoder %c\n", |
| 244 | pipe_name(pch_transcoder)); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 245 | } |
| 246 | } |
| 247 | } |
| 248 | |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 249 | static bool __intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev, |
| 250 | enum pipe pipe, bool enable) |
| 251 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 252 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 9818783 | 2016-10-31 22:37:10 +0200 | [diff] [blame] | 253 | struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 254 | bool old; |
| 255 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 256 | lockdep_assert_held(&dev_priv->irq_lock); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 257 | |
Ville Syrjälä | e2af48c | 2016-10-31 22:37:05 +0200 | [diff] [blame] | 258 | old = !crtc->cpu_fifo_underrun_disabled; |
| 259 | crtc->cpu_fifo_underrun_disabled = !enable; |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 260 | |
Tvrtko Ursulin | 49cff96 | 2016-10-13 11:02:54 +0100 | [diff] [blame] | 261 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 262 | i9xx_set_fifo_underrun_reporting(dev, pipe, enable, old); |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 263 | else if (IS_GEN5(dev_priv) || IS_GEN6(dev_priv)) |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 264 | ironlake_set_fifo_underrun_reporting(dev, pipe, enable); |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 265 | else if (IS_GEN7(dev_priv)) |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 266 | ivybridge_set_fifo_underrun_reporting(dev, pipe, enable, old); |
Rodrigo Vivi | 4efa16c | 2017-06-09 15:26:13 -0700 | [diff] [blame] | 267 | else if (INTEL_GEN(dev_priv) >= 8) |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 268 | broadwell_set_fifo_underrun_reporting(dev, pipe, enable); |
| 269 | |
| 270 | return old; |
| 271 | } |
| 272 | |
Daniel Vetter | ef07388 | 2014-09-30 10:56:50 +0200 | [diff] [blame] | 273 | /** |
| 274 | * intel_set_cpu_fifo_underrun_reporting - set cpu fifo underrrun reporting state |
| 275 | * @dev_priv: i915 device instance |
| 276 | * @pipe: (CPU) pipe to set state for |
| 277 | * @enable: whether underruns should be reported or not |
| 278 | * |
| 279 | * This function sets the fifo underrun state for @pipe. It is used in the |
| 280 | * modeset code to avoid false positives since on many platforms underruns are |
| 281 | * expected when disabling or enabling the pipe. |
| 282 | * |
| 283 | * Notice that on some platforms disabling underrun reports for one pipe |
| 284 | * disables for all due to shared interrupts. Actual reporting is still per-pipe |
| 285 | * though. |
| 286 | * |
| 287 | * Returns the previous state of underrun reporting. |
| 288 | */ |
Daniel Vetter | a72e4c9 | 2014-09-30 10:56:47 +0200 | [diff] [blame] | 289 | bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv, |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 290 | enum pipe pipe, bool enable) |
| 291 | { |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 292 | unsigned long flags; |
| 293 | bool ret; |
| 294 | |
| 295 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 296 | ret = __intel_set_cpu_fifo_underrun_reporting(&dev_priv->drm, pipe, |
Daniel Vetter | a72e4c9 | 2014-09-30 10:56:47 +0200 | [diff] [blame] | 297 | enable); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 298 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
| 299 | |
| 300 | return ret; |
| 301 | } |
| 302 | |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 303 | /** |
Daniel Vetter | ef07388 | 2014-09-30 10:56:50 +0200 | [diff] [blame] | 304 | * intel_set_pch_fifo_underrun_reporting - set PCH fifo underrun reporting state |
| 305 | * @dev_priv: i915 device instance |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 306 | * @pch_transcoder: the PCH transcoder (same as pipe on IVB and older) |
Daniel Vetter | ef07388 | 2014-09-30 10:56:50 +0200 | [diff] [blame] | 307 | * @enable: whether underruns should be reported or not |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 308 | * |
| 309 | * This function makes us disable or enable PCH fifo underruns for a specific |
| 310 | * PCH transcoder. Notice that on some PCHs (e.g. CPT/PPT), disabling FIFO |
| 311 | * underrun reporting for one transcoder may also disable all the other PCH |
| 312 | * error interruts for the other transcoders, due to the fact that there's just |
| 313 | * one interrupt mask/enable bit for all the transcoders. |
| 314 | * |
| 315 | * Returns the previous state of underrun reporting. |
| 316 | */ |
Daniel Vetter | a72e4c9 | 2014-09-30 10:56:47 +0200 | [diff] [blame] | 317 | bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv, |
Matthias Kaehlcke | a219603 | 2017-07-17 11:14:03 -0700 | [diff] [blame] | 318 | enum pipe pch_transcoder, |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 319 | bool enable) |
| 320 | { |
Ville Syrjälä | 9818783 | 2016-10-31 22:37:10 +0200 | [diff] [blame] | 321 | struct intel_crtc *crtc = |
Matthias Kaehlcke | a219603 | 2017-07-17 11:14:03 -0700 | [diff] [blame] | 322 | intel_get_crtc_for_pipe(dev_priv, pch_transcoder); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 323 | unsigned long flags; |
| 324 | bool old; |
| 325 | |
| 326 | /* |
| 327 | * NOTE: Pre-LPT has a fixed cpu pipe -> pch transcoder mapping, but LPT |
| 328 | * has only one pch transcoder A that all pipes can use. To avoid racy |
| 329 | * pch transcoder -> pipe lookups from interrupt code simply store the |
| 330 | * underrun statistics in crtc A. Since we never expose this anywhere |
| 331 | * nor use it outside of the fifo underrun code here using the "wrong" |
| 332 | * crtc on LPT won't cause issues. |
| 333 | */ |
| 334 | |
| 335 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
| 336 | |
Ville Syrjälä | e2af48c | 2016-10-31 22:37:05 +0200 | [diff] [blame] | 337 | old = !crtc->pch_fifo_underrun_disabled; |
| 338 | crtc->pch_fifo_underrun_disabled = !enable; |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 339 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 340 | if (HAS_PCH_IBX(dev_priv)) |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 341 | ibx_set_fifo_underrun_reporting(&dev_priv->drm, |
| 342 | pch_transcoder, |
Daniel Vetter | a72e4c9 | 2014-09-30 10:56:47 +0200 | [diff] [blame] | 343 | enable); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 344 | else |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 345 | cpt_set_fifo_underrun_reporting(&dev_priv->drm, |
| 346 | pch_transcoder, |
Daniel Vetter | a72e4c9 | 2014-09-30 10:56:47 +0200 | [diff] [blame] | 347 | enable, old); |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 348 | |
| 349 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
| 350 | return old; |
| 351 | } |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 352 | |
Daniel Vetter | ef07388 | 2014-09-30 10:56:50 +0200 | [diff] [blame] | 353 | /** |
Kumar Amit Mehta | cea3bf8 | 2015-01-26 17:47:32 +0100 | [diff] [blame] | 354 | * intel_cpu_fifo_underrun_irq_handler - handle CPU fifo underrun interrupt |
Daniel Vetter | ef07388 | 2014-09-30 10:56:50 +0200 | [diff] [blame] | 355 | * @dev_priv: i915 device instance |
| 356 | * @pipe: (CPU) pipe to set state for |
| 357 | * |
| 358 | * This handles a CPU fifo underrun interrupt, generating an underrun warning |
| 359 | * into dmesg if underrun reporting is enabled and then disables the underrun |
| 360 | * interrupt to avoid an irq storm. |
| 361 | */ |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 362 | void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv, |
| 363 | enum pipe pipe) |
| 364 | { |
Ville Syrjälä | 9818783 | 2016-10-31 22:37:10 +0200 | [diff] [blame] | 365 | struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe); |
Chris Wilson | 54fc7c1 | 2015-02-26 15:53:02 +0000 | [diff] [blame] | 366 | |
| 367 | /* We may be called too early in init, thanks BIOS! */ |
| 368 | if (crtc == NULL) |
| 369 | return; |
| 370 | |
Daniel Vetter | 0f239f4 | 2014-09-30 10:56:49 +0200 | [diff] [blame] | 371 | /* GMCH can't disable fifo underruns, filter them. */ |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 372 | if (HAS_GMCH_DISPLAY(dev_priv) && |
Ville Syrjälä | e2af48c | 2016-10-31 22:37:05 +0200 | [diff] [blame] | 373 | crtc->cpu_fifo_underrun_disabled) |
Daniel Vetter | 0f239f4 | 2014-09-30 10:56:49 +0200 | [diff] [blame] | 374 | return; |
| 375 | |
Ville Syrjälä | 53a7915 | 2017-03-02 19:15:08 +0200 | [diff] [blame] | 376 | if (intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false)) { |
| 377 | trace_intel_cpu_fifo_underrun(dev_priv, pipe); |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 378 | DRM_ERROR("CPU pipe %c FIFO underrun\n", |
| 379 | pipe_name(pipe)); |
Ville Syrjälä | 53a7915 | 2017-03-02 19:15:08 +0200 | [diff] [blame] | 380 | } |
Paulo Zanoni | 61a585d | 2016-09-13 10:38:57 -0300 | [diff] [blame] | 381 | |
| 382 | intel_fbc_handle_fifo_underrun_irq(dev_priv); |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 383 | } |
| 384 | |
Daniel Vetter | ef07388 | 2014-09-30 10:56:50 +0200 | [diff] [blame] | 385 | /** |
| 386 | * intel_pch_fifo_underrun_irq_handler - handle PCH fifo underrun interrupt |
| 387 | * @dev_priv: i915 device instance |
| 388 | * @pch_transcoder: the PCH transcoder (same as pipe on IVB and older) |
| 389 | * |
| 390 | * This handles a PCH fifo underrun interrupt, generating an underrun warning |
| 391 | * into dmesg if underrun reporting is enabled and then disables the underrun |
| 392 | * interrupt to avoid an irq storm. |
| 393 | */ |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 394 | void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv, |
Matthias Kaehlcke | a219603 | 2017-07-17 11:14:03 -0700 | [diff] [blame] | 395 | enum pipe pch_transcoder) |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 396 | { |
| 397 | if (intel_set_pch_fifo_underrun_reporting(dev_priv, pch_transcoder, |
Ville Syrjälä | 53a7915 | 2017-03-02 19:15:08 +0200 | [diff] [blame] | 398 | false)) { |
| 399 | trace_intel_pch_fifo_underrun(dev_priv, pch_transcoder); |
Ville Syrjälä | 41c32e5d | 2017-09-01 17:31:23 +0300 | [diff] [blame] | 400 | DRM_ERROR("PCH transcoder %c FIFO underrun\n", |
| 401 | pipe_name(pch_transcoder)); |
Ville Syrjälä | 53a7915 | 2017-03-02 19:15:08 +0200 | [diff] [blame] | 402 | } |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 403 | } |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 404 | |
| 405 | /** |
| 406 | * intel_check_cpu_fifo_underruns - check for CPU fifo underruns immediately |
| 407 | * @dev_priv: i915 device instance |
| 408 | * |
| 409 | * Check for CPU fifo underruns immediately. Useful on IVB/HSW where the shared |
| 410 | * error interrupt may have been disabled, and so CPU fifo underruns won't |
| 411 | * necessarily raise an interrupt, and on GMCH platforms where underruns never |
| 412 | * raise an interrupt. |
| 413 | */ |
| 414 | void intel_check_cpu_fifo_underruns(struct drm_i915_private *dev_priv) |
| 415 | { |
| 416 | struct intel_crtc *crtc; |
| 417 | |
| 418 | spin_lock_irq(&dev_priv->irq_lock); |
| 419 | |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 420 | for_each_intel_crtc(&dev_priv->drm, crtc) { |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 421 | if (crtc->cpu_fifo_underrun_disabled) |
| 422 | continue; |
| 423 | |
| 424 | if (HAS_GMCH_DISPLAY(dev_priv)) |
| 425 | i9xx_check_fifo_underruns(crtc); |
| 426 | else if (IS_GEN7(dev_priv)) |
| 427 | ivybridge_check_fifo_underruns(crtc); |
| 428 | } |
| 429 | |
| 430 | spin_unlock_irq(&dev_priv->irq_lock); |
| 431 | } |
| 432 | |
| 433 | /** |
| 434 | * intel_check_pch_fifo_underruns - check for PCH fifo underruns immediately |
| 435 | * @dev_priv: i915 device instance |
| 436 | * |
| 437 | * Check for PCH fifo underruns immediately. Useful on CPT/PPT where the shared |
| 438 | * error interrupt may have been disabled, and so PCH fifo underruns won't |
| 439 | * necessarily raise an interrupt. |
| 440 | */ |
| 441 | void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv) |
| 442 | { |
| 443 | struct intel_crtc *crtc; |
| 444 | |
| 445 | spin_lock_irq(&dev_priv->irq_lock); |
| 446 | |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 447 | for_each_intel_crtc(&dev_priv->drm, crtc) { |
Ville Syrjälä | aca7b68 | 2015-10-30 19:22:21 +0200 | [diff] [blame] | 448 | if (crtc->pch_fifo_underrun_disabled) |
| 449 | continue; |
| 450 | |
| 451 | if (HAS_PCH_CPT(dev_priv)) |
| 452 | cpt_check_pch_fifo_underruns(crtc); |
| 453 | } |
| 454 | |
| 455 | spin_unlock_irq(&dev_priv->irq_lock); |
| 456 | } |