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