Dave Airlie | 0d6aa60 | 2006-01-02 20:14:23 +1100 | [diff] [blame] | 1 | /* i915_irq.c -- IRQ support for the I915 -*- linux-c -*- |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | */ |
Dave Airlie | 0d6aa60 | 2006-01-02 20:14:23 +1100 | [diff] [blame] | 3 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. |
| 5 | * All Rights Reserved. |
Dave Airlie | bc54fd1 | 2005-06-23 22:46:46 +1000 | [diff] [blame] | 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the |
| 9 | * "Software"), to deal in the Software without restriction, including |
| 10 | * without limitation the rights to use, copy, modify, merge, publish, |
| 11 | * distribute, sub license, and/or sell copies of the Software, and to |
| 12 | * permit persons to whom the Software is furnished to do so, subject to |
| 13 | * the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice (including the |
| 16 | * next paragraph) shall be included in all copies or substantial portions |
| 17 | * of the Software. |
| 18 | * |
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
| 22 | * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR |
| 23 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 26 | * |
Dave Airlie | 0d6aa60 | 2006-01-02 20:14:23 +1100 | [diff] [blame] | 27 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 29 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 30 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 31 | #include <linux/sysrq.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 32 | #include <linux/slab.h> |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 33 | #include <linux/circ_buf.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 34 | #include <drm/drmP.h> |
| 35 | #include <drm/i915_drm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include "i915_drv.h" |
Chris Wilson | 1c5d22f | 2009-08-25 11:15:50 +0100 | [diff] [blame] | 37 | #include "i915_trace.h" |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 38 | #include "intel_drv.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 40 | /** |
| 41 | * DOC: interrupt handling |
| 42 | * |
| 43 | * These functions provide the basic support for enabling and disabling the |
| 44 | * interrupt handling support. There's a lot more functionality in i915_irq.c |
| 45 | * and related files, but that will be described in separate chapters. |
| 46 | */ |
| 47 | |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 48 | static const u32 hpd_ilk[HPD_NUM_PINS] = { |
| 49 | [HPD_PORT_A] = DE_DP_A_HOTPLUG, |
| 50 | }; |
| 51 | |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 52 | static const u32 hpd_ivb[HPD_NUM_PINS] = { |
| 53 | [HPD_PORT_A] = DE_DP_A_HOTPLUG_IVB, |
| 54 | }; |
| 55 | |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 56 | static const u32 hpd_bdw[HPD_NUM_PINS] = { |
| 57 | [HPD_PORT_A] = GEN8_PORT_DP_A_HOTPLUG, |
| 58 | }; |
| 59 | |
Ville Syrjälä | 7c7e10d | 2015-01-09 14:21:12 +0200 | [diff] [blame] | 60 | static const u32 hpd_ibx[HPD_NUM_PINS] = { |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 61 | [HPD_CRT] = SDE_CRT_HOTPLUG, |
| 62 | [HPD_SDVO_B] = SDE_SDVOB_HOTPLUG, |
| 63 | [HPD_PORT_B] = SDE_PORTB_HOTPLUG, |
| 64 | [HPD_PORT_C] = SDE_PORTC_HOTPLUG, |
| 65 | [HPD_PORT_D] = SDE_PORTD_HOTPLUG |
| 66 | }; |
| 67 | |
Ville Syrjälä | 7c7e10d | 2015-01-09 14:21:12 +0200 | [diff] [blame] | 68 | static const u32 hpd_cpt[HPD_NUM_PINS] = { |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 69 | [HPD_CRT] = SDE_CRT_HOTPLUG_CPT, |
Daniel Vetter | 73c352a | 2013-03-26 22:38:43 +0100 | [diff] [blame] | 70 | [HPD_SDVO_B] = SDE_SDVOB_HOTPLUG_CPT, |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 71 | [HPD_PORT_B] = SDE_PORTB_HOTPLUG_CPT, |
| 72 | [HPD_PORT_C] = SDE_PORTC_HOTPLUG_CPT, |
| 73 | [HPD_PORT_D] = SDE_PORTD_HOTPLUG_CPT |
| 74 | }; |
| 75 | |
Xiong Zhang | 26951ca | 2015-08-17 15:55:50 +0800 | [diff] [blame] | 76 | static const u32 hpd_spt[HPD_NUM_PINS] = { |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 77 | [HPD_PORT_A] = SDE_PORTA_HOTPLUG_SPT, |
Xiong Zhang | 26951ca | 2015-08-17 15:55:50 +0800 | [diff] [blame] | 78 | [HPD_PORT_B] = SDE_PORTB_HOTPLUG_CPT, |
| 79 | [HPD_PORT_C] = SDE_PORTC_HOTPLUG_CPT, |
| 80 | [HPD_PORT_D] = SDE_PORTD_HOTPLUG_CPT, |
| 81 | [HPD_PORT_E] = SDE_PORTE_HOTPLUG_SPT |
| 82 | }; |
| 83 | |
Ville Syrjälä | 7c7e10d | 2015-01-09 14:21:12 +0200 | [diff] [blame] | 84 | static const u32 hpd_mask_i915[HPD_NUM_PINS] = { |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 85 | [HPD_CRT] = CRT_HOTPLUG_INT_EN, |
| 86 | [HPD_SDVO_B] = SDVOB_HOTPLUG_INT_EN, |
| 87 | [HPD_SDVO_C] = SDVOC_HOTPLUG_INT_EN, |
| 88 | [HPD_PORT_B] = PORTB_HOTPLUG_INT_EN, |
| 89 | [HPD_PORT_C] = PORTC_HOTPLUG_INT_EN, |
| 90 | [HPD_PORT_D] = PORTD_HOTPLUG_INT_EN |
| 91 | }; |
| 92 | |
Ville Syrjälä | 7c7e10d | 2015-01-09 14:21:12 +0200 | [diff] [blame] | 93 | static const u32 hpd_status_g4x[HPD_NUM_PINS] = { |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 94 | [HPD_CRT] = CRT_HOTPLUG_INT_STATUS, |
| 95 | [HPD_SDVO_B] = SDVOB_HOTPLUG_INT_STATUS_G4X, |
| 96 | [HPD_SDVO_C] = SDVOC_HOTPLUG_INT_STATUS_G4X, |
| 97 | [HPD_PORT_B] = PORTB_HOTPLUG_INT_STATUS, |
| 98 | [HPD_PORT_C] = PORTC_HOTPLUG_INT_STATUS, |
| 99 | [HPD_PORT_D] = PORTD_HOTPLUG_INT_STATUS |
| 100 | }; |
| 101 | |
Ville Syrjälä | 4bca26d | 2015-05-11 20:49:10 +0300 | [diff] [blame] | 102 | static const u32 hpd_status_i915[HPD_NUM_PINS] = { |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 103 | [HPD_CRT] = CRT_HOTPLUG_INT_STATUS, |
| 104 | [HPD_SDVO_B] = SDVOB_HOTPLUG_INT_STATUS_I915, |
| 105 | [HPD_SDVO_C] = SDVOC_HOTPLUG_INT_STATUS_I915, |
| 106 | [HPD_PORT_B] = PORTB_HOTPLUG_INT_STATUS, |
| 107 | [HPD_PORT_C] = PORTC_HOTPLUG_INT_STATUS, |
| 108 | [HPD_PORT_D] = PORTD_HOTPLUG_INT_STATUS |
| 109 | }; |
| 110 | |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 111 | /* BXT hpd list */ |
| 112 | static const u32 hpd_bxt[HPD_NUM_PINS] = { |
Sonika Jindal | 7f3561b | 2015-08-10 10:35:35 +0530 | [diff] [blame] | 113 | [HPD_PORT_A] = BXT_DE_PORT_HP_DDIA, |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 114 | [HPD_PORT_B] = BXT_DE_PORT_HP_DDIB, |
| 115 | [HPD_PORT_C] = BXT_DE_PORT_HP_DDIC |
| 116 | }; |
| 117 | |
Paulo Zanoni | 5c50244 | 2014-04-01 15:37:11 -0300 | [diff] [blame] | 118 | /* IIR can theoretically queue up two events. Be paranoid. */ |
Paulo Zanoni | f86f3fb | 2014-04-01 15:37:14 -0300 | [diff] [blame] | 119 | #define GEN8_IRQ_RESET_NDX(type, which) do { \ |
Paulo Zanoni | 5c50244 | 2014-04-01 15:37:11 -0300 | [diff] [blame] | 120 | I915_WRITE(GEN8_##type##_IMR(which), 0xffffffff); \ |
| 121 | POSTING_READ(GEN8_##type##_IMR(which)); \ |
| 122 | I915_WRITE(GEN8_##type##_IER(which), 0); \ |
| 123 | I915_WRITE(GEN8_##type##_IIR(which), 0xffffffff); \ |
| 124 | POSTING_READ(GEN8_##type##_IIR(which)); \ |
| 125 | I915_WRITE(GEN8_##type##_IIR(which), 0xffffffff); \ |
| 126 | POSTING_READ(GEN8_##type##_IIR(which)); \ |
| 127 | } while (0) |
| 128 | |
Paulo Zanoni | f86f3fb | 2014-04-01 15:37:14 -0300 | [diff] [blame] | 129 | #define GEN5_IRQ_RESET(type) do { \ |
Paulo Zanoni | a9d356a | 2014-04-01 15:37:09 -0300 | [diff] [blame] | 130 | I915_WRITE(type##IMR, 0xffffffff); \ |
Paulo Zanoni | 5c50244 | 2014-04-01 15:37:11 -0300 | [diff] [blame] | 131 | POSTING_READ(type##IMR); \ |
Paulo Zanoni | a9d356a | 2014-04-01 15:37:09 -0300 | [diff] [blame] | 132 | I915_WRITE(type##IER, 0); \ |
Paulo Zanoni | 5c50244 | 2014-04-01 15:37:11 -0300 | [diff] [blame] | 133 | I915_WRITE(type##IIR, 0xffffffff); \ |
| 134 | POSTING_READ(type##IIR); \ |
| 135 | I915_WRITE(type##IIR, 0xffffffff); \ |
| 136 | POSTING_READ(type##IIR); \ |
Paulo Zanoni | a9d356a | 2014-04-01 15:37:09 -0300 | [diff] [blame] | 137 | } while (0) |
| 138 | |
Paulo Zanoni | 337ba01 | 2014-04-01 15:37:16 -0300 | [diff] [blame] | 139 | /* |
| 140 | * We should clear IMR at preinstall/uninstall, and just check at postinstall. |
| 141 | */ |
Ville Syrjälä | b51a284 | 2015-09-18 20:03:41 +0300 | [diff] [blame] | 142 | static void gen5_assert_iir_is_zero(struct drm_i915_private *dev_priv, u32 reg) |
| 143 | { |
| 144 | u32 val = I915_READ(reg); |
| 145 | |
| 146 | if (val == 0) |
| 147 | return; |
| 148 | |
| 149 | WARN(1, "Interrupt register 0x%x is not zero: 0x%08x\n", |
| 150 | reg, val); |
| 151 | I915_WRITE(reg, 0xffffffff); |
| 152 | POSTING_READ(reg); |
| 153 | I915_WRITE(reg, 0xffffffff); |
| 154 | POSTING_READ(reg); |
| 155 | } |
Paulo Zanoni | 337ba01 | 2014-04-01 15:37:16 -0300 | [diff] [blame] | 156 | |
Paulo Zanoni | 3507989 | 2014-04-01 15:37:15 -0300 | [diff] [blame] | 157 | #define GEN8_IRQ_INIT_NDX(type, which, imr_val, ier_val) do { \ |
Ville Syrjälä | b51a284 | 2015-09-18 20:03:41 +0300 | [diff] [blame] | 158 | gen5_assert_iir_is_zero(dev_priv, GEN8_##type##_IIR(which)); \ |
Paulo Zanoni | 3507989 | 2014-04-01 15:37:15 -0300 | [diff] [blame] | 159 | I915_WRITE(GEN8_##type##_IER(which), (ier_val)); \ |
Ville Syrjälä | 7d1bd539 | 2014-10-30 19:42:50 +0200 | [diff] [blame] | 160 | I915_WRITE(GEN8_##type##_IMR(which), (imr_val)); \ |
| 161 | POSTING_READ(GEN8_##type##_IMR(which)); \ |
Paulo Zanoni | 3507989 | 2014-04-01 15:37:15 -0300 | [diff] [blame] | 162 | } while (0) |
| 163 | |
| 164 | #define GEN5_IRQ_INIT(type, imr_val, ier_val) do { \ |
Ville Syrjälä | b51a284 | 2015-09-18 20:03:41 +0300 | [diff] [blame] | 165 | gen5_assert_iir_is_zero(dev_priv, type##IIR); \ |
Paulo Zanoni | 3507989 | 2014-04-01 15:37:15 -0300 | [diff] [blame] | 166 | I915_WRITE(type##IER, (ier_val)); \ |
Ville Syrjälä | 7d1bd539 | 2014-10-30 19:42:50 +0200 | [diff] [blame] | 167 | I915_WRITE(type##IMR, (imr_val)); \ |
| 168 | POSTING_READ(type##IMR); \ |
Paulo Zanoni | 3507989 | 2014-04-01 15:37:15 -0300 | [diff] [blame] | 169 | } while (0) |
| 170 | |
Imre Deak | c9a9a26 | 2014-11-05 20:48:37 +0200 | [diff] [blame] | 171 | static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir); |
| 172 | |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 173 | /* For display hotplug interrupt */ |
| 174 | static inline void |
| 175 | i915_hotplug_interrupt_update_locked(struct drm_i915_private *dev_priv, |
| 176 | uint32_t mask, |
| 177 | uint32_t bits) |
| 178 | { |
| 179 | uint32_t val; |
| 180 | |
| 181 | assert_spin_locked(&dev_priv->irq_lock); |
| 182 | WARN_ON(bits & ~mask); |
| 183 | |
| 184 | val = I915_READ(PORT_HOTPLUG_EN); |
| 185 | val &= ~mask; |
| 186 | val |= bits; |
| 187 | I915_WRITE(PORT_HOTPLUG_EN, val); |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * i915_hotplug_interrupt_update - update hotplug interrupt enable |
| 192 | * @dev_priv: driver private |
| 193 | * @mask: bits to update |
| 194 | * @bits: bits to enable |
| 195 | * NOTE: the HPD enable bits are modified both inside and outside |
| 196 | * of an interrupt context. To avoid that read-modify-write cycles |
| 197 | * interfer, these bits are protected by a spinlock. Since this |
| 198 | * function is usually not called from a context where the lock is |
| 199 | * held already, this function acquires the lock itself. A non-locking |
| 200 | * version is also available. |
| 201 | */ |
| 202 | void i915_hotplug_interrupt_update(struct drm_i915_private *dev_priv, |
| 203 | uint32_t mask, |
| 204 | uint32_t bits) |
| 205 | { |
| 206 | spin_lock_irq(&dev_priv->irq_lock); |
| 207 | i915_hotplug_interrupt_update_locked(dev_priv, mask, bits); |
| 208 | spin_unlock_irq(&dev_priv->irq_lock); |
| 209 | } |
| 210 | |
Ville Syrjälä | d9dc34f1 | 2015-08-27 23:55:58 +0300 | [diff] [blame] | 211 | /** |
| 212 | * ilk_update_display_irq - update DEIMR |
| 213 | * @dev_priv: driver private |
| 214 | * @interrupt_mask: mask of interrupt bits to update |
| 215 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 216 | */ |
| 217 | static void ilk_update_display_irq(struct drm_i915_private *dev_priv, |
| 218 | uint32_t interrupt_mask, |
| 219 | uint32_t enabled_irq_mask) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 220 | { |
Ville Syrjälä | d9dc34f1 | 2015-08-27 23:55:58 +0300 | [diff] [blame] | 221 | uint32_t new_val; |
| 222 | |
Daniel Vetter | 4bc9d43 | 2013-06-27 13:44:58 +0200 | [diff] [blame] | 223 | assert_spin_locked(&dev_priv->irq_lock); |
| 224 | |
Ville Syrjälä | d9dc34f1 | 2015-08-27 23:55:58 +0300 | [diff] [blame] | 225 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 226 | |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 227 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 228 | return; |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 229 | |
Ville Syrjälä | d9dc34f1 | 2015-08-27 23:55:58 +0300 | [diff] [blame] | 230 | new_val = dev_priv->irq_mask; |
| 231 | new_val &= ~interrupt_mask; |
| 232 | new_val |= (~enabled_irq_mask & interrupt_mask); |
| 233 | |
| 234 | if (new_val != dev_priv->irq_mask) { |
| 235 | dev_priv->irq_mask = new_val; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 236 | I915_WRITE(DEIMR, dev_priv->irq_mask); |
Chris Wilson | 3143a2b | 2010-11-16 15:55:10 +0000 | [diff] [blame] | 237 | POSTING_READ(DEIMR); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 238 | } |
| 239 | } |
| 240 | |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 241 | void |
Ville Syrjälä | d9dc34f1 | 2015-08-27 23:55:58 +0300 | [diff] [blame] | 242 | ironlake_enable_display_irq(struct drm_i915_private *dev_priv, u32 mask) |
| 243 | { |
| 244 | ilk_update_display_irq(dev_priv, mask, mask); |
| 245 | } |
| 246 | |
| 247 | void |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 248 | ironlake_disable_display_irq(struct drm_i915_private *dev_priv, u32 mask) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 249 | { |
Ville Syrjälä | d9dc34f1 | 2015-08-27 23:55:58 +0300 | [diff] [blame] | 250 | ilk_update_display_irq(dev_priv, mask, 0); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 251 | } |
| 252 | |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 253 | /** |
| 254 | * ilk_update_gt_irq - update GTIMR |
| 255 | * @dev_priv: driver private |
| 256 | * @interrupt_mask: mask of interrupt bits to update |
| 257 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 258 | */ |
| 259 | static void ilk_update_gt_irq(struct drm_i915_private *dev_priv, |
| 260 | uint32_t interrupt_mask, |
| 261 | uint32_t enabled_irq_mask) |
| 262 | { |
| 263 | assert_spin_locked(&dev_priv->irq_lock); |
| 264 | |
Daniel Vetter | 15a17aa | 2014-12-08 16:30:00 +0100 | [diff] [blame] | 265 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 266 | |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 267 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 268 | return; |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 269 | |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 270 | dev_priv->gt_irq_mask &= ~interrupt_mask; |
| 271 | dev_priv->gt_irq_mask |= (~enabled_irq_mask & interrupt_mask); |
| 272 | I915_WRITE(GTIMR, dev_priv->gt_irq_mask); |
| 273 | POSTING_READ(GTIMR); |
| 274 | } |
| 275 | |
Daniel Vetter | 480c803 | 2014-07-16 09:49:40 +0200 | [diff] [blame] | 276 | void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask) |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 277 | { |
| 278 | ilk_update_gt_irq(dev_priv, mask, mask); |
| 279 | } |
| 280 | |
Daniel Vetter | 480c803 | 2014-07-16 09:49:40 +0200 | [diff] [blame] | 281 | void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask) |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 282 | { |
| 283 | ilk_update_gt_irq(dev_priv, mask, 0); |
| 284 | } |
| 285 | |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 286 | static u32 gen6_pm_iir(struct drm_i915_private *dev_priv) |
| 287 | { |
| 288 | return INTEL_INFO(dev_priv)->gen >= 8 ? GEN8_GT_IIR(2) : GEN6_PMIIR; |
| 289 | } |
| 290 | |
Imre Deak | a72fbc3 | 2014-11-05 20:48:31 +0200 | [diff] [blame] | 291 | static u32 gen6_pm_imr(struct drm_i915_private *dev_priv) |
| 292 | { |
| 293 | return INTEL_INFO(dev_priv)->gen >= 8 ? GEN8_GT_IMR(2) : GEN6_PMIMR; |
| 294 | } |
| 295 | |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 296 | static u32 gen6_pm_ier(struct drm_i915_private *dev_priv) |
| 297 | { |
| 298 | return INTEL_INFO(dev_priv)->gen >= 8 ? GEN8_GT_IER(2) : GEN6_PMIER; |
| 299 | } |
| 300 | |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 301 | /** |
| 302 | * snb_update_pm_irq - update GEN6_PMIMR |
| 303 | * @dev_priv: driver private |
| 304 | * @interrupt_mask: mask of interrupt bits to update |
| 305 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 306 | */ |
| 307 | static void snb_update_pm_irq(struct drm_i915_private *dev_priv, |
| 308 | uint32_t interrupt_mask, |
| 309 | uint32_t enabled_irq_mask) |
| 310 | { |
Paulo Zanoni | 605cd25 | 2013-08-06 18:57:15 -0300 | [diff] [blame] | 311 | uint32_t new_val; |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 312 | |
Daniel Vetter | 15a17aa | 2014-12-08 16:30:00 +0100 | [diff] [blame] | 313 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 314 | |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 315 | assert_spin_locked(&dev_priv->irq_lock); |
| 316 | |
Paulo Zanoni | 605cd25 | 2013-08-06 18:57:15 -0300 | [diff] [blame] | 317 | new_val = dev_priv->pm_irq_mask; |
Paulo Zanoni | f52ecbc | 2013-08-06 18:57:14 -0300 | [diff] [blame] | 318 | new_val &= ~interrupt_mask; |
| 319 | new_val |= (~enabled_irq_mask & interrupt_mask); |
| 320 | |
Paulo Zanoni | 605cd25 | 2013-08-06 18:57:15 -0300 | [diff] [blame] | 321 | if (new_val != dev_priv->pm_irq_mask) { |
| 322 | dev_priv->pm_irq_mask = new_val; |
Imre Deak | a72fbc3 | 2014-11-05 20:48:31 +0200 | [diff] [blame] | 323 | I915_WRITE(gen6_pm_imr(dev_priv), dev_priv->pm_irq_mask); |
| 324 | POSTING_READ(gen6_pm_imr(dev_priv)); |
Paulo Zanoni | f52ecbc | 2013-08-06 18:57:14 -0300 | [diff] [blame] | 325 | } |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 326 | } |
| 327 | |
Daniel Vetter | 480c803 | 2014-07-16 09:49:40 +0200 | [diff] [blame] | 328 | void gen6_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask) |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 329 | { |
Imre Deak | 9939fba | 2014-11-20 23:01:47 +0200 | [diff] [blame] | 330 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
| 331 | return; |
| 332 | |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 333 | snb_update_pm_irq(dev_priv, mask, mask); |
| 334 | } |
| 335 | |
Imre Deak | 9939fba | 2014-11-20 23:01:47 +0200 | [diff] [blame] | 336 | static void __gen6_disable_pm_irq(struct drm_i915_private *dev_priv, |
| 337 | uint32_t mask) |
| 338 | { |
| 339 | snb_update_pm_irq(dev_priv, mask, 0); |
| 340 | } |
| 341 | |
Daniel Vetter | 480c803 | 2014-07-16 09:49:40 +0200 | [diff] [blame] | 342 | void gen6_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask) |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 343 | { |
Imre Deak | 9939fba | 2014-11-20 23:01:47 +0200 | [diff] [blame] | 344 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
| 345 | return; |
| 346 | |
| 347 | __gen6_disable_pm_irq(dev_priv, mask); |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 348 | } |
| 349 | |
Imre Deak | 3cc134e | 2014-11-19 15:30:03 +0200 | [diff] [blame] | 350 | void gen6_reset_rps_interrupts(struct drm_device *dev) |
| 351 | { |
| 352 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 353 | uint32_t reg = gen6_pm_iir(dev_priv); |
| 354 | |
| 355 | spin_lock_irq(&dev_priv->irq_lock); |
| 356 | I915_WRITE(reg, dev_priv->pm_rps_events); |
| 357 | I915_WRITE(reg, dev_priv->pm_rps_events); |
| 358 | POSTING_READ(reg); |
Imre Deak | 096fad9 | 2015-03-23 19:11:35 +0200 | [diff] [blame] | 359 | dev_priv->rps.pm_iir = 0; |
Imre Deak | 3cc134e | 2014-11-19 15:30:03 +0200 | [diff] [blame] | 360 | spin_unlock_irq(&dev_priv->irq_lock); |
| 361 | } |
| 362 | |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 363 | void gen6_enable_rps_interrupts(struct drm_device *dev) |
| 364 | { |
| 365 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 366 | |
| 367 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | 78e68d3 | 2014-12-15 18:59:27 +0200 | [diff] [blame] | 368 | |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 369 | WARN_ON(dev_priv->rps.pm_iir); |
Imre Deak | 3cc134e | 2014-11-19 15:30:03 +0200 | [diff] [blame] | 370 | WARN_ON(I915_READ(gen6_pm_iir(dev_priv)) & dev_priv->pm_rps_events); |
Imre Deak | d4d70aa | 2014-11-19 15:30:04 +0200 | [diff] [blame] | 371 | dev_priv->rps.interrupts_enabled = true; |
Imre Deak | 78e68d3 | 2014-12-15 18:59:27 +0200 | [diff] [blame] | 372 | I915_WRITE(gen6_pm_ier(dev_priv), I915_READ(gen6_pm_ier(dev_priv)) | |
| 373 | dev_priv->pm_rps_events); |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 374 | gen6_enable_pm_irq(dev_priv, dev_priv->pm_rps_events); |
Imre Deak | 78e68d3 | 2014-12-15 18:59:27 +0200 | [diff] [blame] | 375 | |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 376 | spin_unlock_irq(&dev_priv->irq_lock); |
| 377 | } |
| 378 | |
Imre Deak | 59d02a1 | 2014-12-19 19:33:26 +0200 | [diff] [blame] | 379 | u32 gen6_sanitize_rps_pm_mask(struct drm_i915_private *dev_priv, u32 mask) |
| 380 | { |
| 381 | /* |
Imre Deak | f24eeb1 | 2014-12-19 19:33:27 +0200 | [diff] [blame] | 382 | * SNB,IVB can while VLV,CHV may hard hang on looping batchbuffer |
Imre Deak | 59d02a1 | 2014-12-19 19:33:26 +0200 | [diff] [blame] | 383 | * if GEN6_PM_UP_EI_EXPIRED is masked. |
Imre Deak | f24eeb1 | 2014-12-19 19:33:27 +0200 | [diff] [blame] | 384 | * |
| 385 | * TODO: verify if this can be reproduced on VLV,CHV. |
Imre Deak | 59d02a1 | 2014-12-19 19:33:26 +0200 | [diff] [blame] | 386 | */ |
| 387 | if (INTEL_INFO(dev_priv)->gen <= 7 && !IS_HASWELL(dev_priv)) |
| 388 | mask &= ~GEN6_PM_RP_UP_EI_EXPIRED; |
| 389 | |
| 390 | if (INTEL_INFO(dev_priv)->gen >= 8) |
| 391 | mask &= ~GEN8_PMINTR_REDIRECT_TO_NON_DISP; |
| 392 | |
| 393 | return mask; |
| 394 | } |
| 395 | |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 396 | void gen6_disable_rps_interrupts(struct drm_device *dev) |
| 397 | { |
| 398 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 399 | |
Imre Deak | d4d70aa | 2014-11-19 15:30:04 +0200 | [diff] [blame] | 400 | spin_lock_irq(&dev_priv->irq_lock); |
| 401 | dev_priv->rps.interrupts_enabled = false; |
| 402 | spin_unlock_irq(&dev_priv->irq_lock); |
| 403 | |
| 404 | cancel_work_sync(&dev_priv->rps.work); |
| 405 | |
Imre Deak | 9939fba | 2014-11-20 23:01:47 +0200 | [diff] [blame] | 406 | spin_lock_irq(&dev_priv->irq_lock); |
| 407 | |
Imre Deak | 59d02a1 | 2014-12-19 19:33:26 +0200 | [diff] [blame] | 408 | I915_WRITE(GEN6_PMINTRMSK, gen6_sanitize_rps_pm_mask(dev_priv, ~0)); |
Imre Deak | 9939fba | 2014-11-20 23:01:47 +0200 | [diff] [blame] | 409 | |
| 410 | __gen6_disable_pm_irq(dev_priv, dev_priv->pm_rps_events); |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 411 | I915_WRITE(gen6_pm_ier(dev_priv), I915_READ(gen6_pm_ier(dev_priv)) & |
| 412 | ~dev_priv->pm_rps_events); |
Imre Deak | 58072cc | 2015-03-23 19:11:34 +0200 | [diff] [blame] | 413 | |
| 414 | spin_unlock_irq(&dev_priv->irq_lock); |
| 415 | |
| 416 | synchronize_irq(dev->irq); |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 417 | } |
| 418 | |
Ben Widawsky | 0961021 | 2014-05-15 20:58:08 +0300 | [diff] [blame] | 419 | /** |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 420 | * bdw_update_port_irq - update DE port interrupt |
| 421 | * @dev_priv: driver private |
| 422 | * @interrupt_mask: mask of interrupt bits to update |
| 423 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 424 | */ |
| 425 | static void bdw_update_port_irq(struct drm_i915_private *dev_priv, |
| 426 | uint32_t interrupt_mask, |
| 427 | uint32_t enabled_irq_mask) |
| 428 | { |
| 429 | uint32_t new_val; |
| 430 | uint32_t old_val; |
| 431 | |
| 432 | assert_spin_locked(&dev_priv->irq_lock); |
| 433 | |
| 434 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 435 | |
| 436 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
| 437 | return; |
| 438 | |
| 439 | old_val = I915_READ(GEN8_DE_PORT_IMR); |
| 440 | |
| 441 | new_val = old_val; |
| 442 | new_val &= ~interrupt_mask; |
| 443 | new_val |= (~enabled_irq_mask & interrupt_mask); |
| 444 | |
| 445 | if (new_val != old_val) { |
| 446 | I915_WRITE(GEN8_DE_PORT_IMR, new_val); |
| 447 | POSTING_READ(GEN8_DE_PORT_IMR); |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | /** |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 452 | * ibx_display_interrupt_update - update SDEIMR |
| 453 | * @dev_priv: driver private |
| 454 | * @interrupt_mask: mask of interrupt bits to update |
| 455 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 456 | */ |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 457 | void ibx_display_interrupt_update(struct drm_i915_private *dev_priv, |
| 458 | uint32_t interrupt_mask, |
| 459 | uint32_t enabled_irq_mask) |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 460 | { |
| 461 | uint32_t sdeimr = I915_READ(SDEIMR); |
| 462 | sdeimr &= ~interrupt_mask; |
| 463 | sdeimr |= (~enabled_irq_mask & interrupt_mask); |
| 464 | |
Daniel Vetter | 15a17aa | 2014-12-08 16:30:00 +0100 | [diff] [blame] | 465 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 466 | |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 467 | assert_spin_locked(&dev_priv->irq_lock); |
| 468 | |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 469 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 470 | return; |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 471 | |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 472 | I915_WRITE(SDEIMR, sdeimr); |
| 473 | POSTING_READ(SDEIMR); |
| 474 | } |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 475 | |
Daniel Vetter | b5ea642 | 2014-03-02 21:18:00 +0100 | [diff] [blame] | 476 | static void |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 477 | __i915_enable_pipestat(struct drm_i915_private *dev_priv, enum pipe pipe, |
| 478 | u32 enable_mask, u32 status_mask) |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 479 | { |
Ville Syrjälä | 46c06a3 | 2013-02-20 21:16:18 +0200 | [diff] [blame] | 480 | u32 reg = PIPESTAT(pipe); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 481 | u32 pipestat = I915_READ(reg) & PIPESTAT_INT_ENABLE_MASK; |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 482 | |
Daniel Vetter | b79480b | 2013-06-27 17:52:10 +0200 | [diff] [blame] | 483 | assert_spin_locked(&dev_priv->irq_lock); |
Daniel Vetter | d518ce5 | 2014-08-27 10:43:37 +0200 | [diff] [blame] | 484 | WARN_ON(!intel_irqs_enabled(dev_priv)); |
Daniel Vetter | b79480b | 2013-06-27 17:52:10 +0200 | [diff] [blame] | 485 | |
Ville Syrjälä | 04feced | 2014-04-03 13:28:33 +0300 | [diff] [blame] | 486 | if (WARN_ONCE(enable_mask & ~PIPESTAT_INT_ENABLE_MASK || |
| 487 | status_mask & ~PIPESTAT_INT_STATUS_MASK, |
| 488 | "pipe %c: enable_mask=0x%x, status_mask=0x%x\n", |
| 489 | pipe_name(pipe), enable_mask, status_mask)) |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 490 | return; |
| 491 | |
| 492 | if ((pipestat & enable_mask) == enable_mask) |
Ville Syrjälä | 46c06a3 | 2013-02-20 21:16:18 +0200 | [diff] [blame] | 493 | return; |
| 494 | |
Imre Deak | 91d181d | 2014-02-10 18:42:49 +0200 | [diff] [blame] | 495 | dev_priv->pipestat_irq_mask[pipe] |= status_mask; |
| 496 | |
Ville Syrjälä | 46c06a3 | 2013-02-20 21:16:18 +0200 | [diff] [blame] | 497 | /* Enable the interrupt, clear any pending status */ |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 498 | pipestat |= enable_mask | status_mask; |
Ville Syrjälä | 46c06a3 | 2013-02-20 21:16:18 +0200 | [diff] [blame] | 499 | I915_WRITE(reg, pipestat); |
| 500 | POSTING_READ(reg); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 501 | } |
| 502 | |
Daniel Vetter | b5ea642 | 2014-03-02 21:18:00 +0100 | [diff] [blame] | 503 | static void |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 504 | __i915_disable_pipestat(struct drm_i915_private *dev_priv, enum pipe pipe, |
| 505 | u32 enable_mask, u32 status_mask) |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 506 | { |
Ville Syrjälä | 46c06a3 | 2013-02-20 21:16:18 +0200 | [diff] [blame] | 507 | u32 reg = PIPESTAT(pipe); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 508 | u32 pipestat = I915_READ(reg) & PIPESTAT_INT_ENABLE_MASK; |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 509 | |
Daniel Vetter | b79480b | 2013-06-27 17:52:10 +0200 | [diff] [blame] | 510 | assert_spin_locked(&dev_priv->irq_lock); |
Daniel Vetter | d518ce5 | 2014-08-27 10:43:37 +0200 | [diff] [blame] | 511 | WARN_ON(!intel_irqs_enabled(dev_priv)); |
Daniel Vetter | b79480b | 2013-06-27 17:52:10 +0200 | [diff] [blame] | 512 | |
Ville Syrjälä | 04feced | 2014-04-03 13:28:33 +0300 | [diff] [blame] | 513 | if (WARN_ONCE(enable_mask & ~PIPESTAT_INT_ENABLE_MASK || |
| 514 | status_mask & ~PIPESTAT_INT_STATUS_MASK, |
| 515 | "pipe %c: enable_mask=0x%x, status_mask=0x%x\n", |
| 516 | pipe_name(pipe), enable_mask, status_mask)) |
Ville Syrjälä | 46c06a3 | 2013-02-20 21:16:18 +0200 | [diff] [blame] | 517 | return; |
| 518 | |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 519 | if ((pipestat & enable_mask) == 0) |
| 520 | return; |
| 521 | |
Imre Deak | 91d181d | 2014-02-10 18:42:49 +0200 | [diff] [blame] | 522 | dev_priv->pipestat_irq_mask[pipe] &= ~status_mask; |
| 523 | |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 524 | pipestat &= ~enable_mask; |
Ville Syrjälä | 46c06a3 | 2013-02-20 21:16:18 +0200 | [diff] [blame] | 525 | I915_WRITE(reg, pipestat); |
| 526 | POSTING_READ(reg); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 527 | } |
| 528 | |
Imre Deak | 10c59c5 | 2014-02-10 18:42:48 +0200 | [diff] [blame] | 529 | static u32 vlv_get_pipestat_enable_mask(struct drm_device *dev, u32 status_mask) |
| 530 | { |
| 531 | u32 enable_mask = status_mask << 16; |
| 532 | |
| 533 | /* |
Ville Syrjälä | 724a690 | 2014-04-09 13:28:48 +0300 | [diff] [blame] | 534 | * On pipe A we don't support the PSR interrupt yet, |
| 535 | * on pipe B and C the same bit MBZ. |
Imre Deak | 10c59c5 | 2014-02-10 18:42:48 +0200 | [diff] [blame] | 536 | */ |
| 537 | if (WARN_ON_ONCE(status_mask & PIPE_A_PSR_STATUS_VLV)) |
| 538 | return 0; |
Ville Syrjälä | 724a690 | 2014-04-09 13:28:48 +0300 | [diff] [blame] | 539 | /* |
| 540 | * On pipe B and C we don't support the PSR interrupt yet, on pipe |
| 541 | * A the same bit is for perf counters which we don't use either. |
| 542 | */ |
| 543 | if (WARN_ON_ONCE(status_mask & PIPE_B_PSR_STATUS_VLV)) |
| 544 | return 0; |
Imre Deak | 10c59c5 | 2014-02-10 18:42:48 +0200 | [diff] [blame] | 545 | |
| 546 | enable_mask &= ~(PIPE_FIFO_UNDERRUN_STATUS | |
| 547 | SPRITE0_FLIP_DONE_INT_EN_VLV | |
| 548 | SPRITE1_FLIP_DONE_INT_EN_VLV); |
| 549 | if (status_mask & SPRITE0_FLIP_DONE_INT_STATUS_VLV) |
| 550 | enable_mask |= SPRITE0_FLIP_DONE_INT_EN_VLV; |
| 551 | if (status_mask & SPRITE1_FLIP_DONE_INT_STATUS_VLV) |
| 552 | enable_mask |= SPRITE1_FLIP_DONE_INT_EN_VLV; |
| 553 | |
| 554 | return enable_mask; |
| 555 | } |
| 556 | |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 557 | void |
| 558 | i915_enable_pipestat(struct drm_i915_private *dev_priv, enum pipe pipe, |
| 559 | u32 status_mask) |
| 560 | { |
| 561 | u32 enable_mask; |
| 562 | |
Imre Deak | 10c59c5 | 2014-02-10 18:42:48 +0200 | [diff] [blame] | 563 | if (IS_VALLEYVIEW(dev_priv->dev)) |
| 564 | enable_mask = vlv_get_pipestat_enable_mask(dev_priv->dev, |
| 565 | status_mask); |
| 566 | else |
| 567 | enable_mask = status_mask << 16; |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 568 | __i915_enable_pipestat(dev_priv, pipe, enable_mask, status_mask); |
| 569 | } |
| 570 | |
| 571 | void |
| 572 | i915_disable_pipestat(struct drm_i915_private *dev_priv, enum pipe pipe, |
| 573 | u32 status_mask) |
| 574 | { |
| 575 | u32 enable_mask; |
| 576 | |
Imre Deak | 10c59c5 | 2014-02-10 18:42:48 +0200 | [diff] [blame] | 577 | if (IS_VALLEYVIEW(dev_priv->dev)) |
| 578 | enable_mask = vlv_get_pipestat_enable_mask(dev_priv->dev, |
| 579 | status_mask); |
| 580 | else |
| 581 | enable_mask = status_mask << 16; |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 582 | __i915_disable_pipestat(dev_priv, pipe, enable_mask, status_mask); |
| 583 | } |
| 584 | |
=?utf-8?q?Michel_D=C3=A4nzer?= | a6b54f3 | 2006-10-24 23:37:43 +1000 | [diff] [blame] | 585 | /** |
Jani Nikula | f49e38d | 2013-04-29 13:02:54 +0300 | [diff] [blame] | 586 | * i915_enable_asle_pipestat - enable ASLE pipestat for OpRegion |
Javier Martinez Canillas | 468f9d2 | 2015-10-08 09:54:44 +0200 | [diff] [blame] | 587 | * @dev: drm device |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 588 | */ |
Jani Nikula | f49e38d | 2013-04-29 13:02:54 +0300 | [diff] [blame] | 589 | static void i915_enable_asle_pipestat(struct drm_device *dev) |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 590 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 591 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 592 | |
Jani Nikula | f49e38d | 2013-04-29 13:02:54 +0300 | [diff] [blame] | 593 | if (!dev_priv->opregion.asle || !IS_MOBILE(dev)) |
| 594 | return; |
| 595 | |
Daniel Vetter | 1332178 | 2014-09-15 14:55:29 +0200 | [diff] [blame] | 596 | spin_lock_irq(&dev_priv->irq_lock); |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 597 | |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 598 | i915_enable_pipestat(dev_priv, PIPE_B, PIPE_LEGACY_BLC_EVENT_STATUS); |
Jani Nikula | f898780 | 2013-04-29 13:02:53 +0300 | [diff] [blame] | 599 | if (INTEL_INFO(dev)->gen >= 4) |
Daniel Vetter | 3b6c42e | 2013-10-21 18:04:35 +0200 | [diff] [blame] | 600 | i915_enable_pipestat(dev_priv, PIPE_A, |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 601 | PIPE_LEGACY_BLC_EVENT_STATUS); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 602 | |
Daniel Vetter | 1332178 | 2014-09-15 14:55:29 +0200 | [diff] [blame] | 603 | spin_unlock_irq(&dev_priv->irq_lock); |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 604 | } |
| 605 | |
Ville Syrjälä | f75f374 | 2014-05-15 20:20:36 +0300 | [diff] [blame] | 606 | /* |
| 607 | * This timing diagram depicts the video signal in and |
| 608 | * around the vertical blanking period. |
| 609 | * |
| 610 | * Assumptions about the fictitious mode used in this example: |
| 611 | * vblank_start >= 3 |
| 612 | * vsync_start = vblank_start + 1 |
| 613 | * vsync_end = vblank_start + 2 |
| 614 | * vtotal = vblank_start + 3 |
| 615 | * |
| 616 | * start of vblank: |
| 617 | * latch double buffered registers |
| 618 | * increment frame counter (ctg+) |
| 619 | * generate start of vblank interrupt (gen4+) |
| 620 | * | |
| 621 | * | frame start: |
| 622 | * | generate frame start interrupt (aka. vblank interrupt) (gmch) |
| 623 | * | may be shifted forward 1-3 extra lines via PIPECONF |
| 624 | * | | |
| 625 | * | | start of vsync: |
| 626 | * | | generate vsync interrupt |
| 627 | * | | | |
| 628 | * ___xxxx___ ___xxxx___ ___xxxx___ ___xxxx___ ___xxxx___ ___xxxx |
| 629 | * . \hs/ . \hs/ \hs/ \hs/ . \hs/ |
| 630 | * ----va---> <-----------------vb--------------------> <--------va------------- |
| 631 | * | | <----vs-----> | |
| 632 | * -vbs-----> <---vbs+1---> <---vbs+2---> <-----0-----> <-----1-----> <-----2--- (scanline counter gen2) |
| 633 | * -vbs-2---> <---vbs-1---> <---vbs-----> <---vbs+1---> <---vbs+2---> <-----0--- (scanline counter gen3+) |
| 634 | * -vbs-2---> <---vbs-2---> <---vbs-1---> <---vbs-----> <---vbs+1---> <---vbs+2- (scanline counter hsw+ hdmi) |
| 635 | * | | | |
| 636 | * last visible pixel first visible pixel |
| 637 | * | increment frame counter (gen3/4) |
| 638 | * pixel counter = vblank_start * htotal pixel counter = 0 (gen3/4) |
| 639 | * |
| 640 | * x = horizontal active |
| 641 | * _ = horizontal blanking |
| 642 | * hs = horizontal sync |
| 643 | * va = vertical active |
| 644 | * vb = vertical blanking |
| 645 | * vs = vertical sync |
| 646 | * vbs = vblank_start (number) |
| 647 | * |
| 648 | * Summary: |
| 649 | * - most events happen at the start of horizontal sync |
| 650 | * - frame start happens at the start of horizontal blank, 1-4 lines |
| 651 | * (depending on PIPECONF settings) after the start of vblank |
| 652 | * - gen3/4 pixel and frame counter are synchronized with the start |
| 653 | * of horizontal active on the first line of vertical active |
| 654 | */ |
| 655 | |
Ville Syrjälä | 4cdb83e | 2013-10-11 21:52:44 +0300 | [diff] [blame] | 656 | static u32 i8xx_get_vblank_counter(struct drm_device *dev, int pipe) |
| 657 | { |
| 658 | /* Gen2 doesn't have a hardware frame counter */ |
| 659 | return 0; |
| 660 | } |
| 661 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 662 | /* Called from drm generic code, passed a 'crtc', which |
| 663 | * we use as a pipe index |
| 664 | */ |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 665 | static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 666 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 667 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 668 | unsigned long high_frame; |
| 669 | unsigned long low_frame; |
Ville Syrjälä | 0b2a8e0 | 2014-04-29 13:35:50 +0300 | [diff] [blame] | 670 | u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal; |
Daniel Vetter | f3a5c3f | 2015-02-13 21:03:44 +0100 | [diff] [blame] | 671 | struct intel_crtc *intel_crtc = |
| 672 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
Maarten Lankhorst | fc467a22 | 2015-06-01 12:50:07 +0200 | [diff] [blame] | 673 | const struct drm_display_mode *mode = &intel_crtc->base.hwmode; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 674 | |
Daniel Vetter | f3a5c3f | 2015-02-13 21:03:44 +0100 | [diff] [blame] | 675 | htotal = mode->crtc_htotal; |
| 676 | hsync_start = mode->crtc_hsync_start; |
| 677 | vbl_start = mode->crtc_vblank_start; |
| 678 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
| 679 | vbl_start = DIV_ROUND_UP(vbl_start, 2); |
Ville Syrjälä | 391f75e | 2013-09-25 19:55:26 +0300 | [diff] [blame] | 680 | |
Ville Syrjälä | 0b2a8e0 | 2014-04-29 13:35:50 +0300 | [diff] [blame] | 681 | /* Convert to pixel count */ |
| 682 | vbl_start *= htotal; |
| 683 | |
| 684 | /* Start of vblank event occurs at start of hsync */ |
| 685 | vbl_start -= htotal - hsync_start; |
| 686 | |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 687 | high_frame = PIPEFRAME(pipe); |
| 688 | low_frame = PIPEFRAMEPIXEL(pipe); |
Chris Wilson | 5eddb70 | 2010-09-11 13:48:45 +0100 | [diff] [blame] | 689 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 690 | /* |
| 691 | * High & low register fields aren't synchronized, so make sure |
| 692 | * we get a low value that's stable across two reads of the high |
| 693 | * register. |
| 694 | */ |
| 695 | do { |
Chris Wilson | 5eddb70 | 2010-09-11 13:48:45 +0100 | [diff] [blame] | 696 | high1 = I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK; |
Ville Syrjälä | 391f75e | 2013-09-25 19:55:26 +0300 | [diff] [blame] | 697 | low = I915_READ(low_frame); |
Chris Wilson | 5eddb70 | 2010-09-11 13:48:45 +0100 | [diff] [blame] | 698 | high2 = I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 699 | } while (high1 != high2); |
| 700 | |
Chris Wilson | 5eddb70 | 2010-09-11 13:48:45 +0100 | [diff] [blame] | 701 | high1 >>= PIPE_FRAME_HIGH_SHIFT; |
Ville Syrjälä | 391f75e | 2013-09-25 19:55:26 +0300 | [diff] [blame] | 702 | pixel = low & PIPE_PIXEL_MASK; |
Chris Wilson | 5eddb70 | 2010-09-11 13:48:45 +0100 | [diff] [blame] | 703 | low >>= PIPE_FRAME_LOW_SHIFT; |
Ville Syrjälä | 391f75e | 2013-09-25 19:55:26 +0300 | [diff] [blame] | 704 | |
| 705 | /* |
| 706 | * The frame counter increments at beginning of active. |
| 707 | * Cook up a vblank counter by also checking the pixel |
| 708 | * counter against vblank start. |
| 709 | */ |
Ville Syrjälä | edc08d0 | 2013-11-06 13:56:27 -0200 | [diff] [blame] | 710 | return (((high1 << 8) | low) + (pixel >= vbl_start)) & 0xffffff; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 711 | } |
| 712 | |
Ville Syrjälä | fd8f507 | 2015-09-18 20:03:42 +0300 | [diff] [blame] | 713 | static u32 g4x_get_vblank_counter(struct drm_device *dev, int pipe) |
Jesse Barnes | 9880b7a | 2009-02-06 10:22:41 -0800 | [diff] [blame] | 714 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 715 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 9880b7a | 2009-02-06 10:22:41 -0800 | [diff] [blame] | 716 | |
Ville Syrjälä | 649636e | 2015-09-22 19:50:01 +0300 | [diff] [blame] | 717 | return I915_READ(PIPE_FRMCOUNT_G4X(pipe)); |
Jesse Barnes | 9880b7a | 2009-02-06 10:22:41 -0800 | [diff] [blame] | 718 | } |
| 719 | |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 720 | /* raw reads, only for fast reads of display block, no need for forcewake etc. */ |
| 721 | #define __raw_i915_read32(dev_priv__, reg__) readl((dev_priv__)->regs + (reg__)) |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 722 | |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 723 | static int __intel_get_crtc_scanline(struct intel_crtc *crtc) |
| 724 | { |
| 725 | struct drm_device *dev = crtc->base.dev; |
| 726 | struct drm_i915_private *dev_priv = dev->dev_private; |
Maarten Lankhorst | fc467a22 | 2015-06-01 12:50:07 +0200 | [diff] [blame] | 727 | const struct drm_display_mode *mode = &crtc->base.hwmode; |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 728 | enum pipe pipe = crtc->pipe; |
Ville Syrjälä | 80715b2 | 2014-05-15 20:23:23 +0300 | [diff] [blame] | 729 | int position, vtotal; |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 730 | |
Ville Syrjälä | 80715b2 | 2014-05-15 20:23:23 +0300 | [diff] [blame] | 731 | vtotal = mode->crtc_vtotal; |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 732 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
| 733 | vtotal /= 2; |
| 734 | |
| 735 | if (IS_GEN2(dev)) |
| 736 | position = __raw_i915_read32(dev_priv, PIPEDSL(pipe)) & DSL_LINEMASK_GEN2; |
| 737 | else |
| 738 | position = __raw_i915_read32(dev_priv, PIPEDSL(pipe)) & DSL_LINEMASK_GEN3; |
| 739 | |
| 740 | /* |
Jesse Barnes | 41b578f | 2015-09-22 12:15:54 -0700 | [diff] [blame] | 741 | * On HSW, the DSL reg (0x70000) appears to return 0 if we |
| 742 | * read it just before the start of vblank. So try it again |
| 743 | * so we don't accidentally end up spanning a vblank frame |
| 744 | * increment, causing the pipe_update_end() code to squak at us. |
| 745 | * |
| 746 | * The nature of this problem means we can't simply check the ISR |
| 747 | * bit and return the vblank start value; nor can we use the scanline |
| 748 | * debug register in the transcoder as it appears to have the same |
| 749 | * problem. We may need to extend this to include other platforms, |
| 750 | * but so far testing only shows the problem on HSW. |
| 751 | */ |
| 752 | if (IS_HASWELL(dev) && !position) { |
| 753 | int i, temp; |
| 754 | |
| 755 | for (i = 0; i < 100; i++) { |
| 756 | udelay(1); |
| 757 | temp = __raw_i915_read32(dev_priv, PIPEDSL(pipe)) & |
| 758 | DSL_LINEMASK_GEN3; |
| 759 | if (temp != position) { |
| 760 | position = temp; |
| 761 | break; |
| 762 | } |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | /* |
Ville Syrjälä | 80715b2 | 2014-05-15 20:23:23 +0300 | [diff] [blame] | 767 | * See update_scanline_offset() for the details on the |
| 768 | * scanline_offset adjustment. |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 769 | */ |
Ville Syrjälä | 80715b2 | 2014-05-15 20:23:23 +0300 | [diff] [blame] | 770 | return (position + crtc->scanline_offset) % vtotal; |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 771 | } |
| 772 | |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 773 | static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe, |
Ville Syrjälä | abca9e4 | 2013-10-28 20:50:48 +0200 | [diff] [blame] | 774 | unsigned int flags, int *vpos, int *hpos, |
Ville Syrjälä | 3bb403b | 2015-09-14 22:43:44 +0300 | [diff] [blame] | 775 | ktime_t *stime, ktime_t *etime, |
| 776 | const struct drm_display_mode *mode) |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 777 | { |
Ville Syrjälä | c2baf4b | 2013-09-23 14:48:50 +0300 | [diff] [blame] | 778 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 779 | struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe]; |
| 780 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Ville Syrjälä | 3aa18df | 2013-10-11 19:10:32 +0300 | [diff] [blame] | 781 | int position; |
Ville Syrjälä | 78e8fc6 | 2014-04-29 13:35:44 +0300 | [diff] [blame] | 782 | int vbl_start, vbl_end, hsync_start, htotal, vtotal; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 783 | bool in_vbl = true; |
| 784 | int ret = 0; |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 785 | unsigned long irqflags; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 786 | |
Maarten Lankhorst | fc467a22 | 2015-06-01 12:50:07 +0200 | [diff] [blame] | 787 | if (WARN_ON(!mode->crtc_clock)) { |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 788 | DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled " |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 789 | "pipe %c\n", pipe_name(pipe)); |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 790 | return 0; |
| 791 | } |
| 792 | |
Ville Syrjälä | c2baf4b | 2013-09-23 14:48:50 +0300 | [diff] [blame] | 793 | htotal = mode->crtc_htotal; |
Ville Syrjälä | 78e8fc6 | 2014-04-29 13:35:44 +0300 | [diff] [blame] | 794 | hsync_start = mode->crtc_hsync_start; |
Ville Syrjälä | c2baf4b | 2013-09-23 14:48:50 +0300 | [diff] [blame] | 795 | vtotal = mode->crtc_vtotal; |
| 796 | vbl_start = mode->crtc_vblank_start; |
| 797 | vbl_end = mode->crtc_vblank_end; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 798 | |
Ville Syrjälä | d31faf6 | 2013-10-28 16:31:41 +0200 | [diff] [blame] | 799 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { |
| 800 | vbl_start = DIV_ROUND_UP(vbl_start, 2); |
| 801 | vbl_end /= 2; |
| 802 | vtotal /= 2; |
| 803 | } |
| 804 | |
Ville Syrjälä | c2baf4b | 2013-09-23 14:48:50 +0300 | [diff] [blame] | 805 | ret |= DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE; |
| 806 | |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 807 | /* |
| 808 | * Lock uncore.lock, as we will do multiple timing critical raw |
| 809 | * register reads, potentially with preemption disabled, so the |
| 810 | * following code must not block on uncore.lock. |
| 811 | */ |
| 812 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
Ville Syrjälä | 78e8fc6 | 2014-04-29 13:35:44 +0300 | [diff] [blame] | 813 | |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 814 | /* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */ |
| 815 | |
| 816 | /* Get optional system timestamp before query. */ |
| 817 | if (stime) |
| 818 | *stime = ktime_get(); |
| 819 | |
Ville Syrjälä | 7c06b08 | 2013-10-11 21:52:43 +0300 | [diff] [blame] | 820 | if (IS_GEN2(dev) || IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) { |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 821 | /* No obvious pixelcount register. Only query vertical |
| 822 | * scanout position from Display scan line register. |
| 823 | */ |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 824 | position = __intel_get_crtc_scanline(intel_crtc); |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 825 | } else { |
| 826 | /* Have access to pixelcount since start of frame. |
| 827 | * We can split this into vertical and horizontal |
| 828 | * scanout position. |
| 829 | */ |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 830 | position = (__raw_i915_read32(dev_priv, PIPEFRAMEPIXEL(pipe)) & PIPE_PIXEL_MASK) >> PIPE_PIXEL_SHIFT; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 831 | |
Ville Syrjälä | 3aa18df | 2013-10-11 19:10:32 +0300 | [diff] [blame] | 832 | /* convert to pixel counts */ |
| 833 | vbl_start *= htotal; |
| 834 | vbl_end *= htotal; |
| 835 | vtotal *= htotal; |
Ville Syrjälä | 78e8fc6 | 2014-04-29 13:35:44 +0300 | [diff] [blame] | 836 | |
| 837 | /* |
Ville Syrjälä | 7e78f1cb | 2014-04-29 13:35:49 +0300 | [diff] [blame] | 838 | * In interlaced modes, the pixel counter counts all pixels, |
| 839 | * so one field will have htotal more pixels. In order to avoid |
| 840 | * the reported position from jumping backwards when the pixel |
| 841 | * counter is beyond the length of the shorter field, just |
| 842 | * clamp the position the length of the shorter field. This |
| 843 | * matches how the scanline counter based position works since |
| 844 | * the scanline counter doesn't count the two half lines. |
| 845 | */ |
| 846 | if (position >= vtotal) |
| 847 | position = vtotal - 1; |
| 848 | |
| 849 | /* |
Ville Syrjälä | 78e8fc6 | 2014-04-29 13:35:44 +0300 | [diff] [blame] | 850 | * Start of vblank interrupt is triggered at start of hsync, |
| 851 | * just prior to the first active line of vblank. However we |
| 852 | * consider lines to start at the leading edge of horizontal |
| 853 | * active. So, should we get here before we've crossed into |
| 854 | * the horizontal active of the first line in vblank, we would |
| 855 | * not set the DRM_SCANOUTPOS_INVBL flag. In order to fix that, |
| 856 | * always add htotal-hsync_start to the current pixel position. |
| 857 | */ |
| 858 | position = (position + htotal - hsync_start) % vtotal; |
Ville Syrjälä | 3aa18df | 2013-10-11 19:10:32 +0300 | [diff] [blame] | 859 | } |
| 860 | |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 861 | /* Get optional system timestamp after query. */ |
| 862 | if (etime) |
| 863 | *etime = ktime_get(); |
| 864 | |
| 865 | /* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */ |
| 866 | |
| 867 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
| 868 | |
Ville Syrjälä | 3aa18df | 2013-10-11 19:10:32 +0300 | [diff] [blame] | 869 | in_vbl = position >= vbl_start && position < vbl_end; |
| 870 | |
| 871 | /* |
| 872 | * While in vblank, position will be negative |
| 873 | * counting up towards 0 at vbl_end. And outside |
| 874 | * vblank, position will be positive counting |
| 875 | * up since vbl_end. |
| 876 | */ |
| 877 | if (position >= vbl_start) |
| 878 | position -= vbl_end; |
| 879 | else |
| 880 | position += vtotal - vbl_end; |
| 881 | |
Ville Syrjälä | 7c06b08 | 2013-10-11 21:52:43 +0300 | [diff] [blame] | 882 | if (IS_GEN2(dev) || IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) { |
Ville Syrjälä | 3aa18df | 2013-10-11 19:10:32 +0300 | [diff] [blame] | 883 | *vpos = position; |
| 884 | *hpos = 0; |
| 885 | } else { |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 886 | *vpos = position / htotal; |
| 887 | *hpos = position - (*vpos * htotal); |
| 888 | } |
| 889 | |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 890 | /* In vblank? */ |
| 891 | if (in_vbl) |
Daniel Vetter | 3d3cbd8 | 2014-09-10 17:36:11 +0200 | [diff] [blame] | 892 | ret |= DRM_SCANOUTPOS_IN_VBLANK; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 893 | |
| 894 | return ret; |
| 895 | } |
| 896 | |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 897 | int intel_get_crtc_scanline(struct intel_crtc *crtc) |
| 898 | { |
| 899 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 900 | unsigned long irqflags; |
| 901 | int position; |
| 902 | |
| 903 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
| 904 | position = __intel_get_crtc_scanline(crtc); |
| 905 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
| 906 | |
| 907 | return position; |
| 908 | } |
| 909 | |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 910 | static int i915_get_vblank_timestamp(struct drm_device *dev, int pipe, |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 911 | int *max_error, |
| 912 | struct timeval *vblank_time, |
| 913 | unsigned flags) |
| 914 | { |
Chris Wilson | 4041b85 | 2011-01-22 10:07:56 +0000 | [diff] [blame] | 915 | struct drm_crtc *crtc; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 916 | |
Ben Widawsky | 7eb552a | 2013-03-13 14:05:41 -0700 | [diff] [blame] | 917 | if (pipe < 0 || pipe >= INTEL_INFO(dev)->num_pipes) { |
Chris Wilson | 4041b85 | 2011-01-22 10:07:56 +0000 | [diff] [blame] | 918 | DRM_ERROR("Invalid crtc %d\n", pipe); |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 919 | return -EINVAL; |
| 920 | } |
| 921 | |
| 922 | /* Get drm_crtc to timestamp: */ |
Chris Wilson | 4041b85 | 2011-01-22 10:07:56 +0000 | [diff] [blame] | 923 | crtc = intel_get_crtc_for_pipe(dev, pipe); |
| 924 | if (crtc == NULL) { |
| 925 | DRM_ERROR("Invalid crtc %d\n", pipe); |
| 926 | return -EINVAL; |
| 927 | } |
| 928 | |
Maarten Lankhorst | fc467a22 | 2015-06-01 12:50:07 +0200 | [diff] [blame] | 929 | if (!crtc->hwmode.crtc_clock) { |
Chris Wilson | 4041b85 | 2011-01-22 10:07:56 +0000 | [diff] [blame] | 930 | DRM_DEBUG_KMS("crtc %d is disabled\n", pipe); |
| 931 | return -EBUSY; |
| 932 | } |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 933 | |
| 934 | /* Helper routine in DRM core does all the work: */ |
Chris Wilson | 4041b85 | 2011-01-22 10:07:56 +0000 | [diff] [blame] | 935 | return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error, |
| 936 | vblank_time, flags, |
Maarten Lankhorst | fc467a22 | 2015-06-01 12:50:07 +0200 | [diff] [blame] | 937 | &crtc->hwmode); |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 938 | } |
| 939 | |
Daniel Vetter | d0ecd7e | 2013-07-04 23:35:25 +0200 | [diff] [blame] | 940 | static void ironlake_rps_change_irq_handler(struct drm_device *dev) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 941 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 942 | struct drm_i915_private *dev_priv = dev->dev_private; |
Matthew Garrett | b5b72e8 | 2010-02-02 18:30:47 +0000 | [diff] [blame] | 943 | u32 busy_up, busy_down, max_avg, min_avg; |
Daniel Vetter | 9270388 | 2012-08-09 16:46:01 +0200 | [diff] [blame] | 944 | u8 new_delay; |
Daniel Vetter | 9270388 | 2012-08-09 16:46:01 +0200 | [diff] [blame] | 945 | |
Daniel Vetter | d0ecd7e | 2013-07-04 23:35:25 +0200 | [diff] [blame] | 946 | spin_lock(&mchdev_lock); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 947 | |
Daniel Vetter | 73edd18f | 2012-08-08 23:35:37 +0200 | [diff] [blame] | 948 | I915_WRITE16(MEMINTRSTS, I915_READ(MEMINTRSTS)); |
| 949 | |
Daniel Vetter | 20e4d40 | 2012-08-08 23:35:39 +0200 | [diff] [blame] | 950 | new_delay = dev_priv->ips.cur_delay; |
Daniel Vetter | 9270388 | 2012-08-09 16:46:01 +0200 | [diff] [blame] | 951 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 952 | I915_WRITE16(MEMINTRSTS, MEMINT_EVAL_CHG); |
Matthew Garrett | b5b72e8 | 2010-02-02 18:30:47 +0000 | [diff] [blame] | 953 | busy_up = I915_READ(RCPREVBSYTUPAVG); |
| 954 | busy_down = I915_READ(RCPREVBSYTDNAVG); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 955 | max_avg = I915_READ(RCBMAXAVG); |
| 956 | min_avg = I915_READ(RCBMINAVG); |
| 957 | |
| 958 | /* Handle RCS change request from hw */ |
Matthew Garrett | b5b72e8 | 2010-02-02 18:30:47 +0000 | [diff] [blame] | 959 | if (busy_up > max_avg) { |
Daniel Vetter | 20e4d40 | 2012-08-08 23:35:39 +0200 | [diff] [blame] | 960 | if (dev_priv->ips.cur_delay != dev_priv->ips.max_delay) |
| 961 | new_delay = dev_priv->ips.cur_delay - 1; |
| 962 | if (new_delay < dev_priv->ips.max_delay) |
| 963 | new_delay = dev_priv->ips.max_delay; |
Matthew Garrett | b5b72e8 | 2010-02-02 18:30:47 +0000 | [diff] [blame] | 964 | } else if (busy_down < min_avg) { |
Daniel Vetter | 20e4d40 | 2012-08-08 23:35:39 +0200 | [diff] [blame] | 965 | if (dev_priv->ips.cur_delay != dev_priv->ips.min_delay) |
| 966 | new_delay = dev_priv->ips.cur_delay + 1; |
| 967 | if (new_delay > dev_priv->ips.min_delay) |
| 968 | new_delay = dev_priv->ips.min_delay; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 969 | } |
| 970 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 971 | if (ironlake_set_drps(dev, new_delay)) |
Daniel Vetter | 20e4d40 | 2012-08-08 23:35:39 +0200 | [diff] [blame] | 972 | dev_priv->ips.cur_delay = new_delay; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 973 | |
Daniel Vetter | d0ecd7e | 2013-07-04 23:35:25 +0200 | [diff] [blame] | 974 | spin_unlock(&mchdev_lock); |
Daniel Vetter | 9270388 | 2012-08-09 16:46:01 +0200 | [diff] [blame] | 975 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 976 | return; |
| 977 | } |
| 978 | |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 979 | static void notify_ring(struct intel_engine_cs *ring) |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 980 | { |
Oscar Mateo | 93b0a4e | 2014-05-22 14:13:36 +0100 | [diff] [blame] | 981 | if (!intel_ring_initialized(ring)) |
Chris Wilson | 475553d | 2011-01-20 09:52:56 +0000 | [diff] [blame] | 982 | return; |
| 983 | |
John Harrison | bcfcc8b | 2014-12-05 13:49:36 +0000 | [diff] [blame] | 984 | trace_i915_gem_request_notify(ring); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 985 | |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 986 | wake_up_all(&ring->irq_queue); |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 987 | } |
| 988 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 989 | static void vlv_c0_read(struct drm_i915_private *dev_priv, |
| 990 | struct intel_rps_ei *ei) |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 991 | { |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 992 | ei->cz_clock = vlv_punit_read(dev_priv, PUNIT_REG_CZ_TIMESTAMP); |
| 993 | ei->render_c0 = I915_READ(VLV_RENDER_C0_COUNT); |
| 994 | ei->media_c0 = I915_READ(VLV_MEDIA_C0_COUNT); |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 995 | } |
| 996 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 997 | static bool vlv_c0_above(struct drm_i915_private *dev_priv, |
| 998 | const struct intel_rps_ei *old, |
| 999 | const struct intel_rps_ei *now, |
| 1000 | int threshold) |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1001 | { |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1002 | u64 time, c0; |
Ville Syrjälä | 7bad74d | 2015-09-24 23:29:20 +0300 | [diff] [blame] | 1003 | unsigned int mul = 100; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1004 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1005 | if (old->cz_clock == 0) |
| 1006 | return false; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1007 | |
Ville Syrjälä | 7bad74d | 2015-09-24 23:29:20 +0300 | [diff] [blame] | 1008 | if (I915_READ(VLV_COUNTER_CONTROL) & VLV_COUNT_RANGE_HIGH) |
| 1009 | mul <<= 8; |
| 1010 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1011 | time = now->cz_clock - old->cz_clock; |
Ville Syrjälä | 7bad74d | 2015-09-24 23:29:20 +0300 | [diff] [blame] | 1012 | time *= threshold * dev_priv->czclk_freq; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1013 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1014 | /* Workload can be split between render + media, e.g. SwapBuffers |
| 1015 | * being blitted in X after being rendered in mesa. To account for |
| 1016 | * this we need to combine both engines into our activity counter. |
| 1017 | */ |
| 1018 | c0 = now->render_c0 - old->render_c0; |
| 1019 | c0 += now->media_c0 - old->media_c0; |
Ville Syrjälä | 7bad74d | 2015-09-24 23:29:20 +0300 | [diff] [blame] | 1020 | c0 *= mul * VLV_CZ_CLOCK_TO_MILLI_SEC; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1021 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1022 | return c0 >= time; |
| 1023 | } |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1024 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1025 | void gen6_rps_reset_ei(struct drm_i915_private *dev_priv) |
| 1026 | { |
| 1027 | vlv_c0_read(dev_priv, &dev_priv->rps.down_ei); |
| 1028 | dev_priv->rps.up_ei = dev_priv->rps.down_ei; |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1029 | } |
| 1030 | |
| 1031 | static u32 vlv_wa_c0_ei(struct drm_i915_private *dev_priv, u32 pm_iir) |
| 1032 | { |
| 1033 | struct intel_rps_ei now; |
| 1034 | u32 events = 0; |
| 1035 | |
Chris Wilson | 6f4b12f8 | 2015-03-18 09:48:23 +0000 | [diff] [blame] | 1036 | if ((pm_iir & (GEN6_PM_RP_DOWN_EI_EXPIRED | GEN6_PM_RP_UP_EI_EXPIRED)) == 0) |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1037 | return 0; |
| 1038 | |
| 1039 | vlv_c0_read(dev_priv, &now); |
| 1040 | if (now.cz_clock == 0) |
| 1041 | return 0; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1042 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1043 | if (pm_iir & GEN6_PM_RP_DOWN_EI_EXPIRED) { |
| 1044 | if (!vlv_c0_above(dev_priv, |
| 1045 | &dev_priv->rps.down_ei, &now, |
Chris Wilson | 8fb5519 | 2015-04-07 16:20:28 +0100 | [diff] [blame] | 1046 | dev_priv->rps.down_threshold)) |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1047 | events |= GEN6_PM_RP_DOWN_THRESHOLD; |
| 1048 | dev_priv->rps.down_ei = now; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1049 | } |
| 1050 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1051 | if (pm_iir & GEN6_PM_RP_UP_EI_EXPIRED) { |
| 1052 | if (vlv_c0_above(dev_priv, |
| 1053 | &dev_priv->rps.up_ei, &now, |
Chris Wilson | 8fb5519 | 2015-04-07 16:20:28 +0100 | [diff] [blame] | 1054 | dev_priv->rps.up_threshold)) |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1055 | events |= GEN6_PM_RP_UP_THRESHOLD; |
| 1056 | dev_priv->rps.up_ei = now; |
| 1057 | } |
| 1058 | |
| 1059 | return events; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1060 | } |
| 1061 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 1062 | static bool any_waiters(struct drm_i915_private *dev_priv) |
| 1063 | { |
| 1064 | struct intel_engine_cs *ring; |
| 1065 | int i; |
| 1066 | |
| 1067 | for_each_ring(ring, dev_priv, i) |
| 1068 | if (ring->irq_refcount) |
| 1069 | return true; |
| 1070 | |
| 1071 | return false; |
| 1072 | } |
| 1073 | |
Ben Widawsky | 4912d04 | 2011-04-25 11:25:20 -0700 | [diff] [blame] | 1074 | static void gen6_pm_rps_work(struct work_struct *work) |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1075 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 1076 | struct drm_i915_private *dev_priv = |
| 1077 | container_of(work, struct drm_i915_private, rps.work); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 1078 | bool client_boost; |
| 1079 | int new_delay, adj, min, max; |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 1080 | u32 pm_iir; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1081 | |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1082 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | d4d70aa | 2014-11-19 15:30:04 +0200 | [diff] [blame] | 1083 | /* Speed up work cancelation during disabling rps interrupts. */ |
| 1084 | if (!dev_priv->rps.interrupts_enabled) { |
| 1085 | spin_unlock_irq(&dev_priv->irq_lock); |
| 1086 | return; |
| 1087 | } |
Daniel Vetter | c6a828d | 2012-08-08 23:35:35 +0200 | [diff] [blame] | 1088 | pm_iir = dev_priv->rps.pm_iir; |
| 1089 | dev_priv->rps.pm_iir = 0; |
Imre Deak | a72fbc3 | 2014-11-05 20:48:31 +0200 | [diff] [blame] | 1090 | /* Make sure not to corrupt PMIMR state used by ringbuffer on GEN6 */ |
| 1091 | gen6_enable_pm_irq(dev_priv, dev_priv->pm_rps_events); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 1092 | client_boost = dev_priv->rps.client_boost; |
| 1093 | dev_priv->rps.client_boost = false; |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1094 | spin_unlock_irq(&dev_priv->irq_lock); |
Ben Widawsky | 4912d04 | 2011-04-25 11:25:20 -0700 | [diff] [blame] | 1095 | |
Paulo Zanoni | 60611c1 | 2013-08-15 11:50:01 -0300 | [diff] [blame] | 1096 | /* Make sure we didn't queue anything we're not going to process. */ |
Deepak S | a6706b4 | 2014-03-15 20:23:22 +0530 | [diff] [blame] | 1097 | WARN_ON(pm_iir & ~dev_priv->pm_rps_events); |
Paulo Zanoni | 60611c1 | 2013-08-15 11:50:01 -0300 | [diff] [blame] | 1098 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 1099 | if ((pm_iir & dev_priv->pm_rps_events) == 0 && !client_boost) |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1100 | return; |
| 1101 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1102 | mutex_lock(&dev_priv->rps.hw_lock); |
Chris Wilson | 7b9e0ae | 2012-04-28 08:56:39 +0100 | [diff] [blame] | 1103 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1104 | pm_iir |= vlv_wa_c0_ei(dev_priv, pm_iir); |
| 1105 | |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1106 | adj = dev_priv->rps.last_adj; |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1107 | new_delay = dev_priv->rps.cur_freq; |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 1108 | min = dev_priv->rps.min_freq_softlimit; |
| 1109 | max = dev_priv->rps.max_freq_softlimit; |
| 1110 | |
| 1111 | if (client_boost) { |
| 1112 | new_delay = dev_priv->rps.max_freq_softlimit; |
| 1113 | adj = 0; |
| 1114 | } else if (pm_iir & GEN6_PM_RP_UP_THRESHOLD) { |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1115 | if (adj > 0) |
| 1116 | adj *= 2; |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1117 | else /* CHV needs even encode values */ |
| 1118 | adj = IS_CHERRYVIEW(dev_priv) ? 2 : 1; |
Ville Syrjälä | 7425034 | 2013-06-25 21:38:11 +0300 | [diff] [blame] | 1119 | /* |
| 1120 | * For better performance, jump directly |
| 1121 | * to RPe if we're below it. |
| 1122 | */ |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1123 | if (new_delay < dev_priv->rps.efficient_freq - adj) { |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 1124 | new_delay = dev_priv->rps.efficient_freq; |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1125 | adj = 0; |
| 1126 | } |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 1127 | } else if (any_waiters(dev_priv)) { |
| 1128 | adj = 0; |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1129 | } else if (pm_iir & GEN6_PM_RP_DOWN_TIMEOUT) { |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 1130 | if (dev_priv->rps.cur_freq > dev_priv->rps.efficient_freq) |
| 1131 | new_delay = dev_priv->rps.efficient_freq; |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1132 | else |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 1133 | new_delay = dev_priv->rps.min_freq_softlimit; |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1134 | adj = 0; |
| 1135 | } else if (pm_iir & GEN6_PM_RP_DOWN_THRESHOLD) { |
| 1136 | if (adj < 0) |
| 1137 | adj *= 2; |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1138 | else /* CHV needs even encode values */ |
| 1139 | adj = IS_CHERRYVIEW(dev_priv) ? -2 : -1; |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1140 | } else { /* unknown event */ |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1141 | adj = 0; |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1142 | } |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1143 | |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1144 | dev_priv->rps.last_adj = adj; |
| 1145 | |
Ben Widawsky | 7924963 | 2012-09-07 19:43:42 -0700 | [diff] [blame] | 1146 | /* sysfs frequency interfaces may have snuck in while servicing the |
| 1147 | * interrupt |
| 1148 | */ |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1149 | new_delay += adj; |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 1150 | new_delay = clamp_t(int, new_delay, min, max); |
Deepak S | 2754436 | 2014-01-27 21:35:05 +0530 | [diff] [blame] | 1151 | |
Ville Syrjälä | ffe02b4 | 2015-02-02 19:09:50 +0200 | [diff] [blame] | 1152 | intel_set_rps(dev_priv->dev, new_delay); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1153 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1154 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1155 | } |
| 1156 | |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1157 | |
| 1158 | /** |
| 1159 | * ivybridge_parity_work - Workqueue called when a parity error interrupt |
| 1160 | * occurred. |
| 1161 | * @work: workqueue struct |
| 1162 | * |
| 1163 | * Doesn't actually do anything except notify userspace. As a consequence of |
| 1164 | * this event, userspace should try to remap the bad rows since statistically |
| 1165 | * it is likely the same row is more likely to go bad again. |
| 1166 | */ |
| 1167 | static void ivybridge_parity_work(struct work_struct *work) |
| 1168 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 1169 | struct drm_i915_private *dev_priv = |
| 1170 | container_of(work, struct drm_i915_private, l3_parity.error_work); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1171 | u32 error_status, row, bank, subbank; |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1172 | char *parity_event[6]; |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1173 | uint32_t misccpctl; |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1174 | uint8_t slice = 0; |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1175 | |
| 1176 | /* We must turn off DOP level clock gating to access the L3 registers. |
| 1177 | * In order to prevent a get/put style interface, acquire struct mutex |
| 1178 | * any time we access those registers. |
| 1179 | */ |
| 1180 | mutex_lock(&dev_priv->dev->struct_mutex); |
| 1181 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1182 | /* If we've screwed up tracking, just let the interrupt fire again */ |
| 1183 | if (WARN_ON(!dev_priv->l3_parity.which_slice)) |
| 1184 | goto out; |
| 1185 | |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1186 | misccpctl = I915_READ(GEN7_MISCCPCTL); |
| 1187 | I915_WRITE(GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE); |
| 1188 | POSTING_READ(GEN7_MISCCPCTL); |
| 1189 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1190 | while ((slice = ffs(dev_priv->l3_parity.which_slice)) != 0) { |
| 1191 | u32 reg; |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1192 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1193 | slice--; |
| 1194 | if (WARN_ON_ONCE(slice >= NUM_L3_SLICES(dev_priv->dev))) |
| 1195 | break; |
| 1196 | |
| 1197 | dev_priv->l3_parity.which_slice &= ~(1<<slice); |
| 1198 | |
| 1199 | reg = GEN7_L3CDERRST1 + (slice * 0x200); |
| 1200 | |
| 1201 | error_status = I915_READ(reg); |
| 1202 | row = GEN7_PARITY_ERROR_ROW(error_status); |
| 1203 | bank = GEN7_PARITY_ERROR_BANK(error_status); |
| 1204 | subbank = GEN7_PARITY_ERROR_SUBBANK(error_status); |
| 1205 | |
| 1206 | I915_WRITE(reg, GEN7_PARITY_ERROR_VALID | GEN7_L3CDERRST1_ENABLE); |
| 1207 | POSTING_READ(reg); |
| 1208 | |
| 1209 | parity_event[0] = I915_L3_PARITY_UEVENT "=1"; |
| 1210 | parity_event[1] = kasprintf(GFP_KERNEL, "ROW=%d", row); |
| 1211 | parity_event[2] = kasprintf(GFP_KERNEL, "BANK=%d", bank); |
| 1212 | parity_event[3] = kasprintf(GFP_KERNEL, "SUBBANK=%d", subbank); |
| 1213 | parity_event[4] = kasprintf(GFP_KERNEL, "SLICE=%d", slice); |
| 1214 | parity_event[5] = NULL; |
| 1215 | |
Dave Airlie | 5bdebb1 | 2013-10-11 14:07:25 +1000 | [diff] [blame] | 1216 | kobject_uevent_env(&dev_priv->dev->primary->kdev->kobj, |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1217 | KOBJ_CHANGE, parity_event); |
| 1218 | |
| 1219 | DRM_DEBUG("Parity error: Slice = %d, Row = %d, Bank = %d, Sub bank = %d.\n", |
| 1220 | slice, row, bank, subbank); |
| 1221 | |
| 1222 | kfree(parity_event[4]); |
| 1223 | kfree(parity_event[3]); |
| 1224 | kfree(parity_event[2]); |
| 1225 | kfree(parity_event[1]); |
| 1226 | } |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1227 | |
| 1228 | I915_WRITE(GEN7_MISCCPCTL, misccpctl); |
| 1229 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1230 | out: |
| 1231 | WARN_ON(dev_priv->l3_parity.which_slice); |
Daniel Vetter | 4cb2183 | 2014-09-15 14:55:26 +0200 | [diff] [blame] | 1232 | spin_lock_irq(&dev_priv->irq_lock); |
Daniel Vetter | 480c803 | 2014-07-16 09:49:40 +0200 | [diff] [blame] | 1233 | gen5_enable_gt_irq(dev_priv, GT_PARITY_ERROR(dev_priv->dev)); |
Daniel Vetter | 4cb2183 | 2014-09-15 14:55:26 +0200 | [diff] [blame] | 1234 | spin_unlock_irq(&dev_priv->irq_lock); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1235 | |
| 1236 | mutex_unlock(&dev_priv->dev->struct_mutex); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1237 | } |
| 1238 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1239 | static void ivybridge_parity_error_irq_handler(struct drm_device *dev, u32 iir) |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1240 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 1241 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1242 | |
Ben Widawsky | 040d2ba | 2013-09-19 11:01:40 -0700 | [diff] [blame] | 1243 | if (!HAS_L3_DPF(dev)) |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1244 | return; |
| 1245 | |
Daniel Vetter | d0ecd7e | 2013-07-04 23:35:25 +0200 | [diff] [blame] | 1246 | spin_lock(&dev_priv->irq_lock); |
Daniel Vetter | 480c803 | 2014-07-16 09:49:40 +0200 | [diff] [blame] | 1247 | gen5_disable_gt_irq(dev_priv, GT_PARITY_ERROR(dev)); |
Daniel Vetter | d0ecd7e | 2013-07-04 23:35:25 +0200 | [diff] [blame] | 1248 | spin_unlock(&dev_priv->irq_lock); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1249 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1250 | iir &= GT_PARITY_ERROR(dev); |
| 1251 | if (iir & GT_RENDER_L3_PARITY_ERROR_INTERRUPT_S1) |
| 1252 | dev_priv->l3_parity.which_slice |= 1 << 1; |
| 1253 | |
| 1254 | if (iir & GT_RENDER_L3_PARITY_ERROR_INTERRUPT) |
| 1255 | dev_priv->l3_parity.which_slice |= 1 << 0; |
| 1256 | |
Daniel Vetter | a4da4fa | 2012-11-02 19:55:07 +0100 | [diff] [blame] | 1257 | queue_work(dev_priv->wq, &dev_priv->l3_parity.error_work); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1258 | } |
| 1259 | |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 1260 | static void ilk_gt_irq_handler(struct drm_device *dev, |
| 1261 | struct drm_i915_private *dev_priv, |
| 1262 | u32 gt_iir) |
| 1263 | { |
| 1264 | if (gt_iir & |
| 1265 | (GT_RENDER_USER_INTERRUPT | GT_RENDER_PIPECTL_NOTIFY_INTERRUPT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1266 | notify_ring(&dev_priv->ring[RCS]); |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 1267 | if (gt_iir & ILK_BSD_USER_INTERRUPT) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1268 | notify_ring(&dev_priv->ring[VCS]); |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 1269 | } |
| 1270 | |
Daniel Vetter | e7b4c6b | 2012-03-30 20:24:35 +0200 | [diff] [blame] | 1271 | static void snb_gt_irq_handler(struct drm_device *dev, |
| 1272 | struct drm_i915_private *dev_priv, |
| 1273 | u32 gt_iir) |
| 1274 | { |
| 1275 | |
Ben Widawsky | cc609d5 | 2013-05-28 19:22:29 -0700 | [diff] [blame] | 1276 | if (gt_iir & |
| 1277 | (GT_RENDER_USER_INTERRUPT | GT_RENDER_PIPECTL_NOTIFY_INTERRUPT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1278 | notify_ring(&dev_priv->ring[RCS]); |
Ben Widawsky | cc609d5 | 2013-05-28 19:22:29 -0700 | [diff] [blame] | 1279 | if (gt_iir & GT_BSD_USER_INTERRUPT) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1280 | notify_ring(&dev_priv->ring[VCS]); |
Ben Widawsky | cc609d5 | 2013-05-28 19:22:29 -0700 | [diff] [blame] | 1281 | if (gt_iir & GT_BLT_USER_INTERRUPT) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1282 | notify_ring(&dev_priv->ring[BCS]); |
Daniel Vetter | e7b4c6b | 2012-03-30 20:24:35 +0200 | [diff] [blame] | 1283 | |
Ben Widawsky | cc609d5 | 2013-05-28 19:22:29 -0700 | [diff] [blame] | 1284 | if (gt_iir & (GT_BLT_CS_ERROR_INTERRUPT | |
| 1285 | GT_BSD_CS_ERROR_INTERRUPT | |
Daniel Vetter | aaecdf6 | 2014-11-04 15:52:22 +0100 | [diff] [blame] | 1286 | GT_RENDER_CS_MASTER_ERROR_INTERRUPT)) |
| 1287 | DRM_DEBUG("Command parser error, gt_iir 0x%08x\n", gt_iir); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1288 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1289 | if (gt_iir & GT_PARITY_ERROR(dev)) |
| 1290 | ivybridge_parity_error_irq_handler(dev, gt_iir); |
Daniel Vetter | e7b4c6b | 2012-03-30 20:24:35 +0200 | [diff] [blame] | 1291 | } |
| 1292 | |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1293 | static irqreturn_t gen8_gt_irq_handler(struct drm_i915_private *dev_priv, |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1294 | u32 master_ctl) |
| 1295 | { |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1296 | irqreturn_t ret = IRQ_NONE; |
| 1297 | |
| 1298 | if (master_ctl & (GEN8_GT_RCS_IRQ | GEN8_GT_BCS_IRQ)) { |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1299 | u32 iir = I915_READ_FW(GEN8_GT_IIR(0)); |
| 1300 | if (iir) { |
| 1301 | I915_WRITE_FW(GEN8_GT_IIR(0), iir); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1302 | ret = IRQ_HANDLED; |
Thomas Daniel | e981e7b | 2014-07-24 17:04:39 +0100 | [diff] [blame] | 1303 | |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1304 | if (iir & (GT_CONTEXT_SWITCH_INTERRUPT << GEN8_RCS_IRQ_SHIFT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1305 | intel_lrc_irq_handler(&dev_priv->ring[RCS]); |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1306 | if (iir & (GT_RENDER_USER_INTERRUPT << GEN8_RCS_IRQ_SHIFT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1307 | notify_ring(&dev_priv->ring[RCS]); |
Thomas Daniel | e981e7b | 2014-07-24 17:04:39 +0100 | [diff] [blame] | 1308 | |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1309 | if (iir & (GT_CONTEXT_SWITCH_INTERRUPT << GEN8_BCS_IRQ_SHIFT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1310 | intel_lrc_irq_handler(&dev_priv->ring[BCS]); |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1311 | if (iir & (GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1312 | notify_ring(&dev_priv->ring[BCS]); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1313 | } else |
| 1314 | DRM_ERROR("The master control interrupt lied (GT0)!\n"); |
| 1315 | } |
| 1316 | |
Zhao Yakui | 85f9b5f | 2014-04-17 10:37:38 +0800 | [diff] [blame] | 1317 | if (master_ctl & (GEN8_GT_VCS1_IRQ | GEN8_GT_VCS2_IRQ)) { |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1318 | u32 iir = I915_READ_FW(GEN8_GT_IIR(1)); |
| 1319 | if (iir) { |
| 1320 | I915_WRITE_FW(GEN8_GT_IIR(1), iir); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1321 | ret = IRQ_HANDLED; |
Thomas Daniel | e981e7b | 2014-07-24 17:04:39 +0100 | [diff] [blame] | 1322 | |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1323 | if (iir & (GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS1_IRQ_SHIFT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1324 | intel_lrc_irq_handler(&dev_priv->ring[VCS]); |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1325 | if (iir & (GT_RENDER_USER_INTERRUPT << GEN8_VCS1_IRQ_SHIFT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1326 | notify_ring(&dev_priv->ring[VCS]); |
Thomas Daniel | e981e7b | 2014-07-24 17:04:39 +0100 | [diff] [blame] | 1327 | |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1328 | if (iir & (GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS2_IRQ_SHIFT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1329 | intel_lrc_irq_handler(&dev_priv->ring[VCS2]); |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1330 | if (iir & (GT_RENDER_USER_INTERRUPT << GEN8_VCS2_IRQ_SHIFT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1331 | notify_ring(&dev_priv->ring[VCS2]); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1332 | } else |
| 1333 | DRM_ERROR("The master control interrupt lied (GT1)!\n"); |
| 1334 | } |
| 1335 | |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1336 | if (master_ctl & GEN8_GT_VECS_IRQ) { |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1337 | u32 iir = I915_READ_FW(GEN8_GT_IIR(3)); |
| 1338 | if (iir) { |
| 1339 | I915_WRITE_FW(GEN8_GT_IIR(3), iir); |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1340 | ret = IRQ_HANDLED; |
| 1341 | |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1342 | if (iir & (GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VECS_IRQ_SHIFT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1343 | intel_lrc_irq_handler(&dev_priv->ring[VECS]); |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1344 | if (iir & (GT_RENDER_USER_INTERRUPT << GEN8_VECS_IRQ_SHIFT)) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1345 | notify_ring(&dev_priv->ring[VECS]); |
| 1346 | } else |
| 1347 | DRM_ERROR("The master control interrupt lied (GT3)!\n"); |
| 1348 | } |
| 1349 | |
Ben Widawsky | 0961021 | 2014-05-15 20:58:08 +0300 | [diff] [blame] | 1350 | if (master_ctl & GEN8_GT_PM_IRQ) { |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1351 | u32 iir = I915_READ_FW(GEN8_GT_IIR(2)); |
| 1352 | if (iir & dev_priv->pm_rps_events) { |
Chris Wilson | cb0d205 | 2015-04-07 16:21:04 +0100 | [diff] [blame] | 1353 | I915_WRITE_FW(GEN8_GT_IIR(2), |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1354 | iir & dev_priv->pm_rps_events); |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 1355 | ret = IRQ_HANDLED; |
Nick Hoath | 5dd280b | 2015-10-20 10:23:51 +0100 | [diff] [blame^] | 1356 | gen6_rps_irq_handler(dev_priv, iir); |
Ben Widawsky | 0961021 | 2014-05-15 20:58:08 +0300 | [diff] [blame] | 1357 | } else |
| 1358 | DRM_ERROR("The master control interrupt lied (PM)!\n"); |
| 1359 | } |
| 1360 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1361 | return ret; |
| 1362 | } |
| 1363 | |
Imre Deak | 63c88d2 | 2015-07-20 14:43:39 -0700 | [diff] [blame] | 1364 | static bool bxt_port_hotplug_long_detect(enum port port, u32 val) |
| 1365 | { |
| 1366 | switch (port) { |
| 1367 | case PORT_A: |
Ville Syrjälä | 195baa0 | 2015-08-27 23:56:00 +0300 | [diff] [blame] | 1368 | return val & PORTA_HOTPLUG_LONG_DETECT; |
Imre Deak | 63c88d2 | 2015-07-20 14:43:39 -0700 | [diff] [blame] | 1369 | case PORT_B: |
| 1370 | return val & PORTB_HOTPLUG_LONG_DETECT; |
| 1371 | case PORT_C: |
| 1372 | return val & PORTC_HOTPLUG_LONG_DETECT; |
Imre Deak | 63c88d2 | 2015-07-20 14:43:39 -0700 | [diff] [blame] | 1373 | default: |
| 1374 | return false; |
| 1375 | } |
| 1376 | } |
| 1377 | |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 1378 | static bool spt_port_hotplug2_long_detect(enum port port, u32 val) |
| 1379 | { |
| 1380 | switch (port) { |
| 1381 | case PORT_E: |
| 1382 | return val & PORTE_HOTPLUG_LONG_DETECT; |
| 1383 | default: |
| 1384 | return false; |
| 1385 | } |
| 1386 | } |
| 1387 | |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 1388 | static bool spt_port_hotplug_long_detect(enum port port, u32 val) |
| 1389 | { |
| 1390 | switch (port) { |
| 1391 | case PORT_A: |
| 1392 | return val & PORTA_HOTPLUG_LONG_DETECT; |
| 1393 | case PORT_B: |
| 1394 | return val & PORTB_HOTPLUG_LONG_DETECT; |
| 1395 | case PORT_C: |
| 1396 | return val & PORTC_HOTPLUG_LONG_DETECT; |
| 1397 | case PORT_D: |
| 1398 | return val & PORTD_HOTPLUG_LONG_DETECT; |
| 1399 | default: |
| 1400 | return false; |
| 1401 | } |
| 1402 | } |
| 1403 | |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 1404 | static bool ilk_port_hotplug_long_detect(enum port port, u32 val) |
| 1405 | { |
| 1406 | switch (port) { |
| 1407 | case PORT_A: |
| 1408 | return val & DIGITAL_PORTA_HOTPLUG_LONG_DETECT; |
| 1409 | default: |
| 1410 | return false; |
| 1411 | } |
| 1412 | } |
| 1413 | |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1414 | static bool pch_port_hotplug_long_detect(enum port port, u32 val) |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1415 | { |
| 1416 | switch (port) { |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1417 | case PORT_B: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1418 | return val & PORTB_HOTPLUG_LONG_DETECT; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1419 | case PORT_C: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1420 | return val & PORTC_HOTPLUG_LONG_DETECT; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1421 | case PORT_D: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1422 | return val & PORTD_HOTPLUG_LONG_DETECT; |
| 1423 | default: |
| 1424 | return false; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1425 | } |
| 1426 | } |
| 1427 | |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1428 | static bool i9xx_port_hotplug_long_detect(enum port port, u32 val) |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1429 | { |
| 1430 | switch (port) { |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1431 | case PORT_B: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1432 | return val & PORTB_HOTPLUG_INT_LONG_PULSE; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1433 | case PORT_C: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1434 | return val & PORTC_HOTPLUG_INT_LONG_PULSE; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1435 | case PORT_D: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1436 | return val & PORTD_HOTPLUG_INT_LONG_PULSE; |
| 1437 | default: |
| 1438 | return false; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1439 | } |
| 1440 | } |
| 1441 | |
Ville Syrjälä | 42db67d | 2015-08-28 21:26:27 +0300 | [diff] [blame] | 1442 | /* |
| 1443 | * Get a bit mask of pins that have triggered, and which ones may be long. |
| 1444 | * This can be called multiple times with the same masks to accumulate |
| 1445 | * hotplug detection results from several registers. |
| 1446 | * |
| 1447 | * Note that the caller is expected to zero out the masks initially. |
| 1448 | */ |
Imre Deak | fd63e2a | 2015-07-21 15:32:44 -0700 | [diff] [blame] | 1449 | static void intel_get_hpd_pins(u32 *pin_mask, u32 *long_mask, |
Jani Nikula | 8c841e5 | 2015-06-18 13:06:17 +0300 | [diff] [blame] | 1450 | u32 hotplug_trigger, u32 dig_hotplug_reg, |
Imre Deak | fd63e2a | 2015-07-21 15:32:44 -0700 | [diff] [blame] | 1451 | const u32 hpd[HPD_NUM_PINS], |
| 1452 | bool long_pulse_detect(enum port port, u32 val)) |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1453 | { |
Jani Nikula | 8c841e5 | 2015-06-18 13:06:17 +0300 | [diff] [blame] | 1454 | enum port port; |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1455 | int i; |
| 1456 | |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1457 | for_each_hpd_pin(i) { |
Jani Nikula | 8c841e5 | 2015-06-18 13:06:17 +0300 | [diff] [blame] | 1458 | if ((hpd[i] & hotplug_trigger) == 0) |
| 1459 | continue; |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1460 | |
Jani Nikula | 8c841e5 | 2015-06-18 13:06:17 +0300 | [diff] [blame] | 1461 | *pin_mask |= BIT(i); |
| 1462 | |
Imre Deak | cc24fcd | 2015-07-21 15:32:45 -0700 | [diff] [blame] | 1463 | if (!intel_hpd_pin_to_port(i, &port)) |
| 1464 | continue; |
| 1465 | |
Imre Deak | fd63e2a | 2015-07-21 15:32:44 -0700 | [diff] [blame] | 1466 | if (long_pulse_detect(port, dig_hotplug_reg)) |
Jani Nikula | 8c841e5 | 2015-06-18 13:06:17 +0300 | [diff] [blame] | 1467 | *long_mask |= BIT(i); |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1468 | } |
| 1469 | |
| 1470 | DRM_DEBUG_DRIVER("hotplug event received, stat 0x%08x, dig 0x%08x, pins 0x%08x\n", |
| 1471 | hotplug_trigger, dig_hotplug_reg, *pin_mask); |
| 1472 | |
| 1473 | } |
| 1474 | |
Daniel Vetter | 515ac2b | 2012-12-01 13:53:44 +0100 | [diff] [blame] | 1475 | static void gmbus_irq_handler(struct drm_device *dev) |
| 1476 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 1477 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 28c70f1 | 2012-12-01 13:53:45 +0100 | [diff] [blame] | 1478 | |
Daniel Vetter | 28c70f1 | 2012-12-01 13:53:45 +0100 | [diff] [blame] | 1479 | wake_up_all(&dev_priv->gmbus_wait_queue); |
Daniel Vetter | 515ac2b | 2012-12-01 13:53:44 +0100 | [diff] [blame] | 1480 | } |
| 1481 | |
Daniel Vetter | ce99c25 | 2012-12-01 13:53:47 +0100 | [diff] [blame] | 1482 | static void dp_aux_irq_handler(struct drm_device *dev) |
| 1483 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 1484 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1485 | |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1486 | wake_up_all(&dev_priv->gmbus_wait_queue); |
Daniel Vetter | ce99c25 | 2012-12-01 13:53:47 +0100 | [diff] [blame] | 1487 | } |
| 1488 | |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1489 | #if defined(CONFIG_DEBUG_FS) |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1490 | static void display_pipe_crc_irq_handler(struct drm_device *dev, enum pipe pipe, |
| 1491 | uint32_t crc0, uint32_t crc1, |
| 1492 | uint32_t crc2, uint32_t crc3, |
| 1493 | uint32_t crc4) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1494 | { |
| 1495 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1496 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
| 1497 | struct intel_pipe_crc_entry *entry; |
Damien Lespiau | ac2300d | 2013-10-15 18:55:30 +0100 | [diff] [blame] | 1498 | int head, tail; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 1499 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 1500 | spin_lock(&pipe_crc->lock); |
| 1501 | |
Damien Lespiau | 0c912c7 | 2013-10-15 18:55:37 +0100 | [diff] [blame] | 1502 | if (!pipe_crc->entries) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 1503 | spin_unlock(&pipe_crc->lock); |
Daniel Vetter | 3427362 | 2014-11-26 16:29:04 +0100 | [diff] [blame] | 1504 | DRM_DEBUG_KMS("spurious interrupt\n"); |
Damien Lespiau | 0c912c7 | 2013-10-15 18:55:37 +0100 | [diff] [blame] | 1505 | return; |
| 1506 | } |
| 1507 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 1508 | head = pipe_crc->head; |
| 1509 | tail = pipe_crc->tail; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 1510 | |
| 1511 | if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 1512 | spin_unlock(&pipe_crc->lock); |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 1513 | DRM_ERROR("CRC buffer overflowing\n"); |
| 1514 | return; |
| 1515 | } |
| 1516 | |
| 1517 | entry = &pipe_crc->entries[head]; |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1518 | |
Daniel Vetter | 8bc5e95 | 2013-10-16 22:55:49 +0200 | [diff] [blame] | 1519 | entry->frame = dev->driver->get_vblank_counter(dev, pipe); |
Daniel Vetter | eba94eb | 2013-10-16 22:55:46 +0200 | [diff] [blame] | 1520 | entry->crc[0] = crc0; |
| 1521 | entry->crc[1] = crc1; |
| 1522 | entry->crc[2] = crc2; |
| 1523 | entry->crc[3] = crc3; |
| 1524 | entry->crc[4] = crc4; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 1525 | |
| 1526 | head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 1527 | pipe_crc->head = head; |
| 1528 | |
| 1529 | spin_unlock(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 1530 | |
| 1531 | wake_up_interruptible(&pipe_crc->wq); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1532 | } |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1533 | #else |
| 1534 | static inline void |
| 1535 | display_pipe_crc_irq_handler(struct drm_device *dev, enum pipe pipe, |
| 1536 | uint32_t crc0, uint32_t crc1, |
| 1537 | uint32_t crc2, uint32_t crc3, |
| 1538 | uint32_t crc4) {} |
| 1539 | #endif |
Daniel Vetter | eba94eb | 2013-10-16 22:55:46 +0200 | [diff] [blame] | 1540 | |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1541 | |
| 1542 | static void hsw_pipe_crc_irq_handler(struct drm_device *dev, enum pipe pipe) |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 1543 | { |
| 1544 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1545 | |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1546 | display_pipe_crc_irq_handler(dev, pipe, |
| 1547 | I915_READ(PIPE_CRC_RES_1_IVB(pipe)), |
| 1548 | 0, 0, 0, 0); |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 1549 | } |
| 1550 | |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1551 | static void ivb_pipe_crc_irq_handler(struct drm_device *dev, enum pipe pipe) |
Daniel Vetter | eba94eb | 2013-10-16 22:55:46 +0200 | [diff] [blame] | 1552 | { |
| 1553 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1554 | |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1555 | display_pipe_crc_irq_handler(dev, pipe, |
| 1556 | I915_READ(PIPE_CRC_RES_1_IVB(pipe)), |
| 1557 | I915_READ(PIPE_CRC_RES_2_IVB(pipe)), |
| 1558 | I915_READ(PIPE_CRC_RES_3_IVB(pipe)), |
| 1559 | I915_READ(PIPE_CRC_RES_4_IVB(pipe)), |
| 1560 | I915_READ(PIPE_CRC_RES_5_IVB(pipe))); |
Daniel Vetter | eba94eb | 2013-10-16 22:55:46 +0200 | [diff] [blame] | 1561 | } |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 1562 | |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1563 | static void i9xx_pipe_crc_irq_handler(struct drm_device *dev, enum pipe pipe) |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 1564 | { |
| 1565 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 0b5c5ed | 2013-10-16 22:55:53 +0200 | [diff] [blame] | 1566 | uint32_t res1, res2; |
| 1567 | |
| 1568 | if (INTEL_INFO(dev)->gen >= 3) |
| 1569 | res1 = I915_READ(PIPE_CRC_RES_RES1_I915(pipe)); |
| 1570 | else |
| 1571 | res1 = 0; |
| 1572 | |
| 1573 | if (INTEL_INFO(dev)->gen >= 5 || IS_G4X(dev)) |
| 1574 | res2 = I915_READ(PIPE_CRC_RES_RES2_G4X(pipe)); |
| 1575 | else |
| 1576 | res2 = 0; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 1577 | |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1578 | display_pipe_crc_irq_handler(dev, pipe, |
| 1579 | I915_READ(PIPE_CRC_RES_RED(pipe)), |
| 1580 | I915_READ(PIPE_CRC_RES_GREEN(pipe)), |
| 1581 | I915_READ(PIPE_CRC_RES_BLUE(pipe)), |
| 1582 | res1, res2); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 1583 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1584 | |
Paulo Zanoni | 1403c0d | 2013-08-15 11:51:32 -0300 | [diff] [blame] | 1585 | /* The RPS events need forcewake, so we add them to a work queue and mask their |
| 1586 | * IMR bits until the work is done. Other interrupts can be processed without |
| 1587 | * the work queue. */ |
| 1588 | static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir) |
Ben Widawsky | baf02a1 | 2013-05-28 19:22:24 -0700 | [diff] [blame] | 1589 | { |
Deepak S | a6706b4 | 2014-03-15 20:23:22 +0530 | [diff] [blame] | 1590 | if (pm_iir & dev_priv->pm_rps_events) { |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1591 | spin_lock(&dev_priv->irq_lock); |
Daniel Vetter | 480c803 | 2014-07-16 09:49:40 +0200 | [diff] [blame] | 1592 | gen6_disable_pm_irq(dev_priv, pm_iir & dev_priv->pm_rps_events); |
Imre Deak | d4d70aa | 2014-11-19 15:30:04 +0200 | [diff] [blame] | 1593 | if (dev_priv->rps.interrupts_enabled) { |
| 1594 | dev_priv->rps.pm_iir |= pm_iir & dev_priv->pm_rps_events; |
| 1595 | queue_work(dev_priv->wq, &dev_priv->rps.work); |
| 1596 | } |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1597 | spin_unlock(&dev_priv->irq_lock); |
Ben Widawsky | baf02a1 | 2013-05-28 19:22:24 -0700 | [diff] [blame] | 1598 | } |
Ben Widawsky | baf02a1 | 2013-05-28 19:22:24 -0700 | [diff] [blame] | 1599 | |
Imre Deak | c9a9a26 | 2014-11-05 20:48:37 +0200 | [diff] [blame] | 1600 | if (INTEL_INFO(dev_priv)->gen >= 8) |
| 1601 | return; |
| 1602 | |
Paulo Zanoni | 1403c0d | 2013-08-15 11:51:32 -0300 | [diff] [blame] | 1603 | if (HAS_VEBOX(dev_priv->dev)) { |
| 1604 | if (pm_iir & PM_VEBOX_USER_INTERRUPT) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1605 | notify_ring(&dev_priv->ring[VECS]); |
Ben Widawsky | 12638c5 | 2013-05-28 19:22:31 -0700 | [diff] [blame] | 1606 | |
Daniel Vetter | aaecdf6 | 2014-11-04 15:52:22 +0100 | [diff] [blame] | 1607 | if (pm_iir & PM_VEBOX_CS_ERROR_INTERRUPT) |
| 1608 | DRM_DEBUG("Command parser error, pm_iir 0x%08x\n", pm_iir); |
Ben Widawsky | 12638c5 | 2013-05-28 19:22:31 -0700 | [diff] [blame] | 1609 | } |
Ben Widawsky | baf02a1 | 2013-05-28 19:22:24 -0700 | [diff] [blame] | 1610 | } |
| 1611 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 1612 | static bool intel_pipe_handle_vblank(struct drm_device *dev, enum pipe pipe) |
| 1613 | { |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 1614 | if (!drm_handle_vblank(dev, pipe)) |
| 1615 | return false; |
| 1616 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 1617 | return true; |
| 1618 | } |
| 1619 | |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1620 | static void valleyview_pipestat_irq_handler(struct drm_device *dev, u32 iir) |
| 1621 | { |
| 1622 | struct drm_i915_private *dev_priv = dev->dev_private; |
Imre Deak | 91d181d | 2014-02-10 18:42:49 +0200 | [diff] [blame] | 1623 | u32 pipe_stats[I915_MAX_PIPES] = { }; |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1624 | int pipe; |
| 1625 | |
Imre Deak | 58ead0d | 2014-02-04 21:35:47 +0200 | [diff] [blame] | 1626 | spin_lock(&dev_priv->irq_lock); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 1627 | for_each_pipe(dev_priv, pipe) { |
Imre Deak | 91d181d | 2014-02-10 18:42:49 +0200 | [diff] [blame] | 1628 | int reg; |
Daniel Vetter | bbb5eeb | 2014-02-12 17:55:36 +0100 | [diff] [blame] | 1629 | u32 mask, iir_bit = 0; |
Imre Deak | 91d181d | 2014-02-10 18:42:49 +0200 | [diff] [blame] | 1630 | |
Daniel Vetter | bbb5eeb | 2014-02-12 17:55:36 +0100 | [diff] [blame] | 1631 | /* |
| 1632 | * PIPESTAT bits get signalled even when the interrupt is |
| 1633 | * disabled with the mask bits, and some of the status bits do |
| 1634 | * not generate interrupts at all (like the underrun bit). Hence |
| 1635 | * we need to be careful that we only handle what we want to |
| 1636 | * handle. |
| 1637 | */ |
Daniel Vetter | 0f239f4 | 2014-09-30 10:56:49 +0200 | [diff] [blame] | 1638 | |
| 1639 | /* fifo underruns are filterered in the underrun handler. */ |
| 1640 | mask = PIPE_FIFO_UNDERRUN_STATUS; |
Daniel Vetter | bbb5eeb | 2014-02-12 17:55:36 +0100 | [diff] [blame] | 1641 | |
| 1642 | switch (pipe) { |
| 1643 | case PIPE_A: |
| 1644 | iir_bit = I915_DISPLAY_PIPE_A_EVENT_INTERRUPT; |
| 1645 | break; |
| 1646 | case PIPE_B: |
| 1647 | iir_bit = I915_DISPLAY_PIPE_B_EVENT_INTERRUPT; |
| 1648 | break; |
Ville Syrjälä | 3278f67 | 2014-04-09 13:28:49 +0300 | [diff] [blame] | 1649 | case PIPE_C: |
| 1650 | iir_bit = I915_DISPLAY_PIPE_C_EVENT_INTERRUPT; |
| 1651 | break; |
Daniel Vetter | bbb5eeb | 2014-02-12 17:55:36 +0100 | [diff] [blame] | 1652 | } |
| 1653 | if (iir & iir_bit) |
| 1654 | mask |= dev_priv->pipestat_irq_mask[pipe]; |
| 1655 | |
| 1656 | if (!mask) |
Imre Deak | 91d181d | 2014-02-10 18:42:49 +0200 | [diff] [blame] | 1657 | continue; |
| 1658 | |
| 1659 | reg = PIPESTAT(pipe); |
Daniel Vetter | bbb5eeb | 2014-02-12 17:55:36 +0100 | [diff] [blame] | 1660 | mask |= PIPESTAT_INT_ENABLE_MASK; |
| 1661 | pipe_stats[pipe] = I915_READ(reg) & mask; |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1662 | |
| 1663 | /* |
| 1664 | * Clear the PIPE*STAT regs before the IIR |
| 1665 | */ |
Imre Deak | 91d181d | 2014-02-10 18:42:49 +0200 | [diff] [blame] | 1666 | if (pipe_stats[pipe] & (PIPE_FIFO_UNDERRUN_STATUS | |
| 1667 | PIPESTAT_INT_STATUS_MASK)) |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1668 | I915_WRITE(reg, pipe_stats[pipe]); |
| 1669 | } |
Imre Deak | 58ead0d | 2014-02-04 21:35:47 +0200 | [diff] [blame] | 1670 | spin_unlock(&dev_priv->irq_lock); |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1671 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 1672 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 1673 | if (pipe_stats[pipe] & PIPE_START_VBLANK_INTERRUPT_STATUS && |
| 1674 | intel_pipe_handle_vblank(dev, pipe)) |
| 1675 | intel_check_page_flip(dev, pipe); |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1676 | |
Imre Deak | 579a9b0 | 2014-02-04 21:35:48 +0200 | [diff] [blame] | 1677 | if (pipe_stats[pipe] & PLANE_FLIP_DONE_INT_STATUS_VLV) { |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1678 | intel_prepare_page_flip(dev, pipe); |
| 1679 | intel_finish_page_flip(dev, pipe); |
| 1680 | } |
| 1681 | |
| 1682 | if (pipe_stats[pipe] & PIPE_CRC_DONE_INTERRUPT_STATUS) |
| 1683 | i9xx_pipe_crc_irq_handler(dev, pipe); |
| 1684 | |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 1685 | if (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS) |
| 1686 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1687 | } |
| 1688 | |
| 1689 | if (pipe_stats[0] & PIPE_GMBUS_INTERRUPT_STATUS) |
| 1690 | gmbus_irq_handler(dev); |
| 1691 | } |
| 1692 | |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 1693 | static void i9xx_hpd_irq_handler(struct drm_device *dev) |
| 1694 | { |
| 1695 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1696 | u32 hotplug_status = I915_READ(PORT_HOTPLUG_STAT); |
Ville Syrjälä | 42db67d | 2015-08-28 21:26:27 +0300 | [diff] [blame] | 1697 | u32 pin_mask = 0, long_mask = 0; |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 1698 | |
Jani Nikula | 0d2e429 | 2015-05-27 15:03:39 +0300 | [diff] [blame] | 1699 | if (!hotplug_status) |
| 1700 | return; |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 1701 | |
Jani Nikula | 0d2e429 | 2015-05-27 15:03:39 +0300 | [diff] [blame] | 1702 | I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status); |
| 1703 | /* |
| 1704 | * Make sure hotplug status is cleared before we clear IIR, or else we |
| 1705 | * may miss hotplug events. |
| 1706 | */ |
| 1707 | POSTING_READ(PORT_HOTPLUG_STAT); |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 1708 | |
Jani Nikula | 0d2e429 | 2015-05-27 15:03:39 +0300 | [diff] [blame] | 1709 | if (IS_G4X(dev) || IS_VALLEYVIEW(dev)) { |
| 1710 | u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_G4X; |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 1711 | |
Ville Syrjälä | 58f2cf2 | 2015-08-28 22:59:08 +0300 | [diff] [blame] | 1712 | if (hotplug_trigger) { |
| 1713 | intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, |
| 1714 | hotplug_trigger, hpd_status_g4x, |
| 1715 | i9xx_port_hotplug_long_detect); |
| 1716 | |
| 1717 | intel_hpd_irq_handler(dev, pin_mask, long_mask); |
| 1718 | } |
Jani Nikula | 369712e | 2015-05-27 15:03:40 +0300 | [diff] [blame] | 1719 | |
| 1720 | if (hotplug_status & DP_AUX_CHANNEL_MASK_INT_STATUS_G4X) |
| 1721 | dp_aux_irq_handler(dev); |
Jani Nikula | 0d2e429 | 2015-05-27 15:03:39 +0300 | [diff] [blame] | 1722 | } else { |
| 1723 | u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_I915; |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 1724 | |
Ville Syrjälä | 58f2cf2 | 2015-08-28 22:59:08 +0300 | [diff] [blame] | 1725 | if (hotplug_trigger) { |
| 1726 | intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, |
Daniel Vetter | 44cc6c0 | 2015-09-30 08:47:41 +0200 | [diff] [blame] | 1727 | hotplug_trigger, hpd_status_i915, |
Ville Syrjälä | 58f2cf2 | 2015-08-28 22:59:08 +0300 | [diff] [blame] | 1728 | i9xx_port_hotplug_long_detect); |
Ville Syrjälä | 58f2cf2 | 2015-08-28 22:59:08 +0300 | [diff] [blame] | 1729 | intel_hpd_irq_handler(dev, pin_mask, long_mask); |
| 1730 | } |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 1731 | } |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 1732 | } |
| 1733 | |
Daniel Vetter | ff1f525 | 2012-10-02 15:10:55 +0200 | [diff] [blame] | 1734 | static irqreturn_t valleyview_irq_handler(int irq, void *arg) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 1735 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 1736 | struct drm_device *dev = arg; |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 1737 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 1738 | u32 iir, gt_iir, pm_iir; |
| 1739 | irqreturn_t ret = IRQ_NONE; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 1740 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 1741 | if (!intel_irqs_enabled(dev_priv)) |
| 1742 | return IRQ_NONE; |
| 1743 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 1744 | while (true) { |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 1745 | /* Find, clear, then process each source of interrupt */ |
| 1746 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 1747 | gt_iir = I915_READ(GTIIR); |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 1748 | if (gt_iir) |
| 1749 | I915_WRITE(GTIIR, gt_iir); |
| 1750 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 1751 | pm_iir = I915_READ(GEN6_PMIIR); |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 1752 | if (pm_iir) |
| 1753 | I915_WRITE(GEN6_PMIIR, pm_iir); |
| 1754 | |
| 1755 | iir = I915_READ(VLV_IIR); |
| 1756 | if (iir) { |
| 1757 | /* Consume port before clearing IIR or we'll miss events */ |
| 1758 | if (iir & I915_DISPLAY_PORT_INTERRUPT) |
| 1759 | i9xx_hpd_irq_handler(dev); |
| 1760 | I915_WRITE(VLV_IIR, iir); |
| 1761 | } |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 1762 | |
| 1763 | if (gt_iir == 0 && pm_iir == 0 && iir == 0) |
| 1764 | goto out; |
| 1765 | |
| 1766 | ret = IRQ_HANDLED; |
| 1767 | |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 1768 | if (gt_iir) |
| 1769 | snb_gt_irq_handler(dev, dev_priv, gt_iir); |
Paulo Zanoni | 60611c1 | 2013-08-15 11:50:01 -0300 | [diff] [blame] | 1770 | if (pm_iir) |
Daniel Vetter | d0ecd7e | 2013-07-04 23:35:25 +0200 | [diff] [blame] | 1771 | gen6_rps_irq_handler(dev_priv, pm_iir); |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 1772 | /* Call regardless, as some status bits might not be |
| 1773 | * signalled in iir */ |
| 1774 | valleyview_pipestat_irq_handler(dev, iir); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 1775 | } |
| 1776 | |
| 1777 | out: |
| 1778 | return ret; |
| 1779 | } |
| 1780 | |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 1781 | static irqreturn_t cherryview_irq_handler(int irq, void *arg) |
| 1782 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 1783 | struct drm_device *dev = arg; |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 1784 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1785 | u32 master_ctl, iir; |
| 1786 | irqreturn_t ret = IRQ_NONE; |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 1787 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 1788 | if (!intel_irqs_enabled(dev_priv)) |
| 1789 | return IRQ_NONE; |
| 1790 | |
Ville Syrjälä | 8e5fd59 | 2014-04-09 13:28:50 +0300 | [diff] [blame] | 1791 | for (;;) { |
| 1792 | master_ctl = I915_READ(GEN8_MASTER_IRQ) & ~GEN8_MASTER_IRQ_CONTROL; |
| 1793 | iir = I915_READ(VLV_IIR); |
Ville Syrjälä | 3278f67 | 2014-04-09 13:28:49 +0300 | [diff] [blame] | 1794 | |
Ville Syrjälä | 8e5fd59 | 2014-04-09 13:28:50 +0300 | [diff] [blame] | 1795 | if (master_ctl == 0 && iir == 0) |
| 1796 | break; |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 1797 | |
Oscar Mateo | 27b6c12 | 2014-06-16 16:11:00 +0100 | [diff] [blame] | 1798 | ret = IRQ_HANDLED; |
| 1799 | |
Ville Syrjälä | 8e5fd59 | 2014-04-09 13:28:50 +0300 | [diff] [blame] | 1800 | I915_WRITE(GEN8_MASTER_IRQ, 0); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 1801 | |
Oscar Mateo | 27b6c12 | 2014-06-16 16:11:00 +0100 | [diff] [blame] | 1802 | /* Find, clear, then process each source of interrupt */ |
| 1803 | |
| 1804 | if (iir) { |
| 1805 | /* Consume port before clearing IIR or we'll miss events */ |
| 1806 | if (iir & I915_DISPLAY_PORT_INTERRUPT) |
| 1807 | i9xx_hpd_irq_handler(dev); |
| 1808 | I915_WRITE(VLV_IIR, iir); |
| 1809 | } |
| 1810 | |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1811 | gen8_gt_irq_handler(dev_priv, master_ctl); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 1812 | |
Oscar Mateo | 27b6c12 | 2014-06-16 16:11:00 +0100 | [diff] [blame] | 1813 | /* Call regardless, as some status bits might not be |
| 1814 | * signalled in iir */ |
Ville Syrjälä | 8e5fd59 | 2014-04-09 13:28:50 +0300 | [diff] [blame] | 1815 | valleyview_pipestat_irq_handler(dev, iir); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 1816 | |
Ville Syrjälä | 8e5fd59 | 2014-04-09 13:28:50 +0300 | [diff] [blame] | 1817 | I915_WRITE(GEN8_MASTER_IRQ, DE_MASTER_IRQ_CONTROL); |
| 1818 | POSTING_READ(GEN8_MASTER_IRQ); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 1819 | } |
| 1820 | |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 1821 | return ret; |
| 1822 | } |
| 1823 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 1824 | static void ibx_hpd_irq_handler(struct drm_device *dev, u32 hotplug_trigger, |
| 1825 | const u32 hpd[HPD_NUM_PINS]) |
| 1826 | { |
| 1827 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 1828 | u32 dig_hotplug_reg, pin_mask = 0, long_mask = 0; |
| 1829 | |
| 1830 | dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG); |
| 1831 | I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg); |
| 1832 | |
| 1833 | intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, |
| 1834 | dig_hotplug_reg, hpd, |
| 1835 | pch_port_hotplug_long_detect); |
| 1836 | |
| 1837 | intel_hpd_irq_handler(dev, pin_mask, long_mask); |
| 1838 | } |
| 1839 | |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 1840 | static void ibx_irq_handler(struct drm_device *dev, u32 pch_iir) |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 1841 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 1842 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 1843 | int pipe; |
Egbert Eich | b543fb0 | 2013-04-16 13:36:54 +0200 | [diff] [blame] | 1844 | u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK; |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 1845 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 1846 | if (hotplug_trigger) |
| 1847 | ibx_hpd_irq_handler(dev, hotplug_trigger, hpd_ibx); |
Daniel Vetter | 91d131d | 2013-06-27 17:52:14 +0200 | [diff] [blame] | 1848 | |
Ville Syrjälä | cfc33bf | 2013-04-17 17:48:48 +0300 | [diff] [blame] | 1849 | if (pch_iir & SDE_AUDIO_POWER_MASK) { |
| 1850 | int port = ffs((pch_iir & SDE_AUDIO_POWER_MASK) >> |
| 1851 | SDE_AUDIO_POWER_SHIFT); |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 1852 | DRM_DEBUG_DRIVER("PCH audio power change on port %d\n", |
Ville Syrjälä | cfc33bf | 2013-04-17 17:48:48 +0300 | [diff] [blame] | 1853 | port_name(port)); |
| 1854 | } |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 1855 | |
Daniel Vetter | ce99c25 | 2012-12-01 13:53:47 +0100 | [diff] [blame] | 1856 | if (pch_iir & SDE_AUX_MASK) |
| 1857 | dp_aux_irq_handler(dev); |
| 1858 | |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 1859 | if (pch_iir & SDE_GMBUS) |
Daniel Vetter | 515ac2b | 2012-12-01 13:53:44 +0100 | [diff] [blame] | 1860 | gmbus_irq_handler(dev); |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 1861 | |
| 1862 | if (pch_iir & SDE_AUDIO_HDCP_MASK) |
| 1863 | DRM_DEBUG_DRIVER("PCH HDCP audio interrupt\n"); |
| 1864 | |
| 1865 | if (pch_iir & SDE_AUDIO_TRANS_MASK) |
| 1866 | DRM_DEBUG_DRIVER("PCH transcoder audio interrupt\n"); |
| 1867 | |
| 1868 | if (pch_iir & SDE_POISON) |
| 1869 | DRM_ERROR("PCH poison interrupt\n"); |
| 1870 | |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 1871 | if (pch_iir & SDE_FDI_MASK) |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 1872 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 1873 | DRM_DEBUG_DRIVER(" pipe %c FDI IIR: 0x%08x\n", |
| 1874 | pipe_name(pipe), |
| 1875 | I915_READ(FDI_RX_IIR(pipe))); |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 1876 | |
| 1877 | if (pch_iir & (SDE_TRANSB_CRC_DONE | SDE_TRANSA_CRC_DONE)) |
| 1878 | DRM_DEBUG_DRIVER("PCH transcoder CRC done interrupt\n"); |
| 1879 | |
| 1880 | if (pch_iir & (SDE_TRANSB_CRC_ERR | SDE_TRANSA_CRC_ERR)) |
| 1881 | DRM_DEBUG_DRIVER("PCH transcoder CRC error interrupt\n"); |
| 1882 | |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 1883 | if (pch_iir & SDE_TRANSA_FIFO_UNDER) |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 1884 | intel_pch_fifo_underrun_irq_handler(dev_priv, TRANSCODER_A); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 1885 | |
| 1886 | if (pch_iir & SDE_TRANSB_FIFO_UNDER) |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 1887 | intel_pch_fifo_underrun_irq_handler(dev_priv, TRANSCODER_B); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 1888 | } |
| 1889 | |
| 1890 | static void ivb_err_int_handler(struct drm_device *dev) |
| 1891 | { |
| 1892 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1893 | u32 err_int = I915_READ(GEN7_ERR_INT); |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 1894 | enum pipe pipe; |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 1895 | |
Paulo Zanoni | de032bf | 2013-04-12 17:57:58 -0300 | [diff] [blame] | 1896 | if (err_int & ERR_INT_POISON) |
| 1897 | DRM_ERROR("Poison interrupt\n"); |
| 1898 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 1899 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 1900 | if (err_int & ERR_INT_FIFO_UNDERRUN(pipe)) |
| 1901 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 1902 | |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 1903 | if (err_int & ERR_INT_PIPE_CRC_DONE(pipe)) { |
| 1904 | if (IS_IVYBRIDGE(dev)) |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1905 | ivb_pipe_crc_irq_handler(dev, pipe); |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 1906 | else |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1907 | hsw_pipe_crc_irq_handler(dev, pipe); |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 1908 | } |
| 1909 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1910 | |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 1911 | I915_WRITE(GEN7_ERR_INT, err_int); |
| 1912 | } |
| 1913 | |
| 1914 | static void cpt_serr_int_handler(struct drm_device *dev) |
| 1915 | { |
| 1916 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1917 | u32 serr_int = I915_READ(SERR_INT); |
| 1918 | |
Paulo Zanoni | de032bf | 2013-04-12 17:57:58 -0300 | [diff] [blame] | 1919 | if (serr_int & SERR_INT_POISON) |
| 1920 | DRM_ERROR("PCH poison interrupt\n"); |
| 1921 | |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 1922 | if (serr_int & SERR_INT_TRANS_A_FIFO_UNDERRUN) |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 1923 | intel_pch_fifo_underrun_irq_handler(dev_priv, TRANSCODER_A); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 1924 | |
| 1925 | if (serr_int & SERR_INT_TRANS_B_FIFO_UNDERRUN) |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 1926 | intel_pch_fifo_underrun_irq_handler(dev_priv, TRANSCODER_B); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 1927 | |
| 1928 | if (serr_int & SERR_INT_TRANS_C_FIFO_UNDERRUN) |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 1929 | intel_pch_fifo_underrun_irq_handler(dev_priv, TRANSCODER_C); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 1930 | |
| 1931 | I915_WRITE(SERR_INT, serr_int); |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 1932 | } |
| 1933 | |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 1934 | static void cpt_irq_handler(struct drm_device *dev, u32 pch_iir) |
| 1935 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 1936 | struct drm_i915_private *dev_priv = dev->dev_private; |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 1937 | int pipe; |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 1938 | u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK_CPT; |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 1939 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 1940 | if (hotplug_trigger) |
| 1941 | ibx_hpd_irq_handler(dev, hotplug_trigger, hpd_cpt); |
Daniel Vetter | 91d131d | 2013-06-27 17:52:14 +0200 | [diff] [blame] | 1942 | |
Ville Syrjälä | cfc33bf | 2013-04-17 17:48:48 +0300 | [diff] [blame] | 1943 | if (pch_iir & SDE_AUDIO_POWER_MASK_CPT) { |
| 1944 | int port = ffs((pch_iir & SDE_AUDIO_POWER_MASK_CPT) >> |
| 1945 | SDE_AUDIO_POWER_SHIFT_CPT); |
| 1946 | DRM_DEBUG_DRIVER("PCH audio power change on port %c\n", |
| 1947 | port_name(port)); |
| 1948 | } |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 1949 | |
| 1950 | if (pch_iir & SDE_AUX_MASK_CPT) |
Daniel Vetter | ce99c25 | 2012-12-01 13:53:47 +0100 | [diff] [blame] | 1951 | dp_aux_irq_handler(dev); |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 1952 | |
| 1953 | if (pch_iir & SDE_GMBUS_CPT) |
Daniel Vetter | 515ac2b | 2012-12-01 13:53:44 +0100 | [diff] [blame] | 1954 | gmbus_irq_handler(dev); |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 1955 | |
| 1956 | if (pch_iir & SDE_AUDIO_CP_REQ_CPT) |
| 1957 | DRM_DEBUG_DRIVER("Audio CP request interrupt\n"); |
| 1958 | |
| 1959 | if (pch_iir & SDE_AUDIO_CP_CHG_CPT) |
| 1960 | DRM_DEBUG_DRIVER("Audio CP change interrupt\n"); |
| 1961 | |
| 1962 | if (pch_iir & SDE_FDI_MASK_CPT) |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 1963 | for_each_pipe(dev_priv, pipe) |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 1964 | DRM_DEBUG_DRIVER(" pipe %c FDI IIR: 0x%08x\n", |
| 1965 | pipe_name(pipe), |
| 1966 | I915_READ(FDI_RX_IIR(pipe))); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 1967 | |
| 1968 | if (pch_iir & SDE_ERROR_CPT) |
| 1969 | cpt_serr_int_handler(dev); |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 1970 | } |
| 1971 | |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 1972 | static void spt_irq_handler(struct drm_device *dev, u32 pch_iir) |
| 1973 | { |
| 1974 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1975 | u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK_SPT & |
| 1976 | ~SDE_PORTE_HOTPLUG_SPT; |
| 1977 | u32 hotplug2_trigger = pch_iir & SDE_PORTE_HOTPLUG_SPT; |
| 1978 | u32 pin_mask = 0, long_mask = 0; |
| 1979 | |
| 1980 | if (hotplug_trigger) { |
| 1981 | u32 dig_hotplug_reg; |
| 1982 | |
| 1983 | dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG); |
| 1984 | I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg); |
| 1985 | |
| 1986 | intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, |
| 1987 | dig_hotplug_reg, hpd_spt, |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 1988 | spt_port_hotplug_long_detect); |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 1989 | } |
| 1990 | |
| 1991 | if (hotplug2_trigger) { |
| 1992 | u32 dig_hotplug_reg; |
| 1993 | |
| 1994 | dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG2); |
| 1995 | I915_WRITE(PCH_PORT_HOTPLUG2, dig_hotplug_reg); |
| 1996 | |
| 1997 | intel_get_hpd_pins(&pin_mask, &long_mask, hotplug2_trigger, |
| 1998 | dig_hotplug_reg, hpd_spt, |
| 1999 | spt_port_hotplug2_long_detect); |
| 2000 | } |
| 2001 | |
| 2002 | if (pin_mask) |
| 2003 | intel_hpd_irq_handler(dev, pin_mask, long_mask); |
| 2004 | |
| 2005 | if (pch_iir & SDE_GMBUS_CPT) |
| 2006 | gmbus_irq_handler(dev); |
| 2007 | } |
| 2008 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2009 | static void ilk_hpd_irq_handler(struct drm_device *dev, u32 hotplug_trigger, |
| 2010 | const u32 hpd[HPD_NUM_PINS]) |
| 2011 | { |
| 2012 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2013 | u32 dig_hotplug_reg, pin_mask = 0, long_mask = 0; |
| 2014 | |
| 2015 | dig_hotplug_reg = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL); |
| 2016 | I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, dig_hotplug_reg); |
| 2017 | |
| 2018 | intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, |
| 2019 | dig_hotplug_reg, hpd, |
| 2020 | ilk_port_hotplug_long_detect); |
| 2021 | |
| 2022 | intel_hpd_irq_handler(dev, pin_mask, long_mask); |
| 2023 | } |
| 2024 | |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2025 | static void ilk_display_irq_handler(struct drm_device *dev, u32 de_iir) |
| 2026 | { |
| 2027 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 40da17c | 2013-10-21 18:04:36 +0200 | [diff] [blame] | 2028 | enum pipe pipe; |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 2029 | u32 hotplug_trigger = de_iir & DE_DP_A_HOTPLUG; |
| 2030 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2031 | if (hotplug_trigger) |
| 2032 | ilk_hpd_irq_handler(dev, hotplug_trigger, hpd_ilk); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2033 | |
| 2034 | if (de_iir & DE_AUX_CHANNEL_A) |
| 2035 | dp_aux_irq_handler(dev); |
| 2036 | |
| 2037 | if (de_iir & DE_GSE) |
| 2038 | intel_opregion_asle_intr(dev); |
| 2039 | |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2040 | if (de_iir & DE_POISON) |
| 2041 | DRM_ERROR("Poison interrupt\n"); |
| 2042 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2043 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 2044 | if (de_iir & DE_PIPE_VBLANK(pipe) && |
| 2045 | intel_pipe_handle_vblank(dev, pipe)) |
| 2046 | intel_check_page_flip(dev, pipe); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2047 | |
Daniel Vetter | 40da17c | 2013-10-21 18:04:36 +0200 | [diff] [blame] | 2048 | if (de_iir & DE_PIPE_FIFO_UNDERRUN(pipe)) |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 2049 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2050 | |
Daniel Vetter | 40da17c | 2013-10-21 18:04:36 +0200 | [diff] [blame] | 2051 | if (de_iir & DE_PIPE_CRC_DONE(pipe)) |
| 2052 | i9xx_pipe_crc_irq_handler(dev, pipe); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2053 | |
Daniel Vetter | 40da17c | 2013-10-21 18:04:36 +0200 | [diff] [blame] | 2054 | /* plane/pipes map 1:1 on ilk+ */ |
| 2055 | if (de_iir & DE_PLANE_FLIP_DONE(pipe)) { |
| 2056 | intel_prepare_page_flip(dev, pipe); |
| 2057 | intel_finish_page_flip_plane(dev, pipe); |
| 2058 | } |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2059 | } |
| 2060 | |
| 2061 | /* check event from PCH */ |
| 2062 | if (de_iir & DE_PCH_EVENT) { |
| 2063 | u32 pch_iir = I915_READ(SDEIIR); |
| 2064 | |
| 2065 | if (HAS_PCH_CPT(dev)) |
| 2066 | cpt_irq_handler(dev, pch_iir); |
| 2067 | else |
| 2068 | ibx_irq_handler(dev, pch_iir); |
| 2069 | |
| 2070 | /* should clear PCH hotplug event before clear CPU irq */ |
| 2071 | I915_WRITE(SDEIIR, pch_iir); |
| 2072 | } |
| 2073 | |
| 2074 | if (IS_GEN5(dev) && de_iir & DE_PCU_EVENT) |
| 2075 | ironlake_rps_change_irq_handler(dev); |
| 2076 | } |
| 2077 | |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2078 | static void ivb_display_irq_handler(struct drm_device *dev, u32 de_iir) |
| 2079 | { |
| 2080 | struct drm_i915_private *dev_priv = dev->dev_private; |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 2081 | enum pipe pipe; |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 2082 | u32 hotplug_trigger = de_iir & DE_DP_A_HOTPLUG_IVB; |
| 2083 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2084 | if (hotplug_trigger) |
| 2085 | ilk_hpd_irq_handler(dev, hotplug_trigger, hpd_ivb); |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2086 | |
| 2087 | if (de_iir & DE_ERR_INT_IVB) |
| 2088 | ivb_err_int_handler(dev); |
| 2089 | |
| 2090 | if (de_iir & DE_AUX_CHANNEL_A_IVB) |
| 2091 | dp_aux_irq_handler(dev); |
| 2092 | |
| 2093 | if (de_iir & DE_GSE_IVB) |
| 2094 | intel_opregion_asle_intr(dev); |
| 2095 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2096 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 2097 | if (de_iir & (DE_PIPE_VBLANK_IVB(pipe)) && |
| 2098 | intel_pipe_handle_vblank(dev, pipe)) |
| 2099 | intel_check_page_flip(dev, pipe); |
Daniel Vetter | 40da17c | 2013-10-21 18:04:36 +0200 | [diff] [blame] | 2100 | |
| 2101 | /* plane/pipes map 1:1 on ilk+ */ |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 2102 | if (de_iir & DE_PLANE_FLIP_DONE_IVB(pipe)) { |
| 2103 | intel_prepare_page_flip(dev, pipe); |
| 2104 | intel_finish_page_flip_plane(dev, pipe); |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2105 | } |
| 2106 | } |
| 2107 | |
| 2108 | /* check event from PCH */ |
| 2109 | if (!HAS_PCH_NOP(dev) && (de_iir & DE_PCH_EVENT_IVB)) { |
| 2110 | u32 pch_iir = I915_READ(SDEIIR); |
| 2111 | |
| 2112 | cpt_irq_handler(dev, pch_iir); |
| 2113 | |
| 2114 | /* clear PCH hotplug event before clear CPU irq */ |
| 2115 | I915_WRITE(SDEIIR, pch_iir); |
| 2116 | } |
| 2117 | } |
| 2118 | |
Oscar Mateo | 72c90f6 | 2014-06-16 16:10:57 +0100 | [diff] [blame] | 2119 | /* |
| 2120 | * To handle irqs with the minimum potential races with fresh interrupts, we: |
| 2121 | * 1 - Disable Master Interrupt Control. |
| 2122 | * 2 - Find the source(s) of the interrupt. |
| 2123 | * 3 - Clear the Interrupt Identity bits (IIR). |
| 2124 | * 4 - Process the interrupt(s) that had bits set in the IIRs. |
| 2125 | * 5 - Re-enable Master Interrupt Control. |
| 2126 | */ |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2127 | static irqreturn_t ironlake_irq_handler(int irq, void *arg) |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2128 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 2129 | struct drm_device *dev = arg; |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 2130 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2131 | u32 de_iir, gt_iir, de_ier, sde_ier = 0; |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2132 | irqreturn_t ret = IRQ_NONE; |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2133 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 2134 | if (!intel_irqs_enabled(dev_priv)) |
| 2135 | return IRQ_NONE; |
| 2136 | |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2137 | /* We get interrupts on unclaimed registers, so check for this before we |
| 2138 | * do any I915_{READ,WRITE}. */ |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 2139 | intel_uncore_check_errors(dev); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2140 | |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2141 | /* disable master interrupt before clearing iir */ |
| 2142 | de_ier = I915_READ(DEIER); |
| 2143 | I915_WRITE(DEIER, de_ier & ~DE_MASTER_IRQ_CONTROL); |
Paulo Zanoni | 23a7851 | 2013-07-12 16:35:14 -0300 | [diff] [blame] | 2144 | POSTING_READ(DEIER); |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2145 | |
Paulo Zanoni | 44498ae | 2013-02-22 17:05:28 -0300 | [diff] [blame] | 2146 | /* Disable south interrupts. We'll only write to SDEIIR once, so further |
| 2147 | * interrupts will will be stored on its back queue, and then we'll be |
| 2148 | * able to process them after we restore SDEIER (as soon as we restore |
| 2149 | * it, we'll get an interrupt if SDEIIR still has something to process |
| 2150 | * due to its back queue). */ |
Ben Widawsky | ab5c608 | 2013-04-05 13:12:41 -0700 | [diff] [blame] | 2151 | if (!HAS_PCH_NOP(dev)) { |
| 2152 | sde_ier = I915_READ(SDEIER); |
| 2153 | I915_WRITE(SDEIER, 0); |
| 2154 | POSTING_READ(SDEIER); |
| 2155 | } |
Paulo Zanoni | 44498ae | 2013-02-22 17:05:28 -0300 | [diff] [blame] | 2156 | |
Oscar Mateo | 72c90f6 | 2014-06-16 16:10:57 +0100 | [diff] [blame] | 2157 | /* Find, clear, then process each source of interrupt */ |
| 2158 | |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2159 | gt_iir = I915_READ(GTIIR); |
| 2160 | if (gt_iir) { |
Oscar Mateo | 72c90f6 | 2014-06-16 16:10:57 +0100 | [diff] [blame] | 2161 | I915_WRITE(GTIIR, gt_iir); |
| 2162 | ret = IRQ_HANDLED; |
Paulo Zanoni | d8fc8a4 | 2013-07-19 18:57:55 -0300 | [diff] [blame] | 2163 | if (INTEL_INFO(dev)->gen >= 6) |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2164 | snb_gt_irq_handler(dev, dev_priv, gt_iir); |
Paulo Zanoni | d8fc8a4 | 2013-07-19 18:57:55 -0300 | [diff] [blame] | 2165 | else |
| 2166 | ilk_gt_irq_handler(dev, dev_priv, gt_iir); |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2167 | } |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2168 | |
| 2169 | de_iir = I915_READ(DEIIR); |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2170 | if (de_iir) { |
Oscar Mateo | 72c90f6 | 2014-06-16 16:10:57 +0100 | [diff] [blame] | 2171 | I915_WRITE(DEIIR, de_iir); |
| 2172 | ret = IRQ_HANDLED; |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2173 | if (INTEL_INFO(dev)->gen >= 7) |
| 2174 | ivb_display_irq_handler(dev, de_iir); |
| 2175 | else |
| 2176 | ilk_display_irq_handler(dev, de_iir); |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2177 | } |
| 2178 | |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2179 | if (INTEL_INFO(dev)->gen >= 6) { |
| 2180 | u32 pm_iir = I915_READ(GEN6_PMIIR); |
| 2181 | if (pm_iir) { |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2182 | I915_WRITE(GEN6_PMIIR, pm_iir); |
| 2183 | ret = IRQ_HANDLED; |
Oscar Mateo | 72c90f6 | 2014-06-16 16:10:57 +0100 | [diff] [blame] | 2184 | gen6_rps_irq_handler(dev_priv, pm_iir); |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2185 | } |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2186 | } |
| 2187 | |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2188 | I915_WRITE(DEIER, de_ier); |
| 2189 | POSTING_READ(DEIER); |
Ben Widawsky | ab5c608 | 2013-04-05 13:12:41 -0700 | [diff] [blame] | 2190 | if (!HAS_PCH_NOP(dev)) { |
| 2191 | I915_WRITE(SDEIER, sde_ier); |
| 2192 | POSTING_READ(SDEIER); |
| 2193 | } |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2194 | |
| 2195 | return ret; |
| 2196 | } |
| 2197 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2198 | static void bxt_hpd_irq_handler(struct drm_device *dev, u32 hotplug_trigger, |
| 2199 | const u32 hpd[HPD_NUM_PINS]) |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2200 | { |
Ville Syrjälä | cebd87a | 2015-08-27 23:56:09 +0300 | [diff] [blame] | 2201 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2202 | u32 dig_hotplug_reg, pin_mask = 0, long_mask = 0; |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2203 | |
Ville Syrjälä | a52bb15 | 2015-08-27 23:56:11 +0300 | [diff] [blame] | 2204 | dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG); |
| 2205 | I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg); |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2206 | |
Ville Syrjälä | cebd87a | 2015-08-27 23:56:09 +0300 | [diff] [blame] | 2207 | intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2208 | dig_hotplug_reg, hpd, |
Ville Syrjälä | cebd87a | 2015-08-27 23:56:09 +0300 | [diff] [blame] | 2209 | bxt_port_hotplug_long_detect); |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2210 | |
Jani Nikula | 475c2e3 | 2015-05-28 15:43:54 +0300 | [diff] [blame] | 2211 | intel_hpd_irq_handler(dev, pin_mask, long_mask); |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2212 | } |
| 2213 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2214 | static irqreturn_t gen8_irq_handler(int irq, void *arg) |
| 2215 | { |
| 2216 | struct drm_device *dev = arg; |
| 2217 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2218 | u32 master_ctl; |
| 2219 | irqreturn_t ret = IRQ_NONE; |
| 2220 | uint32_t tmp = 0; |
Daniel Vetter | c42664c | 2013-11-07 11:05:40 +0100 | [diff] [blame] | 2221 | enum pipe pipe; |
Jesse Barnes | 88e0470 | 2014-11-13 17:51:48 +0000 | [diff] [blame] | 2222 | u32 aux_mask = GEN8_AUX_CHANNEL_A; |
| 2223 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 2224 | if (!intel_irqs_enabled(dev_priv)) |
| 2225 | return IRQ_NONE; |
| 2226 | |
Rodrigo Vivi | b4834a5 | 2015-09-02 15:19:24 -0700 | [diff] [blame] | 2227 | if (INTEL_INFO(dev_priv)->gen >= 9) |
Jesse Barnes | 88e0470 | 2014-11-13 17:51:48 +0000 | [diff] [blame] | 2228 | aux_mask |= GEN9_AUX_CHANNEL_B | GEN9_AUX_CHANNEL_C | |
| 2229 | GEN9_AUX_CHANNEL_D; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2230 | |
Chris Wilson | cb0d205 | 2015-04-07 16:21:04 +0100 | [diff] [blame] | 2231 | master_ctl = I915_READ_FW(GEN8_MASTER_IRQ); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2232 | master_ctl &= ~GEN8_MASTER_IRQ_CONTROL; |
| 2233 | if (!master_ctl) |
| 2234 | return IRQ_NONE; |
| 2235 | |
Chris Wilson | cb0d205 | 2015-04-07 16:21:04 +0100 | [diff] [blame] | 2236 | I915_WRITE_FW(GEN8_MASTER_IRQ, 0); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2237 | |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2238 | /* Find, clear, then process each source of interrupt */ |
| 2239 | |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 2240 | ret = gen8_gt_irq_handler(dev_priv, master_ctl); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2241 | |
| 2242 | if (master_ctl & GEN8_DE_MISC_IRQ) { |
| 2243 | tmp = I915_READ(GEN8_DE_MISC_IIR); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2244 | if (tmp) { |
| 2245 | I915_WRITE(GEN8_DE_MISC_IIR, tmp); |
| 2246 | ret = IRQ_HANDLED; |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2247 | if (tmp & GEN8_DE_MISC_GSE) |
| 2248 | intel_opregion_asle_intr(dev); |
| 2249 | else |
| 2250 | DRM_ERROR("Unexpected DE Misc interrupt\n"); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2251 | } |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2252 | else |
| 2253 | DRM_ERROR("The master control interrupt lied (DE MISC)!\n"); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2254 | } |
| 2255 | |
Daniel Vetter | 6d766f0 | 2013-11-07 14:49:55 +0100 | [diff] [blame] | 2256 | if (master_ctl & GEN8_DE_PORT_IRQ) { |
| 2257 | tmp = I915_READ(GEN8_DE_PORT_IIR); |
Daniel Vetter | 6d766f0 | 2013-11-07 14:49:55 +0100 | [diff] [blame] | 2258 | if (tmp) { |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2259 | bool found = false; |
Ville Syrjälä | cebd87a | 2015-08-27 23:56:09 +0300 | [diff] [blame] | 2260 | u32 hotplug_trigger = 0; |
| 2261 | |
| 2262 | if (IS_BROXTON(dev_priv)) |
| 2263 | hotplug_trigger = tmp & BXT_DE_PORT_HOTPLUG_MASK; |
| 2264 | else if (IS_BROADWELL(dev_priv)) |
| 2265 | hotplug_trigger = tmp & GEN8_PORT_DP_A_HOTPLUG; |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2266 | |
Daniel Vetter | 6d766f0 | 2013-11-07 14:49:55 +0100 | [diff] [blame] | 2267 | I915_WRITE(GEN8_DE_PORT_IIR, tmp); |
| 2268 | ret = IRQ_HANDLED; |
Jesse Barnes | 88e0470 | 2014-11-13 17:51:48 +0000 | [diff] [blame] | 2269 | |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2270 | if (tmp & aux_mask) { |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2271 | dp_aux_irq_handler(dev); |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2272 | found = true; |
| 2273 | } |
| 2274 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2275 | if (hotplug_trigger) { |
| 2276 | if (IS_BROXTON(dev)) |
| 2277 | bxt_hpd_irq_handler(dev, hotplug_trigger, hpd_bxt); |
| 2278 | else |
| 2279 | ilk_hpd_irq_handler(dev, hotplug_trigger, hpd_bdw); |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2280 | found = true; |
| 2281 | } |
| 2282 | |
Shashank Sharma | 9e63743 | 2014-08-22 17:40:43 +0530 | [diff] [blame] | 2283 | if (IS_BROXTON(dev) && (tmp & BXT_DE_PORT_GMBUS)) { |
| 2284 | gmbus_irq_handler(dev); |
| 2285 | found = true; |
| 2286 | } |
| 2287 | |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2288 | if (!found) |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2289 | DRM_ERROR("Unexpected DE Port interrupt\n"); |
Daniel Vetter | 6d766f0 | 2013-11-07 14:49:55 +0100 | [diff] [blame] | 2290 | } |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2291 | else |
| 2292 | DRM_ERROR("The master control interrupt lied (DE PORT)!\n"); |
Daniel Vetter | 6d766f0 | 2013-11-07 14:49:55 +0100 | [diff] [blame] | 2293 | } |
| 2294 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2295 | for_each_pipe(dev_priv, pipe) { |
Damien Lespiau | 770de83 | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 2296 | uint32_t pipe_iir, flip_done = 0, fault_errors = 0; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2297 | |
Daniel Vetter | c42664c | 2013-11-07 11:05:40 +0100 | [diff] [blame] | 2298 | if (!(master_ctl & GEN8_DE_PIPE_IRQ(pipe))) |
| 2299 | continue; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2300 | |
Daniel Vetter | c42664c | 2013-11-07 11:05:40 +0100 | [diff] [blame] | 2301 | pipe_iir = I915_READ(GEN8_DE_PIPE_IIR(pipe)); |
Daniel Vetter | c42664c | 2013-11-07 11:05:40 +0100 | [diff] [blame] | 2302 | if (pipe_iir) { |
| 2303 | ret = IRQ_HANDLED; |
| 2304 | I915_WRITE(GEN8_DE_PIPE_IIR(pipe), pipe_iir); |
Damien Lespiau | 770de83 | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 2305 | |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 2306 | if (pipe_iir & GEN8_PIPE_VBLANK && |
| 2307 | intel_pipe_handle_vblank(dev, pipe)) |
| 2308 | intel_check_page_flip(dev, pipe); |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2309 | |
Rodrigo Vivi | b4834a5 | 2015-09-02 15:19:24 -0700 | [diff] [blame] | 2310 | if (INTEL_INFO(dev_priv)->gen >= 9) |
Damien Lespiau | 770de83 | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 2311 | flip_done = pipe_iir & GEN9_PIPE_PLANE1_FLIP_DONE; |
| 2312 | else |
| 2313 | flip_done = pipe_iir & GEN8_PIPE_PRIMARY_FLIP_DONE; |
| 2314 | |
| 2315 | if (flip_done) { |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2316 | intel_prepare_page_flip(dev, pipe); |
| 2317 | intel_finish_page_flip_plane(dev, pipe); |
| 2318 | } |
| 2319 | |
| 2320 | if (pipe_iir & GEN8_PIPE_CDCLK_CRC_DONE) |
| 2321 | hsw_pipe_crc_irq_handler(dev, pipe); |
| 2322 | |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 2323 | if (pipe_iir & GEN8_PIPE_FIFO_UNDERRUN) |
| 2324 | intel_cpu_fifo_underrun_irq_handler(dev_priv, |
| 2325 | pipe); |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2326 | |
Damien Lespiau | 770de83 | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 2327 | |
Rodrigo Vivi | b4834a5 | 2015-09-02 15:19:24 -0700 | [diff] [blame] | 2328 | if (INTEL_INFO(dev_priv)->gen >= 9) |
Damien Lespiau | 770de83 | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 2329 | fault_errors = pipe_iir & GEN9_DE_PIPE_IRQ_FAULT_ERRORS; |
| 2330 | else |
| 2331 | fault_errors = pipe_iir & GEN8_DE_PIPE_IRQ_FAULT_ERRORS; |
| 2332 | |
| 2333 | if (fault_errors) |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2334 | DRM_ERROR("Fault errors on pipe %c\n: 0x%08x", |
| 2335 | pipe_name(pipe), |
| 2336 | pipe_iir & GEN8_DE_PIPE_IRQ_FAULT_ERRORS); |
Daniel Vetter | c42664c | 2013-11-07 11:05:40 +0100 | [diff] [blame] | 2337 | } else |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2338 | DRM_ERROR("The master control interrupt lied (DE PIPE)!\n"); |
| 2339 | } |
| 2340 | |
Shashank Sharma | 266ea3d | 2014-08-22 17:40:42 +0530 | [diff] [blame] | 2341 | if (HAS_PCH_SPLIT(dev) && !HAS_PCH_NOP(dev) && |
| 2342 | master_ctl & GEN8_DE_PCH_IRQ) { |
Daniel Vetter | 92d03a8 | 2013-11-07 11:05:43 +0100 | [diff] [blame] | 2343 | /* |
| 2344 | * FIXME(BDW): Assume for now that the new interrupt handling |
| 2345 | * scheme also closed the SDE interrupt handling race we've seen |
| 2346 | * on older pch-split platforms. But this needs testing. |
| 2347 | */ |
| 2348 | u32 pch_iir = I915_READ(SDEIIR); |
Daniel Vetter | 92d03a8 | 2013-11-07 11:05:43 +0100 | [diff] [blame] | 2349 | if (pch_iir) { |
| 2350 | I915_WRITE(SDEIIR, pch_iir); |
| 2351 | ret = IRQ_HANDLED; |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 2352 | |
| 2353 | if (HAS_PCH_SPT(dev_priv)) |
| 2354 | spt_irq_handler(dev, pch_iir); |
| 2355 | else |
| 2356 | cpt_irq_handler(dev, pch_iir); |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2357 | } else |
| 2358 | DRM_ERROR("The master control interrupt lied (SDE)!\n"); |
| 2359 | |
Daniel Vetter | 92d03a8 | 2013-11-07 11:05:43 +0100 | [diff] [blame] | 2360 | } |
| 2361 | |
Chris Wilson | cb0d205 | 2015-04-07 16:21:04 +0100 | [diff] [blame] | 2362 | I915_WRITE_FW(GEN8_MASTER_IRQ, GEN8_MASTER_IRQ_CONTROL); |
| 2363 | POSTING_READ_FW(GEN8_MASTER_IRQ); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2364 | |
| 2365 | return ret; |
| 2366 | } |
| 2367 | |
Daniel Vetter | 17e1df0 | 2013-09-08 21:57:13 +0200 | [diff] [blame] | 2368 | static void i915_error_wake_up(struct drm_i915_private *dev_priv, |
| 2369 | bool reset_completed) |
| 2370 | { |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2371 | struct intel_engine_cs *ring; |
Daniel Vetter | 17e1df0 | 2013-09-08 21:57:13 +0200 | [diff] [blame] | 2372 | int i; |
| 2373 | |
| 2374 | /* |
| 2375 | * Notify all waiters for GPU completion events that reset state has |
| 2376 | * been changed, and that they need to restart their wait after |
| 2377 | * checking for potential errors (and bail out to drop locks if there is |
| 2378 | * a gpu reset pending so that i915_error_work_func can acquire them). |
| 2379 | */ |
| 2380 | |
| 2381 | /* Wake up __wait_seqno, potentially holding dev->struct_mutex. */ |
| 2382 | for_each_ring(ring, dev_priv, i) |
| 2383 | wake_up_all(&ring->irq_queue); |
| 2384 | |
| 2385 | /* Wake up intel_crtc_wait_for_pending_flips, holding crtc->mutex. */ |
| 2386 | wake_up_all(&dev_priv->pending_flip_queue); |
| 2387 | |
| 2388 | /* |
| 2389 | * Signal tasks blocked in i915_gem_wait_for_error that the pending |
| 2390 | * reset state is cleared. |
| 2391 | */ |
| 2392 | if (reset_completed) |
| 2393 | wake_up_all(&dev_priv->gpu_error.reset_queue); |
| 2394 | } |
| 2395 | |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2396 | /** |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 2397 | * i915_reset_and_wakeup - do process context error handling work |
Javier Martinez Canillas | 468f9d2 | 2015-10-08 09:54:44 +0200 | [diff] [blame] | 2398 | * @dev: drm device |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2399 | * |
| 2400 | * Fire an error uevent so userspace can see that a hang or error |
| 2401 | * was detected. |
| 2402 | */ |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 2403 | static void i915_reset_and_wakeup(struct drm_device *dev) |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2404 | { |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 2405 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2406 | struct i915_gpu_error *error = &dev_priv->gpu_error; |
Ben Widawsky | cce723e | 2013-07-19 09:16:42 -0700 | [diff] [blame] | 2407 | char *error_event[] = { I915_ERROR_UEVENT "=1", NULL }; |
| 2408 | char *reset_event[] = { I915_RESET_UEVENT "=1", NULL }; |
| 2409 | char *reset_done_event[] = { I915_ERROR_UEVENT "=0", NULL }; |
Daniel Vetter | 17e1df0 | 2013-09-08 21:57:13 +0200 | [diff] [blame] | 2410 | int ret; |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2411 | |
Dave Airlie | 5bdebb1 | 2013-10-11 14:07:25 +1000 | [diff] [blame] | 2412 | kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, error_event); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2413 | |
Daniel Vetter | 7db0ba2 | 2012-12-06 16:23:37 +0100 | [diff] [blame] | 2414 | /* |
| 2415 | * Note that there's only one work item which does gpu resets, so we |
| 2416 | * need not worry about concurrent gpu resets potentially incrementing |
| 2417 | * error->reset_counter twice. We only need to take care of another |
| 2418 | * racing irq/hangcheck declaring the gpu dead for a second time. A |
| 2419 | * quick check for that is good enough: schedule_work ensures the |
| 2420 | * correct ordering between hang detection and this work item, and since |
| 2421 | * the reset in-progress bit is only ever set by code outside of this |
| 2422 | * work we don't need to worry about any other races. |
| 2423 | */ |
| 2424 | if (i915_reset_in_progress(error) && !i915_terminally_wedged(error)) { |
Chris Wilson | f803aa5 | 2010-09-19 12:38:26 +0100 | [diff] [blame] | 2425 | DRM_DEBUG_DRIVER("resetting chip\n"); |
Dave Airlie | 5bdebb1 | 2013-10-11 14:07:25 +1000 | [diff] [blame] | 2426 | kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, |
Daniel Vetter | 7db0ba2 | 2012-12-06 16:23:37 +0100 | [diff] [blame] | 2427 | reset_event); |
Daniel Vetter | 1f83fee | 2012-11-15 17:17:22 +0100 | [diff] [blame] | 2428 | |
Daniel Vetter | 17e1df0 | 2013-09-08 21:57:13 +0200 | [diff] [blame] | 2429 | /* |
Imre Deak | f454c69 | 2014-04-23 01:09:04 +0300 | [diff] [blame] | 2430 | * In most cases it's guaranteed that we get here with an RPM |
| 2431 | * reference held, for example because there is a pending GPU |
| 2432 | * request that won't finish until the reset is done. This |
| 2433 | * isn't the case at least when we get here by doing a |
| 2434 | * simulated reset via debugs, so get an RPM reference. |
| 2435 | */ |
| 2436 | intel_runtime_pm_get(dev_priv); |
Ville Syrjälä | 7514747 | 2014-11-24 18:28:11 +0200 | [diff] [blame] | 2437 | |
| 2438 | intel_prepare_reset(dev); |
| 2439 | |
Imre Deak | f454c69 | 2014-04-23 01:09:04 +0300 | [diff] [blame] | 2440 | /* |
Daniel Vetter | 17e1df0 | 2013-09-08 21:57:13 +0200 | [diff] [blame] | 2441 | * All state reset _must_ be completed before we update the |
| 2442 | * reset counter, for otherwise waiters might miss the reset |
| 2443 | * pending state and not properly drop locks, resulting in |
| 2444 | * deadlocks with the reset work. |
| 2445 | */ |
Daniel Vetter | f69061b | 2012-12-06 09:01:42 +0100 | [diff] [blame] | 2446 | ret = i915_reset(dev); |
| 2447 | |
Ville Syrjälä | 7514747 | 2014-11-24 18:28:11 +0200 | [diff] [blame] | 2448 | intel_finish_reset(dev); |
Daniel Vetter | 17e1df0 | 2013-09-08 21:57:13 +0200 | [diff] [blame] | 2449 | |
Imre Deak | f454c69 | 2014-04-23 01:09:04 +0300 | [diff] [blame] | 2450 | intel_runtime_pm_put(dev_priv); |
| 2451 | |
Daniel Vetter | f69061b | 2012-12-06 09:01:42 +0100 | [diff] [blame] | 2452 | if (ret == 0) { |
| 2453 | /* |
| 2454 | * After all the gem state is reset, increment the reset |
| 2455 | * counter and wake up everyone waiting for the reset to |
| 2456 | * complete. |
| 2457 | * |
| 2458 | * Since unlock operations are a one-sided barrier only, |
| 2459 | * we need to insert a barrier here to order any seqno |
| 2460 | * updates before |
| 2461 | * the counter increment. |
| 2462 | */ |
Peter Zijlstra | 4e857c5 | 2014-03-17 18:06:10 +0100 | [diff] [blame] | 2463 | smp_mb__before_atomic(); |
Daniel Vetter | f69061b | 2012-12-06 09:01:42 +0100 | [diff] [blame] | 2464 | atomic_inc(&dev_priv->gpu_error.reset_counter); |
| 2465 | |
Dave Airlie | 5bdebb1 | 2013-10-11 14:07:25 +1000 | [diff] [blame] | 2466 | kobject_uevent_env(&dev->primary->kdev->kobj, |
Daniel Vetter | f69061b | 2012-12-06 09:01:42 +0100 | [diff] [blame] | 2467 | KOBJ_CHANGE, reset_done_event); |
Daniel Vetter | 1f83fee | 2012-11-15 17:17:22 +0100 | [diff] [blame] | 2468 | } else { |
Peter Zijlstra | 805de8f4 | 2015-04-24 01:12:32 +0200 | [diff] [blame] | 2469 | atomic_or(I915_WEDGED, &error->reset_counter); |
Ben Gamari | f316a42 | 2009-09-14 17:48:46 -0400 | [diff] [blame] | 2470 | } |
Daniel Vetter | 1f83fee | 2012-11-15 17:17:22 +0100 | [diff] [blame] | 2471 | |
Daniel Vetter | 17e1df0 | 2013-09-08 21:57:13 +0200 | [diff] [blame] | 2472 | /* |
| 2473 | * Note: The wake_up also serves as a memory barrier so that |
| 2474 | * waiters see the update value of the reset counter atomic_t. |
| 2475 | */ |
| 2476 | i915_error_wake_up(dev_priv, true); |
Ben Gamari | f316a42 | 2009-09-14 17:48:46 -0400 | [diff] [blame] | 2477 | } |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2478 | } |
| 2479 | |
Chris Wilson | 35aed2e | 2010-05-27 13:18:12 +0100 | [diff] [blame] | 2480 | static void i915_report_and_clear_eir(struct drm_device *dev) |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2481 | { |
| 2482 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | bd9854f | 2012-08-23 15:18:09 -0700 | [diff] [blame] | 2483 | uint32_t instdone[I915_NUM_INSTDONE_REG]; |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2484 | u32 eir = I915_READ(EIR); |
Ben Widawsky | 050ee91 | 2012-08-22 11:32:15 -0700 | [diff] [blame] | 2485 | int pipe, i; |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2486 | |
Chris Wilson | 35aed2e | 2010-05-27 13:18:12 +0100 | [diff] [blame] | 2487 | if (!eir) |
| 2488 | return; |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2489 | |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2490 | pr_err("render error detected, EIR: 0x%08x\n", eir); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2491 | |
Ben Widawsky | bd9854f | 2012-08-23 15:18:09 -0700 | [diff] [blame] | 2492 | i915_get_extra_instdone(dev, instdone); |
| 2493 | |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2494 | if (IS_G4X(dev)) { |
| 2495 | if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) { |
| 2496 | u32 ipeir = I915_READ(IPEIR_I965); |
| 2497 | |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2498 | pr_err(" IPEIR: 0x%08x\n", I915_READ(IPEIR_I965)); |
| 2499 | pr_err(" IPEHR: 0x%08x\n", I915_READ(IPEHR_I965)); |
Ben Widawsky | 050ee91 | 2012-08-22 11:32:15 -0700 | [diff] [blame] | 2500 | for (i = 0; i < ARRAY_SIZE(instdone); i++) |
| 2501 | pr_err(" INSTDONE_%d: 0x%08x\n", i, instdone[i]); |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2502 | pr_err(" INSTPS: 0x%08x\n", I915_READ(INSTPS)); |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2503 | pr_err(" ACTHD: 0x%08x\n", I915_READ(ACTHD_I965)); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2504 | I915_WRITE(IPEIR_I965, ipeir); |
Chris Wilson | 3143a2b | 2010-11-16 15:55:10 +0000 | [diff] [blame] | 2505 | POSTING_READ(IPEIR_I965); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2506 | } |
| 2507 | if (eir & GM45_ERROR_PAGE_TABLE) { |
| 2508 | u32 pgtbl_err = I915_READ(PGTBL_ER); |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2509 | pr_err("page table error\n"); |
| 2510 | pr_err(" PGTBL_ER: 0x%08x\n", pgtbl_err); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2511 | I915_WRITE(PGTBL_ER, pgtbl_err); |
Chris Wilson | 3143a2b | 2010-11-16 15:55:10 +0000 | [diff] [blame] | 2512 | POSTING_READ(PGTBL_ER); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2513 | } |
| 2514 | } |
| 2515 | |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 2516 | if (!IS_GEN2(dev)) { |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2517 | if (eir & I915_ERROR_PAGE_TABLE) { |
| 2518 | u32 pgtbl_err = I915_READ(PGTBL_ER); |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2519 | pr_err("page table error\n"); |
| 2520 | pr_err(" PGTBL_ER: 0x%08x\n", pgtbl_err); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2521 | I915_WRITE(PGTBL_ER, pgtbl_err); |
Chris Wilson | 3143a2b | 2010-11-16 15:55:10 +0000 | [diff] [blame] | 2522 | POSTING_READ(PGTBL_ER); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2523 | } |
| 2524 | } |
| 2525 | |
| 2526 | if (eir & I915_ERROR_MEMORY_REFRESH) { |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2527 | pr_err("memory refresh error:\n"); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2528 | for_each_pipe(dev_priv, pipe) |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2529 | pr_err("pipe %c stat: 0x%08x\n", |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 2530 | pipe_name(pipe), I915_READ(PIPESTAT(pipe))); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2531 | /* pipestat has already been acked */ |
| 2532 | } |
| 2533 | if (eir & I915_ERROR_INSTRUCTION) { |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2534 | pr_err("instruction error\n"); |
| 2535 | pr_err(" INSTPM: 0x%08x\n", I915_READ(INSTPM)); |
Ben Widawsky | 050ee91 | 2012-08-22 11:32:15 -0700 | [diff] [blame] | 2536 | for (i = 0; i < ARRAY_SIZE(instdone); i++) |
| 2537 | pr_err(" INSTDONE_%d: 0x%08x\n", i, instdone[i]); |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 2538 | if (INTEL_INFO(dev)->gen < 4) { |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2539 | u32 ipeir = I915_READ(IPEIR); |
| 2540 | |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2541 | pr_err(" IPEIR: 0x%08x\n", I915_READ(IPEIR)); |
| 2542 | pr_err(" IPEHR: 0x%08x\n", I915_READ(IPEHR)); |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2543 | pr_err(" ACTHD: 0x%08x\n", I915_READ(ACTHD)); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2544 | I915_WRITE(IPEIR, ipeir); |
Chris Wilson | 3143a2b | 2010-11-16 15:55:10 +0000 | [diff] [blame] | 2545 | POSTING_READ(IPEIR); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2546 | } else { |
| 2547 | u32 ipeir = I915_READ(IPEIR_I965); |
| 2548 | |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2549 | pr_err(" IPEIR: 0x%08x\n", I915_READ(IPEIR_I965)); |
| 2550 | pr_err(" IPEHR: 0x%08x\n", I915_READ(IPEHR_I965)); |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2551 | pr_err(" INSTPS: 0x%08x\n", I915_READ(INSTPS)); |
Joe Perches | a70491c | 2012-03-18 13:00:11 -0700 | [diff] [blame] | 2552 | pr_err(" ACTHD: 0x%08x\n", I915_READ(ACTHD_I965)); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2553 | I915_WRITE(IPEIR_I965, ipeir); |
Chris Wilson | 3143a2b | 2010-11-16 15:55:10 +0000 | [diff] [blame] | 2554 | POSTING_READ(IPEIR_I965); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2555 | } |
| 2556 | } |
| 2557 | |
| 2558 | I915_WRITE(EIR, eir); |
Chris Wilson | 3143a2b | 2010-11-16 15:55:10 +0000 | [diff] [blame] | 2559 | POSTING_READ(EIR); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2560 | eir = I915_READ(EIR); |
| 2561 | if (eir) { |
| 2562 | /* |
| 2563 | * some errors might have become stuck, |
| 2564 | * mask them. |
| 2565 | */ |
| 2566 | DRM_ERROR("EIR stuck: 0x%08x, masking\n", eir); |
| 2567 | I915_WRITE(EMR, I915_READ(EMR) | eir); |
| 2568 | I915_WRITE(IIR, I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT); |
| 2569 | } |
Chris Wilson | 35aed2e | 2010-05-27 13:18:12 +0100 | [diff] [blame] | 2570 | } |
| 2571 | |
| 2572 | /** |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 2573 | * i915_handle_error - handle a gpu error |
Chris Wilson | 35aed2e | 2010-05-27 13:18:12 +0100 | [diff] [blame] | 2574 | * @dev: drm device |
| 2575 | * |
Javier Martinez Canillas | aafd858 | 2015-10-08 09:57:49 +0200 | [diff] [blame] | 2576 | * Do some basic checking of register state at error time and |
Chris Wilson | 35aed2e | 2010-05-27 13:18:12 +0100 | [diff] [blame] | 2577 | * dump it to the syslog. Also call i915_capture_error_state() to make |
| 2578 | * sure we get a record and make it available in debugfs. Fire a uevent |
| 2579 | * so userspace knows something bad happened (should trigger collection |
| 2580 | * of a ring dump etc.). |
| 2581 | */ |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 2582 | void i915_handle_error(struct drm_device *dev, bool wedged, |
| 2583 | const char *fmt, ...) |
Chris Wilson | 35aed2e | 2010-05-27 13:18:12 +0100 | [diff] [blame] | 2584 | { |
| 2585 | struct drm_i915_private *dev_priv = dev->dev_private; |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 2586 | va_list args; |
| 2587 | char error_msg[80]; |
Chris Wilson | 35aed2e | 2010-05-27 13:18:12 +0100 | [diff] [blame] | 2588 | |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 2589 | va_start(args, fmt); |
| 2590 | vscnprintf(error_msg, sizeof(error_msg), fmt, args); |
| 2591 | va_end(args); |
| 2592 | |
| 2593 | i915_capture_error_state(dev, wedged, error_msg); |
Chris Wilson | 35aed2e | 2010-05-27 13:18:12 +0100 | [diff] [blame] | 2594 | i915_report_and_clear_eir(dev); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2595 | |
Ben Gamari | ba1234d | 2009-09-14 17:48:47 -0400 | [diff] [blame] | 2596 | if (wedged) { |
Peter Zijlstra | 805de8f4 | 2015-04-24 01:12:32 +0200 | [diff] [blame] | 2597 | atomic_or(I915_RESET_IN_PROGRESS_FLAG, |
Daniel Vetter | f69061b | 2012-12-06 09:01:42 +0100 | [diff] [blame] | 2598 | &dev_priv->gpu_error.reset_counter); |
Ben Gamari | ba1234d | 2009-09-14 17:48:47 -0400 | [diff] [blame] | 2599 | |
Ben Gamari | 11ed50e | 2009-09-14 17:48:45 -0400 | [diff] [blame] | 2600 | /* |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 2601 | * Wakeup waiting processes so that the reset function |
| 2602 | * i915_reset_and_wakeup doesn't deadlock trying to grab |
| 2603 | * various locks. By bumping the reset counter first, the woken |
Daniel Vetter | 17e1df0 | 2013-09-08 21:57:13 +0200 | [diff] [blame] | 2604 | * processes will see a reset in progress and back off, |
| 2605 | * releasing their locks and then wait for the reset completion. |
| 2606 | * We must do this for _all_ gpu waiters that might hold locks |
| 2607 | * that the reset work needs to acquire. |
| 2608 | * |
| 2609 | * Note: The wake_up serves as the required memory barrier to |
| 2610 | * ensure that the waiters see the updated value of the reset |
| 2611 | * counter atomic_t. |
Ben Gamari | 11ed50e | 2009-09-14 17:48:45 -0400 | [diff] [blame] | 2612 | */ |
Daniel Vetter | 17e1df0 | 2013-09-08 21:57:13 +0200 | [diff] [blame] | 2613 | i915_error_wake_up(dev_priv, false); |
Ben Gamari | 11ed50e | 2009-09-14 17:48:45 -0400 | [diff] [blame] | 2614 | } |
| 2615 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 2616 | i915_reset_and_wakeup(dev); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 2617 | } |
| 2618 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 2619 | /* Called from drm generic code, passed 'crtc' which |
| 2620 | * we use as a pipe index |
| 2621 | */ |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 2622 | static int i915_enable_vblank(struct drm_device *dev, int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 2623 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 2624 | struct drm_i915_private *dev_priv = dev->dev_private; |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 2625 | unsigned long irqflags; |
Jesse Barnes | 71e0ffa | 2009-01-08 10:42:15 -0800 | [diff] [blame] | 2626 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 2627 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 2628 | if (INTEL_INFO(dev)->gen >= 4) |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 2629 | i915_enable_pipestat(dev_priv, pipe, |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 2630 | PIPE_START_VBLANK_INTERRUPT_STATUS); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 2631 | else |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 2632 | i915_enable_pipestat(dev_priv, pipe, |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 2633 | PIPE_VBLANK_INTERRUPT_STATUS); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 2634 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
Chris Wilson | 8692d00e | 2011-02-05 10:08:21 +0000 | [diff] [blame] | 2635 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 2636 | return 0; |
| 2637 | } |
| 2638 | |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 2639 | static int ironlake_enable_vblank(struct drm_device *dev, int pipe) |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 2640 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 2641 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 2642 | unsigned long irqflags; |
Paulo Zanoni | b518421 | 2013-07-12 20:00:08 -0300 | [diff] [blame] | 2643 | uint32_t bit = (INTEL_INFO(dev)->gen >= 7) ? DE_PIPE_VBLANK_IVB(pipe) : |
Daniel Vetter | 40da17c | 2013-10-21 18:04:36 +0200 | [diff] [blame] | 2644 | DE_PIPE_VBLANK(pipe); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 2645 | |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 2646 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Paulo Zanoni | b518421 | 2013-07-12 20:00:08 -0300 | [diff] [blame] | 2647 | ironlake_enable_display_irq(dev_priv, bit); |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2648 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 2649 | |
| 2650 | return 0; |
| 2651 | } |
| 2652 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2653 | static int valleyview_enable_vblank(struct drm_device *dev, int pipe) |
| 2654 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 2655 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2656 | unsigned long irqflags; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2657 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2658 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Jesse Barnes | 31acc7f | 2012-06-20 10:53:11 -0700 | [diff] [blame] | 2659 | i915_enable_pipestat(dev_priv, pipe, |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 2660 | PIPE_START_VBLANK_INTERRUPT_STATUS); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2661 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 2662 | |
| 2663 | return 0; |
| 2664 | } |
| 2665 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2666 | static int gen8_enable_vblank(struct drm_device *dev, int pipe) |
| 2667 | { |
| 2668 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2669 | unsigned long irqflags; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2670 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2671 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Daniel Vetter | 7167d7c | 2013-11-07 11:05:45 +0100 | [diff] [blame] | 2672 | dev_priv->de_irq_mask[pipe] &= ~GEN8_PIPE_VBLANK; |
| 2673 | I915_WRITE(GEN8_DE_PIPE_IMR(pipe), dev_priv->de_irq_mask[pipe]); |
| 2674 | POSTING_READ(GEN8_DE_PIPE_IMR(pipe)); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2675 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 2676 | return 0; |
| 2677 | } |
| 2678 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 2679 | /* Called from drm generic code, passed 'crtc' which |
| 2680 | * we use as a pipe index |
| 2681 | */ |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 2682 | static void i915_disable_vblank(struct drm_device *dev, int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 2683 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 2684 | struct drm_i915_private *dev_priv = dev->dev_private; |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 2685 | unsigned long irqflags; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 2686 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 2687 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 2688 | i915_disable_pipestat(dev_priv, pipe, |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 2689 | PIPE_VBLANK_INTERRUPT_STATUS | |
| 2690 | PIPE_START_VBLANK_INTERRUPT_STATUS); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 2691 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 2692 | } |
| 2693 | |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 2694 | static void ironlake_disable_vblank(struct drm_device *dev, int pipe) |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 2695 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 2696 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 2697 | unsigned long irqflags; |
Paulo Zanoni | b518421 | 2013-07-12 20:00:08 -0300 | [diff] [blame] | 2698 | uint32_t bit = (INTEL_INFO(dev)->gen >= 7) ? DE_PIPE_VBLANK_IVB(pipe) : |
Daniel Vetter | 40da17c | 2013-10-21 18:04:36 +0200 | [diff] [blame] | 2699 | DE_PIPE_VBLANK(pipe); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 2700 | |
| 2701 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Paulo Zanoni | b518421 | 2013-07-12 20:00:08 -0300 | [diff] [blame] | 2702 | ironlake_disable_display_irq(dev_priv, bit); |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2703 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 2704 | } |
| 2705 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2706 | static void valleyview_disable_vblank(struct drm_device *dev, int pipe) |
| 2707 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 2708 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2709 | unsigned long irqflags; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2710 | |
| 2711 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Jesse Barnes | 31acc7f | 2012-06-20 10:53:11 -0700 | [diff] [blame] | 2712 | i915_disable_pipestat(dev_priv, pipe, |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 2713 | PIPE_START_VBLANK_INTERRUPT_STATUS); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2714 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 2715 | } |
| 2716 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2717 | static void gen8_disable_vblank(struct drm_device *dev, int pipe) |
| 2718 | { |
| 2719 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2720 | unsigned long irqflags; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2721 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2722 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Daniel Vetter | 7167d7c | 2013-11-07 11:05:45 +0100 | [diff] [blame] | 2723 | dev_priv->de_irq_mask[pipe] |= GEN8_PIPE_VBLANK; |
| 2724 | I915_WRITE(GEN8_DE_PIPE_IMR(pipe), dev_priv->de_irq_mask[pipe]); |
| 2725 | POSTING_READ(GEN8_DE_PIPE_IMR(pipe)); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2726 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 2727 | } |
| 2728 | |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2729 | static bool |
Tomas Elf | 94f7bbe | 2015-07-09 15:30:57 +0100 | [diff] [blame] | 2730 | ring_idle(struct intel_engine_cs *ring, u32 seqno) |
Chris Wilson | 893eead | 2010-10-27 14:44:35 +0100 | [diff] [blame] | 2731 | { |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2732 | return (list_empty(&ring->request_list) || |
Tomas Elf | 94f7bbe | 2015-07-09 15:30:57 +0100 | [diff] [blame] | 2733 | i915_seqno_passed(seqno, ring->last_submitted_seqno)); |
Ben Gamari | f65d942 | 2009-09-14 17:48:44 -0400 | [diff] [blame] | 2734 | } |
| 2735 | |
Daniel Vetter | a028c4b | 2014-03-15 00:08:56 +0100 | [diff] [blame] | 2736 | static bool |
| 2737 | ipehr_is_semaphore_wait(struct drm_device *dev, u32 ipehr) |
| 2738 | { |
| 2739 | if (INTEL_INFO(dev)->gen >= 8) { |
Rodrigo Vivi | a6cdb93 | 2014-06-30 09:53:39 -0700 | [diff] [blame] | 2740 | return (ipehr >> 23) == 0x1c; |
Daniel Vetter | a028c4b | 2014-03-15 00:08:56 +0100 | [diff] [blame] | 2741 | } else { |
| 2742 | ipehr &= ~MI_SEMAPHORE_SYNC_MASK; |
| 2743 | return ipehr == (MI_SEMAPHORE_MBOX | MI_SEMAPHORE_COMPARE | |
| 2744 | MI_SEMAPHORE_REGISTER); |
| 2745 | } |
| 2746 | } |
| 2747 | |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2748 | static struct intel_engine_cs * |
Rodrigo Vivi | a6cdb93 | 2014-06-30 09:53:39 -0700 | [diff] [blame] | 2749 | semaphore_wait_to_signaller_ring(struct intel_engine_cs *ring, u32 ipehr, u64 offset) |
Daniel Vetter | 921d42e | 2014-03-18 10:26:04 +0100 | [diff] [blame] | 2750 | { |
| 2751 | struct drm_i915_private *dev_priv = ring->dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2752 | struct intel_engine_cs *signaller; |
Daniel Vetter | 921d42e | 2014-03-18 10:26:04 +0100 | [diff] [blame] | 2753 | int i; |
| 2754 | |
| 2755 | if (INTEL_INFO(dev_priv->dev)->gen >= 8) { |
Rodrigo Vivi | a6cdb93 | 2014-06-30 09:53:39 -0700 | [diff] [blame] | 2756 | for_each_ring(signaller, dev_priv, i) { |
| 2757 | if (ring == signaller) |
| 2758 | continue; |
| 2759 | |
| 2760 | if (offset == signaller->semaphore.signal_ggtt[ring->id]) |
| 2761 | return signaller; |
| 2762 | } |
Daniel Vetter | 921d42e | 2014-03-18 10:26:04 +0100 | [diff] [blame] | 2763 | } else { |
| 2764 | u32 sync_bits = ipehr & MI_SEMAPHORE_SYNC_MASK; |
| 2765 | |
| 2766 | for_each_ring(signaller, dev_priv, i) { |
| 2767 | if(ring == signaller) |
| 2768 | continue; |
| 2769 | |
Ben Widawsky | ebc348b | 2014-04-29 14:52:28 -0700 | [diff] [blame] | 2770 | if (sync_bits == signaller->semaphore.mbox.wait[ring->id]) |
Daniel Vetter | 921d42e | 2014-03-18 10:26:04 +0100 | [diff] [blame] | 2771 | return signaller; |
| 2772 | } |
| 2773 | } |
| 2774 | |
Rodrigo Vivi | a6cdb93 | 2014-06-30 09:53:39 -0700 | [diff] [blame] | 2775 | DRM_ERROR("No signaller ring found for ring %i, ipehr 0x%08x, offset 0x%016llx\n", |
| 2776 | ring->id, ipehr, offset); |
Daniel Vetter | 921d42e | 2014-03-18 10:26:04 +0100 | [diff] [blame] | 2777 | |
| 2778 | return NULL; |
| 2779 | } |
| 2780 | |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2781 | static struct intel_engine_cs * |
| 2782 | semaphore_waits_for(struct intel_engine_cs *ring, u32 *seqno) |
Chris Wilson | a24a11e | 2013-03-14 17:52:05 +0200 | [diff] [blame] | 2783 | { |
| 2784 | struct drm_i915_private *dev_priv = ring->dev->dev_private; |
Daniel Vetter | 88fe429 | 2014-03-15 00:08:55 +0100 | [diff] [blame] | 2785 | u32 cmd, ipehr, head; |
Rodrigo Vivi | a6cdb93 | 2014-06-30 09:53:39 -0700 | [diff] [blame] | 2786 | u64 offset = 0; |
| 2787 | int i, backwards; |
Chris Wilson | a24a11e | 2013-03-14 17:52:05 +0200 | [diff] [blame] | 2788 | |
Tomas Elf | 381e8ae | 2015-10-08 19:31:33 +0100 | [diff] [blame] | 2789 | /* |
| 2790 | * This function does not support execlist mode - any attempt to |
| 2791 | * proceed further into this function will result in a kernel panic |
| 2792 | * when dereferencing ring->buffer, which is not set up in execlist |
| 2793 | * mode. |
| 2794 | * |
| 2795 | * The correct way of doing it would be to derive the currently |
| 2796 | * executing ring buffer from the current context, which is derived |
| 2797 | * from the currently running request. Unfortunately, to get the |
| 2798 | * current request we would have to grab the struct_mutex before doing |
| 2799 | * anything else, which would be ill-advised since some other thread |
| 2800 | * might have grabbed it already and managed to hang itself, causing |
| 2801 | * the hang checker to deadlock. |
| 2802 | * |
| 2803 | * Therefore, this function does not support execlist mode in its |
| 2804 | * current form. Just return NULL and move on. |
| 2805 | */ |
| 2806 | if (ring->buffer == NULL) |
| 2807 | return NULL; |
| 2808 | |
Chris Wilson | a24a11e | 2013-03-14 17:52:05 +0200 | [diff] [blame] | 2809 | ipehr = I915_READ(RING_IPEHR(ring->mmio_base)); |
Daniel Vetter | a028c4b | 2014-03-15 00:08:56 +0100 | [diff] [blame] | 2810 | if (!ipehr_is_semaphore_wait(ring->dev, ipehr)) |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2811 | return NULL; |
Chris Wilson | a24a11e | 2013-03-14 17:52:05 +0200 | [diff] [blame] | 2812 | |
Daniel Vetter | 88fe429 | 2014-03-15 00:08:55 +0100 | [diff] [blame] | 2813 | /* |
| 2814 | * HEAD is likely pointing to the dword after the actual command, |
| 2815 | * so scan backwards until we find the MBOX. But limit it to just 3 |
Rodrigo Vivi | a6cdb93 | 2014-06-30 09:53:39 -0700 | [diff] [blame] | 2816 | * or 4 dwords depending on the semaphore wait command size. |
| 2817 | * Note that we don't care about ACTHD here since that might |
Daniel Vetter | 88fe429 | 2014-03-15 00:08:55 +0100 | [diff] [blame] | 2818 | * point at at batch, and semaphores are always emitted into the |
| 2819 | * ringbuffer itself. |
Chris Wilson | a24a11e | 2013-03-14 17:52:05 +0200 | [diff] [blame] | 2820 | */ |
Daniel Vetter | 88fe429 | 2014-03-15 00:08:55 +0100 | [diff] [blame] | 2821 | head = I915_READ_HEAD(ring) & HEAD_ADDR; |
Rodrigo Vivi | a6cdb93 | 2014-06-30 09:53:39 -0700 | [diff] [blame] | 2822 | backwards = (INTEL_INFO(ring->dev)->gen >= 8) ? 5 : 4; |
Daniel Vetter | 88fe429 | 2014-03-15 00:08:55 +0100 | [diff] [blame] | 2823 | |
Rodrigo Vivi | a6cdb93 | 2014-06-30 09:53:39 -0700 | [diff] [blame] | 2824 | for (i = backwards; i; --i) { |
Daniel Vetter | 88fe429 | 2014-03-15 00:08:55 +0100 | [diff] [blame] | 2825 | /* |
| 2826 | * Be paranoid and presume the hw has gone off into the wild - |
| 2827 | * our ring is smaller than what the hardware (and hence |
| 2828 | * HEAD_ADDR) allows. Also handles wrap-around. |
| 2829 | */ |
Oscar Mateo | ee1b1e5 | 2014-05-22 14:13:35 +0100 | [diff] [blame] | 2830 | head &= ring->buffer->size - 1; |
Daniel Vetter | 88fe429 | 2014-03-15 00:08:55 +0100 | [diff] [blame] | 2831 | |
| 2832 | /* This here seems to blow up */ |
Oscar Mateo | ee1b1e5 | 2014-05-22 14:13:35 +0100 | [diff] [blame] | 2833 | cmd = ioread32(ring->buffer->virtual_start + head); |
Chris Wilson | a24a11e | 2013-03-14 17:52:05 +0200 | [diff] [blame] | 2834 | if (cmd == ipehr) |
| 2835 | break; |
| 2836 | |
Daniel Vetter | 88fe429 | 2014-03-15 00:08:55 +0100 | [diff] [blame] | 2837 | head -= 4; |
| 2838 | } |
Chris Wilson | a24a11e | 2013-03-14 17:52:05 +0200 | [diff] [blame] | 2839 | |
Daniel Vetter | 88fe429 | 2014-03-15 00:08:55 +0100 | [diff] [blame] | 2840 | if (!i) |
| 2841 | return NULL; |
| 2842 | |
Oscar Mateo | ee1b1e5 | 2014-05-22 14:13:35 +0100 | [diff] [blame] | 2843 | *seqno = ioread32(ring->buffer->virtual_start + head + 4) + 1; |
Rodrigo Vivi | a6cdb93 | 2014-06-30 09:53:39 -0700 | [diff] [blame] | 2844 | if (INTEL_INFO(ring->dev)->gen >= 8) { |
| 2845 | offset = ioread32(ring->buffer->virtual_start + head + 12); |
| 2846 | offset <<= 32; |
| 2847 | offset = ioread32(ring->buffer->virtual_start + head + 8); |
| 2848 | } |
| 2849 | return semaphore_wait_to_signaller_ring(ring, ipehr, offset); |
Chris Wilson | a24a11e | 2013-03-14 17:52:05 +0200 | [diff] [blame] | 2850 | } |
| 2851 | |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2852 | static int semaphore_passed(struct intel_engine_cs *ring) |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2853 | { |
| 2854 | struct drm_i915_private *dev_priv = ring->dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2855 | struct intel_engine_cs *signaller; |
Chris Wilson | a0d036b | 2014-07-19 12:40:42 +0100 | [diff] [blame] | 2856 | u32 seqno; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2857 | |
Chris Wilson | 4be1738 | 2014-06-06 10:22:29 +0100 | [diff] [blame] | 2858 | ring->hangcheck.deadlock++; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2859 | |
| 2860 | signaller = semaphore_waits_for(ring, &seqno); |
Chris Wilson | 4be1738 | 2014-06-06 10:22:29 +0100 | [diff] [blame] | 2861 | if (signaller == NULL) |
| 2862 | return -1; |
| 2863 | |
| 2864 | /* Prevent pathological recursion due to driver bugs */ |
| 2865 | if (signaller->hangcheck.deadlock >= I915_NUM_RINGS) |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2866 | return -1; |
| 2867 | |
Chris Wilson | 4be1738 | 2014-06-06 10:22:29 +0100 | [diff] [blame] | 2868 | if (i915_seqno_passed(signaller->get_seqno(signaller, false), seqno)) |
| 2869 | return 1; |
| 2870 | |
Chris Wilson | a0d036b | 2014-07-19 12:40:42 +0100 | [diff] [blame] | 2871 | /* cursory check for an unkickable deadlock */ |
| 2872 | if (I915_READ_CTL(signaller) & RING_WAIT_SEMAPHORE && |
| 2873 | semaphore_passed(signaller) < 0) |
Chris Wilson | 4be1738 | 2014-06-06 10:22:29 +0100 | [diff] [blame] | 2874 | return -1; |
| 2875 | |
| 2876 | return 0; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2877 | } |
| 2878 | |
| 2879 | static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv) |
| 2880 | { |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2881 | struct intel_engine_cs *ring; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2882 | int i; |
| 2883 | |
| 2884 | for_each_ring(ring, dev_priv, i) |
Chris Wilson | 4be1738 | 2014-06-06 10:22:29 +0100 | [diff] [blame] | 2885 | ring->hangcheck.deadlock = 0; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2886 | } |
| 2887 | |
Mika Kuoppala | ad8beae | 2013-06-12 12:35:32 +0300 | [diff] [blame] | 2888 | static enum intel_ring_hangcheck_action |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2889 | ring_stuck(struct intel_engine_cs *ring, u64 acthd) |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 2890 | { |
| 2891 | struct drm_device *dev = ring->dev; |
| 2892 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2893 | u32 tmp; |
| 2894 | |
Mika Kuoppala | f260fe7 | 2014-08-05 17:16:26 +0300 | [diff] [blame] | 2895 | if (acthd != ring->hangcheck.acthd) { |
| 2896 | if (acthd > ring->hangcheck.max_acthd) { |
| 2897 | ring->hangcheck.max_acthd = acthd; |
| 2898 | return HANGCHECK_ACTIVE; |
| 2899 | } |
| 2900 | |
| 2901 | return HANGCHECK_ACTIVE_LOOP; |
| 2902 | } |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2903 | |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2904 | if (IS_GEN2(dev)) |
Jani Nikula | f2f4d82 | 2013-08-11 12:44:01 +0300 | [diff] [blame] | 2905 | return HANGCHECK_HUNG; |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2906 | |
| 2907 | /* Is the chip hanging on a WAIT_FOR_EVENT? |
| 2908 | * If so we can simply poke the RB_WAIT bit |
| 2909 | * and break the hang. This should work on |
| 2910 | * all but the second generation chipsets. |
| 2911 | */ |
| 2912 | tmp = I915_READ_CTL(ring); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 2913 | if (tmp & RING_WAIT) { |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 2914 | i915_handle_error(dev, false, |
| 2915 | "Kicking stuck wait on %s", |
| 2916 | ring->name); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 2917 | I915_WRITE_CTL(ring, tmp); |
Jani Nikula | f2f4d82 | 2013-08-11 12:44:01 +0300 | [diff] [blame] | 2918 | return HANGCHECK_KICK; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 2919 | } |
Chris Wilson | a24a11e | 2013-03-14 17:52:05 +0200 | [diff] [blame] | 2920 | |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2921 | if (INTEL_INFO(dev)->gen >= 6 && tmp & RING_WAIT_SEMAPHORE) { |
| 2922 | switch (semaphore_passed(ring)) { |
| 2923 | default: |
Jani Nikula | f2f4d82 | 2013-08-11 12:44:01 +0300 | [diff] [blame] | 2924 | return HANGCHECK_HUNG; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2925 | case 1: |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 2926 | i915_handle_error(dev, false, |
| 2927 | "Kicking stuck semaphore on %s", |
| 2928 | ring->name); |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2929 | I915_WRITE_CTL(ring, tmp); |
Jani Nikula | f2f4d82 | 2013-08-11 12:44:01 +0300 | [diff] [blame] | 2930 | return HANGCHECK_KICK; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2931 | case 0: |
Jani Nikula | f2f4d82 | 2013-08-11 12:44:01 +0300 | [diff] [blame] | 2932 | return HANGCHECK_WAIT; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2933 | } |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2934 | } |
Mika Kuoppala | ed5cbb0 | 2013-05-13 16:32:11 +0300 | [diff] [blame] | 2935 | |
Jani Nikula | f2f4d82 | 2013-08-11 12:44:01 +0300 | [diff] [blame] | 2936 | return HANGCHECK_HUNG; |
Mika Kuoppala | ed5cbb0 | 2013-05-13 16:32:11 +0300 | [diff] [blame] | 2937 | } |
| 2938 | |
Chris Wilson | 737b150 | 2015-01-26 18:03:03 +0200 | [diff] [blame] | 2939 | /* |
Ben Gamari | f65d942 | 2009-09-14 17:48:44 -0400 | [diff] [blame] | 2940 | * This is called when the chip hasn't reported back with completed |
Mika Kuoppala | 05407ff | 2013-05-30 09:04:29 +0300 | [diff] [blame] | 2941 | * batchbuffers in a long time. We keep track per ring seqno progress and |
| 2942 | * if there are no progress, hangcheck score for that ring is increased. |
| 2943 | * Further, acthd is inspected to see if the ring is stuck. On stuck case |
| 2944 | * we kick the ring. If we see no progress on three subsequent calls |
| 2945 | * we assume chip is wedged and try to fix it by resetting the chip. |
Ben Gamari | f65d942 | 2009-09-14 17:48:44 -0400 | [diff] [blame] | 2946 | */ |
Chris Wilson | 737b150 | 2015-01-26 18:03:03 +0200 | [diff] [blame] | 2947 | static void i915_hangcheck_elapsed(struct work_struct *work) |
Ben Gamari | f65d942 | 2009-09-14 17:48:44 -0400 | [diff] [blame] | 2948 | { |
Chris Wilson | 737b150 | 2015-01-26 18:03:03 +0200 | [diff] [blame] | 2949 | struct drm_i915_private *dev_priv = |
| 2950 | container_of(work, typeof(*dev_priv), |
| 2951 | gpu_error.hangcheck_work.work); |
| 2952 | struct drm_device *dev = dev_priv->dev; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2953 | struct intel_engine_cs *ring; |
Chris Wilson | b451951 | 2012-05-11 14:29:30 +0100 | [diff] [blame] | 2954 | int i; |
Mika Kuoppala | 05407ff | 2013-05-30 09:04:29 +0300 | [diff] [blame] | 2955 | int busy_count = 0, rings_hung = 0; |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2956 | bool stuck[I915_NUM_RINGS] = { 0 }; |
| 2957 | #define BUSY 1 |
| 2958 | #define KICK 5 |
| 2959 | #define HUNG 20 |
Chris Wilson | 893eead | 2010-10-27 14:44:35 +0100 | [diff] [blame] | 2960 | |
Jani Nikula | d330a95 | 2014-01-21 11:24:25 +0200 | [diff] [blame] | 2961 | if (!i915.enable_hangcheck) |
Ben Widawsky | 3e0dc6b | 2011-06-29 10:26:42 -0700 | [diff] [blame] | 2962 | return; |
| 2963 | |
Chris Wilson | b451951 | 2012-05-11 14:29:30 +0100 | [diff] [blame] | 2964 | for_each_ring(ring, dev_priv, i) { |
Chris Wilson | 5087744 | 2014-03-21 12:41:53 +0000 | [diff] [blame] | 2965 | u64 acthd; |
| 2966 | u32 seqno; |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2967 | bool busy = true; |
Chris Wilson | b451951 | 2012-05-11 14:29:30 +0100 | [diff] [blame] | 2968 | |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2969 | semaphore_clear_deadlocks(dev_priv); |
| 2970 | |
Mika Kuoppala | 05407ff | 2013-05-30 09:04:29 +0300 | [diff] [blame] | 2971 | seqno = ring->get_seqno(ring, false); |
| 2972 | acthd = intel_ring_get_active_head(ring); |
Chris Wilson | d1e61e7 | 2012-04-10 17:00:41 +0100 | [diff] [blame] | 2973 | |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2974 | if (ring->hangcheck.seqno == seqno) { |
Tomas Elf | 94f7bbe | 2015-07-09 15:30:57 +0100 | [diff] [blame] | 2975 | if (ring_idle(ring, seqno)) { |
Mika Kuoppala | da66146 | 2013-09-06 16:03:28 +0300 | [diff] [blame] | 2976 | ring->hangcheck.action = HANGCHECK_IDLE; |
| 2977 | |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2978 | if (waitqueue_active(&ring->irq_queue)) { |
| 2979 | /* Issue a wake-up to catch stuck h/w. */ |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 2980 | if (!test_and_set_bit(ring->id, &dev_priv->gpu_error.missed_irq_rings)) { |
Daniel Vetter | f4adcd2 | 2013-10-28 09:24:13 +0100 | [diff] [blame] | 2981 | if (!(dev_priv->gpu_error.test_irq_rings & intel_ring_flag(ring))) |
| 2982 | DRM_ERROR("Hangcheck timer elapsed... %s idle\n", |
| 2983 | ring->name); |
| 2984 | else |
| 2985 | DRM_INFO("Fake missed irq on %s\n", |
| 2986 | ring->name); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 2987 | wake_up_all(&ring->irq_queue); |
| 2988 | } |
| 2989 | /* Safeguard against driver failure */ |
| 2990 | ring->hangcheck.score += BUSY; |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 2991 | } else |
| 2992 | busy = false; |
Mika Kuoppala | 05407ff | 2013-05-30 09:04:29 +0300 | [diff] [blame] | 2993 | } else { |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 2994 | /* We always increment the hangcheck score |
| 2995 | * if the ring is busy and still processing |
| 2996 | * the same request, so that no single request |
| 2997 | * can run indefinitely (such as a chain of |
| 2998 | * batches). The only time we do not increment |
| 2999 | * the hangcheck score on this ring, if this |
| 3000 | * ring is in a legitimate wait for another |
| 3001 | * ring. In that case the waiting ring is a |
| 3002 | * victim and we want to be sure we catch the |
| 3003 | * right culprit. Then every time we do kick |
| 3004 | * the ring, add a small increment to the |
| 3005 | * score so that we can catch a batch that is |
| 3006 | * being repeatedly kicked and so responsible |
| 3007 | * for stalling the machine. |
| 3008 | */ |
Mika Kuoppala | ad8beae | 2013-06-12 12:35:32 +0300 | [diff] [blame] | 3009 | ring->hangcheck.action = ring_stuck(ring, |
| 3010 | acthd); |
| 3011 | |
| 3012 | switch (ring->hangcheck.action) { |
Mika Kuoppala | da66146 | 2013-09-06 16:03:28 +0300 | [diff] [blame] | 3013 | case HANGCHECK_IDLE: |
Jani Nikula | f2f4d82 | 2013-08-11 12:44:01 +0300 | [diff] [blame] | 3014 | case HANGCHECK_WAIT: |
Jani Nikula | f2f4d82 | 2013-08-11 12:44:01 +0300 | [diff] [blame] | 3015 | case HANGCHECK_ACTIVE: |
Mika Kuoppala | f260fe7 | 2014-08-05 17:16:26 +0300 | [diff] [blame] | 3016 | break; |
| 3017 | case HANGCHECK_ACTIVE_LOOP: |
Jani Nikula | ea04cb3 | 2013-08-11 12:44:02 +0300 | [diff] [blame] | 3018 | ring->hangcheck.score += BUSY; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 3019 | break; |
Jani Nikula | f2f4d82 | 2013-08-11 12:44:01 +0300 | [diff] [blame] | 3020 | case HANGCHECK_KICK: |
Jani Nikula | ea04cb3 | 2013-08-11 12:44:02 +0300 | [diff] [blame] | 3021 | ring->hangcheck.score += KICK; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 3022 | break; |
Jani Nikula | f2f4d82 | 2013-08-11 12:44:01 +0300 | [diff] [blame] | 3023 | case HANGCHECK_HUNG: |
Jani Nikula | ea04cb3 | 2013-08-11 12:44:02 +0300 | [diff] [blame] | 3024 | ring->hangcheck.score += HUNG; |
Chris Wilson | 6274f21 | 2013-06-10 11:20:21 +0100 | [diff] [blame] | 3025 | stuck[i] = true; |
| 3026 | break; |
| 3027 | } |
Mika Kuoppala | 05407ff | 2013-05-30 09:04:29 +0300 | [diff] [blame] | 3028 | } |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 3029 | } else { |
Mika Kuoppala | da66146 | 2013-09-06 16:03:28 +0300 | [diff] [blame] | 3030 | ring->hangcheck.action = HANGCHECK_ACTIVE; |
| 3031 | |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 3032 | /* Gradually reduce the count so that we catch DoS |
| 3033 | * attempts across multiple batches. |
| 3034 | */ |
| 3035 | if (ring->hangcheck.score > 0) |
| 3036 | ring->hangcheck.score--; |
Mika Kuoppala | f260fe7 | 2014-08-05 17:16:26 +0300 | [diff] [blame] | 3037 | |
| 3038 | ring->hangcheck.acthd = ring->hangcheck.max_acthd = 0; |
Chris Wilson | d1e61e7 | 2012-04-10 17:00:41 +0100 | [diff] [blame] | 3039 | } |
| 3040 | |
Mika Kuoppala | 05407ff | 2013-05-30 09:04:29 +0300 | [diff] [blame] | 3041 | ring->hangcheck.seqno = seqno; |
| 3042 | ring->hangcheck.acthd = acthd; |
Chris Wilson | 9107e9d | 2013-06-10 11:20:20 +0100 | [diff] [blame] | 3043 | busy_count += busy; |
Chris Wilson | 893eead | 2010-10-27 14:44:35 +0100 | [diff] [blame] | 3044 | } |
Eric Anholt | b9201c1 | 2010-01-08 14:25:16 -0800 | [diff] [blame] | 3045 | |
Mika Kuoppala | 92cab73 | 2013-05-24 17:16:07 +0300 | [diff] [blame] | 3046 | for_each_ring(ring, dev_priv, i) { |
Mika Kuoppala | b6b0fac | 2014-01-30 19:04:43 +0200 | [diff] [blame] | 3047 | if (ring->hangcheck.score >= HANGCHECK_SCORE_RING_HUNG) { |
Daniel Vetter | b8d88d1 | 2013-08-28 10:57:59 +0200 | [diff] [blame] | 3048 | DRM_INFO("%s on %s\n", |
| 3049 | stuck[i] ? "stuck" : "no progress", |
| 3050 | ring->name); |
Chris Wilson | a43adf0 | 2013-06-10 11:20:22 +0100 | [diff] [blame] | 3051 | rings_hung++; |
Mika Kuoppala | 92cab73 | 2013-05-24 17:16:07 +0300 | [diff] [blame] | 3052 | } |
| 3053 | } |
| 3054 | |
Mika Kuoppala | 05407ff | 2013-05-30 09:04:29 +0300 | [diff] [blame] | 3055 | if (rings_hung) |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 3056 | return i915_handle_error(dev, true, "Ring hung"); |
Ben Gamari | f65d942 | 2009-09-14 17:48:44 -0400 | [diff] [blame] | 3057 | |
Mika Kuoppala | 05407ff | 2013-05-30 09:04:29 +0300 | [diff] [blame] | 3058 | if (busy_count) |
| 3059 | /* Reset timer case chip hangs without another request |
| 3060 | * being added */ |
Mika Kuoppala | 10cd45b | 2013-07-03 17:22:08 +0300 | [diff] [blame] | 3061 | i915_queue_hangcheck(dev); |
| 3062 | } |
| 3063 | |
| 3064 | void i915_queue_hangcheck(struct drm_device *dev) |
| 3065 | { |
Chris Wilson | 737b150 | 2015-01-26 18:03:03 +0200 | [diff] [blame] | 3066 | struct i915_gpu_error *e = &to_i915(dev)->gpu_error; |
Chris Wilson | 672e7b7 | 2014-11-19 09:47:19 +0000 | [diff] [blame] | 3067 | |
Jani Nikula | d330a95 | 2014-01-21 11:24:25 +0200 | [diff] [blame] | 3068 | if (!i915.enable_hangcheck) |
Mika Kuoppala | 10cd45b | 2013-07-03 17:22:08 +0300 | [diff] [blame] | 3069 | return; |
| 3070 | |
Chris Wilson | 737b150 | 2015-01-26 18:03:03 +0200 | [diff] [blame] | 3071 | /* Don't continually defer the hangcheck so that it is always run at |
| 3072 | * least once after work has been scheduled on any ring. Otherwise, |
| 3073 | * we will ignore a hung ring if a second ring is kept busy. |
| 3074 | */ |
| 3075 | |
| 3076 | queue_delayed_work(e->hangcheck_wq, &e->hangcheck_work, |
| 3077 | round_jiffies_up_relative(DRM_I915_HANGCHECK_JIFFIES)); |
Ben Gamari | f65d942 | 2009-09-14 17:48:44 -0400 | [diff] [blame] | 3078 | } |
| 3079 | |
Paulo Zanoni | 1c69eb4 | 2014-04-01 15:37:23 -0300 | [diff] [blame] | 3080 | static void ibx_irq_reset(struct drm_device *dev) |
Paulo Zanoni | 91738a9 | 2013-06-05 14:21:51 -0300 | [diff] [blame] | 3081 | { |
| 3082 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3083 | |
| 3084 | if (HAS_PCH_NOP(dev)) |
| 3085 | return; |
| 3086 | |
Paulo Zanoni | f86f3fb | 2014-04-01 15:37:14 -0300 | [diff] [blame] | 3087 | GEN5_IRQ_RESET(SDE); |
Paulo Zanoni | 105b122 | 2014-04-01 15:37:17 -0300 | [diff] [blame] | 3088 | |
| 3089 | if (HAS_PCH_CPT(dev) || HAS_PCH_LPT(dev)) |
| 3090 | I915_WRITE(SERR_INT, 0xffffffff); |
Paulo Zanoni | 622364b | 2014-04-01 15:37:22 -0300 | [diff] [blame] | 3091 | } |
Paulo Zanoni | 105b122 | 2014-04-01 15:37:17 -0300 | [diff] [blame] | 3092 | |
Paulo Zanoni | 622364b | 2014-04-01 15:37:22 -0300 | [diff] [blame] | 3093 | /* |
| 3094 | * SDEIER is also touched by the interrupt handler to work around missed PCH |
| 3095 | * interrupts. Hence we can't update it after the interrupt handler is enabled - |
| 3096 | * instead we unconditionally enable all PCH interrupt sources here, but then |
| 3097 | * only unmask them as needed with SDEIMR. |
| 3098 | * |
| 3099 | * This function needs to be called before interrupts are enabled. |
| 3100 | */ |
| 3101 | static void ibx_irq_pre_postinstall(struct drm_device *dev) |
| 3102 | { |
| 3103 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3104 | |
| 3105 | if (HAS_PCH_NOP(dev)) |
| 3106 | return; |
| 3107 | |
| 3108 | WARN_ON(I915_READ(SDEIER) != 0); |
Paulo Zanoni | 91738a9 | 2013-06-05 14:21:51 -0300 | [diff] [blame] | 3109 | I915_WRITE(SDEIER, 0xffffffff); |
| 3110 | POSTING_READ(SDEIER); |
| 3111 | } |
| 3112 | |
Paulo Zanoni | 7c4d664 | 2014-04-01 15:37:19 -0300 | [diff] [blame] | 3113 | static void gen5_gt_irq_reset(struct drm_device *dev) |
Daniel Vetter | d18ea1b | 2013-07-12 22:43:25 +0200 | [diff] [blame] | 3114 | { |
| 3115 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3116 | |
Paulo Zanoni | f86f3fb | 2014-04-01 15:37:14 -0300 | [diff] [blame] | 3117 | GEN5_IRQ_RESET(GT); |
Paulo Zanoni | a9d356a | 2014-04-01 15:37:09 -0300 | [diff] [blame] | 3118 | if (INTEL_INFO(dev)->gen >= 6) |
Paulo Zanoni | f86f3fb | 2014-04-01 15:37:14 -0300 | [diff] [blame] | 3119 | GEN5_IRQ_RESET(GEN6_PM); |
Daniel Vetter | d18ea1b | 2013-07-12 22:43:25 +0200 | [diff] [blame] | 3120 | } |
| 3121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3122 | /* drm_dma.h hooks |
| 3123 | */ |
Paulo Zanoni | be30b29 | 2014-04-01 15:37:25 -0300 | [diff] [blame] | 3124 | static void ironlake_irq_reset(struct drm_device *dev) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3125 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3126 | struct drm_i915_private *dev_priv = dev->dev_private; |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3127 | |
Paulo Zanoni | 0c84121 | 2014-04-01 15:37:27 -0300 | [diff] [blame] | 3128 | I915_WRITE(HWSTAM, 0xffffffff); |
Daniel Vetter | bdfcdb6 | 2012-01-05 01:05:26 +0100 | [diff] [blame] | 3129 | |
Paulo Zanoni | f86f3fb | 2014-04-01 15:37:14 -0300 | [diff] [blame] | 3130 | GEN5_IRQ_RESET(DE); |
Paulo Zanoni | c6d954c | 2014-04-01 15:37:18 -0300 | [diff] [blame] | 3131 | if (IS_GEN7(dev)) |
| 3132 | I915_WRITE(GEN7_ERR_INT, 0xffffffff); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3133 | |
Paulo Zanoni | 7c4d664 | 2014-04-01 15:37:19 -0300 | [diff] [blame] | 3134 | gen5_gt_irq_reset(dev); |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 3135 | |
Paulo Zanoni | 1c69eb4 | 2014-04-01 15:37:23 -0300 | [diff] [blame] | 3136 | ibx_irq_reset(dev); |
Ben Widawsky | 7d99163 | 2013-05-28 19:22:25 -0700 | [diff] [blame] | 3137 | } |
| 3138 | |
Ville Syrjälä | 70591a4 | 2014-10-30 19:42:58 +0200 | [diff] [blame] | 3139 | static void vlv_display_irq_reset(struct drm_i915_private *dev_priv) |
| 3140 | { |
| 3141 | enum pipe pipe; |
| 3142 | |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 3143 | i915_hotplug_interrupt_update(dev_priv, 0xFFFFFFFF, 0); |
Ville Syrjälä | 70591a4 | 2014-10-30 19:42:58 +0200 | [diff] [blame] | 3144 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
| 3145 | |
| 3146 | for_each_pipe(dev_priv, pipe) |
| 3147 | I915_WRITE(PIPESTAT(pipe), 0xffff); |
| 3148 | |
| 3149 | GEN5_IRQ_RESET(VLV_); |
| 3150 | } |
| 3151 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3152 | static void valleyview_irq_preinstall(struct drm_device *dev) |
| 3153 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3154 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3155 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3156 | /* VLV magic */ |
| 3157 | I915_WRITE(VLV_IMR, 0); |
| 3158 | I915_WRITE(RING_IMR(RENDER_RING_BASE), 0); |
| 3159 | I915_WRITE(RING_IMR(GEN6_BSD_RING_BASE), 0); |
| 3160 | I915_WRITE(RING_IMR(BLT_RING_BASE), 0); |
| 3161 | |
Paulo Zanoni | 7c4d664 | 2014-04-01 15:37:19 -0300 | [diff] [blame] | 3162 | gen5_gt_irq_reset(dev); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3163 | |
Ville Syrjälä | 7c4cde3 | 2014-10-30 19:42:51 +0200 | [diff] [blame] | 3164 | I915_WRITE(DPINVGTT, DPINVGTT_STATUS_MASK); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3165 | |
Ville Syrjälä | 70591a4 | 2014-10-30 19:42:58 +0200 | [diff] [blame] | 3166 | vlv_display_irq_reset(dev_priv); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3167 | } |
| 3168 | |
Daniel Vetter | d6e3cca | 2014-05-22 22:18:22 +0200 | [diff] [blame] | 3169 | static void gen8_gt_irq_reset(struct drm_i915_private *dev_priv) |
| 3170 | { |
| 3171 | GEN8_IRQ_RESET_NDX(GT, 0); |
| 3172 | GEN8_IRQ_RESET_NDX(GT, 1); |
| 3173 | GEN8_IRQ_RESET_NDX(GT, 2); |
| 3174 | GEN8_IRQ_RESET_NDX(GT, 3); |
| 3175 | } |
| 3176 | |
Paulo Zanoni | 823f6b3 | 2014-04-01 15:37:26 -0300 | [diff] [blame] | 3177 | static void gen8_irq_reset(struct drm_device *dev) |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3178 | { |
| 3179 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3180 | int pipe; |
| 3181 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3182 | I915_WRITE(GEN8_MASTER_IRQ, 0); |
| 3183 | POSTING_READ(GEN8_MASTER_IRQ); |
| 3184 | |
Daniel Vetter | d6e3cca | 2014-05-22 22:18:22 +0200 | [diff] [blame] | 3185 | gen8_gt_irq_reset(dev_priv); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3186 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 3187 | for_each_pipe(dev_priv, pipe) |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 3188 | if (intel_display_power_is_enabled(dev_priv, |
| 3189 | POWER_DOMAIN_PIPE(pipe))) |
Paulo Zanoni | 813bde4 | 2014-07-04 11:50:29 -0300 | [diff] [blame] | 3190 | GEN8_IRQ_RESET_NDX(DE_PIPE, pipe); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3191 | |
Paulo Zanoni | f86f3fb | 2014-04-01 15:37:14 -0300 | [diff] [blame] | 3192 | GEN5_IRQ_RESET(GEN8_DE_PORT_); |
| 3193 | GEN5_IRQ_RESET(GEN8_DE_MISC_); |
| 3194 | GEN5_IRQ_RESET(GEN8_PCU_); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3195 | |
Shashank Sharma | 266ea3d | 2014-08-22 17:40:42 +0530 | [diff] [blame] | 3196 | if (HAS_PCH_SPLIT(dev)) |
| 3197 | ibx_irq_reset(dev); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3198 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3199 | |
Damien Lespiau | 4c6c03b | 2015-03-06 18:50:48 +0000 | [diff] [blame] | 3200 | void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv, |
| 3201 | unsigned int pipe_mask) |
Paulo Zanoni | d49bdb0 | 2014-07-04 11:50:31 -0300 | [diff] [blame] | 3202 | { |
Paulo Zanoni | 1180e20 | 2014-10-07 18:02:52 -0300 | [diff] [blame] | 3203 | uint32_t extra_ier = GEN8_PIPE_VBLANK | GEN8_PIPE_FIFO_UNDERRUN; |
Paulo Zanoni | d49bdb0 | 2014-07-04 11:50:31 -0300 | [diff] [blame] | 3204 | |
Daniel Vetter | 1332178 | 2014-09-15 14:55:29 +0200 | [diff] [blame] | 3205 | spin_lock_irq(&dev_priv->irq_lock); |
Damien Lespiau | d14c034 | 2015-03-06 18:50:51 +0000 | [diff] [blame] | 3206 | if (pipe_mask & 1 << PIPE_A) |
| 3207 | GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_A, |
| 3208 | dev_priv->de_irq_mask[PIPE_A], |
| 3209 | ~dev_priv->de_irq_mask[PIPE_A] | extra_ier); |
Damien Lespiau | 4c6c03b | 2015-03-06 18:50:48 +0000 | [diff] [blame] | 3210 | if (pipe_mask & 1 << PIPE_B) |
| 3211 | GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_B, |
| 3212 | dev_priv->de_irq_mask[PIPE_B], |
| 3213 | ~dev_priv->de_irq_mask[PIPE_B] | extra_ier); |
| 3214 | if (pipe_mask & 1 << PIPE_C) |
| 3215 | GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_C, |
| 3216 | dev_priv->de_irq_mask[PIPE_C], |
| 3217 | ~dev_priv->de_irq_mask[PIPE_C] | extra_ier); |
Daniel Vetter | 1332178 | 2014-09-15 14:55:29 +0200 | [diff] [blame] | 3218 | spin_unlock_irq(&dev_priv->irq_lock); |
Paulo Zanoni | d49bdb0 | 2014-07-04 11:50:31 -0300 | [diff] [blame] | 3219 | } |
| 3220 | |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3221 | static void cherryview_irq_preinstall(struct drm_device *dev) |
| 3222 | { |
| 3223 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3224 | |
| 3225 | I915_WRITE(GEN8_MASTER_IRQ, 0); |
| 3226 | POSTING_READ(GEN8_MASTER_IRQ); |
| 3227 | |
Daniel Vetter | d6e3cca | 2014-05-22 22:18:22 +0200 | [diff] [blame] | 3228 | gen8_gt_irq_reset(dev_priv); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3229 | |
| 3230 | GEN5_IRQ_RESET(GEN8_PCU_); |
| 3231 | |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3232 | I915_WRITE(DPINVGTT, DPINVGTT_STATUS_MASK_CHV); |
| 3233 | |
Ville Syrjälä | 70591a4 | 2014-10-30 19:42:58 +0200 | [diff] [blame] | 3234 | vlv_display_irq_reset(dev_priv); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3235 | } |
| 3236 | |
Ville Syrjälä | 87a0210 | 2015-08-27 23:55:57 +0300 | [diff] [blame] | 3237 | static u32 intel_hpd_enabled_irqs(struct drm_device *dev, |
| 3238 | const u32 hpd[HPD_NUM_PINS]) |
| 3239 | { |
| 3240 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 3241 | struct intel_encoder *encoder; |
| 3242 | u32 enabled_irqs = 0; |
| 3243 | |
| 3244 | for_each_intel_encoder(dev, encoder) |
| 3245 | if (dev_priv->hotplug.stats[encoder->hpd_pin].state == HPD_ENABLED) |
| 3246 | enabled_irqs |= hpd[encoder->hpd_pin]; |
| 3247 | |
| 3248 | return enabled_irqs; |
| 3249 | } |
| 3250 | |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3251 | static void ibx_hpd_irq_setup(struct drm_device *dev) |
Keith Packard | 7fe0b97 | 2011-09-19 13:31:02 -0700 | [diff] [blame] | 3252 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3253 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 87a0210 | 2015-08-27 23:55:57 +0300 | [diff] [blame] | 3254 | u32 hotplug_irqs, hotplug, enabled_irqs; |
Keith Packard | 7fe0b97 | 2011-09-19 13:31:02 -0700 | [diff] [blame] | 3255 | |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3256 | if (HAS_PCH_IBX(dev)) { |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 3257 | hotplug_irqs = SDE_HOTPLUG_MASK; |
Ville Syrjälä | 87a0210 | 2015-08-27 23:55:57 +0300 | [diff] [blame] | 3258 | enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_ibx); |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3259 | } else { |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 3260 | hotplug_irqs = SDE_HOTPLUG_MASK_CPT; |
Ville Syrjälä | 87a0210 | 2015-08-27 23:55:57 +0300 | [diff] [blame] | 3261 | enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_cpt); |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3262 | } |
| 3263 | |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 3264 | ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs); |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3265 | |
| 3266 | /* |
| 3267 | * Enable digital hotplug on the PCH, and configure the DP short pulse |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 3268 | * duration to 2ms (which is the minimum in the Display Port spec). |
| 3269 | * The pulse duration bits are reserved on LPT+. |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3270 | */ |
Keith Packard | 7fe0b97 | 2011-09-19 13:31:02 -0700 | [diff] [blame] | 3271 | hotplug = I915_READ(PCH_PORT_HOTPLUG); |
| 3272 | hotplug &= ~(PORTD_PULSE_DURATION_MASK|PORTC_PULSE_DURATION_MASK|PORTB_PULSE_DURATION_MASK); |
| 3273 | hotplug |= PORTD_HOTPLUG_ENABLE | PORTD_PULSE_DURATION_2ms; |
| 3274 | hotplug |= PORTC_HOTPLUG_ENABLE | PORTC_PULSE_DURATION_2ms; |
| 3275 | hotplug |= PORTB_HOTPLUG_ENABLE | PORTB_PULSE_DURATION_2ms; |
Ville Syrjälä | 0b2eb33 | 2015-08-27 23:56:05 +0300 | [diff] [blame] | 3276 | /* |
| 3277 | * When CPU and PCH are on the same package, port A |
| 3278 | * HPD must be enabled in both north and south. |
| 3279 | */ |
| 3280 | if (HAS_PCH_LPT_LP(dev)) |
| 3281 | hotplug |= PORTA_HOTPLUG_ENABLE; |
Keith Packard | 7fe0b97 | 2011-09-19 13:31:02 -0700 | [diff] [blame] | 3282 | I915_WRITE(PCH_PORT_HOTPLUG, hotplug); |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 3283 | } |
Xiong Zhang | 26951ca | 2015-08-17 15:55:50 +0800 | [diff] [blame] | 3284 | |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 3285 | static void spt_hpd_irq_setup(struct drm_device *dev) |
| 3286 | { |
| 3287 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3288 | u32 hotplug_irqs, hotplug, enabled_irqs; |
| 3289 | |
| 3290 | hotplug_irqs = SDE_HOTPLUG_MASK_SPT; |
| 3291 | enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_spt); |
| 3292 | |
| 3293 | ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs); |
| 3294 | |
| 3295 | /* Enable digital hotplug on the PCH */ |
| 3296 | hotplug = I915_READ(PCH_PORT_HOTPLUG); |
| 3297 | hotplug |= PORTD_HOTPLUG_ENABLE | PORTC_HOTPLUG_ENABLE | |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 3298 | PORTB_HOTPLUG_ENABLE | PORTA_HOTPLUG_ENABLE; |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 3299 | I915_WRITE(PCH_PORT_HOTPLUG, hotplug); |
| 3300 | |
| 3301 | hotplug = I915_READ(PCH_PORT_HOTPLUG2); |
| 3302 | hotplug |= PORTE_HOTPLUG_ENABLE; |
| 3303 | I915_WRITE(PCH_PORT_HOTPLUG2, hotplug); |
Keith Packard | 7fe0b97 | 2011-09-19 13:31:02 -0700 | [diff] [blame] | 3304 | } |
| 3305 | |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3306 | static void ilk_hpd_irq_setup(struct drm_device *dev) |
| 3307 | { |
| 3308 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3309 | u32 hotplug_irqs, hotplug, enabled_irqs; |
| 3310 | |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3311 | if (INTEL_INFO(dev)->gen >= 8) { |
| 3312 | hotplug_irqs = GEN8_PORT_DP_A_HOTPLUG; |
| 3313 | enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_bdw); |
| 3314 | |
| 3315 | bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs); |
| 3316 | } else if (INTEL_INFO(dev)->gen >= 7) { |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 3317 | hotplug_irqs = DE_DP_A_HOTPLUG_IVB; |
| 3318 | enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_ivb); |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3319 | |
| 3320 | ilk_update_display_irq(dev_priv, hotplug_irqs, enabled_irqs); |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 3321 | } else { |
| 3322 | hotplug_irqs = DE_DP_A_HOTPLUG; |
| 3323 | enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_ilk); |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3324 | |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3325 | ilk_update_display_irq(dev_priv, hotplug_irqs, enabled_irqs); |
| 3326 | } |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3327 | |
| 3328 | /* |
| 3329 | * Enable digital hotplug on the CPU, and configure the DP short pulse |
| 3330 | * duration to 2ms (which is the minimum in the Display Port spec) |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 3331 | * The pulse duration bits are reserved on HSW+. |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3332 | */ |
| 3333 | hotplug = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL); |
| 3334 | hotplug &= ~DIGITAL_PORTA_PULSE_DURATION_MASK; |
| 3335 | hotplug |= DIGITAL_PORTA_HOTPLUG_ENABLE | DIGITAL_PORTA_PULSE_DURATION_2ms; |
| 3336 | I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, hotplug); |
| 3337 | |
| 3338 | ibx_hpd_irq_setup(dev); |
| 3339 | } |
| 3340 | |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 3341 | static void bxt_hpd_irq_setup(struct drm_device *dev) |
| 3342 | { |
| 3343 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | a52bb15 | 2015-08-27 23:56:11 +0300 | [diff] [blame] | 3344 | u32 hotplug_irqs, hotplug, enabled_irqs; |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 3345 | |
Ville Syrjälä | a52bb15 | 2015-08-27 23:56:11 +0300 | [diff] [blame] | 3346 | enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_bxt); |
| 3347 | hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK; |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 3348 | |
Ville Syrjälä | a52bb15 | 2015-08-27 23:56:11 +0300 | [diff] [blame] | 3349 | bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs); |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 3350 | |
Ville Syrjälä | a52bb15 | 2015-08-27 23:56:11 +0300 | [diff] [blame] | 3351 | hotplug = I915_READ(PCH_PORT_HOTPLUG); |
| 3352 | hotplug |= PORTC_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE | |
| 3353 | PORTA_HOTPLUG_ENABLE; |
| 3354 | I915_WRITE(PCH_PORT_HOTPLUG, hotplug); |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 3355 | } |
| 3356 | |
Paulo Zanoni | d46da43 | 2013-02-08 17:35:15 -0200 | [diff] [blame] | 3357 | static void ibx_irq_postinstall(struct drm_device *dev) |
| 3358 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3359 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3360 | u32 mask; |
Paulo Zanoni | d46da43 | 2013-02-08 17:35:15 -0200 | [diff] [blame] | 3361 | |
Daniel Vetter | 692a04c | 2013-05-29 21:43:05 +0200 | [diff] [blame] | 3362 | if (HAS_PCH_NOP(dev)) |
| 3363 | return; |
| 3364 | |
Paulo Zanoni | 105b122 | 2014-04-01 15:37:17 -0300 | [diff] [blame] | 3365 | if (HAS_PCH_IBX(dev)) |
Daniel Vetter | 5c673b6 | 2014-03-07 20:34:46 +0100 | [diff] [blame] | 3366 | mask = SDE_GMBUS | SDE_AUX_MASK | SDE_POISON; |
Paulo Zanoni | 105b122 | 2014-04-01 15:37:17 -0300 | [diff] [blame] | 3367 | else |
Daniel Vetter | 5c673b6 | 2014-03-07 20:34:46 +0100 | [diff] [blame] | 3368 | mask = SDE_GMBUS_CPT | SDE_AUX_MASK_CPT; |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 3369 | |
Ville Syrjälä | b51a284 | 2015-09-18 20:03:41 +0300 | [diff] [blame] | 3370 | gen5_assert_iir_is_zero(dev_priv, SDEIIR); |
Paulo Zanoni | d46da43 | 2013-02-08 17:35:15 -0200 | [diff] [blame] | 3371 | I915_WRITE(SDEIMR, ~mask); |
Paulo Zanoni | d46da43 | 2013-02-08 17:35:15 -0200 | [diff] [blame] | 3372 | } |
| 3373 | |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3374 | static void gen5_gt_irq_postinstall(struct drm_device *dev) |
| 3375 | { |
| 3376 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3377 | u32 pm_irqs, gt_irqs; |
| 3378 | |
| 3379 | pm_irqs = gt_irqs = 0; |
| 3380 | |
| 3381 | dev_priv->gt_irq_mask = ~0; |
Ben Widawsky | 040d2ba | 2013-09-19 11:01:40 -0700 | [diff] [blame] | 3382 | if (HAS_L3_DPF(dev)) { |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3383 | /* L3 parity interrupt is always unmasked. */ |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 3384 | dev_priv->gt_irq_mask = ~GT_PARITY_ERROR(dev); |
| 3385 | gt_irqs |= GT_PARITY_ERROR(dev); |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3386 | } |
| 3387 | |
| 3388 | gt_irqs |= GT_RENDER_USER_INTERRUPT; |
| 3389 | if (IS_GEN5(dev)) { |
| 3390 | gt_irqs |= GT_RENDER_PIPECTL_NOTIFY_INTERRUPT | |
| 3391 | ILK_BSD_USER_INTERRUPT; |
| 3392 | } else { |
| 3393 | gt_irqs |= GT_BLT_USER_INTERRUPT | GT_BSD_USER_INTERRUPT; |
| 3394 | } |
| 3395 | |
Paulo Zanoni | 3507989 | 2014-04-01 15:37:15 -0300 | [diff] [blame] | 3396 | GEN5_IRQ_INIT(GT, dev_priv->gt_irq_mask, gt_irqs); |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3397 | |
| 3398 | if (INTEL_INFO(dev)->gen >= 6) { |
Imre Deak | 78e68d3 | 2014-12-15 18:59:27 +0200 | [diff] [blame] | 3399 | /* |
| 3400 | * RPS interrupts will get enabled/disabled on demand when RPS |
| 3401 | * itself is enabled/disabled. |
| 3402 | */ |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3403 | if (HAS_VEBOX(dev)) |
| 3404 | pm_irqs |= PM_VEBOX_USER_INTERRUPT; |
| 3405 | |
Paulo Zanoni | 605cd25 | 2013-08-06 18:57:15 -0300 | [diff] [blame] | 3406 | dev_priv->pm_irq_mask = 0xffffffff; |
Paulo Zanoni | 3507989 | 2014-04-01 15:37:15 -0300 | [diff] [blame] | 3407 | GEN5_IRQ_INIT(GEN6_PM, dev_priv->pm_irq_mask, pm_irqs); |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3408 | } |
| 3409 | } |
| 3410 | |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 3411 | static int ironlake_irq_postinstall(struct drm_device *dev) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3412 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3413 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 8e76f8d | 2013-07-12 20:01:56 -0300 | [diff] [blame] | 3414 | u32 display_mask, extra_mask; |
| 3415 | |
| 3416 | if (INTEL_INFO(dev)->gen >= 7) { |
| 3417 | display_mask = (DE_MASTER_IRQ_CONTROL | DE_GSE_IVB | |
| 3418 | DE_PCH_EVENT_IVB | DE_PLANEC_FLIP_DONE_IVB | |
| 3419 | DE_PLANEB_FLIP_DONE_IVB | |
Daniel Vetter | 5c673b6 | 2014-03-07 20:34:46 +0100 | [diff] [blame] | 3420 | DE_PLANEA_FLIP_DONE_IVB | DE_AUX_CHANNEL_A_IVB); |
Paulo Zanoni | 8e76f8d | 2013-07-12 20:01:56 -0300 | [diff] [blame] | 3421 | extra_mask = (DE_PIPEC_VBLANK_IVB | DE_PIPEB_VBLANK_IVB | |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 3422 | DE_PIPEA_VBLANK_IVB | DE_ERR_INT_IVB | |
| 3423 | DE_DP_A_HOTPLUG_IVB); |
Paulo Zanoni | 8e76f8d | 2013-07-12 20:01:56 -0300 | [diff] [blame] | 3424 | } else { |
| 3425 | display_mask = (DE_MASTER_IRQ_CONTROL | DE_GSE | DE_PCH_EVENT | |
| 3426 | DE_PLANEA_FLIP_DONE | DE_PLANEB_FLIP_DONE | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3427 | DE_AUX_CHANNEL_A | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3428 | DE_PIPEB_CRC_DONE | DE_PIPEA_CRC_DONE | |
| 3429 | DE_POISON); |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3430 | extra_mask = (DE_PIPEA_VBLANK | DE_PIPEB_VBLANK | DE_PCU_EVENT | |
| 3431 | DE_PIPEB_FIFO_UNDERRUN | DE_PIPEA_FIFO_UNDERRUN | |
| 3432 | DE_DP_A_HOTPLUG); |
Paulo Zanoni | 8e76f8d | 2013-07-12 20:01:56 -0300 | [diff] [blame] | 3433 | } |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3434 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 3435 | dev_priv->irq_mask = ~display_mask; |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3436 | |
Paulo Zanoni | 0c84121 | 2014-04-01 15:37:27 -0300 | [diff] [blame] | 3437 | I915_WRITE(HWSTAM, 0xeffe); |
| 3438 | |
Paulo Zanoni | 622364b | 2014-04-01 15:37:22 -0300 | [diff] [blame] | 3439 | ibx_irq_pre_postinstall(dev); |
| 3440 | |
Paulo Zanoni | 3507989 | 2014-04-01 15:37:15 -0300 | [diff] [blame] | 3441 | GEN5_IRQ_INIT(DE, dev_priv->irq_mask, display_mask | extra_mask); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3442 | |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3443 | gen5_gt_irq_postinstall(dev); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3444 | |
Paulo Zanoni | d46da43 | 2013-02-08 17:35:15 -0200 | [diff] [blame] | 3445 | ibx_irq_postinstall(dev); |
Keith Packard | 7fe0b97 | 2011-09-19 13:31:02 -0700 | [diff] [blame] | 3446 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 3447 | if (IS_IRONLAKE_M(dev)) { |
Daniel Vetter | 6005ce4 | 2013-06-27 13:44:59 +0200 | [diff] [blame] | 3448 | /* Enable PCU event interrupts |
| 3449 | * |
| 3450 | * spinlocking not required here for correctness since interrupt |
Daniel Vetter | 4bc9d43 | 2013-06-27 13:44:58 +0200 | [diff] [blame] | 3451 | * setup is guaranteed to run in single-threaded context. But we |
| 3452 | * need it to make the assert_spin_locked happy. */ |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 3453 | spin_lock_irq(&dev_priv->irq_lock); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 3454 | ironlake_enable_display_irq(dev_priv, DE_PCU_EVENT); |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 3455 | spin_unlock_irq(&dev_priv->irq_lock); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 3456 | } |
| 3457 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3458 | return 0; |
| 3459 | } |
| 3460 | |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3461 | static void valleyview_display_irqs_install(struct drm_i915_private *dev_priv) |
| 3462 | { |
| 3463 | u32 pipestat_mask; |
| 3464 | u32 iir_mask; |
Ville Syrjälä | 120dda4 | 2014-10-30 19:42:57 +0200 | [diff] [blame] | 3465 | enum pipe pipe; |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3466 | |
| 3467 | pipestat_mask = PIPESTAT_INT_STATUS_MASK | |
| 3468 | PIPE_FIFO_UNDERRUN_STATUS; |
| 3469 | |
Ville Syrjälä | 120dda4 | 2014-10-30 19:42:57 +0200 | [diff] [blame] | 3470 | for_each_pipe(dev_priv, pipe) |
| 3471 | I915_WRITE(PIPESTAT(pipe), pipestat_mask); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3472 | POSTING_READ(PIPESTAT(PIPE_A)); |
| 3473 | |
| 3474 | pipestat_mask = PLANE_FLIP_DONE_INT_STATUS_VLV | |
| 3475 | PIPE_CRC_DONE_INTERRUPT_STATUS; |
| 3476 | |
Ville Syrjälä | 120dda4 | 2014-10-30 19:42:57 +0200 | [diff] [blame] | 3477 | i915_enable_pipestat(dev_priv, PIPE_A, PIPE_GMBUS_INTERRUPT_STATUS); |
| 3478 | for_each_pipe(dev_priv, pipe) |
| 3479 | i915_enable_pipestat(dev_priv, pipe, pipestat_mask); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3480 | |
| 3481 | iir_mask = I915_DISPLAY_PORT_INTERRUPT | |
| 3482 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
| 3483 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT; |
Ville Syrjälä | 120dda4 | 2014-10-30 19:42:57 +0200 | [diff] [blame] | 3484 | if (IS_CHERRYVIEW(dev_priv)) |
| 3485 | iir_mask |= I915_DISPLAY_PIPE_C_EVENT_INTERRUPT; |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3486 | dev_priv->irq_mask &= ~iir_mask; |
| 3487 | |
| 3488 | I915_WRITE(VLV_IIR, iir_mask); |
| 3489 | I915_WRITE(VLV_IIR, iir_mask); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3490 | I915_WRITE(VLV_IER, ~dev_priv->irq_mask); |
Ville Syrjälä | 76e4186 | 2014-10-30 19:42:54 +0200 | [diff] [blame] | 3491 | I915_WRITE(VLV_IMR, dev_priv->irq_mask); |
| 3492 | POSTING_READ(VLV_IMR); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3493 | } |
| 3494 | |
| 3495 | static void valleyview_display_irqs_uninstall(struct drm_i915_private *dev_priv) |
| 3496 | { |
| 3497 | u32 pipestat_mask; |
| 3498 | u32 iir_mask; |
Ville Syrjälä | 120dda4 | 2014-10-30 19:42:57 +0200 | [diff] [blame] | 3499 | enum pipe pipe; |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3500 | |
| 3501 | iir_mask = I915_DISPLAY_PORT_INTERRUPT | |
| 3502 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
Imre Deak | 6c7fba0 | 2014-03-10 19:44:48 +0200 | [diff] [blame] | 3503 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT; |
Ville Syrjälä | 120dda4 | 2014-10-30 19:42:57 +0200 | [diff] [blame] | 3504 | if (IS_CHERRYVIEW(dev_priv)) |
| 3505 | iir_mask |= I915_DISPLAY_PIPE_C_EVENT_INTERRUPT; |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3506 | |
| 3507 | dev_priv->irq_mask |= iir_mask; |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3508 | I915_WRITE(VLV_IMR, dev_priv->irq_mask); |
Ville Syrjälä | 76e4186 | 2014-10-30 19:42:54 +0200 | [diff] [blame] | 3509 | I915_WRITE(VLV_IER, ~dev_priv->irq_mask); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3510 | I915_WRITE(VLV_IIR, iir_mask); |
| 3511 | I915_WRITE(VLV_IIR, iir_mask); |
| 3512 | POSTING_READ(VLV_IIR); |
| 3513 | |
| 3514 | pipestat_mask = PLANE_FLIP_DONE_INT_STATUS_VLV | |
| 3515 | PIPE_CRC_DONE_INTERRUPT_STATUS; |
| 3516 | |
Ville Syrjälä | 120dda4 | 2014-10-30 19:42:57 +0200 | [diff] [blame] | 3517 | i915_disable_pipestat(dev_priv, PIPE_A, PIPE_GMBUS_INTERRUPT_STATUS); |
| 3518 | for_each_pipe(dev_priv, pipe) |
| 3519 | i915_disable_pipestat(dev_priv, pipe, pipestat_mask); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3520 | |
| 3521 | pipestat_mask = PIPESTAT_INT_STATUS_MASK | |
| 3522 | PIPE_FIFO_UNDERRUN_STATUS; |
Ville Syrjälä | 120dda4 | 2014-10-30 19:42:57 +0200 | [diff] [blame] | 3523 | |
| 3524 | for_each_pipe(dev_priv, pipe) |
| 3525 | I915_WRITE(PIPESTAT(pipe), pipestat_mask); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3526 | POSTING_READ(PIPESTAT(PIPE_A)); |
| 3527 | } |
| 3528 | |
| 3529 | void valleyview_enable_display_irqs(struct drm_i915_private *dev_priv) |
| 3530 | { |
| 3531 | assert_spin_locked(&dev_priv->irq_lock); |
| 3532 | |
| 3533 | if (dev_priv->display_irqs_enabled) |
| 3534 | return; |
| 3535 | |
| 3536 | dev_priv->display_irqs_enabled = true; |
| 3537 | |
Imre Deak | 950eaba | 2014-09-08 15:21:09 +0300 | [diff] [blame] | 3538 | if (intel_irqs_enabled(dev_priv)) |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3539 | valleyview_display_irqs_install(dev_priv); |
| 3540 | } |
| 3541 | |
| 3542 | void valleyview_disable_display_irqs(struct drm_i915_private *dev_priv) |
| 3543 | { |
| 3544 | assert_spin_locked(&dev_priv->irq_lock); |
| 3545 | |
| 3546 | if (!dev_priv->display_irqs_enabled) |
| 3547 | return; |
| 3548 | |
| 3549 | dev_priv->display_irqs_enabled = false; |
| 3550 | |
Imre Deak | 950eaba | 2014-09-08 15:21:09 +0300 | [diff] [blame] | 3551 | if (intel_irqs_enabled(dev_priv)) |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3552 | valleyview_display_irqs_uninstall(dev_priv); |
| 3553 | } |
| 3554 | |
Ville Syrjälä | 0e6c9a9 | 2014-10-30 19:43:00 +0200 | [diff] [blame] | 3555 | static void vlv_display_irq_postinstall(struct drm_i915_private *dev_priv) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3556 | { |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3557 | dev_priv->irq_mask = ~0; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3558 | |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 3559 | i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0); |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 3560 | POSTING_READ(PORT_HOTPLUG_EN); |
| 3561 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3562 | I915_WRITE(VLV_IIR, 0xffffffff); |
Ville Syrjälä | 76e4186 | 2014-10-30 19:42:54 +0200 | [diff] [blame] | 3563 | I915_WRITE(VLV_IIR, 0xffffffff); |
| 3564 | I915_WRITE(VLV_IER, ~dev_priv->irq_mask); |
| 3565 | I915_WRITE(VLV_IMR, dev_priv->irq_mask); |
| 3566 | POSTING_READ(VLV_IMR); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3567 | |
Daniel Vetter | b79480b | 2013-06-27 17:52:10 +0200 | [diff] [blame] | 3568 | /* Interrupt setup is already guaranteed to be single-threaded, this is |
| 3569 | * just to make the assert_spin_locked check happy. */ |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 3570 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3571 | if (dev_priv->display_irqs_enabled) |
| 3572 | valleyview_display_irqs_install(dev_priv); |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 3573 | spin_unlock_irq(&dev_priv->irq_lock); |
Ville Syrjälä | 0e6c9a9 | 2014-10-30 19:43:00 +0200 | [diff] [blame] | 3574 | } |
| 3575 | |
| 3576 | static int valleyview_irq_postinstall(struct drm_device *dev) |
| 3577 | { |
| 3578 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3579 | |
| 3580 | vlv_display_irq_postinstall(dev_priv); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3581 | |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3582 | gen5_gt_irq_postinstall(dev); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3583 | |
| 3584 | /* ack & enable invalid PTE error interrupts */ |
| 3585 | #if 0 /* FIXME: add support to irq handler for checking these bits */ |
| 3586 | I915_WRITE(DPINVGTT, DPINVGTT_STATUS_MASK); |
| 3587 | I915_WRITE(DPINVGTT, DPINVGTT_EN_MASK); |
| 3588 | #endif |
| 3589 | |
| 3590 | I915_WRITE(VLV_MASTER_IER, MASTER_INTERRUPT_ENABLE); |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 3591 | |
| 3592 | return 0; |
| 3593 | } |
| 3594 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3595 | static void gen8_gt_irq_postinstall(struct drm_i915_private *dev_priv) |
| 3596 | { |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3597 | /* These are interrupts we'll toggle with the ring mask register */ |
| 3598 | uint32_t gt_interrupts[] = { |
| 3599 | GT_RENDER_USER_INTERRUPT << GEN8_RCS_IRQ_SHIFT | |
Oscar Mateo | 73d477f | 2014-07-24 17:04:31 +0100 | [diff] [blame] | 3600 | GT_CONTEXT_SWITCH_INTERRUPT << GEN8_RCS_IRQ_SHIFT | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3601 | GT_RENDER_L3_PARITY_ERROR_INTERRUPT | |
Oscar Mateo | 73d477f | 2014-07-24 17:04:31 +0100 | [diff] [blame] | 3602 | GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT | |
| 3603 | GT_CONTEXT_SWITCH_INTERRUPT << GEN8_BCS_IRQ_SHIFT, |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3604 | GT_RENDER_USER_INTERRUPT << GEN8_VCS1_IRQ_SHIFT | |
Oscar Mateo | 73d477f | 2014-07-24 17:04:31 +0100 | [diff] [blame] | 3605 | GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS1_IRQ_SHIFT | |
| 3606 | GT_RENDER_USER_INTERRUPT << GEN8_VCS2_IRQ_SHIFT | |
| 3607 | GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS2_IRQ_SHIFT, |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3608 | 0, |
Oscar Mateo | 73d477f | 2014-07-24 17:04:31 +0100 | [diff] [blame] | 3609 | GT_RENDER_USER_INTERRUPT << GEN8_VECS_IRQ_SHIFT | |
| 3610 | GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VECS_IRQ_SHIFT |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3611 | }; |
| 3612 | |
Ben Widawsky | 0961021 | 2014-05-15 20:58:08 +0300 | [diff] [blame] | 3613 | dev_priv->pm_irq_mask = 0xffffffff; |
Deepak S | 9a2d2d8 | 2014-08-22 08:32:40 +0530 | [diff] [blame] | 3614 | GEN8_IRQ_INIT_NDX(GT, 0, ~gt_interrupts[0], gt_interrupts[0]); |
| 3615 | GEN8_IRQ_INIT_NDX(GT, 1, ~gt_interrupts[1], gt_interrupts[1]); |
Imre Deak | 78e68d3 | 2014-12-15 18:59:27 +0200 | [diff] [blame] | 3616 | /* |
| 3617 | * RPS interrupts will get enabled/disabled on demand when RPS itself |
| 3618 | * is enabled/disabled. |
| 3619 | */ |
| 3620 | GEN8_IRQ_INIT_NDX(GT, 2, dev_priv->pm_irq_mask, 0); |
Deepak S | 9a2d2d8 | 2014-08-22 08:32:40 +0530 | [diff] [blame] | 3621 | GEN8_IRQ_INIT_NDX(GT, 3, ~gt_interrupts[3], gt_interrupts[3]); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3622 | } |
| 3623 | |
| 3624 | static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv) |
| 3625 | { |
Damien Lespiau | 770de83 | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 3626 | uint32_t de_pipe_masked = GEN8_PIPE_CDCLK_CRC_DONE; |
| 3627 | uint32_t de_pipe_enables; |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3628 | u32 de_port_masked = GEN8_AUX_CHANNEL_A; |
| 3629 | u32 de_port_enables; |
| 3630 | enum pipe pipe; |
Damien Lespiau | 770de83 | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 3631 | |
Rodrigo Vivi | b4834a5 | 2015-09-02 15:19:24 -0700 | [diff] [blame] | 3632 | if (INTEL_INFO(dev_priv)->gen >= 9) { |
Damien Lespiau | 770de83 | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 3633 | de_pipe_masked |= GEN9_PIPE_PLANE1_FLIP_DONE | |
| 3634 | GEN9_DE_PIPE_IRQ_FAULT_ERRORS; |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3635 | de_port_masked |= GEN9_AUX_CHANNEL_B | GEN9_AUX_CHANNEL_C | |
| 3636 | GEN9_AUX_CHANNEL_D; |
Shashank Sharma | 9e63743 | 2014-08-22 17:40:43 +0530 | [diff] [blame] | 3637 | if (IS_BROXTON(dev_priv)) |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3638 | de_port_masked |= BXT_DE_PORT_GMBUS; |
| 3639 | } else { |
Damien Lespiau | 770de83 | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 3640 | de_pipe_masked |= GEN8_PIPE_PRIMARY_FLIP_DONE | |
| 3641 | GEN8_DE_PIPE_IRQ_FAULT_ERRORS; |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3642 | } |
Damien Lespiau | 770de83 | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 3643 | |
| 3644 | de_pipe_enables = de_pipe_masked | GEN8_PIPE_VBLANK | |
| 3645 | GEN8_PIPE_FIFO_UNDERRUN; |
| 3646 | |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3647 | de_port_enables = de_port_masked; |
Ville Syrjälä | a52bb15 | 2015-08-27 23:56:11 +0300 | [diff] [blame] | 3648 | if (IS_BROXTON(dev_priv)) |
| 3649 | de_port_enables |= BXT_DE_PORT_HOTPLUG_MASK; |
| 3650 | else if (IS_BROADWELL(dev_priv)) |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3651 | de_port_enables |= GEN8_PORT_DP_A_HOTPLUG; |
| 3652 | |
Daniel Vetter | 13b3a0a | 2013-11-07 15:31:52 +0100 | [diff] [blame] | 3653 | dev_priv->de_irq_mask[PIPE_A] = ~de_pipe_masked; |
| 3654 | dev_priv->de_irq_mask[PIPE_B] = ~de_pipe_masked; |
| 3655 | dev_priv->de_irq_mask[PIPE_C] = ~de_pipe_masked; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3656 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 3657 | for_each_pipe(dev_priv, pipe) |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 3658 | if (intel_display_power_is_enabled(dev_priv, |
Paulo Zanoni | 813bde4 | 2014-07-04 11:50:29 -0300 | [diff] [blame] | 3659 | POWER_DOMAIN_PIPE(pipe))) |
| 3660 | GEN8_IRQ_INIT_NDX(DE_PIPE, pipe, |
| 3661 | dev_priv->de_irq_mask[pipe], |
| 3662 | de_pipe_enables); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3663 | |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3664 | GEN5_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3665 | } |
| 3666 | |
| 3667 | static int gen8_irq_postinstall(struct drm_device *dev) |
| 3668 | { |
| 3669 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3670 | |
Shashank Sharma | 266ea3d | 2014-08-22 17:40:42 +0530 | [diff] [blame] | 3671 | if (HAS_PCH_SPLIT(dev)) |
| 3672 | ibx_irq_pre_postinstall(dev); |
Paulo Zanoni | 622364b | 2014-04-01 15:37:22 -0300 | [diff] [blame] | 3673 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3674 | gen8_gt_irq_postinstall(dev_priv); |
| 3675 | gen8_de_irq_postinstall(dev_priv); |
| 3676 | |
Shashank Sharma | 266ea3d | 2014-08-22 17:40:42 +0530 | [diff] [blame] | 3677 | if (HAS_PCH_SPLIT(dev)) |
| 3678 | ibx_irq_postinstall(dev); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3679 | |
| 3680 | I915_WRITE(GEN8_MASTER_IRQ, DE_MASTER_IRQ_CONTROL); |
| 3681 | POSTING_READ(GEN8_MASTER_IRQ); |
| 3682 | |
| 3683 | return 0; |
| 3684 | } |
| 3685 | |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3686 | static int cherryview_irq_postinstall(struct drm_device *dev) |
| 3687 | { |
| 3688 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3689 | |
Ville Syrjälä | c2b6679 | 2014-10-30 19:43:02 +0200 | [diff] [blame] | 3690 | vlv_display_irq_postinstall(dev_priv); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3691 | |
| 3692 | gen8_gt_irq_postinstall(dev_priv); |
| 3693 | |
| 3694 | I915_WRITE(GEN8_MASTER_IRQ, MASTER_INTERRUPT_ENABLE); |
| 3695 | POSTING_READ(GEN8_MASTER_IRQ); |
| 3696 | |
| 3697 | return 0; |
| 3698 | } |
| 3699 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3700 | static void gen8_irq_uninstall(struct drm_device *dev) |
| 3701 | { |
| 3702 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3703 | |
| 3704 | if (!dev_priv) |
| 3705 | return; |
| 3706 | |
Paulo Zanoni | 823f6b3 | 2014-04-01 15:37:26 -0300 | [diff] [blame] | 3707 | gen8_irq_reset(dev); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3708 | } |
| 3709 | |
Ville Syrjälä | 8ea0be4 | 2014-10-30 19:42:59 +0200 | [diff] [blame] | 3710 | static void vlv_display_irq_uninstall(struct drm_i915_private *dev_priv) |
| 3711 | { |
| 3712 | /* Interrupt setup is already guaranteed to be single-threaded, this is |
| 3713 | * just to make the assert_spin_locked check happy. */ |
| 3714 | spin_lock_irq(&dev_priv->irq_lock); |
| 3715 | if (dev_priv->display_irqs_enabled) |
| 3716 | valleyview_display_irqs_uninstall(dev_priv); |
| 3717 | spin_unlock_irq(&dev_priv->irq_lock); |
| 3718 | |
| 3719 | vlv_display_irq_reset(dev_priv); |
| 3720 | |
Imre Deak | c352d1b | 2014-11-20 16:05:55 +0200 | [diff] [blame] | 3721 | dev_priv->irq_mask = ~0; |
Ville Syrjälä | 8ea0be4 | 2014-10-30 19:42:59 +0200 | [diff] [blame] | 3722 | } |
| 3723 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3724 | static void valleyview_irq_uninstall(struct drm_device *dev) |
| 3725 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3726 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3727 | |
| 3728 | if (!dev_priv) |
| 3729 | return; |
| 3730 | |
Imre Deak | 843d0e7 | 2014-04-14 20:24:23 +0300 | [diff] [blame] | 3731 | I915_WRITE(VLV_MASTER_IER, 0); |
| 3732 | |
Ville Syrjälä | 893fce8 | 2014-10-30 19:42:56 +0200 | [diff] [blame] | 3733 | gen5_gt_irq_reset(dev); |
| 3734 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3735 | I915_WRITE(HWSTAM, 0xffffffff); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3736 | |
Ville Syrjälä | 8ea0be4 | 2014-10-30 19:42:59 +0200 | [diff] [blame] | 3737 | vlv_display_irq_uninstall(dev_priv); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3738 | } |
| 3739 | |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3740 | static void cherryview_irq_uninstall(struct drm_device *dev) |
| 3741 | { |
| 3742 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3743 | |
| 3744 | if (!dev_priv) |
| 3745 | return; |
| 3746 | |
| 3747 | I915_WRITE(GEN8_MASTER_IRQ, 0); |
| 3748 | POSTING_READ(GEN8_MASTER_IRQ); |
| 3749 | |
Ville Syrjälä | a2c30fb | 2014-10-30 19:42:52 +0200 | [diff] [blame] | 3750 | gen8_gt_irq_reset(dev_priv); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3751 | |
Ville Syrjälä | a2c30fb | 2014-10-30 19:42:52 +0200 | [diff] [blame] | 3752 | GEN5_IRQ_RESET(GEN8_PCU_); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3753 | |
Ville Syrjälä | c2b6679 | 2014-10-30 19:43:02 +0200 | [diff] [blame] | 3754 | vlv_display_irq_uninstall(dev_priv); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3755 | } |
| 3756 | |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 3757 | static void ironlake_irq_uninstall(struct drm_device *dev) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3758 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3759 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 4697995 | 2011-04-07 13:53:55 -0700 | [diff] [blame] | 3760 | |
| 3761 | if (!dev_priv) |
| 3762 | return; |
| 3763 | |
Paulo Zanoni | be30b29 | 2014-04-01 15:37:25 -0300 | [diff] [blame] | 3764 | ironlake_irq_reset(dev); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3765 | } |
| 3766 | |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3767 | static void i8xx_irq_preinstall(struct drm_device * dev) |
| 3768 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3769 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3770 | int pipe; |
| 3771 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 3772 | for_each_pipe(dev_priv, pipe) |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3773 | I915_WRITE(PIPESTAT(pipe), 0); |
| 3774 | I915_WRITE16(IMR, 0xffff); |
| 3775 | I915_WRITE16(IER, 0x0); |
| 3776 | POSTING_READ16(IER); |
| 3777 | } |
| 3778 | |
| 3779 | static int i8xx_irq_postinstall(struct drm_device *dev) |
| 3780 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3781 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3782 | |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3783 | I915_WRITE16(EMR, |
| 3784 | ~(I915_ERROR_PAGE_TABLE | I915_ERROR_MEMORY_REFRESH)); |
| 3785 | |
| 3786 | /* Unmask the interrupts that we always want on. */ |
| 3787 | dev_priv->irq_mask = |
| 3788 | ~(I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
| 3789 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
| 3790 | I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | |
Daniel Vetter | 37ef01a | 2015-04-01 13:43:46 +0200 | [diff] [blame] | 3791 | I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3792 | I915_WRITE16(IMR, dev_priv->irq_mask); |
| 3793 | |
| 3794 | I915_WRITE16(IER, |
| 3795 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
| 3796 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3797 | I915_USER_INTERRUPT); |
| 3798 | POSTING_READ16(IER); |
| 3799 | |
Daniel Vetter | 379ef82 | 2013-10-16 22:55:56 +0200 | [diff] [blame] | 3800 | /* Interrupt setup is already guaranteed to be single-threaded, this is |
| 3801 | * just to make the assert_spin_locked check happy. */ |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 3802 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 3803 | i915_enable_pipestat(dev_priv, PIPE_A, PIPE_CRC_DONE_INTERRUPT_STATUS); |
| 3804 | i915_enable_pipestat(dev_priv, PIPE_B, PIPE_CRC_DONE_INTERRUPT_STATUS); |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 3805 | spin_unlock_irq(&dev_priv->irq_lock); |
Daniel Vetter | 379ef82 | 2013-10-16 22:55:56 +0200 | [diff] [blame] | 3806 | |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3807 | return 0; |
| 3808 | } |
| 3809 | |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3810 | /* |
| 3811 | * Returns true when a page flip has completed. |
| 3812 | */ |
| 3813 | static bool i8xx_handle_vblank(struct drm_device *dev, |
Ville Syrjälä | 1f1c2e2 | 2013-11-28 17:30:01 +0200 | [diff] [blame] | 3814 | int plane, int pipe, u32 iir) |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3815 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3816 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 1f1c2e2 | 2013-11-28 17:30:01 +0200 | [diff] [blame] | 3817 | u16 flip_pending = DISPLAY_PLANE_FLIP_PENDING(plane); |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3818 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 3819 | if (!intel_pipe_handle_vblank(dev, pipe)) |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3820 | return false; |
| 3821 | |
| 3822 | if ((iir & flip_pending) == 0) |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 3823 | goto check_page_flip; |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3824 | |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3825 | /* We detect FlipDone by looking for the change in PendingFlip from '1' |
| 3826 | * to '0' on the following vblank, i.e. IIR has the Pendingflip |
| 3827 | * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence |
| 3828 | * the flip is completed (no longer pending). Since this doesn't raise |
| 3829 | * an interrupt per se, we watch for the change at vblank. |
| 3830 | */ |
| 3831 | if (I915_READ16(ISR) & flip_pending) |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 3832 | goto check_page_flip; |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3833 | |
Ville Syrjälä | 7d47559 | 2014-12-17 23:08:03 +0200 | [diff] [blame] | 3834 | intel_prepare_page_flip(dev, plane); |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3835 | intel_finish_page_flip(dev, pipe); |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3836 | return true; |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 3837 | |
| 3838 | check_page_flip: |
| 3839 | intel_check_page_flip(dev, pipe); |
| 3840 | return false; |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3841 | } |
| 3842 | |
Daniel Vetter | ff1f525 | 2012-10-02 15:10:55 +0200 | [diff] [blame] | 3843 | static irqreturn_t i8xx_irq_handler(int irq, void *arg) |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3844 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 3845 | struct drm_device *dev = arg; |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3846 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3847 | u16 iir, new_iir; |
| 3848 | u32 pipe_stats[2]; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3849 | int pipe; |
| 3850 | u16 flip_mask = |
| 3851 | I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | |
| 3852 | I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT; |
| 3853 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 3854 | if (!intel_irqs_enabled(dev_priv)) |
| 3855 | return IRQ_NONE; |
| 3856 | |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3857 | iir = I915_READ16(IIR); |
| 3858 | if (iir == 0) |
| 3859 | return IRQ_NONE; |
| 3860 | |
| 3861 | while (iir & ~flip_mask) { |
| 3862 | /* Can't rely on pipestat interrupt bit in iir as it might |
| 3863 | * have been cleared after the pipestat interrupt was received. |
| 3864 | * It doesn't set the bit in iir again, but it still produces |
| 3865 | * interrupts (for non-MSI). |
| 3866 | */ |
Daniel Vetter | 222c7f5 | 2014-09-15 14:55:28 +0200 | [diff] [blame] | 3867 | spin_lock(&dev_priv->irq_lock); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3868 | if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT) |
Daniel Vetter | aaecdf6 | 2014-11-04 15:52:22 +0100 | [diff] [blame] | 3869 | DRM_DEBUG("Command parser error, iir 0x%08x\n", iir); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3870 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 3871 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3872 | int reg = PIPESTAT(pipe); |
| 3873 | pipe_stats[pipe] = I915_READ(reg); |
| 3874 | |
| 3875 | /* |
| 3876 | * Clear the PIPE*STAT regs before the IIR |
| 3877 | */ |
Ville Syrjälä | 2d9d2b0 | 2014-01-17 11:44:31 +0200 | [diff] [blame] | 3878 | if (pipe_stats[pipe] & 0x8000ffff) |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3879 | I915_WRITE(reg, pipe_stats[pipe]); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3880 | } |
Daniel Vetter | 222c7f5 | 2014-09-15 14:55:28 +0200 | [diff] [blame] | 3881 | spin_unlock(&dev_priv->irq_lock); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3882 | |
| 3883 | I915_WRITE16(IIR, iir & ~flip_mask); |
| 3884 | new_iir = I915_READ16(IIR); /* Flush posted writes */ |
| 3885 | |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3886 | if (iir & I915_USER_INTERRUPT) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 3887 | notify_ring(&dev_priv->ring[RCS]); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3888 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 3889 | for_each_pipe(dev_priv, pipe) { |
Ville Syrjälä | 1f1c2e2 | 2013-11-28 17:30:01 +0200 | [diff] [blame] | 3890 | int plane = pipe; |
Daniel Vetter | 3a77c4c | 2014-01-10 08:50:12 +0100 | [diff] [blame] | 3891 | if (HAS_FBC(dev)) |
Ville Syrjälä | 1f1c2e2 | 2013-11-28 17:30:01 +0200 | [diff] [blame] | 3892 | plane = !plane; |
| 3893 | |
Daniel Vetter | 4356d58 | 2013-10-16 22:55:55 +0200 | [diff] [blame] | 3894 | if (pipe_stats[pipe] & PIPE_VBLANK_INTERRUPT_STATUS && |
Ville Syrjälä | 1f1c2e2 | 2013-11-28 17:30:01 +0200 | [diff] [blame] | 3895 | i8xx_handle_vblank(dev, plane, pipe, iir)) |
| 3896 | flip_mask &= ~DISPLAY_PLANE_FLIP_PENDING(plane); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3897 | |
Daniel Vetter | 4356d58 | 2013-10-16 22:55:55 +0200 | [diff] [blame] | 3898 | if (pipe_stats[pipe] & PIPE_CRC_DONE_INTERRUPT_STATUS) |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 3899 | i9xx_pipe_crc_irq_handler(dev, pipe); |
Ville Syrjälä | 2d9d2b0 | 2014-01-17 11:44:31 +0200 | [diff] [blame] | 3900 | |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 3901 | if (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS) |
| 3902 | intel_cpu_fifo_underrun_irq_handler(dev_priv, |
| 3903 | pipe); |
Daniel Vetter | 4356d58 | 2013-10-16 22:55:55 +0200 | [diff] [blame] | 3904 | } |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3905 | |
| 3906 | iir = new_iir; |
| 3907 | } |
| 3908 | |
| 3909 | return IRQ_HANDLED; |
| 3910 | } |
| 3911 | |
| 3912 | static void i8xx_irq_uninstall(struct drm_device * dev) |
| 3913 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3914 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3915 | int pipe; |
| 3916 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 3917 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 3918 | /* Clear enable bits; then clear status bits */ |
| 3919 | I915_WRITE(PIPESTAT(pipe), 0); |
| 3920 | I915_WRITE(PIPESTAT(pipe), I915_READ(PIPESTAT(pipe))); |
| 3921 | } |
| 3922 | I915_WRITE16(IMR, 0xffff); |
| 3923 | I915_WRITE16(IER, 0x0); |
| 3924 | I915_WRITE16(IIR, I915_READ16(IIR)); |
| 3925 | } |
| 3926 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 3927 | static void i915_irq_preinstall(struct drm_device * dev) |
| 3928 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3929 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 3930 | int pipe; |
| 3931 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 3932 | if (I915_HAS_HOTPLUG(dev)) { |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 3933 | i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 3934 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
| 3935 | } |
| 3936 | |
Chris Wilson | 00d98eb | 2012-04-24 22:59:48 +0100 | [diff] [blame] | 3937 | I915_WRITE16(HWSTAM, 0xeffe); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 3938 | for_each_pipe(dev_priv, pipe) |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 3939 | I915_WRITE(PIPESTAT(pipe), 0); |
| 3940 | I915_WRITE(IMR, 0xffffffff); |
| 3941 | I915_WRITE(IER, 0x0); |
| 3942 | POSTING_READ(IER); |
| 3943 | } |
| 3944 | |
| 3945 | static int i915_irq_postinstall(struct drm_device *dev) |
| 3946 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3947 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 3948 | u32 enable_mask; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 3949 | |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 3950 | I915_WRITE(EMR, ~(I915_ERROR_PAGE_TABLE | I915_ERROR_MEMORY_REFRESH)); |
| 3951 | |
| 3952 | /* Unmask the interrupts that we always want on. */ |
| 3953 | dev_priv->irq_mask = |
| 3954 | ~(I915_ASLE_INTERRUPT | |
| 3955 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
| 3956 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
| 3957 | I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | |
Daniel Vetter | 37ef01a | 2015-04-01 13:43:46 +0200 | [diff] [blame] | 3958 | I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT); |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 3959 | |
| 3960 | enable_mask = |
| 3961 | I915_ASLE_INTERRUPT | |
| 3962 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
| 3963 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 3964 | I915_USER_INTERRUPT; |
| 3965 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 3966 | if (I915_HAS_HOTPLUG(dev)) { |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 3967 | i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0); |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 3968 | POSTING_READ(PORT_HOTPLUG_EN); |
| 3969 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 3970 | /* Enable in IER... */ |
| 3971 | enable_mask |= I915_DISPLAY_PORT_INTERRUPT; |
| 3972 | /* and unmask in IMR */ |
| 3973 | dev_priv->irq_mask &= ~I915_DISPLAY_PORT_INTERRUPT; |
| 3974 | } |
| 3975 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 3976 | I915_WRITE(IMR, dev_priv->irq_mask); |
| 3977 | I915_WRITE(IER, enable_mask); |
| 3978 | POSTING_READ(IER); |
| 3979 | |
Jani Nikula | f49e38d | 2013-04-29 13:02:54 +0300 | [diff] [blame] | 3980 | i915_enable_asle_pipestat(dev); |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 3981 | |
Daniel Vetter | 379ef82 | 2013-10-16 22:55:56 +0200 | [diff] [blame] | 3982 | /* Interrupt setup is already guaranteed to be single-threaded, this is |
| 3983 | * just to make the assert_spin_locked check happy. */ |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 3984 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 3985 | i915_enable_pipestat(dev_priv, PIPE_A, PIPE_CRC_DONE_INTERRUPT_STATUS); |
| 3986 | i915_enable_pipestat(dev_priv, PIPE_B, PIPE_CRC_DONE_INTERRUPT_STATUS); |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 3987 | spin_unlock_irq(&dev_priv->irq_lock); |
Daniel Vetter | 379ef82 | 2013-10-16 22:55:56 +0200 | [diff] [blame] | 3988 | |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 3989 | return 0; |
| 3990 | } |
| 3991 | |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3992 | /* |
| 3993 | * Returns true when a page flip has completed. |
| 3994 | */ |
| 3995 | static bool i915_handle_vblank(struct drm_device *dev, |
| 3996 | int plane, int pipe, u32 iir) |
| 3997 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 3998 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 3999 | u32 flip_pending = DISPLAY_PLANE_FLIP_PENDING(plane); |
| 4000 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 4001 | if (!intel_pipe_handle_vblank(dev, pipe)) |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 4002 | return false; |
| 4003 | |
| 4004 | if ((iir & flip_pending) == 0) |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 4005 | goto check_page_flip; |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 4006 | |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 4007 | /* We detect FlipDone by looking for the change in PendingFlip from '1' |
| 4008 | * to '0' on the following vblank, i.e. IIR has the Pendingflip |
| 4009 | * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence |
| 4010 | * the flip is completed (no longer pending). Since this doesn't raise |
| 4011 | * an interrupt per se, we watch for the change at vblank. |
| 4012 | */ |
| 4013 | if (I915_READ(ISR) & flip_pending) |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 4014 | goto check_page_flip; |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 4015 | |
Ville Syrjälä | 7d47559 | 2014-12-17 23:08:03 +0200 | [diff] [blame] | 4016 | intel_prepare_page_flip(dev, plane); |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 4017 | intel_finish_page_flip(dev, pipe); |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 4018 | return true; |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 4019 | |
| 4020 | check_page_flip: |
| 4021 | intel_check_page_flip(dev, pipe); |
| 4022 | return false; |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 4023 | } |
| 4024 | |
Daniel Vetter | ff1f525 | 2012-10-02 15:10:55 +0200 | [diff] [blame] | 4025 | static irqreturn_t i915_irq_handler(int irq, void *arg) |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4026 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 4027 | struct drm_device *dev = arg; |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 4028 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 8291ee9 | 2012-04-24 22:59:47 +0100 | [diff] [blame] | 4029 | u32 iir, new_iir, pipe_stats[I915_MAX_PIPES]; |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4030 | u32 flip_mask = |
| 4031 | I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | |
| 4032 | I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT; |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4033 | int pipe, ret = IRQ_NONE; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4034 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 4035 | if (!intel_irqs_enabled(dev_priv)) |
| 4036 | return IRQ_NONE; |
| 4037 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4038 | iir = I915_READ(IIR); |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4039 | do { |
| 4040 | bool irq_received = (iir & ~flip_mask) != 0; |
Chris Wilson | 8291ee9 | 2012-04-24 22:59:47 +0100 | [diff] [blame] | 4041 | bool blc_event = false; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4042 | |
| 4043 | /* Can't rely on pipestat interrupt bit in iir as it might |
| 4044 | * have been cleared after the pipestat interrupt was received. |
| 4045 | * It doesn't set the bit in iir again, but it still produces |
| 4046 | * interrupts (for non-MSI). |
| 4047 | */ |
Daniel Vetter | 222c7f5 | 2014-09-15 14:55:28 +0200 | [diff] [blame] | 4048 | spin_lock(&dev_priv->irq_lock); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4049 | if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT) |
Daniel Vetter | aaecdf6 | 2014-11-04 15:52:22 +0100 | [diff] [blame] | 4050 | DRM_DEBUG("Command parser error, iir 0x%08x\n", iir); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4051 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 4052 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4053 | int reg = PIPESTAT(pipe); |
| 4054 | pipe_stats[pipe] = I915_READ(reg); |
| 4055 | |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4056 | /* Clear the PIPE*STAT regs before the IIR */ |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4057 | if (pipe_stats[pipe] & 0x8000ffff) { |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4058 | I915_WRITE(reg, pipe_stats[pipe]); |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4059 | irq_received = true; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4060 | } |
| 4061 | } |
Daniel Vetter | 222c7f5 | 2014-09-15 14:55:28 +0200 | [diff] [blame] | 4062 | spin_unlock(&dev_priv->irq_lock); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4063 | |
| 4064 | if (!irq_received) |
| 4065 | break; |
| 4066 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4067 | /* Consume port. Then clear IIR or we'll miss events */ |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 4068 | if (I915_HAS_HOTPLUG(dev) && |
| 4069 | iir & I915_DISPLAY_PORT_INTERRUPT) |
| 4070 | i9xx_hpd_irq_handler(dev); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4071 | |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4072 | I915_WRITE(IIR, iir & ~flip_mask); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4073 | new_iir = I915_READ(IIR); /* Flush posted writes */ |
| 4074 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4075 | if (iir & I915_USER_INTERRUPT) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 4076 | notify_ring(&dev_priv->ring[RCS]); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4077 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 4078 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4079 | int plane = pipe; |
Daniel Vetter | 3a77c4c | 2014-01-10 08:50:12 +0100 | [diff] [blame] | 4080 | if (HAS_FBC(dev)) |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4081 | plane = !plane; |
Ville Syrjälä | 5e2032d | 2013-02-19 15:16:38 +0200 | [diff] [blame] | 4082 | |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 4083 | if (pipe_stats[pipe] & PIPE_VBLANK_INTERRUPT_STATUS && |
| 4084 | i915_handle_vblank(dev, plane, pipe, iir)) |
| 4085 | flip_mask &= ~DISPLAY_PLANE_FLIP_PENDING(plane); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4086 | |
| 4087 | if (pipe_stats[pipe] & PIPE_LEGACY_BLC_EVENT_STATUS) |
| 4088 | blc_event = true; |
Daniel Vetter | 4356d58 | 2013-10-16 22:55:55 +0200 | [diff] [blame] | 4089 | |
| 4090 | if (pipe_stats[pipe] & PIPE_CRC_DONE_INTERRUPT_STATUS) |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 4091 | i9xx_pipe_crc_irq_handler(dev, pipe); |
Ville Syrjälä | 2d9d2b0 | 2014-01-17 11:44:31 +0200 | [diff] [blame] | 4092 | |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 4093 | if (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS) |
| 4094 | intel_cpu_fifo_underrun_irq_handler(dev_priv, |
| 4095 | pipe); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4096 | } |
| 4097 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4098 | if (blc_event || (iir & I915_ASLE_INTERRUPT)) |
| 4099 | intel_opregion_asle_intr(dev); |
| 4100 | |
| 4101 | /* With MSI, interrupts are only generated when iir |
| 4102 | * transitions from zero to nonzero. If another bit got |
| 4103 | * set while we were handling the existing iir bits, then |
| 4104 | * we would never get another interrupt. |
| 4105 | * |
| 4106 | * This is fine on non-MSI as well, as if we hit this path |
| 4107 | * we avoid exiting the interrupt handler only to generate |
| 4108 | * another one. |
| 4109 | * |
| 4110 | * Note that for MSI this could cause a stray interrupt report |
| 4111 | * if an interrupt landed in the time between writing IIR and |
| 4112 | * the posting read. This should be rare enough to never |
| 4113 | * trigger the 99% of 100,000 interrupts test for disabling |
| 4114 | * stray interrupts. |
| 4115 | */ |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4116 | ret = IRQ_HANDLED; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4117 | iir = new_iir; |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4118 | } while (iir & ~flip_mask); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4119 | |
| 4120 | return ret; |
| 4121 | } |
| 4122 | |
| 4123 | static void i915_irq_uninstall(struct drm_device * dev) |
| 4124 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 4125 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4126 | int pipe; |
| 4127 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4128 | if (I915_HAS_HOTPLUG(dev)) { |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 4129 | i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4130 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
| 4131 | } |
| 4132 | |
Chris Wilson | 00d98eb | 2012-04-24 22:59:48 +0100 | [diff] [blame] | 4133 | I915_WRITE16(HWSTAM, 0xffff); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 4134 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | 55b3975 | 2012-04-24 22:59:49 +0100 | [diff] [blame] | 4135 | /* Clear enable bits; then clear status bits */ |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4136 | I915_WRITE(PIPESTAT(pipe), 0); |
Chris Wilson | 55b3975 | 2012-04-24 22:59:49 +0100 | [diff] [blame] | 4137 | I915_WRITE(PIPESTAT(pipe), I915_READ(PIPESTAT(pipe))); |
| 4138 | } |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4139 | I915_WRITE(IMR, 0xffffffff); |
| 4140 | I915_WRITE(IER, 0x0); |
| 4141 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4142 | I915_WRITE(IIR, I915_READ(IIR)); |
| 4143 | } |
| 4144 | |
| 4145 | static void i965_irq_preinstall(struct drm_device * dev) |
| 4146 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 4147 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4148 | int pipe; |
| 4149 | |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 4150 | i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0); |
Chris Wilson | adca473 | 2012-05-11 18:01:31 +0100 | [diff] [blame] | 4151 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4152 | |
| 4153 | I915_WRITE(HWSTAM, 0xeffe); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 4154 | for_each_pipe(dev_priv, pipe) |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4155 | I915_WRITE(PIPESTAT(pipe), 0); |
| 4156 | I915_WRITE(IMR, 0xffffffff); |
| 4157 | I915_WRITE(IER, 0x0); |
| 4158 | POSTING_READ(IER); |
| 4159 | } |
| 4160 | |
| 4161 | static int i965_irq_postinstall(struct drm_device *dev) |
| 4162 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 4163 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | bbba0a9 | 2012-04-24 22:59:51 +0100 | [diff] [blame] | 4164 | u32 enable_mask; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4165 | u32 error_mask; |
| 4166 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4167 | /* Unmask the interrupts that we always want on. */ |
Chris Wilson | bbba0a9 | 2012-04-24 22:59:51 +0100 | [diff] [blame] | 4168 | dev_priv->irq_mask = ~(I915_ASLE_INTERRUPT | |
Chris Wilson | adca473 | 2012-05-11 18:01:31 +0100 | [diff] [blame] | 4169 | I915_DISPLAY_PORT_INTERRUPT | |
Chris Wilson | bbba0a9 | 2012-04-24 22:59:51 +0100 | [diff] [blame] | 4170 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
| 4171 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
| 4172 | I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | |
| 4173 | I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT | |
| 4174 | I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT); |
| 4175 | |
| 4176 | enable_mask = ~dev_priv->irq_mask; |
Ville Syrjälä | 21ad833 | 2013-02-19 15:16:39 +0200 | [diff] [blame] | 4177 | enable_mask &= ~(I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | |
| 4178 | I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT); |
Chris Wilson | bbba0a9 | 2012-04-24 22:59:51 +0100 | [diff] [blame] | 4179 | enable_mask |= I915_USER_INTERRUPT; |
| 4180 | |
| 4181 | if (IS_G4X(dev)) |
| 4182 | enable_mask |= I915_BSD_USER_INTERRUPT; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4183 | |
Daniel Vetter | b79480b | 2013-06-27 17:52:10 +0200 | [diff] [blame] | 4184 | /* Interrupt setup is already guaranteed to be single-threaded, this is |
| 4185 | * just to make the assert_spin_locked check happy. */ |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 4186 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 4187 | i915_enable_pipestat(dev_priv, PIPE_A, PIPE_GMBUS_INTERRUPT_STATUS); |
| 4188 | i915_enable_pipestat(dev_priv, PIPE_A, PIPE_CRC_DONE_INTERRUPT_STATUS); |
| 4189 | i915_enable_pipestat(dev_priv, PIPE_B, PIPE_CRC_DONE_INTERRUPT_STATUS); |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 4190 | spin_unlock_irq(&dev_priv->irq_lock); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4191 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4192 | /* |
| 4193 | * Enable some error detection, note the instruction error mask |
| 4194 | * bit is reserved, so we leave it masked. |
| 4195 | */ |
| 4196 | if (IS_G4X(dev)) { |
| 4197 | error_mask = ~(GM45_ERROR_PAGE_TABLE | |
| 4198 | GM45_ERROR_MEM_PRIV | |
| 4199 | GM45_ERROR_CP_PRIV | |
| 4200 | I915_ERROR_MEMORY_REFRESH); |
| 4201 | } else { |
| 4202 | error_mask = ~(I915_ERROR_PAGE_TABLE | |
| 4203 | I915_ERROR_MEMORY_REFRESH); |
| 4204 | } |
| 4205 | I915_WRITE(EMR, error_mask); |
| 4206 | |
| 4207 | I915_WRITE(IMR, dev_priv->irq_mask); |
| 4208 | I915_WRITE(IER, enable_mask); |
| 4209 | POSTING_READ(IER); |
| 4210 | |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 4211 | i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0); |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4212 | POSTING_READ(PORT_HOTPLUG_EN); |
| 4213 | |
Jani Nikula | f49e38d | 2013-04-29 13:02:54 +0300 | [diff] [blame] | 4214 | i915_enable_asle_pipestat(dev); |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4215 | |
| 4216 | return 0; |
| 4217 | } |
| 4218 | |
Egbert Eich | bac56d5 | 2013-02-25 12:06:51 -0500 | [diff] [blame] | 4219 | static void i915_hpd_irq_setup(struct drm_device *dev) |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4220 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 4221 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4222 | u32 hotplug_en; |
| 4223 | |
Daniel Vetter | b5ea2d5 | 2013-06-27 17:52:15 +0200 | [diff] [blame] | 4224 | assert_spin_locked(&dev_priv->irq_lock); |
| 4225 | |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4226 | /* Note HDMI and DP share hotplug bits */ |
| 4227 | /* enable bits are the same for all generations */ |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 4228 | hotplug_en = intel_hpd_enabled_irqs(dev, hpd_mask_i915); |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4229 | /* Programming the CRT detection parameters tends |
| 4230 | to generate a spurious hotplug event about three |
| 4231 | seconds later. So just do it once. |
| 4232 | */ |
| 4233 | if (IS_G4X(dev)) |
| 4234 | hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64; |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4235 | hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4236 | |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4237 | /* Ignore TV since it's buggy */ |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 4238 | i915_hotplug_interrupt_update_locked(dev_priv, |
| 4239 | (HOTPLUG_INT_EN_MASK |
| 4240 | | CRT_HOTPLUG_VOLTAGE_COMPARE_MASK), |
| 4241 | hotplug_en); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4242 | } |
| 4243 | |
Daniel Vetter | ff1f525 | 2012-10-02 15:10:55 +0200 | [diff] [blame] | 4244 | static irqreturn_t i965_irq_handler(int irq, void *arg) |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4245 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 4246 | struct drm_device *dev = arg; |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 4247 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4248 | u32 iir, new_iir; |
| 4249 | u32 pipe_stats[I915_MAX_PIPES]; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4250 | int ret = IRQ_NONE, pipe; |
Ville Syrjälä | 21ad833 | 2013-02-19 15:16:39 +0200 | [diff] [blame] | 4251 | u32 flip_mask = |
| 4252 | I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | |
| 4253 | I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4254 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 4255 | if (!intel_irqs_enabled(dev_priv)) |
| 4256 | return IRQ_NONE; |
| 4257 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4258 | iir = I915_READ(IIR); |
| 4259 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4260 | for (;;) { |
Ville Syrjälä | 501e01d | 2014-01-17 11:35:15 +0200 | [diff] [blame] | 4261 | bool irq_received = (iir & ~flip_mask) != 0; |
Chris Wilson | 2c8ba29 | 2012-04-24 22:59:46 +0100 | [diff] [blame] | 4262 | bool blc_event = false; |
| 4263 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4264 | /* Can't rely on pipestat interrupt bit in iir as it might |
| 4265 | * have been cleared after the pipestat interrupt was received. |
| 4266 | * It doesn't set the bit in iir again, but it still produces |
| 4267 | * interrupts (for non-MSI). |
| 4268 | */ |
Daniel Vetter | 222c7f5 | 2014-09-15 14:55:28 +0200 | [diff] [blame] | 4269 | spin_lock(&dev_priv->irq_lock); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4270 | if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT) |
Daniel Vetter | aaecdf6 | 2014-11-04 15:52:22 +0100 | [diff] [blame] | 4271 | DRM_DEBUG("Command parser error, iir 0x%08x\n", iir); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4272 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 4273 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4274 | int reg = PIPESTAT(pipe); |
| 4275 | pipe_stats[pipe] = I915_READ(reg); |
| 4276 | |
| 4277 | /* |
| 4278 | * Clear the PIPE*STAT regs before the IIR |
| 4279 | */ |
| 4280 | if (pipe_stats[pipe] & 0x8000ffff) { |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4281 | I915_WRITE(reg, pipe_stats[pipe]); |
Ville Syrjälä | 501e01d | 2014-01-17 11:35:15 +0200 | [diff] [blame] | 4282 | irq_received = true; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4283 | } |
| 4284 | } |
Daniel Vetter | 222c7f5 | 2014-09-15 14:55:28 +0200 | [diff] [blame] | 4285 | spin_unlock(&dev_priv->irq_lock); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4286 | |
| 4287 | if (!irq_received) |
| 4288 | break; |
| 4289 | |
| 4290 | ret = IRQ_HANDLED; |
| 4291 | |
| 4292 | /* Consume port. Then clear IIR or we'll miss events */ |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 4293 | if (iir & I915_DISPLAY_PORT_INTERRUPT) |
| 4294 | i9xx_hpd_irq_handler(dev); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4295 | |
Ville Syrjälä | 21ad833 | 2013-02-19 15:16:39 +0200 | [diff] [blame] | 4296 | I915_WRITE(IIR, iir & ~flip_mask); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4297 | new_iir = I915_READ(IIR); /* Flush posted writes */ |
| 4298 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4299 | if (iir & I915_USER_INTERRUPT) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 4300 | notify_ring(&dev_priv->ring[RCS]); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4301 | if (iir & I915_BSD_USER_INTERRUPT) |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 4302 | notify_ring(&dev_priv->ring[VCS]); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4303 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 4304 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | 2c8ba29 | 2012-04-24 22:59:46 +0100 | [diff] [blame] | 4305 | if (pipe_stats[pipe] & PIPE_START_VBLANK_INTERRUPT_STATUS && |
Ville Syrjälä | 90a72f8 | 2013-02-19 23:16:44 +0200 | [diff] [blame] | 4306 | i915_handle_vblank(dev, pipe, pipe, iir)) |
| 4307 | flip_mask &= ~DISPLAY_PLANE_FLIP_PENDING(pipe); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4308 | |
| 4309 | if (pipe_stats[pipe] & PIPE_LEGACY_BLC_EVENT_STATUS) |
| 4310 | blc_event = true; |
Daniel Vetter | 4356d58 | 2013-10-16 22:55:55 +0200 | [diff] [blame] | 4311 | |
| 4312 | if (pipe_stats[pipe] & PIPE_CRC_DONE_INTERRUPT_STATUS) |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 4313 | i9xx_pipe_crc_irq_handler(dev, pipe); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4314 | |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 4315 | if (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS) |
| 4316 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
Ville Syrjälä | 2d9d2b0 | 2014-01-17 11:44:31 +0200 | [diff] [blame] | 4317 | } |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4318 | |
| 4319 | if (blc_event || (iir & I915_ASLE_INTERRUPT)) |
| 4320 | intel_opregion_asle_intr(dev); |
| 4321 | |
Daniel Vetter | 515ac2b | 2012-12-01 13:53:44 +0100 | [diff] [blame] | 4322 | if (pipe_stats[0] & PIPE_GMBUS_INTERRUPT_STATUS) |
| 4323 | gmbus_irq_handler(dev); |
| 4324 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4325 | /* With MSI, interrupts are only generated when iir |
| 4326 | * transitions from zero to nonzero. If another bit got |
| 4327 | * set while we were handling the existing iir bits, then |
| 4328 | * we would never get another interrupt. |
| 4329 | * |
| 4330 | * This is fine on non-MSI as well, as if we hit this path |
| 4331 | * we avoid exiting the interrupt handler only to generate |
| 4332 | * another one. |
| 4333 | * |
| 4334 | * Note that for MSI this could cause a stray interrupt report |
| 4335 | * if an interrupt landed in the time between writing IIR and |
| 4336 | * the posting read. This should be rare enough to never |
| 4337 | * trigger the 99% of 100,000 interrupts test for disabling |
| 4338 | * stray interrupts. |
| 4339 | */ |
| 4340 | iir = new_iir; |
| 4341 | } |
| 4342 | |
| 4343 | return ret; |
| 4344 | } |
| 4345 | |
| 4346 | static void i965_irq_uninstall(struct drm_device * dev) |
| 4347 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 4348 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4349 | int pipe; |
| 4350 | |
| 4351 | if (!dev_priv) |
| 4352 | return; |
| 4353 | |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 4354 | i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0); |
Chris Wilson | adca473 | 2012-05-11 18:01:31 +0100 | [diff] [blame] | 4355 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4356 | |
| 4357 | I915_WRITE(HWSTAM, 0xffffffff); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 4358 | for_each_pipe(dev_priv, pipe) |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4359 | I915_WRITE(PIPESTAT(pipe), 0); |
| 4360 | I915_WRITE(IMR, 0xffffffff); |
| 4361 | I915_WRITE(IER, 0x0); |
| 4362 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 4363 | for_each_pipe(dev_priv, pipe) |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4364 | I915_WRITE(PIPESTAT(pipe), |
| 4365 | I915_READ(PIPESTAT(pipe)) & 0x8000ffff); |
| 4366 | I915_WRITE(IIR, I915_READ(IIR)); |
| 4367 | } |
| 4368 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4369 | /** |
| 4370 | * intel_irq_init - initializes irq support |
| 4371 | * @dev_priv: i915 device instance |
| 4372 | * |
| 4373 | * This function initializes all the irq support including work items, timers |
| 4374 | * and all the vtables. It does not setup the interrupt itself though. |
| 4375 | */ |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4376 | void intel_irq_init(struct drm_i915_private *dev_priv) |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4377 | { |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4378 | struct drm_device *dev = dev_priv->dev; |
Chris Wilson | 8b2e326 | 2012-04-24 22:59:41 +0100 | [diff] [blame] | 4379 | |
Jani Nikula | 77913b3 | 2015-06-18 13:06:16 +0300 | [diff] [blame] | 4380 | intel_hpd_init_work(dev_priv); |
| 4381 | |
Daniel Vetter | c6a828d | 2012-08-08 23:35:35 +0200 | [diff] [blame] | 4382 | INIT_WORK(&dev_priv->rps.work, gen6_pm_rps_work); |
Daniel Vetter | a4da4fa | 2012-11-02 19:55:07 +0100 | [diff] [blame] | 4383 | INIT_WORK(&dev_priv->l3_parity.error_work, ivybridge_parity_work); |
Chris Wilson | 8b2e326 | 2012-04-24 22:59:41 +0100 | [diff] [blame] | 4384 | |
Deepak S | a6706b4 | 2014-03-15 20:23:22 +0530 | [diff] [blame] | 4385 | /* Let's track the enabled rps events */ |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4386 | if (IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | 6c65a58 | 2014-08-29 14:14:07 +0300 | [diff] [blame] | 4387 | /* WaGsvRC0ResidencyMethod:vlv */ |
Chris Wilson | 6f4b12f8 | 2015-03-18 09:48:23 +0000 | [diff] [blame] | 4388 | dev_priv->pm_rps_events = GEN6_PM_RP_DOWN_EI_EXPIRED | GEN6_PM_RP_UP_EI_EXPIRED; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 4389 | else |
| 4390 | dev_priv->pm_rps_events = GEN6_PM_RPS_EVENTS; |
Deepak S | a6706b4 | 2014-03-15 20:23:22 +0530 | [diff] [blame] | 4391 | |
Chris Wilson | 737b150 | 2015-01-26 18:03:03 +0200 | [diff] [blame] | 4392 | INIT_DELAYED_WORK(&dev_priv->gpu_error.hangcheck_work, |
| 4393 | i915_hangcheck_elapsed); |
Daniel Vetter | 61bac78 | 2012-12-01 21:03:21 +0100 | [diff] [blame] | 4394 | |
Tomas Janousek | 97a19a2 | 2012-12-08 13:48:13 +0100 | [diff] [blame] | 4395 | pm_qos_add_request(&dev_priv->pm_qos, PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 4396 | |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4397 | if (IS_GEN2(dev_priv)) { |
Ville Syrjälä | 4cdb83e | 2013-10-11 21:52:44 +0300 | [diff] [blame] | 4398 | dev->max_vblank_count = 0; |
| 4399 | dev->driver->get_vblank_counter = i8xx_get_vblank_counter; |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4400 | } else if (IS_G4X(dev_priv) || INTEL_INFO(dev_priv)->gen >= 5) { |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4401 | dev->max_vblank_count = 0xffffffff; /* full 32 bit counter */ |
Ville Syrjälä | fd8f507 | 2015-09-18 20:03:42 +0300 | [diff] [blame] | 4402 | dev->driver->get_vblank_counter = g4x_get_vblank_counter; |
Ville Syrjälä | 391f75e | 2013-09-25 19:55:26 +0300 | [diff] [blame] | 4403 | } else { |
| 4404 | dev->driver->get_vblank_counter = i915_get_vblank_counter; |
| 4405 | dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */ |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4406 | } |
| 4407 | |
Ville Syrjälä | 21da270 | 2014-08-06 14:49:55 +0300 | [diff] [blame] | 4408 | /* |
| 4409 | * Opt out of the vblank disable timer on everything except gen2. |
| 4410 | * Gen2 doesn't have a hardware frame counter and so depends on |
| 4411 | * vblank interrupts to produce sane vblank seuquence numbers. |
| 4412 | */ |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4413 | if (!IS_GEN2(dev_priv)) |
Ville Syrjälä | 21da270 | 2014-08-06 14:49:55 +0300 | [diff] [blame] | 4414 | dev->vblank_disable_immediate = true; |
| 4415 | |
Daniel Vetter | f3a5c3f | 2015-02-13 21:03:44 +0100 | [diff] [blame] | 4416 | dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp; |
| 4417 | dev->driver->get_scanout_position = i915_get_crtc_scanoutpos; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4418 | |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4419 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 4420 | dev->driver->irq_handler = cherryview_irq_handler; |
| 4421 | dev->driver->irq_preinstall = cherryview_irq_preinstall; |
| 4422 | dev->driver->irq_postinstall = cherryview_irq_postinstall; |
| 4423 | dev->driver->irq_uninstall = cherryview_irq_uninstall; |
| 4424 | dev->driver->enable_vblank = valleyview_enable_vblank; |
| 4425 | dev->driver->disable_vblank = valleyview_disable_vblank; |
| 4426 | dev_priv->display.hpd_irq_setup = i915_hpd_irq_setup; |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4427 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 4428 | dev->driver->irq_handler = valleyview_irq_handler; |
| 4429 | dev->driver->irq_preinstall = valleyview_irq_preinstall; |
| 4430 | dev->driver->irq_postinstall = valleyview_irq_postinstall; |
| 4431 | dev->driver->irq_uninstall = valleyview_irq_uninstall; |
| 4432 | dev->driver->enable_vblank = valleyview_enable_vblank; |
| 4433 | dev->driver->disable_vblank = valleyview_disable_vblank; |
Egbert Eich | fa00abe | 2013-02-25 12:06:48 -0500 | [diff] [blame] | 4434 | dev_priv->display.hpd_irq_setup = i915_hpd_irq_setup; |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4435 | } else if (INTEL_INFO(dev_priv)->gen >= 8) { |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4436 | dev->driver->irq_handler = gen8_irq_handler; |
Daniel Vetter | 723761b | 2014-05-22 17:56:34 +0200 | [diff] [blame] | 4437 | dev->driver->irq_preinstall = gen8_irq_reset; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4438 | dev->driver->irq_postinstall = gen8_irq_postinstall; |
| 4439 | dev->driver->irq_uninstall = gen8_irq_uninstall; |
| 4440 | dev->driver->enable_vblank = gen8_enable_vblank; |
| 4441 | dev->driver->disable_vblank = gen8_disable_vblank; |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 4442 | if (IS_BROXTON(dev)) |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 4443 | dev_priv->display.hpd_irq_setup = bxt_hpd_irq_setup; |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 4444 | else if (HAS_PCH_SPT(dev)) |
| 4445 | dev_priv->display.hpd_irq_setup = spt_hpd_irq_setup; |
| 4446 | else |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 4447 | dev_priv->display.hpd_irq_setup = ilk_hpd_irq_setup; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4448 | } else if (HAS_PCH_SPLIT(dev)) { |
| 4449 | dev->driver->irq_handler = ironlake_irq_handler; |
Daniel Vetter | 723761b | 2014-05-22 17:56:34 +0200 | [diff] [blame] | 4450 | dev->driver->irq_preinstall = ironlake_irq_reset; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4451 | dev->driver->irq_postinstall = ironlake_irq_postinstall; |
| 4452 | dev->driver->irq_uninstall = ironlake_irq_uninstall; |
| 4453 | dev->driver->enable_vblank = ironlake_enable_vblank; |
| 4454 | dev->driver->disable_vblank = ironlake_disable_vblank; |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 4455 | dev_priv->display.hpd_irq_setup = ilk_hpd_irq_setup; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4456 | } else { |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4457 | if (INTEL_INFO(dev_priv)->gen == 2) { |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4458 | dev->driver->irq_preinstall = i8xx_irq_preinstall; |
| 4459 | dev->driver->irq_postinstall = i8xx_irq_postinstall; |
| 4460 | dev->driver->irq_handler = i8xx_irq_handler; |
| 4461 | dev->driver->irq_uninstall = i8xx_irq_uninstall; |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4462 | } else if (INTEL_INFO(dev_priv)->gen == 3) { |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4463 | dev->driver->irq_preinstall = i915_irq_preinstall; |
| 4464 | dev->driver->irq_postinstall = i915_irq_postinstall; |
| 4465 | dev->driver->irq_uninstall = i915_irq_uninstall; |
| 4466 | dev->driver->irq_handler = i915_irq_handler; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4467 | } else { |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4468 | dev->driver->irq_preinstall = i965_irq_preinstall; |
| 4469 | dev->driver->irq_postinstall = i965_irq_postinstall; |
| 4470 | dev->driver->irq_uninstall = i965_irq_uninstall; |
| 4471 | dev->driver->irq_handler = i965_irq_handler; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4472 | } |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4473 | if (I915_HAS_HOTPLUG(dev_priv)) |
| 4474 | dev_priv->display.hpd_irq_setup = i915_hpd_irq_setup; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4475 | dev->driver->enable_vblank = i915_enable_vblank; |
| 4476 | dev->driver->disable_vblank = i915_disable_vblank; |
| 4477 | } |
| 4478 | } |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4479 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4480 | /** |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4481 | * intel_irq_install - enables the hardware interrupt |
| 4482 | * @dev_priv: i915 device instance |
| 4483 | * |
| 4484 | * This function enables the hardware interrupt handling, but leaves the hotplug |
| 4485 | * handling still disabled. It is called after intel_irq_init(). |
| 4486 | * |
| 4487 | * In the driver load and resume code we need working interrupts in a few places |
| 4488 | * but don't want to deal with the hassle of concurrent probe and hotplug |
| 4489 | * workers. Hence the split into this two-stage approach. |
| 4490 | */ |
Daniel Vetter | 2aeb7d3 | 2014-09-30 10:56:43 +0200 | [diff] [blame] | 4491 | int intel_irq_install(struct drm_i915_private *dev_priv) |
| 4492 | { |
| 4493 | /* |
| 4494 | * We enable some interrupt sources in our postinstall hooks, so mark |
| 4495 | * interrupts as enabled _before_ actually enabling them to avoid |
| 4496 | * special cases in our ordering checks. |
| 4497 | */ |
| 4498 | dev_priv->pm.irqs_enabled = true; |
| 4499 | |
| 4500 | return drm_irq_install(dev_priv->dev, dev_priv->dev->pdev->irq); |
| 4501 | } |
| 4502 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4503 | /** |
| 4504 | * intel_irq_uninstall - finilizes all irq handling |
| 4505 | * @dev_priv: i915 device instance |
| 4506 | * |
| 4507 | * This stops interrupt and hotplug handling and unregisters and frees all |
| 4508 | * resources acquired in the init functions. |
| 4509 | */ |
Daniel Vetter | 2aeb7d3 | 2014-09-30 10:56:43 +0200 | [diff] [blame] | 4510 | void intel_irq_uninstall(struct drm_i915_private *dev_priv) |
| 4511 | { |
| 4512 | drm_irq_uninstall(dev_priv->dev); |
| 4513 | intel_hpd_cancel_work(dev_priv); |
| 4514 | dev_priv->pm.irqs_enabled = false; |
| 4515 | } |
| 4516 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4517 | /** |
| 4518 | * intel_runtime_pm_disable_interrupts - runtime interrupt disabling |
| 4519 | * @dev_priv: i915 device instance |
| 4520 | * |
| 4521 | * This function is used to disable interrupts at runtime, both in the runtime |
| 4522 | * pm and the system suspend/resume code. |
| 4523 | */ |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4524 | void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv) |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 4525 | { |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4526 | dev_priv->dev->driver->irq_uninstall(dev_priv->dev); |
Daniel Vetter | 2aeb7d3 | 2014-09-30 10:56:43 +0200 | [diff] [blame] | 4527 | dev_priv->pm.irqs_enabled = false; |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 4528 | synchronize_irq(dev_priv->dev->irq); |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 4529 | } |
| 4530 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4531 | /** |
| 4532 | * intel_runtime_pm_enable_interrupts - runtime interrupt enabling |
| 4533 | * @dev_priv: i915 device instance |
| 4534 | * |
| 4535 | * This function is used to enable interrupts at runtime, both in the runtime |
| 4536 | * pm and the system suspend/resume code. |
| 4537 | */ |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4538 | void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv) |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 4539 | { |
Daniel Vetter | 2aeb7d3 | 2014-09-30 10:56:43 +0200 | [diff] [blame] | 4540 | dev_priv->pm.irqs_enabled = true; |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4541 | dev_priv->dev->driver->irq_preinstall(dev_priv->dev); |
| 4542 | dev_priv->dev->driver->irq_postinstall(dev_priv->dev); |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 4543 | } |