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