blob: b86b7b7130c603beca04456ccca0abc4c5bbfbcc [file] [log] [blame]
Dave Airlie0d6aa602006-01-02 20:14:23 +11001/* i915_irq.c -- IRQ support for the I915 -*- linux-c -*-
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 */
Dave Airlie0d6aa602006-01-02 20:14:23 +11003/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
5 * All Rights Reserved.
Dave Airliebc54fd12005-06-23 22:46:46 +10006 *
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 Airlie0d6aa602006-01-02 20:14:23 +110027 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29#include "drmP.h"
30#include "drm.h"
31#include "i915_drm.h"
32#include "i915_drv.h"
Jesse Barnes79e53942008-11-07 14:24:08 -080033#include "intel_drv.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#define MAX_NOPID ((u32)~0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Keith Packard7c463582008-11-04 02:03:27 -080037/**
38 * Interrupts that are always left unmasked.
39 *
40 * Since pipe events are edge-triggered from the PIPESTAT register to IIR,
41 * we leave them always unmasked in IMR and then control enabling them through
42 * PIPESTAT alone.
43 */
44#define I915_INTERRUPT_ENABLE_FIX (I915_ASLE_INTERRUPT | \
45 I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | \
46 I915_DISPLAY_PIPE_B_EVENT_INTERRUPT)
47
48/** Interrupts that we mask and unmask at runtime. */
49#define I915_INTERRUPT_ENABLE_VAR (I915_USER_INTERRUPT)
50
Jesse Barnes79e53942008-11-07 14:24:08 -080051#define I915_PIPE_VBLANK_STATUS (PIPE_START_VBLANK_INTERRUPT_STATUS |\
52 PIPE_VBLANK_INTERRUPT_STATUS)
53
54#define I915_PIPE_VBLANK_ENABLE (PIPE_START_VBLANK_INTERRUPT_ENABLE |\
55 PIPE_VBLANK_INTERRUPT_ENABLE)
56
57#define DRM_I915_VBLANK_PIPE_ALL (DRM_I915_VBLANK_PIPE_A | \
58 DRM_I915_VBLANK_PIPE_B)
59
Matthew Garrett8ee1c3d2008-08-05 19:37:25 +010060void
Zhenyu Wang036a4a72009-06-08 14:40:19 +080061igdng_enable_graphics_irq(drm_i915_private_t *dev_priv, u32 mask)
62{
63 if ((dev_priv->gt_irq_mask_reg & mask) != 0) {
64 dev_priv->gt_irq_mask_reg &= ~mask;
65 I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg);
66 (void) I915_READ(GTIMR);
67 }
68}
69
70static inline void
71igdng_disable_graphics_irq(drm_i915_private_t *dev_priv, u32 mask)
72{
73 if ((dev_priv->gt_irq_mask_reg & mask) != mask) {
74 dev_priv->gt_irq_mask_reg |= mask;
75 I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg);
76 (void) I915_READ(GTIMR);
77 }
78}
79
80/* For display hotplug interrupt */
81void
82igdng_enable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
83{
84 if ((dev_priv->irq_mask_reg & mask) != 0) {
85 dev_priv->irq_mask_reg &= ~mask;
86 I915_WRITE(DEIMR, dev_priv->irq_mask_reg);
87 (void) I915_READ(DEIMR);
88 }
89}
90
91static inline void
92igdng_disable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
93{
94 if ((dev_priv->irq_mask_reg & mask) != mask) {
95 dev_priv->irq_mask_reg |= mask;
96 I915_WRITE(DEIMR, dev_priv->irq_mask_reg);
97 (void) I915_READ(DEIMR);
98 }
99}
100
101void
Eric Anholted4cb412008-07-29 12:10:39 -0700102i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask)
103{
104 if ((dev_priv->irq_mask_reg & mask) != 0) {
105 dev_priv->irq_mask_reg &= ~mask;
106 I915_WRITE(IMR, dev_priv->irq_mask_reg);
107 (void) I915_READ(IMR);
108 }
109}
110
111static inline void
112i915_disable_irq(drm_i915_private_t *dev_priv, u32 mask)
113{
114 if ((dev_priv->irq_mask_reg & mask) != mask) {
115 dev_priv->irq_mask_reg |= mask;
116 I915_WRITE(IMR, dev_priv->irq_mask_reg);
117 (void) I915_READ(IMR);
118 }
119}
120
Keith Packard7c463582008-11-04 02:03:27 -0800121static inline u32
122i915_pipestat(int pipe)
123{
124 if (pipe == 0)
125 return PIPEASTAT;
126 if (pipe == 1)
127 return PIPEBSTAT;
Andrew Morton9c84ba42008-12-01 13:14:08 -0800128 BUG();
Keith Packard7c463582008-11-04 02:03:27 -0800129}
130
131void
132i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask)
133{
134 if ((dev_priv->pipestat[pipe] & mask) != mask) {
135 u32 reg = i915_pipestat(pipe);
136
137 dev_priv->pipestat[pipe] |= mask;
138 /* Enable the interrupt, clear any pending status */
139 I915_WRITE(reg, dev_priv->pipestat[pipe] | (mask >> 16));
140 (void) I915_READ(reg);
141 }
142}
143
144void
145i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask)
146{
147 if ((dev_priv->pipestat[pipe] & mask) != 0) {
148 u32 reg = i915_pipestat(pipe);
149
150 dev_priv->pipestat[pipe] &= ~mask;
151 I915_WRITE(reg, dev_priv->pipestat[pipe]);
152 (void) I915_READ(reg);
153 }
154}
155
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000156/**
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700157 * i915_pipe_enabled - check if a pipe is enabled
158 * @dev: DRM device
159 * @pipe: pipe to check
160 *
161 * Reading certain registers when the pipe is disabled can hang the chip.
162 * Use this routine to make sure the PLL is running and the pipe is active
163 * before reading such registers if unsure.
164 */
165static int
166i915_pipe_enabled(struct drm_device *dev, int pipe)
167{
168 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
169 unsigned long pipeconf = pipe ? PIPEBCONF : PIPEACONF;
170
171 if (I915_READ(pipeconf) & PIPEACONF_ENABLE)
172 return 1;
173
174 return 0;
175}
176
Keith Packard42f52ef2008-10-18 19:39:29 -0700177/* Called from drm generic code, passed a 'crtc', which
178 * we use as a pipe index
179 */
180u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700181{
182 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
183 unsigned long high_frame;
184 unsigned long low_frame;
185 u32 high1, high2, low, count;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700186
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700187 high_frame = pipe ? PIPEBFRAMEHIGH : PIPEAFRAMEHIGH;
188 low_frame = pipe ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL;
189
190 if (!i915_pipe_enabled(dev, pipe)) {
191 DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe);
192 return 0;
193 }
194
195 /*
196 * High & low register fields aren't synchronized, so make sure
197 * we get a low value that's stable across two reads of the high
198 * register.
199 */
200 do {
201 high1 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >>
202 PIPE_FRAME_HIGH_SHIFT);
203 low = ((I915_READ(low_frame) & PIPE_FRAME_LOW_MASK) >>
204 PIPE_FRAME_LOW_SHIFT);
205 high2 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >>
206 PIPE_FRAME_HIGH_SHIFT);
207 } while (high1 != high2);
208
209 count = (high1 << 8) | low;
210
211 return count;
212}
213
Jesse Barnes9880b7a2009-02-06 10:22:41 -0800214u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
215{
216 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
217 int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45;
218
219 if (!i915_pipe_enabled(dev, pipe)) {
220 DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe);
221 return 0;
222 }
223
224 return I915_READ(reg);
225}
226
Jesse Barnes5ca58282009-03-31 14:11:15 -0700227/*
228 * Handle hotplug events outside the interrupt handler proper.
229 */
230static void i915_hotplug_work_func(struct work_struct *work)
231{
232 drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t,
233 hotplug_work);
234 struct drm_device *dev = dev_priv->dev;
235
236 /* Just fire off a uevent and let userspace tell us what to do */
237 drm_sysfs_hotplug_event(dev);
238}
239
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800240irqreturn_t igdng_irq_handler(struct drm_device *dev)
241{
242 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
243 int ret = IRQ_NONE;
244 u32 de_iir, gt_iir;
245 u32 new_de_iir, new_gt_iir;
246 struct drm_i915_master_private *master_priv;
247
248 de_iir = I915_READ(DEIIR);
249 gt_iir = I915_READ(GTIIR);
250
251 for (;;) {
252 if (de_iir == 0 && gt_iir == 0)
253 break;
254
255 ret = IRQ_HANDLED;
256
257 I915_WRITE(DEIIR, de_iir);
258 new_de_iir = I915_READ(DEIIR);
259 I915_WRITE(GTIIR, gt_iir);
260 new_gt_iir = I915_READ(GTIIR);
261
262 if (dev->primary->master) {
263 master_priv = dev->primary->master->driver_priv;
264 if (master_priv->sarea_priv)
265 master_priv->sarea_priv->last_dispatch =
266 READ_BREADCRUMB(dev_priv);
267 }
268
269 if (gt_iir & GT_USER_INTERRUPT) {
270 dev_priv->mm.irq_gem_seqno = i915_get_gem_seqno(dev);
271 DRM_WAKEUP(&dev_priv->irq_queue);
272 }
273
274 de_iir = new_de_iir;
275 gt_iir = new_gt_iir;
276 }
277
278 return ret;
279}
280
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
282{
Dave Airlie84b1fd12007-07-11 15:53:27 +1000283 struct drm_device *dev = (struct drm_device *) arg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Dave Airlie7c1c2872008-11-28 14:22:24 +1000285 struct drm_i915_master_private *master_priv;
Eric Anholtcdfbc412008-11-04 15:50:30 -0800286 u32 iir, new_iir;
287 u32 pipea_stats, pipeb_stats;
Keith Packard05eff842008-11-19 14:03:05 -0800288 u32 vblank_status;
289 u32 vblank_enable;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700290 int vblank = 0;
Keith Packard7c463582008-11-04 02:03:27 -0800291 unsigned long irqflags;
Keith Packard05eff842008-11-19 14:03:05 -0800292 int irq_received;
293 int ret = IRQ_NONE;
Dave Airlieaf6061a2008-05-07 12:15:39 +1000294
Eric Anholt630681d2008-10-06 15:14:12 -0700295 atomic_inc(&dev_priv->irq_received);
296
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800297 if (IS_IGDNG(dev))
298 return igdng_irq_handler(dev);
299
Eric Anholted4cb412008-07-29 12:10:39 -0700300 iir = I915_READ(IIR);
Dave Airlieaf6061a2008-05-07 12:15:39 +1000301
Keith Packard05eff842008-11-19 14:03:05 -0800302 if (IS_I965G(dev)) {
303 vblank_status = I915_START_VBLANK_INTERRUPT_STATUS;
304 vblank_enable = PIPE_START_VBLANK_INTERRUPT_ENABLE;
305 } else {
306 vblank_status = I915_VBLANK_INTERRUPT_STATUS;
307 vblank_enable = I915_VBLANK_INTERRUPT_ENABLE;
308 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
Keith Packard05eff842008-11-19 14:03:05 -0800310 for (;;) {
311 irq_received = iir != 0;
312
313 /* Can't rely on pipestat interrupt bit in iir as it might
314 * have been cleared after the pipestat interrupt was received.
315 * It doesn't set the bit in iir again, but it still produces
316 * interrupts (for non-MSI).
317 */
318 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
319 pipea_stats = I915_READ(PIPEASTAT);
320 pipeb_stats = I915_READ(PIPEBSTAT);
Jesse Barnes79e53942008-11-07 14:24:08 -0800321
Eric Anholtcdfbc412008-11-04 15:50:30 -0800322 /*
323 * Clear the PIPE(A|B)STAT regs before the IIR
324 */
Keith Packard05eff842008-11-19 14:03:05 -0800325 if (pipea_stats & 0x8000ffff) {
Eric Anholtcdfbc412008-11-04 15:50:30 -0800326 I915_WRITE(PIPEASTAT, pipea_stats);
Keith Packard05eff842008-11-19 14:03:05 -0800327 irq_received = 1;
Eric Anholtcdfbc412008-11-04 15:50:30 -0800328 }
Keith Packard7c463582008-11-04 02:03:27 -0800329
Keith Packard05eff842008-11-19 14:03:05 -0800330 if (pipeb_stats & 0x8000ffff) {
Eric Anholtcdfbc412008-11-04 15:50:30 -0800331 I915_WRITE(PIPEBSTAT, pipeb_stats);
Keith Packard05eff842008-11-19 14:03:05 -0800332 irq_received = 1;
Eric Anholtcdfbc412008-11-04 15:50:30 -0800333 }
Keith Packard05eff842008-11-19 14:03:05 -0800334 spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
335
336 if (!irq_received)
337 break;
338
339 ret = IRQ_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
Jesse Barnes5ca58282009-03-31 14:11:15 -0700341 /* Consume port. Then clear IIR or we'll miss events */
342 if ((I915_HAS_HOTPLUG(dev)) &&
343 (iir & I915_DISPLAY_PORT_INTERRUPT)) {
344 u32 hotplug_status = I915_READ(PORT_HOTPLUG_STAT);
345
346 DRM_DEBUG("hotplug event received, stat 0x%08x\n",
347 hotplug_status);
348 if (hotplug_status & dev_priv->hotplug_supported_mask)
349 schedule_work(&dev_priv->hotplug_work);
350
351 I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status);
352 I915_READ(PORT_HOTPLUG_STAT);
353 }
354
Eric Anholtcdfbc412008-11-04 15:50:30 -0800355 I915_WRITE(IIR, iir);
356 new_iir = I915_READ(IIR); /* Flush posted writes */
Matthew Garrett8ee1c3d2008-08-05 19:37:25 +0100357
Dave Airlie7c1c2872008-11-28 14:22:24 +1000358 if (dev->primary->master) {
359 master_priv = dev->primary->master->driver_priv;
360 if (master_priv->sarea_priv)
361 master_priv->sarea_priv->last_dispatch =
362 READ_BREADCRUMB(dev_priv);
363 }
Keith Packard7c463582008-11-04 02:03:27 -0800364
Eric Anholtcdfbc412008-11-04 15:50:30 -0800365 if (iir & I915_USER_INTERRUPT) {
366 dev_priv->mm.irq_gem_seqno = i915_get_gem_seqno(dev);
367 DRM_WAKEUP(&dev_priv->irq_queue);
368 }
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700369
Keith Packard05eff842008-11-19 14:03:05 -0800370 if (pipea_stats & vblank_status) {
Eric Anholtcdfbc412008-11-04 15:50:30 -0800371 vblank++;
372 drm_handle_vblank(dev, 0);
373 }
Eric Anholt673a3942008-07-30 12:06:12 -0700374
Keith Packard05eff842008-11-19 14:03:05 -0800375 if (pipeb_stats & vblank_status) {
Eric Anholtcdfbc412008-11-04 15:50:30 -0800376 vblank++;
377 drm_handle_vblank(dev, 1);
378 }
Keith Packard7c463582008-11-04 02:03:27 -0800379
Eric Anholtcdfbc412008-11-04 15:50:30 -0800380 if ((pipeb_stats & I915_LEGACY_BLC_EVENT_STATUS) ||
381 (iir & I915_ASLE_INTERRUPT))
382 opregion_asle_intr(dev);
Keith Packard7c463582008-11-04 02:03:27 -0800383
Eric Anholtcdfbc412008-11-04 15:50:30 -0800384 /* With MSI, interrupts are only generated when iir
385 * transitions from zero to nonzero. If another bit got
386 * set while we were handling the existing iir bits, then
387 * we would never get another interrupt.
388 *
389 * This is fine on non-MSI as well, as if we hit this path
390 * we avoid exiting the interrupt handler only to generate
391 * another one.
392 *
393 * Note that for MSI this could cause a stray interrupt report
394 * if an interrupt landed in the time between writing IIR and
395 * the posting read. This should be rare enough to never
396 * trigger the 99% of 100,000 interrupts test for disabling
397 * stray interrupts.
398 */
399 iir = new_iir;
Keith Packard05eff842008-11-19 14:03:05 -0800400 }
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700401
Keith Packard05eff842008-11-19 14:03:05 -0800402 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403}
404
Dave Airlieaf6061a2008-05-07 12:15:39 +1000405static int i915_emit_irq(struct drm_device * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406{
407 drm_i915_private_t *dev_priv = dev->dev_private;
Dave Airlie7c1c2872008-11-28 14:22:24 +1000408 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 RING_LOCALS;
410
411 i915_kernel_lost_context(dev);
412
Márton Németh3e684ea2008-01-24 15:58:57 +1000413 DRM_DEBUG("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
Kristian Høgsbergc99b0582008-08-20 11:20:13 -0400415 dev_priv->counter++;
Alan Hourihanec29b6692006-08-12 16:29:24 +1000416 if (dev_priv->counter > 0x7FFFFFFFUL)
Kristian Høgsbergc99b0582008-08-20 11:20:13 -0400417 dev_priv->counter = 1;
Dave Airlie7c1c2872008-11-28 14:22:24 +1000418 if (master_priv->sarea_priv)
419 master_priv->sarea_priv->last_enqueue = dev_priv->counter;
Alan Hourihanec29b6692006-08-12 16:29:24 +1000420
Keith Packard0baf8232008-11-08 11:44:14 +1000421 BEGIN_LP_RING(4);
Jesse Barnes585fb112008-07-29 11:54:06 -0700422 OUT_RING(MI_STORE_DWORD_INDEX);
Keith Packard0baf8232008-11-08 11:44:14 +1000423 OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
Alan Hourihanec29b6692006-08-12 16:29:24 +1000424 OUT_RING(dev_priv->counter);
Jesse Barnes585fb112008-07-29 11:54:06 -0700425 OUT_RING(MI_USER_INTERRUPT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 ADVANCE_LP_RING();
Dave Airliebc5f4522007-11-05 12:50:58 +1000427
Alan Hourihanec29b6692006-08-12 16:29:24 +1000428 return dev_priv->counter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429}
430
Eric Anholt673a3942008-07-30 12:06:12 -0700431void i915_user_irq_get(struct drm_device *dev)
Eric Anholted4cb412008-07-29 12:10:39 -0700432{
433 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Keith Packarde9d21d72008-10-16 11:31:38 -0700434 unsigned long irqflags;
Eric Anholted4cb412008-07-29 12:10:39 -0700435
Keith Packarde9d21d72008-10-16 11:31:38 -0700436 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800437 if (dev->irq_enabled && (++dev_priv->user_irq_refcount == 1)) {
438 if (IS_IGDNG(dev))
439 igdng_enable_graphics_irq(dev_priv, GT_USER_INTERRUPT);
440 else
441 i915_enable_irq(dev_priv, I915_USER_INTERRUPT);
442 }
Keith Packarde9d21d72008-10-16 11:31:38 -0700443 spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
Eric Anholted4cb412008-07-29 12:10:39 -0700444}
445
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700446void i915_user_irq_put(struct drm_device *dev)
Eric Anholted4cb412008-07-29 12:10:39 -0700447{
448 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Keith Packarde9d21d72008-10-16 11:31:38 -0700449 unsigned long irqflags;
Eric Anholted4cb412008-07-29 12:10:39 -0700450
Keith Packarde9d21d72008-10-16 11:31:38 -0700451 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
Eric Anholted4cb412008-07-29 12:10:39 -0700452 BUG_ON(dev->irq_enabled && dev_priv->user_irq_refcount <= 0);
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800453 if (dev->irq_enabled && (--dev_priv->user_irq_refcount == 0)) {
454 if (IS_IGDNG(dev))
455 igdng_disable_graphics_irq(dev_priv, GT_USER_INTERRUPT);
456 else
457 i915_disable_irq(dev_priv, I915_USER_INTERRUPT);
458 }
Keith Packarde9d21d72008-10-16 11:31:38 -0700459 spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
Eric Anholted4cb412008-07-29 12:10:39 -0700460}
461
Dave Airlie84b1fd12007-07-11 15:53:27 +1000462static int i915_wait_irq(struct drm_device * dev, int irq_nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463{
464 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Dave Airlie7c1c2872008-11-28 14:22:24 +1000465 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 int ret = 0;
467
Márton Németh3e684ea2008-01-24 15:58:57 +1000468 DRM_DEBUG("irq_nr=%d breadcrumb=%d\n", irq_nr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 READ_BREADCRUMB(dev_priv));
470
Eric Anholted4cb412008-07-29 12:10:39 -0700471 if (READ_BREADCRUMB(dev_priv) >= irq_nr) {
Dave Airlie7c1c2872008-11-28 14:22:24 +1000472 if (master_priv->sarea_priv)
473 master_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 return 0;
Eric Anholted4cb412008-07-29 12:10:39 -0700475 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476
Dave Airlie7c1c2872008-11-28 14:22:24 +1000477 if (master_priv->sarea_priv)
478 master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Eric Anholted4cb412008-07-29 12:10:39 -0700480 i915_user_irq_get(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ,
482 READ_BREADCRUMB(dev_priv) >= irq_nr);
Eric Anholted4cb412008-07-29 12:10:39 -0700483 i915_user_irq_put(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484
Eric Anholt20caafa2007-08-25 19:22:43 +1000485 if (ret == -EBUSY) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000486 DRM_ERROR("EBUSY -- rec: %d emitted: %d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 READ_BREADCRUMB(dev_priv), (int)dev_priv->counter);
488 }
489
Dave Airlieaf6061a2008-05-07 12:15:39 +1000490 return ret;
491}
492
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493/* Needs the lock as it touches the ring.
494 */
Eric Anholtc153f452007-09-03 12:06:45 +1000495int i915_irq_emit(struct drm_device *dev, void *data,
496 struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 drm_i915_private_t *dev_priv = dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000499 drm_i915_irq_emit_t *emit = data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 int result;
501
Eric Anholt07f4f8b2009-04-16 13:46:12 -0700502 if (!dev_priv || !dev_priv->ring.virtual_start) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000503 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000504 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 }
Eric Anholt299eb932009-02-24 22:14:12 -0800506
507 RING_LOCK_TEST_WITH_RETURN(dev, file_priv);
508
Eric Anholt546b0972008-09-01 16:45:29 -0700509 mutex_lock(&dev->struct_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 result = i915_emit_irq(dev);
Eric Anholt546b0972008-09-01 16:45:29 -0700511 mutex_unlock(&dev->struct_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512
Eric Anholtc153f452007-09-03 12:06:45 +1000513 if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 DRM_ERROR("copy_to_user\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000515 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 }
517
518 return 0;
519}
520
521/* Doesn't need the hardware lock.
522 */
Eric Anholtc153f452007-09-03 12:06:45 +1000523int i915_irq_wait(struct drm_device *dev, void *data,
524 struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 drm_i915_private_t *dev_priv = dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000527 drm_i915_irq_wait_t *irqwait = data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528
529 if (!dev_priv) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000530 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000531 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 }
533
Eric Anholtc153f452007-09-03 12:06:45 +1000534 return i915_wait_irq(dev, irqwait->irq_seq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535}
536
Keith Packard42f52ef2008-10-18 19:39:29 -0700537/* Called from drm generic code, passed 'crtc' which
538 * we use as a pipe index
539 */
540int i915_enable_vblank(struct drm_device *dev, int pipe)
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700541{
542 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Keith Packarde9d21d72008-10-16 11:31:38 -0700543 unsigned long irqflags;
Jesse Barnes71e0ffa2009-01-08 10:42:15 -0800544 int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
545 u32 pipeconf;
546
547 pipeconf = I915_READ(pipeconf_reg);
548 if (!(pipeconf & PIPEACONF_ENABLE))
549 return -EINVAL;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700550
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800551 if (IS_IGDNG(dev))
552 return 0;
553
Keith Packarde9d21d72008-10-16 11:31:38 -0700554 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
Keith Packarde9d21d72008-10-16 11:31:38 -0700555 if (IS_I965G(dev))
Keith Packard7c463582008-11-04 02:03:27 -0800556 i915_enable_pipestat(dev_priv, pipe,
557 PIPE_START_VBLANK_INTERRUPT_ENABLE);
Keith Packarde9d21d72008-10-16 11:31:38 -0700558 else
Keith Packard7c463582008-11-04 02:03:27 -0800559 i915_enable_pipestat(dev_priv, pipe,
560 PIPE_VBLANK_INTERRUPT_ENABLE);
Keith Packarde9d21d72008-10-16 11:31:38 -0700561 spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700562 return 0;
563}
564
Keith Packard42f52ef2008-10-18 19:39:29 -0700565/* Called from drm generic code, passed 'crtc' which
566 * we use as a pipe index
567 */
568void i915_disable_vblank(struct drm_device *dev, int pipe)
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700569{
570 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Keith Packarde9d21d72008-10-16 11:31:38 -0700571 unsigned long irqflags;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700572
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800573 if (IS_IGDNG(dev))
574 return;
575
Keith Packarde9d21d72008-10-16 11:31:38 -0700576 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
Keith Packard7c463582008-11-04 02:03:27 -0800577 i915_disable_pipestat(dev_priv, pipe,
578 PIPE_VBLANK_INTERRUPT_ENABLE |
579 PIPE_START_VBLANK_INTERRUPT_ENABLE);
Keith Packarde9d21d72008-10-16 11:31:38 -0700580 spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700581}
582
Jesse Barnes79e53942008-11-07 14:24:08 -0800583void i915_enable_interrupt (struct drm_device *dev)
584{
585 struct drm_i915_private *dev_priv = dev->dev_private;
Zhenyu Wange170b032009-06-05 15:38:40 +0800586
587 if (!IS_IGDNG(dev))
588 opregion_enable_asle(dev);
Jesse Barnes79e53942008-11-07 14:24:08 -0800589 dev_priv->irq_enabled = 1;
590}
591
592
Dave Airlie702880f2006-06-24 17:07:34 +1000593/* Set the vblank monitor pipe
594 */
Eric Anholtc153f452007-09-03 12:06:45 +1000595int i915_vblank_pipe_set(struct drm_device *dev, void *data,
596 struct drm_file *file_priv)
Dave Airlie702880f2006-06-24 17:07:34 +1000597{
Dave Airlie702880f2006-06-24 17:07:34 +1000598 drm_i915_private_t *dev_priv = dev->dev_private;
Dave Airlie702880f2006-06-24 17:07:34 +1000599
600 if (!dev_priv) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000601 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000602 return -EINVAL;
Dave Airlie702880f2006-06-24 17:07:34 +1000603 }
604
=?utf-8?q?Michel_D=C3=A4nzer?=5b516942006-10-25 00:08:23 +1000605 return 0;
Dave Airlie702880f2006-06-24 17:07:34 +1000606}
607
Eric Anholtc153f452007-09-03 12:06:45 +1000608int i915_vblank_pipe_get(struct drm_device *dev, void *data,
609 struct drm_file *file_priv)
Dave Airlie702880f2006-06-24 17:07:34 +1000610{
Dave Airlie702880f2006-06-24 17:07:34 +1000611 drm_i915_private_t *dev_priv = dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000612 drm_i915_vblank_pipe_t *pipe = data;
Dave Airlie702880f2006-06-24 17:07:34 +1000613
614 if (!dev_priv) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000615 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000616 return -EINVAL;
Dave Airlie702880f2006-06-24 17:07:34 +1000617 }
618
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700619 pipe->pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B;
Eric Anholtc153f452007-09-03 12:06:45 +1000620
Dave Airlie702880f2006-06-24 17:07:34 +1000621 return 0;
622}
623
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000624/**
625 * Schedule buffer swap at given vertical blank.
626 */
Eric Anholtc153f452007-09-03 12:06:45 +1000627int i915_vblank_swap(struct drm_device *dev, void *data,
628 struct drm_file *file_priv)
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000629{
Eric Anholtbd95e0a2008-11-04 12:01:24 -0800630 /* The delayed swap mechanism was fundamentally racy, and has been
631 * removed. The model was that the client requested a delayed flip/swap
632 * from the kernel, then waited for vblank before continuing to perform
633 * rendering. The problem was that the kernel might wake the client
634 * up before it dispatched the vblank swap (since the lock has to be
635 * held while touching the ringbuffer), in which case the client would
636 * clear and start the next frame before the swap occurred, and
637 * flicker would occur in addition to likely missing the vblank.
638 *
639 * In the absence of this ioctl, userland falls back to a correct path
640 * of waiting for a vblank, then dispatching the swap on its own.
641 * Context switching to userland and back is plenty fast enough for
642 * meeting the requirements of vblank swapping.
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700643 */
Eric Anholtbd95e0a2008-11-04 12:01:24 -0800644 return -EINVAL;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000645}
646
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647/* drm_dma.h hooks
648*/
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800649static void igdng_irq_preinstall(struct drm_device *dev)
650{
651 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
652
653 I915_WRITE(HWSTAM, 0xeffe);
654
655 /* XXX hotplug from PCH */
656
657 I915_WRITE(DEIMR, 0xffffffff);
658 I915_WRITE(DEIER, 0x0);
659 (void) I915_READ(DEIER);
660
661 /* and GT */
662 I915_WRITE(GTIMR, 0xffffffff);
663 I915_WRITE(GTIER, 0x0);
664 (void) I915_READ(GTIER);
665}
666
667static int igdng_irq_postinstall(struct drm_device *dev)
668{
669 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
670 /* enable kind of interrupts always enabled */
671 u32 display_mask = DE_MASTER_IRQ_CONTROL /*| DE_PCH_EVENT */;
672 u32 render_mask = GT_USER_INTERRUPT;
673
674 dev_priv->irq_mask_reg = ~display_mask;
675 dev_priv->de_irq_enable_reg = display_mask;
676
677 /* should always can generate irq */
678 I915_WRITE(DEIIR, I915_READ(DEIIR));
679 I915_WRITE(DEIMR, dev_priv->irq_mask_reg);
680 I915_WRITE(DEIER, dev_priv->de_irq_enable_reg);
681 (void) I915_READ(DEIER);
682
683 /* user interrupt should be enabled, but masked initial */
684 dev_priv->gt_irq_mask_reg = 0xffffffff;
685 dev_priv->gt_irq_enable_reg = render_mask;
686
687 I915_WRITE(GTIIR, I915_READ(GTIIR));
688 I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg);
689 I915_WRITE(GTIER, dev_priv->gt_irq_enable_reg);
690 (void) I915_READ(GTIER);
691
692 return 0;
693}
694
Dave Airlie84b1fd12007-07-11 15:53:27 +1000695void i915_driver_irq_preinstall(struct drm_device * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696{
697 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
698
Jesse Barnes79e53942008-11-07 14:24:08 -0800699 atomic_set(&dev_priv->irq_received, 0);
700
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800701 INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
702
703 if (IS_IGDNG(dev)) {
704 igdng_irq_preinstall(dev);
705 return;
706 }
707
Jesse Barnes5ca58282009-03-31 14:11:15 -0700708 if (I915_HAS_HOTPLUG(dev)) {
709 I915_WRITE(PORT_HOTPLUG_EN, 0);
710 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
711 }
712
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700713 I915_WRITE(HWSTAM, 0xeffe);
Keith Packard7c463582008-11-04 02:03:27 -0800714 I915_WRITE(PIPEASTAT, 0);
715 I915_WRITE(PIPEBSTAT, 0);
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700716 I915_WRITE(IMR, 0xffffffff);
Eric Anholted4cb412008-07-29 12:10:39 -0700717 I915_WRITE(IER, 0x0);
Keith Packard7c463582008-11-04 02:03:27 -0800718 (void) I915_READ(IER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719}
720
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700721int i915_driver_irq_postinstall(struct drm_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722{
723 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Jesse Barnes5ca58282009-03-31 14:11:15 -0700724 u32 enable_mask = I915_INTERRUPT_ENABLE_FIX | I915_INTERRUPT_ENABLE_VAR;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700725
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800726 DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
727
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700728 dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700729
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800730 if (IS_IGDNG(dev))
731 return igdng_irq_postinstall(dev);
732
Keith Packard7c463582008-11-04 02:03:27 -0800733 /* Unmask the interrupts that we always want on. */
734 dev_priv->irq_mask_reg = ~I915_INTERRUPT_ENABLE_FIX;
Matthew Garrett8ee1c3d2008-08-05 19:37:25 +0100735
Keith Packard7c463582008-11-04 02:03:27 -0800736 dev_priv->pipestat[0] = 0;
737 dev_priv->pipestat[1] = 0;
738
Jesse Barnes5ca58282009-03-31 14:11:15 -0700739 if (I915_HAS_HOTPLUG(dev)) {
740 u32 hotplug_en = I915_READ(PORT_HOTPLUG_EN);
741
742 /* Leave other bits alone */
743 hotplug_en |= HOTPLUG_EN_MASK;
744 I915_WRITE(PORT_HOTPLUG_EN, hotplug_en);
745
746 dev_priv->hotplug_supported_mask = CRT_HOTPLUG_INT_STATUS |
747 TV_HOTPLUG_INT_STATUS | SDVOC_HOTPLUG_INT_STATUS |
748 SDVOB_HOTPLUG_INT_STATUS;
749 if (IS_G4X(dev)) {
750 dev_priv->hotplug_supported_mask |=
751 HDMIB_HOTPLUG_INT_STATUS |
752 HDMIC_HOTPLUG_INT_STATUS |
753 HDMID_HOTPLUG_INT_STATUS;
754 }
755 /* Enable in IER... */
756 enable_mask |= I915_DISPLAY_PORT_INTERRUPT;
757 /* and unmask in IMR */
758 i915_enable_irq(dev_priv, I915_DISPLAY_PORT_INTERRUPT);
759 }
760
Keith Packard7c463582008-11-04 02:03:27 -0800761 /* Disable pipe interrupt enables, clear pending pipe status */
762 I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff);
763 I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff);
764 /* Clear pending interrupt status */
765 I915_WRITE(IIR, I915_READ(IIR));
766
Jesse Barnes5ca58282009-03-31 14:11:15 -0700767 I915_WRITE(IER, enable_mask);
Keith Packard7c463582008-11-04 02:03:27 -0800768 I915_WRITE(IMR, dev_priv->irq_mask_reg);
Eric Anholted4cb412008-07-29 12:10:39 -0700769 (void) I915_READ(IER);
770
Matthew Garrett8ee1c3d2008-08-05 19:37:25 +0100771 opregion_enable_asle(dev);
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700772
773 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774}
775
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800776static void igdng_irq_uninstall(struct drm_device *dev)
777{
778 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
779 I915_WRITE(HWSTAM, 0xffffffff);
780
781 I915_WRITE(DEIMR, 0xffffffff);
782 I915_WRITE(DEIER, 0x0);
783 I915_WRITE(DEIIR, I915_READ(DEIIR));
784
785 I915_WRITE(GTIMR, 0xffffffff);
786 I915_WRITE(GTIER, 0x0);
787 I915_WRITE(GTIIR, I915_READ(GTIIR));
788}
789
Dave Airlie84b1fd12007-07-11 15:53:27 +1000790void i915_driver_irq_uninstall(struct drm_device * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791{
792 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Dave Airlie91e37382006-02-18 15:17:04 +1100793
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 if (!dev_priv)
795 return;
796
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700797 dev_priv->vblank_pipe = 0;
798
Zhenyu Wang036a4a72009-06-08 14:40:19 +0800799 if (IS_IGDNG(dev)) {
800 igdng_irq_uninstall(dev);
801 return;
802 }
803
Jesse Barnes5ca58282009-03-31 14:11:15 -0700804 if (I915_HAS_HOTPLUG(dev)) {
805 I915_WRITE(PORT_HOTPLUG_EN, 0);
806 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
807 }
808
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700809 I915_WRITE(HWSTAM, 0xffffffff);
Keith Packard7c463582008-11-04 02:03:27 -0800810 I915_WRITE(PIPEASTAT, 0);
811 I915_WRITE(PIPEBSTAT, 0);
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700812 I915_WRITE(IMR, 0xffffffff);
Eric Anholted4cb412008-07-29 12:10:39 -0700813 I915_WRITE(IER, 0x0);
Dave Airlie91e37382006-02-18 15:17:04 +1100814
Keith Packard7c463582008-11-04 02:03:27 -0800815 I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff);
816 I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff);
817 I915_WRITE(IIR, I915_READ(IIR));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818}