1 /* i915_dma.c -- DMA support for the I915 -*- linux-c -*-
4 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
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.
34 /* Really want an OS-independent resettable timer. Would like to have
35 * this loop run for (eg) 3 sec, but have the timer reset every time
36 * the head pointer changes, so that EBUSY only happens if the ring
37 * actually stalls for (eg) 3 seconds.
39 int i915_wait_ring(struct drm_device * dev, int n, const char *caller)
41 drm_i915_private_t *dev_priv = dev->dev_private;
42 drm_i915_ring_buffer_t *ring = &(dev_priv->ring);
43 u32 last_head = I915_READ(LP_RING + RING_HEAD) & HEAD_ADDR;
46 for (i = 0; i < 10000; i++) {
47 ring->head = I915_READ(LP_RING + RING_HEAD) & HEAD_ADDR;
48 ring->space = ring->head - (ring->tail + 8);
50 ring->space += ring->Size;
54 if (ring->head != last_head)
57 last_head = ring->head;
64 void i915_kernel_lost_context(struct drm_device * dev)
66 drm_i915_private_t *dev_priv = dev->dev_private;
67 drm_i915_ring_buffer_t *ring = &(dev_priv->ring);
69 ring->head = I915_READ(LP_RING + RING_HEAD) & HEAD_ADDR;
70 ring->tail = I915_READ(LP_RING + RING_TAIL) & TAIL_ADDR;
71 ring->space = ring->head - (ring->tail + 8);
73 ring->space += ring->Size;
76 static int i915_dma_cleanup(struct drm_device * dev)
78 drm_i915_private_t *dev_priv = dev->dev_private;
79 /* Make sure interrupts are disabled here because the uninstall ioctl
80 * may not have been called from userspace and after dev_private
81 * is freed, it's too late.
84 drm_irq_uninstall(dev);
86 if (dev_priv->ring.virtual_start) {
87 drm_core_ioremapfree(&dev_priv->ring.map, dev);
88 dev_priv->ring.virtual_start = 0;
89 dev_priv->ring.map.handle = 0;
90 dev_priv->ring.map.size = 0;
93 if (dev_priv->status_page_dmah) {
94 drm_pci_free(dev, dev_priv->status_page_dmah);
95 dev_priv->status_page_dmah = NULL;
96 /* Need to rewrite hardware status page */
97 I915_WRITE(0x02080, 0x1ffff000);
100 if (dev_priv->status_gfx_addr) {
101 dev_priv->status_gfx_addr = 0;
102 drm_core_ioremapfree(&dev_priv->hws_map, dev);
103 I915_WRITE(0x02080, 0x1ffff000);
110 #define DRI2_SAREA_BLOCK_TYPE(b) ((b) >> 16)
111 #define DRI2_SAREA_BLOCK_SIZE(b) ((b) & 0xffff)
112 #define DRI2_SAREA_BLOCK_NEXT(p) \
113 ((void *) ((unsigned char *) (p) + \
114 DRI2_SAREA_BLOCK_SIZE(*(unsigned int *) p)))
116 #define DRI2_SAREA_BLOCK_END 0x0000
117 #define DRI2_SAREA_BLOCK_LOCK 0x0001
118 #define DRI2_SAREA_BLOCK_EVENT_BUFFER 0x0002
121 setup_dri2_sarea(struct drm_device * dev,
122 struct drm_file *file_priv,
123 drm_i915_init_t * init)
125 drm_i915_private_t *dev_priv = dev->dev_private;
127 unsigned int *p, *end, *next;
129 mutex_lock(&dev->struct_mutex);
131 drm_lookup_buffer_object(file_priv,
132 init->sarea_handle, 1);
133 mutex_unlock(&dev->struct_mutex);
135 if (!dev_priv->sarea_bo) {
136 DRM_ERROR("did not find sarea bo\n");
140 ret = drm_bo_kmap(dev_priv->sarea_bo, 0,
141 dev_priv->sarea_bo->num_pages,
142 &dev_priv->sarea_kmap);
144 DRM_ERROR("could not map sarea bo\n");
148 p = dev_priv->sarea_kmap.virtual;
149 end = (void *) p + (dev_priv->sarea_bo->num_pages << PAGE_SHIFT);
150 while (p < end && DRI2_SAREA_BLOCK_TYPE(*p) != DRI2_SAREA_BLOCK_END) {
151 switch (DRI2_SAREA_BLOCK_TYPE(*p)) {
152 case DRI2_SAREA_BLOCK_LOCK:
153 dev->lock.hw_lock = (void *) (p + 1);
154 dev->sigdata.lock = dev->lock.hw_lock;
157 next = DRI2_SAREA_BLOCK_NEXT(p);
158 if (next <= p || end < next) {
159 DRM_ERROR("malformed dri2 sarea: next is %p should be within %p-%p\n",
170 static int i915_initialize(struct drm_device * dev,
171 struct drm_file *file_priv,
172 drm_i915_init_t * init)
174 drm_i915_private_t *dev_priv = dev->dev_private;
177 dev_priv->sarea = drm_getsarea(dev);
178 if (!dev_priv->sarea) {
179 DRM_ERROR("can not find sarea!\n");
180 i915_dma_cleanup(dev);
184 if (init->mmio_offset != 0)
185 dev_priv->mmio_map = drm_core_findmap(dev, init->mmio_offset);
186 if (!dev_priv->mmio_map) {
187 i915_dma_cleanup(dev);
188 DRM_ERROR("can not find mmio map!\n");
192 #ifdef I915_HAVE_BUFFER
193 dev_priv->max_validate_buffers = I915_MAX_VALIDATE_BUFFERS;
196 if (init->sarea_priv_offset)
197 dev_priv->sarea_priv = (drm_i915_sarea_t *)
198 ((u8 *) dev_priv->sarea->handle +
199 init->sarea_priv_offset);
201 /* No sarea_priv for you! */
202 dev_priv->sarea_priv = NULL;
205 dev_priv->ring.Start = init->ring_start;
206 dev_priv->ring.End = init->ring_end;
207 dev_priv->ring.Size = init->ring_size;
208 dev_priv->ring.tail_mask = dev_priv->ring.Size - 1;
210 dev_priv->ring.map.offset = init->ring_start;
211 dev_priv->ring.map.size = init->ring_size;
212 dev_priv->ring.map.type = 0;
213 dev_priv->ring.map.flags = 0;
214 dev_priv->ring.map.mtrr = 0;
216 drm_core_ioremap(&dev_priv->ring.map, dev);
218 if (dev_priv->ring.map.handle == NULL) {
219 i915_dma_cleanup(dev);
220 DRM_ERROR("can not ioremap virtual address for"
225 dev_priv->ring.virtual_start = dev_priv->ring.map.handle;
227 dev_priv->cpp = init->cpp;
229 if (dev_priv->sarea_priv)
230 dev_priv->sarea_priv->pf_current_page = 0;
232 /* We are using separate values as placeholders for mechanisms for
233 * private backbuffer/depthbuffer usage.
235 dev_priv->use_mi_batchbuffer_start = 0;
236 if (IS_I965G(dev)) /* 965 doesn't support older method */
237 dev_priv->use_mi_batchbuffer_start = 1;
239 /* Allow hardware batchbuffers unless told otherwise.
241 dev_priv->allow_batchbuffer = 1;
243 /* Enable vblank on pipe A for older X servers
245 dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A;
247 /* Program Hardware Status Page */
249 dev_priv->status_page_dmah =
250 drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff);
252 if (!dev_priv->status_page_dmah) {
253 i915_dma_cleanup(dev);
254 DRM_ERROR("Can not allocate hardware status page\n");
257 dev_priv->hw_status_page = dev_priv->status_page_dmah->vaddr;
258 dev_priv->dma_status_page = dev_priv->status_page_dmah->busaddr;
260 memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
262 I915_WRITE(0x02080, dev_priv->dma_status_page);
264 DRM_DEBUG("Enabled hardware status page\n");
265 #ifdef I915_HAVE_BUFFER
266 mutex_init(&dev_priv->cmdbuf_mutex);
269 if (init->func == I915_INIT_DMA2) {
270 ret = setup_dri2_sarea(dev, file_priv, init);
272 i915_dma_cleanup(dev);
273 DRM_ERROR("could not set up dri2 sarea\n");
282 static int i915_dma_resume(struct drm_device * dev)
284 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
288 if (!dev_priv->sarea) {
289 DRM_ERROR("can not find sarea!\n");
293 if (!dev_priv->mmio_map) {
294 DRM_ERROR("can not find mmio map!\n");
298 if (dev_priv->ring.map.handle == NULL) {
299 DRM_ERROR("can not ioremap virtual address for"
304 /* Program Hardware Status Page */
305 if (!dev_priv->hw_status_page) {
306 DRM_ERROR("Can not find hardware status page\n");
309 DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page);
311 if (dev_priv->status_gfx_addr != 0)
312 I915_WRITE(0x02080, dev_priv->status_gfx_addr);
314 I915_WRITE(0x02080, dev_priv->dma_status_page);
315 DRM_DEBUG("Enabled hardware status page\n");
320 static int i915_dma_init(struct drm_device *dev, void *data,
321 struct drm_file *file_priv)
323 drm_i915_init_t *init = data;
326 switch (init->func) {
329 retcode = i915_initialize(dev, file_priv, init);
331 case I915_CLEANUP_DMA:
332 retcode = i915_dma_cleanup(dev);
334 case I915_RESUME_DMA:
335 retcode = i915_dma_resume(dev);
345 /* Implement basically the same security restrictions as hardware does
346 * for MI_BATCH_NON_SECURE. These can be made stricter at any time.
348 * Most of the calculations below involve calculating the size of a
349 * particular instruction. It's important to get the size right as
350 * that tells us where the next instruction to check is. Any illegal
351 * instruction detected will be given a size of zero, which is a
352 * signal to abort the rest of the buffer.
354 static int do_validate_cmd(int cmd)
356 switch (((cmd >> 29) & 0x7)) {
358 switch ((cmd >> 23) & 0x3f) {
360 return 1; /* MI_NOOP */
362 return 1; /* MI_FLUSH */
364 return 0; /* disallow everything else */
368 return 0; /* reserved */
370 return (cmd & 0xff) + 2; /* 2d commands */
372 if (((cmd >> 24) & 0x1f) <= 0x18)
375 switch ((cmd >> 24) & 0x1f) {
379 switch ((cmd >> 16) & 0xff) {
381 return (cmd & 0x1f) + 2;
383 return (cmd & 0xf) + 2;
385 return (cmd & 0xffff) + 2;
389 return (cmd & 0xffff) + 1;
393 if ((cmd & (1 << 23)) == 0) /* inline vertices */
394 return (cmd & 0x1ffff) + 2;
395 else if (cmd & (1 << 17)) /* indirect random */
396 if ((cmd & 0xffff) == 0)
397 return 0; /* unknown length, too hard */
399 return (((cmd & 0xffff) + 1) / 2) + 1;
401 return 2; /* indirect sequential */
412 static int validate_cmd(int cmd)
414 int ret = do_validate_cmd(cmd);
416 /* printk("validate_cmd( %x ): %d\n", cmd, ret); */
421 static int i915_emit_cmds(struct drm_device *dev, int __user *buffer,
424 drm_i915_private_t *dev_priv = dev->dev_private;
428 if ((dwords+1) * sizeof(int) >= dev_priv->ring.Size - 8)
431 BEGIN_LP_RING((dwords+1)&~1);
433 for (i = 0; i < dwords;) {
436 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd)))
439 if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords)
445 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i],
461 static int i915_emit_box(struct drm_device * dev,
462 struct drm_clip_rect __user * boxes,
463 int i, int DR1, int DR4)
465 drm_i915_private_t *dev_priv = dev->dev_private;
466 struct drm_clip_rect box;
469 if (DRM_COPY_FROM_USER_UNCHECKED(&box, &boxes[i], sizeof(box))) {
473 if (box.y2 <= box.y1 || box.x2 <= box.x1 || box.y2 <= 0 || box.x2 <= 0) {
474 DRM_ERROR("Bad box %d,%d..%d,%d\n",
475 box.x1, box.y1, box.x2, box.y2);
481 OUT_RING(GFX_OP_DRAWRECT_INFO_I965);
482 OUT_RING((box.x1 & 0xffff) | (box.y1 << 16));
483 OUT_RING(((box.x2 - 1) & 0xffff) | ((box.y2 - 1) << 16));
488 OUT_RING(GFX_OP_DRAWRECT_INFO);
490 OUT_RING((box.x1 & 0xffff) | (box.y1 << 16));
491 OUT_RING(((box.x2 - 1) & 0xffff) | ((box.y2 - 1) << 16));
500 /* XXX: Emitting the counter should really be moved to part of the IRQ
501 * emit. For now, do it in both places:
504 void i915_emit_breadcrumb(struct drm_device *dev)
506 drm_i915_private_t *dev_priv = dev->dev_private;
509 if (++dev_priv->counter > BREADCRUMB_MASK) {
510 dev_priv->counter = 1;
511 DRM_DEBUG("Breadcrumb counter wrapped around\n");
514 if (dev_priv->sarea_priv)
515 dev_priv->sarea_priv->last_enqueue = dev_priv->counter;
518 OUT_RING(CMD_STORE_DWORD_IDX);
520 OUT_RING(dev_priv->counter);
526 int i915_emit_mi_flush(struct drm_device *dev, uint32_t flush)
528 drm_i915_private_t *dev_priv = dev->dev_private;
529 uint32_t flush_cmd = CMD_MI_FLUSH;
534 i915_kernel_lost_context(dev);
547 static int i915_dispatch_cmdbuffer(struct drm_device * dev,
548 drm_i915_cmdbuffer_t * cmd)
550 #ifdef I915_HAVE_FENCE
551 drm_i915_private_t *dev_priv = dev->dev_private;
553 int nbox = cmd->num_cliprects;
554 int i = 0, count, ret;
557 DRM_ERROR("alignment\n");
561 i915_kernel_lost_context(dev);
563 count = nbox ? nbox : 1;
565 for (i = 0; i < count; i++) {
567 ret = i915_emit_box(dev, cmd->cliprects, i,
573 ret = i915_emit_cmds(dev, (int __user *)cmd->buf, cmd->sz / 4);
578 i915_emit_breadcrumb(dev);
579 #ifdef I915_HAVE_FENCE
580 if (unlikely((dev_priv->counter & 0xFF) == 0))
581 drm_fence_flush_old(dev, 0, dev_priv->counter);
586 static int i915_dispatch_batchbuffer(struct drm_device * dev,
587 drm_i915_batchbuffer_t * batch)
589 drm_i915_private_t *dev_priv = dev->dev_private;
590 struct drm_clip_rect __user *boxes = batch->cliprects;
591 int nbox = batch->num_cliprects;
595 if ((batch->start | batch->used) & 0x7) {
596 DRM_ERROR("alignment\n");
600 i915_kernel_lost_context(dev);
602 count = nbox ? nbox : 1;
604 for (i = 0; i < count; i++) {
606 int ret = i915_emit_box(dev, boxes, i,
607 batch->DR1, batch->DR4);
612 if (dev_priv->use_mi_batchbuffer_start) {
615 OUT_RING(MI_BATCH_BUFFER_START | (2 << 6) | MI_BATCH_NON_SECURE_I965);
616 OUT_RING(batch->start);
618 OUT_RING(MI_BATCH_BUFFER_START | (2 << 6));
619 OUT_RING(batch->start | MI_BATCH_NON_SECURE);
625 OUT_RING(MI_BATCH_BUFFER);
626 OUT_RING(batch->start | MI_BATCH_NON_SECURE);
627 OUT_RING(batch->start + batch->used - 4);
633 i915_emit_breadcrumb(dev);
634 #ifdef I915_HAVE_FENCE
635 if (unlikely((dev_priv->counter & 0xFF) == 0))
636 drm_fence_flush_old(dev, 0, dev_priv->counter);
641 static void i915_do_dispatch_flip(struct drm_device * dev, int plane, int sync)
643 drm_i915_private_t *dev_priv = dev->dev_private;
644 u32 num_pages, current_page, next_page, dspbase;
645 int shift = 2 * plane, x, y;
648 /* Calculate display base offset */
649 num_pages = dev_priv->sarea_priv->third_handle ? 3 : 2;
650 current_page = (dev_priv->sarea_priv->pf_current_page >> shift) & 0x3;
651 next_page = (current_page + 1) % num_pages;
656 dspbase = dev_priv->sarea_priv->front_offset;
659 dspbase = dev_priv->sarea_priv->back_offset;
662 dspbase = dev_priv->sarea_priv->third_offset;
667 x = dev_priv->sarea_priv->planeA_x;
668 y = dev_priv->sarea_priv->planeA_y;
670 x = dev_priv->sarea_priv->planeB_x;
671 y = dev_priv->sarea_priv->planeB_y;
674 dspbase += (y * dev_priv->sarea_priv->pitch + x) * dev_priv->cpp;
676 DRM_DEBUG("plane=%d current_page=%d dspbase=0x%x\n", plane, current_page,
681 (MI_WAIT_FOR_EVENT | (plane ? MI_WAIT_FOR_PLANE_B_FLIP :
682 MI_WAIT_FOR_PLANE_A_FLIP)));
683 OUT_RING(CMD_OP_DISPLAYBUFFER_INFO | (sync ? 0 : ASYNC_FLIP) |
684 (plane ? DISPLAY_PLANE_B : DISPLAY_PLANE_A));
685 OUT_RING(dev_priv->sarea_priv->pitch * dev_priv->cpp);
689 dev_priv->sarea_priv->pf_current_page &= ~(0x3 << shift);
690 dev_priv->sarea_priv->pf_current_page |= next_page << shift;
693 void i915_dispatch_flip(struct drm_device * dev, int planes, int sync)
695 drm_i915_private_t *dev_priv = dev->dev_private;
698 DRM_DEBUG("planes=0x%x pfCurrentPage=%d\n",
699 planes, dev_priv->sarea_priv->pf_current_page);
701 i915_emit_mi_flush(dev, MI_READ_FLUSH | MI_EXE_FLUSH);
703 for (i = 0; i < 2; i++)
704 if (planes & (1 << i))
705 i915_do_dispatch_flip(dev, i, sync);
707 i915_emit_breadcrumb(dev);
708 #ifdef I915_HAVE_FENCE
709 if (unlikely(!sync && ((dev_priv->counter & 0xFF) == 0)))
710 drm_fence_flush_old(dev, 0, dev_priv->counter);
714 static int i915_quiescent(struct drm_device *dev)
716 drm_i915_private_t *dev_priv = dev->dev_private;
718 i915_kernel_lost_context(dev);
719 return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__);
722 static int i915_flush_ioctl(struct drm_device *dev, void *data,
723 struct drm_file *file_priv)
726 LOCK_TEST_WITH_RETURN(dev, file_priv);
728 return i915_quiescent(dev);
731 static int i915_batchbuffer(struct drm_device *dev, void *data,
732 struct drm_file *file_priv)
734 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
735 drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
736 dev_priv->sarea_priv;
737 drm_i915_batchbuffer_t *batch = data;
740 if (!dev_priv->allow_batchbuffer) {
741 DRM_ERROR("Batchbuffer ioctl disabled\n");
745 DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n",
746 batch->start, batch->used, batch->num_cliprects);
748 LOCK_TEST_WITH_RETURN(dev, file_priv);
750 if (batch->num_cliprects && DRM_VERIFYAREA_READ(batch->cliprects,
751 batch->num_cliprects *
752 sizeof(struct drm_clip_rect)))
755 ret = i915_dispatch_batchbuffer(dev, batch);
757 sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
761 static int i915_cmdbuffer(struct drm_device *dev, void *data,
762 struct drm_file *file_priv)
764 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
765 drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
766 dev_priv->sarea_priv;
767 drm_i915_cmdbuffer_t *cmdbuf = data;
770 DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n",
771 cmdbuf->buf, cmdbuf->sz, cmdbuf->num_cliprects);
773 LOCK_TEST_WITH_RETURN(dev, file_priv);
775 if (cmdbuf->num_cliprects &&
776 DRM_VERIFYAREA_READ(cmdbuf->cliprects,
777 cmdbuf->num_cliprects *
778 sizeof(struct drm_clip_rect))) {
779 DRM_ERROR("Fault accessing cliprects\n");
783 ret = i915_dispatch_cmdbuffer(dev, cmdbuf);
785 DRM_ERROR("i915_dispatch_cmdbuffer failed\n");
789 sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
794 #define DRM_DEBUG_RELOCATION (drm_debug != 0)
796 #define DRM_DEBUG_RELOCATION 0
799 #ifdef I915_HAVE_BUFFER
801 struct i915_relocatee_info {
802 struct drm_buffer_object *buf;
803 unsigned long offset;
805 unsigned page_offset;
806 struct drm_bo_kmap_obj kmap;
812 struct drm_i915_validate_buffer {
813 struct drm_buffer_object *buffer;
814 struct drm_bo_info_rep rep;
815 int presumed_offset_correct;
820 static void i915_dereference_buffers_locked(struct drm_i915_validate_buffer *buffers,
821 unsigned num_buffers)
823 while (num_buffers--)
824 drm_bo_usage_deref_locked(&buffers[num_buffers].buffer);
827 int i915_apply_reloc(struct drm_file *file_priv, int num_buffers,
828 struct drm_i915_validate_buffer *buffers,
829 struct i915_relocatee_info *relocatee,
833 unsigned long new_cmd_offset;
839 * FIXME: O(relocs * buffers) complexity.
842 for (i = 0; i <= num_buffers; i++)
843 if (buffers[i].buffer)
844 if (reloc[2] == buffers[i].buffer->base.hash.key)
847 if (buf_index == -1) {
848 DRM_ERROR("Illegal relocation buffer %08X\n", reloc[2]);
853 * Short-circuit relocations that were correctly
854 * guessed by the client
856 if (buffers[buf_index].presumed_offset_correct && !DRM_DEBUG_RELOCATION)
859 new_cmd_offset = reloc[0];
860 if (!relocatee->data_page ||
861 !drm_bo_same_page(relocatee->offset, new_cmd_offset)) {
862 drm_bo_kunmap(&relocatee->kmap);
863 relocatee->data_page = NULL;
864 relocatee->offset = new_cmd_offset;
866 if (unlikely(!relocatee->idle)) {
867 ret = drm_bo_wait(relocatee->buf, 0, 0, 0);
873 ret = drm_bo_kmap(relocatee->buf, new_cmd_offset >> PAGE_SHIFT,
874 1, &relocatee->kmap);
876 DRM_ERROR("Could not map command buffer to apply relocs\n %08lx", new_cmd_offset);
879 relocatee->data_page = drm_bmo_virtual(&relocatee->kmap,
880 &relocatee->is_iomem);
881 relocatee->page_offset = (relocatee->offset & PAGE_MASK);
883 if (!relocatee->evicted &&
884 relocatee->buf->mem.flags & DRM_BO_FLAG_CACHED_MAPPED) {
885 drm_bo_evict_cached(relocatee->buf);
886 relocatee->evicted = 1;
890 val = buffers[buf_index].buffer->offset;
891 index = (reloc[0] - relocatee->page_offset) >> 2;
893 /* add in validate */
894 val = val + reloc[1];
896 if (DRM_DEBUG_RELOCATION) {
897 if (buffers[buf_index].presumed_offset_correct &&
898 relocatee->data_page[index] != val) {
899 DRM_DEBUG ("Relocation mismatch source %d target %d buffer %d user %08x kernel %08x\n",
900 reloc[0], reloc[1], buf_index, relocatee->data_page[index], val);
904 if (relocatee->is_iomem)
905 iowrite32(val, relocatee->data_page + index);
907 relocatee->data_page[index] = val;
911 int i915_process_relocs(struct drm_file *file_priv,
913 uint32_t __user **reloc_user_ptr,
914 struct i915_relocatee_info *relocatee,
915 struct drm_i915_validate_buffer *buffers,
916 uint32_t num_buffers)
918 int ret, reloc_stride;
920 uint32_t reloc_count;
922 uint32_t reloc_buf_size;
923 uint32_t *reloc_buf = NULL;
926 /* do a copy from user from the user ptr */
927 ret = get_user(reloc_count, *reloc_user_ptr);
929 DRM_ERROR("Could not map relocation buffer.\n");
933 ret = get_user(reloc_type, (*reloc_user_ptr)+1);
935 DRM_ERROR("Could not map relocation buffer.\n");
939 if (reloc_type != 0) {
940 DRM_ERROR("Unsupported relocation type requested\n");
945 reloc_buf_size = (I915_RELOC_HEADER + (reloc_count * I915_RELOC0_STRIDE)) * sizeof(uint32_t);
946 reloc_buf = kmalloc(reloc_buf_size, GFP_KERNEL);
948 DRM_ERROR("Out of memory for reloc buffer\n");
953 if (copy_from_user(reloc_buf, *reloc_user_ptr, reloc_buf_size)) {
958 /* get next relocate buffer handle */
959 *reloc_user_ptr = (uint32_t *)*(unsigned long *)&reloc_buf[2];
961 reloc_stride = I915_RELOC0_STRIDE * sizeof(uint32_t); /* may be different for other types of relocs */
963 DRM_DEBUG("num relocs is %d, next is %p\n", reloc_count, *reloc_user_ptr);
965 for (i = 0; i < reloc_count; i++) {
966 cur_offset = I915_RELOC_HEADER + (i * I915_RELOC0_STRIDE);
968 ret = i915_apply_reloc(file_priv, num_buffers, buffers,
969 relocatee, reloc_buf + cur_offset);
978 if (relocatee->data_page) {
979 drm_bo_kunmap(&relocatee->kmap);
980 relocatee->data_page = NULL;
986 static int i915_exec_reloc(struct drm_file *file_priv, drm_handle_t buf_handle,
987 uint32_t __user *reloc_user_ptr,
988 struct drm_i915_validate_buffer *buffers,
991 struct drm_device *dev = file_priv->minor->dev;
992 struct i915_relocatee_info relocatee;
997 * Short circuit relocations when all previous
998 * buffers offsets were correctly guessed by
1001 if (!DRM_DEBUG_RELOCATION) {
1002 for (b = 0; b < buf_count; b++)
1003 if (!buffers[b].presumed_offset_correct)
1010 memset(&relocatee, 0, sizeof(relocatee));
1012 mutex_lock(&dev->struct_mutex);
1013 relocatee.buf = drm_lookup_buffer_object(file_priv, buf_handle, 1);
1014 mutex_unlock(&dev->struct_mutex);
1015 if (!relocatee.buf) {
1016 DRM_DEBUG("relocatee buffer invalid %08x\n", buf_handle);
1021 mutex_lock (&relocatee.buf->mutex);
1022 while (reloc_user_ptr) {
1023 ret = i915_process_relocs(file_priv, buf_handle, &reloc_user_ptr, &relocatee, buffers, buf_count);
1025 DRM_ERROR("process relocs failed\n");
1031 mutex_unlock (&relocatee.buf->mutex);
1032 drm_bo_usage_deref_unlocked(&relocatee.buf);
1037 static int i915_check_presumed(struct drm_i915_op_arg *arg,
1038 struct drm_buffer_object *bo,
1039 uint32_t __user *data,
1042 struct drm_bo_op_req *req = &arg->d.req;
1043 uint32_t hint_offset;
1044 uint32_t hint = req->bo_req.hint;
1048 if (!(hint & DRM_BO_HINT_PRESUMED_OFFSET))
1050 if (bo->offset == req->bo_req.presumed_offset) {
1056 * We need to turn off the HINT_PRESUMED_OFFSET for this buffer in
1057 * the user-space IOCTL argument list, since the buffer has moved,
1058 * we're about to apply relocations and we might subsequently
1059 * hit an -EAGAIN. In that case the argument list will be reused by
1060 * user-space, but the presumed offset is no longer valid.
1062 * Needless to say, this is a bit ugly.
1065 hint_offset = (uint32_t *)&req->bo_req.hint - (uint32_t *)arg;
1066 hint &= ~DRM_BO_HINT_PRESUMED_OFFSET;
1067 return __put_user(hint, data + hint_offset);
1072 * Validate, add fence and relocate a block of bos from a userspace list
1074 int i915_validate_buffer_list(struct drm_file *file_priv,
1075 unsigned int fence_class, uint64_t data,
1076 struct drm_i915_validate_buffer *buffers,
1077 uint32_t *num_buffers)
1079 struct drm_i915_op_arg arg;
1080 struct drm_bo_op_req *req = &arg.d.req;
1082 unsigned buf_count = 0;
1083 uint32_t buf_handle;
1084 uint32_t __user *reloc_user_ptr;
1085 struct drm_i915_validate_buffer *item = buffers;
1088 if (buf_count >= *num_buffers) {
1089 DRM_ERROR("Buffer count exceeded %d\n.", *num_buffers);
1093 item = buffers + buf_count;
1094 item->buffer = NULL;
1095 item->presumed_offset_correct = 0;
1097 buffers[buf_count].buffer = NULL;
1099 if (copy_from_user(&arg, (void __user *)(unsigned long)data, sizeof(arg))) {
1105 if (req->op != drm_bo_validate) {
1107 ("Buffer object operation wasn't \"validate\".\n");
1112 item->data = (void __user *) (unsigned long) data;
1114 buf_handle = req->bo_req.handle;
1115 reloc_user_ptr = (uint32_t *)(unsigned long)arg.reloc_ptr;
1117 if (reloc_user_ptr) {
1118 ret = i915_exec_reloc(file_priv, buf_handle, reloc_user_ptr, buffers, buf_count);
1121 DRM_MEMORYBARRIER();
1124 ret = drm_bo_handle_validate(file_priv, req->bo_req.handle,
1125 req->bo_req.flags, req->bo_req.mask,
1127 req->bo_req.fence_class, 0,
1132 DRM_ERROR("error on handle validate %d\n", ret);
1138 ret = i915_check_presumed(&arg, item->buffer,
1140 (unsigned long) data,
1141 &item->presumed_offset_correct);
1146 } while (data != 0);
1148 *num_buffers = buf_count;
1149 item->ret = (ret != -EAGAIN) ? ret : 0;
1155 * Remove all buffers from the unfenced list.
1156 * If the execbuffer operation was aborted, for example due to a signal,
1157 * this also make sure that buffers retain their original state and
1159 * Copy back buffer information to user-space unless we were interrupted
1160 * by a signal. In which case the IOCTL must be rerun.
1163 static int i915_handle_copyback(struct drm_device *dev,
1164 struct drm_i915_validate_buffer *buffers,
1165 unsigned int num_buffers, int ret)
1169 struct drm_i915_op_arg arg;
1172 drm_putback_buffer_objects(dev);
1174 if (ret != -EAGAIN) {
1175 for (i = 0; i < num_buffers; ++i) {
1177 arg.d.rep.ret = buffers->ret;
1178 arg.d.rep.bo_info = buffers->rep;
1179 if (__copy_to_user(buffers->data, &arg, sizeof(arg)))
1188 * Create a fence object, and if that fails, pretend that everything is
1189 * OK and just idle the GPU.
1192 void i915_fence_or_sync(struct drm_file *file_priv,
1193 uint32_t fence_flags,
1194 struct drm_fence_arg *fence_arg,
1195 struct drm_fence_object **fence_p)
1197 struct drm_device *dev = file_priv->minor->dev;
1199 struct drm_fence_object *fence;
1201 ret = drm_fence_buffer_objects(dev, NULL, fence_flags,
1207 * Fence creation failed.
1208 * Fall back to synchronous operation and idle the engine.
1211 (void) i915_emit_mi_flush(dev, MI_READ_FLUSH);
1212 (void) i915_quiescent(dev);
1214 if (!(fence_flags & DRM_FENCE_FLAG_NO_USER)) {
1217 * Communicate to user-space that
1218 * fence creation has failed and that
1219 * the engine is idle.
1222 fence_arg->handle = ~0;
1223 fence_arg->error = ret;
1226 drm_putback_buffer_objects(dev);
1232 if (!(fence_flags & DRM_FENCE_FLAG_NO_USER)) {
1234 ret = drm_fence_add_user_object(file_priv, fence,
1236 DRM_FENCE_FLAG_SHAREABLE);
1238 drm_fence_fill_arg(fence, fence_arg);
1241 * Fence user object creation failed.
1242 * We must idle the engine here as well, as user-
1243 * space expects a fence object to wait on. Since we
1244 * have a fence object we wait for it to signal
1245 * to indicate engine "sufficiently" idle.
1248 (void) drm_fence_object_wait(fence, 0, 1,
1250 drm_fence_usage_deref_unlocked(&fence);
1251 fence_arg->handle = ~0;
1252 fence_arg->error = ret;
1259 drm_fence_usage_deref_unlocked(&fence);
1263 static int i915_execbuffer(struct drm_device *dev, void *data,
1264 struct drm_file *file_priv)
1266 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
1267 drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
1268 dev_priv->sarea_priv;
1269 struct drm_i915_execbuffer *exec_buf = data;
1270 struct drm_i915_batchbuffer *batch = &exec_buf->batch;
1271 struct drm_fence_arg *fence_arg = &exec_buf->fence_arg;
1275 if (!dev_priv->allow_batchbuffer) {
1276 DRM_ERROR("Batchbuffer ioctl disabled\n");
1281 if (batch->num_cliprects && DRM_VERIFYAREA_READ(batch->cliprects,
1282 batch->num_cliprects *
1283 sizeof(struct drm_clip_rect)))
1286 if (exec_buf->num_buffers > dev_priv->max_validate_buffers)
1289 ret = drm_bo_read_lock(&dev->bm.bm_lock);
1294 * The cmdbuf_mutex makes sure the validate-submit-fence
1295 * operation is atomic.
1298 ret = mutex_lock_interruptible(&dev_priv->cmdbuf_mutex);
1300 drm_bo_read_unlock(&dev->bm.bm_lock);
1304 num_buffers = exec_buf->num_buffers;
1306 if (!dev_priv->val_bufs) {
1307 dev_priv->val_bufs =
1308 vmalloc(sizeof(struct drm_i915_validate_buffer)*
1309 dev_priv->max_validate_buffers);
1311 if (!dev_priv->val_bufs) {
1312 drm_bo_read_unlock(&dev->bm.bm_lock);
1313 mutex_unlock(&dev_priv->cmdbuf_mutex);
1317 /* validate buffer list + fixup relocations */
1318 ret = i915_validate_buffer_list(file_priv, 0, exec_buf->ops_list,
1319 dev_priv->val_bufs, &num_buffers);
1323 /* make sure all previous memory operations have passed */
1324 DRM_MEMORYBARRIER();
1325 drm_agp_chipset_flush(dev);
1328 batch->start = dev_priv->val_bufs[num_buffers-1].buffer->offset;
1330 DRM_DEBUG("i915 exec batchbuffer, start %x used %d cliprects %d\n",
1331 batch->start, batch->used, batch->num_cliprects);
1333 ret = i915_dispatch_batchbuffer(dev, batch);
1338 sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
1340 i915_fence_or_sync(file_priv, fence_arg->flags, fence_arg, NULL);
1345 ret = i915_handle_copyback(dev, dev_priv->val_bufs, num_buffers, ret);
1346 mutex_lock(&dev->struct_mutex);
1347 i915_dereference_buffers_locked(dev_priv->val_bufs, num_buffers);
1348 mutex_unlock(&dev->struct_mutex);
1350 mutex_unlock(&dev_priv->cmdbuf_mutex);
1351 drm_bo_read_unlock(&dev->bm.bm_lock);
1356 static int i915_do_cleanup_pageflip(struct drm_device * dev)
1358 drm_i915_private_t *dev_priv = dev->dev_private;
1359 int i, planes, num_pages = dev_priv->sarea_priv->third_handle ? 3 : 2;
1363 for (i = 0, planes = 0; i < 2; i++)
1364 if (dev_priv->sarea_priv->pf_current_page & (0x3 << (2 * i))) {
1365 dev_priv->sarea_priv->pf_current_page =
1366 (dev_priv->sarea_priv->pf_current_page &
1367 ~(0x3 << (2 * i))) | ((num_pages - 1) << (2 * i));
1373 i915_dispatch_flip(dev, planes, 0);
1378 static int i915_flip_bufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
1380 drm_i915_flip_t *param = data;
1384 LOCK_TEST_WITH_RETURN(dev, file_priv);
1386 /* This is really planes */
1387 if (param->pipes & ~0x3) {
1388 DRM_ERROR("Invalid planes 0x%x, only <= 0x3 is valid\n",
1393 i915_dispatch_flip(dev, param->pipes, 0);
1399 static int i915_getparam(struct drm_device *dev, void *data,
1400 struct drm_file *file_priv)
1402 drm_i915_private_t *dev_priv = dev->dev_private;
1403 drm_i915_getparam_t *param = data;
1407 DRM_ERROR("called with no initialization\n");
1411 switch (param->param) {
1412 case I915_PARAM_IRQ_ACTIVE:
1413 value = dev->irq ? 1 : 0;
1415 case I915_PARAM_ALLOW_BATCHBUFFER:
1416 value = dev_priv->allow_batchbuffer ? 1 : 0;
1418 case I915_PARAM_LAST_DISPATCH:
1419 value = READ_BREADCRUMB(dev_priv);
1421 case I915_PARAM_CHIPSET_ID:
1422 value = dev->pci_device;
1425 DRM_ERROR("Unknown parameter %d\n", param->param);
1429 if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) {
1430 DRM_ERROR("DRM_COPY_TO_USER failed\n");
1437 static int i915_setparam(struct drm_device *dev, void *data,
1438 struct drm_file *file_priv)
1440 drm_i915_private_t *dev_priv = dev->dev_private;
1441 drm_i915_setparam_t *param = data;
1444 DRM_ERROR("called with no initialization\n");
1448 switch (param->param) {
1449 case I915_SETPARAM_USE_MI_BATCHBUFFER_START:
1451 dev_priv->use_mi_batchbuffer_start = param->value;
1453 case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY:
1454 dev_priv->tex_lru_log_granularity = param->value;
1456 case I915_SETPARAM_ALLOW_BATCHBUFFER:
1457 dev_priv->allow_batchbuffer = param->value;
1460 DRM_ERROR("unknown parameter %d\n", param->param);
1467 drm_i915_mmio_entry_t mmio_table[] = {
1468 [MMIO_REGS_PS_DEPTH_COUNT] = {
1469 I915_MMIO_MAY_READ|I915_MMIO_MAY_WRITE,
1475 static int mmio_table_size = sizeof(mmio_table)/sizeof(drm_i915_mmio_entry_t);
1477 static int i915_mmio(struct drm_device *dev, void *data,
1478 struct drm_file *file_priv)
1481 drm_i915_private_t *dev_priv = dev->dev_private;
1482 drm_i915_mmio_entry_t *e;
1483 drm_i915_mmio_t *mmio = data;
1488 DRM_ERROR("called with no initialization\n");
1492 if (mmio->reg >= mmio_table_size)
1495 e = &mmio_table[mmio->reg];
1496 base = (u8 *) dev_priv->mmio_map->handle + e->offset;
1498 switch (mmio->read_write) {
1499 case I915_MMIO_READ:
1500 if (!(e->flag & I915_MMIO_MAY_READ))
1502 for (i = 0; i < e->size / 4; i++)
1503 buf[i] = I915_READ(e->offset + i * 4);
1504 if (DRM_COPY_TO_USER(mmio->data, buf, e->size)) {
1505 DRM_ERROR("DRM_COPY_TO_USER failed\n");
1510 case I915_MMIO_WRITE:
1511 if (!(e->flag & I915_MMIO_MAY_WRITE))
1513 if (DRM_COPY_FROM_USER(buf, mmio->data, e->size)) {
1514 DRM_ERROR("DRM_COPY_TO_USER failed\n");
1517 for (i = 0; i < e->size / 4; i++)
1518 I915_WRITE(e->offset + i * 4, buf[i]);
1524 static int i915_set_status_page(struct drm_device *dev, void *data,
1525 struct drm_file *file_priv)
1527 drm_i915_private_t *dev_priv = dev->dev_private;
1528 drm_i915_hws_addr_t *hws = data;
1531 DRM_ERROR("called with no initialization\n");
1534 DRM_DEBUG("set status page addr 0x%08x\n", (u32)hws->addr);
1536 dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12);
1538 dev_priv->hws_map.offset = dev->agp->base + hws->addr;
1539 dev_priv->hws_map.size = 4*1024;
1540 dev_priv->hws_map.type = 0;
1541 dev_priv->hws_map.flags = 0;
1542 dev_priv->hws_map.mtrr = 0;
1544 drm_core_ioremap(&dev_priv->hws_map, dev);
1545 if (dev_priv->hws_map.handle == NULL) {
1546 i915_dma_cleanup(dev);
1547 dev_priv->status_gfx_addr = 0;
1548 DRM_ERROR("can not ioremap virtual address for"
1549 " G33 hw status page\n");
1552 dev_priv->hw_status_page = dev_priv->hws_map.handle;
1554 memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
1555 I915_WRITE(0x02080, dev_priv->status_gfx_addr);
1556 DRM_DEBUG("load hws 0x2080 with gfx mem 0x%x\n",
1557 dev_priv->status_gfx_addr);
1558 DRM_DEBUG("load hws at %p\n", dev_priv->hw_status_page);
1562 int i915_driver_load(struct drm_device *dev, unsigned long flags)
1564 struct drm_i915_private *dev_priv = dev->dev_private;
1565 unsigned long base, size;
1566 int ret = 0, mmio_bar = IS_I9XX(dev) ? 0 : 1;
1568 /* i915 has 4 more counters */
1570 dev->types[6] = _DRM_STAT_IRQ;
1571 dev->types[7] = _DRM_STAT_PRIMARY;
1572 dev->types[8] = _DRM_STAT_SECONDARY;
1573 dev->types[9] = _DRM_STAT_DMA;
1575 dev_priv = drm_alloc(sizeof(drm_i915_private_t), DRM_MEM_DRIVER);
1576 if (dev_priv == NULL)
1579 memset(dev_priv, 0, sizeof(drm_i915_private_t));
1581 dev->dev_private = (void *)dev_priv;
1583 /* Add register map (needed for suspend/resume) */
1584 base = drm_get_resource_start(dev, mmio_bar);
1585 size = drm_get_resource_len(dev, mmio_bar);
1587 ret = drm_addmap(dev, base, size, _DRM_REGISTERS,
1588 _DRM_KERNEL | _DRM_DRIVER, &dev_priv->mmio_map);
1591 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
1592 intel_init_chipset_flush_compat(dev);
1599 int i915_driver_unload(struct drm_device *dev)
1601 struct drm_i915_private *dev_priv = dev->dev_private;
1603 if (dev_priv->mmio_map)
1604 drm_rmmap(dev, dev_priv->mmio_map);
1606 drm_free(dev->dev_private, sizeof(drm_i915_private_t),
1609 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
1610 intel_fini_chipset_flush_compat(dev);
1616 void i915_driver_lastclose(struct drm_device * dev)
1618 drm_i915_private_t *dev_priv = dev->dev_private;
1620 #ifdef I915_HAVE_BUFFER
1621 if (dev_priv->val_bufs) {
1622 vfree(dev_priv->val_bufs);
1623 dev_priv->val_bufs = NULL;
1627 if (drm_getsarea(dev) && dev_priv->sarea_priv)
1628 i915_do_cleanup_pageflip(dev);
1629 if (dev_priv->agp_heap)
1630 i915_mem_takedown(&(dev_priv->agp_heap));
1632 if (dev_priv->sarea_kmap.virtual) {
1633 drm_bo_kunmap(&dev_priv->sarea_kmap);
1634 dev_priv->sarea_kmap.virtual = NULL;
1635 dev->lock.hw_lock = NULL;
1636 dev->sigdata.lock = NULL;
1639 if (dev_priv->sarea_bo) {
1640 mutex_lock(&dev->struct_mutex);
1641 drm_bo_usage_deref_locked(&dev_priv->sarea_bo);
1642 mutex_unlock(&dev->struct_mutex);
1643 dev_priv->sarea_bo = NULL;
1646 i915_dma_cleanup(dev);
1649 void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
1651 drm_i915_private_t *dev_priv = dev->dev_private;
1652 i915_mem_release(dev, file_priv, dev_priv->agp_heap);
1655 struct drm_ioctl_desc i915_ioctls[] = {
1656 DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1657 DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH),
1658 DRM_IOCTL_DEF(DRM_I915_FLIP, i915_flip_bufs, DRM_AUTH),
1659 DRM_IOCTL_DEF(DRM_I915_BATCHBUFFER, i915_batchbuffer, DRM_AUTH),
1660 DRM_IOCTL_DEF(DRM_I915_IRQ_EMIT, i915_irq_emit, DRM_AUTH),
1661 DRM_IOCTL_DEF(DRM_I915_IRQ_WAIT, i915_irq_wait, DRM_AUTH),
1662 DRM_IOCTL_DEF(DRM_I915_GETPARAM, i915_getparam, DRM_AUTH),
1663 DRM_IOCTL_DEF(DRM_I915_SETPARAM, i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1664 DRM_IOCTL_DEF(DRM_I915_ALLOC, i915_mem_alloc, DRM_AUTH),
1665 DRM_IOCTL_DEF(DRM_I915_FREE, i915_mem_free, DRM_AUTH),
1666 DRM_IOCTL_DEF(DRM_I915_INIT_HEAP, i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1667 DRM_IOCTL_DEF(DRM_I915_CMDBUFFER, i915_cmdbuffer, DRM_AUTH),
1668 DRM_IOCTL_DEF(DRM_I915_DESTROY_HEAP, i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ),
1669 DRM_IOCTL_DEF(DRM_I915_SET_VBLANK_PIPE, i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ),
1670 DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ),
1671 DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH),
1672 DRM_IOCTL_DEF(DRM_I915_MMIO, i915_mmio, DRM_AUTH),
1673 DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH),
1674 #ifdef I915_HAVE_BUFFER
1675 DRM_IOCTL_DEF(DRM_I915_EXECBUFFER, i915_execbuffer, DRM_AUTH),
1679 int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
1682 * Determine if the device really is AGP or not.
1684 * All Intel graphics chipsets are treated as AGP, even if they are really
1687 * \param dev The device to be tested.
1690 * A value of 1 is always retured to indictate every i9x5 is AGP.
1692 int i915_driver_device_is_agp(struct drm_device * dev)
1697 int i915_driver_firstopen(struct drm_device *dev)
1699 #ifdef I915_HAVE_BUFFER
1700 drm_bo_driver_init(dev);