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