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" |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 34 | #include "intel_drv.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #define MAX_NOPID ((u32)~0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 38 | /** |
| 39 | * Interrupts that are always left unmasked. |
| 40 | * |
| 41 | * Since pipe events are edge-triggered from the PIPESTAT register to IIR, |
| 42 | * we leave them always unmasked in IMR and then control enabling them through |
| 43 | * PIPESTAT alone. |
| 44 | */ |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 45 | #define I915_INTERRUPT_ENABLE_FIX (I915_ASLE_INTERRUPT | \ |
| 46 | I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | \ |
| 47 | I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | \ |
| 48 | I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT) |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 49 | |
| 50 | /** Interrupts that we mask and unmask at runtime. */ |
| 51 | #define I915_INTERRUPT_ENABLE_VAR (I915_USER_INTERRUPT) |
| 52 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 53 | #define I915_PIPE_VBLANK_STATUS (PIPE_START_VBLANK_INTERRUPT_STATUS |\ |
| 54 | PIPE_VBLANK_INTERRUPT_STATUS) |
| 55 | |
| 56 | #define I915_PIPE_VBLANK_ENABLE (PIPE_START_VBLANK_INTERRUPT_ENABLE |\ |
| 57 | PIPE_VBLANK_INTERRUPT_ENABLE) |
| 58 | |
| 59 | #define DRM_I915_VBLANK_PIPE_ALL (DRM_I915_VBLANK_PIPE_A | \ |
| 60 | DRM_I915_VBLANK_PIPE_B) |
| 61 | |
Matthew Garrett | 8ee1c3d | 2008-08-05 19:37:25 +0100 | [diff] [blame] | 62 | void |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 63 | igdng_enable_graphics_irq(drm_i915_private_t *dev_priv, u32 mask) |
| 64 | { |
| 65 | if ((dev_priv->gt_irq_mask_reg & mask) != 0) { |
| 66 | dev_priv->gt_irq_mask_reg &= ~mask; |
| 67 | I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg); |
| 68 | (void) I915_READ(GTIMR); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | static inline void |
| 73 | igdng_disable_graphics_irq(drm_i915_private_t *dev_priv, u32 mask) |
| 74 | { |
| 75 | if ((dev_priv->gt_irq_mask_reg & mask) != mask) { |
| 76 | dev_priv->gt_irq_mask_reg |= mask; |
| 77 | I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg); |
| 78 | (void) I915_READ(GTIMR); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | /* For display hotplug interrupt */ |
| 83 | void |
| 84 | igdng_enable_display_irq(drm_i915_private_t *dev_priv, u32 mask) |
| 85 | { |
| 86 | if ((dev_priv->irq_mask_reg & mask) != 0) { |
| 87 | dev_priv->irq_mask_reg &= ~mask; |
| 88 | I915_WRITE(DEIMR, dev_priv->irq_mask_reg); |
| 89 | (void) I915_READ(DEIMR); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | static inline void |
| 94 | igdng_disable_display_irq(drm_i915_private_t *dev_priv, u32 mask) |
| 95 | { |
| 96 | if ((dev_priv->irq_mask_reg & mask) != mask) { |
| 97 | dev_priv->irq_mask_reg |= mask; |
| 98 | I915_WRITE(DEIMR, dev_priv->irq_mask_reg); |
| 99 | (void) I915_READ(DEIMR); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | void |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 104 | i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask) |
| 105 | { |
| 106 | if ((dev_priv->irq_mask_reg & mask) != 0) { |
| 107 | dev_priv->irq_mask_reg &= ~mask; |
| 108 | I915_WRITE(IMR, dev_priv->irq_mask_reg); |
| 109 | (void) I915_READ(IMR); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | static inline void |
| 114 | i915_disable_irq(drm_i915_private_t *dev_priv, u32 mask) |
| 115 | { |
| 116 | if ((dev_priv->irq_mask_reg & mask) != mask) { |
| 117 | dev_priv->irq_mask_reg |= mask; |
| 118 | I915_WRITE(IMR, dev_priv->irq_mask_reg); |
| 119 | (void) I915_READ(IMR); |
| 120 | } |
| 121 | } |
| 122 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 123 | static inline u32 |
| 124 | i915_pipestat(int pipe) |
| 125 | { |
| 126 | if (pipe == 0) |
| 127 | return PIPEASTAT; |
| 128 | if (pipe == 1) |
| 129 | return PIPEBSTAT; |
Andrew Morton | 9c84ba4 | 2008-12-01 13:14:08 -0800 | [diff] [blame] | 130 | BUG(); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | void |
| 134 | i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask) |
| 135 | { |
| 136 | if ((dev_priv->pipestat[pipe] & mask) != mask) { |
| 137 | u32 reg = i915_pipestat(pipe); |
| 138 | |
| 139 | dev_priv->pipestat[pipe] |= mask; |
| 140 | /* Enable the interrupt, clear any pending status */ |
| 141 | I915_WRITE(reg, dev_priv->pipestat[pipe] | (mask >> 16)); |
| 142 | (void) I915_READ(reg); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | void |
| 147 | i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask) |
| 148 | { |
| 149 | if ((dev_priv->pipestat[pipe] & mask) != 0) { |
| 150 | u32 reg = i915_pipestat(pipe); |
| 151 | |
| 152 | dev_priv->pipestat[pipe] &= ~mask; |
| 153 | I915_WRITE(reg, dev_priv->pipestat[pipe]); |
| 154 | (void) I915_READ(reg); |
| 155 | } |
| 156 | } |
| 157 | |
=?utf-8?q?Michel_D=C3=A4nzer?= | a6b54f3 | 2006-10-24 23:37:43 +1000 | [diff] [blame] | 158 | /** |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 159 | * i915_pipe_enabled - check if a pipe is enabled |
| 160 | * @dev: DRM device |
| 161 | * @pipe: pipe to check |
| 162 | * |
| 163 | * Reading certain registers when the pipe is disabled can hang the chip. |
| 164 | * Use this routine to make sure the PLL is running and the pipe is active |
| 165 | * before reading such registers if unsure. |
| 166 | */ |
| 167 | static int |
| 168 | i915_pipe_enabled(struct drm_device *dev, int pipe) |
| 169 | { |
| 170 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 171 | unsigned long pipeconf = pipe ? PIPEBCONF : PIPEACONF; |
| 172 | |
| 173 | if (I915_READ(pipeconf) & PIPEACONF_ENABLE) |
| 174 | return 1; |
| 175 | |
| 176 | return 0; |
| 177 | } |
| 178 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 179 | /* Called from drm generic code, passed a 'crtc', which |
| 180 | * we use as a pipe index |
| 181 | */ |
| 182 | u32 i915_get_vblank_counter(struct drm_device *dev, int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 183 | { |
| 184 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 185 | unsigned long high_frame; |
| 186 | unsigned long low_frame; |
| 187 | u32 high1, high2, low, count; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 188 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 189 | high_frame = pipe ? PIPEBFRAMEHIGH : PIPEAFRAMEHIGH; |
| 190 | low_frame = pipe ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL; |
| 191 | |
| 192 | if (!i915_pipe_enabled(dev, pipe)) { |
| 193 | DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe); |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | /* |
| 198 | * High & low register fields aren't synchronized, so make sure |
| 199 | * we get a low value that's stable across two reads of the high |
| 200 | * register. |
| 201 | */ |
| 202 | do { |
| 203 | high1 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >> |
| 204 | PIPE_FRAME_HIGH_SHIFT); |
| 205 | low = ((I915_READ(low_frame) & PIPE_FRAME_LOW_MASK) >> |
| 206 | PIPE_FRAME_LOW_SHIFT); |
| 207 | high2 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >> |
| 208 | PIPE_FRAME_HIGH_SHIFT); |
| 209 | } while (high1 != high2); |
| 210 | |
| 211 | count = (high1 << 8) | low; |
| 212 | |
| 213 | return count; |
| 214 | } |
| 215 | |
Jesse Barnes | 9880b7a | 2009-02-06 10:22:41 -0800 | [diff] [blame] | 216 | u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe) |
| 217 | { |
| 218 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 219 | int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45; |
| 220 | |
| 221 | if (!i915_pipe_enabled(dev, pipe)) { |
| 222 | DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe); |
| 223 | return 0; |
| 224 | } |
| 225 | |
| 226 | return I915_READ(reg); |
| 227 | } |
| 228 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 229 | /* |
| 230 | * Handle hotplug events outside the interrupt handler proper. |
| 231 | */ |
| 232 | static void i915_hotplug_work_func(struct work_struct *work) |
| 233 | { |
| 234 | drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t, |
| 235 | hotplug_work); |
| 236 | struct drm_device *dev = dev_priv->dev; |
Keith Packard | c31c4ba | 2009-05-06 11:48:58 -0700 | [diff] [blame] | 237 | struct drm_mode_config *mode_config = &dev->mode_config; |
| 238 | struct drm_connector *connector; |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 239 | |
Keith Packard | c31c4ba | 2009-05-06 11:48:58 -0700 | [diff] [blame] | 240 | if (mode_config->num_connector) { |
| 241 | list_for_each_entry(connector, &mode_config->connector_list, head) { |
| 242 | struct intel_output *intel_output = to_intel_output(connector); |
| 243 | |
| 244 | if (intel_output->hot_plug) |
| 245 | (*intel_output->hot_plug) (intel_output); |
| 246 | } |
| 247 | } |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 248 | /* Just fire off a uevent and let userspace tell us what to do */ |
| 249 | drm_sysfs_hotplug_event(dev); |
| 250 | } |
| 251 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 252 | irqreturn_t igdng_irq_handler(struct drm_device *dev) |
| 253 | { |
| 254 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 255 | int ret = IRQ_NONE; |
| 256 | u32 de_iir, gt_iir; |
| 257 | u32 new_de_iir, new_gt_iir; |
| 258 | struct drm_i915_master_private *master_priv; |
| 259 | |
| 260 | de_iir = I915_READ(DEIIR); |
| 261 | gt_iir = I915_READ(GTIIR); |
| 262 | |
| 263 | for (;;) { |
| 264 | if (de_iir == 0 && gt_iir == 0) |
| 265 | break; |
| 266 | |
| 267 | ret = IRQ_HANDLED; |
| 268 | |
| 269 | I915_WRITE(DEIIR, de_iir); |
| 270 | new_de_iir = I915_READ(DEIIR); |
| 271 | I915_WRITE(GTIIR, gt_iir); |
| 272 | new_gt_iir = I915_READ(GTIIR); |
| 273 | |
| 274 | if (dev->primary->master) { |
| 275 | master_priv = dev->primary->master->driver_priv; |
| 276 | if (master_priv->sarea_priv) |
| 277 | master_priv->sarea_priv->last_dispatch = |
| 278 | READ_BREADCRUMB(dev_priv); |
| 279 | } |
| 280 | |
| 281 | if (gt_iir & GT_USER_INTERRUPT) { |
| 282 | dev_priv->mm.irq_gem_seqno = i915_get_gem_seqno(dev); |
| 283 | DRM_WAKEUP(&dev_priv->irq_queue); |
| 284 | } |
| 285 | |
| 286 | de_iir = new_de_iir; |
| 287 | gt_iir = new_gt_iir; |
| 288 | } |
| 289 | |
| 290 | return ret; |
| 291 | } |
| 292 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 293 | static void i915_capture_error_state(struct drm_device *dev) |
| 294 | { |
| 295 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 296 | struct drm_i915_error_state *error; |
| 297 | unsigned long flags; |
| 298 | |
| 299 | spin_lock_irqsave(&dev_priv->error_lock, flags); |
| 300 | if (dev_priv->first_error) |
| 301 | goto out; |
| 302 | |
| 303 | error = kmalloc(sizeof(*error), GFP_ATOMIC); |
| 304 | if (!error) { |
| 305 | DRM_DEBUG("out ot memory, not capturing error state\n"); |
| 306 | goto out; |
| 307 | } |
| 308 | |
| 309 | error->eir = I915_READ(EIR); |
| 310 | error->pgtbl_er = I915_READ(PGTBL_ER); |
| 311 | error->pipeastat = I915_READ(PIPEASTAT); |
| 312 | error->pipebstat = I915_READ(PIPEBSTAT); |
| 313 | error->instpm = I915_READ(INSTPM); |
| 314 | if (!IS_I965G(dev)) { |
| 315 | error->ipeir = I915_READ(IPEIR); |
| 316 | error->ipehr = I915_READ(IPEHR); |
| 317 | error->instdone = I915_READ(INSTDONE); |
| 318 | error->acthd = I915_READ(ACTHD); |
| 319 | } else { |
| 320 | error->ipeir = I915_READ(IPEIR_I965); |
| 321 | error->ipehr = I915_READ(IPEHR_I965); |
| 322 | error->instdone = I915_READ(INSTDONE_I965); |
| 323 | error->instps = I915_READ(INSTPS); |
| 324 | error->instdone1 = I915_READ(INSTDONE1); |
| 325 | error->acthd = I915_READ(ACTHD_I965); |
| 326 | } |
| 327 | |
| 328 | dev_priv->first_error = error; |
| 329 | |
| 330 | out: |
| 331 | spin_unlock_irqrestore(&dev_priv->error_lock, flags); |
| 332 | } |
| 333 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) |
| 335 | { |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 336 | struct drm_device *dev = (struct drm_device *) arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | 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] | 338 | struct drm_i915_master_private *master_priv; |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 339 | u32 iir, new_iir; |
| 340 | u32 pipea_stats, pipeb_stats; |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 341 | u32 vblank_status; |
| 342 | u32 vblank_enable; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 343 | int vblank = 0; |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 344 | unsigned long irqflags; |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 345 | int irq_received; |
| 346 | int ret = IRQ_NONE; |
Dave Airlie | af6061a | 2008-05-07 12:15:39 +1000 | [diff] [blame] | 347 | |
Eric Anholt | 630681d | 2008-10-06 15:14:12 -0700 | [diff] [blame] | 348 | atomic_inc(&dev_priv->irq_received); |
| 349 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 350 | if (IS_IGDNG(dev)) |
| 351 | return igdng_irq_handler(dev); |
| 352 | |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 353 | iir = I915_READ(IIR); |
Dave Airlie | af6061a | 2008-05-07 12:15:39 +1000 | [diff] [blame] | 354 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 355 | if (IS_I965G(dev)) { |
| 356 | vblank_status = I915_START_VBLANK_INTERRUPT_STATUS; |
| 357 | vblank_enable = PIPE_START_VBLANK_INTERRUPT_ENABLE; |
| 358 | } else { |
| 359 | vblank_status = I915_VBLANK_INTERRUPT_STATUS; |
| 360 | vblank_enable = I915_VBLANK_INTERRUPT_ENABLE; |
| 361 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 363 | for (;;) { |
| 364 | irq_received = iir != 0; |
| 365 | |
| 366 | /* Can't rely on pipestat interrupt bit in iir as it might |
| 367 | * have been cleared after the pipestat interrupt was received. |
| 368 | * It doesn't set the bit in iir again, but it still produces |
| 369 | * interrupts (for non-MSI). |
| 370 | */ |
| 371 | spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); |
| 372 | pipea_stats = I915_READ(PIPEASTAT); |
| 373 | pipeb_stats = I915_READ(PIPEBSTAT); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 374 | |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 375 | /* |
| 376 | * Clear the PIPE(A|B)STAT regs before the IIR |
| 377 | */ |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 378 | if (pipea_stats & 0x8000ffff) { |
Shaohua Li | 7662c8b | 2009-06-26 11:23:55 +0800 | [diff] [blame^] | 379 | if (pipea_stats & PIPE_FIFO_UNDERRUN_STATUS) |
| 380 | DRM_DEBUG("pipe a underrun\n"); |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 381 | I915_WRITE(PIPEASTAT, pipea_stats); |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 382 | irq_received = 1; |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 383 | } |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 384 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 385 | if (pipeb_stats & 0x8000ffff) { |
Shaohua Li | 7662c8b | 2009-06-26 11:23:55 +0800 | [diff] [blame^] | 386 | if (pipeb_stats & PIPE_FIFO_UNDERRUN_STATUS) |
| 387 | DRM_DEBUG("pipe b underrun\n"); |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 388 | I915_WRITE(PIPEBSTAT, pipeb_stats); |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 389 | irq_received = 1; |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 390 | } |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 391 | spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); |
| 392 | |
| 393 | if (!irq_received) |
| 394 | break; |
| 395 | |
| 396 | ret = IRQ_HANDLED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 398 | /* Consume port. Then clear IIR or we'll miss events */ |
| 399 | if ((I915_HAS_HOTPLUG(dev)) && |
| 400 | (iir & I915_DISPLAY_PORT_INTERRUPT)) { |
| 401 | u32 hotplug_status = I915_READ(PORT_HOTPLUG_STAT); |
| 402 | |
| 403 | DRM_DEBUG("hotplug event received, stat 0x%08x\n", |
| 404 | hotplug_status); |
| 405 | if (hotplug_status & dev_priv->hotplug_supported_mask) |
| 406 | schedule_work(&dev_priv->hotplug_work); |
| 407 | |
| 408 | I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status); |
| 409 | I915_READ(PORT_HOTPLUG_STAT); |
| 410 | } |
| 411 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 412 | if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT) { |
| 413 | u32 eir = I915_READ(EIR); |
| 414 | |
| 415 | i915_capture_error_state(dev); |
| 416 | |
| 417 | printk(KERN_ERR "render error detected, EIR: 0x%08x\n", |
| 418 | eir); |
| 419 | if (eir & I915_ERROR_PAGE_TABLE) { |
| 420 | u32 pgtbl_err = I915_READ(PGTBL_ER); |
| 421 | printk(KERN_ERR "page table error\n"); |
| 422 | printk(KERN_ERR " PGTBL_ER: 0x%08x\n", |
| 423 | pgtbl_err); |
| 424 | I915_WRITE(PGTBL_ER, pgtbl_err); |
| 425 | (void)I915_READ(PGTBL_ER); |
| 426 | } |
| 427 | if (eir & I915_ERROR_MEMORY_REFRESH) { |
| 428 | printk(KERN_ERR "memory refresh error\n"); |
| 429 | printk(KERN_ERR "PIPEASTAT: 0x%08x\n", |
| 430 | pipea_stats); |
| 431 | printk(KERN_ERR "PIPEBSTAT: 0x%08x\n", |
| 432 | pipeb_stats); |
| 433 | /* pipestat has already been acked */ |
| 434 | } |
| 435 | if (eir & I915_ERROR_INSTRUCTION) { |
| 436 | printk(KERN_ERR "instruction error\n"); |
| 437 | printk(KERN_ERR " INSTPM: 0x%08x\n", |
| 438 | I915_READ(INSTPM)); |
| 439 | if (!IS_I965G(dev)) { |
| 440 | u32 ipeir = I915_READ(IPEIR); |
| 441 | |
| 442 | printk(KERN_ERR " IPEIR: 0x%08x\n", |
| 443 | I915_READ(IPEIR)); |
| 444 | printk(KERN_ERR " IPEHR: 0x%08x\n", |
| 445 | I915_READ(IPEHR)); |
| 446 | printk(KERN_ERR " INSTDONE: 0x%08x\n", |
| 447 | I915_READ(INSTDONE)); |
| 448 | printk(KERN_ERR " ACTHD: 0x%08x\n", |
| 449 | I915_READ(ACTHD)); |
| 450 | I915_WRITE(IPEIR, ipeir); |
| 451 | (void)I915_READ(IPEIR); |
| 452 | } else { |
| 453 | u32 ipeir = I915_READ(IPEIR_I965); |
| 454 | |
| 455 | printk(KERN_ERR " IPEIR: 0x%08x\n", |
| 456 | I915_READ(IPEIR_I965)); |
| 457 | printk(KERN_ERR " IPEHR: 0x%08x\n", |
| 458 | I915_READ(IPEHR_I965)); |
| 459 | printk(KERN_ERR " INSTDONE: 0x%08x\n", |
| 460 | I915_READ(INSTDONE_I965)); |
| 461 | printk(KERN_ERR " INSTPS: 0x%08x\n", |
| 462 | I915_READ(INSTPS)); |
| 463 | printk(KERN_ERR " INSTDONE1: 0x%08x\n", |
| 464 | I915_READ(INSTDONE1)); |
| 465 | printk(KERN_ERR " ACTHD: 0x%08x\n", |
| 466 | I915_READ(ACTHD_I965)); |
| 467 | I915_WRITE(IPEIR_I965, ipeir); |
| 468 | (void)I915_READ(IPEIR_I965); |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | I915_WRITE(EIR, eir); |
| 473 | (void)I915_READ(EIR); |
| 474 | eir = I915_READ(EIR); |
| 475 | if (eir) { |
| 476 | /* |
| 477 | * some errors might have become stuck, |
| 478 | * mask them. |
| 479 | */ |
| 480 | DRM_ERROR("EIR stuck: 0x%08x, masking\n", eir); |
| 481 | I915_WRITE(EMR, I915_READ(EMR) | eir); |
| 482 | I915_WRITE(IIR, I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT); |
| 483 | } |
| 484 | } |
| 485 | |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 486 | I915_WRITE(IIR, iir); |
| 487 | new_iir = I915_READ(IIR); /* Flush posted writes */ |
Matthew Garrett | 8ee1c3d | 2008-08-05 19:37:25 +0100 | [diff] [blame] | 488 | |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 489 | if (dev->primary->master) { |
| 490 | master_priv = dev->primary->master->driver_priv; |
| 491 | if (master_priv->sarea_priv) |
| 492 | master_priv->sarea_priv->last_dispatch = |
| 493 | READ_BREADCRUMB(dev_priv); |
| 494 | } |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 495 | |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 496 | if (iir & I915_USER_INTERRUPT) { |
| 497 | dev_priv->mm.irq_gem_seqno = i915_get_gem_seqno(dev); |
| 498 | DRM_WAKEUP(&dev_priv->irq_queue); |
| 499 | } |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 500 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 501 | if (pipea_stats & vblank_status) { |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 502 | vblank++; |
| 503 | drm_handle_vblank(dev, 0); |
| 504 | } |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 505 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 506 | if (pipeb_stats & vblank_status) { |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 507 | vblank++; |
| 508 | drm_handle_vblank(dev, 1); |
| 509 | } |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 510 | |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 511 | if ((pipeb_stats & I915_LEGACY_BLC_EVENT_STATUS) || |
| 512 | (iir & I915_ASLE_INTERRUPT)) |
| 513 | opregion_asle_intr(dev); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 514 | |
Eric Anholt | cdfbc41 | 2008-11-04 15:50:30 -0800 | [diff] [blame] | 515 | /* With MSI, interrupts are only generated when iir |
| 516 | * transitions from zero to nonzero. If another bit got |
| 517 | * set while we were handling the existing iir bits, then |
| 518 | * we would never get another interrupt. |
| 519 | * |
| 520 | * This is fine on non-MSI as well, as if we hit this path |
| 521 | * we avoid exiting the interrupt handler only to generate |
| 522 | * another one. |
| 523 | * |
| 524 | * Note that for MSI this could cause a stray interrupt report |
| 525 | * if an interrupt landed in the time between writing IIR and |
| 526 | * the posting read. This should be rare enough to never |
| 527 | * trigger the 99% of 100,000 interrupts test for disabling |
| 528 | * stray interrupts. |
| 529 | */ |
| 530 | iir = new_iir; |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 531 | } |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 532 | |
Keith Packard | 05eff84 | 2008-11-19 14:03:05 -0800 | [diff] [blame] | 533 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | } |
| 535 | |
Dave Airlie | af6061a | 2008-05-07 12:15:39 +1000 | [diff] [blame] | 536 | static int i915_emit_irq(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | { |
| 538 | drm_i915_private_t *dev_priv = dev->dev_private; |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 539 | struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | RING_LOCALS; |
| 541 | |
| 542 | i915_kernel_lost_context(dev); |
| 543 | |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 544 | DRM_DEBUG("\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | |
Kristian Høgsberg | c99b058 | 2008-08-20 11:20:13 -0400 | [diff] [blame] | 546 | dev_priv->counter++; |
Alan Hourihane | c29b669 | 2006-08-12 16:29:24 +1000 | [diff] [blame] | 547 | if (dev_priv->counter > 0x7FFFFFFFUL) |
Kristian Høgsberg | c99b058 | 2008-08-20 11:20:13 -0400 | [diff] [blame] | 548 | dev_priv->counter = 1; |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 549 | if (master_priv->sarea_priv) |
| 550 | master_priv->sarea_priv->last_enqueue = dev_priv->counter; |
Alan Hourihane | c29b669 | 2006-08-12 16:29:24 +1000 | [diff] [blame] | 551 | |
Keith Packard | 0baf823 | 2008-11-08 11:44:14 +1000 | [diff] [blame] | 552 | BEGIN_LP_RING(4); |
Jesse Barnes | 585fb11 | 2008-07-29 11:54:06 -0700 | [diff] [blame] | 553 | OUT_RING(MI_STORE_DWORD_INDEX); |
Keith Packard | 0baf823 | 2008-11-08 11:44:14 +1000 | [diff] [blame] | 554 | OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT); |
Alan Hourihane | c29b669 | 2006-08-12 16:29:24 +1000 | [diff] [blame] | 555 | OUT_RING(dev_priv->counter); |
Jesse Barnes | 585fb11 | 2008-07-29 11:54:06 -0700 | [diff] [blame] | 556 | OUT_RING(MI_USER_INTERRUPT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | ADVANCE_LP_RING(); |
Dave Airlie | bc5f452 | 2007-11-05 12:50:58 +1000 | [diff] [blame] | 558 | |
Alan Hourihane | c29b669 | 2006-08-12 16:29:24 +1000 | [diff] [blame] | 559 | return dev_priv->counter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 562 | void i915_user_irq_get(struct drm_device *dev) |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 563 | { |
| 564 | 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] | 565 | unsigned long irqflags; |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 566 | |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 567 | spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 568 | if (dev->irq_enabled && (++dev_priv->user_irq_refcount == 1)) { |
| 569 | if (IS_IGDNG(dev)) |
| 570 | igdng_enable_graphics_irq(dev_priv, GT_USER_INTERRUPT); |
| 571 | else |
| 572 | i915_enable_irq(dev_priv, I915_USER_INTERRUPT); |
| 573 | } |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 574 | spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 575 | } |
| 576 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 577 | void i915_user_irq_put(struct drm_device *dev) |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 578 | { |
| 579 | 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] | 580 | unsigned long irqflags; |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 581 | |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 582 | spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 583 | BUG_ON(dev->irq_enabled && dev_priv->user_irq_refcount <= 0); |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 584 | if (dev->irq_enabled && (--dev_priv->user_irq_refcount == 0)) { |
| 585 | if (IS_IGDNG(dev)) |
| 586 | igdng_disable_graphics_irq(dev_priv, GT_USER_INTERRUPT); |
| 587 | else |
| 588 | i915_disable_irq(dev_priv, I915_USER_INTERRUPT); |
| 589 | } |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 590 | spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 591 | } |
| 592 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 593 | static int i915_wait_irq(struct drm_device * dev, int irq_nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | { |
| 595 | 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] | 596 | struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | int ret = 0; |
| 598 | |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 599 | DRM_DEBUG("irq_nr=%d breadcrumb=%d\n", irq_nr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | READ_BREADCRUMB(dev_priv)); |
| 601 | |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 602 | if (READ_BREADCRUMB(dev_priv) >= irq_nr) { |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 603 | if (master_priv->sarea_priv) |
| 604 | master_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | return 0; |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 606 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 608 | if (master_priv->sarea_priv) |
| 609 | master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 611 | i915_user_irq_get(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ, |
| 613 | READ_BREADCRUMB(dev_priv) >= irq_nr); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 614 | i915_user_irq_put(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 616 | if (ret == -EBUSY) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 617 | DRM_ERROR("EBUSY -- rec: %d emitted: %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | READ_BREADCRUMB(dev_priv), (int)dev_priv->counter); |
| 619 | } |
| 620 | |
Dave Airlie | af6061a | 2008-05-07 12:15:39 +1000 | [diff] [blame] | 621 | return ret; |
| 622 | } |
| 623 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | /* Needs the lock as it touches the ring. |
| 625 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 626 | int i915_irq_emit(struct drm_device *dev, void *data, |
| 627 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | drm_i915_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 630 | drm_i915_irq_emit_t *emit = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | int result; |
| 632 | |
Eric Anholt | 07f4f8b | 2009-04-16 13:46:12 -0700 | [diff] [blame] | 633 | if (!dev_priv || !dev_priv->ring.virtual_start) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 634 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 635 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | } |
Eric Anholt | 299eb93 | 2009-02-24 22:14:12 -0800 | [diff] [blame] | 637 | |
| 638 | RING_LOCK_TEST_WITH_RETURN(dev, file_priv); |
| 639 | |
Eric Anholt | 546b097 | 2008-09-01 16:45:29 -0700 | [diff] [blame] | 640 | mutex_lock(&dev->struct_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | result = i915_emit_irq(dev); |
Eric Anholt | 546b097 | 2008-09-01 16:45:29 -0700 | [diff] [blame] | 642 | mutex_unlock(&dev->struct_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 644 | if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | DRM_ERROR("copy_to_user\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 646 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | /* Doesn't need the hardware lock. |
| 653 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 654 | int i915_irq_wait(struct drm_device *dev, void *data, |
| 655 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | drm_i915_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 658 | drm_i915_irq_wait_t *irqwait = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | |
| 660 | if (!dev_priv) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 661 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 662 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | } |
| 664 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 665 | return i915_wait_irq(dev, irqwait->irq_seq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | } |
| 667 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 668 | /* Called from drm generic code, passed 'crtc' which |
| 669 | * we use as a pipe index |
| 670 | */ |
| 671 | int i915_enable_vblank(struct drm_device *dev, int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 672 | { |
| 673 | 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] | 674 | unsigned long irqflags; |
Jesse Barnes | 71e0ffa | 2009-01-08 10:42:15 -0800 | [diff] [blame] | 675 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; |
| 676 | u32 pipeconf; |
| 677 | |
| 678 | pipeconf = I915_READ(pipeconf_reg); |
| 679 | if (!(pipeconf & PIPEACONF_ENABLE)) |
| 680 | return -EINVAL; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 681 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 682 | if (IS_IGDNG(dev)) |
| 683 | return 0; |
| 684 | |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 685 | spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 686 | if (IS_I965G(dev)) |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 687 | i915_enable_pipestat(dev_priv, pipe, |
| 688 | PIPE_START_VBLANK_INTERRUPT_ENABLE); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 689 | else |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 690 | i915_enable_pipestat(dev_priv, pipe, |
| 691 | PIPE_VBLANK_INTERRUPT_ENABLE); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 692 | spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 693 | return 0; |
| 694 | } |
| 695 | |
Keith Packard | 42f52ef | 2008-10-18 19:39:29 -0700 | [diff] [blame] | 696 | /* Called from drm generic code, passed 'crtc' which |
| 697 | * we use as a pipe index |
| 698 | */ |
| 699 | void i915_disable_vblank(struct drm_device *dev, int pipe) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 700 | { |
| 701 | 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] | 702 | unsigned long irqflags; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 703 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 704 | if (IS_IGDNG(dev)) |
| 705 | return; |
| 706 | |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 707 | spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 708 | i915_disable_pipestat(dev_priv, pipe, |
| 709 | PIPE_VBLANK_INTERRUPT_ENABLE | |
| 710 | PIPE_START_VBLANK_INTERRUPT_ENABLE); |
Keith Packard | e9d21d7 | 2008-10-16 11:31:38 -0700 | [diff] [blame] | 711 | spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 712 | } |
| 713 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 714 | void i915_enable_interrupt (struct drm_device *dev) |
| 715 | { |
| 716 | struct drm_i915_private *dev_priv = dev->dev_private; |
Zhenyu Wang | e170b03 | 2009-06-05 15:38:40 +0800 | [diff] [blame] | 717 | |
| 718 | if (!IS_IGDNG(dev)) |
| 719 | opregion_enable_asle(dev); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 720 | dev_priv->irq_enabled = 1; |
| 721 | } |
| 722 | |
| 723 | |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 724 | /* Set the vblank monitor pipe |
| 725 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 726 | int i915_vblank_pipe_set(struct drm_device *dev, void *data, |
| 727 | struct drm_file *file_priv) |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 728 | { |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 729 | drm_i915_private_t *dev_priv = dev->dev_private; |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 730 | |
| 731 | if (!dev_priv) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 732 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 733 | return -EINVAL; |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 734 | } |
| 735 | |
=?utf-8?q?Michel_D=C3=A4nzer?= | 5b51694 | 2006-10-25 00:08:23 +1000 | [diff] [blame] | 736 | return 0; |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 737 | } |
| 738 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 739 | int i915_vblank_pipe_get(struct drm_device *dev, void *data, |
| 740 | struct drm_file *file_priv) |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 741 | { |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 742 | drm_i915_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 743 | drm_i915_vblank_pipe_t *pipe = data; |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 744 | |
| 745 | if (!dev_priv) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 746 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 747 | return -EINVAL; |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 748 | } |
| 749 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 750 | pipe->pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 751 | |
Dave Airlie | 702880f | 2006-06-24 17:07:34 +1000 | [diff] [blame] | 752 | return 0; |
| 753 | } |
| 754 | |
=?utf-8?q?Michel_D=C3=A4nzer?= | a6b54f3 | 2006-10-24 23:37:43 +1000 | [diff] [blame] | 755 | /** |
| 756 | * Schedule buffer swap at given vertical blank. |
| 757 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 758 | int i915_vblank_swap(struct drm_device *dev, void *data, |
| 759 | struct drm_file *file_priv) |
=?utf-8?q?Michel_D=C3=A4nzer?= | a6b54f3 | 2006-10-24 23:37:43 +1000 | [diff] [blame] | 760 | { |
Eric Anholt | bd95e0a | 2008-11-04 12:01:24 -0800 | [diff] [blame] | 761 | /* The delayed swap mechanism was fundamentally racy, and has been |
| 762 | * removed. The model was that the client requested a delayed flip/swap |
| 763 | * from the kernel, then waited for vblank before continuing to perform |
| 764 | * rendering. The problem was that the kernel might wake the client |
| 765 | * up before it dispatched the vblank swap (since the lock has to be |
| 766 | * held while touching the ringbuffer), in which case the client would |
| 767 | * clear and start the next frame before the swap occurred, and |
| 768 | * flicker would occur in addition to likely missing the vblank. |
| 769 | * |
| 770 | * In the absence of this ioctl, userland falls back to a correct path |
| 771 | * of waiting for a vblank, then dispatching the swap on its own. |
| 772 | * Context switching to userland and back is plenty fast enough for |
| 773 | * meeting the requirements of vblank swapping. |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 774 | */ |
Eric Anholt | bd95e0a | 2008-11-04 12:01:24 -0800 | [diff] [blame] | 775 | return -EINVAL; |
=?utf-8?q?Michel_D=C3=A4nzer?= | a6b54f3 | 2006-10-24 23:37:43 +1000 | [diff] [blame] | 776 | } |
| 777 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | /* drm_dma.h hooks |
| 779 | */ |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 780 | static void igdng_irq_preinstall(struct drm_device *dev) |
| 781 | { |
| 782 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 783 | |
| 784 | I915_WRITE(HWSTAM, 0xeffe); |
| 785 | |
| 786 | /* XXX hotplug from PCH */ |
| 787 | |
| 788 | I915_WRITE(DEIMR, 0xffffffff); |
| 789 | I915_WRITE(DEIER, 0x0); |
| 790 | (void) I915_READ(DEIER); |
| 791 | |
| 792 | /* and GT */ |
| 793 | I915_WRITE(GTIMR, 0xffffffff); |
| 794 | I915_WRITE(GTIER, 0x0); |
| 795 | (void) I915_READ(GTIER); |
| 796 | } |
| 797 | |
| 798 | static int igdng_irq_postinstall(struct drm_device *dev) |
| 799 | { |
| 800 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 801 | /* enable kind of interrupts always enabled */ |
| 802 | u32 display_mask = DE_MASTER_IRQ_CONTROL /*| DE_PCH_EVENT */; |
| 803 | u32 render_mask = GT_USER_INTERRUPT; |
| 804 | |
| 805 | dev_priv->irq_mask_reg = ~display_mask; |
| 806 | dev_priv->de_irq_enable_reg = display_mask; |
| 807 | |
| 808 | /* should always can generate irq */ |
| 809 | I915_WRITE(DEIIR, I915_READ(DEIIR)); |
| 810 | I915_WRITE(DEIMR, dev_priv->irq_mask_reg); |
| 811 | I915_WRITE(DEIER, dev_priv->de_irq_enable_reg); |
| 812 | (void) I915_READ(DEIER); |
| 813 | |
| 814 | /* user interrupt should be enabled, but masked initial */ |
| 815 | dev_priv->gt_irq_mask_reg = 0xffffffff; |
| 816 | dev_priv->gt_irq_enable_reg = render_mask; |
| 817 | |
| 818 | I915_WRITE(GTIIR, I915_READ(GTIIR)); |
| 819 | I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg); |
| 820 | I915_WRITE(GTIER, dev_priv->gt_irq_enable_reg); |
| 821 | (void) I915_READ(GTIER); |
| 822 | |
| 823 | return 0; |
| 824 | } |
| 825 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 826 | void i915_driver_irq_preinstall(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | { |
| 828 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 829 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 830 | atomic_set(&dev_priv->irq_received, 0); |
| 831 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 832 | INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func); |
| 833 | |
| 834 | if (IS_IGDNG(dev)) { |
| 835 | igdng_irq_preinstall(dev); |
| 836 | return; |
| 837 | } |
| 838 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 839 | if (I915_HAS_HOTPLUG(dev)) { |
| 840 | I915_WRITE(PORT_HOTPLUG_EN, 0); |
| 841 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
| 842 | } |
| 843 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 844 | I915_WRITE(HWSTAM, 0xeffe); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 845 | I915_WRITE(PIPEASTAT, 0); |
| 846 | I915_WRITE(PIPEBSTAT, 0); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 847 | I915_WRITE(IMR, 0xffffffff); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 848 | I915_WRITE(IER, 0x0); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 849 | (void) I915_READ(IER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | } |
| 851 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 852 | int i915_driver_irq_postinstall(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | { |
| 854 | 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] | 855 | u32 enable_mask = I915_INTERRUPT_ENABLE_FIX | I915_INTERRUPT_ENABLE_VAR; |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 856 | u32 error_mask; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 857 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 858 | DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); |
| 859 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 860 | 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] | 861 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 862 | if (IS_IGDNG(dev)) |
| 863 | return igdng_irq_postinstall(dev); |
| 864 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 865 | /* Unmask the interrupts that we always want on. */ |
| 866 | dev_priv->irq_mask_reg = ~I915_INTERRUPT_ENABLE_FIX; |
Matthew Garrett | 8ee1c3d | 2008-08-05 19:37:25 +0100 | [diff] [blame] | 867 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 868 | dev_priv->pipestat[0] = 0; |
| 869 | dev_priv->pipestat[1] = 0; |
| 870 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 871 | if (I915_HAS_HOTPLUG(dev)) { |
| 872 | u32 hotplug_en = I915_READ(PORT_HOTPLUG_EN); |
| 873 | |
| 874 | /* Leave other bits alone */ |
| 875 | hotplug_en |= HOTPLUG_EN_MASK; |
| 876 | I915_WRITE(PORT_HOTPLUG_EN, hotplug_en); |
| 877 | |
| 878 | dev_priv->hotplug_supported_mask = CRT_HOTPLUG_INT_STATUS | |
| 879 | TV_HOTPLUG_INT_STATUS | SDVOC_HOTPLUG_INT_STATUS | |
| 880 | SDVOB_HOTPLUG_INT_STATUS; |
| 881 | if (IS_G4X(dev)) { |
| 882 | dev_priv->hotplug_supported_mask |= |
| 883 | HDMIB_HOTPLUG_INT_STATUS | |
| 884 | HDMIC_HOTPLUG_INT_STATUS | |
| 885 | HDMID_HOTPLUG_INT_STATUS; |
| 886 | } |
| 887 | /* Enable in IER... */ |
| 888 | enable_mask |= I915_DISPLAY_PORT_INTERRUPT; |
| 889 | /* and unmask in IMR */ |
| 890 | i915_enable_irq(dev_priv, I915_DISPLAY_PORT_INTERRUPT); |
| 891 | } |
| 892 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 893 | /* |
| 894 | * Enable some error detection, note the instruction error mask |
| 895 | * bit is reserved, so we leave it masked. |
| 896 | */ |
| 897 | if (IS_G4X(dev)) { |
| 898 | error_mask = ~(GM45_ERROR_PAGE_TABLE | |
| 899 | GM45_ERROR_MEM_PRIV | |
| 900 | GM45_ERROR_CP_PRIV | |
| 901 | I915_ERROR_MEMORY_REFRESH); |
| 902 | } else { |
| 903 | error_mask = ~(I915_ERROR_PAGE_TABLE | |
| 904 | I915_ERROR_MEMORY_REFRESH); |
| 905 | } |
| 906 | I915_WRITE(EMR, error_mask); |
| 907 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 908 | /* Disable pipe interrupt enables, clear pending pipe status */ |
| 909 | I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff); |
| 910 | I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff); |
| 911 | /* Clear pending interrupt status */ |
| 912 | I915_WRITE(IIR, I915_READ(IIR)); |
| 913 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 914 | I915_WRITE(IER, enable_mask); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 915 | I915_WRITE(IMR, dev_priv->irq_mask_reg); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 916 | (void) I915_READ(IER); |
| 917 | |
Matthew Garrett | 8ee1c3d | 2008-08-05 19:37:25 +0100 | [diff] [blame] | 918 | opregion_enable_asle(dev); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 919 | |
| 920 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | } |
| 922 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 923 | static void igdng_irq_uninstall(struct drm_device *dev) |
| 924 | { |
| 925 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
| 926 | I915_WRITE(HWSTAM, 0xffffffff); |
| 927 | |
| 928 | I915_WRITE(DEIMR, 0xffffffff); |
| 929 | I915_WRITE(DEIER, 0x0); |
| 930 | I915_WRITE(DEIIR, I915_READ(DEIIR)); |
| 931 | |
| 932 | I915_WRITE(GTIMR, 0xffffffff); |
| 933 | I915_WRITE(GTIER, 0x0); |
| 934 | I915_WRITE(GTIIR, I915_READ(GTIIR)); |
| 935 | } |
| 936 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 937 | void i915_driver_irq_uninstall(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | { |
| 939 | 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] | 940 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | if (!dev_priv) |
| 942 | return; |
| 943 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 944 | dev_priv->vblank_pipe = 0; |
| 945 | |
Zhenyu Wang | 036a4a7 | 2009-06-08 14:40:19 +0800 | [diff] [blame] | 946 | if (IS_IGDNG(dev)) { |
| 947 | igdng_irq_uninstall(dev); |
| 948 | return; |
| 949 | } |
| 950 | |
Jesse Barnes | 5ca5828 | 2009-03-31 14:11:15 -0700 | [diff] [blame] | 951 | if (I915_HAS_HOTPLUG(dev)) { |
| 952 | I915_WRITE(PORT_HOTPLUG_EN, 0); |
| 953 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
| 954 | } |
| 955 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 956 | I915_WRITE(HWSTAM, 0xffffffff); |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 957 | I915_WRITE(PIPEASTAT, 0); |
| 958 | I915_WRITE(PIPEBSTAT, 0); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 959 | I915_WRITE(IMR, 0xffffffff); |
Eric Anholt | ed4cb41 | 2008-07-29 12:10:39 -0700 | [diff] [blame] | 960 | I915_WRITE(IER, 0x0); |
Dave Airlie | 91e3738 | 2006-02-18 15:17:04 +1100 | [diff] [blame] | 961 | |
Keith Packard | 7c46358 | 2008-11-04 02:03:27 -0800 | [diff] [blame] | 962 | I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff); |
| 963 | I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff); |
| 964 | I915_WRITE(IIR, I915_READ(IIR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | } |