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 | |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 31 | #include <linux/circ_buf.h> |
Jani Nikula | 55367a2 | 2019-04-05 14:00:09 +0300 | [diff] [blame] | 32 | #include <linux/cpuidle.h> |
| 33 | #include <linux/slab.h> |
| 34 | #include <linux/sysrq.h> |
| 35 | |
Daniel Vetter | fcd70cd | 2019-01-17 22:03:34 +0100 | [diff] [blame] | 36 | #include <drm/drm_drv.h> |
Jani Nikula | 55367a2 | 2019-04-05 14:00:09 +0300 | [diff] [blame] | 37 | #include <drm/drm_irq.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 38 | #include <drm/i915_drm.h> |
Jani Nikula | 55367a2 | 2019-04-05 14:00:09 +0300 | [diff] [blame] | 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include "i915_drv.h" |
Chris Wilson | 1c5d22f | 2009-08-25 11:15:50 +0100 | [diff] [blame] | 41 | #include "i915_trace.h" |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 42 | #include "intel_drv.h" |
Jani Nikula | 55367a2 | 2019-04-05 14:00:09 +0300 | [diff] [blame] | 43 | #include "intel_psr.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 45 | /** |
| 46 | * DOC: interrupt handling |
| 47 | * |
| 48 | * These functions provide the basic support for enabling and disabling the |
| 49 | * interrupt handling support. There's a lot more functionality in i915_irq.c |
| 50 | * and related files, but that will be described in separate chapters. |
| 51 | */ |
| 52 | |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 53 | static const u32 hpd_ilk[HPD_NUM_PINS] = { |
| 54 | [HPD_PORT_A] = DE_DP_A_HOTPLUG, |
| 55 | }; |
| 56 | |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 57 | static const u32 hpd_ivb[HPD_NUM_PINS] = { |
| 58 | [HPD_PORT_A] = DE_DP_A_HOTPLUG_IVB, |
| 59 | }; |
| 60 | |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 61 | static const u32 hpd_bdw[HPD_NUM_PINS] = { |
| 62 | [HPD_PORT_A] = GEN8_PORT_DP_A_HOTPLUG, |
| 63 | }; |
| 64 | |
Ville Syrjälä | 7c7e10d | 2015-01-09 14:21:12 +0200 | [diff] [blame] | 65 | static const u32 hpd_ibx[HPD_NUM_PINS] = { |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 66 | [HPD_CRT] = SDE_CRT_HOTPLUG, |
| 67 | [HPD_SDVO_B] = SDE_SDVOB_HOTPLUG, |
| 68 | [HPD_PORT_B] = SDE_PORTB_HOTPLUG, |
| 69 | [HPD_PORT_C] = SDE_PORTC_HOTPLUG, |
| 70 | [HPD_PORT_D] = SDE_PORTD_HOTPLUG |
| 71 | }; |
| 72 | |
Ville Syrjälä | 7c7e10d | 2015-01-09 14:21:12 +0200 | [diff] [blame] | 73 | static const u32 hpd_cpt[HPD_NUM_PINS] = { |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 74 | [HPD_CRT] = SDE_CRT_HOTPLUG_CPT, |
Daniel Vetter | 73c352a | 2013-03-26 22:38:43 +0100 | [diff] [blame] | 75 | [HPD_SDVO_B] = SDE_SDVOB_HOTPLUG_CPT, |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 76 | [HPD_PORT_B] = SDE_PORTB_HOTPLUG_CPT, |
| 77 | [HPD_PORT_C] = SDE_PORTC_HOTPLUG_CPT, |
| 78 | [HPD_PORT_D] = SDE_PORTD_HOTPLUG_CPT |
| 79 | }; |
| 80 | |
Xiong Zhang | 26951ca | 2015-08-17 15:55:50 +0800 | [diff] [blame] | 81 | static const u32 hpd_spt[HPD_NUM_PINS] = { |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 82 | [HPD_PORT_A] = SDE_PORTA_HOTPLUG_SPT, |
Xiong Zhang | 26951ca | 2015-08-17 15:55:50 +0800 | [diff] [blame] | 83 | [HPD_PORT_B] = SDE_PORTB_HOTPLUG_CPT, |
| 84 | [HPD_PORT_C] = SDE_PORTC_HOTPLUG_CPT, |
| 85 | [HPD_PORT_D] = SDE_PORTD_HOTPLUG_CPT, |
| 86 | [HPD_PORT_E] = SDE_PORTE_HOTPLUG_SPT |
| 87 | }; |
| 88 | |
Ville Syrjälä | 7c7e10d | 2015-01-09 14:21:12 +0200 | [diff] [blame] | 89 | static const u32 hpd_mask_i915[HPD_NUM_PINS] = { |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 90 | [HPD_CRT] = CRT_HOTPLUG_INT_EN, |
| 91 | [HPD_SDVO_B] = SDVOB_HOTPLUG_INT_EN, |
| 92 | [HPD_SDVO_C] = SDVOC_HOTPLUG_INT_EN, |
| 93 | [HPD_PORT_B] = PORTB_HOTPLUG_INT_EN, |
| 94 | [HPD_PORT_C] = PORTC_HOTPLUG_INT_EN, |
| 95 | [HPD_PORT_D] = PORTD_HOTPLUG_INT_EN |
| 96 | }; |
| 97 | |
Ville Syrjälä | 7c7e10d | 2015-01-09 14:21:12 +0200 | [diff] [blame] | 98 | static const u32 hpd_status_g4x[HPD_NUM_PINS] = { |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 99 | [HPD_CRT] = CRT_HOTPLUG_INT_STATUS, |
| 100 | [HPD_SDVO_B] = SDVOB_HOTPLUG_INT_STATUS_G4X, |
| 101 | [HPD_SDVO_C] = SDVOC_HOTPLUG_INT_STATUS_G4X, |
| 102 | [HPD_PORT_B] = PORTB_HOTPLUG_INT_STATUS, |
| 103 | [HPD_PORT_C] = PORTC_HOTPLUG_INT_STATUS, |
| 104 | [HPD_PORT_D] = PORTD_HOTPLUG_INT_STATUS |
| 105 | }; |
| 106 | |
Ville Syrjälä | 4bca26d | 2015-05-11 20:49:10 +0300 | [diff] [blame] | 107 | static const u32 hpd_status_i915[HPD_NUM_PINS] = { |
Egbert Eich | e5868a3 | 2013-02-28 04:17:12 -0500 | [diff] [blame] | 108 | [HPD_CRT] = CRT_HOTPLUG_INT_STATUS, |
| 109 | [HPD_SDVO_B] = SDVOB_HOTPLUG_INT_STATUS_I915, |
| 110 | [HPD_SDVO_C] = SDVOC_HOTPLUG_INT_STATUS_I915, |
| 111 | [HPD_PORT_B] = PORTB_HOTPLUG_INT_STATUS, |
| 112 | [HPD_PORT_C] = PORTC_HOTPLUG_INT_STATUS, |
| 113 | [HPD_PORT_D] = PORTD_HOTPLUG_INT_STATUS |
| 114 | }; |
| 115 | |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 116 | /* BXT hpd list */ |
| 117 | static const u32 hpd_bxt[HPD_NUM_PINS] = { |
Sonika Jindal | 7f3561b | 2015-08-10 10:35:35 +0530 | [diff] [blame] | 118 | [HPD_PORT_A] = BXT_DE_PORT_HP_DDIA, |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 119 | [HPD_PORT_B] = BXT_DE_PORT_HP_DDIB, |
| 120 | [HPD_PORT_C] = BXT_DE_PORT_HP_DDIC |
| 121 | }; |
| 122 | |
Dhinakaran Pandiyan | b796b97 | 2018-06-15 17:05:30 -0700 | [diff] [blame] | 123 | static const u32 hpd_gen11[HPD_NUM_PINS] = { |
| 124 | [HPD_PORT_C] = GEN11_TC1_HOTPLUG | GEN11_TBT1_HOTPLUG, |
| 125 | [HPD_PORT_D] = GEN11_TC2_HOTPLUG | GEN11_TBT2_HOTPLUG, |
| 126 | [HPD_PORT_E] = GEN11_TC3_HOTPLUG | GEN11_TBT3_HOTPLUG, |
| 127 | [HPD_PORT_F] = GEN11_TC4_HOTPLUG | GEN11_TBT4_HOTPLUG |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 128 | }; |
| 129 | |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 130 | static const u32 hpd_icp[HPD_NUM_PINS] = { |
| 131 | [HPD_PORT_A] = SDE_DDIA_HOTPLUG_ICP, |
| 132 | [HPD_PORT_B] = SDE_DDIB_HOTPLUG_ICP, |
| 133 | [HPD_PORT_C] = SDE_TC1_HOTPLUG_ICP, |
| 134 | [HPD_PORT_D] = SDE_TC2_HOTPLUG_ICP, |
| 135 | [HPD_PORT_E] = SDE_TC3_HOTPLUG_ICP, |
| 136 | [HPD_PORT_F] = SDE_TC4_HOTPLUG_ICP |
| 137 | }; |
| 138 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 139 | static void gen3_irq_reset(struct intel_uncore *uncore, i915_reg_t imr, |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 140 | i915_reg_t iir, i915_reg_t ier) |
| 141 | { |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 142 | intel_uncore_write(uncore, imr, 0xffffffff); |
| 143 | intel_uncore_posting_read(uncore, imr); |
Paulo Zanoni | 5c50244 | 2014-04-01 15:37:11 -0300 | [diff] [blame] | 144 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 145 | intel_uncore_write(uncore, ier, 0); |
Paulo Zanoni | a9d356a | 2014-04-01 15:37:09 -0300 | [diff] [blame] | 146 | |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 147 | /* IIR can theoretically queue up two events. Be paranoid. */ |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 148 | intel_uncore_write(uncore, iir, 0xffffffff); |
| 149 | intel_uncore_posting_read(uncore, iir); |
| 150 | intel_uncore_write(uncore, iir, 0xffffffff); |
| 151 | intel_uncore_posting_read(uncore, iir); |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 154 | static void gen2_irq_reset(struct intel_uncore *uncore) |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 155 | { |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 156 | intel_uncore_write16(uncore, GEN2_IMR, 0xffff); |
| 157 | intel_uncore_posting_read16(uncore, GEN2_IMR); |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 158 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 159 | intel_uncore_write16(uncore, GEN2_IER, 0); |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 160 | |
| 161 | /* IIR can theoretically queue up two events. Be paranoid. */ |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 162 | intel_uncore_write16(uncore, GEN2_IIR, 0xffff); |
| 163 | intel_uncore_posting_read16(uncore, GEN2_IIR); |
| 164 | intel_uncore_write16(uncore, GEN2_IIR, 0xffff); |
| 165 | intel_uncore_posting_read16(uncore, GEN2_IIR); |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | #define GEN8_IRQ_RESET_NDX(type, which) \ |
| 169 | ({ \ |
| 170 | unsigned int which_ = which; \ |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 171 | gen3_irq_reset(&dev_priv->uncore, GEN8_##type##_IMR(which_), \ |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 172 | GEN8_##type##_IIR(which_), GEN8_##type##_IER(which_)); \ |
| 173 | }) |
| 174 | |
| 175 | #define GEN3_IRQ_RESET(type) \ |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 176 | gen3_irq_reset(&dev_priv->uncore, type##IMR, type##IIR, type##IER) |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 177 | |
Paulo Zanoni | 2918c3c | 2019-04-10 16:53:41 -0700 | [diff] [blame] | 178 | #define GEN2_IRQ_RESET() \ |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 179 | gen2_irq_reset(&dev_priv->uncore) |
Ville Syrjälä | e9e9848 | 2017-08-18 21:36:54 +0300 | [diff] [blame] | 180 | |
Paulo Zanoni | 337ba01 | 2014-04-01 15:37:16 -0300 | [diff] [blame] | 181 | /* |
| 182 | * We should clear IMR at preinstall/uninstall, and just check at postinstall. |
| 183 | */ |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 184 | static void gen3_assert_iir_is_zero(struct intel_uncore *uncore, i915_reg_t reg) |
Ville Syrjälä | b51a284 | 2015-09-18 20:03:41 +0300 | [diff] [blame] | 185 | { |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 186 | u32 val = intel_uncore_read(uncore, reg); |
Ville Syrjälä | b51a284 | 2015-09-18 20:03:41 +0300 | [diff] [blame] | 187 | |
| 188 | if (val == 0) |
| 189 | return; |
| 190 | |
| 191 | WARN(1, "Interrupt register 0x%x is not zero: 0x%08x\n", |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 192 | i915_mmio_reg_offset(reg), val); |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 193 | intel_uncore_write(uncore, reg, 0xffffffff); |
| 194 | intel_uncore_posting_read(uncore, reg); |
| 195 | intel_uncore_write(uncore, reg, 0xffffffff); |
| 196 | intel_uncore_posting_read(uncore, reg); |
Ville Syrjälä | b51a284 | 2015-09-18 20:03:41 +0300 | [diff] [blame] | 197 | } |
Paulo Zanoni | 337ba01 | 2014-04-01 15:37:16 -0300 | [diff] [blame] | 198 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 199 | static void gen2_assert_iir_is_zero(struct intel_uncore *uncore) |
Ville Syrjälä | e9e9848 | 2017-08-18 21:36:54 +0300 | [diff] [blame] | 200 | { |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 201 | u16 val = intel_uncore_read16(uncore, GEN2_IIR); |
Ville Syrjälä | e9e9848 | 2017-08-18 21:36:54 +0300 | [diff] [blame] | 202 | |
| 203 | if (val == 0) |
| 204 | return; |
| 205 | |
| 206 | WARN(1, "Interrupt register 0x%x is not zero: 0x%08x\n", |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 207 | i915_mmio_reg_offset(GEN2_IIR), val); |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 208 | intel_uncore_write16(uncore, GEN2_IIR, 0xffff); |
| 209 | intel_uncore_posting_read16(uncore, GEN2_IIR); |
| 210 | intel_uncore_write16(uncore, GEN2_IIR, 0xffff); |
| 211 | intel_uncore_posting_read16(uncore, GEN2_IIR); |
Ville Syrjälä | e9e9848 | 2017-08-18 21:36:54 +0300 | [diff] [blame] | 212 | } |
| 213 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 214 | static void gen3_irq_init(struct intel_uncore *uncore, |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 215 | i915_reg_t imr, u32 imr_val, |
| 216 | i915_reg_t ier, u32 ier_val, |
| 217 | i915_reg_t iir) |
| 218 | { |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 219 | gen3_assert_iir_is_zero(uncore, iir); |
Paulo Zanoni | 3507989 | 2014-04-01 15:37:15 -0300 | [diff] [blame] | 220 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 221 | intel_uncore_write(uncore, ier, ier_val); |
| 222 | intel_uncore_write(uncore, imr, imr_val); |
| 223 | intel_uncore_posting_read(uncore, imr); |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 224 | } |
Paulo Zanoni | 3507989 | 2014-04-01 15:37:15 -0300 | [diff] [blame] | 225 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 226 | static void gen2_irq_init(struct intel_uncore *uncore, |
Paulo Zanoni | 2918c3c | 2019-04-10 16:53:41 -0700 | [diff] [blame] | 227 | u32 imr_val, u32 ier_val) |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 228 | { |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 229 | gen2_assert_iir_is_zero(uncore); |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 230 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 231 | intel_uncore_write16(uncore, GEN2_IER, ier_val); |
| 232 | intel_uncore_write16(uncore, GEN2_IMR, imr_val); |
| 233 | intel_uncore_posting_read16(uncore, GEN2_IMR); |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | #define GEN8_IRQ_INIT_NDX(type, which, imr_val, ier_val) \ |
| 237 | ({ \ |
| 238 | unsigned int which_ = which; \ |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 239 | gen3_irq_init(&dev_priv->uncore, \ |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 240 | GEN8_##type##_IMR(which_), imr_val, \ |
| 241 | GEN8_##type##_IER(which_), ier_val, \ |
| 242 | GEN8_##type##_IIR(which_)); \ |
| 243 | }) |
| 244 | |
| 245 | #define GEN3_IRQ_INIT(type, imr_val, ier_val) \ |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 246 | gen3_irq_init(&dev_priv->uncore, \ |
Paulo Zanoni | 68eb49b | 2019-04-10 16:53:40 -0700 | [diff] [blame] | 247 | type##IMR, imr_val, \ |
| 248 | type##IER, ier_val, \ |
| 249 | type##IIR) |
| 250 | |
Paulo Zanoni | 2918c3c | 2019-04-10 16:53:41 -0700 | [diff] [blame] | 251 | #define GEN2_IRQ_INIT(imr_val, ier_val) \ |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 252 | gen2_irq_init(&dev_priv->uncore, imr_val, ier_val) |
Ville Syrjälä | e9e9848 | 2017-08-18 21:36:54 +0300 | [diff] [blame] | 253 | |
Imre Deak | c9a9a26 | 2014-11-05 20:48:37 +0200 | [diff] [blame] | 254 | static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir); |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 255 | static void gen9_guc_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir); |
Imre Deak | c9a9a26 | 2014-11-05 20:48:37 +0200 | [diff] [blame] | 256 | |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 257 | /* For display hotplug interrupt */ |
| 258 | static inline void |
| 259 | i915_hotplug_interrupt_update_locked(struct drm_i915_private *dev_priv, |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 260 | u32 mask, |
| 261 | u32 bits) |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 262 | { |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 263 | u32 val; |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 264 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 265 | lockdep_assert_held(&dev_priv->irq_lock); |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 266 | WARN_ON(bits & ~mask); |
| 267 | |
| 268 | val = I915_READ(PORT_HOTPLUG_EN); |
| 269 | val &= ~mask; |
| 270 | val |= bits; |
| 271 | I915_WRITE(PORT_HOTPLUG_EN, val); |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * i915_hotplug_interrupt_update - update hotplug interrupt enable |
| 276 | * @dev_priv: driver private |
| 277 | * @mask: bits to update |
| 278 | * @bits: bits to enable |
| 279 | * NOTE: the HPD enable bits are modified both inside and outside |
| 280 | * of an interrupt context. To avoid that read-modify-write cycles |
| 281 | * interfer, these bits are protected by a spinlock. Since this |
| 282 | * function is usually not called from a context where the lock is |
| 283 | * held already, this function acquires the lock itself. A non-locking |
| 284 | * version is also available. |
| 285 | */ |
| 286 | void i915_hotplug_interrupt_update(struct drm_i915_private *dev_priv, |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 287 | u32 mask, |
| 288 | u32 bits) |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 289 | { |
| 290 | spin_lock_irq(&dev_priv->irq_lock); |
| 291 | i915_hotplug_interrupt_update_locked(dev_priv, mask, bits); |
| 292 | spin_unlock_irq(&dev_priv->irq_lock); |
| 293 | } |
| 294 | |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 295 | static u32 |
| 296 | gen11_gt_engine_identity(struct drm_i915_private * const i915, |
| 297 | const unsigned int bank, const unsigned int bit); |
| 298 | |
Chris Wilson | 60a9432 | 2018-07-13 21:35:29 +0100 | [diff] [blame] | 299 | static bool gen11_reset_one_iir(struct drm_i915_private * const i915, |
| 300 | const unsigned int bank, |
| 301 | const unsigned int bit) |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 302 | { |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 303 | void __iomem * const regs = i915->uncore.regs; |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 304 | u32 dw; |
| 305 | |
| 306 | lockdep_assert_held(&i915->irq_lock); |
| 307 | |
| 308 | dw = raw_reg_read(regs, GEN11_GT_INTR_DW(bank)); |
| 309 | if (dw & BIT(bit)) { |
| 310 | /* |
| 311 | * According to the BSpec, DW_IIR bits cannot be cleared without |
| 312 | * first servicing the Selector & Shared IIR registers. |
| 313 | */ |
| 314 | gen11_gt_engine_identity(i915, bank, bit); |
| 315 | |
| 316 | /* |
| 317 | * We locked GT INT DW by reading it. If we want to (try |
| 318 | * to) recover from this succesfully, we need to clear |
| 319 | * our bit, otherwise we are locking the register for |
| 320 | * everybody. |
| 321 | */ |
| 322 | raw_reg_write(regs, GEN11_GT_INTR_DW(bank), BIT(bit)); |
| 323 | |
| 324 | return true; |
| 325 | } |
| 326 | |
| 327 | return false; |
| 328 | } |
| 329 | |
Ville Syrjälä | d9dc34f1 | 2015-08-27 23:55:58 +0300 | [diff] [blame] | 330 | /** |
| 331 | * ilk_update_display_irq - update DEIMR |
| 332 | * @dev_priv: driver private |
| 333 | * @interrupt_mask: mask of interrupt bits to update |
| 334 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 335 | */ |
Ville Syrjälä | fbdedaea | 2015-11-23 18:06:16 +0200 | [diff] [blame] | 336 | void ilk_update_display_irq(struct drm_i915_private *dev_priv, |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 337 | u32 interrupt_mask, |
| 338 | u32 enabled_irq_mask) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 339 | { |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 340 | u32 new_val; |
Ville Syrjälä | d9dc34f1 | 2015-08-27 23:55:58 +0300 | [diff] [blame] | 341 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 342 | lockdep_assert_held(&dev_priv->irq_lock); |
Daniel Vetter | 4bc9d43 | 2013-06-27 13:44:58 +0200 | [diff] [blame] | 343 | |
Ville Syrjälä | d9dc34f1 | 2015-08-27 23:55:58 +0300 | [diff] [blame] | 344 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 345 | |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 346 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 347 | return; |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 348 | |
Ville Syrjälä | d9dc34f1 | 2015-08-27 23:55:58 +0300 | [diff] [blame] | 349 | new_val = dev_priv->irq_mask; |
| 350 | new_val &= ~interrupt_mask; |
| 351 | new_val |= (~enabled_irq_mask & interrupt_mask); |
| 352 | |
| 353 | if (new_val != dev_priv->irq_mask) { |
| 354 | dev_priv->irq_mask = new_val; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 355 | I915_WRITE(DEIMR, dev_priv->irq_mask); |
Chris Wilson | 3143a2b | 2010-11-16 15:55:10 +0000 | [diff] [blame] | 356 | POSTING_READ(DEIMR); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 360 | /** |
| 361 | * ilk_update_gt_irq - update GTIMR |
| 362 | * @dev_priv: driver private |
| 363 | * @interrupt_mask: mask of interrupt bits to update |
| 364 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 365 | */ |
| 366 | static void ilk_update_gt_irq(struct drm_i915_private *dev_priv, |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 367 | u32 interrupt_mask, |
| 368 | u32 enabled_irq_mask) |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 369 | { |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 370 | lockdep_assert_held(&dev_priv->irq_lock); |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 371 | |
Daniel Vetter | 15a17aa | 2014-12-08 16:30:00 +0100 | [diff] [blame] | 372 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 373 | |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 374 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 375 | return; |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 376 | |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 377 | dev_priv->gt_irq_mask &= ~interrupt_mask; |
| 378 | dev_priv->gt_irq_mask |= (~enabled_irq_mask & interrupt_mask); |
| 379 | I915_WRITE(GTIMR, dev_priv->gt_irq_mask); |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 380 | } |
| 381 | |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 382 | void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, u32 mask) |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 383 | { |
| 384 | ilk_update_gt_irq(dev_priv, mask, mask); |
Chris Wilson | 31bb59c | 2016-07-01 17:23:27 +0100 | [diff] [blame] | 385 | POSTING_READ_FW(GTIMR); |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 386 | } |
| 387 | |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 388 | void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, u32 mask) |
Paulo Zanoni | 43eaea1 | 2013-08-06 18:57:12 -0300 | [diff] [blame] | 389 | { |
| 390 | ilk_update_gt_irq(dev_priv, mask, 0); |
| 391 | } |
| 392 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 393 | static i915_reg_t gen6_pm_iir(struct drm_i915_private *dev_priv) |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 394 | { |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 395 | WARN_ON_ONCE(INTEL_GEN(dev_priv) >= 11); |
| 396 | |
Pandiyan, Dhinakaran | bca2bf2 | 2017-07-18 11:28:00 -0700 | [diff] [blame] | 397 | return INTEL_GEN(dev_priv) >= 8 ? GEN8_GT_IIR(2) : GEN6_PMIIR; |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 398 | } |
| 399 | |
Mika Kuoppala | 917dc6b | 2019-04-10 13:59:22 +0300 | [diff] [blame] | 400 | static void write_pm_imr(struct drm_i915_private *dev_priv) |
Imre Deak | a72fbc3 | 2014-11-05 20:48:31 +0200 | [diff] [blame] | 401 | { |
Mika Kuoppala | 917dc6b | 2019-04-10 13:59:22 +0300 | [diff] [blame] | 402 | i915_reg_t reg; |
| 403 | u32 mask = dev_priv->pm_imr; |
| 404 | |
| 405 | if (INTEL_GEN(dev_priv) >= 11) { |
| 406 | reg = GEN11_GPM_WGBOXPERF_INTR_MASK; |
| 407 | /* pm is in upper half */ |
| 408 | mask = mask << 16; |
| 409 | } else if (INTEL_GEN(dev_priv) >= 8) { |
| 410 | reg = GEN8_GT_IMR(2); |
| 411 | } else { |
| 412 | reg = GEN6_PMIMR; |
| 413 | } |
| 414 | |
| 415 | I915_WRITE(reg, mask); |
| 416 | POSTING_READ(reg); |
Imre Deak | a72fbc3 | 2014-11-05 20:48:31 +0200 | [diff] [blame] | 417 | } |
| 418 | |
Mika Kuoppala | 917dc6b | 2019-04-10 13:59:22 +0300 | [diff] [blame] | 419 | static void write_pm_ier(struct drm_i915_private *dev_priv) |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 420 | { |
Mika Kuoppala | 917dc6b | 2019-04-10 13:59:22 +0300 | [diff] [blame] | 421 | i915_reg_t reg; |
| 422 | u32 mask = dev_priv->pm_ier; |
| 423 | |
| 424 | if (INTEL_GEN(dev_priv) >= 11) { |
| 425 | reg = GEN11_GPM_WGBOXPERF_INTR_ENABLE; |
| 426 | /* pm is in upper half */ |
| 427 | mask = mask << 16; |
| 428 | } else if (INTEL_GEN(dev_priv) >= 8) { |
| 429 | reg = GEN8_GT_IER(2); |
| 430 | } else { |
| 431 | reg = GEN6_PMIER; |
| 432 | } |
| 433 | |
| 434 | I915_WRITE(reg, mask); |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 435 | } |
| 436 | |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 437 | /** |
Ville Syrjälä | 81fd874 | 2015-11-25 16:21:30 +0200 | [diff] [blame] | 438 | * snb_update_pm_irq - update GEN6_PMIMR |
| 439 | * @dev_priv: driver private |
| 440 | * @interrupt_mask: mask of interrupt bits to update |
| 441 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 442 | */ |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 443 | static void snb_update_pm_irq(struct drm_i915_private *dev_priv, |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 444 | u32 interrupt_mask, |
| 445 | u32 enabled_irq_mask) |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 446 | { |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 447 | u32 new_val; |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 448 | |
Daniel Vetter | 15a17aa | 2014-12-08 16:30:00 +0100 | [diff] [blame] | 449 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 450 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 451 | lockdep_assert_held(&dev_priv->irq_lock); |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 452 | |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 453 | new_val = dev_priv->pm_imr; |
Paulo Zanoni | f52ecbc | 2013-08-06 18:57:14 -0300 | [diff] [blame] | 454 | new_val &= ~interrupt_mask; |
| 455 | new_val |= (~enabled_irq_mask & interrupt_mask); |
| 456 | |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 457 | if (new_val != dev_priv->pm_imr) { |
| 458 | dev_priv->pm_imr = new_val; |
Mika Kuoppala | 917dc6b | 2019-04-10 13:59:22 +0300 | [diff] [blame] | 459 | write_pm_imr(dev_priv); |
Paulo Zanoni | f52ecbc | 2013-08-06 18:57:14 -0300 | [diff] [blame] | 460 | } |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 461 | } |
| 462 | |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 463 | void gen6_unmask_pm_irq(struct drm_i915_private *dev_priv, u32 mask) |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 464 | { |
Imre Deak | 9939fba | 2014-11-20 23:01:47 +0200 | [diff] [blame] | 465 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
| 466 | return; |
| 467 | |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 468 | snb_update_pm_irq(dev_priv, mask, mask); |
| 469 | } |
| 470 | |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 471 | static void __gen6_mask_pm_irq(struct drm_i915_private *dev_priv, u32 mask) |
Imre Deak | 9939fba | 2014-11-20 23:01:47 +0200 | [diff] [blame] | 472 | { |
| 473 | snb_update_pm_irq(dev_priv, mask, 0); |
| 474 | } |
| 475 | |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 476 | void gen6_mask_pm_irq(struct drm_i915_private *dev_priv, u32 mask) |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 477 | { |
Imre Deak | 9939fba | 2014-11-20 23:01:47 +0200 | [diff] [blame] | 478 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
| 479 | return; |
| 480 | |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 481 | __gen6_mask_pm_irq(dev_priv, mask); |
| 482 | } |
| 483 | |
Oscar Mateo | 3814fd7 | 2017-08-23 16:58:24 -0700 | [diff] [blame] | 484 | static void gen6_reset_pm_iir(struct drm_i915_private *dev_priv, u32 reset_mask) |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 485 | { |
| 486 | i915_reg_t reg = gen6_pm_iir(dev_priv); |
| 487 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 488 | lockdep_assert_held(&dev_priv->irq_lock); |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 489 | |
| 490 | I915_WRITE(reg, reset_mask); |
| 491 | I915_WRITE(reg, reset_mask); |
| 492 | POSTING_READ(reg); |
| 493 | } |
| 494 | |
Oscar Mateo | 3814fd7 | 2017-08-23 16:58:24 -0700 | [diff] [blame] | 495 | static void gen6_enable_pm_irq(struct drm_i915_private *dev_priv, u32 enable_mask) |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 496 | { |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 497 | lockdep_assert_held(&dev_priv->irq_lock); |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 498 | |
| 499 | dev_priv->pm_ier |= enable_mask; |
Mika Kuoppala | 917dc6b | 2019-04-10 13:59:22 +0300 | [diff] [blame] | 500 | write_pm_ier(dev_priv); |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 501 | gen6_unmask_pm_irq(dev_priv, enable_mask); |
| 502 | /* unmask_pm_irq provides an implicit barrier (POSTING_READ) */ |
| 503 | } |
| 504 | |
Oscar Mateo | 3814fd7 | 2017-08-23 16:58:24 -0700 | [diff] [blame] | 505 | static void gen6_disable_pm_irq(struct drm_i915_private *dev_priv, u32 disable_mask) |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 506 | { |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 507 | lockdep_assert_held(&dev_priv->irq_lock); |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 508 | |
| 509 | dev_priv->pm_ier &= ~disable_mask; |
| 510 | __gen6_mask_pm_irq(dev_priv, disable_mask); |
Mika Kuoppala | 917dc6b | 2019-04-10 13:59:22 +0300 | [diff] [blame] | 511 | write_pm_ier(dev_priv); |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 512 | /* though a barrier is missing here, but don't really need a one */ |
Paulo Zanoni | edbfdb4 | 2013-08-06 18:57:13 -0300 | [diff] [blame] | 513 | } |
| 514 | |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 515 | void gen11_reset_rps_interrupts(struct drm_i915_private *dev_priv) |
| 516 | { |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 517 | spin_lock_irq(&dev_priv->irq_lock); |
| 518 | |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 519 | while (gen11_reset_one_iir(dev_priv, 0, GEN11_GTPM)) |
| 520 | ; |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 521 | |
| 522 | dev_priv->gt_pm.rps.pm_iir = 0; |
| 523 | |
| 524 | spin_unlock_irq(&dev_priv->irq_lock); |
| 525 | } |
| 526 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 527 | void gen6_reset_rps_interrupts(struct drm_i915_private *dev_priv) |
Imre Deak | 3cc134e | 2014-11-19 15:30:03 +0200 | [diff] [blame] | 528 | { |
Imre Deak | 3cc134e | 2014-11-19 15:30:03 +0200 | [diff] [blame] | 529 | spin_lock_irq(&dev_priv->irq_lock); |
Chris Wilson | 4668f69 | 2018-08-02 11:06:30 +0100 | [diff] [blame] | 530 | gen6_reset_pm_iir(dev_priv, GEN6_PM_RPS_EVENTS); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 531 | dev_priv->gt_pm.rps.pm_iir = 0; |
Imre Deak | 3cc134e | 2014-11-19 15:30:03 +0200 | [diff] [blame] | 532 | spin_unlock_irq(&dev_priv->irq_lock); |
| 533 | } |
| 534 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 535 | void gen6_enable_rps_interrupts(struct drm_i915_private *dev_priv) |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 536 | { |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 537 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
| 538 | |
| 539 | if (READ_ONCE(rps->interrupts_enabled)) |
Chris Wilson | f2a91d1 | 2016-09-21 14:51:06 +0100 | [diff] [blame] | 540 | return; |
| 541 | |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 542 | spin_lock_irq(&dev_priv->irq_lock); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 543 | WARN_ON_ONCE(rps->pm_iir); |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 544 | |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 545 | if (INTEL_GEN(dev_priv) >= 11) |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 546 | WARN_ON_ONCE(gen11_reset_one_iir(dev_priv, 0, GEN11_GTPM)); |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 547 | else |
| 548 | WARN_ON_ONCE(I915_READ(gen6_pm_iir(dev_priv)) & dev_priv->pm_rps_events); |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 549 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 550 | rps->interrupts_enabled = true; |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 551 | gen6_enable_pm_irq(dev_priv, dev_priv->pm_rps_events); |
Imre Deak | 78e68d3 | 2014-12-15 18:59:27 +0200 | [diff] [blame] | 552 | |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 553 | spin_unlock_irq(&dev_priv->irq_lock); |
| 554 | } |
| 555 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 556 | void gen6_disable_rps_interrupts(struct drm_i915_private *dev_priv) |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 557 | { |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 558 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
| 559 | |
| 560 | if (!READ_ONCE(rps->interrupts_enabled)) |
Chris Wilson | f2a91d1 | 2016-09-21 14:51:06 +0100 | [diff] [blame] | 561 | return; |
| 562 | |
Imre Deak | d4d70aa | 2014-11-19 15:30:04 +0200 | [diff] [blame] | 563 | spin_lock_irq(&dev_priv->irq_lock); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 564 | rps->interrupts_enabled = false; |
Imre Deak | 9939fba | 2014-11-20 23:01:47 +0200 | [diff] [blame] | 565 | |
Dave Gordon | b20e3cf | 2016-09-12 21:19:35 +0100 | [diff] [blame] | 566 | I915_WRITE(GEN6_PMINTRMSK, gen6_sanitize_rps_pm_mask(dev_priv, ~0u)); |
Imre Deak | 9939fba | 2014-11-20 23:01:47 +0200 | [diff] [blame] | 567 | |
Chris Wilson | 4668f69 | 2018-08-02 11:06:30 +0100 | [diff] [blame] | 568 | gen6_disable_pm_irq(dev_priv, GEN6_PM_RPS_EVENTS); |
Imre Deak | 58072cc | 2015-03-23 19:11:34 +0200 | [diff] [blame] | 569 | |
| 570 | spin_unlock_irq(&dev_priv->irq_lock); |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 571 | synchronize_irq(dev_priv->drm.irq); |
Chris Wilson | c33d247 | 2016-07-04 08:08:36 +0100 | [diff] [blame] | 572 | |
| 573 | /* Now that we will not be generating any more work, flush any |
Oscar Mateo | 3814fd7 | 2017-08-23 16:58:24 -0700 | [diff] [blame] | 574 | * outstanding tasks. As we are called on the RPS idle path, |
Chris Wilson | c33d247 | 2016-07-04 08:08:36 +0100 | [diff] [blame] | 575 | * we will reset the GPU to minimum frequencies, so the current |
| 576 | * state of the worker can be discarded. |
| 577 | */ |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 578 | cancel_work_sync(&rps->work); |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 579 | if (INTEL_GEN(dev_priv) >= 11) |
| 580 | gen11_reset_rps_interrupts(dev_priv); |
| 581 | else |
| 582 | gen6_reset_rps_interrupts(dev_priv); |
Imre Deak | b900b94 | 2014-11-05 20:48:48 +0200 | [diff] [blame] | 583 | } |
| 584 | |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 585 | void gen9_reset_guc_interrupts(struct drm_i915_private *dev_priv) |
| 586 | { |
Sagar Arun Kamble | 1be333d | 2018-01-24 21:16:56 +0530 | [diff] [blame] | 587 | assert_rpm_wakelock_held(dev_priv); |
| 588 | |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 589 | spin_lock_irq(&dev_priv->irq_lock); |
| 590 | gen6_reset_pm_iir(dev_priv, dev_priv->pm_guc_events); |
| 591 | spin_unlock_irq(&dev_priv->irq_lock); |
| 592 | } |
| 593 | |
| 594 | void gen9_enable_guc_interrupts(struct drm_i915_private *dev_priv) |
| 595 | { |
Sagar Arun Kamble | 1be333d | 2018-01-24 21:16:56 +0530 | [diff] [blame] | 596 | assert_rpm_wakelock_held(dev_priv); |
| 597 | |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 598 | spin_lock_irq(&dev_priv->irq_lock); |
| 599 | if (!dev_priv->guc.interrupts_enabled) { |
| 600 | WARN_ON_ONCE(I915_READ(gen6_pm_iir(dev_priv)) & |
| 601 | dev_priv->pm_guc_events); |
| 602 | dev_priv->guc.interrupts_enabled = true; |
| 603 | gen6_enable_pm_irq(dev_priv, dev_priv->pm_guc_events); |
| 604 | } |
| 605 | spin_unlock_irq(&dev_priv->irq_lock); |
| 606 | } |
| 607 | |
| 608 | void gen9_disable_guc_interrupts(struct drm_i915_private *dev_priv) |
| 609 | { |
Sagar Arun Kamble | 1be333d | 2018-01-24 21:16:56 +0530 | [diff] [blame] | 610 | assert_rpm_wakelock_held(dev_priv); |
| 611 | |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 612 | spin_lock_irq(&dev_priv->irq_lock); |
| 613 | dev_priv->guc.interrupts_enabled = false; |
| 614 | |
| 615 | gen6_disable_pm_irq(dev_priv, dev_priv->pm_guc_events); |
| 616 | |
| 617 | spin_unlock_irq(&dev_priv->irq_lock); |
| 618 | synchronize_irq(dev_priv->drm.irq); |
| 619 | |
| 620 | gen9_reset_guc_interrupts(dev_priv); |
| 621 | } |
| 622 | |
Ben Widawsky | 0961021 | 2014-05-15 20:58:08 +0300 | [diff] [blame] | 623 | /** |
Ville Syrjälä | 81fd874 | 2015-11-25 16:21:30 +0200 | [diff] [blame] | 624 | * bdw_update_port_irq - update DE port interrupt |
| 625 | * @dev_priv: driver private |
| 626 | * @interrupt_mask: mask of interrupt bits to update |
| 627 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 628 | */ |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 629 | static void bdw_update_port_irq(struct drm_i915_private *dev_priv, |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 630 | u32 interrupt_mask, |
| 631 | u32 enabled_irq_mask) |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 632 | { |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 633 | u32 new_val; |
| 634 | u32 old_val; |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 635 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 636 | lockdep_assert_held(&dev_priv->irq_lock); |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 637 | |
| 638 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 639 | |
| 640 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
| 641 | return; |
| 642 | |
| 643 | old_val = I915_READ(GEN8_DE_PORT_IMR); |
| 644 | |
| 645 | new_val = old_val; |
| 646 | new_val &= ~interrupt_mask; |
| 647 | new_val |= (~enabled_irq_mask & interrupt_mask); |
| 648 | |
| 649 | if (new_val != old_val) { |
| 650 | I915_WRITE(GEN8_DE_PORT_IMR, new_val); |
| 651 | POSTING_READ(GEN8_DE_PORT_IMR); |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | /** |
Ville Syrjälä | 013d375 | 2015-11-23 18:06:17 +0200 | [diff] [blame] | 656 | * bdw_update_pipe_irq - update DE pipe interrupt |
| 657 | * @dev_priv: driver private |
| 658 | * @pipe: pipe whose interrupt to update |
| 659 | * @interrupt_mask: mask of interrupt bits to update |
| 660 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 661 | */ |
| 662 | void bdw_update_pipe_irq(struct drm_i915_private *dev_priv, |
| 663 | enum pipe pipe, |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 664 | u32 interrupt_mask, |
| 665 | u32 enabled_irq_mask) |
Ville Syrjälä | 013d375 | 2015-11-23 18:06:17 +0200 | [diff] [blame] | 666 | { |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 667 | u32 new_val; |
Ville Syrjälä | 013d375 | 2015-11-23 18:06:17 +0200 | [diff] [blame] | 668 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 669 | lockdep_assert_held(&dev_priv->irq_lock); |
Ville Syrjälä | 013d375 | 2015-11-23 18:06:17 +0200 | [diff] [blame] | 670 | |
| 671 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 672 | |
| 673 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
| 674 | return; |
| 675 | |
| 676 | new_val = dev_priv->de_irq_mask[pipe]; |
| 677 | new_val &= ~interrupt_mask; |
| 678 | new_val |= (~enabled_irq_mask & interrupt_mask); |
| 679 | |
| 680 | if (new_val != dev_priv->de_irq_mask[pipe]) { |
| 681 | dev_priv->de_irq_mask[pipe] = new_val; |
| 682 | I915_WRITE(GEN8_DE_PIPE_IMR(pipe), dev_priv->de_irq_mask[pipe]); |
| 683 | POSTING_READ(GEN8_DE_PIPE_IMR(pipe)); |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | /** |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 688 | * ibx_display_interrupt_update - update SDEIMR |
| 689 | * @dev_priv: driver private |
| 690 | * @interrupt_mask: mask of interrupt bits to update |
| 691 | * @enabled_irq_mask: mask of interrupt bits to enable |
| 692 | */ |
Daniel Vetter | 47339cd | 2014-09-30 10:56:46 +0200 | [diff] [blame] | 693 | void ibx_display_interrupt_update(struct drm_i915_private *dev_priv, |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 694 | u32 interrupt_mask, |
| 695 | u32 enabled_irq_mask) |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 696 | { |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 697 | u32 sdeimr = I915_READ(SDEIMR); |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 698 | sdeimr &= ~interrupt_mask; |
| 699 | sdeimr |= (~enabled_irq_mask & interrupt_mask); |
| 700 | |
Daniel Vetter | 15a17aa | 2014-12-08 16:30:00 +0100 | [diff] [blame] | 701 | WARN_ON(enabled_irq_mask & ~interrupt_mask); |
| 702 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 703 | lockdep_assert_held(&dev_priv->irq_lock); |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 704 | |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 705 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 706 | return; |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 707 | |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 708 | I915_WRITE(SDEIMR, sdeimr); |
| 709 | POSTING_READ(SDEIMR); |
| 710 | } |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 711 | |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 712 | u32 i915_pipestat_enable_mask(struct drm_i915_private *dev_priv, |
| 713 | enum pipe pipe) |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 714 | { |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 715 | u32 status_mask = dev_priv->pipestat_irq_mask[pipe]; |
Imre Deak | 10c59c5 | 2014-02-10 18:42:48 +0200 | [diff] [blame] | 716 | u32 enable_mask = status_mask << 16; |
| 717 | |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 718 | lockdep_assert_held(&dev_priv->irq_lock); |
| 719 | |
| 720 | if (INTEL_GEN(dev_priv) < 5) |
| 721 | goto out; |
| 722 | |
Imre Deak | 10c59c5 | 2014-02-10 18:42:48 +0200 | [diff] [blame] | 723 | /* |
Ville Syrjälä | 724a690 | 2014-04-09 13:28:48 +0300 | [diff] [blame] | 724 | * On pipe A we don't support the PSR interrupt yet, |
| 725 | * on pipe B and C the same bit MBZ. |
Imre Deak | 10c59c5 | 2014-02-10 18:42:48 +0200 | [diff] [blame] | 726 | */ |
| 727 | if (WARN_ON_ONCE(status_mask & PIPE_A_PSR_STATUS_VLV)) |
| 728 | return 0; |
Ville Syrjälä | 724a690 | 2014-04-09 13:28:48 +0300 | [diff] [blame] | 729 | /* |
| 730 | * On pipe B and C we don't support the PSR interrupt yet, on pipe |
| 731 | * A the same bit is for perf counters which we don't use either. |
| 732 | */ |
| 733 | if (WARN_ON_ONCE(status_mask & PIPE_B_PSR_STATUS_VLV)) |
| 734 | return 0; |
Imre Deak | 10c59c5 | 2014-02-10 18:42:48 +0200 | [diff] [blame] | 735 | |
| 736 | enable_mask &= ~(PIPE_FIFO_UNDERRUN_STATUS | |
| 737 | SPRITE0_FLIP_DONE_INT_EN_VLV | |
| 738 | SPRITE1_FLIP_DONE_INT_EN_VLV); |
| 739 | if (status_mask & SPRITE0_FLIP_DONE_INT_STATUS_VLV) |
| 740 | enable_mask |= SPRITE0_FLIP_DONE_INT_EN_VLV; |
| 741 | if (status_mask & SPRITE1_FLIP_DONE_INT_STATUS_VLV) |
| 742 | enable_mask |= SPRITE1_FLIP_DONE_INT_EN_VLV; |
| 743 | |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 744 | out: |
| 745 | WARN_ONCE(enable_mask & ~PIPESTAT_INT_ENABLE_MASK || |
| 746 | status_mask & ~PIPESTAT_INT_STATUS_MASK, |
| 747 | "pipe %c: enable_mask=0x%x, status_mask=0x%x\n", |
| 748 | pipe_name(pipe), enable_mask, status_mask); |
| 749 | |
Imre Deak | 10c59c5 | 2014-02-10 18:42:48 +0200 | [diff] [blame] | 750 | return enable_mask; |
| 751 | } |
| 752 | |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 753 | void i915_enable_pipestat(struct drm_i915_private *dev_priv, |
| 754 | enum pipe pipe, u32 status_mask) |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 755 | { |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 756 | i915_reg_t reg = PIPESTAT(pipe); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 757 | u32 enable_mask; |
| 758 | |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 759 | WARN_ONCE(status_mask & ~PIPESTAT_INT_STATUS_MASK, |
| 760 | "pipe %c: status_mask=0x%x\n", |
| 761 | pipe_name(pipe), status_mask); |
| 762 | |
| 763 | lockdep_assert_held(&dev_priv->irq_lock); |
| 764 | WARN_ON(!intel_irqs_enabled(dev_priv)); |
| 765 | |
| 766 | if ((dev_priv->pipestat_irq_mask[pipe] & status_mask) == status_mask) |
| 767 | return; |
| 768 | |
| 769 | dev_priv->pipestat_irq_mask[pipe] |= status_mask; |
| 770 | enable_mask = i915_pipestat_enable_mask(dev_priv, pipe); |
| 771 | |
| 772 | I915_WRITE(reg, enable_mask | status_mask); |
| 773 | POSTING_READ(reg); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 774 | } |
| 775 | |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 776 | void i915_disable_pipestat(struct drm_i915_private *dev_priv, |
| 777 | enum pipe pipe, u32 status_mask) |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 778 | { |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 779 | i915_reg_t reg = PIPESTAT(pipe); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 780 | u32 enable_mask; |
| 781 | |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 782 | WARN_ONCE(status_mask & ~PIPESTAT_INT_STATUS_MASK, |
| 783 | "pipe %c: status_mask=0x%x\n", |
| 784 | pipe_name(pipe), status_mask); |
| 785 | |
| 786 | lockdep_assert_held(&dev_priv->irq_lock); |
| 787 | WARN_ON(!intel_irqs_enabled(dev_priv)); |
| 788 | |
| 789 | if ((dev_priv->pipestat_irq_mask[pipe] & status_mask) == 0) |
| 790 | return; |
| 791 | |
| 792 | dev_priv->pipestat_irq_mask[pipe] &= ~status_mask; |
| 793 | enable_mask = i915_pipestat_enable_mask(dev_priv, pipe); |
| 794 | |
| 795 | I915_WRITE(reg, enable_mask | status_mask); |
| 796 | POSTING_READ(reg); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 797 | } |
| 798 | |
Ville Syrjälä | f3e3048 | 2019-03-18 18:56:31 +0200 | [diff] [blame] | 799 | static bool i915_has_asle(struct drm_i915_private *dev_priv) |
| 800 | { |
| 801 | if (!dev_priv->opregion.asle) |
| 802 | return false; |
| 803 | |
| 804 | return IS_PINEVIEW(dev_priv) || IS_MOBILE(dev_priv); |
| 805 | } |
| 806 | |
=?utf-8?q?Michel_D=C3=A4nzer?= | a6b54f3 | 2006-10-24 23:37:43 +1000 | [diff] [blame] | 807 | /** |
Jani Nikula | f49e38d | 2013-04-29 13:02:54 +0300 | [diff] [blame] | 808 | * i915_enable_asle_pipestat - enable ASLE pipestat for OpRegion |
Tvrtko Ursulin | 14bb2c1 | 2016-06-03 14:02:17 +0100 | [diff] [blame] | 809 | * @dev_priv: i915 device private |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 810 | */ |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 811 | static void i915_enable_asle_pipestat(struct drm_i915_private *dev_priv) |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 812 | { |
Ville Syrjälä | f3e3048 | 2019-03-18 18:56:31 +0200 | [diff] [blame] | 813 | if (!i915_has_asle(dev_priv)) |
Jani Nikula | f49e38d | 2013-04-29 13:02:54 +0300 | [diff] [blame] | 814 | return; |
| 815 | |
Daniel Vetter | 1332178 | 2014-09-15 14:55:29 +0200 | [diff] [blame] | 816 | spin_lock_irq(&dev_priv->irq_lock); |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 817 | |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 818 | i915_enable_pipestat(dev_priv, PIPE_B, PIPE_LEGACY_BLC_EVENT_STATUS); |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 819 | if (INTEL_GEN(dev_priv) >= 4) |
Daniel Vetter | 3b6c42e | 2013-10-21 18:04:35 +0200 | [diff] [blame] | 820 | i915_enable_pipestat(dev_priv, PIPE_A, |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 821 | PIPE_LEGACY_BLC_EVENT_STATUS); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 822 | |
Daniel Vetter | 1332178 | 2014-09-15 14:55:29 +0200 | [diff] [blame] | 823 | spin_unlock_irq(&dev_priv->irq_lock); |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 824 | } |
| 825 | |
Ville Syrjälä | f75f374 | 2014-05-15 20:20:36 +0300 | [diff] [blame] | 826 | /* |
| 827 | * This timing diagram depicts the video signal in and |
| 828 | * around the vertical blanking period. |
| 829 | * |
| 830 | * Assumptions about the fictitious mode used in this example: |
| 831 | * vblank_start >= 3 |
| 832 | * vsync_start = vblank_start + 1 |
| 833 | * vsync_end = vblank_start + 2 |
| 834 | * vtotal = vblank_start + 3 |
| 835 | * |
| 836 | * start of vblank: |
| 837 | * latch double buffered registers |
| 838 | * increment frame counter (ctg+) |
| 839 | * generate start of vblank interrupt (gen4+) |
| 840 | * | |
| 841 | * | frame start: |
| 842 | * | generate frame start interrupt (aka. vblank interrupt) (gmch) |
| 843 | * | may be shifted forward 1-3 extra lines via PIPECONF |
| 844 | * | | |
| 845 | * | | start of vsync: |
| 846 | * | | generate vsync interrupt |
| 847 | * | | | |
| 848 | * ___xxxx___ ___xxxx___ ___xxxx___ ___xxxx___ ___xxxx___ ___xxxx |
| 849 | * . \hs/ . \hs/ \hs/ \hs/ . \hs/ |
| 850 | * ----va---> <-----------------vb--------------------> <--------va------------- |
| 851 | * | | <----vs-----> | |
| 852 | * -vbs-----> <---vbs+1---> <---vbs+2---> <-----0-----> <-----1-----> <-----2--- (scanline counter gen2) |
| 853 | * -vbs-2---> <---vbs-1---> <---vbs-----> <---vbs+1---> <---vbs+2---> <-----0--- (scanline counter gen3+) |
| 854 | * -vbs-2---> <---vbs-2---> <---vbs-1---> <---vbs-----> <---vbs+1---> <---vbs+2- (scanline counter hsw+ hdmi) |
| 855 | * | | | |
| 856 | * last visible pixel first visible pixel |
| 857 | * | increment frame counter (gen3/4) |
| 858 | * pixel counter = vblank_start * htotal pixel counter = 0 (gen3/4) |
| 859 | * |
| 860 | * x = horizontal active |
| 861 | * _ = horizontal blanking |
| 862 | * hs = horizontal sync |
| 863 | * va = vertical active |
| 864 | * vb = vertical blanking |
| 865 | * vs = vertical sync |
| 866 | * vbs = vblank_start (number) |
| 867 | * |
| 868 | * Summary: |
| 869 | * - most events happen at the start of horizontal sync |
| 870 | * - frame start happens at the start of horizontal blank, 1-4 lines |
| 871 | * (depending on PIPECONF settings) after the start of vblank |
| 872 | * - gen3/4 pixel and frame counter are synchronized with the start |
| 873 | * of horizontal active on the first line of vertical active |
| 874 | */ |
| 875 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 876 | /* Called from drm generic code, passed a 'crtc', which |
| 877 | * we use as a pipe index |
| 878 | */ |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 879 | static u32 i915_get_vblank_counter(struct drm_device *dev, unsigned int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 880 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 881 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 32db0b6 | 2018-11-27 22:05:50 +0200 | [diff] [blame] | 882 | struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; |
| 883 | const struct drm_display_mode *mode = &vblank->hwmode; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 884 | i915_reg_t high_frame, low_frame; |
Ville Syrjälä | 0b2a8e0 | 2014-04-29 13:35:50 +0300 | [diff] [blame] | 885 | u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal; |
Ville Syrjälä | 694e409 | 2017-03-09 17:44:30 +0200 | [diff] [blame] | 886 | unsigned long irqflags; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 887 | |
Ville Syrjälä | 32db0b6 | 2018-11-27 22:05:50 +0200 | [diff] [blame] | 888 | /* |
| 889 | * On i965gm TV output the frame counter only works up to |
| 890 | * the point when we enable the TV encoder. After that the |
| 891 | * frame counter ceases to work and reads zero. We need a |
| 892 | * vblank wait before enabling the TV encoder and so we |
| 893 | * have to enable vblank interrupts while the frame counter |
| 894 | * is still in a working state. However the core vblank code |
| 895 | * does not like us returning non-zero frame counter values |
| 896 | * when we've told it that we don't have a working frame |
| 897 | * counter. Thus we must stop non-zero values leaking out. |
| 898 | */ |
| 899 | if (!vblank->max_vblank_count) |
| 900 | return 0; |
| 901 | |
Daniel Vetter | f3a5c3f | 2015-02-13 21:03:44 +0100 | [diff] [blame] | 902 | htotal = mode->crtc_htotal; |
| 903 | hsync_start = mode->crtc_hsync_start; |
| 904 | vbl_start = mode->crtc_vblank_start; |
| 905 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
| 906 | vbl_start = DIV_ROUND_UP(vbl_start, 2); |
Ville Syrjälä | 391f75e | 2013-09-25 19:55:26 +0300 | [diff] [blame] | 907 | |
Ville Syrjälä | 0b2a8e0 | 2014-04-29 13:35:50 +0300 | [diff] [blame] | 908 | /* Convert to pixel count */ |
| 909 | vbl_start *= htotal; |
| 910 | |
| 911 | /* Start of vblank event occurs at start of hsync */ |
| 912 | vbl_start -= htotal - hsync_start; |
| 913 | |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 914 | high_frame = PIPEFRAME(pipe); |
| 915 | low_frame = PIPEFRAMEPIXEL(pipe); |
Chris Wilson | 5eddb70 | 2010-09-11 13:48:45 +0100 | [diff] [blame] | 916 | |
Ville Syrjälä | 694e409 | 2017-03-09 17:44:30 +0200 | [diff] [blame] | 917 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
| 918 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 919 | /* |
| 920 | * High & low register fields aren't synchronized, so make sure |
| 921 | * we get a low value that's stable across two reads of the high |
| 922 | * register. |
| 923 | */ |
| 924 | do { |
Ville Syrjälä | 694e409 | 2017-03-09 17:44:30 +0200 | [diff] [blame] | 925 | high1 = I915_READ_FW(high_frame) & PIPE_FRAME_HIGH_MASK; |
| 926 | low = I915_READ_FW(low_frame); |
| 927 | high2 = I915_READ_FW(high_frame) & PIPE_FRAME_HIGH_MASK; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 928 | } while (high1 != high2); |
| 929 | |
Ville Syrjälä | 694e409 | 2017-03-09 17:44:30 +0200 | [diff] [blame] | 930 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
| 931 | |
Chris Wilson | 5eddb70 | 2010-09-11 13:48:45 +0100 | [diff] [blame] | 932 | high1 >>= PIPE_FRAME_HIGH_SHIFT; |
Ville Syrjälä | 391f75e | 2013-09-25 19:55:26 +0300 | [diff] [blame] | 933 | pixel = low & PIPE_PIXEL_MASK; |
Chris Wilson | 5eddb70 | 2010-09-11 13:48:45 +0100 | [diff] [blame] | 934 | low >>= PIPE_FRAME_LOW_SHIFT; |
Ville Syrjälä | 391f75e | 2013-09-25 19:55:26 +0300 | [diff] [blame] | 935 | |
| 936 | /* |
| 937 | * The frame counter increments at beginning of active. |
| 938 | * Cook up a vblank counter by also checking the pixel |
| 939 | * counter against vblank start. |
| 940 | */ |
Ville Syrjälä | edc08d0 | 2013-11-06 13:56:27 -0200 | [diff] [blame] | 941 | return (((high1 << 8) | low) + (pixel >= vbl_start)) & 0xffffff; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 942 | } |
| 943 | |
Dave Airlie | 974e59b | 2015-10-30 09:45:33 +1000 | [diff] [blame] | 944 | static u32 g4x_get_vblank_counter(struct drm_device *dev, unsigned int pipe) |
Jesse Barnes | 9880b7a | 2009-02-06 10:22:41 -0800 | [diff] [blame] | 945 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 946 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | 9880b7a | 2009-02-06 10:22:41 -0800 | [diff] [blame] | 947 | |
Ville Syrjälä | 649636e | 2015-09-22 19:50:01 +0300 | [diff] [blame] | 948 | return I915_READ(PIPE_FRMCOUNT_G4X(pipe)); |
Jesse Barnes | 9880b7a | 2009-02-06 10:22:41 -0800 | [diff] [blame] | 949 | } |
| 950 | |
Uma Shankar | aec0246 | 2017-09-25 19:26:01 +0530 | [diff] [blame] | 951 | /* |
| 952 | * On certain encoders on certain platforms, pipe |
| 953 | * scanline register will not work to get the scanline, |
| 954 | * since the timings are driven from the PORT or issues |
| 955 | * with scanline register updates. |
| 956 | * This function will use Framestamp and current |
| 957 | * timestamp registers to calculate the scanline. |
| 958 | */ |
| 959 | static u32 __intel_get_crtc_scanline_from_timestamp(struct intel_crtc *crtc) |
| 960 | { |
| 961 | struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
| 962 | struct drm_vblank_crtc *vblank = |
| 963 | &crtc->base.dev->vblank[drm_crtc_index(&crtc->base)]; |
| 964 | const struct drm_display_mode *mode = &vblank->hwmode; |
| 965 | u32 vblank_start = mode->crtc_vblank_start; |
| 966 | u32 vtotal = mode->crtc_vtotal; |
| 967 | u32 htotal = mode->crtc_htotal; |
| 968 | u32 clock = mode->crtc_clock; |
| 969 | u32 scanline, scan_prev_time, scan_curr_time, scan_post_time; |
| 970 | |
| 971 | /* |
| 972 | * To avoid the race condition where we might cross into the |
| 973 | * next vblank just between the PIPE_FRMTMSTMP and TIMESTAMP_CTR |
| 974 | * reads. We make sure we read PIPE_FRMTMSTMP and TIMESTAMP_CTR |
| 975 | * during the same frame. |
| 976 | */ |
| 977 | do { |
| 978 | /* |
| 979 | * This field provides read back of the display |
| 980 | * pipe frame time stamp. The time stamp value |
| 981 | * is sampled at every start of vertical blank. |
| 982 | */ |
| 983 | scan_prev_time = I915_READ_FW(PIPE_FRMTMSTMP(crtc->pipe)); |
| 984 | |
| 985 | /* |
| 986 | * The TIMESTAMP_CTR register has the current |
| 987 | * time stamp value. |
| 988 | */ |
| 989 | scan_curr_time = I915_READ_FW(IVB_TIMESTAMP_CTR); |
| 990 | |
| 991 | scan_post_time = I915_READ_FW(PIPE_FRMTMSTMP(crtc->pipe)); |
| 992 | } while (scan_post_time != scan_prev_time); |
| 993 | |
| 994 | scanline = div_u64(mul_u32_u32(scan_curr_time - scan_prev_time, |
| 995 | clock), 1000 * htotal); |
| 996 | scanline = min(scanline, vtotal - 1); |
| 997 | scanline = (scanline + vblank_start) % vtotal; |
| 998 | |
| 999 | return scanline; |
| 1000 | } |
| 1001 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1002 | /* I915_READ_FW, only for fast reads of display block, no need for forcewake etc. */ |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1003 | static int __intel_get_crtc_scanline(struct intel_crtc *crtc) |
| 1004 | { |
| 1005 | struct drm_device *dev = crtc->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1006 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 5caa0fe | 2017-05-09 16:03:29 +0200 | [diff] [blame] | 1007 | const struct drm_display_mode *mode; |
| 1008 | struct drm_vblank_crtc *vblank; |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1009 | enum pipe pipe = crtc->pipe; |
Ville Syrjälä | 80715b2 | 2014-05-15 20:23:23 +0300 | [diff] [blame] | 1010 | int position, vtotal; |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1011 | |
Ville Syrjälä | 7225953 | 2017-03-02 19:15:05 +0200 | [diff] [blame] | 1012 | if (!crtc->active) |
| 1013 | return -1; |
| 1014 | |
Daniel Vetter | 5caa0fe | 2017-05-09 16:03:29 +0200 | [diff] [blame] | 1015 | vblank = &crtc->base.dev->vblank[drm_crtc_index(&crtc->base)]; |
| 1016 | mode = &vblank->hwmode; |
| 1017 | |
Uma Shankar | aec0246 | 2017-09-25 19:26:01 +0530 | [diff] [blame] | 1018 | if (mode->private_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP) |
| 1019 | return __intel_get_crtc_scanline_from_timestamp(crtc); |
| 1020 | |
Ville Syrjälä | 80715b2 | 2014-05-15 20:23:23 +0300 | [diff] [blame] | 1021 | vtotal = mode->crtc_vtotal; |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1022 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
| 1023 | vtotal /= 2; |
| 1024 | |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 1025 | if (IS_GEN(dev_priv, 2)) |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1026 | position = I915_READ_FW(PIPEDSL(pipe)) & DSL_LINEMASK_GEN2; |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1027 | else |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1028 | position = I915_READ_FW(PIPEDSL(pipe)) & DSL_LINEMASK_GEN3; |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1029 | |
| 1030 | /* |
Jesse Barnes | 41b578f | 2015-09-22 12:15:54 -0700 | [diff] [blame] | 1031 | * On HSW, the DSL reg (0x70000) appears to return 0 if we |
| 1032 | * read it just before the start of vblank. So try it again |
| 1033 | * so we don't accidentally end up spanning a vblank frame |
| 1034 | * increment, causing the pipe_update_end() code to squak at us. |
| 1035 | * |
| 1036 | * The nature of this problem means we can't simply check the ISR |
| 1037 | * bit and return the vblank start value; nor can we use the scanline |
| 1038 | * debug register in the transcoder as it appears to have the same |
| 1039 | * problem. We may need to extend this to include other platforms, |
| 1040 | * but so far testing only shows the problem on HSW. |
| 1041 | */ |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1042 | if (HAS_DDI(dev_priv) && !position) { |
Jesse Barnes | 41b578f | 2015-09-22 12:15:54 -0700 | [diff] [blame] | 1043 | int i, temp; |
| 1044 | |
| 1045 | for (i = 0; i < 100; i++) { |
| 1046 | udelay(1); |
Ville Syrjälä | 707bdd3 | 2017-03-09 17:44:31 +0200 | [diff] [blame] | 1047 | temp = I915_READ_FW(PIPEDSL(pipe)) & DSL_LINEMASK_GEN3; |
Jesse Barnes | 41b578f | 2015-09-22 12:15:54 -0700 | [diff] [blame] | 1048 | if (temp != position) { |
| 1049 | position = temp; |
| 1050 | break; |
| 1051 | } |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | /* |
Ville Syrjälä | 80715b2 | 2014-05-15 20:23:23 +0300 | [diff] [blame] | 1056 | * See update_scanline_offset() for the details on the |
| 1057 | * scanline_offset adjustment. |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1058 | */ |
Ville Syrjälä | 80715b2 | 2014-05-15 20:23:23 +0300 | [diff] [blame] | 1059 | return (position + crtc->scanline_offset) % vtotal; |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1060 | } |
| 1061 | |
Daniel Vetter | 1bf6ad6 | 2017-05-09 16:03:28 +0200 | [diff] [blame] | 1062 | static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, |
| 1063 | bool in_vblank_irq, int *vpos, int *hpos, |
| 1064 | ktime_t *stime, ktime_t *etime, |
| 1065 | const struct drm_display_mode *mode) |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 1066 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1067 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 9818783 | 2016-10-31 22:37:10 +0200 | [diff] [blame] | 1068 | struct intel_crtc *intel_crtc = intel_get_crtc_for_pipe(dev_priv, |
| 1069 | pipe); |
Ville Syrjälä | 3aa18df | 2013-10-11 19:10:32 +0300 | [diff] [blame] | 1070 | int position; |
Ville Syrjälä | 78e8fc6 | 2014-04-29 13:35:44 +0300 | [diff] [blame] | 1071 | int vbl_start, vbl_end, hsync_start, htotal, vtotal; |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 1072 | unsigned long irqflags; |
Ville Syrjälä | 8a920e2 | 2019-01-25 20:19:31 +0200 | [diff] [blame] | 1073 | bool use_scanline_counter = INTEL_GEN(dev_priv) >= 5 || |
| 1074 | IS_G4X(dev_priv) || IS_GEN(dev_priv, 2) || |
| 1075 | mode->private_flags & I915_MODE_FLAG_USE_SCANLINE_COUNTER; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 1076 | |
Maarten Lankhorst | fc467a22 | 2015-06-01 12:50:07 +0200 | [diff] [blame] | 1077 | if (WARN_ON(!mode->crtc_clock)) { |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 1078 | DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled " |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 1079 | "pipe %c\n", pipe_name(pipe)); |
Daniel Vetter | 1bf6ad6 | 2017-05-09 16:03:28 +0200 | [diff] [blame] | 1080 | return false; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 1081 | } |
| 1082 | |
Ville Syrjälä | c2baf4b | 2013-09-23 14:48:50 +0300 | [diff] [blame] | 1083 | htotal = mode->crtc_htotal; |
Ville Syrjälä | 78e8fc6 | 2014-04-29 13:35:44 +0300 | [diff] [blame] | 1084 | hsync_start = mode->crtc_hsync_start; |
Ville Syrjälä | c2baf4b | 2013-09-23 14:48:50 +0300 | [diff] [blame] | 1085 | vtotal = mode->crtc_vtotal; |
| 1086 | vbl_start = mode->crtc_vblank_start; |
| 1087 | vbl_end = mode->crtc_vblank_end; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 1088 | |
Ville Syrjälä | d31faf6 | 2013-10-28 16:31:41 +0200 | [diff] [blame] | 1089 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { |
| 1090 | vbl_start = DIV_ROUND_UP(vbl_start, 2); |
| 1091 | vbl_end /= 2; |
| 1092 | vtotal /= 2; |
| 1093 | } |
| 1094 | |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 1095 | /* |
| 1096 | * Lock uncore.lock, as we will do multiple timing critical raw |
| 1097 | * register reads, potentially with preemption disabled, so the |
| 1098 | * following code must not block on uncore.lock. |
| 1099 | */ |
| 1100 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
Ville Syrjälä | 78e8fc6 | 2014-04-29 13:35:44 +0300 | [diff] [blame] | 1101 | |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 1102 | /* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */ |
| 1103 | |
| 1104 | /* Get optional system timestamp before query. */ |
| 1105 | if (stime) |
| 1106 | *stime = ktime_get(); |
| 1107 | |
Ville Syrjälä | 8a920e2 | 2019-01-25 20:19:31 +0200 | [diff] [blame] | 1108 | if (use_scanline_counter) { |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 1109 | /* No obvious pixelcount register. Only query vertical |
| 1110 | * scanout position from Display scan line register. |
| 1111 | */ |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1112 | position = __intel_get_crtc_scanline(intel_crtc); |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 1113 | } else { |
| 1114 | /* Have access to pixelcount since start of frame. |
| 1115 | * We can split this into vertical and horizontal |
| 1116 | * scanout position. |
| 1117 | */ |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1118 | position = (I915_READ_FW(PIPEFRAMEPIXEL(pipe)) & PIPE_PIXEL_MASK) >> PIPE_PIXEL_SHIFT; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 1119 | |
Ville Syrjälä | 3aa18df | 2013-10-11 19:10:32 +0300 | [diff] [blame] | 1120 | /* convert to pixel counts */ |
| 1121 | vbl_start *= htotal; |
| 1122 | vbl_end *= htotal; |
| 1123 | vtotal *= htotal; |
Ville Syrjälä | 78e8fc6 | 2014-04-29 13:35:44 +0300 | [diff] [blame] | 1124 | |
| 1125 | /* |
Ville Syrjälä | 7e78f1cb | 2014-04-29 13:35:49 +0300 | [diff] [blame] | 1126 | * In interlaced modes, the pixel counter counts all pixels, |
| 1127 | * so one field will have htotal more pixels. In order to avoid |
| 1128 | * the reported position from jumping backwards when the pixel |
| 1129 | * counter is beyond the length of the shorter field, just |
| 1130 | * clamp the position the length of the shorter field. This |
| 1131 | * matches how the scanline counter based position works since |
| 1132 | * the scanline counter doesn't count the two half lines. |
| 1133 | */ |
| 1134 | if (position >= vtotal) |
| 1135 | position = vtotal - 1; |
| 1136 | |
| 1137 | /* |
Ville Syrjälä | 78e8fc6 | 2014-04-29 13:35:44 +0300 | [diff] [blame] | 1138 | * Start of vblank interrupt is triggered at start of hsync, |
| 1139 | * just prior to the first active line of vblank. However we |
| 1140 | * consider lines to start at the leading edge of horizontal |
| 1141 | * active. So, should we get here before we've crossed into |
| 1142 | * the horizontal active of the first line in vblank, we would |
| 1143 | * not set the DRM_SCANOUTPOS_INVBL flag. In order to fix that, |
| 1144 | * always add htotal-hsync_start to the current pixel position. |
| 1145 | */ |
| 1146 | position = (position + htotal - hsync_start) % vtotal; |
Ville Syrjälä | 3aa18df | 2013-10-11 19:10:32 +0300 | [diff] [blame] | 1147 | } |
| 1148 | |
Mario Kleiner | ad3543e | 2013-10-30 05:13:08 +0100 | [diff] [blame] | 1149 | /* Get optional system timestamp after query. */ |
| 1150 | if (etime) |
| 1151 | *etime = ktime_get(); |
| 1152 | |
| 1153 | /* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */ |
| 1154 | |
| 1155 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
| 1156 | |
Ville Syrjälä | 3aa18df | 2013-10-11 19:10:32 +0300 | [diff] [blame] | 1157 | /* |
| 1158 | * While in vblank, position will be negative |
| 1159 | * counting up towards 0 at vbl_end. And outside |
| 1160 | * vblank, position will be positive counting |
| 1161 | * up since vbl_end. |
| 1162 | */ |
| 1163 | if (position >= vbl_start) |
| 1164 | position -= vbl_end; |
| 1165 | else |
| 1166 | position += vtotal - vbl_end; |
| 1167 | |
Ville Syrjälä | 8a920e2 | 2019-01-25 20:19:31 +0200 | [diff] [blame] | 1168 | if (use_scanline_counter) { |
Ville Syrjälä | 3aa18df | 2013-10-11 19:10:32 +0300 | [diff] [blame] | 1169 | *vpos = position; |
| 1170 | *hpos = 0; |
| 1171 | } else { |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 1172 | *vpos = position / htotal; |
| 1173 | *hpos = position - (*vpos * htotal); |
| 1174 | } |
| 1175 | |
Daniel Vetter | 1bf6ad6 | 2017-05-09 16:03:28 +0200 | [diff] [blame] | 1176 | return true; |
Mario Kleiner | 0af7e4d | 2010-12-08 04:07:19 +0100 | [diff] [blame] | 1177 | } |
| 1178 | |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1179 | int intel_get_crtc_scanline(struct intel_crtc *crtc) |
| 1180 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1181 | struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
Ville Syrjälä | a225f07 | 2014-04-29 13:35:45 +0300 | [diff] [blame] | 1182 | unsigned long irqflags; |
| 1183 | int position; |
| 1184 | |
| 1185 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
| 1186 | position = __intel_get_crtc_scanline(crtc); |
| 1187 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
| 1188 | |
| 1189 | return position; |
| 1190 | } |
| 1191 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1192 | static void ironlake_rps_change_irq_handler(struct drm_i915_private *dev_priv) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1193 | { |
Matthew Garrett | b5b72e8 | 2010-02-02 18:30:47 +0000 | [diff] [blame] | 1194 | u32 busy_up, busy_down, max_avg, min_avg; |
Daniel Vetter | 9270388 | 2012-08-09 16:46:01 +0200 | [diff] [blame] | 1195 | u8 new_delay; |
Daniel Vetter | 9270388 | 2012-08-09 16:46:01 +0200 | [diff] [blame] | 1196 | |
Daniel Vetter | d0ecd7e | 2013-07-04 23:35:25 +0200 | [diff] [blame] | 1197 | spin_lock(&mchdev_lock); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1198 | |
Daniel Vetter | 73edd18f | 2012-08-08 23:35:37 +0200 | [diff] [blame] | 1199 | I915_WRITE16(MEMINTRSTS, I915_READ(MEMINTRSTS)); |
| 1200 | |
Daniel Vetter | 20e4d40 | 2012-08-08 23:35:39 +0200 | [diff] [blame] | 1201 | new_delay = dev_priv->ips.cur_delay; |
Daniel Vetter | 9270388 | 2012-08-09 16:46:01 +0200 | [diff] [blame] | 1202 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1203 | I915_WRITE16(MEMINTRSTS, MEMINT_EVAL_CHG); |
Matthew Garrett | b5b72e8 | 2010-02-02 18:30:47 +0000 | [diff] [blame] | 1204 | busy_up = I915_READ(RCPREVBSYTUPAVG); |
| 1205 | busy_down = I915_READ(RCPREVBSYTDNAVG); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1206 | max_avg = I915_READ(RCBMAXAVG); |
| 1207 | min_avg = I915_READ(RCBMINAVG); |
| 1208 | |
| 1209 | /* Handle RCS change request from hw */ |
Matthew Garrett | b5b72e8 | 2010-02-02 18:30:47 +0000 | [diff] [blame] | 1210 | if (busy_up > max_avg) { |
Daniel Vetter | 20e4d40 | 2012-08-08 23:35:39 +0200 | [diff] [blame] | 1211 | if (dev_priv->ips.cur_delay != dev_priv->ips.max_delay) |
| 1212 | new_delay = dev_priv->ips.cur_delay - 1; |
| 1213 | if (new_delay < dev_priv->ips.max_delay) |
| 1214 | new_delay = dev_priv->ips.max_delay; |
Matthew Garrett | b5b72e8 | 2010-02-02 18:30:47 +0000 | [diff] [blame] | 1215 | } else if (busy_down < min_avg) { |
Daniel Vetter | 20e4d40 | 2012-08-08 23:35:39 +0200 | [diff] [blame] | 1216 | if (dev_priv->ips.cur_delay != dev_priv->ips.min_delay) |
| 1217 | new_delay = dev_priv->ips.cur_delay + 1; |
| 1218 | if (new_delay > dev_priv->ips.min_delay) |
| 1219 | new_delay = dev_priv->ips.min_delay; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1220 | } |
| 1221 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1222 | if (ironlake_set_drps(dev_priv, new_delay)) |
Daniel Vetter | 20e4d40 | 2012-08-08 23:35:39 +0200 | [diff] [blame] | 1223 | dev_priv->ips.cur_delay = new_delay; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1224 | |
Daniel Vetter | d0ecd7e | 2013-07-04 23:35:25 +0200 | [diff] [blame] | 1225 | spin_unlock(&mchdev_lock); |
Daniel Vetter | 9270388 | 2012-08-09 16:46:01 +0200 | [diff] [blame] | 1226 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1227 | return; |
| 1228 | } |
| 1229 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1230 | static void vlv_c0_read(struct drm_i915_private *dev_priv, |
| 1231 | struct intel_rps_ei *ei) |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1232 | { |
Mika Kuoppala | 679cb6c | 2017-03-15 17:43:03 +0200 | [diff] [blame] | 1233 | ei->ktime = ktime_get_raw(); |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1234 | ei->render_c0 = I915_READ(VLV_RENDER_C0_COUNT); |
| 1235 | ei->media_c0 = I915_READ(VLV_MEDIA_C0_COUNT); |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1236 | } |
| 1237 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1238 | void gen6_rps_reset_ei(struct drm_i915_private *dev_priv) |
| 1239 | { |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1240 | memset(&dev_priv->gt_pm.rps.ei, 0, sizeof(dev_priv->gt_pm.rps.ei)); |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1241 | } |
| 1242 | |
| 1243 | static u32 vlv_wa_c0_ei(struct drm_i915_private *dev_priv, u32 pm_iir) |
| 1244 | { |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1245 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
| 1246 | const struct intel_rps_ei *prev = &rps->ei; |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1247 | struct intel_rps_ei now; |
| 1248 | u32 events = 0; |
| 1249 | |
Chris Wilson | e0e8c7c | 2017-03-09 21:12:30 +0000 | [diff] [blame] | 1250 | if ((pm_iir & GEN6_PM_RP_UP_EI_EXPIRED) == 0) |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1251 | return 0; |
| 1252 | |
| 1253 | vlv_c0_read(dev_priv, &now); |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1254 | |
Mika Kuoppala | 679cb6c | 2017-03-15 17:43:03 +0200 | [diff] [blame] | 1255 | if (prev->ktime) { |
Chris Wilson | e0e8c7c | 2017-03-09 21:12:30 +0000 | [diff] [blame] | 1256 | u64 time, c0; |
Chris Wilson | 569884e | 2017-03-09 21:12:31 +0000 | [diff] [blame] | 1257 | u32 render, media; |
Chris Wilson | e0e8c7c | 2017-03-09 21:12:30 +0000 | [diff] [blame] | 1258 | |
Mika Kuoppala | 679cb6c | 2017-03-15 17:43:03 +0200 | [diff] [blame] | 1259 | time = ktime_us_delta(now.ktime, prev->ktime); |
Chris Wilson | 8f68d59 | 2017-03-13 17:06:17 +0000 | [diff] [blame] | 1260 | |
Chris Wilson | e0e8c7c | 2017-03-09 21:12:30 +0000 | [diff] [blame] | 1261 | time *= dev_priv->czclk_freq; |
| 1262 | |
| 1263 | /* Workload can be split between render + media, |
| 1264 | * e.g. SwapBuffers being blitted in X after being rendered in |
| 1265 | * mesa. To account for this we need to combine both engines |
| 1266 | * into our activity counter. |
| 1267 | */ |
Chris Wilson | 569884e | 2017-03-09 21:12:31 +0000 | [diff] [blame] | 1268 | render = now.render_c0 - prev->render_c0; |
| 1269 | media = now.media_c0 - prev->media_c0; |
| 1270 | c0 = max(render, media); |
Mika Kuoppala | 6b7f6aa | 2017-03-15 18:12:59 +0200 | [diff] [blame] | 1271 | c0 *= 1000 * 100 << 8; /* to usecs and scale to threshold% */ |
Chris Wilson | e0e8c7c | 2017-03-09 21:12:30 +0000 | [diff] [blame] | 1272 | |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1273 | if (c0 > time * rps->power.up_threshold) |
Chris Wilson | e0e8c7c | 2017-03-09 21:12:30 +0000 | [diff] [blame] | 1274 | events = GEN6_PM_RP_UP_THRESHOLD; |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1275 | else if (c0 < time * rps->power.down_threshold) |
Chris Wilson | e0e8c7c | 2017-03-09 21:12:30 +0000 | [diff] [blame] | 1276 | events = GEN6_PM_RP_DOWN_THRESHOLD; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1277 | } |
| 1278 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1279 | rps->ei = now; |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1280 | return events; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 1281 | } |
| 1282 | |
Ben Widawsky | 4912d04 | 2011-04-25 11:25:20 -0700 | [diff] [blame] | 1283 | static void gen6_pm_rps_work(struct work_struct *work) |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1284 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 1285 | struct drm_i915_private *dev_priv = |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1286 | container_of(work, struct drm_i915_private, gt_pm.rps.work); |
| 1287 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | 7c0a16a | 2017-03-09 21:12:32 +0000 | [diff] [blame] | 1288 | bool client_boost = false; |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 1289 | int new_delay, adj, min, max; |
Chris Wilson | 7c0a16a | 2017-03-09 21:12:32 +0000 | [diff] [blame] | 1290 | u32 pm_iir = 0; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1291 | |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1292 | spin_lock_irq(&dev_priv->irq_lock); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1293 | if (rps->interrupts_enabled) { |
| 1294 | pm_iir = fetch_and_zero(&rps->pm_iir); |
| 1295 | client_boost = atomic_read(&rps->num_waiters); |
Imre Deak | d4d70aa | 2014-11-19 15:30:04 +0200 | [diff] [blame] | 1296 | } |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1297 | spin_unlock_irq(&dev_priv->irq_lock); |
Ben Widawsky | 4912d04 | 2011-04-25 11:25:20 -0700 | [diff] [blame] | 1298 | |
Paulo Zanoni | 60611c1 | 2013-08-15 11:50:01 -0300 | [diff] [blame] | 1299 | /* 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] | 1300 | WARN_ON(pm_iir & ~dev_priv->pm_rps_events); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 1301 | if ((pm_iir & dev_priv->pm_rps_events) == 0 && !client_boost) |
Chris Wilson | 7c0a16a | 2017-03-09 21:12:32 +0000 | [diff] [blame] | 1302 | goto out; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1303 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1304 | mutex_lock(&dev_priv->pcu_lock); |
Chris Wilson | 7b9e0ae | 2012-04-28 08:56:39 +0100 | [diff] [blame] | 1305 | |
Chris Wilson | 43cf3bf | 2015-03-18 09:48:22 +0000 | [diff] [blame] | 1306 | pm_iir |= vlv_wa_c0_ei(dev_priv, pm_iir); |
| 1307 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1308 | adj = rps->last_adj; |
| 1309 | new_delay = rps->cur_freq; |
| 1310 | min = rps->min_freq_softlimit; |
| 1311 | max = rps->max_freq_softlimit; |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 1312 | if (client_boost) |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1313 | max = rps->max_freq; |
| 1314 | if (client_boost && new_delay < rps->boost_freq) { |
| 1315 | new_delay = rps->boost_freq; |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 1316 | adj = 0; |
| 1317 | } else if (pm_iir & GEN6_PM_RP_UP_THRESHOLD) { |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1318 | if (adj > 0) |
| 1319 | adj *= 2; |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1320 | else /* CHV needs even encode values */ |
| 1321 | adj = IS_CHERRYVIEW(dev_priv) ? 2 : 1; |
Sagar Arun Kamble | 7e79a68 | 2017-01-20 09:18:24 +0530 | [diff] [blame] | 1322 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1323 | if (new_delay >= rps->max_freq_softlimit) |
Sagar Arun Kamble | 7e79a68 | 2017-01-20 09:18:24 +0530 | [diff] [blame] | 1324 | adj = 0; |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 1325 | } else if (client_boost) { |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 1326 | adj = 0; |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1327 | } else if (pm_iir & GEN6_PM_RP_DOWN_TIMEOUT) { |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1328 | if (rps->cur_freq > rps->efficient_freq) |
| 1329 | new_delay = rps->efficient_freq; |
| 1330 | else if (rps->cur_freq > rps->min_freq_softlimit) |
| 1331 | new_delay = rps->min_freq_softlimit; |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1332 | adj = 0; |
| 1333 | } else if (pm_iir & GEN6_PM_RP_DOWN_THRESHOLD) { |
| 1334 | if (adj < 0) |
| 1335 | adj *= 2; |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1336 | else /* CHV needs even encode values */ |
| 1337 | adj = IS_CHERRYVIEW(dev_priv) ? -2 : -1; |
Sagar Arun Kamble | 7e79a68 | 2017-01-20 09:18:24 +0530 | [diff] [blame] | 1338 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1339 | if (new_delay <= rps->min_freq_softlimit) |
Sagar Arun Kamble | 7e79a68 | 2017-01-20 09:18:24 +0530 | [diff] [blame] | 1340 | adj = 0; |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1341 | } else { /* unknown event */ |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1342 | adj = 0; |
Chris Wilson | dd75fdc | 2013-09-25 17:34:57 +0100 | [diff] [blame] | 1343 | } |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1344 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1345 | rps->last_adj = adj; |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1346 | |
Chris Wilson | 2a8862d | 2019-02-19 12:22:03 +0000 | [diff] [blame] | 1347 | /* |
| 1348 | * Limit deboosting and boosting to keep ourselves at the extremes |
| 1349 | * when in the respective power modes (i.e. slowly decrease frequencies |
| 1350 | * while in the HIGH_POWER zone and slowly increase frequencies while |
| 1351 | * in the LOW_POWER zone). On idle, we will hit the timeout and drop |
| 1352 | * to the next level quickly, and conversely if busy we expect to |
| 1353 | * hit a waitboost and rapidly switch into max power. |
| 1354 | */ |
| 1355 | if ((adj < 0 && rps->power.mode == HIGH_POWER) || |
| 1356 | (adj > 0 && rps->power.mode == LOW_POWER)) |
| 1357 | rps->last_adj = 0; |
| 1358 | |
Ben Widawsky | 7924963 | 2012-09-07 19:43:42 -0700 | [diff] [blame] | 1359 | /* sysfs frequency interfaces may have snuck in while servicing the |
| 1360 | * interrupt |
| 1361 | */ |
Chris Wilson | edcf284 | 2015-04-07 16:20:29 +0100 | [diff] [blame] | 1362 | new_delay += adj; |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 1363 | new_delay = clamp_t(int, new_delay, min, max); |
Deepak S | 2754436 | 2014-01-27 21:35:05 +0530 | [diff] [blame] | 1364 | |
Chris Wilson | 9fcee2f | 2017-01-26 10:19:19 +0000 | [diff] [blame] | 1365 | if (intel_set_rps(dev_priv, new_delay)) { |
| 1366 | DRM_DEBUG_DRIVER("Failed to set new GPU frequency\n"); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1367 | rps->last_adj = 0; |
Chris Wilson | 9fcee2f | 2017-01-26 10:19:19 +0000 | [diff] [blame] | 1368 | } |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1369 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1370 | mutex_unlock(&dev_priv->pcu_lock); |
Chris Wilson | 7c0a16a | 2017-03-09 21:12:32 +0000 | [diff] [blame] | 1371 | |
| 1372 | out: |
| 1373 | /* Make sure not to corrupt PMIMR state used by ringbuffer on GEN6 */ |
| 1374 | spin_lock_irq(&dev_priv->irq_lock); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1375 | if (rps->interrupts_enabled) |
Chris Wilson | 7c0a16a | 2017-03-09 21:12:32 +0000 | [diff] [blame] | 1376 | gen6_unmask_pm_irq(dev_priv, dev_priv->pm_rps_events); |
| 1377 | spin_unlock_irq(&dev_priv->irq_lock); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1378 | } |
| 1379 | |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1380 | |
| 1381 | /** |
| 1382 | * ivybridge_parity_work - Workqueue called when a parity error interrupt |
| 1383 | * occurred. |
| 1384 | * @work: workqueue struct |
| 1385 | * |
| 1386 | * Doesn't actually do anything except notify userspace. As a consequence of |
| 1387 | * this event, userspace should try to remap the bad rows since statistically |
| 1388 | * it is likely the same row is more likely to go bad again. |
| 1389 | */ |
| 1390 | static void ivybridge_parity_work(struct work_struct *work) |
| 1391 | { |
Jani Nikula | 2d1013d | 2014-03-31 14:27:17 +0300 | [diff] [blame] | 1392 | struct drm_i915_private *dev_priv = |
Joonas Lahtinen | cefcff8 | 2017-04-28 10:58:39 +0300 | [diff] [blame] | 1393 | container_of(work, typeof(*dev_priv), l3_parity.error_work); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1394 | u32 error_status, row, bank, subbank; |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1395 | char *parity_event[6]; |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 1396 | u32 misccpctl; |
| 1397 | u8 slice = 0; |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1398 | |
| 1399 | /* We must turn off DOP level clock gating to access the L3 registers. |
| 1400 | * In order to prevent a get/put style interface, acquire struct mutex |
| 1401 | * any time we access those registers. |
| 1402 | */ |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 1403 | mutex_lock(&dev_priv->drm.struct_mutex); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1404 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1405 | /* If we've screwed up tracking, just let the interrupt fire again */ |
| 1406 | if (WARN_ON(!dev_priv->l3_parity.which_slice)) |
| 1407 | goto out; |
| 1408 | |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1409 | misccpctl = I915_READ(GEN7_MISCCPCTL); |
| 1410 | I915_WRITE(GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE); |
| 1411 | POSTING_READ(GEN7_MISCCPCTL); |
| 1412 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1413 | while ((slice = ffs(dev_priv->l3_parity.which_slice)) != 0) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1414 | i915_reg_t reg; |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1415 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1416 | slice--; |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 1417 | if (WARN_ON_ONCE(slice >= NUM_L3_SLICES(dev_priv))) |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1418 | break; |
| 1419 | |
| 1420 | dev_priv->l3_parity.which_slice &= ~(1<<slice); |
| 1421 | |
Ville Syrjälä | 6fa1c5f | 2015-11-04 23:20:02 +0200 | [diff] [blame] | 1422 | reg = GEN7_L3CDERRST1(slice); |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1423 | |
| 1424 | error_status = I915_READ(reg); |
| 1425 | row = GEN7_PARITY_ERROR_ROW(error_status); |
| 1426 | bank = GEN7_PARITY_ERROR_BANK(error_status); |
| 1427 | subbank = GEN7_PARITY_ERROR_SUBBANK(error_status); |
| 1428 | |
| 1429 | I915_WRITE(reg, GEN7_PARITY_ERROR_VALID | GEN7_L3CDERRST1_ENABLE); |
| 1430 | POSTING_READ(reg); |
| 1431 | |
| 1432 | parity_event[0] = I915_L3_PARITY_UEVENT "=1"; |
| 1433 | parity_event[1] = kasprintf(GFP_KERNEL, "ROW=%d", row); |
| 1434 | parity_event[2] = kasprintf(GFP_KERNEL, "BANK=%d", bank); |
| 1435 | parity_event[3] = kasprintf(GFP_KERNEL, "SUBBANK=%d", subbank); |
| 1436 | parity_event[4] = kasprintf(GFP_KERNEL, "SLICE=%d", slice); |
| 1437 | parity_event[5] = NULL; |
| 1438 | |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 1439 | kobject_uevent_env(&dev_priv->drm.primary->kdev->kobj, |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1440 | KOBJ_CHANGE, parity_event); |
| 1441 | |
| 1442 | DRM_DEBUG("Parity error: Slice = %d, Row = %d, Bank = %d, Sub bank = %d.\n", |
| 1443 | slice, row, bank, subbank); |
| 1444 | |
| 1445 | kfree(parity_event[4]); |
| 1446 | kfree(parity_event[3]); |
| 1447 | kfree(parity_event[2]); |
| 1448 | kfree(parity_event[1]); |
| 1449 | } |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1450 | |
| 1451 | I915_WRITE(GEN7_MISCCPCTL, misccpctl); |
| 1452 | |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1453 | out: |
| 1454 | WARN_ON(dev_priv->l3_parity.which_slice); |
Daniel Vetter | 4cb2183 | 2014-09-15 14:55:26 +0200 | [diff] [blame] | 1455 | spin_lock_irq(&dev_priv->irq_lock); |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 1456 | gen5_enable_gt_irq(dev_priv, GT_PARITY_ERROR(dev_priv)); |
Daniel Vetter | 4cb2183 | 2014-09-15 14:55:26 +0200 | [diff] [blame] | 1457 | spin_unlock_irq(&dev_priv->irq_lock); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1458 | |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 1459 | mutex_unlock(&dev_priv->drm.struct_mutex); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1460 | } |
| 1461 | |
Ville Syrjälä | 261e40b | 2016-04-13 21:19:57 +0300 | [diff] [blame] | 1462 | static void ivybridge_parity_error_irq_handler(struct drm_i915_private *dev_priv, |
| 1463 | u32 iir) |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1464 | { |
Ville Syrjälä | 261e40b | 2016-04-13 21:19:57 +0300 | [diff] [blame] | 1465 | if (!HAS_L3_DPF(dev_priv)) |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1466 | return; |
| 1467 | |
Daniel Vetter | d0ecd7e | 2013-07-04 23:35:25 +0200 | [diff] [blame] | 1468 | spin_lock(&dev_priv->irq_lock); |
Ville Syrjälä | 261e40b | 2016-04-13 21:19:57 +0300 | [diff] [blame] | 1469 | gen5_disable_gt_irq(dev_priv, GT_PARITY_ERROR(dev_priv)); |
Daniel Vetter | d0ecd7e | 2013-07-04 23:35:25 +0200 | [diff] [blame] | 1470 | spin_unlock(&dev_priv->irq_lock); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1471 | |
Ville Syrjälä | 261e40b | 2016-04-13 21:19:57 +0300 | [diff] [blame] | 1472 | iir &= GT_PARITY_ERROR(dev_priv); |
Ben Widawsky | 35a85ac | 2013-09-19 11:13:41 -0700 | [diff] [blame] | 1473 | if (iir & GT_RENDER_L3_PARITY_ERROR_INTERRUPT_S1) |
| 1474 | dev_priv->l3_parity.which_slice |= 1 << 1; |
| 1475 | |
| 1476 | if (iir & GT_RENDER_L3_PARITY_ERROR_INTERRUPT) |
| 1477 | dev_priv->l3_parity.which_slice |= 1 << 0; |
| 1478 | |
Daniel Vetter | a4da4fa | 2012-11-02 19:55:07 +0100 | [diff] [blame] | 1479 | queue_work(dev_priv->wq, &dev_priv->l3_parity.error_work); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1480 | } |
| 1481 | |
Ville Syrjälä | 261e40b | 2016-04-13 21:19:57 +0300 | [diff] [blame] | 1482 | static void ilk_gt_irq_handler(struct drm_i915_private *dev_priv, |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 1483 | u32 gt_iir) |
| 1484 | { |
Chris Wilson | f8973c2 | 2016-07-01 17:23:21 +0100 | [diff] [blame] | 1485 | if (gt_iir & GT_RENDER_USER_INTERRUPT) |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1486 | intel_engine_breadcrumbs_irq(dev_priv->engine[RCS0]); |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 1487 | if (gt_iir & ILK_BSD_USER_INTERRUPT) |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1488 | intel_engine_breadcrumbs_irq(dev_priv->engine[VCS0]); |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 1489 | } |
| 1490 | |
Ville Syrjälä | 261e40b | 2016-04-13 21:19:57 +0300 | [diff] [blame] | 1491 | static void snb_gt_irq_handler(struct drm_i915_private *dev_priv, |
Daniel Vetter | e7b4c6b | 2012-03-30 20:24:35 +0200 | [diff] [blame] | 1492 | u32 gt_iir) |
| 1493 | { |
Chris Wilson | f8973c2 | 2016-07-01 17:23:21 +0100 | [diff] [blame] | 1494 | if (gt_iir & GT_RENDER_USER_INTERRUPT) |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1495 | intel_engine_breadcrumbs_irq(dev_priv->engine[RCS0]); |
Ben Widawsky | cc609d5 | 2013-05-28 19:22:29 -0700 | [diff] [blame] | 1496 | if (gt_iir & GT_BSD_USER_INTERRUPT) |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1497 | intel_engine_breadcrumbs_irq(dev_priv->engine[VCS0]); |
Ben Widawsky | cc609d5 | 2013-05-28 19:22:29 -0700 | [diff] [blame] | 1498 | if (gt_iir & GT_BLT_USER_INTERRUPT) |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1499 | intel_engine_breadcrumbs_irq(dev_priv->engine[BCS0]); |
Daniel Vetter | e7b4c6b | 2012-03-30 20:24:35 +0200 | [diff] [blame] | 1500 | |
Ben Widawsky | cc609d5 | 2013-05-28 19:22:29 -0700 | [diff] [blame] | 1501 | if (gt_iir & (GT_BLT_CS_ERROR_INTERRUPT | |
| 1502 | GT_BSD_CS_ERROR_INTERRUPT | |
Daniel Vetter | aaecdf6 | 2014-11-04 15:52:22 +0100 | [diff] [blame] | 1503 | GT_RENDER_CS_MASTER_ERROR_INTERRUPT)) |
| 1504 | DRM_DEBUG("Command parser error, gt_iir 0x%08x\n", gt_iir); |
Ben Widawsky | e368919 | 2012-05-25 16:56:22 -0700 | [diff] [blame] | 1505 | |
Ville Syrjälä | 261e40b | 2016-04-13 21:19:57 +0300 | [diff] [blame] | 1506 | if (gt_iir & GT_PARITY_ERROR(dev_priv)) |
| 1507 | ivybridge_parity_error_irq_handler(dev_priv, gt_iir); |
Daniel Vetter | e7b4c6b | 2012-03-30 20:24:35 +0200 | [diff] [blame] | 1508 | } |
| 1509 | |
Chris Wilson | 5d3d69d | 2017-05-17 13:10:06 +0100 | [diff] [blame] | 1510 | static void |
Chris Wilson | 51f6b0f | 2018-03-09 01:08:08 +0000 | [diff] [blame] | 1511 | gen8_cs_irq_handler(struct intel_engine_cs *engine, u32 iir) |
Nick Hoath | fbcc1a0 | 2015-10-20 10:23:52 +0100 | [diff] [blame] | 1512 | { |
Chris Wilson | 31de735 | 2017-03-16 12:56:18 +0000 | [diff] [blame] | 1513 | bool tasklet = false; |
Chris Wilson | f747026 | 2017-01-24 15:20:21 +0000 | [diff] [blame] | 1514 | |
Chris Wilson | fd8526e | 2018-06-28 21:12:10 +0100 | [diff] [blame] | 1515 | if (iir & GT_CONTEXT_SWITCH_INTERRUPT) |
| 1516 | tasklet = true; |
Chris Wilson | 31de735 | 2017-03-16 12:56:18 +0000 | [diff] [blame] | 1517 | |
Chris Wilson | 51f6b0f | 2018-03-09 01:08:08 +0000 | [diff] [blame] | 1518 | if (iir & GT_RENDER_USER_INTERRUPT) { |
Chris Wilson | 52c0fdb | 2019-01-29 20:52:29 +0000 | [diff] [blame] | 1519 | intel_engine_breadcrumbs_irq(engine); |
Chris Wilson | 4c6ce5c | 2019-03-29 15:49:12 +0000 | [diff] [blame] | 1520 | tasklet |= intel_engine_needs_breadcrumb_tasklet(engine); |
Chris Wilson | 31de735 | 2017-03-16 12:56:18 +0000 | [diff] [blame] | 1521 | } |
| 1522 | |
| 1523 | if (tasklet) |
Chris Wilson | fd8526e | 2018-06-28 21:12:10 +0100 | [diff] [blame] | 1524 | tasklet_hi_schedule(&engine->execlists.tasklet); |
Nick Hoath | fbcc1a0 | 2015-10-20 10:23:52 +0100 | [diff] [blame] | 1525 | } |
| 1526 | |
Chris Wilson | 2e4a5b2 | 2018-02-19 10:09:26 +0000 | [diff] [blame] | 1527 | static void gen8_gt_irq_ack(struct drm_i915_private *i915, |
Chris Wilson | 55ef72f | 2018-02-02 15:34:48 +0000 | [diff] [blame] | 1528 | u32 master_ctl, u32 gt_iir[4]) |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1529 | { |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 1530 | void __iomem * const regs = i915->uncore.regs; |
Chris Wilson | 2e4a5b2 | 2018-02-19 10:09:26 +0000 | [diff] [blame] | 1531 | |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 1532 | #define GEN8_GT_IRQS (GEN8_GT_RCS_IRQ | \ |
| 1533 | GEN8_GT_BCS_IRQ | \ |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1534 | GEN8_GT_VCS0_IRQ | \ |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 1535 | GEN8_GT_VCS1_IRQ | \ |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 1536 | GEN8_GT_VECS_IRQ | \ |
| 1537 | GEN8_GT_PM_IRQ | \ |
| 1538 | GEN8_GT_GUC_IRQ) |
| 1539 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1540 | if (master_ctl & (GEN8_GT_RCS_IRQ | GEN8_GT_BCS_IRQ)) { |
Chris Wilson | 2e4a5b2 | 2018-02-19 10:09:26 +0000 | [diff] [blame] | 1541 | gt_iir[0] = raw_reg_read(regs, GEN8_GT_IIR(0)); |
| 1542 | if (likely(gt_iir[0])) |
| 1543 | raw_reg_write(regs, GEN8_GT_IIR(0), gt_iir[0]); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1544 | } |
| 1545 | |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1546 | if (master_ctl & (GEN8_GT_VCS0_IRQ | GEN8_GT_VCS1_IRQ)) { |
Chris Wilson | 2e4a5b2 | 2018-02-19 10:09:26 +0000 | [diff] [blame] | 1547 | gt_iir[1] = raw_reg_read(regs, GEN8_GT_IIR(1)); |
| 1548 | if (likely(gt_iir[1])) |
| 1549 | raw_reg_write(regs, GEN8_GT_IIR(1), gt_iir[1]); |
Chris Wilson | 74cdb33 | 2015-04-07 16:21:05 +0100 | [diff] [blame] | 1550 | } |
| 1551 | |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 1552 | if (master_ctl & (GEN8_GT_PM_IRQ | GEN8_GT_GUC_IRQ)) { |
Chris Wilson | 2e4a5b2 | 2018-02-19 10:09:26 +0000 | [diff] [blame] | 1553 | gt_iir[2] = raw_reg_read(regs, GEN8_GT_IIR(2)); |
Chris Wilson | f4de779 | 2018-08-02 11:06:29 +0100 | [diff] [blame] | 1554 | if (likely(gt_iir[2])) |
| 1555 | raw_reg_write(regs, GEN8_GT_IIR(2), gt_iir[2]); |
Chris Wilson | 2e4a5b2 | 2018-02-19 10:09:26 +0000 | [diff] [blame] | 1556 | } |
| 1557 | |
| 1558 | if (master_ctl & GEN8_GT_VECS_IRQ) { |
| 1559 | gt_iir[3] = raw_reg_read(regs, GEN8_GT_IIR(3)); |
| 1560 | if (likely(gt_iir[3])) |
| 1561 | raw_reg_write(regs, GEN8_GT_IIR(3), gt_iir[3]); |
Ben Widawsky | 0961021 | 2014-05-15 20:58:08 +0300 | [diff] [blame] | 1562 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1563 | } |
| 1564 | |
Chris Wilson | 2e4a5b2 | 2018-02-19 10:09:26 +0000 | [diff] [blame] | 1565 | static void gen8_gt_irq_handler(struct drm_i915_private *i915, |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 1566 | u32 master_ctl, u32 gt_iir[4]) |
Ville Syrjälä | e30e251 | 2016-04-13 21:19:58 +0300 | [diff] [blame] | 1567 | { |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 1568 | if (master_ctl & (GEN8_GT_RCS_IRQ | GEN8_GT_BCS_IRQ)) { |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1569 | gen8_cs_irq_handler(i915->engine[RCS0], |
Chris Wilson | 51f6b0f | 2018-03-09 01:08:08 +0000 | [diff] [blame] | 1570 | gt_iir[0] >> GEN8_RCS_IRQ_SHIFT); |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1571 | gen8_cs_irq_handler(i915->engine[BCS0], |
Chris Wilson | 51f6b0f | 2018-03-09 01:08:08 +0000 | [diff] [blame] | 1572 | gt_iir[0] >> GEN8_BCS_IRQ_SHIFT); |
Ville Syrjälä | e30e251 | 2016-04-13 21:19:58 +0300 | [diff] [blame] | 1573 | } |
| 1574 | |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1575 | if (master_ctl & (GEN8_GT_VCS0_IRQ | GEN8_GT_VCS1_IRQ)) { |
| 1576 | gen8_cs_irq_handler(i915->engine[VCS0], |
| 1577 | gt_iir[1] >> GEN8_VCS0_IRQ_SHIFT); |
| 1578 | gen8_cs_irq_handler(i915->engine[VCS1], |
Chris Wilson | 51f6b0f | 2018-03-09 01:08:08 +0000 | [diff] [blame] | 1579 | gt_iir[1] >> GEN8_VCS1_IRQ_SHIFT); |
Ville Syrjälä | e30e251 | 2016-04-13 21:19:58 +0300 | [diff] [blame] | 1580 | } |
| 1581 | |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 1582 | if (master_ctl & GEN8_GT_VECS_IRQ) { |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1583 | gen8_cs_irq_handler(i915->engine[VECS0], |
Chris Wilson | 51f6b0f | 2018-03-09 01:08:08 +0000 | [diff] [blame] | 1584 | gt_iir[3] >> GEN8_VECS_IRQ_SHIFT); |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 1585 | } |
Ville Syrjälä | e30e251 | 2016-04-13 21:19:58 +0300 | [diff] [blame] | 1586 | |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 1587 | if (master_ctl & (GEN8_GT_PM_IRQ | GEN8_GT_GUC_IRQ)) { |
Chris Wilson | 2e4a5b2 | 2018-02-19 10:09:26 +0000 | [diff] [blame] | 1588 | gen6_rps_irq_handler(i915, gt_iir[2]); |
| 1589 | gen9_guc_irq_handler(i915, gt_iir[2]); |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 1590 | } |
Ville Syrjälä | e30e251 | 2016-04-13 21:19:58 +0300 | [diff] [blame] | 1591 | } |
| 1592 | |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1593 | static bool gen11_port_hotplug_long_detect(enum hpd_pin pin, u32 val) |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 1594 | { |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1595 | switch (pin) { |
| 1596 | case HPD_PORT_C: |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 1597 | return val & GEN11_HOTPLUG_CTL_LONG_DETECT(PORT_TC1); |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1598 | case HPD_PORT_D: |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 1599 | return val & GEN11_HOTPLUG_CTL_LONG_DETECT(PORT_TC2); |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1600 | case HPD_PORT_E: |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 1601 | return val & GEN11_HOTPLUG_CTL_LONG_DETECT(PORT_TC3); |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1602 | case HPD_PORT_F: |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 1603 | return val & GEN11_HOTPLUG_CTL_LONG_DETECT(PORT_TC4); |
| 1604 | default: |
| 1605 | return false; |
| 1606 | } |
| 1607 | } |
| 1608 | |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1609 | static bool bxt_port_hotplug_long_detect(enum hpd_pin pin, u32 val) |
Imre Deak | 63c88d2 | 2015-07-20 14:43:39 -0700 | [diff] [blame] | 1610 | { |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1611 | switch (pin) { |
| 1612 | case HPD_PORT_A: |
Ville Syrjälä | 195baa0 | 2015-08-27 23:56:00 +0300 | [diff] [blame] | 1613 | return val & PORTA_HOTPLUG_LONG_DETECT; |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1614 | case HPD_PORT_B: |
Imre Deak | 63c88d2 | 2015-07-20 14:43:39 -0700 | [diff] [blame] | 1615 | return val & PORTB_HOTPLUG_LONG_DETECT; |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1616 | case HPD_PORT_C: |
Imre Deak | 63c88d2 | 2015-07-20 14:43:39 -0700 | [diff] [blame] | 1617 | return val & PORTC_HOTPLUG_LONG_DETECT; |
Imre Deak | 63c88d2 | 2015-07-20 14:43:39 -0700 | [diff] [blame] | 1618 | default: |
| 1619 | return false; |
| 1620 | } |
| 1621 | } |
| 1622 | |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1623 | static bool icp_ddi_port_hotplug_long_detect(enum hpd_pin pin, u32 val) |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 1624 | { |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1625 | switch (pin) { |
| 1626 | case HPD_PORT_A: |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 1627 | return val & ICP_DDIA_HPD_LONG_DETECT; |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1628 | case HPD_PORT_B: |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 1629 | return val & ICP_DDIB_HPD_LONG_DETECT; |
| 1630 | default: |
| 1631 | return false; |
| 1632 | } |
| 1633 | } |
| 1634 | |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1635 | static bool icp_tc_port_hotplug_long_detect(enum hpd_pin pin, u32 val) |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 1636 | { |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1637 | switch (pin) { |
| 1638 | case HPD_PORT_C: |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 1639 | return val & ICP_TC_HPD_LONG_DETECT(PORT_TC1); |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1640 | case HPD_PORT_D: |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 1641 | return val & ICP_TC_HPD_LONG_DETECT(PORT_TC2); |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1642 | case HPD_PORT_E: |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 1643 | return val & ICP_TC_HPD_LONG_DETECT(PORT_TC3); |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1644 | case HPD_PORT_F: |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 1645 | return val & ICP_TC_HPD_LONG_DETECT(PORT_TC4); |
| 1646 | default: |
| 1647 | return false; |
| 1648 | } |
| 1649 | } |
| 1650 | |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1651 | static bool spt_port_hotplug2_long_detect(enum hpd_pin pin, u32 val) |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 1652 | { |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1653 | switch (pin) { |
| 1654 | case HPD_PORT_E: |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 1655 | return val & PORTE_HOTPLUG_LONG_DETECT; |
| 1656 | default: |
| 1657 | return false; |
| 1658 | } |
| 1659 | } |
| 1660 | |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1661 | static bool spt_port_hotplug_long_detect(enum hpd_pin pin, u32 val) |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 1662 | { |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1663 | switch (pin) { |
| 1664 | case HPD_PORT_A: |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 1665 | return val & PORTA_HOTPLUG_LONG_DETECT; |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1666 | case HPD_PORT_B: |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 1667 | return val & PORTB_HOTPLUG_LONG_DETECT; |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1668 | case HPD_PORT_C: |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 1669 | return val & PORTC_HOTPLUG_LONG_DETECT; |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1670 | case HPD_PORT_D: |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 1671 | return val & PORTD_HOTPLUG_LONG_DETECT; |
| 1672 | default: |
| 1673 | return false; |
| 1674 | } |
| 1675 | } |
| 1676 | |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1677 | static bool ilk_port_hotplug_long_detect(enum hpd_pin pin, u32 val) |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 1678 | { |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1679 | switch (pin) { |
| 1680 | case HPD_PORT_A: |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 1681 | return val & DIGITAL_PORTA_HOTPLUG_LONG_DETECT; |
| 1682 | default: |
| 1683 | return false; |
| 1684 | } |
| 1685 | } |
| 1686 | |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1687 | static bool pch_port_hotplug_long_detect(enum hpd_pin pin, u32 val) |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1688 | { |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1689 | switch (pin) { |
| 1690 | case HPD_PORT_B: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1691 | return val & PORTB_HOTPLUG_LONG_DETECT; |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1692 | case HPD_PORT_C: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1693 | return val & PORTC_HOTPLUG_LONG_DETECT; |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1694 | case HPD_PORT_D: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1695 | return val & PORTD_HOTPLUG_LONG_DETECT; |
| 1696 | default: |
| 1697 | return false; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1698 | } |
| 1699 | } |
| 1700 | |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1701 | static bool i9xx_port_hotplug_long_detect(enum hpd_pin pin, u32 val) |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1702 | { |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1703 | switch (pin) { |
| 1704 | case HPD_PORT_B: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1705 | return val & PORTB_HOTPLUG_INT_LONG_PULSE; |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1706 | case HPD_PORT_C: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1707 | return val & PORTC_HOTPLUG_INT_LONG_PULSE; |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1708 | case HPD_PORT_D: |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1709 | return val & PORTD_HOTPLUG_INT_LONG_PULSE; |
| 1710 | default: |
| 1711 | return false; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 1712 | } |
| 1713 | } |
| 1714 | |
Ville Syrjälä | 42db67d | 2015-08-28 21:26:27 +0300 | [diff] [blame] | 1715 | /* |
| 1716 | * Get a bit mask of pins that have triggered, and which ones may be long. |
| 1717 | * This can be called multiple times with the same masks to accumulate |
| 1718 | * hotplug detection results from several registers. |
| 1719 | * |
| 1720 | * Note that the caller is expected to zero out the masks initially. |
| 1721 | */ |
Rodrigo Vivi | cf53902 | 2018-01-29 15:22:21 -0800 | [diff] [blame] | 1722 | static void intel_get_hpd_pins(struct drm_i915_private *dev_priv, |
| 1723 | u32 *pin_mask, u32 *long_mask, |
| 1724 | u32 hotplug_trigger, u32 dig_hotplug_reg, |
| 1725 | const u32 hpd[HPD_NUM_PINS], |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1726 | bool long_pulse_detect(enum hpd_pin pin, u32 val)) |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1727 | { |
Ville Syrjälä | e9be285 | 2018-07-05 19:43:54 +0300 | [diff] [blame] | 1728 | enum hpd_pin pin; |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1729 | |
Ville Syrjälä | e9be285 | 2018-07-05 19:43:54 +0300 | [diff] [blame] | 1730 | for_each_hpd_pin(pin) { |
| 1731 | if ((hpd[pin] & hotplug_trigger) == 0) |
Jani Nikula | 8c841e5 | 2015-06-18 13:06:17 +0300 | [diff] [blame] | 1732 | continue; |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1733 | |
Ville Syrjälä | e9be285 | 2018-07-05 19:43:54 +0300 | [diff] [blame] | 1734 | *pin_mask |= BIT(pin); |
Jani Nikula | 8c841e5 | 2015-06-18 13:06:17 +0300 | [diff] [blame] | 1735 | |
Ville Syrjälä | af92058 | 2018-07-05 19:43:55 +0300 | [diff] [blame] | 1736 | if (long_pulse_detect(pin, dig_hotplug_reg)) |
Ville Syrjälä | e9be285 | 2018-07-05 19:43:54 +0300 | [diff] [blame] | 1737 | *long_mask |= BIT(pin); |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1738 | } |
| 1739 | |
Ville Syrjälä | f88f047 | 2018-07-05 19:43:57 +0300 | [diff] [blame] | 1740 | DRM_DEBUG_DRIVER("hotplug event received, stat 0x%08x, dig 0x%08x, pins 0x%08x, long 0x%08x\n", |
| 1741 | hotplug_trigger, dig_hotplug_reg, *pin_mask, *long_mask); |
Jani Nikula | 676574d | 2015-05-28 15:43:53 +0300 | [diff] [blame] | 1742 | |
| 1743 | } |
| 1744 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1745 | static void gmbus_irq_handler(struct drm_i915_private *dev_priv) |
Daniel Vetter | 515ac2b | 2012-12-01 13:53:44 +0100 | [diff] [blame] | 1746 | { |
Daniel Vetter | 28c70f1 | 2012-12-01 13:53:45 +0100 | [diff] [blame] | 1747 | wake_up_all(&dev_priv->gmbus_wait_queue); |
Daniel Vetter | 515ac2b | 2012-12-01 13:53:44 +0100 | [diff] [blame] | 1748 | } |
| 1749 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1750 | static void dp_aux_irq_handler(struct drm_i915_private *dev_priv) |
Daniel Vetter | ce99c25 | 2012-12-01 13:53:47 +0100 | [diff] [blame] | 1751 | { |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1752 | wake_up_all(&dev_priv->gmbus_wait_queue); |
Daniel Vetter | ce99c25 | 2012-12-01 13:53:47 +0100 | [diff] [blame] | 1753 | } |
| 1754 | |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1755 | #if defined(CONFIG_DEBUG_FS) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1756 | static void display_pipe_crc_irq_handler(struct drm_i915_private *dev_priv, |
| 1757 | enum pipe pipe, |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 1758 | u32 crc0, u32 crc1, |
| 1759 | u32 crc2, u32 crc3, |
| 1760 | u32 crc4) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1761 | { |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1762 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Tomeu Vizoso | 8c6b709 | 2017-01-10 14:43:04 +0100 | [diff] [blame] | 1763 | struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe); |
Ville Syrjälä | 5cee6c4 | 2019-02-06 22:49:07 +0200 | [diff] [blame] | 1764 | u32 crcs[5] = { crc0, crc1, crc2, crc3, crc4 }; |
| 1765 | |
| 1766 | trace_intel_pipe_crc(crtc, crcs); |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 1767 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 1768 | spin_lock(&pipe_crc->lock); |
Maarten Lankhorst | 6cc4215 | 2018-06-28 09:23:02 +0200 | [diff] [blame] | 1769 | /* |
| 1770 | * For some not yet identified reason, the first CRC is |
| 1771 | * bonkers. So let's just wait for the next vblank and read |
| 1772 | * out the buggy result. |
| 1773 | * |
| 1774 | * On GEN8+ sometimes the second CRC is bonkers as well, so |
| 1775 | * don't trust that one either. |
| 1776 | */ |
| 1777 | if (pipe_crc->skipped <= 0 || |
| 1778 | (INTEL_GEN(dev_priv) >= 8 && pipe_crc->skipped == 1)) { |
| 1779 | pipe_crc->skipped++; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 1780 | spin_unlock(&pipe_crc->lock); |
Maarten Lankhorst | 6cc4215 | 2018-06-28 09:23:02 +0200 | [diff] [blame] | 1781 | return; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 1782 | } |
Maarten Lankhorst | 6cc4215 | 2018-06-28 09:23:02 +0200 | [diff] [blame] | 1783 | spin_unlock(&pipe_crc->lock); |
| 1784 | |
Maarten Lankhorst | 6cc4215 | 2018-06-28 09:23:02 +0200 | [diff] [blame] | 1785 | drm_crtc_add_crc_entry(&crtc->base, true, |
| 1786 | drm_crtc_accurate_vblank_count(&crtc->base), |
| 1787 | crcs); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1788 | } |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1789 | #else |
| 1790 | static inline void |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1791 | display_pipe_crc_irq_handler(struct drm_i915_private *dev_priv, |
| 1792 | enum pipe pipe, |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 1793 | u32 crc0, u32 crc1, |
| 1794 | u32 crc2, u32 crc3, |
| 1795 | u32 crc4) {} |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1796 | #endif |
Daniel Vetter | eba94eb | 2013-10-16 22:55:46 +0200 | [diff] [blame] | 1797 | |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1798 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1799 | static void hsw_pipe_crc_irq_handler(struct drm_i915_private *dev_priv, |
| 1800 | enum pipe pipe) |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 1801 | { |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1802 | display_pipe_crc_irq_handler(dev_priv, pipe, |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1803 | I915_READ(PIPE_CRC_RES_1_IVB(pipe)), |
| 1804 | 0, 0, 0, 0); |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 1805 | } |
| 1806 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1807 | static void ivb_pipe_crc_irq_handler(struct drm_i915_private *dev_priv, |
| 1808 | enum pipe pipe) |
Daniel Vetter | eba94eb | 2013-10-16 22:55:46 +0200 | [diff] [blame] | 1809 | { |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1810 | display_pipe_crc_irq_handler(dev_priv, pipe, |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1811 | I915_READ(PIPE_CRC_RES_1_IVB(pipe)), |
| 1812 | I915_READ(PIPE_CRC_RES_2_IVB(pipe)), |
| 1813 | I915_READ(PIPE_CRC_RES_3_IVB(pipe)), |
| 1814 | I915_READ(PIPE_CRC_RES_4_IVB(pipe)), |
| 1815 | I915_READ(PIPE_CRC_RES_5_IVB(pipe))); |
Daniel Vetter | eba94eb | 2013-10-16 22:55:46 +0200 | [diff] [blame] | 1816 | } |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 1817 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1818 | static void i9xx_pipe_crc_irq_handler(struct drm_i915_private *dev_priv, |
| 1819 | enum pipe pipe) |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 1820 | { |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 1821 | u32 res1, res2; |
Daniel Vetter | 0b5c5ed | 2013-10-16 22:55:53 +0200 | [diff] [blame] | 1822 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1823 | if (INTEL_GEN(dev_priv) >= 3) |
Daniel Vetter | 0b5c5ed | 2013-10-16 22:55:53 +0200 | [diff] [blame] | 1824 | res1 = I915_READ(PIPE_CRC_RES_RES1_I915(pipe)); |
| 1825 | else |
| 1826 | res1 = 0; |
| 1827 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1828 | if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) |
Daniel Vetter | 0b5c5ed | 2013-10-16 22:55:53 +0200 | [diff] [blame] | 1829 | res2 = I915_READ(PIPE_CRC_RES_RES2_G4X(pipe)); |
| 1830 | else |
| 1831 | res2 = 0; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 1832 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1833 | display_pipe_crc_irq_handler(dev_priv, pipe, |
Daniel Vetter | 277de95 | 2013-10-18 16:37:07 +0200 | [diff] [blame] | 1834 | I915_READ(PIPE_CRC_RES_RED(pipe)), |
| 1835 | I915_READ(PIPE_CRC_RES_GREEN(pipe)), |
| 1836 | I915_READ(PIPE_CRC_RES_BLUE(pipe)), |
| 1837 | res1, res2); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 1838 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1839 | |
Paulo Zanoni | 1403c0d | 2013-08-15 11:51:32 -0300 | [diff] [blame] | 1840 | /* The RPS events need forcewake, so we add them to a work queue and mask their |
| 1841 | * IMR bits until the work is done. Other interrupts can be processed without |
| 1842 | * the work queue. */ |
Mika Kuoppala | a087baf | 2019-04-10 16:21:23 +0300 | [diff] [blame] | 1843 | static void gen11_rps_irq_handler(struct drm_i915_private *i915, u32 pm_iir) |
| 1844 | { |
| 1845 | struct intel_rps *rps = &i915->gt_pm.rps; |
| 1846 | const u32 events = i915->pm_rps_events & pm_iir; |
| 1847 | |
| 1848 | lockdep_assert_held(&i915->irq_lock); |
| 1849 | |
| 1850 | if (unlikely(!events)) |
| 1851 | return; |
| 1852 | |
| 1853 | gen6_mask_pm_irq(i915, events); |
| 1854 | |
| 1855 | if (!rps->interrupts_enabled) |
| 1856 | return; |
| 1857 | |
| 1858 | rps->pm_iir |= events; |
| 1859 | schedule_work(&rps->work); |
| 1860 | } |
| 1861 | |
Paulo Zanoni | 1403c0d | 2013-08-15 11:51:32 -0300 | [diff] [blame] | 1862 | 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] | 1863 | { |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1864 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
| 1865 | |
Deepak S | a6706b4 | 2014-03-15 20:23:22 +0530 | [diff] [blame] | 1866 | if (pm_iir & dev_priv->pm_rps_events) { |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1867 | spin_lock(&dev_priv->irq_lock); |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 1868 | gen6_mask_pm_irq(dev_priv, pm_iir & dev_priv->pm_rps_events); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1869 | if (rps->interrupts_enabled) { |
| 1870 | rps->pm_iir |= pm_iir & dev_priv->pm_rps_events; |
| 1871 | schedule_work(&rps->work); |
Imre Deak | d4d70aa | 2014-11-19 15:30:04 +0200 | [diff] [blame] | 1872 | } |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1873 | spin_unlock(&dev_priv->irq_lock); |
Ben Widawsky | baf02a1 | 2013-05-28 19:22:24 -0700 | [diff] [blame] | 1874 | } |
Ben Widawsky | baf02a1 | 2013-05-28 19:22:24 -0700 | [diff] [blame] | 1875 | |
Pandiyan, Dhinakaran | bca2bf2 | 2017-07-18 11:28:00 -0700 | [diff] [blame] | 1876 | if (INTEL_GEN(dev_priv) >= 8) |
Imre Deak | c9a9a26 | 2014-11-05 20:48:37 +0200 | [diff] [blame] | 1877 | return; |
| 1878 | |
Chris Wilson | f14c0d9 | 2019-03-05 15:09:13 +0000 | [diff] [blame] | 1879 | if (pm_iir & PM_VEBOX_USER_INTERRUPT) |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1880 | intel_engine_breadcrumbs_irq(dev_priv->engine[VECS0]); |
Ben Widawsky | 12638c5 | 2013-05-28 19:22:31 -0700 | [diff] [blame] | 1881 | |
Chris Wilson | f14c0d9 | 2019-03-05 15:09:13 +0000 | [diff] [blame] | 1882 | if (pm_iir & PM_VEBOX_CS_ERROR_INTERRUPT) |
| 1883 | DRM_DEBUG("Command parser error, pm_iir 0x%08x\n", pm_iir); |
Ben Widawsky | baf02a1 | 2013-05-28 19:22:24 -0700 | [diff] [blame] | 1884 | } |
| 1885 | |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 1886 | static void gen9_guc_irq_handler(struct drm_i915_private *dev_priv, u32 gt_iir) |
| 1887 | { |
Michal Wajdeczko | 93bf809 | 2018-03-08 16:46:55 +0100 | [diff] [blame] | 1888 | if (gt_iir & GEN9_GUC_TO_HOST_INT_EVENT) |
| 1889 | intel_guc_to_host_event_handler(&dev_priv->guc); |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 1890 | } |
| 1891 | |
Ville Syrjälä | 44d9241 | 2017-08-18 21:36:51 +0300 | [diff] [blame] | 1892 | static void i9xx_pipestat_irq_reset(struct drm_i915_private *dev_priv) |
| 1893 | { |
| 1894 | enum pipe pipe; |
| 1895 | |
| 1896 | for_each_pipe(dev_priv, pipe) { |
| 1897 | I915_WRITE(PIPESTAT(pipe), |
| 1898 | PIPESTAT_INT_STATUS_MASK | |
| 1899 | PIPE_FIFO_UNDERRUN_STATUS); |
| 1900 | |
| 1901 | dev_priv->pipestat_irq_mask[pipe] = 0; |
| 1902 | } |
| 1903 | } |
| 1904 | |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 1905 | static void i9xx_pipestat_irq_ack(struct drm_i915_private *dev_priv, |
| 1906 | u32 iir, u32 pipe_stats[I915_MAX_PIPES]) |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1907 | { |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1908 | int pipe; |
| 1909 | |
Imre Deak | 58ead0d | 2014-02-04 21:35:47 +0200 | [diff] [blame] | 1910 | spin_lock(&dev_priv->irq_lock); |
Ville Syrjälä | 1ca993d | 2016-02-18 21:54:26 +0200 | [diff] [blame] | 1911 | |
| 1912 | if (!dev_priv->display_irqs_enabled) { |
| 1913 | spin_unlock(&dev_priv->irq_lock); |
| 1914 | return; |
| 1915 | } |
| 1916 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 1917 | for_each_pipe(dev_priv, pipe) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1918 | i915_reg_t reg; |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 1919 | u32 status_mask, enable_mask, iir_bit = 0; |
Imre Deak | 91d181d | 2014-02-10 18:42:49 +0200 | [diff] [blame] | 1920 | |
Daniel Vetter | bbb5eeb | 2014-02-12 17:55:36 +0100 | [diff] [blame] | 1921 | /* |
| 1922 | * PIPESTAT bits get signalled even when the interrupt is |
| 1923 | * disabled with the mask bits, and some of the status bits do |
| 1924 | * not generate interrupts at all (like the underrun bit). Hence |
| 1925 | * we need to be careful that we only handle what we want to |
| 1926 | * handle. |
| 1927 | */ |
Daniel Vetter | 0f239f4 | 2014-09-30 10:56:49 +0200 | [diff] [blame] | 1928 | |
| 1929 | /* fifo underruns are filterered in the underrun handler. */ |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 1930 | status_mask = PIPE_FIFO_UNDERRUN_STATUS; |
Daniel Vetter | bbb5eeb | 2014-02-12 17:55:36 +0100 | [diff] [blame] | 1931 | |
| 1932 | switch (pipe) { |
| 1933 | case PIPE_A: |
| 1934 | iir_bit = I915_DISPLAY_PIPE_A_EVENT_INTERRUPT; |
| 1935 | break; |
| 1936 | case PIPE_B: |
| 1937 | iir_bit = I915_DISPLAY_PIPE_B_EVENT_INTERRUPT; |
| 1938 | break; |
Ville Syrjälä | 3278f67 | 2014-04-09 13:28:49 +0300 | [diff] [blame] | 1939 | case PIPE_C: |
| 1940 | iir_bit = I915_DISPLAY_PIPE_C_EVENT_INTERRUPT; |
| 1941 | break; |
Daniel Vetter | bbb5eeb | 2014-02-12 17:55:36 +0100 | [diff] [blame] | 1942 | } |
| 1943 | if (iir & iir_bit) |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 1944 | status_mask |= dev_priv->pipestat_irq_mask[pipe]; |
Daniel Vetter | bbb5eeb | 2014-02-12 17:55:36 +0100 | [diff] [blame] | 1945 | |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 1946 | if (!status_mask) |
Imre Deak | 91d181d | 2014-02-10 18:42:49 +0200 | [diff] [blame] | 1947 | continue; |
| 1948 | |
| 1949 | reg = PIPESTAT(pipe); |
Ville Syrjälä | 6b12ca5 | 2017-09-14 18:17:31 +0300 | [diff] [blame] | 1950 | pipe_stats[pipe] = I915_READ(reg) & status_mask; |
| 1951 | enable_mask = i915_pipestat_enable_mask(dev_priv, pipe); |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1952 | |
| 1953 | /* |
| 1954 | * Clear the PIPE*STAT regs before the IIR |
Ville Syrjälä | 132c27c | 2018-06-11 23:02:55 +0300 | [diff] [blame] | 1955 | * |
| 1956 | * Toggle the enable bits to make sure we get an |
| 1957 | * edge in the ISR pipe event bit if we don't clear |
| 1958 | * all the enabled status bits. Otherwise the edge |
| 1959 | * triggered IIR on i965/g4x wouldn't notice that |
| 1960 | * an interrupt is still pending. |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1961 | */ |
Ville Syrjälä | 132c27c | 2018-06-11 23:02:55 +0300 | [diff] [blame] | 1962 | if (pipe_stats[pipe]) { |
| 1963 | I915_WRITE(reg, pipe_stats[pipe]); |
| 1964 | I915_WRITE(reg, enable_mask); |
| 1965 | } |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 1966 | } |
Imre Deak | 58ead0d | 2014-02-04 21:35:47 +0200 | [diff] [blame] | 1967 | spin_unlock(&dev_priv->irq_lock); |
Ville Syrjälä | 2ecb8ca | 2016-04-13 21:19:55 +0300 | [diff] [blame] | 1968 | } |
| 1969 | |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 1970 | static void i8xx_pipestat_irq_handler(struct drm_i915_private *dev_priv, |
| 1971 | u16 iir, u32 pipe_stats[I915_MAX_PIPES]) |
| 1972 | { |
| 1973 | enum pipe pipe; |
| 1974 | |
| 1975 | for_each_pipe(dev_priv, pipe) { |
| 1976 | if (pipe_stats[pipe] & PIPE_VBLANK_INTERRUPT_STATUS) |
| 1977 | drm_handle_vblank(&dev_priv->drm, pipe); |
| 1978 | |
| 1979 | if (pipe_stats[pipe] & PIPE_CRC_DONE_INTERRUPT_STATUS) |
| 1980 | i9xx_pipe_crc_irq_handler(dev_priv, pipe); |
| 1981 | |
| 1982 | if (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS) |
| 1983 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
| 1984 | } |
| 1985 | } |
| 1986 | |
| 1987 | static void i915_pipestat_irq_handler(struct drm_i915_private *dev_priv, |
| 1988 | u32 iir, u32 pipe_stats[I915_MAX_PIPES]) |
| 1989 | { |
| 1990 | bool blc_event = false; |
| 1991 | enum pipe pipe; |
| 1992 | |
| 1993 | for_each_pipe(dev_priv, pipe) { |
| 1994 | if (pipe_stats[pipe] & PIPE_VBLANK_INTERRUPT_STATUS) |
| 1995 | drm_handle_vblank(&dev_priv->drm, pipe); |
| 1996 | |
| 1997 | if (pipe_stats[pipe] & PIPE_LEGACY_BLC_EVENT_STATUS) |
| 1998 | blc_event = true; |
| 1999 | |
| 2000 | if (pipe_stats[pipe] & PIPE_CRC_DONE_INTERRUPT_STATUS) |
| 2001 | i9xx_pipe_crc_irq_handler(dev_priv, pipe); |
| 2002 | |
| 2003 | if (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS) |
| 2004 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
| 2005 | } |
| 2006 | |
| 2007 | if (blc_event || (iir & I915_ASLE_INTERRUPT)) |
| 2008 | intel_opregion_asle_intr(dev_priv); |
| 2009 | } |
| 2010 | |
| 2011 | static void i965_pipestat_irq_handler(struct drm_i915_private *dev_priv, |
| 2012 | u32 iir, u32 pipe_stats[I915_MAX_PIPES]) |
| 2013 | { |
| 2014 | bool blc_event = false; |
| 2015 | enum pipe pipe; |
| 2016 | |
| 2017 | for_each_pipe(dev_priv, pipe) { |
| 2018 | if (pipe_stats[pipe] & PIPE_START_VBLANK_INTERRUPT_STATUS) |
| 2019 | drm_handle_vblank(&dev_priv->drm, pipe); |
| 2020 | |
| 2021 | if (pipe_stats[pipe] & PIPE_LEGACY_BLC_EVENT_STATUS) |
| 2022 | blc_event = true; |
| 2023 | |
| 2024 | if (pipe_stats[pipe] & PIPE_CRC_DONE_INTERRUPT_STATUS) |
| 2025 | i9xx_pipe_crc_irq_handler(dev_priv, pipe); |
| 2026 | |
| 2027 | if (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS) |
| 2028 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
| 2029 | } |
| 2030 | |
| 2031 | if (blc_event || (iir & I915_ASLE_INTERRUPT)) |
| 2032 | intel_opregion_asle_intr(dev_priv); |
| 2033 | |
| 2034 | if (pipe_stats[0] & PIPE_GMBUS_INTERRUPT_STATUS) |
| 2035 | gmbus_irq_handler(dev_priv); |
| 2036 | } |
| 2037 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2038 | static void valleyview_pipestat_irq_handler(struct drm_i915_private *dev_priv, |
Ville Syrjälä | 2ecb8ca | 2016-04-13 21:19:55 +0300 | [diff] [blame] | 2039 | u32 pipe_stats[I915_MAX_PIPES]) |
| 2040 | { |
Ville Syrjälä | 2ecb8ca | 2016-04-13 21:19:55 +0300 | [diff] [blame] | 2041 | enum pipe pipe; |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 2042 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2043 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | fd3a402 | 2017-07-20 19:57:51 +0200 | [diff] [blame] | 2044 | if (pipe_stats[pipe] & PIPE_START_VBLANK_INTERRUPT_STATUS) |
| 2045 | drm_handle_vblank(&dev_priv->drm, pipe); |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 2046 | |
| 2047 | if (pipe_stats[pipe] & PIPE_CRC_DONE_INTERRUPT_STATUS) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2048 | i9xx_pipe_crc_irq_handler(dev_priv, pipe); |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 2049 | |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 2050 | if (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS) |
| 2051 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 2052 | } |
| 2053 | |
| 2054 | if (pipe_stats[0] & PIPE_GMBUS_INTERRUPT_STATUS) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2055 | gmbus_irq_handler(dev_priv); |
Imre Deak | c1874ed | 2014-02-04 21:35:46 +0200 | [diff] [blame] | 2056 | } |
| 2057 | |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2058 | static u32 i9xx_hpd_irq_ack(struct drm_i915_private *dev_priv) |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 2059 | { |
Ville Syrjälä | 0ba7c51 | 2018-06-14 20:56:25 +0300 | [diff] [blame] | 2060 | u32 hotplug_status = 0, hotplug_status_mask; |
| 2061 | int i; |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2062 | |
Ville Syrjälä | 0ba7c51 | 2018-06-14 20:56:25 +0300 | [diff] [blame] | 2063 | if (IS_G4X(dev_priv) || |
| 2064 | IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 2065 | hotplug_status_mask = HOTPLUG_INT_STATUS_G4X | |
| 2066 | DP_AUX_CHANNEL_MASK_INT_STATUS_G4X; |
| 2067 | else |
| 2068 | hotplug_status_mask = HOTPLUG_INT_STATUS_I915; |
| 2069 | |
| 2070 | /* |
| 2071 | * We absolutely have to clear all the pending interrupt |
| 2072 | * bits in PORT_HOTPLUG_STAT. Otherwise the ISR port |
| 2073 | * interrupt bit won't have an edge, and the i965/g4x |
| 2074 | * edge triggered IIR will not notice that an interrupt |
| 2075 | * is still pending. We can't use PORT_HOTPLUG_EN to |
| 2076 | * guarantee the edge as the act of toggling the enable |
| 2077 | * bits can itself generate a new hotplug interrupt :( |
| 2078 | */ |
| 2079 | for (i = 0; i < 10; i++) { |
| 2080 | u32 tmp = I915_READ(PORT_HOTPLUG_STAT) & hotplug_status_mask; |
| 2081 | |
| 2082 | if (tmp == 0) |
| 2083 | return hotplug_status; |
| 2084 | |
| 2085 | hotplug_status |= tmp; |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2086 | I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status); |
Ville Syrjälä | 0ba7c51 | 2018-06-14 20:56:25 +0300 | [diff] [blame] | 2087 | } |
| 2088 | |
| 2089 | WARN_ONCE(1, |
| 2090 | "PORT_HOTPLUG_STAT did not clear (0x%08x)\n", |
| 2091 | I915_READ(PORT_HOTPLUG_STAT)); |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2092 | |
| 2093 | return hotplug_status; |
| 2094 | } |
| 2095 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2096 | static void i9xx_hpd_irq_handler(struct drm_i915_private *dev_priv, |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2097 | u32 hotplug_status) |
| 2098 | { |
Ville Syrjälä | 42db67d | 2015-08-28 21:26:27 +0300 | [diff] [blame] | 2099 | u32 pin_mask = 0, long_mask = 0; |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 2100 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2101 | if (IS_G4X(dev_priv) || IS_VALLEYVIEW(dev_priv) || |
| 2102 | IS_CHERRYVIEW(dev_priv)) { |
Jani Nikula | 0d2e429 | 2015-05-27 15:03:39 +0300 | [diff] [blame] | 2103 | u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_G4X; |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 2104 | |
Ville Syrjälä | 58f2cf2 | 2015-08-28 22:59:08 +0300 | [diff] [blame] | 2105 | if (hotplug_trigger) { |
Rodrigo Vivi | cf53902 | 2018-01-29 15:22:21 -0800 | [diff] [blame] | 2106 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, |
| 2107 | hotplug_trigger, hotplug_trigger, |
| 2108 | hpd_status_g4x, |
Ville Syrjälä | 58f2cf2 | 2015-08-28 22:59:08 +0300 | [diff] [blame] | 2109 | i9xx_port_hotplug_long_detect); |
| 2110 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2111 | intel_hpd_irq_handler(dev_priv, pin_mask, long_mask); |
Ville Syrjälä | 58f2cf2 | 2015-08-28 22:59:08 +0300 | [diff] [blame] | 2112 | } |
Jani Nikula | 369712e | 2015-05-27 15:03:40 +0300 | [diff] [blame] | 2113 | |
| 2114 | if (hotplug_status & DP_AUX_CHANNEL_MASK_INT_STATUS_G4X) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2115 | dp_aux_irq_handler(dev_priv); |
Jani Nikula | 0d2e429 | 2015-05-27 15:03:39 +0300 | [diff] [blame] | 2116 | } else { |
| 2117 | u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_I915; |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 2118 | |
Ville Syrjälä | 58f2cf2 | 2015-08-28 22:59:08 +0300 | [diff] [blame] | 2119 | if (hotplug_trigger) { |
Rodrigo Vivi | cf53902 | 2018-01-29 15:22:21 -0800 | [diff] [blame] | 2120 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, |
| 2121 | hotplug_trigger, hotplug_trigger, |
| 2122 | hpd_status_i915, |
Ville Syrjälä | 58f2cf2 | 2015-08-28 22:59:08 +0300 | [diff] [blame] | 2123 | i9xx_port_hotplug_long_detect); |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2124 | intel_hpd_irq_handler(dev_priv, pin_mask, long_mask); |
Ville Syrjälä | 58f2cf2 | 2015-08-28 22:59:08 +0300 | [diff] [blame] | 2125 | } |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 2126 | } |
Ville Syrjälä | 16c6c56 | 2014-04-01 10:54:36 +0300 | [diff] [blame] | 2127 | } |
| 2128 | |
Daniel Vetter | ff1f525 | 2012-10-02 15:10:55 +0200 | [diff] [blame] | 2129 | static irqreturn_t valleyview_irq_handler(int irq, void *arg) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2130 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 2131 | struct drm_device *dev = arg; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2132 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2133 | irqreturn_t ret = IRQ_NONE; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2134 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 2135 | if (!intel_irqs_enabled(dev_priv)) |
| 2136 | return IRQ_NONE; |
| 2137 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 2138 | /* IRQs are synced during runtime_suspend, we don't require a wakeref */ |
| 2139 | disable_rpm_wakeref_asserts(dev_priv); |
| 2140 | |
Ville Syrjälä | 1e1cace | 2016-04-13 21:19:52 +0300 | [diff] [blame] | 2141 | do { |
Ville Syrjälä | 6e81480 | 2016-04-13 21:19:53 +0300 | [diff] [blame] | 2142 | u32 iir, gt_iir, pm_iir; |
Ville Syrjälä | 2ecb8ca | 2016-04-13 21:19:55 +0300 | [diff] [blame] | 2143 | u32 pipe_stats[I915_MAX_PIPES] = {}; |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2144 | u32 hotplug_status = 0; |
Ville Syrjälä | a5e485a | 2016-04-13 21:19:51 +0300 | [diff] [blame] | 2145 | u32 ier = 0; |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 2146 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2147 | gt_iir = I915_READ(GTIIR); |
| 2148 | pm_iir = I915_READ(GEN6_PMIIR); |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 2149 | iir = I915_READ(VLV_IIR); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2150 | |
| 2151 | if (gt_iir == 0 && pm_iir == 0 && iir == 0) |
Ville Syrjälä | 1e1cace | 2016-04-13 21:19:52 +0300 | [diff] [blame] | 2152 | break; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2153 | |
| 2154 | ret = IRQ_HANDLED; |
| 2155 | |
Ville Syrjälä | a5e485a | 2016-04-13 21:19:51 +0300 | [diff] [blame] | 2156 | /* |
| 2157 | * Theory on interrupt generation, based on empirical evidence: |
| 2158 | * |
| 2159 | * x = ((VLV_IIR & VLV_IER) || |
| 2160 | * (((GT_IIR & GT_IER) || (GEN6_PMIIR & GEN6_PMIER)) && |
| 2161 | * (VLV_MASTER_IER & MASTER_INTERRUPT_ENABLE))); |
| 2162 | * |
| 2163 | * A CPU interrupt will only be raised when 'x' has a 0->1 edge. |
| 2164 | * Hence we clear MASTER_INTERRUPT_ENABLE and VLV_IER to |
| 2165 | * guarantee the CPU interrupt will be raised again even if we |
| 2166 | * don't end up clearing all the VLV_IIR, GT_IIR, GEN6_PMIIR |
| 2167 | * bits this time around. |
| 2168 | */ |
Ville Syrjälä | 4a0a020 | 2016-04-13 21:19:50 +0300 | [diff] [blame] | 2169 | I915_WRITE(VLV_MASTER_IER, 0); |
Ville Syrjälä | a5e485a | 2016-04-13 21:19:51 +0300 | [diff] [blame] | 2170 | ier = I915_READ(VLV_IER); |
| 2171 | I915_WRITE(VLV_IER, 0); |
Ville Syrjälä | 4a0a020 | 2016-04-13 21:19:50 +0300 | [diff] [blame] | 2172 | |
| 2173 | if (gt_iir) |
| 2174 | I915_WRITE(GTIIR, gt_iir); |
| 2175 | if (pm_iir) |
| 2176 | I915_WRITE(GEN6_PMIIR, pm_iir); |
| 2177 | |
Ville Syrjälä | 7ce4d1f | 2016-04-13 21:19:49 +0300 | [diff] [blame] | 2178 | if (iir & I915_DISPLAY_PORT_INTERRUPT) |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2179 | hotplug_status = i9xx_hpd_irq_ack(dev_priv); |
Ville Syrjälä | 7ce4d1f | 2016-04-13 21:19:49 +0300 | [diff] [blame] | 2180 | |
Oscar Mateo | 3ff60f8 | 2014-06-16 16:10:58 +0100 | [diff] [blame] | 2181 | /* Call regardless, as some status bits might not be |
| 2182 | * signalled in iir */ |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 2183 | i9xx_pipestat_irq_ack(dev_priv, iir, pipe_stats); |
Ville Syrjälä | 7ce4d1f | 2016-04-13 21:19:49 +0300 | [diff] [blame] | 2184 | |
Jerome Anand | eef5732 | 2017-01-25 04:27:49 +0530 | [diff] [blame] | 2185 | if (iir & (I915_LPE_PIPE_A_INTERRUPT | |
| 2186 | I915_LPE_PIPE_B_INTERRUPT)) |
| 2187 | intel_lpe_audio_irq_handler(dev_priv); |
| 2188 | |
Ville Syrjälä | 7ce4d1f | 2016-04-13 21:19:49 +0300 | [diff] [blame] | 2189 | /* |
| 2190 | * VLV_IIR is single buffered, and reflects the level |
| 2191 | * from PIPESTAT/PORT_HOTPLUG_STAT, hence clear it last. |
| 2192 | */ |
| 2193 | if (iir) |
| 2194 | I915_WRITE(VLV_IIR, iir); |
Ville Syrjälä | 4a0a020 | 2016-04-13 21:19:50 +0300 | [diff] [blame] | 2195 | |
Ville Syrjälä | a5e485a | 2016-04-13 21:19:51 +0300 | [diff] [blame] | 2196 | I915_WRITE(VLV_IER, ier); |
Ville Syrjälä | 4a0a020 | 2016-04-13 21:19:50 +0300 | [diff] [blame] | 2197 | I915_WRITE(VLV_MASTER_IER, MASTER_INTERRUPT_ENABLE); |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2198 | |
Ville Syrjälä | 5289487 | 2016-04-13 21:19:56 +0300 | [diff] [blame] | 2199 | if (gt_iir) |
Ville Syrjälä | 261e40b | 2016-04-13 21:19:57 +0300 | [diff] [blame] | 2200 | snb_gt_irq_handler(dev_priv, gt_iir); |
Ville Syrjälä | 5289487 | 2016-04-13 21:19:56 +0300 | [diff] [blame] | 2201 | if (pm_iir) |
| 2202 | gen6_rps_irq_handler(dev_priv, pm_iir); |
| 2203 | |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2204 | if (hotplug_status) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2205 | i9xx_hpd_irq_handler(dev_priv, hotplug_status); |
Ville Syrjälä | 2ecb8ca | 2016-04-13 21:19:55 +0300 | [diff] [blame] | 2206 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2207 | valleyview_pipestat_irq_handler(dev_priv, pipe_stats); |
Ville Syrjälä | 1e1cace | 2016-04-13 21:19:52 +0300 | [diff] [blame] | 2208 | } while (0); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2209 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 2210 | enable_rpm_wakeref_asserts(dev_priv); |
| 2211 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 2212 | return ret; |
| 2213 | } |
| 2214 | |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 2215 | static irqreturn_t cherryview_irq_handler(int irq, void *arg) |
| 2216 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 2217 | struct drm_device *dev = arg; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2218 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 2219 | irqreturn_t ret = IRQ_NONE; |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 2220 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 2221 | if (!intel_irqs_enabled(dev_priv)) |
| 2222 | return IRQ_NONE; |
| 2223 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 2224 | /* IRQs are synced during runtime_suspend, we don't require a wakeref */ |
| 2225 | disable_rpm_wakeref_asserts(dev_priv); |
| 2226 | |
Chris Wilson | 579de73 | 2016-03-14 09:01:57 +0000 | [diff] [blame] | 2227 | do { |
Ville Syrjälä | 6e81480 | 2016-04-13 21:19:53 +0300 | [diff] [blame] | 2228 | u32 master_ctl, iir; |
Ville Syrjälä | 2ecb8ca | 2016-04-13 21:19:55 +0300 | [diff] [blame] | 2229 | u32 pipe_stats[I915_MAX_PIPES] = {}; |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2230 | u32 hotplug_status = 0; |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 2231 | u32 gt_iir[4]; |
Ville Syrjälä | a5e485a | 2016-04-13 21:19:51 +0300 | [diff] [blame] | 2232 | u32 ier = 0; |
| 2233 | |
Ville Syrjälä | 8e5fd59 | 2014-04-09 13:28:50 +0300 | [diff] [blame] | 2234 | master_ctl = I915_READ(GEN8_MASTER_IRQ) & ~GEN8_MASTER_IRQ_CONTROL; |
| 2235 | iir = I915_READ(VLV_IIR); |
Ville Syrjälä | 3278f67 | 2014-04-09 13:28:49 +0300 | [diff] [blame] | 2236 | |
Ville Syrjälä | 8e5fd59 | 2014-04-09 13:28:50 +0300 | [diff] [blame] | 2237 | if (master_ctl == 0 && iir == 0) |
| 2238 | break; |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 2239 | |
Oscar Mateo | 27b6c12 | 2014-06-16 16:11:00 +0100 | [diff] [blame] | 2240 | ret = IRQ_HANDLED; |
| 2241 | |
Ville Syrjälä | a5e485a | 2016-04-13 21:19:51 +0300 | [diff] [blame] | 2242 | /* |
| 2243 | * Theory on interrupt generation, based on empirical evidence: |
| 2244 | * |
| 2245 | * x = ((VLV_IIR & VLV_IER) || |
| 2246 | * ((GEN8_MASTER_IRQ & ~GEN8_MASTER_IRQ_CONTROL) && |
| 2247 | * (GEN8_MASTER_IRQ & GEN8_MASTER_IRQ_CONTROL))); |
| 2248 | * |
| 2249 | * A CPU interrupt will only be raised when 'x' has a 0->1 edge. |
| 2250 | * Hence we clear GEN8_MASTER_IRQ_CONTROL and VLV_IER to |
| 2251 | * guarantee the CPU interrupt will be raised again even if we |
| 2252 | * don't end up clearing all the VLV_IIR and GEN8_MASTER_IRQ_CONTROL |
| 2253 | * bits this time around. |
| 2254 | */ |
Ville Syrjälä | 8e5fd59 | 2014-04-09 13:28:50 +0300 | [diff] [blame] | 2255 | I915_WRITE(GEN8_MASTER_IRQ, 0); |
Ville Syrjälä | a5e485a | 2016-04-13 21:19:51 +0300 | [diff] [blame] | 2256 | ier = I915_READ(VLV_IER); |
| 2257 | I915_WRITE(VLV_IER, 0); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 2258 | |
Ville Syrjälä | e30e251 | 2016-04-13 21:19:58 +0300 | [diff] [blame] | 2259 | gen8_gt_irq_ack(dev_priv, master_ctl, gt_iir); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 2260 | |
Ville Syrjälä | 7ce4d1f | 2016-04-13 21:19:49 +0300 | [diff] [blame] | 2261 | if (iir & I915_DISPLAY_PORT_INTERRUPT) |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2262 | hotplug_status = i9xx_hpd_irq_ack(dev_priv); |
Ville Syrjälä | 7ce4d1f | 2016-04-13 21:19:49 +0300 | [diff] [blame] | 2263 | |
Oscar Mateo | 27b6c12 | 2014-06-16 16:11:00 +0100 | [diff] [blame] | 2264 | /* Call regardless, as some status bits might not be |
| 2265 | * signalled in iir */ |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 2266 | i9xx_pipestat_irq_ack(dev_priv, iir, pipe_stats); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 2267 | |
Jerome Anand | eef5732 | 2017-01-25 04:27:49 +0530 | [diff] [blame] | 2268 | if (iir & (I915_LPE_PIPE_A_INTERRUPT | |
| 2269 | I915_LPE_PIPE_B_INTERRUPT | |
| 2270 | I915_LPE_PIPE_C_INTERRUPT)) |
| 2271 | intel_lpe_audio_irq_handler(dev_priv); |
| 2272 | |
Ville Syrjälä | 7ce4d1f | 2016-04-13 21:19:49 +0300 | [diff] [blame] | 2273 | /* |
| 2274 | * VLV_IIR is single buffered, and reflects the level |
| 2275 | * from PIPESTAT/PORT_HOTPLUG_STAT, hence clear it last. |
| 2276 | */ |
| 2277 | if (iir) |
| 2278 | I915_WRITE(VLV_IIR, iir); |
| 2279 | |
Ville Syrjälä | a5e485a | 2016-04-13 21:19:51 +0300 | [diff] [blame] | 2280 | I915_WRITE(VLV_IER, ier); |
Ville Syrjälä | e5328c4 | 2016-04-13 21:19:47 +0300 | [diff] [blame] | 2281 | I915_WRITE(GEN8_MASTER_IRQ, GEN8_MASTER_IRQ_CONTROL); |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2282 | |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 2283 | gen8_gt_irq_handler(dev_priv, master_ctl, gt_iir); |
Ville Syrjälä | e30e251 | 2016-04-13 21:19:58 +0300 | [diff] [blame] | 2284 | |
Ville Syrjälä | 1ae3c34 | 2016-04-13 21:19:54 +0300 | [diff] [blame] | 2285 | if (hotplug_status) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2286 | i9xx_hpd_irq_handler(dev_priv, hotplug_status); |
Ville Syrjälä | 2ecb8ca | 2016-04-13 21:19:55 +0300 | [diff] [blame] | 2287 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2288 | valleyview_pipestat_irq_handler(dev_priv, pipe_stats); |
Chris Wilson | 579de73 | 2016-03-14 09:01:57 +0000 | [diff] [blame] | 2289 | } while (0); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 2290 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 2291 | enable_rpm_wakeref_asserts(dev_priv); |
| 2292 | |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 2293 | return ret; |
| 2294 | } |
| 2295 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2296 | static void ibx_hpd_irq_handler(struct drm_i915_private *dev_priv, |
| 2297 | u32 hotplug_trigger, |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2298 | const u32 hpd[HPD_NUM_PINS]) |
| 2299 | { |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2300 | u32 dig_hotplug_reg, pin_mask = 0, long_mask = 0; |
| 2301 | |
Jani Nikula | 6a39d7c | 2015-11-25 16:47:22 +0200 | [diff] [blame] | 2302 | /* |
| 2303 | * Somehow the PCH doesn't seem to really ack the interrupt to the CPU |
| 2304 | * unless we touch the hotplug register, even if hotplug_trigger is |
| 2305 | * zero. Not acking leads to "The master control interrupt lied (SDE)!" |
| 2306 | * errors. |
| 2307 | */ |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2308 | dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG); |
Jani Nikula | 6a39d7c | 2015-11-25 16:47:22 +0200 | [diff] [blame] | 2309 | if (!hotplug_trigger) { |
| 2310 | u32 mask = PORTA_HOTPLUG_STATUS_MASK | |
| 2311 | PORTD_HOTPLUG_STATUS_MASK | |
| 2312 | PORTC_HOTPLUG_STATUS_MASK | |
| 2313 | PORTB_HOTPLUG_STATUS_MASK; |
| 2314 | dig_hotplug_reg &= ~mask; |
| 2315 | } |
| 2316 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2317 | I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg); |
Jani Nikula | 6a39d7c | 2015-11-25 16:47:22 +0200 | [diff] [blame] | 2318 | if (!hotplug_trigger) |
| 2319 | return; |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2320 | |
Rodrigo Vivi | cf53902 | 2018-01-29 15:22:21 -0800 | [diff] [blame] | 2321 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, hotplug_trigger, |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2322 | dig_hotplug_reg, hpd, |
| 2323 | pch_port_hotplug_long_detect); |
| 2324 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2325 | intel_hpd_irq_handler(dev_priv, pin_mask, long_mask); |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2326 | } |
| 2327 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2328 | static void ibx_irq_handler(struct drm_i915_private *dev_priv, u32 pch_iir) |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 2329 | { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 2330 | int pipe; |
Egbert Eich | b543fb0 | 2013-04-16 13:36:54 +0200 | [diff] [blame] | 2331 | u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK; |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 2332 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2333 | ibx_hpd_irq_handler(dev_priv, hotplug_trigger, hpd_ibx); |
Daniel Vetter | 91d131d | 2013-06-27 17:52:14 +0200 | [diff] [blame] | 2334 | |
Ville Syrjälä | cfc33bf | 2013-04-17 17:48:48 +0300 | [diff] [blame] | 2335 | if (pch_iir & SDE_AUDIO_POWER_MASK) { |
| 2336 | int port = ffs((pch_iir & SDE_AUDIO_POWER_MASK) >> |
| 2337 | SDE_AUDIO_POWER_SHIFT); |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 2338 | DRM_DEBUG_DRIVER("PCH audio power change on port %d\n", |
Ville Syrjälä | cfc33bf | 2013-04-17 17:48:48 +0300 | [diff] [blame] | 2339 | port_name(port)); |
| 2340 | } |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 2341 | |
Daniel Vetter | ce99c25 | 2012-12-01 13:53:47 +0100 | [diff] [blame] | 2342 | if (pch_iir & SDE_AUX_MASK) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2343 | dp_aux_irq_handler(dev_priv); |
Daniel Vetter | ce99c25 | 2012-12-01 13:53:47 +0100 | [diff] [blame] | 2344 | |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 2345 | if (pch_iir & SDE_GMBUS) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2346 | gmbus_irq_handler(dev_priv); |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 2347 | |
| 2348 | if (pch_iir & SDE_AUDIO_HDCP_MASK) |
| 2349 | DRM_DEBUG_DRIVER("PCH HDCP audio interrupt\n"); |
| 2350 | |
| 2351 | if (pch_iir & SDE_AUDIO_TRANS_MASK) |
| 2352 | DRM_DEBUG_DRIVER("PCH transcoder audio interrupt\n"); |
| 2353 | |
| 2354 | if (pch_iir & SDE_POISON) |
| 2355 | DRM_ERROR("PCH poison interrupt\n"); |
| 2356 | |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 2357 | if (pch_iir & SDE_FDI_MASK) |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2358 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 2359 | DRM_DEBUG_DRIVER(" pipe %c FDI IIR: 0x%08x\n", |
| 2360 | pipe_name(pipe), |
| 2361 | I915_READ(FDI_RX_IIR(pipe))); |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 2362 | |
| 2363 | if (pch_iir & (SDE_TRANSB_CRC_DONE | SDE_TRANSA_CRC_DONE)) |
| 2364 | DRM_DEBUG_DRIVER("PCH transcoder CRC done interrupt\n"); |
| 2365 | |
| 2366 | if (pch_iir & (SDE_TRANSB_CRC_ERR | SDE_TRANSA_CRC_ERR)) |
| 2367 | DRM_DEBUG_DRIVER("PCH transcoder CRC error interrupt\n"); |
| 2368 | |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 2369 | if (pch_iir & SDE_TRANSA_FIFO_UNDER) |
Matthias Kaehlcke | a219603 | 2017-07-17 11:14:03 -0700 | [diff] [blame] | 2370 | intel_pch_fifo_underrun_irq_handler(dev_priv, PIPE_A); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2371 | |
| 2372 | if (pch_iir & SDE_TRANSB_FIFO_UNDER) |
Matthias Kaehlcke | a219603 | 2017-07-17 11:14:03 -0700 | [diff] [blame] | 2373 | intel_pch_fifo_underrun_irq_handler(dev_priv, PIPE_B); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2374 | } |
| 2375 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2376 | static void ivb_err_int_handler(struct drm_i915_private *dev_priv) |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2377 | { |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2378 | u32 err_int = I915_READ(GEN7_ERR_INT); |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 2379 | enum pipe pipe; |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2380 | |
Paulo Zanoni | de032bf | 2013-04-12 17:57:58 -0300 | [diff] [blame] | 2381 | if (err_int & ERR_INT_POISON) |
| 2382 | DRM_ERROR("Poison interrupt\n"); |
| 2383 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2384 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 2385 | if (err_int & ERR_INT_FIFO_UNDERRUN(pipe)) |
| 2386 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2387 | |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 2388 | if (err_int & ERR_INT_PIPE_CRC_DONE(pipe)) { |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2389 | if (IS_IVYBRIDGE(dev_priv)) |
| 2390 | ivb_pipe_crc_irq_handler(dev_priv, pipe); |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 2391 | else |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2392 | hsw_pipe_crc_irq_handler(dev_priv, pipe); |
Daniel Vetter | 5a69b89 | 2013-10-16 22:55:52 +0200 | [diff] [blame] | 2393 | } |
| 2394 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2395 | |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2396 | I915_WRITE(GEN7_ERR_INT, err_int); |
| 2397 | } |
| 2398 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2399 | static void cpt_serr_int_handler(struct drm_i915_private *dev_priv) |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2400 | { |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2401 | u32 serr_int = I915_READ(SERR_INT); |
Mika Kahola | 45c1cd8 | 2017-10-10 13:17:06 +0300 | [diff] [blame] | 2402 | enum pipe pipe; |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2403 | |
Paulo Zanoni | de032bf | 2013-04-12 17:57:58 -0300 | [diff] [blame] | 2404 | if (serr_int & SERR_INT_POISON) |
| 2405 | DRM_ERROR("PCH poison interrupt\n"); |
| 2406 | |
Mika Kahola | 45c1cd8 | 2017-10-10 13:17:06 +0300 | [diff] [blame] | 2407 | for_each_pipe(dev_priv, pipe) |
| 2408 | if (serr_int & SERR_INT_TRANS_FIFO_UNDERRUN(pipe)) |
| 2409 | intel_pch_fifo_underrun_irq_handler(dev_priv, pipe); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2410 | |
| 2411 | I915_WRITE(SERR_INT, serr_int); |
Jesse Barnes | 776ad80 | 2011-01-04 15:09:39 -0800 | [diff] [blame] | 2412 | } |
| 2413 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2414 | static void cpt_irq_handler(struct drm_i915_private *dev_priv, u32 pch_iir) |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 2415 | { |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 2416 | int pipe; |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 2417 | u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK_CPT; |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 2418 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2419 | ibx_hpd_irq_handler(dev_priv, hotplug_trigger, hpd_cpt); |
Daniel Vetter | 91d131d | 2013-06-27 17:52:14 +0200 | [diff] [blame] | 2420 | |
Ville Syrjälä | cfc33bf | 2013-04-17 17:48:48 +0300 | [diff] [blame] | 2421 | if (pch_iir & SDE_AUDIO_POWER_MASK_CPT) { |
| 2422 | int port = ffs((pch_iir & SDE_AUDIO_POWER_MASK_CPT) >> |
| 2423 | SDE_AUDIO_POWER_SHIFT_CPT); |
| 2424 | DRM_DEBUG_DRIVER("PCH audio power change on port %c\n", |
| 2425 | port_name(port)); |
| 2426 | } |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 2427 | |
| 2428 | if (pch_iir & SDE_AUX_MASK_CPT) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2429 | dp_aux_irq_handler(dev_priv); |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 2430 | |
| 2431 | if (pch_iir & SDE_GMBUS_CPT) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2432 | gmbus_irq_handler(dev_priv); |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 2433 | |
| 2434 | if (pch_iir & SDE_AUDIO_CP_REQ_CPT) |
| 2435 | DRM_DEBUG_DRIVER("Audio CP request interrupt\n"); |
| 2436 | |
| 2437 | if (pch_iir & SDE_AUDIO_CP_CHG_CPT) |
| 2438 | DRM_DEBUG_DRIVER("Audio CP change interrupt\n"); |
| 2439 | |
| 2440 | if (pch_iir & SDE_FDI_MASK_CPT) |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2441 | for_each_pipe(dev_priv, pipe) |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 2442 | DRM_DEBUG_DRIVER(" pipe %c FDI IIR: 0x%08x\n", |
| 2443 | pipe_name(pipe), |
| 2444 | I915_READ(FDI_RX_IIR(pipe))); |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 2445 | |
| 2446 | if (pch_iir & SDE_ERROR_CPT) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2447 | cpt_serr_int_handler(dev_priv); |
Adam Jackson | 23e81d6 | 2012-06-06 15:45:44 -0400 | [diff] [blame] | 2448 | } |
| 2449 | |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 2450 | static void icp_irq_handler(struct drm_i915_private *dev_priv, u32 pch_iir) |
| 2451 | { |
| 2452 | u32 ddi_hotplug_trigger = pch_iir & SDE_DDI_MASK_ICP; |
| 2453 | u32 tc_hotplug_trigger = pch_iir & SDE_TC_MASK_ICP; |
| 2454 | u32 pin_mask = 0, long_mask = 0; |
| 2455 | |
| 2456 | if (ddi_hotplug_trigger) { |
| 2457 | u32 dig_hotplug_reg; |
| 2458 | |
| 2459 | dig_hotplug_reg = I915_READ(SHOTPLUG_CTL_DDI); |
| 2460 | I915_WRITE(SHOTPLUG_CTL_DDI, dig_hotplug_reg); |
| 2461 | |
| 2462 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, |
| 2463 | ddi_hotplug_trigger, |
| 2464 | dig_hotplug_reg, hpd_icp, |
| 2465 | icp_ddi_port_hotplug_long_detect); |
| 2466 | } |
| 2467 | |
| 2468 | if (tc_hotplug_trigger) { |
| 2469 | u32 dig_hotplug_reg; |
| 2470 | |
| 2471 | dig_hotplug_reg = I915_READ(SHOTPLUG_CTL_TC); |
| 2472 | I915_WRITE(SHOTPLUG_CTL_TC, dig_hotplug_reg); |
| 2473 | |
| 2474 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, |
| 2475 | tc_hotplug_trigger, |
| 2476 | dig_hotplug_reg, hpd_icp, |
| 2477 | icp_tc_port_hotplug_long_detect); |
| 2478 | } |
| 2479 | |
| 2480 | if (pin_mask) |
| 2481 | intel_hpd_irq_handler(dev_priv, pin_mask, long_mask); |
| 2482 | |
| 2483 | if (pch_iir & SDE_GMBUS_ICP) |
| 2484 | gmbus_irq_handler(dev_priv); |
| 2485 | } |
| 2486 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2487 | static void spt_irq_handler(struct drm_i915_private *dev_priv, u32 pch_iir) |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 2488 | { |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 2489 | u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK_SPT & |
| 2490 | ~SDE_PORTE_HOTPLUG_SPT; |
| 2491 | u32 hotplug2_trigger = pch_iir & SDE_PORTE_HOTPLUG_SPT; |
| 2492 | u32 pin_mask = 0, long_mask = 0; |
| 2493 | |
| 2494 | if (hotplug_trigger) { |
| 2495 | u32 dig_hotplug_reg; |
| 2496 | |
| 2497 | dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG); |
| 2498 | I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg); |
| 2499 | |
Rodrigo Vivi | cf53902 | 2018-01-29 15:22:21 -0800 | [diff] [blame] | 2500 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, |
| 2501 | hotplug_trigger, dig_hotplug_reg, hpd_spt, |
Ville Syrjälä | 74c0b39 | 2015-08-27 23:56:07 +0300 | [diff] [blame] | 2502 | spt_port_hotplug_long_detect); |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 2503 | } |
| 2504 | |
| 2505 | if (hotplug2_trigger) { |
| 2506 | u32 dig_hotplug_reg; |
| 2507 | |
| 2508 | dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG2); |
| 2509 | I915_WRITE(PCH_PORT_HOTPLUG2, dig_hotplug_reg); |
| 2510 | |
Rodrigo Vivi | cf53902 | 2018-01-29 15:22:21 -0800 | [diff] [blame] | 2511 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, |
| 2512 | hotplug2_trigger, dig_hotplug_reg, hpd_spt, |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 2513 | spt_port_hotplug2_long_detect); |
| 2514 | } |
| 2515 | |
| 2516 | if (pin_mask) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2517 | intel_hpd_irq_handler(dev_priv, pin_mask, long_mask); |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 2518 | |
| 2519 | if (pch_iir & SDE_GMBUS_CPT) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2520 | gmbus_irq_handler(dev_priv); |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 2521 | } |
| 2522 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2523 | static void ilk_hpd_irq_handler(struct drm_i915_private *dev_priv, |
| 2524 | u32 hotplug_trigger, |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2525 | const u32 hpd[HPD_NUM_PINS]) |
| 2526 | { |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2527 | u32 dig_hotplug_reg, pin_mask = 0, long_mask = 0; |
| 2528 | |
| 2529 | dig_hotplug_reg = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL); |
| 2530 | I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, dig_hotplug_reg); |
| 2531 | |
Rodrigo Vivi | cf53902 | 2018-01-29 15:22:21 -0800 | [diff] [blame] | 2532 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, hotplug_trigger, |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2533 | dig_hotplug_reg, hpd, |
| 2534 | ilk_port_hotplug_long_detect); |
| 2535 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2536 | intel_hpd_irq_handler(dev_priv, pin_mask, long_mask); |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2537 | } |
| 2538 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2539 | static void ilk_display_irq_handler(struct drm_i915_private *dev_priv, |
| 2540 | u32 de_iir) |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2541 | { |
Daniel Vetter | 40da17c2 | 2013-10-21 18:04:36 +0200 | [diff] [blame] | 2542 | enum pipe pipe; |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 2543 | u32 hotplug_trigger = de_iir & DE_DP_A_HOTPLUG; |
| 2544 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2545 | if (hotplug_trigger) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2546 | ilk_hpd_irq_handler(dev_priv, hotplug_trigger, hpd_ilk); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2547 | |
| 2548 | if (de_iir & DE_AUX_CHANNEL_A) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2549 | dp_aux_irq_handler(dev_priv); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2550 | |
| 2551 | if (de_iir & DE_GSE) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2552 | intel_opregion_asle_intr(dev_priv); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2553 | |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2554 | if (de_iir & DE_POISON) |
| 2555 | DRM_ERROR("Poison interrupt\n"); |
| 2556 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2557 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | fd3a402 | 2017-07-20 19:57:51 +0200 | [diff] [blame] | 2558 | if (de_iir & DE_PIPE_VBLANK(pipe)) |
| 2559 | drm_handle_vblank(&dev_priv->drm, pipe); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2560 | |
Daniel Vetter | 40da17c2 | 2013-10-21 18:04:36 +0200 | [diff] [blame] | 2561 | if (de_iir & DE_PIPE_FIFO_UNDERRUN(pipe)) |
Daniel Vetter | 1f7247c | 2014-09-30 10:56:48 +0200 | [diff] [blame] | 2562 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2563 | |
Daniel Vetter | 40da17c2 | 2013-10-21 18:04:36 +0200 | [diff] [blame] | 2564 | if (de_iir & DE_PIPE_CRC_DONE(pipe)) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2565 | i9xx_pipe_crc_irq_handler(dev_priv, pipe); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2566 | } |
| 2567 | |
| 2568 | /* check event from PCH */ |
| 2569 | if (de_iir & DE_PCH_EVENT) { |
| 2570 | u32 pch_iir = I915_READ(SDEIIR); |
| 2571 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2572 | if (HAS_PCH_CPT(dev_priv)) |
| 2573 | cpt_irq_handler(dev_priv, pch_iir); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2574 | else |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2575 | ibx_irq_handler(dev_priv, pch_iir); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2576 | |
| 2577 | /* should clear PCH hotplug event before clear CPU irq */ |
| 2578 | I915_WRITE(SDEIIR, pch_iir); |
| 2579 | } |
| 2580 | |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 2581 | if (IS_GEN(dev_priv, 5) && de_iir & DE_PCU_EVENT) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2582 | ironlake_rps_change_irq_handler(dev_priv); |
Paulo Zanoni | c008bc6 | 2013-07-12 16:35:10 -0300 | [diff] [blame] | 2583 | } |
| 2584 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2585 | static void ivb_display_irq_handler(struct drm_i915_private *dev_priv, |
| 2586 | u32 de_iir) |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2587 | { |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 2588 | enum pipe pipe; |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 2589 | u32 hotplug_trigger = de_iir & DE_DP_A_HOTPLUG_IVB; |
| 2590 | |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2591 | if (hotplug_trigger) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2592 | ilk_hpd_irq_handler(dev_priv, hotplug_trigger, hpd_ivb); |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2593 | |
| 2594 | if (de_iir & DE_ERR_INT_IVB) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2595 | ivb_err_int_handler(dev_priv); |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2596 | |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2597 | if (de_iir & DE_EDP_PSR_INT_HSW) { |
| 2598 | u32 psr_iir = I915_READ(EDP_PSR_IIR); |
| 2599 | |
| 2600 | intel_psr_irq_handler(dev_priv, psr_iir); |
| 2601 | I915_WRITE(EDP_PSR_IIR, psr_iir); |
| 2602 | } |
Daniel Vetter | fc34044 | 2018-04-05 15:00:23 -0700 | [diff] [blame] | 2603 | |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2604 | if (de_iir & DE_AUX_CHANNEL_A_IVB) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2605 | dp_aux_irq_handler(dev_priv); |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2606 | |
| 2607 | if (de_iir & DE_GSE_IVB) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2608 | intel_opregion_asle_intr(dev_priv); |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2609 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2610 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | fd3a402 | 2017-07-20 19:57:51 +0200 | [diff] [blame] | 2611 | if (de_iir & (DE_PIPE_VBLANK_IVB(pipe))) |
| 2612 | drm_handle_vblank(&dev_priv->drm, pipe); |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2613 | } |
| 2614 | |
| 2615 | /* check event from PCH */ |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2616 | if (!HAS_PCH_NOP(dev_priv) && (de_iir & DE_PCH_EVENT_IVB)) { |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2617 | u32 pch_iir = I915_READ(SDEIIR); |
| 2618 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2619 | cpt_irq_handler(dev_priv, pch_iir); |
Paulo Zanoni | 9719fb9 | 2013-07-12 16:35:11 -0300 | [diff] [blame] | 2620 | |
| 2621 | /* clear PCH hotplug event before clear CPU irq */ |
| 2622 | I915_WRITE(SDEIIR, pch_iir); |
| 2623 | } |
| 2624 | } |
| 2625 | |
Oscar Mateo | 72c90f6 | 2014-06-16 16:10:57 +0100 | [diff] [blame] | 2626 | /* |
| 2627 | * To handle irqs with the minimum potential races with fresh interrupts, we: |
| 2628 | * 1 - Disable Master Interrupt Control. |
| 2629 | * 2 - Find the source(s) of the interrupt. |
| 2630 | * 3 - Clear the Interrupt Identity bits (IIR). |
| 2631 | * 4 - Process the interrupt(s) that had bits set in the IIRs. |
| 2632 | * 5 - Re-enable Master Interrupt Control. |
| 2633 | */ |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2634 | static irqreturn_t ironlake_irq_handler(int irq, void *arg) |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2635 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 2636 | struct drm_device *dev = arg; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2637 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2638 | u32 de_iir, gt_iir, de_ier, sde_ier = 0; |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2639 | irqreturn_t ret = IRQ_NONE; |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2640 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 2641 | if (!intel_irqs_enabled(dev_priv)) |
| 2642 | return IRQ_NONE; |
| 2643 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 2644 | /* IRQs are synced during runtime_suspend, we don't require a wakeref */ |
| 2645 | disable_rpm_wakeref_asserts(dev_priv); |
| 2646 | |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2647 | /* disable master interrupt before clearing iir */ |
| 2648 | de_ier = I915_READ(DEIER); |
| 2649 | I915_WRITE(DEIER, de_ier & ~DE_MASTER_IRQ_CONTROL); |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2650 | |
Paulo Zanoni | 44498ae | 2013-02-22 17:05:28 -0300 | [diff] [blame] | 2651 | /* Disable south interrupts. We'll only write to SDEIIR once, so further |
| 2652 | * interrupts will will be stored on its back queue, and then we'll be |
| 2653 | * able to process them after we restore SDEIER (as soon as we restore |
| 2654 | * it, we'll get an interrupt if SDEIIR still has something to process |
| 2655 | * due to its back queue). */ |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2656 | if (!HAS_PCH_NOP(dev_priv)) { |
Ben Widawsky | ab5c608 | 2013-04-05 13:12:41 -0700 | [diff] [blame] | 2657 | sde_ier = I915_READ(SDEIER); |
| 2658 | I915_WRITE(SDEIER, 0); |
Ben Widawsky | ab5c608 | 2013-04-05 13:12:41 -0700 | [diff] [blame] | 2659 | } |
Paulo Zanoni | 44498ae | 2013-02-22 17:05:28 -0300 | [diff] [blame] | 2660 | |
Oscar Mateo | 72c90f6 | 2014-06-16 16:10:57 +0100 | [diff] [blame] | 2661 | /* Find, clear, then process each source of interrupt */ |
| 2662 | |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2663 | gt_iir = I915_READ(GTIIR); |
| 2664 | if (gt_iir) { |
Oscar Mateo | 72c90f6 | 2014-06-16 16:10:57 +0100 | [diff] [blame] | 2665 | I915_WRITE(GTIIR, gt_iir); |
| 2666 | ret = IRQ_HANDLED; |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2667 | if (INTEL_GEN(dev_priv) >= 6) |
Ville Syrjälä | 261e40b | 2016-04-13 21:19:57 +0300 | [diff] [blame] | 2668 | snb_gt_irq_handler(dev_priv, gt_iir); |
Paulo Zanoni | d8fc8a4 | 2013-07-19 18:57:55 -0300 | [diff] [blame] | 2669 | else |
Ville Syrjälä | 261e40b | 2016-04-13 21:19:57 +0300 | [diff] [blame] | 2670 | ilk_gt_irq_handler(dev_priv, gt_iir); |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2671 | } |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2672 | |
| 2673 | de_iir = I915_READ(DEIIR); |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2674 | if (de_iir) { |
Oscar Mateo | 72c90f6 | 2014-06-16 16:10:57 +0100 | [diff] [blame] | 2675 | I915_WRITE(DEIIR, de_iir); |
| 2676 | ret = IRQ_HANDLED; |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2677 | if (INTEL_GEN(dev_priv) >= 7) |
| 2678 | ivb_display_irq_handler(dev_priv, de_iir); |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2679 | else |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2680 | ilk_display_irq_handler(dev_priv, de_iir); |
Chris Wilson | 0e43406 | 2012-05-09 21:45:44 +0100 | [diff] [blame] | 2681 | } |
| 2682 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2683 | if (INTEL_GEN(dev_priv) >= 6) { |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2684 | u32 pm_iir = I915_READ(GEN6_PMIIR); |
| 2685 | if (pm_iir) { |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2686 | I915_WRITE(GEN6_PMIIR, pm_iir); |
| 2687 | ret = IRQ_HANDLED; |
Oscar Mateo | 72c90f6 | 2014-06-16 16:10:57 +0100 | [diff] [blame] | 2688 | gen6_rps_irq_handler(dev_priv, pm_iir); |
Paulo Zanoni | f1af8fc | 2013-07-12 19:56:30 -0300 | [diff] [blame] | 2689 | } |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2690 | } |
| 2691 | |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2692 | I915_WRITE(DEIER, de_ier); |
Chris Wilson | 74093f3 | 2018-06-28 21:12:03 +0100 | [diff] [blame] | 2693 | if (!HAS_PCH_NOP(dev_priv)) |
Ben Widawsky | ab5c608 | 2013-04-05 13:12:41 -0700 | [diff] [blame] | 2694 | I915_WRITE(SDEIER, sde_ier); |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2695 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 2696 | /* IRQs are synced during runtime_suspend, we don't require a wakeref */ |
| 2697 | enable_rpm_wakeref_asserts(dev_priv); |
| 2698 | |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 2699 | return ret; |
| 2700 | } |
| 2701 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2702 | static void bxt_hpd_irq_handler(struct drm_i915_private *dev_priv, |
| 2703 | u32 hotplug_trigger, |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2704 | const u32 hpd[HPD_NUM_PINS]) |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2705 | { |
Ville Syrjälä | cebd87a | 2015-08-27 23:56:09 +0300 | [diff] [blame] | 2706 | u32 dig_hotplug_reg, pin_mask = 0, long_mask = 0; |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2707 | |
Ville Syrjälä | a52bb15 | 2015-08-27 23:56:11 +0300 | [diff] [blame] | 2708 | dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG); |
| 2709 | I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg); |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2710 | |
Rodrigo Vivi | cf53902 | 2018-01-29 15:22:21 -0800 | [diff] [blame] | 2711 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, hotplug_trigger, |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2712 | dig_hotplug_reg, hpd, |
Ville Syrjälä | cebd87a | 2015-08-27 23:56:09 +0300 | [diff] [blame] | 2713 | bxt_port_hotplug_long_detect); |
Ville Syrjälä | 40e5641 | 2015-08-27 23:56:10 +0300 | [diff] [blame] | 2714 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2715 | intel_hpd_irq_handler(dev_priv, pin_mask, long_mask); |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2716 | } |
| 2717 | |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 2718 | static void gen11_hpd_irq_handler(struct drm_i915_private *dev_priv, u32 iir) |
| 2719 | { |
| 2720 | u32 pin_mask = 0, long_mask = 0; |
Dhinakaran Pandiyan | b796b97 | 2018-06-15 17:05:30 -0700 | [diff] [blame] | 2721 | u32 trigger_tc = iir & GEN11_DE_TC_HOTPLUG_MASK; |
| 2722 | u32 trigger_tbt = iir & GEN11_DE_TBT_HOTPLUG_MASK; |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 2723 | |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 2724 | if (trigger_tc) { |
Dhinakaran Pandiyan | b796b97 | 2018-06-15 17:05:30 -0700 | [diff] [blame] | 2725 | u32 dig_hotplug_reg; |
| 2726 | |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 2727 | dig_hotplug_reg = I915_READ(GEN11_TC_HOTPLUG_CTL); |
| 2728 | I915_WRITE(GEN11_TC_HOTPLUG_CTL, dig_hotplug_reg); |
| 2729 | |
| 2730 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, trigger_tc, |
Dhinakaran Pandiyan | b796b97 | 2018-06-15 17:05:30 -0700 | [diff] [blame] | 2731 | dig_hotplug_reg, hpd_gen11, |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 2732 | gen11_port_hotplug_long_detect); |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 2733 | } |
Dhinakaran Pandiyan | b796b97 | 2018-06-15 17:05:30 -0700 | [diff] [blame] | 2734 | |
| 2735 | if (trigger_tbt) { |
| 2736 | u32 dig_hotplug_reg; |
| 2737 | |
| 2738 | dig_hotplug_reg = I915_READ(GEN11_TBT_HOTPLUG_CTL); |
| 2739 | I915_WRITE(GEN11_TBT_HOTPLUG_CTL, dig_hotplug_reg); |
| 2740 | |
| 2741 | intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, trigger_tbt, |
| 2742 | dig_hotplug_reg, hpd_gen11, |
| 2743 | gen11_port_hotplug_long_detect); |
| 2744 | } |
| 2745 | |
| 2746 | if (pin_mask) |
| 2747 | intel_hpd_irq_handler(dev_priv, pin_mask, long_mask); |
| 2748 | else |
| 2749 | DRM_ERROR("Unexpected DE HPD interrupt 0x%08x\n", iir); |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 2750 | } |
| 2751 | |
Lucas De Marchi | 9d17210 | 2019-02-25 16:49:00 -0800 | [diff] [blame] | 2752 | static u32 gen8_de_port_aux_mask(struct drm_i915_private *dev_priv) |
| 2753 | { |
| 2754 | u32 mask = GEN8_AUX_CHANNEL_A; |
| 2755 | |
| 2756 | if (INTEL_GEN(dev_priv) >= 9) |
| 2757 | mask |= GEN9_AUX_CHANNEL_B | |
| 2758 | GEN9_AUX_CHANNEL_C | |
| 2759 | GEN9_AUX_CHANNEL_D; |
| 2760 | |
| 2761 | if (IS_CNL_WITH_PORT_F(dev_priv)) |
| 2762 | mask |= CNL_AUX_CHANNEL_F; |
| 2763 | |
| 2764 | if (INTEL_GEN(dev_priv) >= 11) |
| 2765 | mask |= ICL_AUX_CHANNEL_E | |
| 2766 | CNL_AUX_CHANNEL_F; |
| 2767 | |
| 2768 | return mask; |
| 2769 | } |
| 2770 | |
Tvrtko Ursulin | f11a0f4 | 2016-01-12 16:04:07 +0000 | [diff] [blame] | 2771 | static irqreturn_t |
| 2772 | gen8_de_irq_handler(struct drm_i915_private *dev_priv, u32 master_ctl) |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2773 | { |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2774 | irqreturn_t ret = IRQ_NONE; |
Tvrtko Ursulin | f11a0f4 | 2016-01-12 16:04:07 +0000 | [diff] [blame] | 2775 | u32 iir; |
Daniel Vetter | c42664c | 2013-11-07 11:05:40 +0100 | [diff] [blame] | 2776 | enum pipe pipe; |
Jesse Barnes | 88e0470 | 2014-11-13 17:51:48 +0000 | [diff] [blame] | 2777 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2778 | if (master_ctl & GEN8_DE_MISC_IRQ) { |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2779 | iir = I915_READ(GEN8_DE_MISC_IIR); |
| 2780 | if (iir) { |
Ville Syrjälä | e04f7ec | 2018-04-03 14:24:18 -0700 | [diff] [blame] | 2781 | bool found = false; |
| 2782 | |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2783 | I915_WRITE(GEN8_DE_MISC_IIR, iir); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2784 | ret = IRQ_HANDLED; |
Ville Syrjälä | e04f7ec | 2018-04-03 14:24:18 -0700 | [diff] [blame] | 2785 | |
| 2786 | if (iir & GEN8_DE_MISC_GSE) { |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2787 | intel_opregion_asle_intr(dev_priv); |
Ville Syrjälä | e04f7ec | 2018-04-03 14:24:18 -0700 | [diff] [blame] | 2788 | found = true; |
| 2789 | } |
| 2790 | |
| 2791 | if (iir & GEN8_DE_EDP_PSR) { |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2792 | u32 psr_iir = I915_READ(EDP_PSR_IIR); |
| 2793 | |
| 2794 | intel_psr_irq_handler(dev_priv, psr_iir); |
| 2795 | I915_WRITE(EDP_PSR_IIR, psr_iir); |
Ville Syrjälä | e04f7ec | 2018-04-03 14:24:18 -0700 | [diff] [blame] | 2796 | found = true; |
| 2797 | } |
| 2798 | |
| 2799 | if (!found) |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2800 | DRM_ERROR("Unexpected DE Misc interrupt\n"); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2801 | } |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2802 | else |
| 2803 | DRM_ERROR("The master control interrupt lied (DE MISC)!\n"); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2804 | } |
| 2805 | |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 2806 | if (INTEL_GEN(dev_priv) >= 11 && (master_ctl & GEN11_DE_HPD_IRQ)) { |
| 2807 | iir = I915_READ(GEN11_DE_HPD_IIR); |
| 2808 | if (iir) { |
| 2809 | I915_WRITE(GEN11_DE_HPD_IIR, iir); |
| 2810 | ret = IRQ_HANDLED; |
| 2811 | gen11_hpd_irq_handler(dev_priv, iir); |
| 2812 | } else { |
| 2813 | DRM_ERROR("The master control interrupt lied, (DE HPD)!\n"); |
| 2814 | } |
| 2815 | } |
| 2816 | |
Daniel Vetter | 6d766f0 | 2013-11-07 14:49:55 +0100 | [diff] [blame] | 2817 | if (master_ctl & GEN8_DE_PORT_IRQ) { |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2818 | iir = I915_READ(GEN8_DE_PORT_IIR); |
| 2819 | if (iir) { |
| 2820 | u32 tmp_mask; |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2821 | bool found = false; |
Ville Syrjälä | cebd87a | 2015-08-27 23:56:09 +0300 | [diff] [blame] | 2822 | |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2823 | I915_WRITE(GEN8_DE_PORT_IIR, iir); |
Daniel Vetter | 6d766f0 | 2013-11-07 14:49:55 +0100 | [diff] [blame] | 2824 | ret = IRQ_HANDLED; |
Jesse Barnes | 88e0470 | 2014-11-13 17:51:48 +0000 | [diff] [blame] | 2825 | |
Lucas De Marchi | 9d17210 | 2019-02-25 16:49:00 -0800 | [diff] [blame] | 2826 | if (iir & gen8_de_port_aux_mask(dev_priv)) { |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2827 | dp_aux_irq_handler(dev_priv); |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2828 | found = true; |
| 2829 | } |
| 2830 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 2831 | if (IS_GEN9_LP(dev_priv)) { |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2832 | tmp_mask = iir & BXT_DE_PORT_HOTPLUG_MASK; |
| 2833 | if (tmp_mask) { |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2834 | bxt_hpd_irq_handler(dev_priv, tmp_mask, |
| 2835 | hpd_bxt); |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2836 | found = true; |
| 2837 | } |
| 2838 | } else if (IS_BROADWELL(dev_priv)) { |
| 2839 | tmp_mask = iir & GEN8_PORT_DP_A_HOTPLUG; |
| 2840 | if (tmp_mask) { |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2841 | ilk_hpd_irq_handler(dev_priv, |
| 2842 | tmp_mask, hpd_bdw); |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2843 | found = true; |
| 2844 | } |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2845 | } |
| 2846 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 2847 | if (IS_GEN9_LP(dev_priv) && (iir & BXT_DE_PORT_GMBUS)) { |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2848 | gmbus_irq_handler(dev_priv); |
Shashank Sharma | 9e63743 | 2014-08-22 17:40:43 +0530 | [diff] [blame] | 2849 | found = true; |
| 2850 | } |
| 2851 | |
Shashank Sharma | d04a492 | 2014-08-22 17:40:41 +0530 | [diff] [blame] | 2852 | if (!found) |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2853 | DRM_ERROR("Unexpected DE Port interrupt\n"); |
Daniel Vetter | 6d766f0 | 2013-11-07 14:49:55 +0100 | [diff] [blame] | 2854 | } |
Oscar Mateo | 38cc46d | 2014-06-16 16:10:59 +0100 | [diff] [blame] | 2855 | else |
| 2856 | DRM_ERROR("The master control interrupt lied (DE PORT)!\n"); |
Daniel Vetter | 6d766f0 | 2013-11-07 14:49:55 +0100 | [diff] [blame] | 2857 | } |
| 2858 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 2859 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | fd3a402 | 2017-07-20 19:57:51 +0200 | [diff] [blame] | 2860 | u32 fault_errors; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2861 | |
Daniel Vetter | c42664c | 2013-11-07 11:05:40 +0100 | [diff] [blame] | 2862 | if (!(master_ctl & GEN8_DE_PIPE_IRQ(pipe))) |
| 2863 | continue; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2864 | |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2865 | iir = I915_READ(GEN8_DE_PIPE_IIR(pipe)); |
| 2866 | if (!iir) { |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2867 | DRM_ERROR("The master control interrupt lied (DE PIPE)!\n"); |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2868 | continue; |
| 2869 | } |
| 2870 | |
| 2871 | ret = IRQ_HANDLED; |
| 2872 | I915_WRITE(GEN8_DE_PIPE_IIR(pipe), iir); |
| 2873 | |
Daniel Vetter | fd3a402 | 2017-07-20 19:57:51 +0200 | [diff] [blame] | 2874 | if (iir & GEN8_PIPE_VBLANK) |
| 2875 | drm_handle_vblank(&dev_priv->drm, pipe); |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2876 | |
| 2877 | if (iir & GEN8_PIPE_CDCLK_CRC_DONE) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2878 | hsw_pipe_crc_irq_handler(dev_priv, pipe); |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2879 | |
| 2880 | if (iir & GEN8_PIPE_FIFO_UNDERRUN) |
| 2881 | intel_cpu_fifo_underrun_irq_handler(dev_priv, pipe); |
| 2882 | |
| 2883 | fault_errors = iir; |
Pandiyan, Dhinakaran | bca2bf2 | 2017-07-18 11:28:00 -0700 | [diff] [blame] | 2884 | if (INTEL_GEN(dev_priv) >= 9) |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2885 | fault_errors &= GEN9_DE_PIPE_IRQ_FAULT_ERRORS; |
| 2886 | else |
| 2887 | fault_errors &= GEN8_DE_PIPE_IRQ_FAULT_ERRORS; |
| 2888 | |
| 2889 | if (fault_errors) |
Tvrtko Ursulin | 1353ec3 | 2016-10-27 13:48:32 +0100 | [diff] [blame] | 2890 | DRM_ERROR("Fault errors on pipe %c: 0x%08x\n", |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2891 | pipe_name(pipe), |
| 2892 | fault_errors); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2893 | } |
| 2894 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2895 | if (HAS_PCH_SPLIT(dev_priv) && !HAS_PCH_NOP(dev_priv) && |
Shashank Sharma | 266ea3d | 2014-08-22 17:40:42 +0530 | [diff] [blame] | 2896 | master_ctl & GEN8_DE_PCH_IRQ) { |
Daniel Vetter | 92d03a8 | 2013-11-07 11:05:43 +0100 | [diff] [blame] | 2897 | /* |
| 2898 | * FIXME(BDW): Assume for now that the new interrupt handling |
| 2899 | * scheme also closed the SDE interrupt handling race we've seen |
| 2900 | * on older pch-split platforms. But this needs testing. |
| 2901 | */ |
Tvrtko Ursulin | e32192e | 2016-01-12 16:04:06 +0000 | [diff] [blame] | 2902 | iir = I915_READ(SDEIIR); |
| 2903 | if (iir) { |
| 2904 | I915_WRITE(SDEIIR, iir); |
Daniel Vetter | 92d03a8 | 2013-11-07 11:05:43 +0100 | [diff] [blame] | 2905 | ret = IRQ_HANDLED; |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 2906 | |
Rodrigo Vivi | 29b43ae | 2019-03-13 14:43:07 -0700 | [diff] [blame] | 2907 | if (INTEL_PCH_TYPE(dev_priv) >= PCH_ICP) |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 2908 | icp_irq_handler(dev_priv, iir); |
Rodrigo Vivi | c6c30b9 | 2019-03-08 13:43:00 -0800 | [diff] [blame] | 2909 | else if (INTEL_PCH_TYPE(dev_priv) >= PCH_SPT) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2910 | spt_irq_handler(dev_priv, iir); |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 2911 | else |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 2912 | cpt_irq_handler(dev_priv, iir); |
Jani Nikula | 2dfb0b8 | 2016-01-07 10:29:10 +0200 | [diff] [blame] | 2913 | } else { |
| 2914 | /* |
| 2915 | * Like on previous PCH there seems to be something |
| 2916 | * fishy going on with forwarding PCH interrupts. |
| 2917 | */ |
| 2918 | DRM_DEBUG_DRIVER("The master control interrupt lied (SDE)!\n"); |
| 2919 | } |
Daniel Vetter | 92d03a8 | 2013-11-07 11:05:43 +0100 | [diff] [blame] | 2920 | } |
| 2921 | |
Tvrtko Ursulin | f11a0f4 | 2016-01-12 16:04:07 +0000 | [diff] [blame] | 2922 | return ret; |
| 2923 | } |
| 2924 | |
Mika Kuoppala | 4376b9c | 2018-10-15 17:14:38 +0300 | [diff] [blame] | 2925 | static inline u32 gen8_master_intr_disable(void __iomem * const regs) |
| 2926 | { |
| 2927 | raw_reg_write(regs, GEN8_MASTER_IRQ, 0); |
| 2928 | |
| 2929 | /* |
| 2930 | * Now with master disabled, get a sample of level indications |
| 2931 | * for this interrupt. Indications will be cleared on related acks. |
| 2932 | * New indications can and will light up during processing, |
| 2933 | * and will generate new interrupt after enabling master. |
| 2934 | */ |
| 2935 | return raw_reg_read(regs, GEN8_MASTER_IRQ); |
| 2936 | } |
| 2937 | |
| 2938 | static inline void gen8_master_intr_enable(void __iomem * const regs) |
| 2939 | { |
| 2940 | raw_reg_write(regs, GEN8_MASTER_IRQ, GEN8_MASTER_IRQ_CONTROL); |
| 2941 | } |
| 2942 | |
Tvrtko Ursulin | f11a0f4 | 2016-01-12 16:04:07 +0000 | [diff] [blame] | 2943 | static irqreturn_t gen8_irq_handler(int irq, void *arg) |
| 2944 | { |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 2945 | struct drm_i915_private *dev_priv = to_i915(arg); |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 2946 | void __iomem * const regs = dev_priv->uncore.regs; |
Tvrtko Ursulin | f11a0f4 | 2016-01-12 16:04:07 +0000 | [diff] [blame] | 2947 | u32 master_ctl; |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 2948 | u32 gt_iir[4]; |
Tvrtko Ursulin | f11a0f4 | 2016-01-12 16:04:07 +0000 | [diff] [blame] | 2949 | |
| 2950 | if (!intel_irqs_enabled(dev_priv)) |
| 2951 | return IRQ_NONE; |
| 2952 | |
Mika Kuoppala | 4376b9c | 2018-10-15 17:14:38 +0300 | [diff] [blame] | 2953 | master_ctl = gen8_master_intr_disable(regs); |
| 2954 | if (!master_ctl) { |
| 2955 | gen8_master_intr_enable(regs); |
Tvrtko Ursulin | f11a0f4 | 2016-01-12 16:04:07 +0000 | [diff] [blame] | 2956 | return IRQ_NONE; |
Mika Kuoppala | 4376b9c | 2018-10-15 17:14:38 +0300 | [diff] [blame] | 2957 | } |
Tvrtko Ursulin | f11a0f4 | 2016-01-12 16:04:07 +0000 | [diff] [blame] | 2958 | |
Tvrtko Ursulin | f11a0f4 | 2016-01-12 16:04:07 +0000 | [diff] [blame] | 2959 | /* Find, clear, then process each source of interrupt */ |
Chris Wilson | 55ef72f | 2018-02-02 15:34:48 +0000 | [diff] [blame] | 2960 | gen8_gt_irq_ack(dev_priv, master_ctl, gt_iir); |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 2961 | |
| 2962 | /* IRQs are synced during runtime_suspend, we don't require a wakeref */ |
| 2963 | if (master_ctl & ~GEN8_GT_IRQS) { |
| 2964 | disable_rpm_wakeref_asserts(dev_priv); |
| 2965 | gen8_de_irq_handler(dev_priv, master_ctl); |
| 2966 | enable_rpm_wakeref_asserts(dev_priv); |
| 2967 | } |
Tvrtko Ursulin | f11a0f4 | 2016-01-12 16:04:07 +0000 | [diff] [blame] | 2968 | |
Mika Kuoppala | 4376b9c | 2018-10-15 17:14:38 +0300 | [diff] [blame] | 2969 | gen8_master_intr_enable(regs); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2970 | |
Chris Wilson | f0fd96f | 2018-02-15 07:37:12 +0000 | [diff] [blame] | 2971 | gen8_gt_irq_handler(dev_priv, master_ctl, gt_iir); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 2972 | |
Chris Wilson | 55ef72f | 2018-02-02 15:34:48 +0000 | [diff] [blame] | 2973 | return IRQ_HANDLED; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2974 | } |
| 2975 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 2976 | static u32 |
Mika Kuoppala | f744dbc | 2018-04-06 12:31:45 +0300 | [diff] [blame] | 2977 | gen11_gt_engine_identity(struct drm_i915_private * const i915, |
| 2978 | const unsigned int bank, const unsigned int bit) |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 2979 | { |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 2980 | void __iomem * const regs = i915->uncore.regs; |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 2981 | u32 timeout_ts; |
| 2982 | u32 ident; |
| 2983 | |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 2984 | lockdep_assert_held(&i915->irq_lock); |
| 2985 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 2986 | raw_reg_write(regs, GEN11_IIR_REG_SELECTOR(bank), BIT(bit)); |
| 2987 | |
| 2988 | /* |
| 2989 | * NB: Specs do not specify how long to spin wait, |
| 2990 | * so we do ~100us as an educated guess. |
| 2991 | */ |
| 2992 | timeout_ts = (local_clock() >> 10) + 100; |
| 2993 | do { |
| 2994 | ident = raw_reg_read(regs, GEN11_INTR_IDENTITY_REG(bank)); |
| 2995 | } while (!(ident & GEN11_INTR_DATA_VALID) && |
| 2996 | !time_after32(local_clock() >> 10, timeout_ts)); |
| 2997 | |
| 2998 | if (unlikely(!(ident & GEN11_INTR_DATA_VALID))) { |
| 2999 | DRM_ERROR("INTR_IDENTITY_REG%u:%u 0x%08x not valid!\n", |
| 3000 | bank, bit, ident); |
| 3001 | return 0; |
| 3002 | } |
| 3003 | |
| 3004 | raw_reg_write(regs, GEN11_INTR_IDENTITY_REG(bank), |
| 3005 | GEN11_INTR_DATA_VALID); |
| 3006 | |
Mika Kuoppala | f744dbc | 2018-04-06 12:31:45 +0300 | [diff] [blame] | 3007 | return ident; |
| 3008 | } |
| 3009 | |
| 3010 | static void |
| 3011 | gen11_other_irq_handler(struct drm_i915_private * const i915, |
| 3012 | const u8 instance, const u16 iir) |
| 3013 | { |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 3014 | if (instance == OTHER_GTPM_INSTANCE) |
Mika Kuoppala | a087baf | 2019-04-10 16:21:23 +0300 | [diff] [blame] | 3015 | return gen11_rps_irq_handler(i915, iir); |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 3016 | |
Mika Kuoppala | f744dbc | 2018-04-06 12:31:45 +0300 | [diff] [blame] | 3017 | WARN_ONCE(1, "unhandled other interrupt instance=0x%x, iir=0x%x\n", |
| 3018 | instance, iir); |
| 3019 | } |
| 3020 | |
| 3021 | static void |
| 3022 | gen11_engine_irq_handler(struct drm_i915_private * const i915, |
| 3023 | const u8 class, const u8 instance, const u16 iir) |
| 3024 | { |
| 3025 | struct intel_engine_cs *engine; |
| 3026 | |
| 3027 | if (instance <= MAX_ENGINE_INSTANCE) |
| 3028 | engine = i915->engine_class[class][instance]; |
| 3029 | else |
| 3030 | engine = NULL; |
| 3031 | |
| 3032 | if (likely(engine)) |
| 3033 | return gen8_cs_irq_handler(engine, iir); |
| 3034 | |
| 3035 | WARN_ONCE(1, "unhandled engine interrupt class=0x%x, instance=0x%x\n", |
| 3036 | class, instance); |
| 3037 | } |
| 3038 | |
| 3039 | static void |
| 3040 | gen11_gt_identity_handler(struct drm_i915_private * const i915, |
| 3041 | const u32 identity) |
| 3042 | { |
| 3043 | const u8 class = GEN11_INTR_ENGINE_CLASS(identity); |
| 3044 | const u8 instance = GEN11_INTR_ENGINE_INSTANCE(identity); |
| 3045 | const u16 intr = GEN11_INTR_ENGINE_INTR(identity); |
| 3046 | |
| 3047 | if (unlikely(!intr)) |
| 3048 | return; |
| 3049 | |
| 3050 | if (class <= COPY_ENGINE_CLASS) |
| 3051 | return gen11_engine_irq_handler(i915, class, instance, intr); |
| 3052 | |
| 3053 | if (class == OTHER_CLASS) |
| 3054 | return gen11_other_irq_handler(i915, instance, intr); |
| 3055 | |
| 3056 | WARN_ONCE(1, "unknown interrupt class=0x%x, instance=0x%x, intr=0x%x\n", |
| 3057 | class, instance, intr); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3058 | } |
| 3059 | |
| 3060 | static void |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 3061 | gen11_gt_bank_handler(struct drm_i915_private * const i915, |
| 3062 | const unsigned int bank) |
| 3063 | { |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 3064 | void __iomem * const regs = i915->uncore.regs; |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 3065 | unsigned long intr_dw; |
| 3066 | unsigned int bit; |
| 3067 | |
| 3068 | lockdep_assert_held(&i915->irq_lock); |
| 3069 | |
| 3070 | intr_dw = raw_reg_read(regs, GEN11_GT_INTR_DW(bank)); |
| 3071 | |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 3072 | for_each_set_bit(bit, &intr_dw, 32) { |
Mika Kuoppala | 8455dad | 2019-04-10 16:21:24 +0300 | [diff] [blame] | 3073 | const u32 ident = gen11_gt_engine_identity(i915, bank, bit); |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 3074 | |
| 3075 | gen11_gt_identity_handler(i915, ident); |
| 3076 | } |
| 3077 | |
| 3078 | /* Clear must be after shared has been served for engine */ |
| 3079 | raw_reg_write(regs, GEN11_GT_INTR_DW(bank), intr_dw); |
| 3080 | } |
| 3081 | |
| 3082 | static void |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3083 | gen11_gt_irq_handler(struct drm_i915_private * const i915, |
| 3084 | const u32 master_ctl) |
| 3085 | { |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3086 | unsigned int bank; |
| 3087 | |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 3088 | spin_lock(&i915->irq_lock); |
| 3089 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3090 | for (bank = 0; bank < 2; bank++) { |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 3091 | if (master_ctl & GEN11_GT_DW_IRQ(bank)) |
| 3092 | gen11_gt_bank_handler(i915, bank); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3093 | } |
Oscar Mateo | 96606f3 | 2018-04-06 12:32:37 +0300 | [diff] [blame] | 3094 | |
| 3095 | spin_unlock(&i915->irq_lock); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3096 | } |
| 3097 | |
Chris Wilson | 7a90938 | 2018-09-26 11:47:18 +0100 | [diff] [blame] | 3098 | static u32 |
| 3099 | gen11_gu_misc_irq_ack(struct drm_i915_private *dev_priv, const u32 master_ctl) |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3100 | { |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 3101 | void __iomem * const regs = dev_priv->uncore.regs; |
Chris Wilson | 7a90938 | 2018-09-26 11:47:18 +0100 | [diff] [blame] | 3102 | u32 iir; |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3103 | |
| 3104 | if (!(master_ctl & GEN11_GU_MISC_IRQ)) |
Chris Wilson | 7a90938 | 2018-09-26 11:47:18 +0100 | [diff] [blame] | 3105 | return 0; |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3106 | |
Chris Wilson | 7a90938 | 2018-09-26 11:47:18 +0100 | [diff] [blame] | 3107 | iir = raw_reg_read(regs, GEN11_GU_MISC_IIR); |
| 3108 | if (likely(iir)) |
| 3109 | raw_reg_write(regs, GEN11_GU_MISC_IIR, iir); |
| 3110 | |
| 3111 | return iir; |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3112 | } |
| 3113 | |
| 3114 | static void |
Chris Wilson | 7a90938 | 2018-09-26 11:47:18 +0100 | [diff] [blame] | 3115 | gen11_gu_misc_irq_handler(struct drm_i915_private *dev_priv, const u32 iir) |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3116 | { |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3117 | if (iir & GEN11_GU_MISC_GSE) |
| 3118 | intel_opregion_asle_intr(dev_priv); |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3119 | } |
| 3120 | |
Mika Kuoppala | 81067b7 | 2018-10-15 17:14:40 +0300 | [diff] [blame] | 3121 | static inline u32 gen11_master_intr_disable(void __iomem * const regs) |
| 3122 | { |
| 3123 | raw_reg_write(regs, GEN11_GFX_MSTR_IRQ, 0); |
| 3124 | |
| 3125 | /* |
| 3126 | * Now with master disabled, get a sample of level indications |
| 3127 | * for this interrupt. Indications will be cleared on related acks. |
| 3128 | * New indications can and will light up during processing, |
| 3129 | * and will generate new interrupt after enabling master. |
| 3130 | */ |
| 3131 | return raw_reg_read(regs, GEN11_GFX_MSTR_IRQ); |
| 3132 | } |
| 3133 | |
| 3134 | static inline void gen11_master_intr_enable(void __iomem * const regs) |
| 3135 | { |
| 3136 | raw_reg_write(regs, GEN11_GFX_MSTR_IRQ, GEN11_MASTER_IRQ); |
| 3137 | } |
| 3138 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3139 | static irqreturn_t gen11_irq_handler(int irq, void *arg) |
| 3140 | { |
| 3141 | struct drm_i915_private * const i915 = to_i915(arg); |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 3142 | void __iomem * const regs = i915->uncore.regs; |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3143 | u32 master_ctl; |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3144 | u32 gu_misc_iir; |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3145 | |
| 3146 | if (!intel_irqs_enabled(i915)) |
| 3147 | return IRQ_NONE; |
| 3148 | |
Mika Kuoppala | 81067b7 | 2018-10-15 17:14:40 +0300 | [diff] [blame] | 3149 | master_ctl = gen11_master_intr_disable(regs); |
| 3150 | if (!master_ctl) { |
| 3151 | gen11_master_intr_enable(regs); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3152 | return IRQ_NONE; |
Mika Kuoppala | 81067b7 | 2018-10-15 17:14:40 +0300 | [diff] [blame] | 3153 | } |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3154 | |
| 3155 | /* Find, clear, then process each source of interrupt. */ |
| 3156 | gen11_gt_irq_handler(i915, master_ctl); |
| 3157 | |
| 3158 | /* IRQs are synced during runtime_suspend, we don't require a wakeref */ |
| 3159 | if (master_ctl & GEN11_DISPLAY_IRQ) { |
| 3160 | const u32 disp_ctl = raw_reg_read(regs, GEN11_DISPLAY_INT_CTL); |
| 3161 | |
| 3162 | disable_rpm_wakeref_asserts(i915); |
| 3163 | /* |
| 3164 | * GEN11_DISPLAY_INT_CTL has same format as GEN8_MASTER_IRQ |
| 3165 | * for the display related bits. |
| 3166 | */ |
| 3167 | gen8_de_irq_handler(i915, disp_ctl); |
| 3168 | enable_rpm_wakeref_asserts(i915); |
| 3169 | } |
| 3170 | |
Chris Wilson | 7a90938 | 2018-09-26 11:47:18 +0100 | [diff] [blame] | 3171 | gu_misc_iir = gen11_gu_misc_irq_ack(i915, master_ctl); |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3172 | |
Mika Kuoppala | 81067b7 | 2018-10-15 17:14:40 +0300 | [diff] [blame] | 3173 | gen11_master_intr_enable(regs); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3174 | |
Chris Wilson | 7a90938 | 2018-09-26 11:47:18 +0100 | [diff] [blame] | 3175 | gen11_gu_misc_irq_handler(i915, gu_misc_iir); |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3176 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3177 | return IRQ_HANDLED; |
| 3178 | } |
| 3179 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 3180 | /* Called from drm generic code, passed 'crtc' which |
| 3181 | * we use as a pipe index |
| 3182 | */ |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 3183 | static int i8xx_enable_vblank(struct drm_device *dev, unsigned int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 3184 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3185 | struct drm_i915_private *dev_priv = to_i915(dev); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 3186 | unsigned long irqflags; |
Jesse Barnes | 71e0ffa | 2009-01-08 10:42:15 -0800 | [diff] [blame] | 3187 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 3188 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 3189 | i915_enable_pipestat(dev_priv, pipe, PIPE_VBLANK_INTERRUPT_STATUS); |
| 3190 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 3191 | |
| 3192 | return 0; |
| 3193 | } |
| 3194 | |
Ville Syrjälä | d938da6 | 2019-03-22 20:08:03 +0200 | [diff] [blame] | 3195 | static int i945gm_enable_vblank(struct drm_device *dev, unsigned int pipe) |
| 3196 | { |
| 3197 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 3198 | |
| 3199 | if (dev_priv->i945gm_vblank.enabled++ == 0) |
| 3200 | schedule_work(&dev_priv->i945gm_vblank.work); |
| 3201 | |
| 3202 | return i8xx_enable_vblank(dev, pipe); |
| 3203 | } |
| 3204 | |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 3205 | static int i965_enable_vblank(struct drm_device *dev, unsigned int pipe) |
| 3206 | { |
| 3207 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 3208 | unsigned long irqflags; |
| 3209 | |
| 3210 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
| 3211 | i915_enable_pipestat(dev_priv, pipe, |
| 3212 | PIPE_START_VBLANK_INTERRUPT_STATUS); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 3213 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
Chris Wilson | 8692d00e | 2011-02-05 10:08:21 +0000 | [diff] [blame] | 3214 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 3215 | return 0; |
| 3216 | } |
| 3217 | |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 3218 | static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe) |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 3219 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3220 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 3221 | unsigned long irqflags; |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 3222 | u32 bit = INTEL_GEN(dev_priv) >= 7 ? |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 3223 | DE_PIPE_VBLANK_IVB(pipe) : DE_PIPE_VBLANK(pipe); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 3224 | |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 3225 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Ville Syrjälä | fbdedaea | 2015-11-23 18:06:16 +0200 | [diff] [blame] | 3226 | ilk_enable_display_irq(dev_priv, bit); |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 3227 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 3228 | |
Dhinakaran Pandiyan | 2e8bf22 | 2018-02-02 21:13:02 -0800 | [diff] [blame] | 3229 | /* Even though there is no DMC, frame counter can get stuck when |
| 3230 | * PSR is active as no frames are generated. |
| 3231 | */ |
| 3232 | if (HAS_PSR(dev_priv)) |
| 3233 | drm_vblank_restore(dev, pipe); |
| 3234 | |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 3235 | return 0; |
| 3236 | } |
| 3237 | |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 3238 | static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe) |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3239 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3240 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3241 | unsigned long irqflags; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3242 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3243 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Ville Syrjälä | 013d375 | 2015-11-23 18:06:17 +0200 | [diff] [blame] | 3244 | bdw_enable_pipe_irq(dev_priv, pipe, GEN8_PIPE_VBLANK); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3245 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
Ville Syrjälä | 013d375 | 2015-11-23 18:06:17 +0200 | [diff] [blame] | 3246 | |
Dhinakaran Pandiyan | 2e8bf22 | 2018-02-02 21:13:02 -0800 | [diff] [blame] | 3247 | /* Even if there is no DMC, frame counter can get stuck when |
| 3248 | * PSR is active as no frames are generated, so check only for PSR. |
| 3249 | */ |
| 3250 | if (HAS_PSR(dev_priv)) |
| 3251 | drm_vblank_restore(dev, pipe); |
| 3252 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3253 | return 0; |
| 3254 | } |
| 3255 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 3256 | /* Called from drm generic code, passed 'crtc' which |
| 3257 | * we use as a pipe index |
| 3258 | */ |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 3259 | static void i8xx_disable_vblank(struct drm_device *dev, unsigned int pipe) |
| 3260 | { |
| 3261 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 3262 | unsigned long irqflags; |
| 3263 | |
| 3264 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
| 3265 | i915_disable_pipestat(dev_priv, pipe, PIPE_VBLANK_INTERRUPT_STATUS); |
| 3266 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 3267 | } |
| 3268 | |
Ville Syrjälä | d938da6 | 2019-03-22 20:08:03 +0200 | [diff] [blame] | 3269 | static void i945gm_disable_vblank(struct drm_device *dev, unsigned int pipe) |
| 3270 | { |
| 3271 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 3272 | |
| 3273 | i8xx_disable_vblank(dev, pipe); |
| 3274 | |
| 3275 | if (--dev_priv->i945gm_vblank.enabled == 0) |
| 3276 | schedule_work(&dev_priv->i945gm_vblank.work); |
| 3277 | } |
| 3278 | |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 3279 | static void i965_disable_vblank(struct drm_device *dev, unsigned int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 3280 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3281 | struct drm_i915_private *dev_priv = to_i915(dev); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 3282 | unsigned long irqflags; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 3283 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 3284 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 3285 | i915_disable_pipestat(dev_priv, pipe, |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 3286 | PIPE_START_VBLANK_INTERRUPT_STATUS); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 3287 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 3288 | } |
| 3289 | |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 3290 | static void ironlake_disable_vblank(struct drm_device *dev, unsigned int pipe) |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 3291 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3292 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 3293 | unsigned long irqflags; |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 3294 | u32 bit = INTEL_GEN(dev_priv) >= 7 ? |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 3295 | DE_PIPE_VBLANK_IVB(pipe) : DE_PIPE_VBLANK(pipe); |
Jesse Barnes | f796cf8 | 2011-04-07 13:58:17 -0700 | [diff] [blame] | 3296 | |
| 3297 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Ville Syrjälä | fbdedaea | 2015-11-23 18:06:16 +0200 | [diff] [blame] | 3298 | ilk_disable_display_irq(dev_priv, bit); |
Jesse Barnes | b1f14ad | 2011-04-06 12:13:38 -0700 | [diff] [blame] | 3299 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 3300 | } |
| 3301 | |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 3302 | static void gen8_disable_vblank(struct drm_device *dev, unsigned int pipe) |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3303 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3304 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3305 | unsigned long irqflags; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3306 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3307 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
Ville Syrjälä | 013d375 | 2015-11-23 18:06:17 +0200 | [diff] [blame] | 3308 | bdw_disable_pipe_irq(dev_priv, pipe, GEN8_PIPE_VBLANK); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3309 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
| 3310 | } |
| 3311 | |
Ville Syrjälä | d938da6 | 2019-03-22 20:08:03 +0200 | [diff] [blame] | 3312 | static void i945gm_vblank_work_func(struct work_struct *work) |
| 3313 | { |
| 3314 | struct drm_i915_private *dev_priv = |
| 3315 | container_of(work, struct drm_i915_private, i945gm_vblank.work); |
| 3316 | |
| 3317 | /* |
| 3318 | * Vblank interrupts fail to wake up the device from C3, |
| 3319 | * hence we want to prevent C3 usage while vblank interrupts |
| 3320 | * are enabled. |
| 3321 | */ |
| 3322 | pm_qos_update_request(&dev_priv->i945gm_vblank.pm_qos, |
| 3323 | READ_ONCE(dev_priv->i945gm_vblank.enabled) ? |
| 3324 | dev_priv->i945gm_vblank.c3_disable_latency : |
| 3325 | PM_QOS_DEFAULT_VALUE); |
| 3326 | } |
| 3327 | |
| 3328 | static int cstate_disable_latency(const char *name) |
| 3329 | { |
| 3330 | const struct cpuidle_driver *drv; |
| 3331 | int i; |
| 3332 | |
| 3333 | drv = cpuidle_get_driver(); |
| 3334 | if (!drv) |
| 3335 | return 0; |
| 3336 | |
| 3337 | for (i = 0; i < drv->state_count; i++) { |
| 3338 | const struct cpuidle_state *state = &drv->states[i]; |
| 3339 | |
| 3340 | if (!strcmp(state->name, name)) |
| 3341 | return state->exit_latency ? |
| 3342 | state->exit_latency - 1 : 0; |
| 3343 | } |
| 3344 | |
| 3345 | return 0; |
| 3346 | } |
| 3347 | |
| 3348 | static void i945gm_vblank_work_init(struct drm_i915_private *dev_priv) |
| 3349 | { |
| 3350 | INIT_WORK(&dev_priv->i945gm_vblank.work, |
| 3351 | i945gm_vblank_work_func); |
| 3352 | |
| 3353 | dev_priv->i945gm_vblank.c3_disable_latency = |
| 3354 | cstate_disable_latency("C3"); |
| 3355 | pm_qos_add_request(&dev_priv->i945gm_vblank.pm_qos, |
| 3356 | PM_QOS_CPU_DMA_LATENCY, |
| 3357 | PM_QOS_DEFAULT_VALUE); |
| 3358 | } |
| 3359 | |
| 3360 | static void i945gm_vblank_work_fini(struct drm_i915_private *dev_priv) |
| 3361 | { |
| 3362 | cancel_work_sync(&dev_priv->i945gm_vblank.work); |
| 3363 | pm_qos_remove_request(&dev_priv->i945gm_vblank.pm_qos); |
| 3364 | } |
| 3365 | |
Tvrtko Ursulin | b243f53 | 2016-11-16 08:55:38 +0000 | [diff] [blame] | 3366 | static void ibx_irq_reset(struct drm_i915_private *dev_priv) |
Paulo Zanoni | 91738a9 | 2013-06-05 14:21:51 -0300 | [diff] [blame] | 3367 | { |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 3368 | if (HAS_PCH_NOP(dev_priv)) |
Paulo Zanoni | 91738a9 | 2013-06-05 14:21:51 -0300 | [diff] [blame] | 3369 | return; |
| 3370 | |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3371 | GEN3_IRQ_RESET(SDE); |
Paulo Zanoni | 105b122 | 2014-04-01 15:37:17 -0300 | [diff] [blame] | 3372 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 3373 | if (HAS_PCH_CPT(dev_priv) || HAS_PCH_LPT(dev_priv)) |
Paulo Zanoni | 105b122 | 2014-04-01 15:37:17 -0300 | [diff] [blame] | 3374 | I915_WRITE(SERR_INT, 0xffffffff); |
Paulo Zanoni | 622364b | 2014-04-01 15:37:22 -0300 | [diff] [blame] | 3375 | } |
Paulo Zanoni | 105b122 | 2014-04-01 15:37:17 -0300 | [diff] [blame] | 3376 | |
Paulo Zanoni | 622364b | 2014-04-01 15:37:22 -0300 | [diff] [blame] | 3377 | /* |
| 3378 | * SDEIER is also touched by the interrupt handler to work around missed PCH |
| 3379 | * interrupts. Hence we can't update it after the interrupt handler is enabled - |
| 3380 | * instead we unconditionally enable all PCH interrupt sources here, but then |
| 3381 | * only unmask them as needed with SDEIMR. |
| 3382 | * |
| 3383 | * This function needs to be called before interrupts are enabled. |
| 3384 | */ |
| 3385 | static void ibx_irq_pre_postinstall(struct drm_device *dev) |
| 3386 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3387 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | 622364b | 2014-04-01 15:37:22 -0300 | [diff] [blame] | 3388 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 3389 | if (HAS_PCH_NOP(dev_priv)) |
Paulo Zanoni | 622364b | 2014-04-01 15:37:22 -0300 | [diff] [blame] | 3390 | return; |
| 3391 | |
| 3392 | WARN_ON(I915_READ(SDEIER) != 0); |
Paulo Zanoni | 91738a9 | 2013-06-05 14:21:51 -0300 | [diff] [blame] | 3393 | I915_WRITE(SDEIER, 0xffffffff); |
| 3394 | POSTING_READ(SDEIER); |
| 3395 | } |
| 3396 | |
Tvrtko Ursulin | b243f53 | 2016-11-16 08:55:38 +0000 | [diff] [blame] | 3397 | static void gen5_gt_irq_reset(struct drm_i915_private *dev_priv) |
Daniel Vetter | d18ea1b | 2013-07-12 22:43:25 +0200 | [diff] [blame] | 3398 | { |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3399 | GEN3_IRQ_RESET(GT); |
Tvrtko Ursulin | b243f53 | 2016-11-16 08:55:38 +0000 | [diff] [blame] | 3400 | if (INTEL_GEN(dev_priv) >= 6) |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3401 | GEN3_IRQ_RESET(GEN6_PM); |
Daniel Vetter | d18ea1b | 2013-07-12 22:43:25 +0200 | [diff] [blame] | 3402 | } |
| 3403 | |
Ville Syrjälä | 70591a4 | 2014-10-30 19:42:58 +0200 | [diff] [blame] | 3404 | static void vlv_display_irq_reset(struct drm_i915_private *dev_priv) |
| 3405 | { |
Ville Syrjälä | 71b8b41 | 2016-04-11 16:56:31 +0300 | [diff] [blame] | 3406 | if (IS_CHERRYVIEW(dev_priv)) |
| 3407 | I915_WRITE(DPINVGTT, DPINVGTT_STATUS_MASK_CHV); |
| 3408 | else |
| 3409 | I915_WRITE(DPINVGTT, DPINVGTT_STATUS_MASK); |
| 3410 | |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 3411 | i915_hotplug_interrupt_update_locked(dev_priv, 0xffffffff, 0); |
Ville Syrjälä | 70591a4 | 2014-10-30 19:42:58 +0200 | [diff] [blame] | 3412 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
| 3413 | |
Ville Syrjälä | 44d9241 | 2017-08-18 21:36:51 +0300 | [diff] [blame] | 3414 | i9xx_pipestat_irq_reset(dev_priv); |
Ville Syrjälä | 70591a4 | 2014-10-30 19:42:58 +0200 | [diff] [blame] | 3415 | |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3416 | GEN3_IRQ_RESET(VLV_); |
Chris Wilson | 8bd099a | 2017-11-30 12:52:53 +0000 | [diff] [blame] | 3417 | dev_priv->irq_mask = ~0u; |
Ville Syrjälä | 70591a4 | 2014-10-30 19:42:58 +0200 | [diff] [blame] | 3418 | } |
| 3419 | |
Ville Syrjälä | 8bb6130 | 2016-04-12 18:56:44 +0300 | [diff] [blame] | 3420 | static void vlv_display_irq_postinstall(struct drm_i915_private *dev_priv) |
| 3421 | { |
| 3422 | u32 pipestat_mask; |
Ville Syrjälä | 9ab981f | 2016-04-11 16:56:28 +0300 | [diff] [blame] | 3423 | u32 enable_mask; |
Ville Syrjälä | 8bb6130 | 2016-04-12 18:56:44 +0300 | [diff] [blame] | 3424 | enum pipe pipe; |
| 3425 | |
Ville Syrjälä | 842ebf7 | 2017-08-18 21:36:50 +0300 | [diff] [blame] | 3426 | pipestat_mask = PIPE_CRC_DONE_INTERRUPT_STATUS; |
Ville Syrjälä | 8bb6130 | 2016-04-12 18:56:44 +0300 | [diff] [blame] | 3427 | |
| 3428 | i915_enable_pipestat(dev_priv, PIPE_A, PIPE_GMBUS_INTERRUPT_STATUS); |
| 3429 | for_each_pipe(dev_priv, pipe) |
| 3430 | i915_enable_pipestat(dev_priv, pipe, pipestat_mask); |
| 3431 | |
Ville Syrjälä | 9ab981f | 2016-04-11 16:56:28 +0300 | [diff] [blame] | 3432 | enable_mask = I915_DISPLAY_PORT_INTERRUPT | |
| 3433 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
Ville Syrjälä | ebf5f92 | 2017-04-27 19:02:22 +0300 | [diff] [blame] | 3434 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
| 3435 | I915_LPE_PIPE_A_INTERRUPT | |
| 3436 | I915_LPE_PIPE_B_INTERRUPT; |
| 3437 | |
Ville Syrjälä | 8bb6130 | 2016-04-12 18:56:44 +0300 | [diff] [blame] | 3438 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | ebf5f92 | 2017-04-27 19:02:22 +0300 | [diff] [blame] | 3439 | enable_mask |= I915_DISPLAY_PIPE_C_EVENT_INTERRUPT | |
| 3440 | I915_LPE_PIPE_C_INTERRUPT; |
Ville Syrjälä | 6b7eafc | 2016-04-11 16:56:29 +0300 | [diff] [blame] | 3441 | |
Chris Wilson | 8bd099a | 2017-11-30 12:52:53 +0000 | [diff] [blame] | 3442 | WARN_ON(dev_priv->irq_mask != ~0u); |
Ville Syrjälä | 6b7eafc | 2016-04-11 16:56:29 +0300 | [diff] [blame] | 3443 | |
Ville Syrjälä | 9ab981f | 2016-04-11 16:56:28 +0300 | [diff] [blame] | 3444 | dev_priv->irq_mask = ~enable_mask; |
Ville Syrjälä | 8bb6130 | 2016-04-12 18:56:44 +0300 | [diff] [blame] | 3445 | |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3446 | GEN3_IRQ_INIT(VLV_, dev_priv->irq_mask, enable_mask); |
Ville Syrjälä | 8bb6130 | 2016-04-12 18:56:44 +0300 | [diff] [blame] | 3447 | } |
| 3448 | |
| 3449 | /* drm_dma.h hooks |
| 3450 | */ |
| 3451 | static void ironlake_irq_reset(struct drm_device *dev) |
| 3452 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3453 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 8bb6130 | 2016-04-12 18:56:44 +0300 | [diff] [blame] | 3454 | |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3455 | GEN3_IRQ_RESET(DE); |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 3456 | if (IS_GEN(dev_priv, 7)) |
Ville Syrjälä | 8bb6130 | 2016-04-12 18:56:44 +0300 | [diff] [blame] | 3457 | I915_WRITE(GEN7_ERR_INT, 0xffffffff); |
| 3458 | |
Daniel Vetter | fc34044 | 2018-04-05 15:00:23 -0700 | [diff] [blame] | 3459 | if (IS_HASWELL(dev_priv)) { |
| 3460 | I915_WRITE(EDP_PSR_IMR, 0xffffffff); |
| 3461 | I915_WRITE(EDP_PSR_IIR, 0xffffffff); |
| 3462 | } |
| 3463 | |
Tvrtko Ursulin | b243f53 | 2016-11-16 08:55:38 +0000 | [diff] [blame] | 3464 | gen5_gt_irq_reset(dev_priv); |
Ville Syrjälä | 8bb6130 | 2016-04-12 18:56:44 +0300 | [diff] [blame] | 3465 | |
Tvrtko Ursulin | b243f53 | 2016-11-16 08:55:38 +0000 | [diff] [blame] | 3466 | ibx_irq_reset(dev_priv); |
Ville Syrjälä | 8bb6130 | 2016-04-12 18:56:44 +0300 | [diff] [blame] | 3467 | } |
| 3468 | |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 3469 | static void valleyview_irq_reset(struct drm_device *dev) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3470 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3471 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3472 | |
Ville Syrjälä | 34c7b8a | 2016-04-13 21:19:48 +0300 | [diff] [blame] | 3473 | I915_WRITE(VLV_MASTER_IER, 0); |
| 3474 | POSTING_READ(VLV_MASTER_IER); |
| 3475 | |
Tvrtko Ursulin | b243f53 | 2016-11-16 08:55:38 +0000 | [diff] [blame] | 3476 | gen5_gt_irq_reset(dev_priv); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3477 | |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 3478 | spin_lock_irq(&dev_priv->irq_lock); |
Ville Syrjälä | 9918271 | 2016-04-11 16:56:25 +0300 | [diff] [blame] | 3479 | if (dev_priv->display_irqs_enabled) |
| 3480 | vlv_display_irq_reset(dev_priv); |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 3481 | spin_unlock_irq(&dev_priv->irq_lock); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 3482 | } |
| 3483 | |
Daniel Vetter | d6e3cca | 2014-05-22 22:18:22 +0200 | [diff] [blame] | 3484 | static void gen8_gt_irq_reset(struct drm_i915_private *dev_priv) |
| 3485 | { |
| 3486 | GEN8_IRQ_RESET_NDX(GT, 0); |
| 3487 | GEN8_IRQ_RESET_NDX(GT, 1); |
| 3488 | GEN8_IRQ_RESET_NDX(GT, 2); |
| 3489 | GEN8_IRQ_RESET_NDX(GT, 3); |
| 3490 | } |
| 3491 | |
Paulo Zanoni | 823f6b3 | 2014-04-01 15:37:26 -0300 | [diff] [blame] | 3492 | static void gen8_irq_reset(struct drm_device *dev) |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3493 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3494 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3495 | int pipe; |
| 3496 | |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 3497 | gen8_master_intr_disable(dev_priv->uncore.regs); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3498 | |
Daniel Vetter | d6e3cca | 2014-05-22 22:18:22 +0200 | [diff] [blame] | 3499 | gen8_gt_irq_reset(dev_priv); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3500 | |
Ville Syrjälä | e04f7ec | 2018-04-03 14:24:18 -0700 | [diff] [blame] | 3501 | I915_WRITE(EDP_PSR_IMR, 0xffffffff); |
| 3502 | I915_WRITE(EDP_PSR_IIR, 0xffffffff); |
| 3503 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 3504 | for_each_pipe(dev_priv, pipe) |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 3505 | if (intel_display_power_is_enabled(dev_priv, |
| 3506 | POWER_DOMAIN_PIPE(pipe))) |
Paulo Zanoni | 813bde4 | 2014-07-04 11:50:29 -0300 | [diff] [blame] | 3507 | GEN8_IRQ_RESET_NDX(DE_PIPE, pipe); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3508 | |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3509 | GEN3_IRQ_RESET(GEN8_DE_PORT_); |
| 3510 | GEN3_IRQ_RESET(GEN8_DE_MISC_); |
| 3511 | GEN3_IRQ_RESET(GEN8_PCU_); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3512 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 3513 | if (HAS_PCH_SPLIT(dev_priv)) |
Tvrtko Ursulin | b243f53 | 2016-11-16 08:55:38 +0000 | [diff] [blame] | 3514 | ibx_irq_reset(dev_priv); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3515 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3516 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3517 | static void gen11_gt_irq_reset(struct drm_i915_private *dev_priv) |
| 3518 | { |
| 3519 | /* Disable RCS, BCS, VCS and VECS class engines. */ |
| 3520 | I915_WRITE(GEN11_RENDER_COPY_INTR_ENABLE, 0); |
| 3521 | I915_WRITE(GEN11_VCS_VECS_INTR_ENABLE, 0); |
| 3522 | |
| 3523 | /* Restore masks irqs on RCS, BCS, VCS and VECS engines. */ |
| 3524 | I915_WRITE(GEN11_RCS0_RSVD_INTR_MASK, ~0); |
| 3525 | I915_WRITE(GEN11_BCS_RSVD_INTR_MASK, ~0); |
| 3526 | I915_WRITE(GEN11_VCS0_VCS1_INTR_MASK, ~0); |
| 3527 | I915_WRITE(GEN11_VCS2_VCS3_INTR_MASK, ~0); |
| 3528 | I915_WRITE(GEN11_VECS0_VECS1_INTR_MASK, ~0); |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 3529 | |
| 3530 | I915_WRITE(GEN11_GPM_WGBOXPERF_INTR_ENABLE, 0); |
| 3531 | I915_WRITE(GEN11_GPM_WGBOXPERF_INTR_MASK, ~0); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3532 | } |
| 3533 | |
| 3534 | static void gen11_irq_reset(struct drm_device *dev) |
| 3535 | { |
| 3536 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3537 | int pipe; |
| 3538 | |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 3539 | gen11_master_intr_disable(dev_priv->uncore.regs); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3540 | |
| 3541 | gen11_gt_irq_reset(dev_priv); |
| 3542 | |
| 3543 | I915_WRITE(GEN11_DISPLAY_INT_CTL, 0); |
| 3544 | |
José Roberto de Souza | 62819df | 2018-11-06 11:08:42 -0800 | [diff] [blame] | 3545 | I915_WRITE(EDP_PSR_IMR, 0xffffffff); |
| 3546 | I915_WRITE(EDP_PSR_IIR, 0xffffffff); |
| 3547 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3548 | for_each_pipe(dev_priv, pipe) |
| 3549 | if (intel_display_power_is_enabled(dev_priv, |
| 3550 | POWER_DOMAIN_PIPE(pipe))) |
| 3551 | GEN8_IRQ_RESET_NDX(DE_PIPE, pipe); |
| 3552 | |
| 3553 | GEN3_IRQ_RESET(GEN8_DE_PORT_); |
| 3554 | GEN3_IRQ_RESET(GEN8_DE_MISC_); |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 3555 | GEN3_IRQ_RESET(GEN11_DE_HPD_); |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 3556 | GEN3_IRQ_RESET(GEN11_GU_MISC_); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3557 | GEN3_IRQ_RESET(GEN8_PCU_); |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 3558 | |
Rodrigo Vivi | 29b43ae | 2019-03-13 14:43:07 -0700 | [diff] [blame] | 3559 | if (INTEL_PCH_TYPE(dev_priv) >= PCH_ICP) |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 3560 | GEN3_IRQ_RESET(SDE); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 3561 | } |
| 3562 | |
Damien Lespiau | 4c6c03b | 2015-03-06 18:50:48 +0000 | [diff] [blame] | 3563 | void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv, |
Imre Deak | 001bd2c | 2017-07-12 18:54:13 +0300 | [diff] [blame] | 3564 | u8 pipe_mask) |
Paulo Zanoni | d49bdb0 | 2014-07-04 11:50:31 -0300 | [diff] [blame] | 3565 | { |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 3566 | u32 extra_ier = GEN8_PIPE_VBLANK | GEN8_PIPE_FIFO_UNDERRUN; |
Ville Syrjälä | 6831f3e | 2016-02-19 20:47:31 +0200 | [diff] [blame] | 3567 | enum pipe pipe; |
Paulo Zanoni | d49bdb0 | 2014-07-04 11:50:31 -0300 | [diff] [blame] | 3568 | |
Daniel Vetter | 1332178 | 2014-09-15 14:55:29 +0200 | [diff] [blame] | 3569 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | 9dfe2e3 | 2017-09-28 13:06:24 +0300 | [diff] [blame] | 3570 | |
| 3571 | if (!intel_irqs_enabled(dev_priv)) { |
| 3572 | spin_unlock_irq(&dev_priv->irq_lock); |
| 3573 | return; |
| 3574 | } |
| 3575 | |
Ville Syrjälä | 6831f3e | 2016-02-19 20:47:31 +0200 | [diff] [blame] | 3576 | for_each_pipe_masked(dev_priv, pipe, pipe_mask) |
| 3577 | GEN8_IRQ_INIT_NDX(DE_PIPE, pipe, |
| 3578 | dev_priv->de_irq_mask[pipe], |
| 3579 | ~dev_priv->de_irq_mask[pipe] | extra_ier); |
Imre Deak | 9dfe2e3 | 2017-09-28 13:06:24 +0300 | [diff] [blame] | 3580 | |
Daniel Vetter | 1332178 | 2014-09-15 14:55:29 +0200 | [diff] [blame] | 3581 | spin_unlock_irq(&dev_priv->irq_lock); |
Paulo Zanoni | d49bdb0 | 2014-07-04 11:50:31 -0300 | [diff] [blame] | 3582 | } |
| 3583 | |
Ville Syrjälä | aae8ba8 | 2016-02-19 20:47:30 +0200 | [diff] [blame] | 3584 | void gen8_irq_power_well_pre_disable(struct drm_i915_private *dev_priv, |
Imre Deak | 001bd2c | 2017-07-12 18:54:13 +0300 | [diff] [blame] | 3585 | u8 pipe_mask) |
Ville Syrjälä | aae8ba8 | 2016-02-19 20:47:30 +0200 | [diff] [blame] | 3586 | { |
Ville Syrjälä | 6831f3e | 2016-02-19 20:47:31 +0200 | [diff] [blame] | 3587 | enum pipe pipe; |
| 3588 | |
Ville Syrjälä | aae8ba8 | 2016-02-19 20:47:30 +0200 | [diff] [blame] | 3589 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | 9dfe2e3 | 2017-09-28 13:06:24 +0300 | [diff] [blame] | 3590 | |
| 3591 | if (!intel_irqs_enabled(dev_priv)) { |
| 3592 | spin_unlock_irq(&dev_priv->irq_lock); |
| 3593 | return; |
| 3594 | } |
| 3595 | |
Ville Syrjälä | 6831f3e | 2016-02-19 20:47:31 +0200 | [diff] [blame] | 3596 | for_each_pipe_masked(dev_priv, pipe, pipe_mask) |
| 3597 | GEN8_IRQ_RESET_NDX(DE_PIPE, pipe); |
Imre Deak | 9dfe2e3 | 2017-09-28 13:06:24 +0300 | [diff] [blame] | 3598 | |
Ville Syrjälä | aae8ba8 | 2016-02-19 20:47:30 +0200 | [diff] [blame] | 3599 | spin_unlock_irq(&dev_priv->irq_lock); |
| 3600 | |
| 3601 | /* make sure we're done processing display irqs */ |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 3602 | synchronize_irq(dev_priv->drm.irq); |
Ville Syrjälä | aae8ba8 | 2016-02-19 20:47:30 +0200 | [diff] [blame] | 3603 | } |
| 3604 | |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 3605 | static void cherryview_irq_reset(struct drm_device *dev) |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3606 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3607 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3608 | |
| 3609 | I915_WRITE(GEN8_MASTER_IRQ, 0); |
| 3610 | POSTING_READ(GEN8_MASTER_IRQ); |
| 3611 | |
Daniel Vetter | d6e3cca | 2014-05-22 22:18:22 +0200 | [diff] [blame] | 3612 | gen8_gt_irq_reset(dev_priv); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3613 | |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3614 | GEN3_IRQ_RESET(GEN8_PCU_); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3615 | |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 3616 | spin_lock_irq(&dev_priv->irq_lock); |
Ville Syrjälä | 9918271 | 2016-04-11 16:56:25 +0300 | [diff] [blame] | 3617 | if (dev_priv->display_irqs_enabled) |
| 3618 | vlv_display_irq_reset(dev_priv); |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 3619 | spin_unlock_irq(&dev_priv->irq_lock); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 3620 | } |
| 3621 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3622 | static u32 intel_hpd_enabled_irqs(struct drm_i915_private *dev_priv, |
Ville Syrjälä | 87a0210 | 2015-08-27 23:55:57 +0300 | [diff] [blame] | 3623 | const u32 hpd[HPD_NUM_PINS]) |
| 3624 | { |
Ville Syrjälä | 87a0210 | 2015-08-27 23:55:57 +0300 | [diff] [blame] | 3625 | struct intel_encoder *encoder; |
| 3626 | u32 enabled_irqs = 0; |
| 3627 | |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 3628 | for_each_intel_encoder(&dev_priv->drm, encoder) |
Ville Syrjälä | 87a0210 | 2015-08-27 23:55:57 +0300 | [diff] [blame] | 3629 | if (dev_priv->hotplug.stats[encoder->hpd_pin].state == HPD_ENABLED) |
| 3630 | enabled_irqs |= hpd[encoder->hpd_pin]; |
| 3631 | |
| 3632 | return enabled_irqs; |
| 3633 | } |
| 3634 | |
Imre Deak | 1a56b1a | 2017-01-27 11:39:21 +0200 | [diff] [blame] | 3635 | static void ibx_hpd_detection_setup(struct drm_i915_private *dev_priv) |
| 3636 | { |
| 3637 | u32 hotplug; |
| 3638 | |
| 3639 | /* |
| 3640 | * Enable digital hotplug on the PCH, and configure the DP short pulse |
| 3641 | * duration to 2ms (which is the minimum in the Display Port spec). |
| 3642 | * The pulse duration bits are reserved on LPT+. |
| 3643 | */ |
| 3644 | hotplug = I915_READ(PCH_PORT_HOTPLUG); |
| 3645 | hotplug &= ~(PORTB_PULSE_DURATION_MASK | |
| 3646 | PORTC_PULSE_DURATION_MASK | |
| 3647 | PORTD_PULSE_DURATION_MASK); |
| 3648 | hotplug |= PORTB_HOTPLUG_ENABLE | PORTB_PULSE_DURATION_2ms; |
| 3649 | hotplug |= PORTC_HOTPLUG_ENABLE | PORTC_PULSE_DURATION_2ms; |
| 3650 | hotplug |= PORTD_HOTPLUG_ENABLE | PORTD_PULSE_DURATION_2ms; |
| 3651 | /* |
| 3652 | * When CPU and PCH are on the same package, port A |
| 3653 | * HPD must be enabled in both north and south. |
| 3654 | */ |
| 3655 | if (HAS_PCH_LPT_LP(dev_priv)) |
| 3656 | hotplug |= PORTA_HOTPLUG_ENABLE; |
| 3657 | I915_WRITE(PCH_PORT_HOTPLUG, hotplug); |
| 3658 | } |
| 3659 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3660 | static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv) |
Keith Packard | 7fe0b97 | 2011-09-19 13:31:02 -0700 | [diff] [blame] | 3661 | { |
Imre Deak | 1a56b1a | 2017-01-27 11:39:21 +0200 | [diff] [blame] | 3662 | u32 hotplug_irqs, enabled_irqs; |
Keith Packard | 7fe0b97 | 2011-09-19 13:31:02 -0700 | [diff] [blame] | 3663 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3664 | if (HAS_PCH_IBX(dev_priv)) { |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 3665 | hotplug_irqs = SDE_HOTPLUG_MASK; |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3666 | enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_ibx); |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3667 | } else { |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 3668 | hotplug_irqs = SDE_HOTPLUG_MASK_CPT; |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3669 | enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_cpt); |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3670 | } |
| 3671 | |
Daniel Vetter | fee884e | 2013-07-04 23:35:21 +0200 | [diff] [blame] | 3672 | ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs); |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3673 | |
Imre Deak | 1a56b1a | 2017-01-27 11:39:21 +0200 | [diff] [blame] | 3674 | ibx_hpd_detection_setup(dev_priv); |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 3675 | } |
Xiong Zhang | 26951ca | 2015-08-17 15:55:50 +0800 | [diff] [blame] | 3676 | |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 3677 | static void icp_hpd_detection_setup(struct drm_i915_private *dev_priv) |
| 3678 | { |
| 3679 | u32 hotplug; |
| 3680 | |
| 3681 | hotplug = I915_READ(SHOTPLUG_CTL_DDI); |
| 3682 | hotplug |= ICP_DDIA_HPD_ENABLE | |
| 3683 | ICP_DDIB_HPD_ENABLE; |
| 3684 | I915_WRITE(SHOTPLUG_CTL_DDI, hotplug); |
| 3685 | |
| 3686 | hotplug = I915_READ(SHOTPLUG_CTL_TC); |
| 3687 | hotplug |= ICP_TC_HPD_ENABLE(PORT_TC1) | |
| 3688 | ICP_TC_HPD_ENABLE(PORT_TC2) | |
| 3689 | ICP_TC_HPD_ENABLE(PORT_TC3) | |
| 3690 | ICP_TC_HPD_ENABLE(PORT_TC4); |
| 3691 | I915_WRITE(SHOTPLUG_CTL_TC, hotplug); |
| 3692 | } |
| 3693 | |
| 3694 | static void icp_hpd_irq_setup(struct drm_i915_private *dev_priv) |
| 3695 | { |
| 3696 | u32 hotplug_irqs, enabled_irqs; |
| 3697 | |
| 3698 | hotplug_irqs = SDE_DDI_MASK_ICP | SDE_TC_MASK_ICP; |
| 3699 | enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_icp); |
| 3700 | |
| 3701 | ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs); |
| 3702 | |
| 3703 | icp_hpd_detection_setup(dev_priv); |
| 3704 | } |
| 3705 | |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 3706 | static void gen11_hpd_detection_setup(struct drm_i915_private *dev_priv) |
| 3707 | { |
| 3708 | u32 hotplug; |
| 3709 | |
| 3710 | hotplug = I915_READ(GEN11_TC_HOTPLUG_CTL); |
| 3711 | hotplug |= GEN11_HOTPLUG_CTL_ENABLE(PORT_TC1) | |
| 3712 | GEN11_HOTPLUG_CTL_ENABLE(PORT_TC2) | |
| 3713 | GEN11_HOTPLUG_CTL_ENABLE(PORT_TC3) | |
| 3714 | GEN11_HOTPLUG_CTL_ENABLE(PORT_TC4); |
| 3715 | I915_WRITE(GEN11_TC_HOTPLUG_CTL, hotplug); |
Dhinakaran Pandiyan | b796b97 | 2018-06-15 17:05:30 -0700 | [diff] [blame] | 3716 | |
| 3717 | hotplug = I915_READ(GEN11_TBT_HOTPLUG_CTL); |
| 3718 | hotplug |= GEN11_HOTPLUG_CTL_ENABLE(PORT_TC1) | |
| 3719 | GEN11_HOTPLUG_CTL_ENABLE(PORT_TC2) | |
| 3720 | GEN11_HOTPLUG_CTL_ENABLE(PORT_TC3) | |
| 3721 | GEN11_HOTPLUG_CTL_ENABLE(PORT_TC4); |
| 3722 | I915_WRITE(GEN11_TBT_HOTPLUG_CTL, hotplug); |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 3723 | } |
| 3724 | |
| 3725 | static void gen11_hpd_irq_setup(struct drm_i915_private *dev_priv) |
| 3726 | { |
| 3727 | u32 hotplug_irqs, enabled_irqs; |
| 3728 | u32 val; |
| 3729 | |
Dhinakaran Pandiyan | b796b97 | 2018-06-15 17:05:30 -0700 | [diff] [blame] | 3730 | enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_gen11); |
| 3731 | hotplug_irqs = GEN11_DE_TC_HOTPLUG_MASK | GEN11_DE_TBT_HOTPLUG_MASK; |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 3732 | |
| 3733 | val = I915_READ(GEN11_DE_HPD_IMR); |
| 3734 | val &= ~hotplug_irqs; |
| 3735 | I915_WRITE(GEN11_DE_HPD_IMR, val); |
| 3736 | POSTING_READ(GEN11_DE_HPD_IMR); |
| 3737 | |
| 3738 | gen11_hpd_detection_setup(dev_priv); |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 3739 | |
Rodrigo Vivi | 29b43ae | 2019-03-13 14:43:07 -0700 | [diff] [blame] | 3740 | if (INTEL_PCH_TYPE(dev_priv) >= PCH_ICP) |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 3741 | icp_hpd_irq_setup(dev_priv); |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 3742 | } |
| 3743 | |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 3744 | static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv) |
| 3745 | { |
Rodrigo Vivi | 3b92e26 | 2017-09-19 14:57:03 -0700 | [diff] [blame] | 3746 | u32 val, hotplug; |
| 3747 | |
| 3748 | /* Display WA #1179 WaHardHangonHotPlug: cnp */ |
| 3749 | if (HAS_PCH_CNP(dev_priv)) { |
| 3750 | val = I915_READ(SOUTH_CHICKEN1); |
| 3751 | val &= ~CHASSIS_CLK_REQ_DURATION_MASK; |
| 3752 | val |= CHASSIS_CLK_REQ_DURATION(0xf); |
| 3753 | I915_WRITE(SOUTH_CHICKEN1, val); |
| 3754 | } |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 3755 | |
| 3756 | /* Enable digital hotplug on the PCH */ |
| 3757 | hotplug = I915_READ(PCH_PORT_HOTPLUG); |
| 3758 | hotplug |= PORTA_HOTPLUG_ENABLE | |
| 3759 | PORTB_HOTPLUG_ENABLE | |
| 3760 | PORTC_HOTPLUG_ENABLE | |
| 3761 | PORTD_HOTPLUG_ENABLE; |
| 3762 | I915_WRITE(PCH_PORT_HOTPLUG, hotplug); |
| 3763 | |
| 3764 | hotplug = I915_READ(PCH_PORT_HOTPLUG2); |
| 3765 | hotplug |= PORTE_HOTPLUG_ENABLE; |
| 3766 | I915_WRITE(PCH_PORT_HOTPLUG2, hotplug); |
| 3767 | } |
| 3768 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3769 | static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv) |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 3770 | { |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 3771 | u32 hotplug_irqs, enabled_irqs; |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 3772 | |
| 3773 | hotplug_irqs = SDE_HOTPLUG_MASK_SPT; |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3774 | enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_spt); |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 3775 | |
| 3776 | ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs); |
| 3777 | |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 3778 | spt_hpd_detection_setup(dev_priv); |
Keith Packard | 7fe0b97 | 2011-09-19 13:31:02 -0700 | [diff] [blame] | 3779 | } |
| 3780 | |
Imre Deak | 1a56b1a | 2017-01-27 11:39:21 +0200 | [diff] [blame] | 3781 | static void ilk_hpd_detection_setup(struct drm_i915_private *dev_priv) |
| 3782 | { |
| 3783 | u32 hotplug; |
| 3784 | |
| 3785 | /* |
| 3786 | * Enable digital hotplug on the CPU, and configure the DP short pulse |
| 3787 | * duration to 2ms (which is the minimum in the Display Port spec) |
| 3788 | * The pulse duration bits are reserved on HSW+. |
| 3789 | */ |
| 3790 | hotplug = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL); |
| 3791 | hotplug &= ~DIGITAL_PORTA_PULSE_DURATION_MASK; |
| 3792 | hotplug |= DIGITAL_PORTA_HOTPLUG_ENABLE | |
| 3793 | DIGITAL_PORTA_PULSE_DURATION_2ms; |
| 3794 | I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, hotplug); |
| 3795 | } |
| 3796 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3797 | static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv) |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3798 | { |
Imre Deak | 1a56b1a | 2017-01-27 11:39:21 +0200 | [diff] [blame] | 3799 | u32 hotplug_irqs, enabled_irqs; |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3800 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3801 | if (INTEL_GEN(dev_priv) >= 8) { |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3802 | hotplug_irqs = GEN8_PORT_DP_A_HOTPLUG; |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3803 | enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bdw); |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3804 | |
| 3805 | bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs); |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3806 | } else if (INTEL_GEN(dev_priv) >= 7) { |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 3807 | hotplug_irqs = DE_DP_A_HOTPLUG_IVB; |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3808 | enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_ivb); |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3809 | |
| 3810 | ilk_update_display_irq(dev_priv, hotplug_irqs, enabled_irqs); |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 3811 | } else { |
| 3812 | hotplug_irqs = DE_DP_A_HOTPLUG; |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3813 | enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_ilk); |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3814 | |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 3815 | ilk_update_display_irq(dev_priv, hotplug_irqs, enabled_irqs); |
| 3816 | } |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3817 | |
Imre Deak | 1a56b1a | 2017-01-27 11:39:21 +0200 | [diff] [blame] | 3818 | ilk_hpd_detection_setup(dev_priv); |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3819 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 3820 | ibx_hpd_irq_setup(dev_priv); |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3821 | } |
| 3822 | |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 3823 | static void __bxt_hpd_detection_setup(struct drm_i915_private *dev_priv, |
| 3824 | u32 enabled_irqs) |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 3825 | { |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 3826 | u32 hotplug; |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 3827 | |
Ville Syrjälä | a52bb15 | 2015-08-27 23:56:11 +0300 | [diff] [blame] | 3828 | hotplug = I915_READ(PCH_PORT_HOTPLUG); |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 3829 | hotplug |= PORTA_HOTPLUG_ENABLE | |
| 3830 | PORTB_HOTPLUG_ENABLE | |
| 3831 | PORTC_HOTPLUG_ENABLE; |
Shubhangi Shrivastava | d252bf6 | 2016-03-31 16:11:47 +0530 | [diff] [blame] | 3832 | |
| 3833 | DRM_DEBUG_KMS("Invert bit setting: hp_ctl:%x hp_port:%x\n", |
| 3834 | hotplug, enabled_irqs); |
| 3835 | hotplug &= ~BXT_DDI_HPD_INVERT_MASK; |
| 3836 | |
| 3837 | /* |
| 3838 | * For BXT invert bit has to be set based on AOB design |
| 3839 | * for HPD detection logic, update it based on VBT fields. |
| 3840 | */ |
Shubhangi Shrivastava | d252bf6 | 2016-03-31 16:11:47 +0530 | [diff] [blame] | 3841 | if ((enabled_irqs & BXT_DE_PORT_HP_DDIA) && |
| 3842 | intel_bios_is_port_hpd_inverted(dev_priv, PORT_A)) |
| 3843 | hotplug |= BXT_DDIA_HPD_INVERT; |
| 3844 | if ((enabled_irqs & BXT_DE_PORT_HP_DDIB) && |
| 3845 | intel_bios_is_port_hpd_inverted(dev_priv, PORT_B)) |
| 3846 | hotplug |= BXT_DDIB_HPD_INVERT; |
| 3847 | if ((enabled_irqs & BXT_DE_PORT_HP_DDIC) && |
| 3848 | intel_bios_is_port_hpd_inverted(dev_priv, PORT_C)) |
| 3849 | hotplug |= BXT_DDIC_HPD_INVERT; |
| 3850 | |
Ville Syrjälä | a52bb15 | 2015-08-27 23:56:11 +0300 | [diff] [blame] | 3851 | I915_WRITE(PCH_PORT_HOTPLUG, hotplug); |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 3852 | } |
| 3853 | |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 3854 | static void bxt_hpd_detection_setup(struct drm_i915_private *dev_priv) |
| 3855 | { |
| 3856 | __bxt_hpd_detection_setup(dev_priv, BXT_DE_PORT_HOTPLUG_MASK); |
| 3857 | } |
| 3858 | |
| 3859 | static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv) |
| 3860 | { |
| 3861 | u32 hotplug_irqs, enabled_irqs; |
| 3862 | |
| 3863 | enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt); |
| 3864 | hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK; |
| 3865 | |
| 3866 | bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs); |
| 3867 | |
| 3868 | __bxt_hpd_detection_setup(dev_priv, enabled_irqs); |
| 3869 | } |
| 3870 | |
Paulo Zanoni | d46da43 | 2013-02-08 17:35:15 -0200 | [diff] [blame] | 3871 | static void ibx_irq_postinstall(struct drm_device *dev) |
| 3872 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3873 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 82a28bc | 2013-03-27 15:55:01 +0100 | [diff] [blame] | 3874 | u32 mask; |
Paulo Zanoni | d46da43 | 2013-02-08 17:35:15 -0200 | [diff] [blame] | 3875 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 3876 | if (HAS_PCH_NOP(dev_priv)) |
Daniel Vetter | 692a04c | 2013-05-29 21:43:05 +0200 | [diff] [blame] | 3877 | return; |
| 3878 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 3879 | if (HAS_PCH_IBX(dev_priv)) |
Daniel Vetter | 5c673b6 | 2014-03-07 20:34:46 +0100 | [diff] [blame] | 3880 | mask = SDE_GMBUS | SDE_AUX_MASK | SDE_POISON; |
Dhinakaran Pandiyan | 4ebc650 | 2017-09-08 17:42:55 -0700 | [diff] [blame] | 3881 | else if (HAS_PCH_CPT(dev_priv) || HAS_PCH_LPT(dev_priv)) |
Daniel Vetter | 5c673b6 | 2014-03-07 20:34:46 +0100 | [diff] [blame] | 3882 | mask = SDE_GMBUS_CPT | SDE_AUX_MASK_CPT; |
Dhinakaran Pandiyan | 4ebc650 | 2017-09-08 17:42:55 -0700 | [diff] [blame] | 3883 | else |
| 3884 | mask = SDE_GMBUS_CPT; |
Paulo Zanoni | 8664281 | 2013-04-12 17:57:57 -0300 | [diff] [blame] | 3885 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 3886 | gen3_assert_iir_is_zero(&dev_priv->uncore, SDEIIR); |
Paulo Zanoni | d46da43 | 2013-02-08 17:35:15 -0200 | [diff] [blame] | 3887 | I915_WRITE(SDEIMR, ~mask); |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 3888 | |
| 3889 | if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) || |
| 3890 | HAS_PCH_LPT(dev_priv)) |
Imre Deak | 1a56b1a | 2017-01-27 11:39:21 +0200 | [diff] [blame] | 3891 | ibx_hpd_detection_setup(dev_priv); |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 3892 | else |
| 3893 | spt_hpd_detection_setup(dev_priv); |
Paulo Zanoni | d46da43 | 2013-02-08 17:35:15 -0200 | [diff] [blame] | 3894 | } |
| 3895 | |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3896 | static void gen5_gt_irq_postinstall(struct drm_device *dev) |
| 3897 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3898 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3899 | u32 pm_irqs, gt_irqs; |
| 3900 | |
| 3901 | pm_irqs = gt_irqs = 0; |
| 3902 | |
| 3903 | dev_priv->gt_irq_mask = ~0; |
Tvrtko Ursulin | 3c9192b | 2016-10-13 11:03:05 +0100 | [diff] [blame] | 3904 | if (HAS_L3_DPF(dev_priv)) { |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3905 | /* L3 parity interrupt is always unmasked. */ |
Tvrtko Ursulin | 772c2a5 | 2016-10-13 11:03:01 +0100 | [diff] [blame] | 3906 | dev_priv->gt_irq_mask = ~GT_PARITY_ERROR(dev_priv); |
| 3907 | gt_irqs |= GT_PARITY_ERROR(dev_priv); |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3908 | } |
| 3909 | |
| 3910 | gt_irqs |= GT_RENDER_USER_INTERRUPT; |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 3911 | if (IS_GEN(dev_priv, 5)) { |
Chris Wilson | f8973c2 | 2016-07-01 17:23:21 +0100 | [diff] [blame] | 3912 | gt_irqs |= ILK_BSD_USER_INTERRUPT; |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3913 | } else { |
| 3914 | gt_irqs |= GT_BLT_USER_INTERRUPT | GT_BSD_USER_INTERRUPT; |
| 3915 | } |
| 3916 | |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3917 | GEN3_IRQ_INIT(GT, dev_priv->gt_irq_mask, gt_irqs); |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3918 | |
Tvrtko Ursulin | b243f53 | 2016-11-16 08:55:38 +0000 | [diff] [blame] | 3919 | if (INTEL_GEN(dev_priv) >= 6) { |
Imre Deak | 78e68d3 | 2014-12-15 18:59:27 +0200 | [diff] [blame] | 3920 | /* |
| 3921 | * RPS interrupts will get enabled/disabled on demand when RPS |
| 3922 | * itself is enabled/disabled. |
| 3923 | */ |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 3924 | if (HAS_ENGINE(dev_priv, VECS0)) { |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3925 | pm_irqs |= PM_VEBOX_USER_INTERRUPT; |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 3926 | dev_priv->pm_ier |= PM_VEBOX_USER_INTERRUPT; |
| 3927 | } |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3928 | |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 3929 | dev_priv->pm_imr = 0xffffffff; |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3930 | GEN3_IRQ_INIT(GEN6_PM, dev_priv->pm_imr, pm_irqs); |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3931 | } |
| 3932 | } |
| 3933 | |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 3934 | static int ironlake_irq_postinstall(struct drm_device *dev) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3935 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3936 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | 8e76f8d | 2013-07-12 20:01:56 -0300 | [diff] [blame] | 3937 | u32 display_mask, extra_mask; |
| 3938 | |
Tvrtko Ursulin | b243f53 | 2016-11-16 08:55:38 +0000 | [diff] [blame] | 3939 | if (INTEL_GEN(dev_priv) >= 7) { |
Paulo Zanoni | 8e76f8d | 2013-07-12 20:01:56 -0300 | [diff] [blame] | 3940 | display_mask = (DE_MASTER_IRQ_CONTROL | DE_GSE_IVB | |
Ville Syrjälä | 842ebf7 | 2017-08-18 21:36:50 +0300 | [diff] [blame] | 3941 | DE_PCH_EVENT_IVB | DE_AUX_CHANNEL_A_IVB); |
Paulo Zanoni | 8e76f8d | 2013-07-12 20:01:56 -0300 | [diff] [blame] | 3942 | extra_mask = (DE_PIPEC_VBLANK_IVB | DE_PIPEB_VBLANK_IVB | |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 3943 | DE_PIPEA_VBLANK_IVB | DE_ERR_INT_IVB | |
| 3944 | DE_DP_A_HOTPLUG_IVB); |
Paulo Zanoni | 8e76f8d | 2013-07-12 20:01:56 -0300 | [diff] [blame] | 3945 | } else { |
| 3946 | display_mask = (DE_MASTER_IRQ_CONTROL | DE_GSE | DE_PCH_EVENT | |
Ville Syrjälä | 842ebf7 | 2017-08-18 21:36:50 +0300 | [diff] [blame] | 3947 | DE_AUX_CHANNEL_A | DE_PIPEB_CRC_DONE | |
| 3948 | DE_PIPEA_CRC_DONE | DE_POISON); |
Ville Syrjälä | e4ce95a | 2015-08-27 23:56:03 +0300 | [diff] [blame] | 3949 | extra_mask = (DE_PIPEA_VBLANK | DE_PIPEB_VBLANK | DE_PCU_EVENT | |
| 3950 | DE_PIPEB_FIFO_UNDERRUN | DE_PIPEA_FIFO_UNDERRUN | |
| 3951 | DE_DP_A_HOTPLUG); |
Paulo Zanoni | 8e76f8d | 2013-07-12 20:01:56 -0300 | [diff] [blame] | 3952 | } |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3953 | |
Daniel Vetter | fc34044 | 2018-04-05 15:00:23 -0700 | [diff] [blame] | 3954 | if (IS_HASWELL(dev_priv)) { |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 3955 | gen3_assert_iir_is_zero(&dev_priv->uncore, EDP_PSR_IIR); |
Dhinakaran Pandiyan | 1aeb1b5 | 2018-08-21 15:11:56 -0700 | [diff] [blame] | 3956 | intel_psr_irq_control(dev_priv, dev_priv->psr.debug); |
Daniel Vetter | fc34044 | 2018-04-05 15:00:23 -0700 | [diff] [blame] | 3957 | display_mask |= DE_EDP_PSR_INT_HSW; |
| 3958 | } |
| 3959 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 3960 | dev_priv->irq_mask = ~display_mask; |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3961 | |
Paulo Zanoni | 622364b | 2014-04-01 15:37:22 -0300 | [diff] [blame] | 3962 | ibx_irq_pre_postinstall(dev); |
| 3963 | |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 3964 | GEN3_IRQ_INIT(DE, dev_priv->irq_mask, display_mask | extra_mask); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3965 | |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 3966 | gen5_gt_irq_postinstall(dev); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3967 | |
Imre Deak | 1a56b1a | 2017-01-27 11:39:21 +0200 | [diff] [blame] | 3968 | ilk_hpd_detection_setup(dev_priv); |
| 3969 | |
Paulo Zanoni | d46da43 | 2013-02-08 17:35:15 -0200 | [diff] [blame] | 3970 | ibx_irq_postinstall(dev); |
Keith Packard | 7fe0b97 | 2011-09-19 13:31:02 -0700 | [diff] [blame] | 3971 | |
Tvrtko Ursulin | 50a0bc9 | 2016-10-13 11:02:58 +0100 | [diff] [blame] | 3972 | if (IS_IRONLAKE_M(dev_priv)) { |
Daniel Vetter | 6005ce4 | 2013-06-27 13:44:59 +0200 | [diff] [blame] | 3973 | /* Enable PCU event interrupts |
| 3974 | * |
| 3975 | * spinlocking not required here for correctness since interrupt |
Daniel Vetter | 4bc9d43 | 2013-06-27 13:44:58 +0200 | [diff] [blame] | 3976 | * setup is guaranteed to run in single-threaded context. But we |
| 3977 | * need it to make the assert_spin_locked happy. */ |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 3978 | spin_lock_irq(&dev_priv->irq_lock); |
Ville Syrjälä | fbdedaea | 2015-11-23 18:06:16 +0200 | [diff] [blame] | 3979 | ilk_enable_display_irq(dev_priv, DE_PCU_EVENT); |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 3980 | spin_unlock_irq(&dev_priv->irq_lock); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 3981 | } |
| 3982 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 3983 | return 0; |
| 3984 | } |
| 3985 | |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3986 | void valleyview_enable_display_irqs(struct drm_i915_private *dev_priv) |
| 3987 | { |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 3988 | lockdep_assert_held(&dev_priv->irq_lock); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3989 | |
| 3990 | if (dev_priv->display_irqs_enabled) |
| 3991 | return; |
| 3992 | |
| 3993 | dev_priv->display_irqs_enabled = true; |
| 3994 | |
Ville Syrjälä | d6c6980 | 2016-04-11 16:56:27 +0300 | [diff] [blame] | 3995 | if (intel_irqs_enabled(dev_priv)) { |
| 3996 | vlv_display_irq_reset(dev_priv); |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 3997 | vlv_display_irq_postinstall(dev_priv); |
Ville Syrjälä | d6c6980 | 2016-04-11 16:56:27 +0300 | [diff] [blame] | 3998 | } |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 3999 | } |
| 4000 | |
| 4001 | void valleyview_disable_display_irqs(struct drm_i915_private *dev_priv) |
| 4002 | { |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 4003 | lockdep_assert_held(&dev_priv->irq_lock); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 4004 | |
| 4005 | if (!dev_priv->display_irqs_enabled) |
| 4006 | return; |
| 4007 | |
| 4008 | dev_priv->display_irqs_enabled = false; |
| 4009 | |
Imre Deak | 950eaba | 2014-09-08 15:21:09 +0300 | [diff] [blame] | 4010 | if (intel_irqs_enabled(dev_priv)) |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 4011 | vlv_display_irq_reset(dev_priv); |
Imre Deak | f8b79e5 | 2014-03-04 19:23:07 +0200 | [diff] [blame] | 4012 | } |
| 4013 | |
Ville Syrjälä | 0e6c9a9 | 2014-10-30 19:43:00 +0200 | [diff] [blame] | 4014 | |
| 4015 | static int valleyview_irq_postinstall(struct drm_device *dev) |
| 4016 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4017 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 0e6c9a9 | 2014-10-30 19:43:00 +0200 | [diff] [blame] | 4018 | |
Daniel Vetter | 0a9a8c9 | 2013-07-12 22:43:26 +0200 | [diff] [blame] | 4019 | gen5_gt_irq_postinstall(dev); |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 4020 | |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 4021 | spin_lock_irq(&dev_priv->irq_lock); |
Ville Syrjälä | 9918271 | 2016-04-11 16:56:25 +0300 | [diff] [blame] | 4022 | if (dev_priv->display_irqs_enabled) |
| 4023 | vlv_display_irq_postinstall(dev_priv); |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 4024 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4025 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 4026 | I915_WRITE(VLV_MASTER_IER, MASTER_INTERRUPT_ENABLE); |
Ville Syrjälä | 34c7b8a | 2016-04-13 21:19:48 +0300 | [diff] [blame] | 4027 | POSTING_READ(VLV_MASTER_IER); |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4028 | |
| 4029 | return 0; |
| 4030 | } |
| 4031 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4032 | static void gen8_gt_irq_postinstall(struct drm_i915_private *dev_priv) |
| 4033 | { |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4034 | /* These are interrupts we'll toggle with the ring mask register */ |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 4035 | u32 gt_interrupts[] = { |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 4036 | (GT_RENDER_USER_INTERRUPT << GEN8_RCS_IRQ_SHIFT | |
| 4037 | GT_CONTEXT_SWITCH_INTERRUPT << GEN8_RCS_IRQ_SHIFT | |
| 4038 | GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT | |
| 4039 | GT_CONTEXT_SWITCH_INTERRUPT << GEN8_BCS_IRQ_SHIFT), |
| 4040 | |
| 4041 | (GT_RENDER_USER_INTERRUPT << GEN8_VCS0_IRQ_SHIFT | |
| 4042 | GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS0_IRQ_SHIFT | |
| 4043 | GT_RENDER_USER_INTERRUPT << GEN8_VCS1_IRQ_SHIFT | |
| 4044 | GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS1_IRQ_SHIFT), |
| 4045 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4046 | 0, |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 4047 | |
| 4048 | (GT_RENDER_USER_INTERRUPT << GEN8_VECS_IRQ_SHIFT | |
| 4049 | GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VECS_IRQ_SHIFT) |
| 4050 | }; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4051 | |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 4052 | dev_priv->pm_ier = 0x0; |
| 4053 | dev_priv->pm_imr = ~dev_priv->pm_ier; |
Deepak S | 9a2d2d8 | 2014-08-22 08:32:40 +0530 | [diff] [blame] | 4054 | GEN8_IRQ_INIT_NDX(GT, 0, ~gt_interrupts[0], gt_interrupts[0]); |
| 4055 | GEN8_IRQ_INIT_NDX(GT, 1, ~gt_interrupts[1], gt_interrupts[1]); |
Imre Deak | 78e68d3 | 2014-12-15 18:59:27 +0200 | [diff] [blame] | 4056 | /* |
| 4057 | * RPS interrupts will get enabled/disabled on demand when RPS itself |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 4058 | * is enabled/disabled. Same wil be the case for GuC interrupts. |
Imre Deak | 78e68d3 | 2014-12-15 18:59:27 +0200 | [diff] [blame] | 4059 | */ |
Akash Goel | f4e9af4 | 2016-10-12 21:54:30 +0530 | [diff] [blame] | 4060 | GEN8_IRQ_INIT_NDX(GT, 2, dev_priv->pm_imr, dev_priv->pm_ier); |
Deepak S | 9a2d2d8 | 2014-08-22 08:32:40 +0530 | [diff] [blame] | 4061 | GEN8_IRQ_INIT_NDX(GT, 3, ~gt_interrupts[3], gt_interrupts[3]); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4062 | } |
| 4063 | |
| 4064 | static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv) |
| 4065 | { |
Jani Nikula | a9c287c | 2019-01-16 11:15:24 +0200 | [diff] [blame] | 4066 | u32 de_pipe_masked = GEN8_PIPE_CDCLK_CRC_DONE; |
| 4067 | u32 de_pipe_enables; |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 4068 | u32 de_port_masked = GEN8_AUX_CHANNEL_A; |
| 4069 | u32 de_port_enables; |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 4070 | u32 de_misc_masked = GEN8_DE_EDP_PSR; |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 4071 | enum pipe pipe; |
Damien Lespiau | 770de83d | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 4072 | |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 4073 | if (INTEL_GEN(dev_priv) <= 10) |
| 4074 | de_misc_masked |= GEN8_DE_MISC_GSE; |
| 4075 | |
Pandiyan, Dhinakaran | bca2bf2 | 2017-07-18 11:28:00 -0700 | [diff] [blame] | 4076 | if (INTEL_GEN(dev_priv) >= 9) { |
Ville Syrjälä | 842ebf7 | 2017-08-18 21:36:50 +0300 | [diff] [blame] | 4077 | de_pipe_masked |= GEN9_DE_PIPE_IRQ_FAULT_ERRORS; |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 4078 | de_port_masked |= GEN9_AUX_CHANNEL_B | GEN9_AUX_CHANNEL_C | |
| 4079 | GEN9_AUX_CHANNEL_D; |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4080 | if (IS_GEN9_LP(dev_priv)) |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 4081 | de_port_masked |= BXT_DE_PORT_GMBUS; |
| 4082 | } else { |
Ville Syrjälä | 842ebf7 | 2017-08-18 21:36:50 +0300 | [diff] [blame] | 4083 | de_pipe_masked |= GEN8_DE_PIPE_IRQ_FAULT_ERRORS; |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 4084 | } |
Damien Lespiau | 770de83d | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 4085 | |
James Ausmus | bb187e9 | 2018-06-11 17:25:12 -0700 | [diff] [blame] | 4086 | if (INTEL_GEN(dev_priv) >= 11) |
| 4087 | de_port_masked |= ICL_AUX_CHANNEL_E; |
| 4088 | |
Dhinakaran Pandiyan | 9bb635d | 2018-05-21 17:25:35 -0700 | [diff] [blame] | 4089 | if (IS_CNL_WITH_PORT_F(dev_priv) || INTEL_GEN(dev_priv) >= 11) |
Rodrigo Vivi | a324fca | 2018-01-29 15:22:15 -0800 | [diff] [blame] | 4090 | de_port_masked |= CNL_AUX_CHANNEL_F; |
| 4091 | |
Damien Lespiau | 770de83d | 2014-03-20 20:45:01 +0000 | [diff] [blame] | 4092 | de_pipe_enables = de_pipe_masked | GEN8_PIPE_VBLANK | |
| 4093 | GEN8_PIPE_FIFO_UNDERRUN; |
| 4094 | |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 4095 | de_port_enables = de_port_masked; |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4096 | if (IS_GEN9_LP(dev_priv)) |
Ville Syrjälä | a52bb15 | 2015-08-27 23:56:11 +0300 | [diff] [blame] | 4097 | de_port_enables |= BXT_DE_PORT_HOTPLUG_MASK; |
| 4098 | else if (IS_BROADWELL(dev_priv)) |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 4099 | de_port_enables |= GEN8_PORT_DP_A_HOTPLUG; |
| 4100 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 4101 | gen3_assert_iir_is_zero(&dev_priv->uncore, EDP_PSR_IIR); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 4102 | intel_psr_irq_control(dev_priv, dev_priv->psr.debug); |
Ville Syrjälä | e04f7ec | 2018-04-03 14:24:18 -0700 | [diff] [blame] | 4103 | |
Mika Kahola | 0a195c0 | 2017-10-10 13:17:04 +0300 | [diff] [blame] | 4104 | for_each_pipe(dev_priv, pipe) { |
| 4105 | dev_priv->de_irq_mask[pipe] = ~de_pipe_masked; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4106 | |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 4107 | if (intel_display_power_is_enabled(dev_priv, |
Paulo Zanoni | 813bde4 | 2014-07-04 11:50:29 -0300 | [diff] [blame] | 4108 | POWER_DOMAIN_PIPE(pipe))) |
| 4109 | GEN8_IRQ_INIT_NDX(DE_PIPE, pipe, |
| 4110 | dev_priv->de_irq_mask[pipe], |
| 4111 | de_pipe_enables); |
Mika Kahola | 0a195c0 | 2017-10-10 13:17:04 +0300 | [diff] [blame] | 4112 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4113 | |
Ville Syrjälä | 3488d4e | 2017-08-18 21:36:52 +0300 | [diff] [blame] | 4114 | GEN3_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables); |
| 4115 | GEN3_IRQ_INIT(GEN8_DE_MISC_, ~de_misc_masked, de_misc_masked); |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 4116 | |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 4117 | if (INTEL_GEN(dev_priv) >= 11) { |
| 4118 | u32 de_hpd_masked = 0; |
Dhinakaran Pandiyan | b796b97 | 2018-06-15 17:05:30 -0700 | [diff] [blame] | 4119 | u32 de_hpd_enables = GEN11_DE_TC_HOTPLUG_MASK | |
| 4120 | GEN11_DE_TBT_HOTPLUG_MASK; |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 4121 | |
| 4122 | GEN3_IRQ_INIT(GEN11_DE_HPD_, ~de_hpd_masked, de_hpd_enables); |
| 4123 | gen11_hpd_detection_setup(dev_priv); |
| 4124 | } else if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 2a57d9c | 2017-01-27 11:39:18 +0200 | [diff] [blame] | 4125 | bxt_hpd_detection_setup(dev_priv); |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 4126 | } else if (IS_BROADWELL(dev_priv)) { |
Imre Deak | 1a56b1a | 2017-01-27 11:39:21 +0200 | [diff] [blame] | 4127 | ilk_hpd_detection_setup(dev_priv); |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 4128 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4129 | } |
| 4130 | |
| 4131 | static int gen8_irq_postinstall(struct drm_device *dev) |
| 4132 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4133 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4134 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 4135 | if (HAS_PCH_SPLIT(dev_priv)) |
Shashank Sharma | 266ea3d | 2014-08-22 17:40:42 +0530 | [diff] [blame] | 4136 | ibx_irq_pre_postinstall(dev); |
Paulo Zanoni | 622364b | 2014-04-01 15:37:22 -0300 | [diff] [blame] | 4137 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4138 | gen8_gt_irq_postinstall(dev_priv); |
| 4139 | gen8_de_irq_postinstall(dev_priv); |
| 4140 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 4141 | if (HAS_PCH_SPLIT(dev_priv)) |
Shashank Sharma | 266ea3d | 2014-08-22 17:40:42 +0530 | [diff] [blame] | 4142 | ibx_irq_postinstall(dev); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4143 | |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 4144 | gen8_master_intr_enable(dev_priv->uncore.regs); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4145 | |
| 4146 | return 0; |
| 4147 | } |
| 4148 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 4149 | static void gen11_gt_irq_postinstall(struct drm_i915_private *dev_priv) |
| 4150 | { |
| 4151 | const u32 irqs = GT_RENDER_USER_INTERRUPT | GT_CONTEXT_SWITCH_INTERRUPT; |
| 4152 | |
| 4153 | BUILD_BUG_ON(irqs & 0xffff0000); |
| 4154 | |
| 4155 | /* Enable RCS, BCS, VCS and VECS class interrupts. */ |
| 4156 | I915_WRITE(GEN11_RENDER_COPY_INTR_ENABLE, irqs << 16 | irqs); |
| 4157 | I915_WRITE(GEN11_VCS_VECS_INTR_ENABLE, irqs << 16 | irqs); |
| 4158 | |
| 4159 | /* Unmask irqs on RCS, BCS, VCS and VECS engines. */ |
| 4160 | I915_WRITE(GEN11_RCS0_RSVD_INTR_MASK, ~(irqs << 16)); |
| 4161 | I915_WRITE(GEN11_BCS_RSVD_INTR_MASK, ~(irqs << 16)); |
| 4162 | I915_WRITE(GEN11_VCS0_VCS1_INTR_MASK, ~(irqs | irqs << 16)); |
| 4163 | I915_WRITE(GEN11_VCS2_VCS3_INTR_MASK, ~(irqs | irqs << 16)); |
| 4164 | I915_WRITE(GEN11_VECS0_VECS1_INTR_MASK, ~(irqs | irqs << 16)); |
| 4165 | |
Oscar Mateo | d02b98b | 2018-04-05 17:00:50 +0300 | [diff] [blame] | 4166 | /* |
| 4167 | * RPS interrupts will get enabled/disabled on demand when RPS itself |
| 4168 | * is enabled/disabled. |
| 4169 | */ |
| 4170 | dev_priv->pm_ier = 0x0; |
| 4171 | dev_priv->pm_imr = ~dev_priv->pm_ier; |
| 4172 | I915_WRITE(GEN11_GPM_WGBOXPERF_INTR_ENABLE, 0); |
| 4173 | I915_WRITE(GEN11_GPM_WGBOXPERF_INTR_MASK, ~0); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 4174 | } |
| 4175 | |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 4176 | static void icp_irq_postinstall(struct drm_device *dev) |
| 4177 | { |
| 4178 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 4179 | u32 mask = SDE_GMBUS_ICP; |
| 4180 | |
| 4181 | WARN_ON(I915_READ(SDEIER) != 0); |
| 4182 | I915_WRITE(SDEIER, 0xffffffff); |
| 4183 | POSTING_READ(SDEIER); |
| 4184 | |
Paulo Zanoni | 65f42cd | 2019-04-10 16:53:43 -0700 | [diff] [blame^] | 4185 | gen3_assert_iir_is_zero(&dev_priv->uncore, SDEIIR); |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 4186 | I915_WRITE(SDEIMR, ~mask); |
| 4187 | |
| 4188 | icp_hpd_detection_setup(dev_priv); |
| 4189 | } |
| 4190 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 4191 | static int gen11_irq_postinstall(struct drm_device *dev) |
| 4192 | { |
| 4193 | struct drm_i915_private *dev_priv = dev->dev_private; |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 4194 | u32 gu_misc_masked = GEN11_GU_MISC_GSE; |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 4195 | |
Rodrigo Vivi | 29b43ae | 2019-03-13 14:43:07 -0700 | [diff] [blame] | 4196 | if (INTEL_PCH_TYPE(dev_priv) >= PCH_ICP) |
Anusha Srivatsa | 3160422 | 2018-06-26 13:52:23 -0700 | [diff] [blame] | 4197 | icp_irq_postinstall(dev); |
| 4198 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 4199 | gen11_gt_irq_postinstall(dev_priv); |
| 4200 | gen8_de_irq_postinstall(dev_priv); |
| 4201 | |
Dhinakaran Pandiyan | df0d28c | 2018-06-15 17:05:28 -0700 | [diff] [blame] | 4202 | GEN3_IRQ_INIT(GEN11_GU_MISC_, ~gu_misc_masked, gu_misc_masked); |
| 4203 | |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 4204 | I915_WRITE(GEN11_DISPLAY_INT_CTL, GEN11_DISPLAY_IRQ_ENABLE); |
| 4205 | |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 4206 | gen11_master_intr_enable(dev_priv->uncore.regs); |
Daniele Ceraolo Spurio | c25f0c6 | 2019-01-22 18:32:27 -0800 | [diff] [blame] | 4207 | POSTING_READ(GEN11_GFX_MSTR_IRQ); |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 4208 | |
| 4209 | return 0; |
| 4210 | } |
| 4211 | |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 4212 | static int cherryview_irq_postinstall(struct drm_device *dev) |
| 4213 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4214 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 4215 | |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 4216 | gen8_gt_irq_postinstall(dev_priv); |
| 4217 | |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 4218 | spin_lock_irq(&dev_priv->irq_lock); |
Ville Syrjälä | 9918271 | 2016-04-11 16:56:25 +0300 | [diff] [blame] | 4219 | if (dev_priv->display_irqs_enabled) |
| 4220 | vlv_display_irq_postinstall(dev_priv); |
Ville Syrjälä | ad22d10 | 2016-04-12 18:56:14 +0300 | [diff] [blame] | 4221 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4222 | |
Ville Syrjälä | e5328c4 | 2016-04-13 21:19:47 +0300 | [diff] [blame] | 4223 | I915_WRITE(GEN8_MASTER_IRQ, GEN8_MASTER_IRQ_CONTROL); |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 4224 | POSTING_READ(GEN8_MASTER_IRQ); |
| 4225 | |
| 4226 | return 0; |
| 4227 | } |
| 4228 | |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4229 | static void i8xx_irq_reset(struct drm_device *dev) |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4230 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4231 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4232 | |
Ville Syrjälä | 44d9241 | 2017-08-18 21:36:51 +0300 | [diff] [blame] | 4233 | i9xx_pipestat_irq_reset(dev_priv); |
| 4234 | |
Ville Syrjälä | e9e9848 | 2017-08-18 21:36:54 +0300 | [diff] [blame] | 4235 | GEN2_IRQ_RESET(); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4236 | } |
| 4237 | |
| 4238 | static int i8xx_irq_postinstall(struct drm_device *dev) |
| 4239 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4240 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | e9e9848 | 2017-08-18 21:36:54 +0300 | [diff] [blame] | 4241 | u16 enable_mask; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4242 | |
Ville Syrjälä | 045cebd | 2017-08-18 21:36:55 +0300 | [diff] [blame] | 4243 | I915_WRITE16(EMR, ~(I915_ERROR_PAGE_TABLE | |
| 4244 | I915_ERROR_MEMORY_REFRESH)); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4245 | |
| 4246 | /* Unmask the interrupts that we always want on. */ |
| 4247 | dev_priv->irq_mask = |
| 4248 | ~(I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
Ville Syrjälä | 16659bc | 2018-06-11 23:02:58 +0300 | [diff] [blame] | 4249 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
| 4250 | I915_MASTER_ERROR_INTERRUPT); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4251 | |
Ville Syrjälä | e9e9848 | 2017-08-18 21:36:54 +0300 | [diff] [blame] | 4252 | enable_mask = |
| 4253 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
| 4254 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
Ville Syrjälä | 16659bc | 2018-06-11 23:02:58 +0300 | [diff] [blame] | 4255 | I915_MASTER_ERROR_INTERRUPT | |
Ville Syrjälä | e9e9848 | 2017-08-18 21:36:54 +0300 | [diff] [blame] | 4256 | I915_USER_INTERRUPT; |
| 4257 | |
Paulo Zanoni | 2918c3c | 2019-04-10 16:53:41 -0700 | [diff] [blame] | 4258 | GEN2_IRQ_INIT(dev_priv->irq_mask, enable_mask); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4259 | |
Daniel Vetter | 379ef82 | 2013-10-16 22:55:56 +0200 | [diff] [blame] | 4260 | /* Interrupt setup is already guaranteed to be single-threaded, this is |
| 4261 | * just to make the assert_spin_locked check happy. */ |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 4262 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 4263 | i915_enable_pipestat(dev_priv, PIPE_A, PIPE_CRC_DONE_INTERRUPT_STATUS); |
| 4264 | i915_enable_pipestat(dev_priv, PIPE_B, PIPE_CRC_DONE_INTERRUPT_STATUS); |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 4265 | spin_unlock_irq(&dev_priv->irq_lock); |
Daniel Vetter | 379ef82 | 2013-10-16 22:55:56 +0200 | [diff] [blame] | 4266 | |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4267 | return 0; |
| 4268 | } |
| 4269 | |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4270 | static void i8xx_error_irq_ack(struct drm_i915_private *dev_priv, |
| 4271 | u16 *eir, u16 *eir_stuck) |
| 4272 | { |
| 4273 | u16 emr; |
| 4274 | |
| 4275 | *eir = I915_READ16(EIR); |
| 4276 | |
| 4277 | if (*eir) |
| 4278 | I915_WRITE16(EIR, *eir); |
| 4279 | |
| 4280 | *eir_stuck = I915_READ16(EIR); |
| 4281 | if (*eir_stuck == 0) |
| 4282 | return; |
| 4283 | |
| 4284 | /* |
| 4285 | * Toggle all EMR bits to make sure we get an edge |
| 4286 | * in the ISR master error bit if we don't clear |
| 4287 | * all the EIR bits. Otherwise the edge triggered |
| 4288 | * IIR on i965/g4x wouldn't notice that an interrupt |
| 4289 | * is still pending. Also some EIR bits can't be |
| 4290 | * cleared except by handling the underlying error |
| 4291 | * (or by a GPU reset) so we mask any bit that |
| 4292 | * remains set. |
| 4293 | */ |
| 4294 | emr = I915_READ16(EMR); |
| 4295 | I915_WRITE16(EMR, 0xffff); |
| 4296 | I915_WRITE16(EMR, emr | *eir_stuck); |
| 4297 | } |
| 4298 | |
| 4299 | static void i8xx_error_irq_handler(struct drm_i915_private *dev_priv, |
| 4300 | u16 eir, u16 eir_stuck) |
| 4301 | { |
| 4302 | DRM_DEBUG("Master Error: EIR 0x%04x\n", eir); |
| 4303 | |
| 4304 | if (eir_stuck) |
| 4305 | DRM_DEBUG_DRIVER("EIR stuck: 0x%04x, masked\n", eir_stuck); |
| 4306 | } |
| 4307 | |
| 4308 | static void i9xx_error_irq_ack(struct drm_i915_private *dev_priv, |
| 4309 | u32 *eir, u32 *eir_stuck) |
| 4310 | { |
| 4311 | u32 emr; |
| 4312 | |
| 4313 | *eir = I915_READ(EIR); |
| 4314 | |
| 4315 | I915_WRITE(EIR, *eir); |
| 4316 | |
| 4317 | *eir_stuck = I915_READ(EIR); |
| 4318 | if (*eir_stuck == 0) |
| 4319 | return; |
| 4320 | |
| 4321 | /* |
| 4322 | * Toggle all EMR bits to make sure we get an edge |
| 4323 | * in the ISR master error bit if we don't clear |
| 4324 | * all the EIR bits. Otherwise the edge triggered |
| 4325 | * IIR on i965/g4x wouldn't notice that an interrupt |
| 4326 | * is still pending. Also some EIR bits can't be |
| 4327 | * cleared except by handling the underlying error |
| 4328 | * (or by a GPU reset) so we mask any bit that |
| 4329 | * remains set. |
| 4330 | */ |
| 4331 | emr = I915_READ(EMR); |
| 4332 | I915_WRITE(EMR, 0xffffffff); |
| 4333 | I915_WRITE(EMR, emr | *eir_stuck); |
| 4334 | } |
| 4335 | |
| 4336 | static void i9xx_error_irq_handler(struct drm_i915_private *dev_priv, |
| 4337 | u32 eir, u32 eir_stuck) |
| 4338 | { |
| 4339 | DRM_DEBUG("Master Error, EIR 0x%08x\n", eir); |
| 4340 | |
| 4341 | if (eir_stuck) |
| 4342 | DRM_DEBUG_DRIVER("EIR stuck: 0x%08x, masked\n", eir_stuck); |
| 4343 | } |
| 4344 | |
Daniel Vetter | ff1f525 | 2012-10-02 15:10:55 +0200 | [diff] [blame] | 4345 | static irqreturn_t i8xx_irq_handler(int irq, void *arg) |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4346 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 4347 | struct drm_device *dev = arg; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4348 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4349 | irqreturn_t ret = IRQ_NONE; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4350 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 4351 | if (!intel_irqs_enabled(dev_priv)) |
| 4352 | return IRQ_NONE; |
| 4353 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 4354 | /* IRQs are synced during runtime_suspend, we don't require a wakeref */ |
| 4355 | disable_rpm_wakeref_asserts(dev_priv); |
| 4356 | |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4357 | do { |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 4358 | u32 pipe_stats[I915_MAX_PIPES] = {}; |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4359 | u16 eir = 0, eir_stuck = 0; |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4360 | u16 iir; |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 4361 | |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 4362 | iir = I915_READ16(GEN2_IIR); |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4363 | if (iir == 0) |
| 4364 | break; |
| 4365 | |
| 4366 | ret = IRQ_HANDLED; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4367 | |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 4368 | /* Call regardless, as some status bits might not be |
| 4369 | * signalled in iir */ |
| 4370 | i9xx_pipestat_irq_ack(dev_priv, iir, pipe_stats); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4371 | |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4372 | if (iir & I915_MASTER_ERROR_INTERRUPT) |
| 4373 | i8xx_error_irq_ack(dev_priv, &eir, &eir_stuck); |
| 4374 | |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 4375 | I915_WRITE16(GEN2_IIR, iir); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4376 | |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4377 | if (iir & I915_USER_INTERRUPT) |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 4378 | intel_engine_breadcrumbs_irq(dev_priv->engine[RCS0]); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4379 | |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4380 | if (iir & I915_MASTER_ERROR_INTERRUPT) |
| 4381 | i8xx_error_irq_handler(dev_priv, eir, eir_stuck); |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4382 | |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 4383 | i8xx_pipestat_irq_handler(dev_priv, iir, pipe_stats); |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4384 | } while (0); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4385 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 4386 | enable_rpm_wakeref_asserts(dev_priv); |
| 4387 | |
| 4388 | return ret; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4389 | } |
| 4390 | |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4391 | static void i915_irq_reset(struct drm_device *dev) |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4392 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4393 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4394 | |
Tvrtko Ursulin | 56b857a | 2016-11-07 09:29:20 +0000 | [diff] [blame] | 4395 | if (I915_HAS_HOTPLUG(dev_priv)) { |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 4396 | i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4397 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
| 4398 | } |
| 4399 | |
Ville Syrjälä | 44d9241 | 2017-08-18 21:36:51 +0300 | [diff] [blame] | 4400 | i9xx_pipestat_irq_reset(dev_priv); |
| 4401 | |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 4402 | GEN3_IRQ_RESET(GEN2_); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4403 | } |
| 4404 | |
| 4405 | static int i915_irq_postinstall(struct drm_device *dev) |
| 4406 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4407 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4408 | u32 enable_mask; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4409 | |
Ville Syrjälä | 045cebd | 2017-08-18 21:36:55 +0300 | [diff] [blame] | 4410 | I915_WRITE(EMR, ~(I915_ERROR_PAGE_TABLE | |
| 4411 | I915_ERROR_MEMORY_REFRESH)); |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4412 | |
| 4413 | /* Unmask the interrupts that we always want on. */ |
| 4414 | dev_priv->irq_mask = |
| 4415 | ~(I915_ASLE_INTERRUPT | |
| 4416 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
Ville Syrjälä | 16659bc | 2018-06-11 23:02:58 +0300 | [diff] [blame] | 4417 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
| 4418 | I915_MASTER_ERROR_INTERRUPT); |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4419 | |
| 4420 | enable_mask = |
| 4421 | I915_ASLE_INTERRUPT | |
| 4422 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
| 4423 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
Ville Syrjälä | 16659bc | 2018-06-11 23:02:58 +0300 | [diff] [blame] | 4424 | I915_MASTER_ERROR_INTERRUPT | |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4425 | I915_USER_INTERRUPT; |
| 4426 | |
Tvrtko Ursulin | 56b857a | 2016-11-07 09:29:20 +0000 | [diff] [blame] | 4427 | if (I915_HAS_HOTPLUG(dev_priv)) { |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4428 | /* Enable in IER... */ |
| 4429 | enable_mask |= I915_DISPLAY_PORT_INTERRUPT; |
| 4430 | /* and unmask in IMR */ |
| 4431 | dev_priv->irq_mask &= ~I915_DISPLAY_PORT_INTERRUPT; |
| 4432 | } |
| 4433 | |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 4434 | GEN3_IRQ_INIT(GEN2_, dev_priv->irq_mask, enable_mask); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4435 | |
Daniel Vetter | 379ef82 | 2013-10-16 22:55:56 +0200 | [diff] [blame] | 4436 | /* Interrupt setup is already guaranteed to be single-threaded, this is |
| 4437 | * just to make the assert_spin_locked check happy. */ |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 4438 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 4439 | i915_enable_pipestat(dev_priv, PIPE_A, PIPE_CRC_DONE_INTERRUPT_STATUS); |
| 4440 | i915_enable_pipestat(dev_priv, PIPE_B, PIPE_CRC_DONE_INTERRUPT_STATUS); |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 4441 | spin_unlock_irq(&dev_priv->irq_lock); |
Daniel Vetter | 379ef82 | 2013-10-16 22:55:56 +0200 | [diff] [blame] | 4442 | |
Ville Syrjälä | c30bb1f | 2017-08-18 21:36:57 +0300 | [diff] [blame] | 4443 | i915_enable_asle_pipestat(dev_priv); |
| 4444 | |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4445 | return 0; |
| 4446 | } |
| 4447 | |
Daniel Vetter | ff1f525 | 2012-10-02 15:10:55 +0200 | [diff] [blame] | 4448 | static irqreturn_t i915_irq_handler(int irq, void *arg) |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4449 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 4450 | struct drm_device *dev = arg; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4451 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4452 | irqreturn_t ret = IRQ_NONE; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4453 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 4454 | if (!intel_irqs_enabled(dev_priv)) |
| 4455 | return IRQ_NONE; |
| 4456 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 4457 | /* IRQs are synced during runtime_suspend, we don't require a wakeref */ |
| 4458 | disable_rpm_wakeref_asserts(dev_priv); |
| 4459 | |
Chris Wilson | 38bde18 | 2012-04-24 22:59:50 +0100 | [diff] [blame] | 4460 | do { |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 4461 | u32 pipe_stats[I915_MAX_PIPES] = {}; |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4462 | u32 eir = 0, eir_stuck = 0; |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4463 | u32 hotplug_status = 0; |
| 4464 | u32 iir; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4465 | |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 4466 | iir = I915_READ(GEN2_IIR); |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4467 | if (iir == 0) |
| 4468 | break; |
| 4469 | |
| 4470 | ret = IRQ_HANDLED; |
| 4471 | |
| 4472 | if (I915_HAS_HOTPLUG(dev_priv) && |
| 4473 | iir & I915_DISPLAY_PORT_INTERRUPT) |
| 4474 | hotplug_status = i9xx_hpd_irq_ack(dev_priv); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4475 | |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 4476 | /* Call regardless, as some status bits might not be |
| 4477 | * signalled in iir */ |
| 4478 | i9xx_pipestat_irq_ack(dev_priv, iir, pipe_stats); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4479 | |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4480 | if (iir & I915_MASTER_ERROR_INTERRUPT) |
| 4481 | i9xx_error_irq_ack(dev_priv, &eir, &eir_stuck); |
| 4482 | |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 4483 | I915_WRITE(GEN2_IIR, iir); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4484 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4485 | if (iir & I915_USER_INTERRUPT) |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 4486 | intel_engine_breadcrumbs_irq(dev_priv->engine[RCS0]); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4487 | |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4488 | if (iir & I915_MASTER_ERROR_INTERRUPT) |
| 4489 | i9xx_error_irq_handler(dev_priv, eir, eir_stuck); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4490 | |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4491 | if (hotplug_status) |
| 4492 | i9xx_hpd_irq_handler(dev_priv, hotplug_status); |
| 4493 | |
| 4494 | i915_pipestat_irq_handler(dev_priv, iir, pipe_stats); |
| 4495 | } while (0); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4496 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 4497 | enable_rpm_wakeref_asserts(dev_priv); |
| 4498 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4499 | return ret; |
| 4500 | } |
| 4501 | |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4502 | static void i965_irq_reset(struct drm_device *dev) |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4503 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4504 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4505 | |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 4506 | i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0); |
Chris Wilson | adca473 | 2012-05-11 18:01:31 +0100 | [diff] [blame] | 4507 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4508 | |
Ville Syrjälä | 44d9241 | 2017-08-18 21:36:51 +0300 | [diff] [blame] | 4509 | i9xx_pipestat_irq_reset(dev_priv); |
| 4510 | |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 4511 | GEN3_IRQ_RESET(GEN2_); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4512 | } |
| 4513 | |
| 4514 | static int i965_irq_postinstall(struct drm_device *dev) |
| 4515 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4516 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | bbba0a9 | 2012-04-24 22:59:51 +0100 | [diff] [blame] | 4517 | u32 enable_mask; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4518 | u32 error_mask; |
| 4519 | |
Ville Syrjälä | 045cebd | 2017-08-18 21:36:55 +0300 | [diff] [blame] | 4520 | /* |
| 4521 | * Enable some error detection, note the instruction error mask |
| 4522 | * bit is reserved, so we leave it masked. |
| 4523 | */ |
| 4524 | if (IS_G4X(dev_priv)) { |
| 4525 | error_mask = ~(GM45_ERROR_PAGE_TABLE | |
| 4526 | GM45_ERROR_MEM_PRIV | |
| 4527 | GM45_ERROR_CP_PRIV | |
| 4528 | I915_ERROR_MEMORY_REFRESH); |
| 4529 | } else { |
| 4530 | error_mask = ~(I915_ERROR_PAGE_TABLE | |
| 4531 | I915_ERROR_MEMORY_REFRESH); |
| 4532 | } |
| 4533 | I915_WRITE(EMR, error_mask); |
| 4534 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4535 | /* Unmask the interrupts that we always want on. */ |
Ville Syrjälä | c30bb1f | 2017-08-18 21:36:57 +0300 | [diff] [blame] | 4536 | dev_priv->irq_mask = |
| 4537 | ~(I915_ASLE_INTERRUPT | |
| 4538 | I915_DISPLAY_PORT_INTERRUPT | |
| 4539 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
| 4540 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4541 | I915_MASTER_ERROR_INTERRUPT); |
Chris Wilson | bbba0a9 | 2012-04-24 22:59:51 +0100 | [diff] [blame] | 4542 | |
Ville Syrjälä | c30bb1f | 2017-08-18 21:36:57 +0300 | [diff] [blame] | 4543 | enable_mask = |
| 4544 | I915_ASLE_INTERRUPT | |
| 4545 | I915_DISPLAY_PORT_INTERRUPT | |
| 4546 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | |
| 4547 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4548 | I915_MASTER_ERROR_INTERRUPT | |
Ville Syrjälä | c30bb1f | 2017-08-18 21:36:57 +0300 | [diff] [blame] | 4549 | I915_USER_INTERRUPT; |
Chris Wilson | bbba0a9 | 2012-04-24 22:59:51 +0100 | [diff] [blame] | 4550 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 4551 | if (IS_G4X(dev_priv)) |
Chris Wilson | bbba0a9 | 2012-04-24 22:59:51 +0100 | [diff] [blame] | 4552 | enable_mask |= I915_BSD_USER_INTERRUPT; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4553 | |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 4554 | GEN3_IRQ_INIT(GEN2_, dev_priv->irq_mask, enable_mask); |
Ville Syrjälä | c30bb1f | 2017-08-18 21:36:57 +0300 | [diff] [blame] | 4555 | |
Daniel Vetter | b79480b | 2013-06-27 17:52:10 +0200 | [diff] [blame] | 4556 | /* Interrupt setup is already guaranteed to be single-threaded, this is |
| 4557 | * just to make the assert_spin_locked check happy. */ |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 4558 | spin_lock_irq(&dev_priv->irq_lock); |
Imre Deak | 755e901 | 2014-02-10 18:42:47 +0200 | [diff] [blame] | 4559 | i915_enable_pipestat(dev_priv, PIPE_A, PIPE_GMBUS_INTERRUPT_STATUS); |
| 4560 | i915_enable_pipestat(dev_priv, PIPE_A, PIPE_CRC_DONE_INTERRUPT_STATUS); |
| 4561 | i915_enable_pipestat(dev_priv, PIPE_B, PIPE_CRC_DONE_INTERRUPT_STATUS); |
Daniel Vetter | d620743 | 2014-09-15 14:55:27 +0200 | [diff] [blame] | 4562 | spin_unlock_irq(&dev_priv->irq_lock); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4563 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 4564 | i915_enable_asle_pipestat(dev_priv); |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4565 | |
| 4566 | return 0; |
| 4567 | } |
| 4568 | |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 4569 | static void i915_hpd_irq_setup(struct drm_i915_private *dev_priv) |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4570 | { |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4571 | u32 hotplug_en; |
| 4572 | |
Chris Wilson | 6752041 | 2017-03-02 13:28:01 +0000 | [diff] [blame] | 4573 | lockdep_assert_held(&dev_priv->irq_lock); |
Daniel Vetter | b5ea2d5 | 2013-06-27 17:52:15 +0200 | [diff] [blame] | 4574 | |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4575 | /* Note HDMI and DP share hotplug bits */ |
| 4576 | /* enable bits are the same for all generations */ |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 4577 | hotplug_en = intel_hpd_enabled_irqs(dev_priv, hpd_mask_i915); |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4578 | /* Programming the CRT detection parameters tends |
| 4579 | to generate a spurious hotplug event about three |
| 4580 | seconds later. So just do it once. |
| 4581 | */ |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 4582 | if (IS_G4X(dev_priv)) |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4583 | hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64; |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4584 | hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4585 | |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4586 | /* Ignore TV since it's buggy */ |
Egbert Eich | 0706f17 | 2015-09-23 16:15:27 +0200 | [diff] [blame] | 4587 | i915_hotplug_interrupt_update_locked(dev_priv, |
Jani Nikula | f9e3dc7 | 2015-10-21 17:22:43 +0300 | [diff] [blame] | 4588 | HOTPLUG_INT_EN_MASK | |
| 4589 | CRT_HOTPLUG_VOLTAGE_COMPARE_MASK | |
| 4590 | CRT_HOTPLUG_ACTIVATION_PERIOD_64, |
| 4591 | hotplug_en); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4592 | } |
| 4593 | |
Daniel Vetter | ff1f525 | 2012-10-02 15:10:55 +0200 | [diff] [blame] | 4594 | static irqreturn_t i965_irq_handler(int irq, void *arg) |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4595 | { |
Daniel Vetter | 45a83f8 | 2014-05-12 19:17:55 +0200 | [diff] [blame] | 4596 | struct drm_device *dev = arg; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4597 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4598 | irqreturn_t ret = IRQ_NONE; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4599 | |
Imre Deak | 2dd2a88 | 2015-02-24 11:14:30 +0200 | [diff] [blame] | 4600 | if (!intel_irqs_enabled(dev_priv)) |
| 4601 | return IRQ_NONE; |
| 4602 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 4603 | /* IRQs are synced during runtime_suspend, we don't require a wakeref */ |
| 4604 | disable_rpm_wakeref_asserts(dev_priv); |
| 4605 | |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4606 | do { |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 4607 | u32 pipe_stats[I915_MAX_PIPES] = {}; |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4608 | u32 eir = 0, eir_stuck = 0; |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4609 | u32 hotplug_status = 0; |
| 4610 | u32 iir; |
Chris Wilson | 2c8ba29 | 2012-04-24 22:59:46 +0100 | [diff] [blame] | 4611 | |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 4612 | iir = I915_READ(GEN2_IIR); |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4613 | if (iir == 0) |
| 4614 | break; |
| 4615 | |
| 4616 | ret = IRQ_HANDLED; |
| 4617 | |
| 4618 | if (iir & I915_DISPLAY_PORT_INTERRUPT) |
| 4619 | hotplug_status = i9xx_hpd_irq_ack(dev_priv); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4620 | |
Ville Syrjälä | eb64343 | 2017-08-18 21:36:59 +0300 | [diff] [blame] | 4621 | /* Call regardless, as some status bits might not be |
| 4622 | * signalled in iir */ |
| 4623 | i9xx_pipestat_irq_ack(dev_priv, iir, pipe_stats); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4624 | |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4625 | if (iir & I915_MASTER_ERROR_INTERRUPT) |
| 4626 | i9xx_error_irq_ack(dev_priv, &eir, &eir_stuck); |
| 4627 | |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 4628 | I915_WRITE(GEN2_IIR, iir); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4629 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4630 | if (iir & I915_USER_INTERRUPT) |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 4631 | intel_engine_breadcrumbs_irq(dev_priv->engine[RCS0]); |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4632 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4633 | if (iir & I915_BSD_USER_INTERRUPT) |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 4634 | intel_engine_breadcrumbs_irq(dev_priv->engine[VCS0]); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4635 | |
Ville Syrjälä | 78c357d | 2018-06-11 23:02:57 +0300 | [diff] [blame] | 4636 | if (iir & I915_MASTER_ERROR_INTERRUPT) |
| 4637 | i9xx_error_irq_handler(dev_priv, eir, eir_stuck); |
Daniel Vetter | 515ac2b | 2012-12-01 13:53:44 +0100 | [diff] [blame] | 4638 | |
Ville Syrjälä | af722d2 | 2017-08-18 21:37:00 +0300 | [diff] [blame] | 4639 | if (hotplug_status) |
| 4640 | i9xx_hpd_irq_handler(dev_priv, hotplug_status); |
| 4641 | |
| 4642 | i965_pipestat_irq_handler(dev_priv, iir, pipe_stats); |
| 4643 | } while (0); |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4644 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 4645 | enable_rpm_wakeref_asserts(dev_priv); |
| 4646 | |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4647 | return ret; |
| 4648 | } |
| 4649 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4650 | /** |
| 4651 | * intel_irq_init - initializes irq support |
| 4652 | * @dev_priv: i915 device instance |
| 4653 | * |
| 4654 | * This function initializes all the irq support including work items, timers |
| 4655 | * and all the vtables. It does not setup the interrupt itself though. |
| 4656 | */ |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4657 | void intel_irq_init(struct drm_i915_private *dev_priv) |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4658 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4659 | struct drm_device *dev = &dev_priv->drm; |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4660 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Joonas Lahtinen | cefcff8 | 2017-04-28 10:58:39 +0300 | [diff] [blame] | 4661 | int i; |
Chris Wilson | 8b2e326 | 2012-04-24 22:59:41 +0100 | [diff] [blame] | 4662 | |
Ville Syrjälä | d938da6 | 2019-03-22 20:08:03 +0200 | [diff] [blame] | 4663 | if (IS_I945GM(dev_priv)) |
| 4664 | i945gm_vblank_work_init(dev_priv); |
| 4665 | |
Jani Nikula | 77913b3 | 2015-06-18 13:06:16 +0300 | [diff] [blame] | 4666 | intel_hpd_init_work(dev_priv); |
| 4667 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4668 | INIT_WORK(&rps->work, gen6_pm_rps_work); |
Joonas Lahtinen | cefcff8 | 2017-04-28 10:58:39 +0300 | [diff] [blame] | 4669 | |
Daniel Vetter | a4da4fa | 2012-11-02 19:55:07 +0100 | [diff] [blame] | 4670 | INIT_WORK(&dev_priv->l3_parity.error_work, ivybridge_parity_work); |
Joonas Lahtinen | cefcff8 | 2017-04-28 10:58:39 +0300 | [diff] [blame] | 4671 | for (i = 0; i < MAX_L3_SLICES; ++i) |
| 4672 | dev_priv->l3_parity.remap_info[i] = NULL; |
Chris Wilson | 8b2e326 | 2012-04-24 22:59:41 +0100 | [diff] [blame] | 4673 | |
Tvrtko Ursulin | 4805fe8 | 2016-11-04 14:42:46 +0000 | [diff] [blame] | 4674 | if (HAS_GUC_SCHED(dev_priv)) |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 4675 | dev_priv->pm_guc_events = GEN9_GUC_TO_HOST_INT_EVENT; |
| 4676 | |
Deepak S | a6706b4 | 2014-03-15 20:23:22 +0530 | [diff] [blame] | 4677 | /* Let's track the enabled rps events */ |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 4678 | if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | 6c65a587 | 2014-08-29 14:14:07 +0300 | [diff] [blame] | 4679 | /* WaGsvRC0ResidencyMethod:vlv */ |
Chris Wilson | e0e8c7c | 2017-03-09 21:12:30 +0000 | [diff] [blame] | 4680 | dev_priv->pm_rps_events = GEN6_PM_RP_UP_EI_EXPIRED; |
Deepak S | 31685c2 | 2014-07-03 17:33:01 -0400 | [diff] [blame] | 4681 | else |
Chris Wilson | 4668f69 | 2018-08-02 11:06:30 +0100 | [diff] [blame] | 4682 | dev_priv->pm_rps_events = (GEN6_PM_RP_UP_THRESHOLD | |
| 4683 | GEN6_PM_RP_DOWN_THRESHOLD | |
| 4684 | GEN6_PM_RP_DOWN_TIMEOUT); |
Deepak S | a6706b4 | 2014-03-15 20:23:22 +0530 | [diff] [blame] | 4685 | |
Mika Kuoppala | 917dc6b | 2019-04-10 13:59:22 +0300 | [diff] [blame] | 4686 | /* We share the register with other engine */ |
| 4687 | if (INTEL_GEN(dev_priv) > 9) |
| 4688 | GEM_WARN_ON(dev_priv->pm_rps_events & 0xffff0000); |
| 4689 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4690 | rps->pm_intrmsk_mbz = 0; |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 4691 | |
| 4692 | /* |
Mika Kuoppala | acf2dc2 | 2017-04-13 14:15:27 +0300 | [diff] [blame] | 4693 | * SNB,IVB,HSW can while VLV,CHV may hard hang on looping batchbuffer |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 4694 | * if GEN6_PM_UP_EI_EXPIRED is masked. |
| 4695 | * |
| 4696 | * TODO: verify if this can be reproduced on VLV,CHV. |
| 4697 | */ |
Pandiyan, Dhinakaran | bca2bf2 | 2017-07-18 11:28:00 -0700 | [diff] [blame] | 4698 | if (INTEL_GEN(dev_priv) <= 7) |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4699 | rps->pm_intrmsk_mbz |= GEN6_PM_RP_UP_EI_EXPIRED; |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 4700 | |
Pandiyan, Dhinakaran | bca2bf2 | 2017-07-18 11:28:00 -0700 | [diff] [blame] | 4701 | if (INTEL_GEN(dev_priv) >= 8) |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4702 | rps->pm_intrmsk_mbz |= GEN8_PMINTR_DISABLE_REDIRECT_TO_GUC; |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 4703 | |
Ville Syrjälä | 32db0b6 | 2018-11-27 22:05:50 +0200 | [diff] [blame] | 4704 | if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) |
Ville Syrjälä | fd8f507c | 2015-09-18 20:03:42 +0300 | [diff] [blame] | 4705 | dev->driver->get_vblank_counter = g4x_get_vblank_counter; |
Ville Syrjälä | 32db0b6 | 2018-11-27 22:05:50 +0200 | [diff] [blame] | 4706 | else if (INTEL_GEN(dev_priv) >= 3) |
Ville Syrjälä | 391f75e | 2013-09-25 19:55:26 +0300 | [diff] [blame] | 4707 | dev->driver->get_vblank_counter = i915_get_vblank_counter; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4708 | |
Ville Syrjälä | 0df3f09 | 2019-03-22 20:08:04 +0200 | [diff] [blame] | 4709 | dev->vblank_disable_immediate = true; |
Ville Syrjälä | 21da270 | 2014-08-06 14:49:55 +0300 | [diff] [blame] | 4710 | |
Chris Wilson | 262fd48 | 2017-02-15 13:15:47 +0000 | [diff] [blame] | 4711 | /* Most platforms treat the display irq block as an always-on |
| 4712 | * power domain. vlv/chv can disable it at runtime and need |
| 4713 | * special care to avoid writing any of the display block registers |
| 4714 | * outside of the power domain. We defer setting up the display irqs |
| 4715 | * in this case to the runtime pm. |
| 4716 | */ |
| 4717 | dev_priv->display_irqs_enabled = true; |
| 4718 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 4719 | dev_priv->display_irqs_enabled = false; |
| 4720 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4721 | dev_priv->hotplug.hpd_storm_threshold = HPD_STORM_DEFAULT_THRESHOLD; |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4722 | /* If we have MST support, we want to avoid doing short HPD IRQ storm |
| 4723 | * detection, as short HPD storms will occur as a natural part of |
| 4724 | * sideband messaging with MST. |
| 4725 | * On older platforms however, IRQ storms can occur with both long and |
| 4726 | * short pulses, as seen on some G4x systems. |
| 4727 | */ |
| 4728 | dev_priv->hotplug.hpd_short_storm_enabled = !HAS_DP_MST(dev_priv); |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4729 | |
Daniel Vetter | 1bf6ad6 | 2017-05-09 16:03:28 +0200 | [diff] [blame] | 4730 | dev->driver->get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos; |
Daniel Vetter | f3a5c3f | 2015-02-13 21:03:44 +0100 | [diff] [blame] | 4731 | dev->driver->get_scanout_position = i915_get_crtc_scanoutpos; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4732 | |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4733 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 4734 | dev->driver->irq_handler = cherryview_irq_handler; |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4735 | dev->driver->irq_preinstall = cherryview_irq_reset; |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 4736 | dev->driver->irq_postinstall = cherryview_irq_postinstall; |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4737 | dev->driver->irq_uninstall = cherryview_irq_reset; |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 4738 | dev->driver->enable_vblank = i965_enable_vblank; |
| 4739 | dev->driver->disable_vblank = i965_disable_vblank; |
Ville Syrjälä | 43f328d | 2014-04-09 20:40:52 +0300 | [diff] [blame] | 4740 | dev_priv->display.hpd_irq_setup = i915_hpd_irq_setup; |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4741 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 4742 | dev->driver->irq_handler = valleyview_irq_handler; |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4743 | dev->driver->irq_preinstall = valleyview_irq_reset; |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 4744 | dev->driver->irq_postinstall = valleyview_irq_postinstall; |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4745 | dev->driver->irq_uninstall = valleyview_irq_reset; |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 4746 | dev->driver->enable_vblank = i965_enable_vblank; |
| 4747 | dev->driver->disable_vblank = i965_disable_vblank; |
Egbert Eich | fa00abe | 2013-02-25 12:06:48 -0500 | [diff] [blame] | 4748 | dev_priv->display.hpd_irq_setup = i915_hpd_irq_setup; |
Mika Kuoppala | 51951ae | 2018-02-28 12:11:53 +0200 | [diff] [blame] | 4749 | } else if (INTEL_GEN(dev_priv) >= 11) { |
| 4750 | dev->driver->irq_handler = gen11_irq_handler; |
| 4751 | dev->driver->irq_preinstall = gen11_irq_reset; |
| 4752 | dev->driver->irq_postinstall = gen11_irq_postinstall; |
| 4753 | dev->driver->irq_uninstall = gen11_irq_reset; |
| 4754 | dev->driver->enable_vblank = gen8_enable_vblank; |
| 4755 | dev->driver->disable_vblank = gen8_disable_vblank; |
Dhinakaran Pandiyan | 121e758 | 2018-06-15 17:05:29 -0700 | [diff] [blame] | 4756 | dev_priv->display.hpd_irq_setup = gen11_hpd_irq_setup; |
Pandiyan, Dhinakaran | bca2bf2 | 2017-07-18 11:28:00 -0700 | [diff] [blame] | 4757 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4758 | dev->driver->irq_handler = gen8_irq_handler; |
Daniel Vetter | 723761b | 2014-05-22 17:56:34 +0200 | [diff] [blame] | 4759 | dev->driver->irq_preinstall = gen8_irq_reset; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4760 | dev->driver->irq_postinstall = gen8_irq_postinstall; |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4761 | dev->driver->irq_uninstall = gen8_irq_reset; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 4762 | dev->driver->enable_vblank = gen8_enable_vblank; |
| 4763 | dev->driver->disable_vblank = gen8_disable_vblank; |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4764 | if (IS_GEN9_LP(dev_priv)) |
Shashank Sharma | e0a20ad | 2015-03-27 14:54:14 +0200 | [diff] [blame] | 4765 | dev_priv->display.hpd_irq_setup = bxt_hpd_irq_setup; |
Rodrigo Vivi | c6c30b9 | 2019-03-08 13:43:00 -0800 | [diff] [blame] | 4766 | else if (INTEL_PCH_TYPE(dev_priv) >= PCH_SPT) |
Ville Syrjälä | 6dbf30c | 2015-08-27 23:56:02 +0300 | [diff] [blame] | 4767 | dev_priv->display.hpd_irq_setup = spt_hpd_irq_setup; |
| 4768 | else |
Ville Syrjälä | 3a3b3c7 | 2015-08-27 23:56:06 +0300 | [diff] [blame] | 4769 | dev_priv->display.hpd_irq_setup = ilk_hpd_irq_setup; |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 4770 | } else if (HAS_PCH_SPLIT(dev_priv)) { |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4771 | dev->driver->irq_handler = ironlake_irq_handler; |
Daniel Vetter | 723761b | 2014-05-22 17:56:34 +0200 | [diff] [blame] | 4772 | dev->driver->irq_preinstall = ironlake_irq_reset; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4773 | dev->driver->irq_postinstall = ironlake_irq_postinstall; |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4774 | dev->driver->irq_uninstall = ironlake_irq_reset; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4775 | dev->driver->enable_vblank = ironlake_enable_vblank; |
| 4776 | dev->driver->disable_vblank = ironlake_disable_vblank; |
Ville Syrjälä | 23bb4cb | 2015-08-27 23:56:04 +0300 | [diff] [blame] | 4777 | dev_priv->display.hpd_irq_setup = ilk_hpd_irq_setup; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4778 | } else { |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 4779 | if (IS_GEN(dev_priv, 2)) { |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4780 | dev->driver->irq_preinstall = i8xx_irq_reset; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4781 | dev->driver->irq_postinstall = i8xx_irq_postinstall; |
| 4782 | dev->driver->irq_handler = i8xx_irq_handler; |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4783 | dev->driver->irq_uninstall = i8xx_irq_reset; |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 4784 | dev->driver->enable_vblank = i8xx_enable_vblank; |
| 4785 | dev->driver->disable_vblank = i8xx_disable_vblank; |
Ville Syrjälä | d938da6 | 2019-03-22 20:08:03 +0200 | [diff] [blame] | 4786 | } else if (IS_I945GM(dev_priv)) { |
| 4787 | dev->driver->irq_preinstall = i915_irq_reset; |
| 4788 | dev->driver->irq_postinstall = i915_irq_postinstall; |
| 4789 | dev->driver->irq_uninstall = i915_irq_reset; |
| 4790 | dev->driver->irq_handler = i915_irq_handler; |
| 4791 | dev->driver->enable_vblank = i945gm_enable_vblank; |
| 4792 | dev->driver->disable_vblank = i945gm_disable_vblank; |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 4793 | } else if (IS_GEN(dev_priv, 3)) { |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4794 | dev->driver->irq_preinstall = i915_irq_reset; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4795 | dev->driver->irq_postinstall = i915_irq_postinstall; |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4796 | dev->driver->irq_uninstall = i915_irq_reset; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4797 | dev->driver->irq_handler = i915_irq_handler; |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 4798 | dev->driver->enable_vblank = i8xx_enable_vblank; |
| 4799 | dev->driver->disable_vblank = i8xx_disable_vblank; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4800 | } else { |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4801 | dev->driver->irq_preinstall = i965_irq_reset; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4802 | dev->driver->irq_postinstall = i965_irq_postinstall; |
Ville Syrjälä | 6bcdb1c | 2017-08-18 21:37:04 +0300 | [diff] [blame] | 4803 | dev->driver->irq_uninstall = i965_irq_reset; |
Chris Wilson | a266c7d | 2012-04-24 22:59:44 +0100 | [diff] [blame] | 4804 | dev->driver->irq_handler = i965_irq_handler; |
Chris Wilson | 86e83e3 | 2016-10-07 20:49:52 +0100 | [diff] [blame] | 4805 | dev->driver->enable_vblank = i965_enable_vblank; |
| 4806 | dev->driver->disable_vblank = i965_disable_vblank; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 4807 | } |
Ville Syrjälä | 778eb33 | 2015-01-09 14:21:13 +0200 | [diff] [blame] | 4808 | if (I915_HAS_HOTPLUG(dev_priv)) |
| 4809 | dev_priv->display.hpd_irq_setup = i915_hpd_irq_setup; |
Jesse Barnes | f71d4af | 2011-06-28 13:00:41 -0700 | [diff] [blame] | 4810 | } |
| 4811 | } |
Daniel Vetter | 20afbda | 2012-12-11 14:05:07 +0100 | [diff] [blame] | 4812 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4813 | /** |
Joonas Lahtinen | cefcff8 | 2017-04-28 10:58:39 +0300 | [diff] [blame] | 4814 | * intel_irq_fini - deinitializes IRQ support |
| 4815 | * @i915: i915 device instance |
| 4816 | * |
| 4817 | * This function deinitializes all the IRQ support. |
| 4818 | */ |
| 4819 | void intel_irq_fini(struct drm_i915_private *i915) |
| 4820 | { |
| 4821 | int i; |
| 4822 | |
Ville Syrjälä | d938da6 | 2019-03-22 20:08:03 +0200 | [diff] [blame] | 4823 | if (IS_I945GM(i915)) |
| 4824 | i945gm_vblank_work_fini(i915); |
| 4825 | |
Joonas Lahtinen | cefcff8 | 2017-04-28 10:58:39 +0300 | [diff] [blame] | 4826 | for (i = 0; i < MAX_L3_SLICES; ++i) |
| 4827 | kfree(i915->l3_parity.remap_info[i]); |
| 4828 | } |
| 4829 | |
| 4830 | /** |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4831 | * intel_irq_install - enables the hardware interrupt |
| 4832 | * @dev_priv: i915 device instance |
| 4833 | * |
| 4834 | * This function enables the hardware interrupt handling, but leaves the hotplug |
| 4835 | * handling still disabled. It is called after intel_irq_init(). |
| 4836 | * |
| 4837 | * In the driver load and resume code we need working interrupts in a few places |
| 4838 | * but don't want to deal with the hassle of concurrent probe and hotplug |
| 4839 | * workers. Hence the split into this two-stage approach. |
| 4840 | */ |
Daniel Vetter | 2aeb7d3 | 2014-09-30 10:56:43 +0200 | [diff] [blame] | 4841 | int intel_irq_install(struct drm_i915_private *dev_priv) |
| 4842 | { |
| 4843 | /* |
| 4844 | * We enable some interrupt sources in our postinstall hooks, so mark |
| 4845 | * interrupts as enabled _before_ actually enabling them to avoid |
| 4846 | * special cases in our ordering checks. |
| 4847 | */ |
Sagar Arun Kamble | ad1443f | 2017-10-10 22:30:04 +0100 | [diff] [blame] | 4848 | dev_priv->runtime_pm.irqs_enabled = true; |
Daniel Vetter | 2aeb7d3 | 2014-09-30 10:56:43 +0200 | [diff] [blame] | 4849 | |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4850 | return drm_irq_install(&dev_priv->drm, dev_priv->drm.pdev->irq); |
Daniel Vetter | 2aeb7d3 | 2014-09-30 10:56:43 +0200 | [diff] [blame] | 4851 | } |
| 4852 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4853 | /** |
| 4854 | * intel_irq_uninstall - finilizes all irq handling |
| 4855 | * @dev_priv: i915 device instance |
| 4856 | * |
| 4857 | * This stops interrupt and hotplug handling and unregisters and frees all |
| 4858 | * resources acquired in the init functions. |
| 4859 | */ |
Daniel Vetter | 2aeb7d3 | 2014-09-30 10:56:43 +0200 | [diff] [blame] | 4860 | void intel_irq_uninstall(struct drm_i915_private *dev_priv) |
| 4861 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4862 | drm_irq_uninstall(&dev_priv->drm); |
Daniel Vetter | 2aeb7d3 | 2014-09-30 10:56:43 +0200 | [diff] [blame] | 4863 | intel_hpd_cancel_work(dev_priv); |
Sagar Arun Kamble | ad1443f | 2017-10-10 22:30:04 +0100 | [diff] [blame] | 4864 | dev_priv->runtime_pm.irqs_enabled = false; |
Daniel Vetter | 2aeb7d3 | 2014-09-30 10:56:43 +0200 | [diff] [blame] | 4865 | } |
| 4866 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4867 | /** |
| 4868 | * intel_runtime_pm_disable_interrupts - runtime interrupt disabling |
| 4869 | * @dev_priv: i915 device instance |
| 4870 | * |
| 4871 | * This function is used to disable interrupts at runtime, both in the runtime |
| 4872 | * pm and the system suspend/resume code. |
| 4873 | */ |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4874 | void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv) |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 4875 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4876 | dev_priv->drm.driver->irq_uninstall(&dev_priv->drm); |
Sagar Arun Kamble | ad1443f | 2017-10-10 22:30:04 +0100 | [diff] [blame] | 4877 | dev_priv->runtime_pm.irqs_enabled = false; |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4878 | synchronize_irq(dev_priv->drm.irq); |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 4879 | } |
| 4880 | |
Daniel Vetter | fca52a5 | 2014-09-30 10:56:45 +0200 | [diff] [blame] | 4881 | /** |
| 4882 | * intel_runtime_pm_enable_interrupts - runtime interrupt enabling |
| 4883 | * @dev_priv: i915 device instance |
| 4884 | * |
| 4885 | * This function is used to enable interrupts at runtime, both in the runtime |
| 4886 | * pm and the system suspend/resume code. |
| 4887 | */ |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 4888 | void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv) |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 4889 | { |
Sagar Arun Kamble | ad1443f | 2017-10-10 22:30:04 +0100 | [diff] [blame] | 4890 | dev_priv->runtime_pm.irqs_enabled = true; |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4891 | dev_priv->drm.driver->irq_preinstall(&dev_priv->drm); |
| 4892 | dev_priv->drm.driver->irq_postinstall(&dev_priv->drm); |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 4893 | } |