blob: 24d11ed5bbc7a76d7cd914830c111872dabb0147 [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"
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#define MAX_NOPID ((u32)~0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Eric Anholted4cb412008-07-29 12:10:39 -070036/** These are the interrupts used by the driver */
37#define I915_INTERRUPT_ENABLE_MASK (I915_USER_INTERRUPT | \
38 I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT | \
39 I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT)
40
41static inline void
42i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask)
43{
44 if ((dev_priv->irq_mask_reg & mask) != 0) {
45 dev_priv->irq_mask_reg &= ~mask;
46 I915_WRITE(IMR, dev_priv->irq_mask_reg);
47 (void) I915_READ(IMR);
48 }
49}
50
51static inline void
52i915_disable_irq(drm_i915_private_t *dev_priv, u32 mask)
53{
54 if ((dev_priv->irq_mask_reg & mask) != mask) {
55 dev_priv->irq_mask_reg |= mask;
56 I915_WRITE(IMR, dev_priv->irq_mask_reg);
57 (void) I915_READ(IMR);
58 }
59}
60
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +100061/**
62 * Emit blits for scheduled buffer swaps.
63 *
64 * This function will be called with the HW lock held.
65 */
Dave Airlie84b1fd12007-07-11 15:53:27 +100066static void i915_vblank_tasklet(struct drm_device *dev)
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +100067{
68 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Dave Airlieaf6061a2008-05-07 12:15:39 +100069 unsigned long irqflags;
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +110070 struct list_head *list, *tmp, hits, *hit;
Dave Airlieaf6061a2008-05-07 12:15:39 +100071 int nhits, nrects, slice[2], upper[2], lower[2], i;
72 unsigned counter[2] = { atomic_read(&dev->vbl_received),
73 atomic_read(&dev->vbl_received2) };
Dave Airliec60ce622007-07-11 15:27:12 +100074 struct drm_drawable_info *drw;
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +110075 drm_i915_sarea_t *sarea_priv = dev_priv->sarea_priv;
Dave Airlieaf6061a2008-05-07 12:15:39 +100076 u32 cpp = dev_priv->cpp;
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +110077 u32 cmd = (cpp == 4) ? (XY_SRC_COPY_BLT_CMD |
78 XY_SRC_COPY_BLT_WRITE_ALPHA |
79 XY_SRC_COPY_BLT_WRITE_RGB)
80 : XY_SRC_COPY_BLT_CMD;
Keith Packard7b832b52008-04-21 16:31:10 +100081 u32 src_pitch = sarea_priv->pitch * cpp;
82 u32 dst_pitch = sarea_priv->pitch * cpp;
83 u32 ropcpp = (0xcc << 16) | ((cpp - 1) << 24);
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +110084 RING_LOCALS;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +100085
Jesse Barnes3d258022008-07-01 12:32:52 -070086 if (IS_I965G(dev) && sarea_priv->front_tiled) {
Keith Packard7b832b52008-04-21 16:31:10 +100087 cmd |= XY_SRC_COPY_BLT_DST_TILED;
88 dst_pitch >>= 2;
89 }
Jesse Barnes3d258022008-07-01 12:32:52 -070090 if (IS_I965G(dev) && sarea_priv->back_tiled) {
Keith Packard7b832b52008-04-21 16:31:10 +100091 cmd |= XY_SRC_COPY_BLT_SRC_TILED;
92 src_pitch >>= 2;
93 }
94
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +100095 DRM_DEBUG("\n");
96
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +110097 INIT_LIST_HEAD(&hits);
98
99 nhits = nrects = 0;
100
Dave Airlieaf6061a2008-05-07 12:15:39 +1000101 spin_lock_irqsave(&dev_priv->swaps_lock, irqflags);
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000102
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100103 /* Find buffer swaps scheduled for this vertical blank */
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000104 list_for_each_safe(list, tmp, &dev_priv->vbl_swaps.head) {
105 drm_i915_vbl_swap_t *vbl_swap =
106 list_entry(list, drm_i915_vbl_swap_t, head);
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000107
Dave Airlieaf6061a2008-05-07 12:15:39 +1000108 if ((counter[vbl_swap->pipe] - vbl_swap->sequence) > (1<<23))
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100109 continue;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000110
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100111 list_del(list);
112 dev_priv->swaps_pending--;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000113
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100114 spin_unlock(&dev_priv->swaps_lock);
115 spin_lock(&dev->drw_lock);
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000116
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100117 drw = drm_get_drawable_info(dev, vbl_swap->drw_id);
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000118
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100119 if (!drw) {
120 spin_unlock(&dev->drw_lock);
121 drm_free(vbl_swap, sizeof(*vbl_swap), DRM_MEM_DRIVER);
122 spin_lock(&dev_priv->swaps_lock);
123 continue;
124 }
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000125
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100126 list_for_each(hit, &hits) {
127 drm_i915_vbl_swap_t *swap_cmp =
128 list_entry(hit, drm_i915_vbl_swap_t, head);
Dave Airliec60ce622007-07-11 15:27:12 +1000129 struct drm_drawable_info *drw_cmp =
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100130 drm_get_drawable_info(dev, swap_cmp->drw_id);
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000131
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100132 if (drw_cmp &&
133 drw_cmp->rects[0].y1 > drw->rects[0].y1) {
134 list_add_tail(list, hit);
135 break;
136 }
137 }
138
139 spin_unlock(&dev->drw_lock);
140
141 /* List of hits was empty, or we reached the end of it */
142 if (hit == &hits)
143 list_add_tail(list, hits.prev);
144
145 nhits++;
146
147 spin_lock(&dev_priv->swaps_lock);
148 }
149
Dave Airlieaf6061a2008-05-07 12:15:39 +1000150 if (nhits == 0) {
151 spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags);
Jesse Barnesac741ab2008-04-22 16:03:07 +1000152 return;
Dave Airlieaf6061a2008-05-07 12:15:39 +1000153 }
154
155 spin_unlock(&dev_priv->swaps_lock);
Jesse Barnesac741ab2008-04-22 16:03:07 +1000156
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100157 i915_kernel_lost_context(dev);
158
Dave Airlieaf6061a2008-05-07 12:15:39 +1000159 if (IS_I965G(dev)) {
160 BEGIN_LP_RING(4);
Jesse Barnesac741ab2008-04-22 16:03:07 +1000161
Dave Airlieaf6061a2008-05-07 12:15:39 +1000162 OUT_RING(GFX_OP_DRAWRECT_INFO_I965);
163 OUT_RING(0);
164 OUT_RING(((sarea_priv->width - 1) & 0xffff) | ((sarea_priv->height - 1) << 16));
165 OUT_RING(0);
166 ADVANCE_LP_RING();
167 } else {
168 BEGIN_LP_RING(6);
169
170 OUT_RING(GFX_OP_DRAWRECT_INFO);
171 OUT_RING(0);
172 OUT_RING(0);
173 OUT_RING(sarea_priv->width | sarea_priv->height << 16);
174 OUT_RING(sarea_priv->width | sarea_priv->height << 16);
175 OUT_RING(0);
176
177 ADVANCE_LP_RING();
178 }
179
180 sarea_priv->ctxOwner = DRM_KERNEL_CONTEXT;
181
182 upper[0] = upper[1] = 0;
183 slice[0] = max(sarea_priv->pipeA_h / nhits, 1);
184 slice[1] = max(sarea_priv->pipeB_h / nhits, 1);
185 lower[0] = sarea_priv->pipeA_y + slice[0];
186 lower[1] = sarea_priv->pipeB_y + slice[0];
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100187
188 spin_lock(&dev->drw_lock);
189
190 /* Emit blits for buffer swaps, partitioning both outputs into as many
191 * slices as there are buffer swaps scheduled in order to avoid tearing
192 * (based on the assumption that a single buffer swap would always
193 * complete before scanout starts).
194 */
195 for (i = 0; i++ < nhits;
196 upper[0] = lower[0], lower[0] += slice[0],
197 upper[1] = lower[1], lower[1] += slice[1]) {
198 if (i == nhits)
199 lower[0] = lower[1] = sarea_priv->height;
200
201 list_for_each(hit, &hits) {
202 drm_i915_vbl_swap_t *swap_hit =
203 list_entry(hit, drm_i915_vbl_swap_t, head);
Dave Airliec60ce622007-07-11 15:27:12 +1000204 struct drm_clip_rect *rect;
Dave Airlieaf6061a2008-05-07 12:15:39 +1000205 int num_rects, pipe;
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100206 unsigned short top, bottom;
207
208 drw = drm_get_drawable_info(dev, swap_hit->drw_id);
209
210 if (!drw)
211 continue;
212
213 rect = drw->rects;
Dave Airlieaf6061a2008-05-07 12:15:39 +1000214 pipe = swap_hit->pipe;
215 top = upper[pipe];
216 bottom = lower[pipe];
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100217
218 for (num_rects = drw->num_rects; num_rects--; rect++) {
219 int y1 = max(rect->y1, top);
220 int y2 = min(rect->y2, bottom);
221
222 if (y1 >= y2)
223 continue;
224
225 BEGIN_LP_RING(8);
226
227 OUT_RING(cmd);
Keith Packard7b832b52008-04-21 16:31:10 +1000228 OUT_RING(ropcpp | dst_pitch);
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100229 OUT_RING((y1 << 16) | rect->x1);
230 OUT_RING((y2 << 16) | rect->x2);
Dave Airlieaf6061a2008-05-07 12:15:39 +1000231 OUT_RING(sarea_priv->front_offset);
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100232 OUT_RING((y1 << 16) | rect->x1);
Keith Packard7b832b52008-04-21 16:31:10 +1000233 OUT_RING(src_pitch);
Dave Airlieaf6061a2008-05-07 12:15:39 +1000234 OUT_RING(sarea_priv->back_offset);
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000235
236 ADVANCE_LP_RING();
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000237 }
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000238 }
239 }
240
Dave Airlieaf6061a2008-05-07 12:15:39 +1000241 spin_unlock_irqrestore(&dev->drw_lock, irqflags);
=?utf-8?q?Michel_D=C3=A4nzer?=3188a242006-12-11 18:32:27 +1100242
243 list_for_each_safe(hit, tmp, &hits) {
244 drm_i915_vbl_swap_t *swap_hit =
245 list_entry(hit, drm_i915_vbl_swap_t, head);
246
247 list_del(hit);
248
249 drm_free(swap_hit, sizeof(*swap_hit), DRM_MEM_DRIVER);
250 }
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000251}
252
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
254{
Dave Airlie84b1fd12007-07-11 15:53:27 +1000255 struct drm_device *dev = (struct drm_device *) arg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Dave Airliee4a7b1d2007-09-28 11:46:28 +1000257 u32 pipea_stats, pipeb_stats;
Eric Anholted4cb412008-07-29 12:10:39 -0700258 u32 iir;
Dave Airliee4a7b1d2007-09-28 11:46:28 +1000259
Jesse Barnes585fb112008-07-29 11:54:06 -0700260 pipea_stats = I915_READ(PIPEASTAT);
261 pipeb_stats = I915_READ(PIPEBSTAT);
Dave Airlieaf6061a2008-05-07 12:15:39 +1000262
Eric Anholted4cb412008-07-29 12:10:39 -0700263 if (dev->pdev->msi_enabled)
264 I915_WRITE(IMR, ~0);
265 iir = I915_READ(IIR);
Dave Airlieaf6061a2008-05-07 12:15:39 +1000266
Eric Anholted4cb412008-07-29 12:10:39 -0700267 DRM_DEBUG("iir=%08x\n", iir);
Dave Airlieaf6061a2008-05-07 12:15:39 +1000268
Eric Anholted4cb412008-07-29 12:10:39 -0700269 if (iir == 0) {
270 if (dev->pdev->msi_enabled) {
271 I915_WRITE(IMR, dev_priv->irq_mask_reg);
272 (void) I915_READ(IMR);
273 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 return IRQ_NONE;
Eric Anholted4cb412008-07-29 12:10:39 -0700275 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
Eric Anholted4cb412008-07-29 12:10:39 -0700277 I915_WRITE(IIR, iir);
278 if (dev->pdev->msi_enabled)
279 I915_WRITE(IMR, dev_priv->irq_mask_reg);
280 (void) I915_READ(IIR); /* Flush posted writes */
Dave Airlie0d6aa602006-01-02 20:14:23 +1100281
Dave Airlieaf6061a2008-05-07 12:15:39 +1000282 dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
Dave Airlie6e5fca52006-03-20 18:34:29 +1100283
Eric Anholted4cb412008-07-29 12:10:39 -0700284 if (iir & I915_USER_INTERRUPT)
Dave Airlie0d6aa602006-01-02 20:14:23 +1100285 DRM_WAKEUP(&dev_priv->irq_queue);
Dave Airlieaf6061a2008-05-07 12:15:39 +1000286
Eric Anholted4cb412008-07-29 12:10:39 -0700287 if (iir & (I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT |
288 I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT)) {
Dave Airlieaf6061a2008-05-07 12:15:39 +1000289 int vblank_pipe = dev_priv->vblank_pipe;
290
291 if ((vblank_pipe &
292 (DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B))
293 == (DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B)) {
Eric Anholted4cb412008-07-29 12:10:39 -0700294 if (iir & I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT)
Dave Airlieaf6061a2008-05-07 12:15:39 +1000295 atomic_inc(&dev->vbl_received);
Eric Anholted4cb412008-07-29 12:10:39 -0700296 if (iir & I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT)
Dave Airlieaf6061a2008-05-07 12:15:39 +1000297 atomic_inc(&dev->vbl_received2);
Eric Anholted4cb412008-07-29 12:10:39 -0700298 } else if (((iir & I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT) &&
Dave Airlieaf6061a2008-05-07 12:15:39 +1000299 (vblank_pipe & DRM_I915_VBLANK_PIPE_A)) ||
Eric Anholted4cb412008-07-29 12:10:39 -0700300 ((iir & I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT) &&
Dave Airlieaf6061a2008-05-07 12:15:39 +1000301 (vblank_pipe & DRM_I915_VBLANK_PIPE_B)))
302 atomic_inc(&dev->vbl_received);
303
304 DRM_WAKEUP(&dev->vbl_queue);
305 drm_vbl_send_signals(dev);
306
=?utf-8?q?Michel_D=C3=A4nzer?=2228ed62006-10-25 01:05:09 +1000307 if (dev_priv->swaps_pending > 0)
308 drm_locked_tasklet(dev, i915_vblank_tasklet);
Jesse Barnes585fb112008-07-29 11:54:06 -0700309 I915_WRITE(PIPEASTAT,
Dave Airlieaf6061a2008-05-07 12:15:39 +1000310 pipea_stats|I915_VBLANK_INTERRUPT_ENABLE|
Jesse Barnes585fb112008-07-29 11:54:06 -0700311 PIPE_VBLANK_INTERRUPT_STATUS);
312 I915_WRITE(PIPEBSTAT,
Dave Airlieaf6061a2008-05-07 12:15:39 +1000313 pipeb_stats|I915_VBLANK_INTERRUPT_ENABLE|
Jesse Barnes585fb112008-07-29 11:54:06 -0700314 PIPE_VBLANK_INTERRUPT_STATUS);
Dave Airlie0d6aa602006-01-02 20:14:23 +1100315 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
317 return IRQ_HANDLED;
318}
319
Dave Airlieaf6061a2008-05-07 12:15:39 +1000320static int i915_emit_irq(struct drm_device * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321{
322 drm_i915_private_t *dev_priv = dev->dev_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 RING_LOCALS;
324
325 i915_kernel_lost_context(dev);
326
Márton Németh3e684ea2008-01-24 15:58:57 +1000327 DRM_DEBUG("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
Alan Hourihanec29b6692006-08-12 16:29:24 +1000329 dev_priv->sarea_priv->last_enqueue = ++dev_priv->counter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
Alan Hourihanec29b6692006-08-12 16:29:24 +1000331 if (dev_priv->counter > 0x7FFFFFFFUL)
332 dev_priv->sarea_priv->last_enqueue = dev_priv->counter = 1;
333
334 BEGIN_LP_RING(6);
Jesse Barnes585fb112008-07-29 11:54:06 -0700335 OUT_RING(MI_STORE_DWORD_INDEX);
336 OUT_RING(5 << MI_STORE_DWORD_INDEX_SHIFT);
Alan Hourihanec29b6692006-08-12 16:29:24 +1000337 OUT_RING(dev_priv->counter);
338 OUT_RING(0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 OUT_RING(0);
Jesse Barnes585fb112008-07-29 11:54:06 -0700340 OUT_RING(MI_USER_INTERRUPT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 ADVANCE_LP_RING();
Dave Airliebc5f4522007-11-05 12:50:58 +1000342
Alan Hourihanec29b6692006-08-12 16:29:24 +1000343 return dev_priv->counter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344}
345
Eric Anholted4cb412008-07-29 12:10:39 -0700346static void i915_user_irq_get(struct drm_device *dev)
347{
348 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
349
350 spin_lock(&dev_priv->user_irq_lock);
351 if (dev->irq_enabled && (++dev_priv->user_irq_refcount == 1))
352 i915_enable_irq(dev_priv, I915_USER_INTERRUPT);
353 spin_unlock(&dev_priv->user_irq_lock);
354}
355
356static void i915_user_irq_put(struct drm_device *dev)
357{
358 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
359
360 spin_lock(&dev_priv->user_irq_lock);
361 BUG_ON(dev->irq_enabled && dev_priv->user_irq_refcount <= 0);
362 if (dev->irq_enabled && (--dev_priv->user_irq_refcount == 0))
363 i915_disable_irq(dev_priv, I915_USER_INTERRUPT);
364 spin_unlock(&dev_priv->user_irq_lock);
365}
366
Dave Airlie84b1fd12007-07-11 15:53:27 +1000367static int i915_wait_irq(struct drm_device * dev, int irq_nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368{
369 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
370 int ret = 0;
371
Márton Németh3e684ea2008-01-24 15:58:57 +1000372 DRM_DEBUG("irq_nr=%d breadcrumb=%d\n", irq_nr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 READ_BREADCRUMB(dev_priv));
374
Eric Anholted4cb412008-07-29 12:10:39 -0700375 if (READ_BREADCRUMB(dev_priv) >= irq_nr) {
376 dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 return 0;
Eric Anholted4cb412008-07-29 12:10:39 -0700378 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
380 dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
381
Eric Anholted4cb412008-07-29 12:10:39 -0700382 i915_user_irq_get(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ,
384 READ_BREADCRUMB(dev_priv) >= irq_nr);
Eric Anholted4cb412008-07-29 12:10:39 -0700385 i915_user_irq_put(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
Eric Anholt20caafa2007-08-25 19:22:43 +1000387 if (ret == -EBUSY) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000388 DRM_ERROR("EBUSY -- rec: %d emitted: %d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 READ_BREADCRUMB(dev_priv), (int)dev_priv->counter);
390 }
391
Dave Airlieaf6061a2008-05-07 12:15:39 +1000392 dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 return ret;
394}
395
Dave Airlieaf6061a2008-05-07 12:15:39 +1000396static int i915_driver_vblank_do_wait(struct drm_device *dev, unsigned int *sequence,
397 atomic_t *counter)
398{
399 drm_i915_private_t *dev_priv = dev->dev_private;
400 unsigned int cur_vblank;
401 int ret = 0;
402
403 if (!dev_priv) {
404 DRM_ERROR("called with no initialization\n");
405 return -EINVAL;
406 }
407
408 DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
409 (((cur_vblank = atomic_read(counter))
410 - *sequence) <= (1<<23)));
411
412 *sequence = cur_vblank;
413
414 return ret;
415}
416
417
418int i915_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence)
419{
420 return i915_driver_vblank_do_wait(dev, sequence, &dev->vbl_received);
421}
422
423int i915_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence)
424{
425 return i915_driver_vblank_do_wait(dev, sequence, &dev->vbl_received2);
426}
427
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428/* Needs the lock as it touches the ring.
429 */
Eric Anholtc153f452007-09-03 12:06:45 +1000430int i915_irq_emit(struct drm_device *dev, void *data,
431 struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 drm_i915_private_t *dev_priv = dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000434 drm_i915_irq_emit_t *emit = data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 int result;
436
Eric Anholt6c340ea2007-08-25 20:23:09 +1000437 LOCK_TEST_WITH_RETURN(dev, file_priv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
439 if (!dev_priv) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000440 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000441 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 }
443
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 result = i915_emit_irq(dev);
445
Eric Anholtc153f452007-09-03 12:06:45 +1000446 if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 DRM_ERROR("copy_to_user\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000448 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 }
450
451 return 0;
452}
453
454/* Doesn't need the hardware lock.
455 */
Eric Anholtc153f452007-09-03 12:06:45 +1000456int i915_irq_wait(struct drm_device *dev, void *data,
457 struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 drm_i915_private_t *dev_priv = dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000460 drm_i915_irq_wait_t *irqwait = data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461
462 if (!dev_priv) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000463 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000464 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 }
466
Eric Anholtc153f452007-09-03 12:06:45 +1000467 return i915_wait_irq(dev, irqwait->irq_seq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468}
469
Dave Airlie702880f2006-06-24 17:07:34 +1000470/* Set the vblank monitor pipe
471 */
Eric Anholtc153f452007-09-03 12:06:45 +1000472int i915_vblank_pipe_set(struct drm_device *dev, void *data,
473 struct drm_file *file_priv)
Dave Airlie702880f2006-06-24 17:07:34 +1000474{
Dave Airlie702880f2006-06-24 17:07:34 +1000475 drm_i915_private_t *dev_priv = dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000476 drm_i915_vblank_pipe_t *pipe = data;
Eric Anholted4cb412008-07-29 12:10:39 -0700477 u32 enable_mask = 0, disable_mask = 0;
Dave Airlie702880f2006-06-24 17:07:34 +1000478
479 if (!dev_priv) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000480 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000481 return -EINVAL;
Dave Airlie702880f2006-06-24 17:07:34 +1000482 }
483
Eric Anholtc153f452007-09-03 12:06:45 +1000484 if (pipe->pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000485 DRM_ERROR("called with invalid pipe 0x%x\n", pipe->pipe);
Eric Anholt20caafa2007-08-25 19:22:43 +1000486 return -EINVAL;
=?utf-8?q?Michel_D=C3=A4nzer?=5b516942006-10-25 00:08:23 +1000487 }
488
Eric Anholted4cb412008-07-29 12:10:39 -0700489 if (pipe->pipe & DRM_I915_VBLANK_PIPE_A)
490 enable_mask |= I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT;
491 else
492 disable_mask |= I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT;
=?utf-8?q?Michel_D=C3=A4nzer?=5b516942006-10-25 00:08:23 +1000493
Eric Anholted4cb412008-07-29 12:10:39 -0700494 if (pipe->pipe & DRM_I915_VBLANK_PIPE_B)
495 enable_mask |= I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT;
496 else
497 disable_mask |= I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT;
498
499 i915_enable_irq(dev_priv, enable_mask);
500 i915_disable_irq(dev_priv, disable_mask);
501
502 dev_priv->vblank_pipe = pipe->pipe;
Dave Airlieaf6061a2008-05-07 12:15:39 +1000503
=?utf-8?q?Michel_D=C3=A4nzer?=5b516942006-10-25 00:08:23 +1000504 return 0;
Dave Airlie702880f2006-06-24 17:07:34 +1000505}
506
Eric Anholtc153f452007-09-03 12:06:45 +1000507int i915_vblank_pipe_get(struct drm_device *dev, void *data,
508 struct drm_file *file_priv)
Dave Airlie702880f2006-06-24 17:07:34 +1000509{
Dave Airlie702880f2006-06-24 17:07:34 +1000510 drm_i915_private_t *dev_priv = dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000511 drm_i915_vblank_pipe_t *pipe = data;
Dave Airlie702880f2006-06-24 17:07:34 +1000512 u16 flag;
513
514 if (!dev_priv) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000515 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000516 return -EINVAL;
Dave Airlie702880f2006-06-24 17:07:34 +1000517 }
518
Eric Anholted4cb412008-07-29 12:10:39 -0700519 flag = I915_READ(IMR);
Eric Anholtc153f452007-09-03 12:06:45 +1000520 pipe->pipe = 0;
Jesse Barnes585fb112008-07-29 11:54:06 -0700521 if (flag & I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT)
Eric Anholtc153f452007-09-03 12:06:45 +1000522 pipe->pipe |= DRM_I915_VBLANK_PIPE_A;
Jesse Barnes585fb112008-07-29 11:54:06 -0700523 if (flag & I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT)
Eric Anholtc153f452007-09-03 12:06:45 +1000524 pipe->pipe |= DRM_I915_VBLANK_PIPE_B;
525
Dave Airlie702880f2006-06-24 17:07:34 +1000526 return 0;
527}
528
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000529/**
530 * Schedule buffer swap at given vertical blank.
531 */
Eric Anholtc153f452007-09-03 12:06:45 +1000532int i915_vblank_swap(struct drm_device *dev, void *data,
533 struct drm_file *file_priv)
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000534{
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000535 drm_i915_private_t *dev_priv = dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000536 drm_i915_vblank_swap_t *swap = data;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000537 drm_i915_vbl_swap_t *vbl_swap;
Dave Airlieaf6061a2008-05-07 12:15:39 +1000538 unsigned int pipe, seqtype, curseq;
=?utf-8?q?Michel_D=C3=A4nzer?=a0b136b2006-10-25 00:12:52 +1000539 unsigned long irqflags;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000540 struct list_head *list;
541
542 if (!dev_priv) {
543 DRM_ERROR("%s called with no initialization\n", __func__);
Eric Anholt20caafa2007-08-25 19:22:43 +1000544 return -EINVAL;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000545 }
546
Dave Airlieaf6061a2008-05-07 12:15:39 +1000547 if (dev_priv->sarea_priv->rotation) {
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000548 DRM_DEBUG("Rotation not supported\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000549 return -EINVAL;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000550 }
551
Eric Anholtc153f452007-09-03 12:06:45 +1000552 if (swap->seqtype & ~(_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE |
Dave Airlieaf6061a2008-05-07 12:15:39 +1000553 _DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)) {
Eric Anholtc153f452007-09-03 12:06:45 +1000554 DRM_ERROR("Invalid sequence type 0x%x\n", swap->seqtype);
Eric Anholt20caafa2007-08-25 19:22:43 +1000555 return -EINVAL;
=?utf-8?q?Michel_D=C3=A4nzer?=541f29a2006-10-24 23:38:54 +1000556 }
557
Dave Airlieaf6061a2008-05-07 12:15:39 +1000558 pipe = (swap->seqtype & _DRM_VBLANK_SECONDARY) ? 1 : 0;
=?utf-8?q?Michel_D=C3=A4nzer?=541f29a2006-10-24 23:38:54 +1000559
Eric Anholtc153f452007-09-03 12:06:45 +1000560 seqtype = swap->seqtype & (_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE);
=?utf-8?q?Michel_D=C3=A4nzer?=541f29a2006-10-24 23:38:54 +1000561
=?utf-8?q?Michel_D=C3=A4nzer?=541f29a2006-10-24 23:38:54 +1000562 if (!(dev_priv->vblank_pipe & (1 << pipe))) {
563 DRM_ERROR("Invalid pipe %d\n", pipe);
Eric Anholt20caafa2007-08-25 19:22:43 +1000564 return -EINVAL;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000565 }
566
567 spin_lock_irqsave(&dev->drw_lock, irqflags);
568
Eric Anholtc153f452007-09-03 12:06:45 +1000569 if (!drm_get_drawable_info(dev, swap->drawable)) {
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000570 spin_unlock_irqrestore(&dev->drw_lock, irqflags);
Eric Anholtc153f452007-09-03 12:06:45 +1000571 DRM_DEBUG("Invalid drawable ID %d\n", swap->drawable);
Eric Anholt20caafa2007-08-25 19:22:43 +1000572 return -EINVAL;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000573 }
574
575 spin_unlock_irqrestore(&dev->drw_lock, irqflags);
576
Dave Airlieaf6061a2008-05-07 12:15:39 +1000577 curseq = atomic_read(pipe ? &dev->vbl_received2 : &dev->vbl_received);
=?utf-8?q?Michel_D=C3=A4nzer?=541f29a2006-10-24 23:38:54 +1000578
=?utf-8?q?Michel_D=C3=A4nzer?=2228ed62006-10-25 01:05:09 +1000579 if (seqtype == _DRM_VBLANK_RELATIVE)
Eric Anholtc153f452007-09-03 12:06:45 +1000580 swap->sequence += curseq;
=?utf-8?q?Michel_D=C3=A4nzer?=2228ed62006-10-25 01:05:09 +1000581
Eric Anholtc153f452007-09-03 12:06:45 +1000582 if ((curseq - swap->sequence) <= (1<<23)) {
583 if (swap->seqtype & _DRM_VBLANK_NEXTONMISS) {
584 swap->sequence = curseq + 1;
=?utf-8?q?Michel_D=C3=A4nzer?=2228ed62006-10-25 01:05:09 +1000585 } else {
=?utf-8?q?Michel_D=C3=A4nzer?=541f29a2006-10-24 23:38:54 +1000586 DRM_DEBUG("Missed target sequence\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000587 return -EINVAL;
=?utf-8?q?Michel_D=C3=A4nzer?=541f29a2006-10-24 23:38:54 +1000588 }
=?utf-8?q?Michel_D=C3=A4nzer?=541f29a2006-10-24 23:38:54 +1000589 }
590
=?utf-8?q?Michel_D=C3=A4nzer?=2228ed62006-10-25 01:05:09 +1000591 spin_lock_irqsave(&dev_priv->swaps_lock, irqflags);
592
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000593 list_for_each(list, &dev_priv->vbl_swaps.head) {
594 vbl_swap = list_entry(list, drm_i915_vbl_swap_t, head);
595
Eric Anholtc153f452007-09-03 12:06:45 +1000596 if (vbl_swap->drw_id == swap->drawable &&
Dave Airlieaf6061a2008-05-07 12:15:39 +1000597 vbl_swap->pipe == pipe &&
Eric Anholtc153f452007-09-03 12:06:45 +1000598 vbl_swap->sequence == swap->sequence) {
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000599 spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags);
600 DRM_DEBUG("Already scheduled\n");
601 return 0;
602 }
603 }
604
605 spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags);
606
=?utf-8?q?Michel_D=C3=A4nzer?=21fa60e2006-10-25 00:10:59 +1000607 if (dev_priv->swaps_pending >= 100) {
608 DRM_DEBUG("Too many swaps queued\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000609 return -EBUSY;
=?utf-8?q?Michel_D=C3=A4nzer?=21fa60e2006-10-25 00:10:59 +1000610 }
611
Dave Airlie54583bf2007-10-14 21:21:30 +1000612 vbl_swap = drm_calloc(1, sizeof(*vbl_swap), DRM_MEM_DRIVER);
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000613
614 if (!vbl_swap) {
615 DRM_ERROR("Failed to allocate memory to queue swap\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000616 return -ENOMEM;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000617 }
618
619 DRM_DEBUG("\n");
620
Eric Anholtc153f452007-09-03 12:06:45 +1000621 vbl_swap->drw_id = swap->drawable;
Dave Airlieaf6061a2008-05-07 12:15:39 +1000622 vbl_swap->pipe = pipe;
Eric Anholtc153f452007-09-03 12:06:45 +1000623 vbl_swap->sequence = swap->sequence;
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000624
625 spin_lock_irqsave(&dev_priv->swaps_lock, irqflags);
626
Li Zefand5b0d1b2007-12-17 09:47:19 +1000627 list_add_tail(&vbl_swap->head, &dev_priv->vbl_swaps.head);
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000628 dev_priv->swaps_pending++;
629
630 spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags);
631
632 return 0;
633}
634
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635/* drm_dma.h hooks
636*/
Dave Airlie84b1fd12007-07-11 15:53:27 +1000637void i915_driver_irq_preinstall(struct drm_device * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638{
639 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
640
Eric Anholted4cb412008-07-29 12:10:39 -0700641 I915_WRITE(HWSTAM, 0xfffe);
642 I915_WRITE(IMR, 0x0);
643 I915_WRITE(IER, 0x0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644}
645
Dave Airlieaf6061a2008-05-07 12:15:39 +1000646void i915_driver_irq_postinstall(struct drm_device * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647{
648 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
649
Thomas Gleixnera6399bd2007-05-26 05:56:14 +1000650 spin_lock_init(&dev_priv->swaps_lock);
=?utf-8?q?Michel_D=C3=A4nzer?=a6b54f32006-10-24 23:37:43 +1000651 INIT_LIST_HEAD(&dev_priv->vbl_swaps.head);
652 dev_priv->swaps_pending = 0;
653
Dave Airlieaf6061a2008-05-07 12:15:39 +1000654 if (!dev_priv->vblank_pipe)
655 dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A;
Eric Anholted4cb412008-07-29 12:10:39 -0700656
657 /* Set initial unmasked IRQs to just the selected vblank pipes. */
658 dev_priv->irq_mask_reg = ~0;
659 if (dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_A)
660 dev_priv->irq_mask_reg &= ~I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT;
661 if (dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_B)
662 dev_priv->irq_mask_reg &= ~I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT;
663
664 I915_WRITE(IMR, dev_priv->irq_mask_reg);
665 I915_WRITE(IER, I915_INTERRUPT_ENABLE_MASK);
666 (void) I915_READ(IER);
667
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
669}
670
Dave Airlie84b1fd12007-07-11 15:53:27 +1000671void i915_driver_irq_uninstall(struct drm_device * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672{
673 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
Dave Airlieaf6061a2008-05-07 12:15:39 +1000674 u16 temp;
Dave Airlie91e37382006-02-18 15:17:04 +1100675
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 if (!dev_priv)
677 return;
678
Eric Anholted4cb412008-07-29 12:10:39 -0700679 I915_WRITE(HWSTAM, 0xffff);
680 I915_WRITE(IMR, 0xffff);
681 I915_WRITE(IER, 0x0);
Dave Airlie91e37382006-02-18 15:17:04 +1100682
Eric Anholted4cb412008-07-29 12:10:39 -0700683 temp = I915_READ(IIR);
684 I915_WRITE(IIR, temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685}