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