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 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 29 | #include <linux/sysrq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include "drmP.h" |
| 31 | #include "drm.h" |
| 32 | #include "i915_drm.h" |
| 33 | #include "i915_drv.h" |
Chris Wilson | 1c5d22f | 2009-08-25 11:15:50 +0100 | [diff] [blame] | 34 | #include "i915_trace.h" |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 35 | #include "intel_drv.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #define MAX_NOPID ((u32)~0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 39 | /** |
| 40 | * Interrupts that are always left unmasked. |
| 41 | * |
| 42 | * Since pipe events are edge-triggered from the PIPESTAT register to IIR, |
| 43 | * we leave them always unmasked in IMR and then control enabling them through |
| 44 | * PIPESTAT alone. |
| 45 | */ |
Kristian Høgsberg | 6b95a20 | 2009-11-18 11:25:18 -0500 | [diff] [blame] | 46 | #define I915_INTERRUPT_ENABLE_FIX \ |
| 47 | (I915_ASLE_INTERRUPT | \ |
| 48 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | \ |
| 49 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | \ |
| 50 | I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | \ |
| 51 | I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT | \ |
| 52 | I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT) |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 53 | |
| 54 | /** Interrupts that we mask and unmask at runtime. */ |
| 55 | #define I915_INTERRUPT_ENABLE_VAR (I915_USER_INTERRUPT) |
| 56 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 57 | #define I915_PIPE_VBLANK_STATUS (PIPE_START_VBLANK_INTERRUPT_STATUS |\ |
| 58 | PIPE_VBLANK_INTERRUPT_STATUS) |
| 59 | |
| 60 | #define I915_PIPE_VBLANK_ENABLE (PIPE_START_VBLANK_INTERRUPT_ENABLE |\ |
| 61 | PIPE_VBLANK_INTERRUPT_ENABLE) |
| 62 | |
| 63 | #define DRM_I915_VBLANK_PIPE_ALL (DRM_I915_VBLANK_PIPE_A | \ |
| 64 | DRM_I915_VBLANK_PIPE_B) |
| 65 | |
Matthew Garrett | 8ee1c3d | 2008-08-05 19:37:25 +0100 | [diff] [blame] | 66 | void |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 67 | ironlake_enable_graphics_irq(drm_i915_private_t *dev_priv, u32 mask) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 68 | { |
| 69 | if ((dev_priv->gt_irq_mask_reg & mask) != 0) { |
| 70 | dev_priv->gt_irq_mask_reg &= ~mask; |
| 71 | I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg); |
| 72 | (void) I915_READ(GTIMR); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | static inline void |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 77 | ironlake_disable_graphics_irq(drm_i915_private_t *dev_priv, u32 mask) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 78 | { |
| 79 | if ((dev_priv->gt_irq_mask_reg & mask) != mask) { |
| 80 | dev_priv->gt_irq_mask_reg |= mask; |
| 81 | I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg); |
| 82 | (void) I915_READ(GTIMR); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /* For display hotplug interrupt */ |
| 87 | void |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 88 | ironlake_enable_display_irq(drm_i915_private_t *dev_priv, u32 mask) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 89 | { |
| 90 | if ((dev_priv->irq_mask_reg & mask) != 0) { |
| 91 | dev_priv->irq_mask_reg &= ~mask; |
| 92 | I915_WRITE(DEIMR, dev_priv->irq_mask_reg); |
| 93 | (void) I915_READ(DEIMR); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | static inline void |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 98 | ironlake_disable_display_irq(drm_i915_private_t *dev_priv, u32 mask) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 99 | { |
| 100 | if ((dev_priv->irq_mask_reg & mask) != mask) { |
| 101 | dev_priv->irq_mask_reg |= mask; |
| 102 | I915_WRITE(DEIMR, dev_priv->irq_mask_reg); |
| 103 | (void) I915_READ(DEIMR); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | void |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 108 | i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask) |
| 109 | { |
| 110 | if ((dev_priv->irq_mask_reg & mask) != 0) { |
| 111 | dev_priv->irq_mask_reg &= ~mask; |
| 112 | I915_WRITE(IMR, dev_priv->irq_mask_reg); |
| 113 | (void) I915_READ(IMR); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | static inline void |
| 118 | i915_disable_irq(drm_i915_private_t *dev_priv, u32 mask) |
| 119 | { |
| 120 | if ((dev_priv->irq_mask_reg & mask) != mask) { |
| 121 | dev_priv->irq_mask_reg |= mask; |
| 122 | I915_WRITE(IMR, dev_priv->irq_mask_reg); |
| 123 | (void) I915_READ(IMR); |
| 124 | } |
| 125 | } |
| 126 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 127 | static inline u32 |
| 128 | i915_pipestat(int pipe) |
| 129 | { |
| 130 | if (pipe == 0) |
| 131 | return PIPEASTAT; |
| 132 | if (pipe == 1) |
| 133 | return PIPEBSTAT; |
Andrew Morton | 9c84ba4 | 2008-12-01 13:14:08 -0800 | [diff] [blame] | 134 | BUG(); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | void |
| 138 | i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask) |
| 139 | { |
| 140 | if ((dev_priv->pipestat[pipe] & mask) != mask) { |
| 141 | u32 reg = i915_pipestat(pipe); |
| 142 | |
| 143 | dev_priv->pipestat[pipe] |= mask; |
| 144 | /* Enable the interrupt, clear any pending status */ |
| 145 | I915_WRITE(reg, dev_priv->pipestat[pipe] | (mask >> 16)); |
| 146 | (void) I915_READ(reg); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | void |
| 151 | i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask) |
| 152 | { |
| 153 | if ((dev_priv->pipestat[pipe] & mask) != 0) { |
| 154 | u32 reg = i915_pipestat(pipe); |
| 155 | |
| 156 | dev_priv->pipestat[pipe] &= ~mask; |
| 157 | I915_WRITE(reg, dev_priv->pipestat[pipe]); |
| 158 | (void) I915_READ(reg); |
| 159 | } |
| 160 | } |
| 161 | |
=?utf-8?q?Michel_D=C3=A4nzer?= | a6b54f3 | 2006-10-24 23:37:43 +1000 | [diff] [blame] | 162 | /** |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 163 | * intel_enable_asle - enable ASLE interrupt for OpRegion |
| 164 | */ |
| 165 | void intel_enable_asle (struct drm_device *dev) |
| 166 | { |
| 167 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 168 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 169 | if (IS_IRONLAKE(dev)) |
| 170 | ironlake_enable_display_irq(dev_priv, DE_GSE); |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 171 | else |
| 172 | i915_enable_pipestat(dev_priv, 1, |
| 173 | I915_LEGACY_BLC_EVENT_ENABLE); |
| 174 | } |
| 175 | |
| 176 | /** |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 177 | * i915_pipe_enabled - check if a pipe is enabled |
| 178 | * @dev: DRM device |
| 179 | * @pipe: pipe to check |
| 180 | * |
| 181 | * Reading certain registers when the pipe is disabled can hang the chip. |
| 182 | * Use this routine to make sure the PLL is running and the pipe is active |
| 183 | * before reading such registers if unsure. |
| 184 | */ |
| 185 | static int |
| 186 | i915_pipe_enabled(struct drm_device *dev, int pipe) |
| 187 | { |
| 188 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 189 | unsigned long pipeconf = pipe ? PIPEBCONF : PIPEACONF; |
| 190 | |
| 191 | if (I915_READ(pipeconf) & PIPEACONF_ENABLE) |
| 192 | return 1; |
| 193 | |
| 194 | return 0; |
| 195 | } |
| 196 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 197 | /* Called from drm generic code, passed a 'crtc', which |
| 198 | * we use as a pipe index |
| 199 | */ |
| 200 | u32 i915_get_vblank_counter(struct drm_device *dev, int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 201 | { |
| 202 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 203 | unsigned long high_frame; |
| 204 | unsigned long low_frame; |
| 205 | u32 high1, high2, low, count; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 206 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 207 | high_frame = pipe ? PIPEBFRAMEHIGH : PIPEAFRAMEHIGH; |
| 208 | low_frame = pipe ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL; |
| 209 | |
| 210 | if (!i915_pipe_enabled(dev, pipe)) { |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 211 | DRM_DEBUG_DRIVER("trying to get vblank count for disabled " |
| 212 | "pipe %d\n", pipe); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | /* |
| 217 | * High & low register fields aren't synchronized, so make sure |
| 218 | * we get a low value that's stable across two reads of the high |
| 219 | * register. |
| 220 | */ |
| 221 | do { |
| 222 | high1 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >> |
| 223 | PIPE_FRAME_HIGH_SHIFT); |
| 224 | low = ((I915_READ(low_frame) & PIPE_FRAME_LOW_MASK) >> |
| 225 | PIPE_FRAME_LOW_SHIFT); |
| 226 | high2 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >> |
| 227 | PIPE_FRAME_HIGH_SHIFT); |
| 228 | } while (high1 != high2); |
| 229 | |
| 230 | count = (high1 << 8) | low; |
| 231 | |
| 232 | return count; |
| 233 | } |
| 234 | |
Jesse Barnes | 9880b7a | 2009-02-06 10:22:41 -0800 | [diff] [blame] | 235 | u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe) |
| 236 | { |
| 237 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 238 | int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45; |
| 239 | |
| 240 | if (!i915_pipe_enabled(dev, pipe)) { |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 241 | DRM_DEBUG_DRIVER("trying to get vblank count for disabled " |
| 242 | "pipe %d\n", pipe); |
Jesse Barnes | 9880b7a | 2009-02-06 10:22:41 -0800 | [diff] [blame] | 243 | return 0; |
| 244 | } |
| 245 | |
| 246 | return I915_READ(reg); |
| 247 | } |
| 248 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 249 | /* |
| 250 | * Handle hotplug events outside the interrupt handler proper. |
| 251 | */ |
| 252 | static void i915_hotplug_work_func(struct work_struct *work) |
| 253 | { |
| 254 | drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t, |
| 255 | hotplug_work); |
| 256 | struct drm_device *dev = dev_priv->dev; |
Keith Packard | c31c4ba | 2009-05-06 11:48:58 -0700 | [diff] [blame] | 257 | struct drm_mode_config *mode_config = &dev->mode_config; |
| 258 | struct drm_connector *connector; |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 259 | |
Keith Packard | c31c4ba | 2009-05-06 11:48:58 -0700 | [diff] [blame] | 260 | if (mode_config->num_connector) { |
| 261 | list_for_each_entry(connector, &mode_config->connector_list, head) { |
| 262 | struct intel_output *intel_output = to_intel_output(connector); |
| 263 | |
| 264 | if (intel_output->hot_plug) |
| 265 | (*intel_output->hot_plug) (intel_output); |
| 266 | } |
| 267 | } |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 268 | /* Just fire off a uevent and let userspace tell us what to do */ |
| 269 | drm_sysfs_hotplug_event(dev); |
| 270 | } |
| 271 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 272 | irqreturn_t ironlake_irq_handler(struct drm_device *dev) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 273 | { |
| 274 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 275 | int ret = IRQ_NONE; |
Dave Airlie | 3ff9916 | 2009-12-08 14:03:47 +1000 | [diff] [blame] | 276 | u32 de_iir, gt_iir, de_ier, pch_iir; |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 277 | u32 new_de_iir, new_gt_iir, new_pch_iir; |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 278 | struct drm_i915_master_private *master_priv; |
| 279 | |
Zou, Nanhai | 2d109a8 | 2009-11-06 02:13:01 +0000 | [diff] [blame] | 280 | /* disable master interrupt before clearing iir */ |
| 281 | de_ier = I915_READ(DEIER); |
| 282 | I915_WRITE(DEIER, de_ier & ~DE_MASTER_IRQ_CONTROL); |
| 283 | (void)I915_READ(DEIER); |
| 284 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 285 | de_iir = I915_READ(DEIIR); |
| 286 | gt_iir = I915_READ(GTIIR); |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 287 | pch_iir = I915_READ(SDEIIR); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 288 | |
| 289 | for (;;) { |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 290 | if (de_iir == 0 && gt_iir == 0 && pch_iir == 0) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 291 | break; |
| 292 | |
| 293 | ret = IRQ_HANDLED; |
| 294 | |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 295 | /* should clear PCH hotplug event before clear CPU irq */ |
| 296 | I915_WRITE(SDEIIR, pch_iir); |
| 297 | new_pch_iir = I915_READ(SDEIIR); |
| 298 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 299 | I915_WRITE(DEIIR, de_iir); |
| 300 | new_de_iir = I915_READ(DEIIR); |
| 301 | I915_WRITE(GTIIR, gt_iir); |
| 302 | new_gt_iir = I915_READ(GTIIR); |
| 303 | |
| 304 | if (dev->primary->master) { |
| 305 | master_priv = dev->primary->master->driver_priv; |
| 306 | if (master_priv->sarea_priv) |
| 307 | master_priv->sarea_priv->last_dispatch = |
| 308 | READ_BREADCRUMB(dev_priv); |
| 309 | } |
| 310 | |
| 311 | if (gt_iir & GT_USER_INTERRUPT) { |
Chris Wilson | 1c5d22f | 2009-08-25 11:15:50 +0100 | [diff] [blame] | 312 | u32 seqno = i915_get_gem_seqno(dev); |
| 313 | dev_priv->mm.irq_gem_seqno = seqno; |
| 314 | trace_i915_gem_request_complete(dev, seqno); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 315 | DRM_WAKEUP(&dev_priv->irq_queue); |
Zhenyu Wang | c566ec4 | 2009-12-17 16:12:56 +0800 | [diff] [blame^] | 316 | dev_priv->hangcheck_count = 0; |
| 317 | mod_timer(&dev_priv->hangcheck_timer, jiffies + DRM_I915_HANGCHECK_PERIOD); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 318 | } |
| 319 | |
Zhao Yakui | 01c6688 | 2009-10-28 05:10:00 +0000 | [diff] [blame] | 320 | if (de_iir & DE_GSE) |
| 321 | ironlake_opregion_gse_intr(dev); |
| 322 | |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 323 | /* check event from PCH */ |
| 324 | if ((de_iir & DE_PCH_EVENT) && |
| 325 | (pch_iir & SDE_HOTPLUG_MASK)) { |
| 326 | queue_work(dev_priv->wq, &dev_priv->hotplug_work); |
| 327 | } |
| 328 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 329 | de_iir = new_de_iir; |
| 330 | gt_iir = new_gt_iir; |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 331 | pch_iir = new_pch_iir; |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 332 | } |
| 333 | |
Zou, Nanhai | 2d109a8 | 2009-11-06 02:13:01 +0000 | [diff] [blame] | 334 | I915_WRITE(DEIER, de_ier); |
| 335 | (void)I915_READ(DEIER); |
| 336 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 337 | return ret; |
| 338 | } |
| 339 | |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 340 | /** |
| 341 | * i915_error_work_func - do process context error handling work |
| 342 | * @work: work struct |
| 343 | * |
| 344 | * Fire an error uevent so userspace can see that a hang or error |
| 345 | * was detected. |
| 346 | */ |
| 347 | static void i915_error_work_func(struct work_struct *work) |
| 348 | { |
| 349 | drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t, |
| 350 | error_work); |
| 351 | struct drm_device *dev = dev_priv->dev; |
Ben Gamari | f316a42 | 2009-09-14 17:48:46 -0400 | [diff] [blame] | 352 | char *error_event[] = { "ERROR=1", NULL }; |
| 353 | char *reset_event[] = { "RESET=1", NULL }; |
| 354 | char *reset_done_event[] = { "ERROR=0", NULL }; |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 355 | |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 356 | DRM_DEBUG_DRIVER("generating error event\n"); |
Ben Gamari | f316a42 | 2009-09-14 17:48:46 -0400 | [diff] [blame] | 357 | kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, error_event); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 358 | |
Ben Gamari | ba1234d | 2009-09-14 17:48:47 -0400 | [diff] [blame] | 359 | if (atomic_read(&dev_priv->mm.wedged)) { |
Ben Gamari | f316a42 | 2009-09-14 17:48:46 -0400 | [diff] [blame] | 360 | if (IS_I965G(dev)) { |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 361 | DRM_DEBUG_DRIVER("resetting chip\n"); |
Ben Gamari | f316a42 | 2009-09-14 17:48:46 -0400 | [diff] [blame] | 362 | kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_event); |
| 363 | if (!i965_reset(dev, GDRST_RENDER)) { |
Ben Gamari | ba1234d | 2009-09-14 17:48:47 -0400 | [diff] [blame] | 364 | atomic_set(&dev_priv->mm.wedged, 0); |
Ben Gamari | f316a42 | 2009-09-14 17:48:46 -0400 | [diff] [blame] | 365 | kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_done_event); |
| 366 | } |
| 367 | } else { |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 368 | DRM_DEBUG_DRIVER("reboot required\n"); |
Ben Gamari | f316a42 | 2009-09-14 17:48:46 -0400 | [diff] [blame] | 369 | } |
| 370 | } |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | /** |
| 374 | * i915_capture_error_state - capture an error record for later analysis |
| 375 | * @dev: drm device |
| 376 | * |
| 377 | * Should be called when an error is detected (either a hang or an error |
| 378 | * interrupt) to capture error state from the time of the error. Fills |
| 379 | * out a structure which becomes available in debugfs for user level tools |
| 380 | * to pick up. |
| 381 | */ |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 382 | static void i915_capture_error_state(struct drm_device *dev) |
| 383 | { |
| 384 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 385 | struct drm_i915_error_state *error; |
| 386 | unsigned long flags; |
| 387 | |
| 388 | spin_lock_irqsave(&dev_priv->error_lock, flags); |
| 389 | if (dev_priv->first_error) |
| 390 | goto out; |
| 391 | |
| 392 | error = kmalloc(sizeof(*error), GFP_ATOMIC); |
| 393 | if (!error) { |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 394 | DRM_DEBUG_DRIVER("out ot memory, not capturing error state\n"); |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 395 | goto out; |
| 396 | } |
| 397 | |
| 398 | error->eir = I915_READ(EIR); |
| 399 | error->pgtbl_er = I915_READ(PGTBL_ER); |
| 400 | error->pipeastat = I915_READ(PIPEASTAT); |
| 401 | error->pipebstat = I915_READ(PIPEBSTAT); |
| 402 | error->instpm = I915_READ(INSTPM); |
| 403 | if (!IS_I965G(dev)) { |
| 404 | error->ipeir = I915_READ(IPEIR); |
| 405 | error->ipehr = I915_READ(IPEHR); |
| 406 | error->instdone = I915_READ(INSTDONE); |
| 407 | error->acthd = I915_READ(ACTHD); |
| 408 | } else { |
| 409 | error->ipeir = I915_READ(IPEIR_I965); |
| 410 | error->ipehr = I915_READ(IPEHR_I965); |
| 411 | error->instdone = I915_READ(INSTDONE_I965); |
| 412 | error->instps = I915_READ(INSTPS); |
| 413 | error->instdone1 = I915_READ(INSTDONE1); |
| 414 | error->acthd = I915_READ(ACTHD_I965); |
| 415 | } |
| 416 | |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 417 | do_gettimeofday(&error->time); |
| 418 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 419 | dev_priv->first_error = error; |
| 420 | |
| 421 | out: |
| 422 | spin_unlock_irqrestore(&dev_priv->error_lock, flags); |
| 423 | } |
| 424 | |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 425 | /** |
| 426 | * i915_handle_error - handle an error interrupt |
| 427 | * @dev: drm device |
| 428 | * |
| 429 | * Do some basic checking of regsiter state at error interrupt time and |
| 430 | * dump it to the syslog. Also call i915_capture_error_state() to make |
| 431 | * sure we get a record and make it available in debugfs. Fire a uevent |
| 432 | * so userspace knows something bad happened (should trigger collection |
| 433 | * of a ring dump etc.). |
| 434 | */ |
Ben Gamari | ba1234d | 2009-09-14 17:48:47 -0400 | [diff] [blame] | 435 | static void i915_handle_error(struct drm_device *dev, bool wedged) |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 436 | { |
| 437 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 438 | u32 eir = I915_READ(EIR); |
| 439 | u32 pipea_stats = I915_READ(PIPEASTAT); |
| 440 | u32 pipeb_stats = I915_READ(PIPEBSTAT); |
| 441 | |
| 442 | i915_capture_error_state(dev); |
| 443 | |
| 444 | printk(KERN_ERR "render error detected, EIR: 0x%08x\n", |
| 445 | eir); |
| 446 | |
| 447 | if (IS_G4X(dev)) { |
| 448 | if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) { |
| 449 | u32 ipeir = I915_READ(IPEIR_I965); |
| 450 | |
| 451 | printk(KERN_ERR " IPEIR: 0x%08x\n", |
| 452 | I915_READ(IPEIR_I965)); |
| 453 | printk(KERN_ERR " IPEHR: 0x%08x\n", |
| 454 | I915_READ(IPEHR_I965)); |
| 455 | printk(KERN_ERR " INSTDONE: 0x%08x\n", |
| 456 | I915_READ(INSTDONE_I965)); |
| 457 | printk(KERN_ERR " INSTPS: 0x%08x\n", |
| 458 | I915_READ(INSTPS)); |
| 459 | printk(KERN_ERR " INSTDONE1: 0x%08x\n", |
| 460 | I915_READ(INSTDONE1)); |
| 461 | printk(KERN_ERR " ACTHD: 0x%08x\n", |
| 462 | I915_READ(ACTHD_I965)); |
| 463 | I915_WRITE(IPEIR_I965, ipeir); |
| 464 | (void)I915_READ(IPEIR_I965); |
| 465 | } |
| 466 | if (eir & GM45_ERROR_PAGE_TABLE) { |
| 467 | u32 pgtbl_err = I915_READ(PGTBL_ER); |
| 468 | printk(KERN_ERR "page table error\n"); |
| 469 | printk(KERN_ERR " PGTBL_ER: 0x%08x\n", |
| 470 | pgtbl_err); |
| 471 | I915_WRITE(PGTBL_ER, pgtbl_err); |
| 472 | (void)I915_READ(PGTBL_ER); |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | if (IS_I9XX(dev)) { |
| 477 | if (eir & I915_ERROR_PAGE_TABLE) { |
| 478 | u32 pgtbl_err = I915_READ(PGTBL_ER); |
| 479 | printk(KERN_ERR "page table error\n"); |
| 480 | printk(KERN_ERR " PGTBL_ER: 0x%08x\n", |
| 481 | pgtbl_err); |
| 482 | I915_WRITE(PGTBL_ER, pgtbl_err); |
| 483 | (void)I915_READ(PGTBL_ER); |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | if (eir & I915_ERROR_MEMORY_REFRESH) { |
| 488 | printk(KERN_ERR "memory refresh error\n"); |
| 489 | printk(KERN_ERR "PIPEASTAT: 0x%08x\n", |
| 490 | pipea_stats); |
| 491 | printk(KERN_ERR "PIPEBSTAT: 0x%08x\n", |
| 492 | pipeb_stats); |
| 493 | /* pipestat has already been acked */ |
| 494 | } |
| 495 | if (eir & I915_ERROR_INSTRUCTION) { |
| 496 | printk(KERN_ERR "instruction error\n"); |
| 497 | printk(KERN_ERR " INSTPM: 0x%08x\n", |
| 498 | I915_READ(INSTPM)); |
| 499 | if (!IS_I965G(dev)) { |
| 500 | u32 ipeir = I915_READ(IPEIR); |
| 501 | |
| 502 | printk(KERN_ERR " IPEIR: 0x%08x\n", |
| 503 | I915_READ(IPEIR)); |
| 504 | printk(KERN_ERR " IPEHR: 0x%08x\n", |
| 505 | I915_READ(IPEHR)); |
| 506 | printk(KERN_ERR " INSTDONE: 0x%08x\n", |
| 507 | I915_READ(INSTDONE)); |
| 508 | printk(KERN_ERR " ACTHD: 0x%08x\n", |
| 509 | I915_READ(ACTHD)); |
| 510 | I915_WRITE(IPEIR, ipeir); |
| 511 | (void)I915_READ(IPEIR); |
| 512 | } else { |
| 513 | u32 ipeir = I915_READ(IPEIR_I965); |
| 514 | |
| 515 | printk(KERN_ERR " IPEIR: 0x%08x\n", |
| 516 | I915_READ(IPEIR_I965)); |
| 517 | printk(KERN_ERR " IPEHR: 0x%08x\n", |
| 518 | I915_READ(IPEHR_I965)); |
| 519 | printk(KERN_ERR " INSTDONE: 0x%08x\n", |
| 520 | I915_READ(INSTDONE_I965)); |
| 521 | printk(KERN_ERR " INSTPS: 0x%08x\n", |
| 522 | I915_READ(INSTPS)); |
| 523 | printk(KERN_ERR " INSTDONE1: 0x%08x\n", |
| 524 | I915_READ(INSTDONE1)); |
| 525 | printk(KERN_ERR " ACTHD: 0x%08x\n", |
| 526 | I915_READ(ACTHD_I965)); |
| 527 | I915_WRITE(IPEIR_I965, ipeir); |
| 528 | (void)I915_READ(IPEIR_I965); |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | I915_WRITE(EIR, eir); |
| 533 | (void)I915_READ(EIR); |
| 534 | eir = I915_READ(EIR); |
| 535 | if (eir) { |
| 536 | /* |
| 537 | * some errors might have become stuck, |
| 538 | * mask them. |
| 539 | */ |
| 540 | DRM_ERROR("EIR stuck: 0x%08x, masking\n", eir); |
| 541 | I915_WRITE(EMR, I915_READ(EMR) | eir); |
| 542 | I915_WRITE(IIR, I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT); |
| 543 | } |
| 544 | |
Ben Gamari | ba1234d | 2009-09-14 17:48:47 -0400 | [diff] [blame] | 545 | if (wedged) { |
| 546 | atomic_set(&dev_priv->mm.wedged, 1); |
| 547 | |
Ben Gamari | 11ed50e | 2009-09-14 17:48:45 -0400 | [diff] [blame] | 548 | /* |
| 549 | * Wakeup waiting processes so they don't hang |
| 550 | */ |
Ben Gamari | 11ed50e | 2009-09-14 17:48:45 -0400 | [diff] [blame] | 551 | DRM_WAKEUP(&dev_priv->irq_queue); |
| 552 | } |
| 553 | |
Eric Anholt | 9c9fe1f | 2009-08-03 16:09:16 -0700 | [diff] [blame] | 554 | queue_work(dev_priv->wq, &dev_priv->error_work); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 555 | } |
| 556 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) |
| 558 | { |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 559 | struct drm_device *dev = (struct drm_device *) arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 561 | struct drm_i915_master_private *master_priv; |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 562 | u32 iir, new_iir; |
| 563 | u32 pipea_stats, pipeb_stats; |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 564 | u32 vblank_status; |
| 565 | u32 vblank_enable; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 566 | int vblank = 0; |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 567 | unsigned long irqflags; |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 568 | int irq_received; |
| 569 | int ret = IRQ_NONE; |
Dave Airlie | af6061a | 2008-05-07 12:15:39 +1000 | [diff] [blame] | 570 | |
Eric Anholt | 630681d | 2008-10-06 15:14:12 -0700 | [diff] [blame] | 571 | atomic_inc(&dev_priv->irq_received); |
| 572 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 573 | if (IS_IRONLAKE(dev)) |
| 574 | return ironlake_irq_handler(dev); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 575 | |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 576 | iir = I915_READ(IIR); |
Dave Airlie | af6061a | 2008-05-07 12:15:39 +1000 | [diff] [blame] | 577 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 578 | if (IS_I965G(dev)) { |
| 579 | vblank_status = I915_START_VBLANK_INTERRUPT_STATUS; |
| 580 | vblank_enable = PIPE_START_VBLANK_INTERRUPT_ENABLE; |
| 581 | } else { |
| 582 | vblank_status = I915_VBLANK_INTERRUPT_STATUS; |
| 583 | vblank_enable = I915_VBLANK_INTERRUPT_ENABLE; |
| 584 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 586 | for (;;) { |
| 587 | irq_received = iir != 0; |
| 588 | |
| 589 | /* Can't rely on pipestat interrupt bit in iir as it might |
| 590 | * have been cleared after the pipestat interrupt was received. |
| 591 | * It doesn't set the bit in iir again, but it still produces |
| 592 | * interrupts (for non-MSI). |
| 593 | */ |
| 594 | spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); |
| 595 | pipea_stats = I915_READ(PIPEASTAT); |
| 596 | pipeb_stats = I915_READ(PIPEBSTAT); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 597 | |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 598 | if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT) |
Ben Gamari | ba1234d | 2009-09-14 17:48:47 -0400 | [diff] [blame] | 599 | i915_handle_error(dev, false); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 600 | |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 601 | /* |
| 602 | * Clear the PIPE(A|B)STAT regs before the IIR |
| 603 | */ |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 604 | if (pipea_stats & 0x8000ffff) { |
Shaohua Li | 7662c8b | 2009-06-26 11:23:55 +0800 | [diff] [blame] | 605 | if (pipea_stats & PIPE_FIFO_UNDERRUN_STATUS) |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 606 | DRM_DEBUG_DRIVER("pipe a underrun\n"); |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 607 | I915_WRITE(PIPEASTAT, pipea_stats); |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 608 | irq_received = 1; |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 609 | } |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 610 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 611 | if (pipeb_stats & 0x8000ffff) { |
Shaohua Li | 7662c8b | 2009-06-26 11:23:55 +0800 | [diff] [blame] | 612 | if (pipeb_stats & PIPE_FIFO_UNDERRUN_STATUS) |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 613 | DRM_DEBUG_DRIVER("pipe b underrun\n"); |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 614 | I915_WRITE(PIPEBSTAT, pipeb_stats); |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 615 | irq_received = 1; |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 616 | } |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 617 | spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); |
| 618 | |
| 619 | if (!irq_received) |
| 620 | break; |
| 621 | |
| 622 | ret = IRQ_HANDLED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 624 | /* Consume port. Then clear IIR or we'll miss events */ |
| 625 | if ((I915_HAS_HOTPLUG(dev)) && |
| 626 | (iir & I915_DISPLAY_PORT_INTERRUPT)) { |
| 627 | u32 hotplug_status = I915_READ(PORT_HOTPLUG_STAT); |
| 628 | |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 629 | DRM_DEBUG_DRIVER("hotplug event received, stat 0x%08x\n", |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 630 | hotplug_status); |
| 631 | if (hotplug_status & dev_priv->hotplug_supported_mask) |
Eric Anholt | 9c9fe1f | 2009-08-03 16:09:16 -0700 | [diff] [blame] | 632 | queue_work(dev_priv->wq, |
| 633 | &dev_priv->hotplug_work); |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 634 | |
| 635 | I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status); |
| 636 | I915_READ(PORT_HOTPLUG_STAT); |
| 637 | } |
| 638 | |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 639 | I915_WRITE(IIR, iir); |
| 640 | new_iir = I915_READ(IIR); /* Flush posted writes */ |
Matthew Garrett | 8ee1c3d | 2008-08-05 19:37:25 +0100 | [diff] [blame] | 641 | |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 642 | if (dev->primary->master) { |
| 643 | master_priv = dev->primary->master->driver_priv; |
| 644 | if (master_priv->sarea_priv) |
| 645 | master_priv->sarea_priv->last_dispatch = |
| 646 | READ_BREADCRUMB(dev_priv); |
| 647 | } |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 648 | |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 649 | if (iir & I915_USER_INTERRUPT) { |
Chris Wilson | 1c5d22f | 2009-08-25 11:15:50 +0100 | [diff] [blame] | 650 | u32 seqno = i915_get_gem_seqno(dev); |
| 651 | dev_priv->mm.irq_gem_seqno = seqno; |
| 652 | trace_i915_gem_request_complete(dev, seqno); |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 653 | DRM_WAKEUP(&dev_priv->irq_queue); |
Ben Gamari | f65d942 | 2009-09-14 17:48:44 -0400 | [diff] [blame] | 654 | dev_priv->hangcheck_count = 0; |
| 655 | mod_timer(&dev_priv->hangcheck_timer, jiffies + DRM_I915_HANGCHECK_PERIOD); |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 656 | } |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 657 | |
Kristian Høgsberg | 6b95a20 | 2009-11-18 11:25:18 -0500 | [diff] [blame] | 658 | if (iir & I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT) |
| 659 | intel_prepare_page_flip(dev, 0); |
| 660 | |
| 661 | if (iir & I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT) |
| 662 | intel_prepare_page_flip(dev, 1); |
| 663 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 664 | if (pipea_stats & vblank_status) { |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 665 | vblank++; |
| 666 | drm_handle_vblank(dev, 0); |
Kristian Høgsberg | 6b95a20 | 2009-11-18 11:25:18 -0500 | [diff] [blame] | 667 | intel_finish_page_flip(dev, 0); |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 668 | } |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 669 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 670 | if (pipeb_stats & vblank_status) { |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 671 | vblank++; |
| 672 | drm_handle_vblank(dev, 1); |
Kristian Høgsberg | 6b95a20 | 2009-11-18 11:25:18 -0500 | [diff] [blame] | 673 | intel_finish_page_flip(dev, 1); |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 674 | } |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 675 | |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 676 | if ((pipeb_stats & I915_LEGACY_BLC_EVENT_STATUS) || |
| 677 | (iir & I915_ASLE_INTERRUPT)) |
| 678 | opregion_asle_intr(dev); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 679 | |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 680 | /* With MSI, interrupts are only generated when iir |
| 681 | * transitions from zero to nonzero. If another bit got |
| 682 | * set while we were handling the existing iir bits, then |
| 683 | * we would never get another interrupt. |
| 684 | * |
| 685 | * This is fine on non-MSI as well, as if we hit this path |
| 686 | * we avoid exiting the interrupt handler only to generate |
| 687 | * another one. |
| 688 | * |
| 689 | * Note that for MSI this could cause a stray interrupt report |
| 690 | * if an interrupt landed in the time between writing IIR and |
| 691 | * the posting read. This should be rare enough to never |
| 692 | * trigger the 99% of 100,000 interrupts test for disabling |
| 693 | * stray interrupts. |
| 694 | */ |
| 695 | iir = new_iir; |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 696 | } |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 697 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 698 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | } |
| 700 | |
Dave Airlie | af6061a | 2008-05-07 12:15:39 +1000 | [diff] [blame] | 701 | static int i915_emit_irq(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | { |
| 703 | drm_i915_private_t *dev_priv = dev->dev_private; |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 704 | struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | RING_LOCALS; |
| 706 | |
| 707 | i915_kernel_lost_context(dev); |
| 708 | |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 709 | DRM_DEBUG_DRIVER("\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | |
Kristian Høgsberg | c99b058 | 2008-08-20 11:20:13 -0400 | [diff] [blame] | 711 | dev_priv->counter++; |
Alan Hourihane | c29b669 | 2006-08-12 16:29:24 +1000 | [diff] [blame] | 712 | if (dev_priv->counter > 0x7FFFFFFFUL) |
Kristian Høgsberg | c99b058 | 2008-08-20 11:20:13 -0400 | [diff] [blame] | 713 | dev_priv->counter = 1; |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 714 | if (master_priv->sarea_priv) |
| 715 | master_priv->sarea_priv->last_enqueue = dev_priv->counter; |
Alan Hourihane | c29b669 | 2006-08-12 16:29:24 +1000 | [diff] [blame] | 716 | |
Keith Packard | 0baf823 | 2008-11-08 11:44:14 +1000 | [diff] [blame] | 717 | BEGIN_LP_RING(4); |
Jesse Barnes | 585fb11 | 2008-07-29 11:54:06 -0700 | [diff] [blame] | 718 | OUT_RING(MI_STORE_DWORD_INDEX); |
Keith Packard | 0baf823 | 2008-11-08 11:44:14 +1000 | [diff] [blame] | 719 | OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT); |
Alan Hourihane | c29b669 | 2006-08-12 16:29:24 +1000 | [diff] [blame] | 720 | OUT_RING(dev_priv->counter); |
Jesse Barnes | 585fb11 | 2008-07-29 11:54:06 -0700 | [diff] [blame] | 721 | OUT_RING(MI_USER_INTERRUPT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | ADVANCE_LP_RING(); |
Dave Airlie | bc5f452 | 2007-11-05 12:50:58 +1000 | [diff] [blame] | 723 | |
Alan Hourihane | c29b669 | 2006-08-12 16:29:24 +1000 | [diff] [blame] | 724 | return dev_priv->counter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | } |
| 726 | |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 727 | void i915_user_irq_get(struct drm_device *dev) |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 728 | { |
| 729 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 730 | unsigned long irqflags; |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 731 | |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 732 | spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 733 | if (dev->irq_enabled && (++dev_priv->user_irq_refcount == 1)) { |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 734 | if (IS_IRONLAKE(dev)) |
| 735 | ironlake_enable_graphics_irq(dev_priv, GT_USER_INTERRUPT); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 736 | else |
| 737 | i915_enable_irq(dev_priv, I915_USER_INTERRUPT); |
| 738 | } |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 739 | spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 740 | } |
| 741 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 742 | void i915_user_irq_put(struct drm_device *dev) |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 743 | { |
| 744 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 745 | unsigned long irqflags; |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 746 | |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 747 | spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 748 | BUG_ON(dev->irq_enabled && dev_priv->user_irq_refcount <= 0); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 749 | if (dev->irq_enabled && (--dev_priv->user_irq_refcount == 0)) { |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 750 | if (IS_IRONLAKE(dev)) |
| 751 | ironlake_disable_graphics_irq(dev_priv, GT_USER_INTERRUPT); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 752 | else |
| 753 | i915_disable_irq(dev_priv, I915_USER_INTERRUPT); |
| 754 | } |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 755 | spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 756 | } |
| 757 | |
Chris Wilson | 9d34e5d | 2009-09-24 05:26:06 +0100 | [diff] [blame] | 758 | void i915_trace_irq_get(struct drm_device *dev, u32 seqno) |
| 759 | { |
| 760 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 761 | |
| 762 | if (dev_priv->trace_irq_seqno == 0) |
| 763 | i915_user_irq_get(dev); |
| 764 | |
| 765 | dev_priv->trace_irq_seqno = seqno; |
| 766 | } |
| 767 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 768 | static int i915_wait_irq(struct drm_device * dev, int irq_nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | { |
| 770 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 771 | struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | int ret = 0; |
| 773 | |
Zhao Yakui | 44d98a6 | 2009-10-09 11:39:40 +0800 | [diff] [blame] | 774 | DRM_DEBUG_DRIVER("irq_nr=%d breadcrumb=%d\n", irq_nr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | READ_BREADCRUMB(dev_priv)); |
| 776 | |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 777 | if (READ_BREADCRUMB(dev_priv) >= irq_nr) { |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 778 | if (master_priv->sarea_priv) |
| 779 | master_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | return 0; |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 781 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 782 | |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 783 | if (master_priv->sarea_priv) |
| 784 | master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 786 | i915_user_irq_get(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ, |
| 788 | READ_BREADCRUMB(dev_priv) >= irq_nr); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 789 | i915_user_irq_put(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 791 | if (ret == -EBUSY) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 792 | DRM_ERROR("EBUSY -- rec: %d emitted: %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | READ_BREADCRUMB(dev_priv), (int)dev_priv->counter); |
| 794 | } |
| 795 | |
Dave Airlie | af6061a | 2008-05-07 12:15:39 +1000 | [diff] [blame] | 796 | return ret; |
| 797 | } |
| 798 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | /* Needs the lock as it touches the ring. |
| 800 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 801 | int i915_irq_emit(struct drm_device *dev, void *data, |
| 802 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | drm_i915_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 805 | drm_i915_irq_emit_t *emit = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | int result; |
| 807 | |
Eric Anholt | 07f4f8b | 2009-04-16 13:46:12 -0700 | [diff] [blame] | 808 | if (!dev_priv || !dev_priv->ring.virtual_start) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 809 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 810 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | } |
Eric Anholt | 299eb93 | 2009-02-24 22:14:12 -0800 | [diff] [blame] | 812 | |
| 813 | RING_LOCK_TEST_WITH_RETURN(dev, file_priv); |
| 814 | |
Eric Anholt | 546b097 | 2008-09-01 16:45:29 -0700 | [diff] [blame] | 815 | mutex_lock(&dev->struct_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | result = i915_emit_irq(dev); |
Eric Anholt | 546b097 | 2008-09-01 16:45:29 -0700 | [diff] [blame] | 817 | mutex_unlock(&dev->struct_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 819 | if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | DRM_ERROR("copy_to_user\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 821 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | return 0; |
| 825 | } |
| 826 | |
| 827 | /* Doesn't need the hardware lock. |
| 828 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 829 | int i915_irq_wait(struct drm_device *dev, void *data, |
| 830 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | drm_i915_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 833 | drm_i915_irq_wait_t *irqwait = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | |
| 835 | if (!dev_priv) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 836 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 837 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | } |
| 839 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 840 | return i915_wait_irq(dev, irqwait->irq_seq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | } |
| 842 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 843 | /* Called from drm generic code, passed 'crtc' which |
| 844 | * we use as a pipe index |
| 845 | */ |
| 846 | int i915_enable_vblank(struct drm_device *dev, int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 847 | { |
| 848 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 849 | unsigned long irqflags; |
Jesse Barnes | 71e0ffa | 2009-01-08 10:42:15 -0800 | [diff] [blame] | 850 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; |
| 851 | u32 pipeconf; |
| 852 | |
| 853 | pipeconf = I915_READ(pipeconf_reg); |
| 854 | if (!(pipeconf & PIPEACONF_ENABLE)) |
| 855 | return -EINVAL; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 856 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 857 | if (IS_IRONLAKE(dev)) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 858 | return 0; |
| 859 | |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 860 | spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 861 | if (IS_I965G(dev)) |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 862 | i915_enable_pipestat(dev_priv, pipe, |
| 863 | PIPE_START_VBLANK_INTERRUPT_ENABLE); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 864 | else |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 865 | i915_enable_pipestat(dev_priv, pipe, |
| 866 | PIPE_VBLANK_INTERRUPT_ENABLE); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 867 | spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 868 | return 0; |
| 869 | } |
| 870 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 871 | /* Called from drm generic code, passed 'crtc' which |
| 872 | * we use as a pipe index |
| 873 | */ |
| 874 | void i915_disable_vblank(struct drm_device *dev, int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 875 | { |
| 876 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 877 | unsigned long irqflags; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 878 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 879 | if (IS_IRONLAKE(dev)) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 880 | return; |
| 881 | |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 882 | spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 883 | i915_disable_pipestat(dev_priv, pipe, |
| 884 | PIPE_VBLANK_INTERRUPT_ENABLE | |
| 885 | PIPE_START_VBLANK_INTERRUPT_ENABLE); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 886 | spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 887 | } |
| 888 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 889 | void i915_enable_interrupt (struct drm_device *dev) |
| 890 | { |
| 891 | struct drm_i915_private *dev_priv = dev->dev_private; |
Zhenyu Wang | e170b03 | 2009-06-05 15:38:40 +0800 | [diff] [blame] | 892 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 893 | if (!IS_IRONLAKE(dev)) |
Zhenyu Wang | e170b03 | 2009-06-05 15:38:40 +0800 | [diff] [blame] | 894 | opregion_enable_asle(dev); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 895 | dev_priv->irq_enabled = 1; |
| 896 | } |
| 897 | |
| 898 | |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 899 | /* Set the vblank monitor pipe |
| 900 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 901 | int i915_vblank_pipe_set(struct drm_device *dev, void *data, |
| 902 | struct drm_file *file_priv) |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 903 | { |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 904 | drm_i915_private_t *dev_priv = dev->dev_private; |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 905 | |
| 906 | if (!dev_priv) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 907 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 908 | return -EINVAL; |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 909 | } |
| 910 | |
=?utf-8?q?Michel_D=C3=A4nzer?= | 5b51694 | 2006-10-25 00:08:23 +1000 | [diff] [blame] | 911 | return 0; |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 912 | } |
| 913 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 914 | int i915_vblank_pipe_get(struct drm_device *dev, void *data, |
| 915 | struct drm_file *file_priv) |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 916 | { |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 917 | drm_i915_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 918 | drm_i915_vblank_pipe_t *pipe = data; |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 919 | |
| 920 | if (!dev_priv) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 921 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 922 | return -EINVAL; |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 923 | } |
| 924 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 925 | pipe->pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 926 | |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 927 | return 0; |
| 928 | } |
| 929 | |
=?utf-8?q?Michel_D=C3=A4nzer?= | a6b54f3 | 2006-10-24 23:37:43 +1000 | [diff] [blame] | 930 | /** |
| 931 | * Schedule buffer swap at given vertical blank. |
| 932 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 933 | int i915_vblank_swap(struct drm_device *dev, void *data, |
| 934 | struct drm_file *file_priv) |
=?utf-8?q?Michel_D=C3=A4nzer?= | a6b54f3 | 2006-10-24 23:37:43 +1000 | [diff] [blame] | 935 | { |
Eric Anholt | bd95e0a | 2008-11-04 12:01:24 -0800 | [diff] [blame] | 936 | /* The delayed swap mechanism was fundamentally racy, and has been |
| 937 | * removed. The model was that the client requested a delayed flip/swap |
| 938 | * from the kernel, then waited for vblank before continuing to perform |
| 939 | * rendering. The problem was that the kernel might wake the client |
| 940 | * up before it dispatched the vblank swap (since the lock has to be |
| 941 | * held while touching the ringbuffer), in which case the client would |
| 942 | * clear and start the next frame before the swap occurred, and |
| 943 | * flicker would occur in addition to likely missing the vblank. |
| 944 | * |
| 945 | * In the absence of this ioctl, userland falls back to a correct path |
| 946 | * of waiting for a vblank, then dispatching the swap on its own. |
| 947 | * Context switching to userland and back is plenty fast enough for |
| 948 | * meeting the requirements of vblank swapping. |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 949 | */ |
Eric Anholt | bd95e0a | 2008-11-04 12:01:24 -0800 | [diff] [blame] | 950 | return -EINVAL; |
=?utf-8?q?Michel_D=C3=A4nzer?= | a6b54f3 | 2006-10-24 23:37:43 +1000 | [diff] [blame] | 951 | } |
| 952 | |
Ben Gamari | f65d942 | 2009-09-14 17:48:44 -0400 | [diff] [blame] | 953 | struct drm_i915_gem_request *i915_get_tail_request(struct drm_device *dev) { |
| 954 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 955 | return list_entry(dev_priv->mm.request_list.prev, struct drm_i915_gem_request, list); |
| 956 | } |
| 957 | |
| 958 | /** |
| 959 | * This is called when the chip hasn't reported back with completed |
| 960 | * batchbuffers in a long time. The first time this is called we simply record |
| 961 | * ACTHD. If ACTHD hasn't changed by the time the hangcheck timer elapses |
| 962 | * again, we assume the chip is wedged and try to fix it. |
| 963 | */ |
| 964 | void i915_hangcheck_elapsed(unsigned long data) |
| 965 | { |
| 966 | struct drm_device *dev = (struct drm_device *)data; |
| 967 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 968 | uint32_t acthd; |
| 969 | |
| 970 | if (!IS_I965G(dev)) |
| 971 | acthd = I915_READ(ACTHD); |
| 972 | else |
| 973 | acthd = I915_READ(ACTHD_I965); |
| 974 | |
| 975 | /* If all work is done then ACTHD clearly hasn't advanced. */ |
| 976 | if (list_empty(&dev_priv->mm.request_list) || |
| 977 | i915_seqno_passed(i915_get_gem_seqno(dev), i915_get_tail_request(dev)->seqno)) { |
| 978 | dev_priv->hangcheck_count = 0; |
| 979 | return; |
| 980 | } |
| 981 | |
| 982 | if (dev_priv->last_acthd == acthd && dev_priv->hangcheck_count > 0) { |
| 983 | DRM_ERROR("Hangcheck timer elapsed... GPU hung\n"); |
Ben Gamari | ba1234d | 2009-09-14 17:48:47 -0400 | [diff] [blame] | 984 | i915_handle_error(dev, true); |
Ben Gamari | f65d942 | 2009-09-14 17:48:44 -0400 | [diff] [blame] | 985 | return; |
| 986 | } |
| 987 | |
| 988 | /* Reset timer case chip hangs without another request being added */ |
| 989 | mod_timer(&dev_priv->hangcheck_timer, jiffies + DRM_I915_HANGCHECK_PERIOD); |
| 990 | |
| 991 | if (acthd != dev_priv->last_acthd) |
| 992 | dev_priv->hangcheck_count = 0; |
| 993 | else |
| 994 | dev_priv->hangcheck_count++; |
| 995 | |
| 996 | dev_priv->last_acthd = acthd; |
| 997 | } |
| 998 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | /* drm_dma.h hooks |
| 1000 | */ |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 1001 | static void ironlake_irq_preinstall(struct drm_device *dev) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1002 | { |
| 1003 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 1004 | |
| 1005 | I915_WRITE(HWSTAM, 0xeffe); |
| 1006 | |
| 1007 | /* XXX hotplug from PCH */ |
| 1008 | |
| 1009 | I915_WRITE(DEIMR, 0xffffffff); |
| 1010 | I915_WRITE(DEIER, 0x0); |
| 1011 | (void) I915_READ(DEIER); |
| 1012 | |
| 1013 | /* and GT */ |
| 1014 | I915_WRITE(GTIMR, 0xffffffff); |
| 1015 | I915_WRITE(GTIER, 0x0); |
| 1016 | (void) I915_READ(GTIER); |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 1017 | |
| 1018 | /* south display irq */ |
| 1019 | I915_WRITE(SDEIMR, 0xffffffff); |
| 1020 | I915_WRITE(SDEIER, 0x0); |
| 1021 | (void) I915_READ(SDEIER); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1022 | } |
| 1023 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 1024 | static int ironlake_irq_postinstall(struct drm_device *dev) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1025 | { |
| 1026 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 1027 | /* enable kind of interrupts always enabled */ |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 1028 | u32 display_mask = DE_MASTER_IRQ_CONTROL | DE_GSE | DE_PCH_EVENT; |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1029 | u32 render_mask = GT_USER_INTERRUPT; |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 1030 | u32 hotplug_mask = SDE_CRT_HOTPLUG | SDE_PORTB_HOTPLUG | |
| 1031 | SDE_PORTC_HOTPLUG | SDE_PORTD_HOTPLUG; |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1032 | |
| 1033 | dev_priv->irq_mask_reg = ~display_mask; |
| 1034 | dev_priv->de_irq_enable_reg = display_mask; |
| 1035 | |
| 1036 | /* should always can generate irq */ |
| 1037 | I915_WRITE(DEIIR, I915_READ(DEIIR)); |
| 1038 | I915_WRITE(DEIMR, dev_priv->irq_mask_reg); |
| 1039 | I915_WRITE(DEIER, dev_priv->de_irq_enable_reg); |
| 1040 | (void) I915_READ(DEIER); |
| 1041 | |
| 1042 | /* user interrupt should be enabled, but masked initial */ |
| 1043 | dev_priv->gt_irq_mask_reg = 0xffffffff; |
| 1044 | dev_priv->gt_irq_enable_reg = render_mask; |
| 1045 | |
| 1046 | I915_WRITE(GTIIR, I915_READ(GTIIR)); |
| 1047 | I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg); |
| 1048 | I915_WRITE(GTIER, dev_priv->gt_irq_enable_reg); |
| 1049 | (void) I915_READ(GTIER); |
| 1050 | |
Zhenyu Wang | c650156 | 2009-11-03 18:57:21 +0000 | [diff] [blame] | 1051 | dev_priv->pch_irq_mask_reg = ~hotplug_mask; |
| 1052 | dev_priv->pch_irq_enable_reg = hotplug_mask; |
| 1053 | |
| 1054 | I915_WRITE(SDEIIR, I915_READ(SDEIIR)); |
| 1055 | I915_WRITE(SDEIMR, dev_priv->pch_irq_mask_reg); |
| 1056 | I915_WRITE(SDEIER, dev_priv->pch_irq_enable_reg); |
| 1057 | (void) I915_READ(SDEIER); |
| 1058 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1059 | return 0; |
| 1060 | } |
| 1061 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 1062 | void i915_driver_irq_preinstall(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | { |
| 1064 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 1065 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1066 | atomic_set(&dev_priv->irq_received, 0); |
| 1067 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1068 | INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func); |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 1069 | INIT_WORK(&dev_priv->error_work, i915_error_work_func); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1070 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 1071 | if (IS_IRONLAKE(dev)) { |
| 1072 | ironlake_irq_preinstall(dev); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1073 | return; |
| 1074 | } |
| 1075 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 1076 | if (I915_HAS_HOTPLUG(dev)) { |
| 1077 | I915_WRITE(PORT_HOTPLUG_EN, 0); |
| 1078 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
| 1079 | } |
| 1080 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 1081 | I915_WRITE(HWSTAM, 0xeffe); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 1082 | I915_WRITE(PIPEASTAT, 0); |
| 1083 | I915_WRITE(PIPEBSTAT, 0); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 1084 | I915_WRITE(IMR, 0xffffffff); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 1085 | I915_WRITE(IER, 0x0); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 1086 | (void) I915_READ(IER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1087 | } |
| 1088 | |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 1089 | /* |
| 1090 | * Must be called after intel_modeset_init or hotplug interrupts won't be |
| 1091 | * enabled correctly. |
| 1092 | */ |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 1093 | int i915_driver_irq_postinstall(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1094 | { |
| 1095 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 1096 | u32 enable_mask = I915_INTERRUPT_ENABLE_FIX | I915_INTERRUPT_ENABLE_VAR; |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 1097 | u32 error_mask; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 1098 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1099 | DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); |
| 1100 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 1101 | dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 1102 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 1103 | if (IS_IRONLAKE(dev)) |
| 1104 | return ironlake_irq_postinstall(dev); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1105 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 1106 | /* Unmask the interrupts that we always want on. */ |
| 1107 | dev_priv->irq_mask_reg = ~I915_INTERRUPT_ENABLE_FIX; |
Matthew Garrett | 8ee1c3d | 2008-08-05 19:37:25 +0100 | [diff] [blame] | 1108 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 1109 | dev_priv->pipestat[0] = 0; |
| 1110 | dev_priv->pipestat[1] = 0; |
| 1111 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 1112 | if (I915_HAS_HOTPLUG(dev)) { |
| 1113 | u32 hotplug_en = I915_READ(PORT_HOTPLUG_EN); |
| 1114 | |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 1115 | /* Note HDMI and DP share bits */ |
| 1116 | if (dev_priv->hotplug_supported_mask & HDMIB_HOTPLUG_INT_STATUS) |
| 1117 | hotplug_en |= HDMIB_HOTPLUG_INT_EN; |
| 1118 | if (dev_priv->hotplug_supported_mask & HDMIC_HOTPLUG_INT_STATUS) |
| 1119 | hotplug_en |= HDMIC_HOTPLUG_INT_EN; |
| 1120 | if (dev_priv->hotplug_supported_mask & HDMID_HOTPLUG_INT_STATUS) |
| 1121 | hotplug_en |= HDMID_HOTPLUG_INT_EN; |
| 1122 | if (dev_priv->hotplug_supported_mask & SDVOC_HOTPLUG_INT_STATUS) |
| 1123 | hotplug_en |= SDVOC_HOTPLUG_INT_EN; |
| 1124 | if (dev_priv->hotplug_supported_mask & SDVOB_HOTPLUG_INT_STATUS) |
| 1125 | hotplug_en |= SDVOB_HOTPLUG_INT_EN; |
| 1126 | if (dev_priv->hotplug_supported_mask & CRT_HOTPLUG_INT_STATUS) |
| 1127 | hotplug_en |= CRT_HOTPLUG_INT_EN; |
| 1128 | /* Ignore TV since it's buggy */ |
| 1129 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 1130 | I915_WRITE(PORT_HOTPLUG_EN, hotplug_en); |
| 1131 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 1132 | /* Enable in IER... */ |
| 1133 | enable_mask |= I915_DISPLAY_PORT_INTERRUPT; |
| 1134 | /* and unmask in IMR */ |
| 1135 | i915_enable_irq(dev_priv, I915_DISPLAY_PORT_INTERRUPT); |
| 1136 | } |
| 1137 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 1138 | /* |
| 1139 | * Enable some error detection, note the instruction error mask |
| 1140 | * bit is reserved, so we leave it masked. |
| 1141 | */ |
| 1142 | if (IS_G4X(dev)) { |
| 1143 | error_mask = ~(GM45_ERROR_PAGE_TABLE | |
| 1144 | GM45_ERROR_MEM_PRIV | |
| 1145 | GM45_ERROR_CP_PRIV | |
| 1146 | I915_ERROR_MEMORY_REFRESH); |
| 1147 | } else { |
| 1148 | error_mask = ~(I915_ERROR_PAGE_TABLE | |
| 1149 | I915_ERROR_MEMORY_REFRESH); |
| 1150 | } |
| 1151 | I915_WRITE(EMR, error_mask); |
| 1152 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 1153 | /* Disable pipe interrupt enables, clear pending pipe status */ |
| 1154 | I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff); |
| 1155 | I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff); |
| 1156 | /* Clear pending interrupt status */ |
| 1157 | I915_WRITE(IIR, I915_READ(IIR)); |
| 1158 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 1159 | I915_WRITE(IER, enable_mask); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 1160 | I915_WRITE(IMR, dev_priv->irq_mask_reg); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 1161 | (void) I915_READ(IER); |
| 1162 | |
Matthew Garrett | 8ee1c3d | 2008-08-05 19:37:25 +0100 | [diff] [blame] | 1163 | opregion_enable_asle(dev); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 1164 | |
| 1165 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | } |
| 1167 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 1168 | static void ironlake_irq_uninstall(struct drm_device *dev) |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1169 | { |
| 1170 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 1171 | I915_WRITE(HWSTAM, 0xffffffff); |
| 1172 | |
| 1173 | I915_WRITE(DEIMR, 0xffffffff); |
| 1174 | I915_WRITE(DEIER, 0x0); |
| 1175 | I915_WRITE(DEIIR, I915_READ(DEIIR)); |
| 1176 | |
| 1177 | I915_WRITE(GTIMR, 0xffffffff); |
| 1178 | I915_WRITE(GTIER, 0x0); |
| 1179 | I915_WRITE(GTIIR, I915_READ(GTIIR)); |
| 1180 | } |
| 1181 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 1182 | void i915_driver_irq_uninstall(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | { |
| 1184 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
Dave Airlie | 91e3738 | 2006-02-18 15:17:04 +1100 | [diff] [blame] | 1185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | if (!dev_priv) |
| 1187 | return; |
| 1188 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 1189 | dev_priv->vblank_pipe = 0; |
| 1190 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 1191 | if (IS_IRONLAKE(dev)) { |
| 1192 | ironlake_irq_uninstall(dev); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 1193 | return; |
| 1194 | } |
| 1195 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 1196 | if (I915_HAS_HOTPLUG(dev)) { |
| 1197 | I915_WRITE(PORT_HOTPLUG_EN, 0); |
| 1198 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
| 1199 | } |
| 1200 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 1201 | I915_WRITE(HWSTAM, 0xffffffff); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 1202 | I915_WRITE(PIPEASTAT, 0); |
| 1203 | I915_WRITE(PIPEBSTAT, 0); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 1204 | I915_WRITE(IMR, 0xffffffff); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 1205 | I915_WRITE(IER, 0x0); |
Dave Airlie | 91e3738 | 2006-02-18 15:17:04 +1100 | [diff] [blame] | 1206 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 1207 | I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff); |
| 1208 | I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff); |
| 1209 | I915_WRITE(IIR, I915_READ(IIR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | } |