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.
31 #include "drm_crtc_helper.h"
32 #include "drm_fb_helper.h"
33 #include "intel_drv.h"
36 #include "i915_trace.h"
37 #include <linux/vgaarb.h>
39 /* Really want an OS-independent resettable timer. Would like to have
40 * this loop run for (eg) 3 sec, but have the timer reset every time
41 * the head pointer changes, so that EBUSY only happens if the ring
42 * actually stalls for (eg) 3 seconds.
44 int i915_wait_ring(struct drm_device * dev, int n, const char *caller)
46 drm_i915_private_t *dev_priv = dev->dev_private;
47 drm_i915_ring_buffer_t *ring = &(dev_priv->ring);
48 u32 acthd_reg = IS_I965G(dev) ? ACTHD_I965 : ACTHD;
49 u32 last_acthd = I915_READ(acthd_reg);
51 u32 last_head = I915_READ(PRB0_HEAD) & HEAD_ADDR;
54 trace_i915_ring_wait_begin (dev);
56 for (i = 0; i < 100000; i++) {
57 ring->head = I915_READ(PRB0_HEAD) & HEAD_ADDR;
58 acthd = I915_READ(acthd_reg);
59 ring->space = ring->head - (ring->tail + 8);
61 ring->space += ring->Size;
62 if (ring->space >= n) {
63 trace_i915_ring_wait_end (dev);
67 if (dev->primary->master) {
68 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
69 if (master_priv->sarea_priv)
70 master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
74 if (ring->head != last_head)
76 if (acthd != last_acthd)
79 last_head = ring->head;
81 msleep_interruptible(10);
85 trace_i915_ring_wait_end (dev);
89 /* As a ringbuffer is only allowed to wrap between instructions, fill
90 * the tail with NOOPs.
92 int i915_wrap_ring(struct drm_device *dev)
94 drm_i915_private_t *dev_priv = dev->dev_private;
95 volatile unsigned int *virt;
98 rem = dev_priv->ring.Size - dev_priv->ring.tail;
99 if (dev_priv->ring.space < rem) {
100 int ret = i915_wait_ring(dev, rem, __func__);
104 dev_priv->ring.space -= rem;
106 virt = (unsigned int *)
107 (dev_priv->ring.virtual_start + dev_priv->ring.tail);
112 dev_priv->ring.tail = 0;
118 * Sets up the hardware status page for devices that need a physical address
121 static int i915_init_phys_hws(struct drm_device *dev)
123 drm_i915_private_t *dev_priv = dev->dev_private;
124 /* Program Hardware Status Page */
125 dev_priv->status_page_dmah =
126 drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff);
128 if (!dev_priv->status_page_dmah) {
129 DRM_ERROR("Can not allocate hardware status page\n");
132 dev_priv->hw_status_page = dev_priv->status_page_dmah->vaddr;
133 dev_priv->dma_status_page = dev_priv->status_page_dmah->busaddr;
135 memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
137 I915_WRITE(HWS_PGA, dev_priv->dma_status_page);
138 DRM_DEBUG_DRIVER("Enabled hardware status page\n");
143 * Frees the hardware status page, whether it's a physical address or a virtual
144 * address set up by the X Server.
146 static void i915_free_hws(struct drm_device *dev)
148 drm_i915_private_t *dev_priv = dev->dev_private;
149 if (dev_priv->status_page_dmah) {
150 drm_pci_free(dev, dev_priv->status_page_dmah);
151 dev_priv->status_page_dmah = NULL;
154 if (dev_priv->status_gfx_addr) {
155 dev_priv->status_gfx_addr = 0;
156 drm_core_ioremapfree(&dev_priv->hws_map, dev);
159 /* Need to rewrite hardware status page */
160 I915_WRITE(HWS_PGA, 0x1ffff000);
163 void i915_kernel_lost_context(struct drm_device * dev)
165 drm_i915_private_t *dev_priv = dev->dev_private;
166 struct drm_i915_master_private *master_priv;
167 drm_i915_ring_buffer_t *ring = &(dev_priv->ring);
170 * We should never lose context on the ring with modesetting
171 * as we don't expose it to userspace
173 if (drm_core_check_feature(dev, DRIVER_MODESET))
176 ring->head = I915_READ(PRB0_HEAD) & HEAD_ADDR;
177 ring->tail = I915_READ(PRB0_TAIL) & TAIL_ADDR;
178 ring->space = ring->head - (ring->tail + 8);
180 ring->space += ring->Size;
182 if (!dev->primary->master)
185 master_priv = dev->primary->master->driver_priv;
186 if (ring->head == ring->tail && master_priv->sarea_priv)
187 master_priv->sarea_priv->perf_boxes |= I915_BOX_RING_EMPTY;
190 static int i915_dma_cleanup(struct drm_device * dev)
192 drm_i915_private_t *dev_priv = dev->dev_private;
193 /* Make sure interrupts are disabled here because the uninstall ioctl
194 * may not have been called from userspace and after dev_private
195 * is freed, it's too late.
197 if (dev->irq_enabled)
198 drm_irq_uninstall(dev);
200 if (dev_priv->ring.virtual_start) {
201 drm_core_ioremapfree(&dev_priv->ring.map, dev);
202 dev_priv->ring.virtual_start = NULL;
203 dev_priv->ring.map.handle = NULL;
204 dev_priv->ring.map.size = 0;
207 /* Clear the HWS virtual address at teardown */
208 if (I915_NEED_GFX_HWS(dev))
214 static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
216 drm_i915_private_t *dev_priv = dev->dev_private;
217 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
219 master_priv->sarea = drm_getsarea(dev);
220 if (master_priv->sarea) {
221 master_priv->sarea_priv = (drm_i915_sarea_t *)
222 ((u8 *)master_priv->sarea->handle + init->sarea_priv_offset);
224 DRM_DEBUG_DRIVER("sarea not found assuming DRI2 userspace\n");
227 if (init->ring_size != 0) {
228 if (dev_priv->ring.ring_obj != NULL) {
229 i915_dma_cleanup(dev);
230 DRM_ERROR("Client tried to initialize ringbuffer in "
235 dev_priv->ring.Size = init->ring_size;
237 dev_priv->ring.map.offset = init->ring_start;
238 dev_priv->ring.map.size = init->ring_size;
239 dev_priv->ring.map.type = 0;
240 dev_priv->ring.map.flags = 0;
241 dev_priv->ring.map.mtrr = 0;
243 drm_core_ioremap_wc(&dev_priv->ring.map, dev);
245 if (dev_priv->ring.map.handle == NULL) {
246 i915_dma_cleanup(dev);
247 DRM_ERROR("can not ioremap virtual address for"
253 dev_priv->ring.virtual_start = dev_priv->ring.map.handle;
255 dev_priv->cpp = init->cpp;
256 dev_priv->back_offset = init->back_offset;
257 dev_priv->front_offset = init->front_offset;
258 dev_priv->current_page = 0;
259 if (master_priv->sarea_priv)
260 master_priv->sarea_priv->pf_current_page = 0;
262 /* Allow hardware batchbuffers unless told otherwise.
264 dev_priv->allow_batchbuffer = 1;
269 static int i915_dma_resume(struct drm_device * dev)
271 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
273 DRM_DEBUG_DRIVER("%s\n", __func__);
275 if (dev_priv->ring.map.handle == NULL) {
276 DRM_ERROR("can not ioremap virtual address for"
281 /* Program Hardware Status Page */
282 if (!dev_priv->hw_status_page) {
283 DRM_ERROR("Can not find hardware status page\n");
286 DRM_DEBUG_DRIVER("hw status page @ %p\n",
287 dev_priv->hw_status_page);
289 if (dev_priv->status_gfx_addr != 0)
290 I915_WRITE(HWS_PGA, dev_priv->status_gfx_addr);
292 I915_WRITE(HWS_PGA, dev_priv->dma_status_page);
293 DRM_DEBUG_DRIVER("Enabled hardware status page\n");
298 static int i915_dma_init(struct drm_device *dev, void *data,
299 struct drm_file *file_priv)
301 drm_i915_init_t *init = data;
304 switch (init->func) {
306 retcode = i915_initialize(dev, init);
308 case I915_CLEANUP_DMA:
309 retcode = i915_dma_cleanup(dev);
311 case I915_RESUME_DMA:
312 retcode = i915_dma_resume(dev);
322 /* Implement basically the same security restrictions as hardware does
323 * for MI_BATCH_NON_SECURE. These can be made stricter at any time.
325 * Most of the calculations below involve calculating the size of a
326 * particular instruction. It's important to get the size right as
327 * that tells us where the next instruction to check is. Any illegal
328 * instruction detected will be given a size of zero, which is a
329 * signal to abort the rest of the buffer.
331 static int do_validate_cmd(int cmd)
333 switch (((cmd >> 29) & 0x7)) {
335 switch ((cmd >> 23) & 0x3f) {
337 return 1; /* MI_NOOP */
339 return 1; /* MI_FLUSH */
341 return 0; /* disallow everything else */
345 return 0; /* reserved */
347 return (cmd & 0xff) + 2; /* 2d commands */
349 if (((cmd >> 24) & 0x1f) <= 0x18)
352 switch ((cmd >> 24) & 0x1f) {
356 switch ((cmd >> 16) & 0xff) {
358 return (cmd & 0x1f) + 2;
360 return (cmd & 0xf) + 2;
362 return (cmd & 0xffff) + 2;
366 return (cmd & 0xffff) + 1;
370 if ((cmd & (1 << 23)) == 0) /* inline vertices */
371 return (cmd & 0x1ffff) + 2;
372 else if (cmd & (1 << 17)) /* indirect random */
373 if ((cmd & 0xffff) == 0)
374 return 0; /* unknown length, too hard */
376 return (((cmd & 0xffff) + 1) / 2) + 1;
378 return 2; /* indirect sequential */
389 static int validate_cmd(int cmd)
391 int ret = do_validate_cmd(cmd);
393 /* printk("validate_cmd( %x ): %d\n", cmd, ret); */
398 static int i915_emit_cmds(struct drm_device * dev, int *buffer, int dwords)
400 drm_i915_private_t *dev_priv = dev->dev_private;
404 if ((dwords+1) * sizeof(int) >= dev_priv->ring.Size - 8)
407 BEGIN_LP_RING((dwords+1)&~1);
409 for (i = 0; i < dwords;) {
414 if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords)
433 i915_emit_box(struct drm_device *dev,
434 struct drm_clip_rect *boxes,
435 int i, int DR1, int DR4)
437 drm_i915_private_t *dev_priv = dev->dev_private;
438 struct drm_clip_rect box = boxes[i];
441 if (box.y2 <= box.y1 || box.x2 <= box.x1 || box.y2 <= 0 || box.x2 <= 0) {
442 DRM_ERROR("Bad box %d,%d..%d,%d\n",
443 box.x1, box.y1, box.x2, box.y2);
449 OUT_RING(GFX_OP_DRAWRECT_INFO_I965);
450 OUT_RING((box.x1 & 0xffff) | (box.y1 << 16));
451 OUT_RING(((box.x2 - 1) & 0xffff) | ((box.y2 - 1) << 16));
456 OUT_RING(GFX_OP_DRAWRECT_INFO);
458 OUT_RING((box.x1 & 0xffff) | (box.y1 << 16));
459 OUT_RING(((box.x2 - 1) & 0xffff) | ((box.y2 - 1) << 16));
468 /* XXX: Emitting the counter should really be moved to part of the IRQ
469 * emit. For now, do it in both places:
472 static void i915_emit_breadcrumb(struct drm_device *dev)
474 drm_i915_private_t *dev_priv = dev->dev_private;
475 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
479 if (dev_priv->counter > 0x7FFFFFFFUL)
480 dev_priv->counter = 0;
481 if (master_priv->sarea_priv)
482 master_priv->sarea_priv->last_enqueue = dev_priv->counter;
485 OUT_RING(MI_STORE_DWORD_INDEX);
486 OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
487 OUT_RING(dev_priv->counter);
492 static int i915_dispatch_cmdbuffer(struct drm_device * dev,
493 drm_i915_cmdbuffer_t *cmd,
494 struct drm_clip_rect *cliprects,
497 int nbox = cmd->num_cliprects;
498 int i = 0, count, ret;
501 DRM_ERROR("alignment");
505 i915_kernel_lost_context(dev);
507 count = nbox ? nbox : 1;
509 for (i = 0; i < count; i++) {
511 ret = i915_emit_box(dev, cliprects, i,
517 ret = i915_emit_cmds(dev, cmdbuf, cmd->sz / 4);
522 i915_emit_breadcrumb(dev);
526 static int i915_dispatch_batchbuffer(struct drm_device * dev,
527 drm_i915_batchbuffer_t * batch,
528 struct drm_clip_rect *cliprects)
530 drm_i915_private_t *dev_priv = dev->dev_private;
531 int nbox = batch->num_cliprects;
535 if ((batch->start | batch->used) & 0x7) {
536 DRM_ERROR("alignment");
540 i915_kernel_lost_context(dev);
542 count = nbox ? nbox : 1;
544 for (i = 0; i < count; i++) {
546 int ret = i915_emit_box(dev, cliprects, i,
547 batch->DR1, batch->DR4);
552 if (!IS_I830(dev) && !IS_845G(dev)) {
555 OUT_RING(MI_BATCH_BUFFER_START | (2 << 6) | MI_BATCH_NON_SECURE_I965);
556 OUT_RING(batch->start);
558 OUT_RING(MI_BATCH_BUFFER_START | (2 << 6));
559 OUT_RING(batch->start | MI_BATCH_NON_SECURE);
564 OUT_RING(MI_BATCH_BUFFER);
565 OUT_RING(batch->start | MI_BATCH_NON_SECURE);
566 OUT_RING(batch->start + batch->used - 4);
572 i915_emit_breadcrumb(dev);
577 static int i915_dispatch_flip(struct drm_device * dev)
579 drm_i915_private_t *dev_priv = dev->dev_private;
580 struct drm_i915_master_private *master_priv =
581 dev->primary->master->driver_priv;
584 if (!master_priv->sarea_priv)
587 DRM_DEBUG_DRIVER("%s: page=%d pfCurrentPage=%d\n",
589 dev_priv->current_page,
590 master_priv->sarea_priv->pf_current_page);
592 i915_kernel_lost_context(dev);
595 OUT_RING(MI_FLUSH | MI_READ_FLUSH);
600 OUT_RING(CMD_OP_DISPLAYBUFFER_INFO | ASYNC_FLIP);
602 if (dev_priv->current_page == 0) {
603 OUT_RING(dev_priv->back_offset);
604 dev_priv->current_page = 1;
606 OUT_RING(dev_priv->front_offset);
607 dev_priv->current_page = 0;
613 OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_A_FLIP);
617 master_priv->sarea_priv->last_enqueue = dev_priv->counter++;
620 OUT_RING(MI_STORE_DWORD_INDEX);
621 OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
622 OUT_RING(dev_priv->counter);
626 master_priv->sarea_priv->pf_current_page = dev_priv->current_page;
630 static int i915_quiescent(struct drm_device * dev)
632 drm_i915_private_t *dev_priv = dev->dev_private;
634 i915_kernel_lost_context(dev);
635 return i915_wait_ring(dev, dev_priv->ring.Size - 8, __func__);
638 static int i915_flush_ioctl(struct drm_device *dev, void *data,
639 struct drm_file *file_priv)
643 RING_LOCK_TEST_WITH_RETURN(dev, file_priv);
645 mutex_lock(&dev->struct_mutex);
646 ret = i915_quiescent(dev);
647 mutex_unlock(&dev->struct_mutex);
652 static int i915_batchbuffer(struct drm_device *dev, void *data,
653 struct drm_file *file_priv)
655 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
656 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
657 drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
658 master_priv->sarea_priv;
659 drm_i915_batchbuffer_t *batch = data;
661 struct drm_clip_rect *cliprects = NULL;
663 if (!dev_priv->allow_batchbuffer) {
664 DRM_ERROR("Batchbuffer ioctl disabled\n");
668 DRM_DEBUG_DRIVER("i915 batchbuffer, start %x used %d cliprects %d\n",
669 batch->start, batch->used, batch->num_cliprects);
671 RING_LOCK_TEST_WITH_RETURN(dev, file_priv);
673 if (batch->num_cliprects < 0)
676 if (batch->num_cliprects) {
677 cliprects = kcalloc(batch->num_cliprects,
678 sizeof(struct drm_clip_rect),
680 if (cliprects == NULL)
683 ret = copy_from_user(cliprects, batch->cliprects,
684 batch->num_cliprects *
685 sizeof(struct drm_clip_rect));
690 mutex_lock(&dev->struct_mutex);
691 ret = i915_dispatch_batchbuffer(dev, batch, cliprects);
692 mutex_unlock(&dev->struct_mutex);
695 sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
703 static int i915_cmdbuffer(struct drm_device *dev, void *data,
704 struct drm_file *file_priv)
706 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
707 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
708 drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
709 master_priv->sarea_priv;
710 drm_i915_cmdbuffer_t *cmdbuf = data;
711 struct drm_clip_rect *cliprects = NULL;
715 DRM_DEBUG_DRIVER("i915 cmdbuffer, buf %p sz %d cliprects %d\n",
716 cmdbuf->buf, cmdbuf->sz, cmdbuf->num_cliprects);
718 RING_LOCK_TEST_WITH_RETURN(dev, file_priv);
720 if (cmdbuf->num_cliprects < 0)
723 batch_data = kmalloc(cmdbuf->sz, GFP_KERNEL);
724 if (batch_data == NULL)
727 ret = copy_from_user(batch_data, cmdbuf->buf, cmdbuf->sz);
729 goto fail_batch_free;
731 if (cmdbuf->num_cliprects) {
732 cliprects = kcalloc(cmdbuf->num_cliprects,
733 sizeof(struct drm_clip_rect), GFP_KERNEL);
734 if (cliprects == NULL)
735 goto fail_batch_free;
737 ret = copy_from_user(cliprects, cmdbuf->cliprects,
738 cmdbuf->num_cliprects *
739 sizeof(struct drm_clip_rect));
744 mutex_lock(&dev->struct_mutex);
745 ret = i915_dispatch_cmdbuffer(dev, cmdbuf, cliprects, batch_data);
746 mutex_unlock(&dev->struct_mutex);
748 DRM_ERROR("i915_dispatch_cmdbuffer failed\n");
753 sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
763 static int i915_flip_bufs(struct drm_device *dev, void *data,
764 struct drm_file *file_priv)
768 DRM_DEBUG_DRIVER("%s\n", __func__);
770 RING_LOCK_TEST_WITH_RETURN(dev, file_priv);
772 mutex_lock(&dev->struct_mutex);
773 ret = i915_dispatch_flip(dev);
774 mutex_unlock(&dev->struct_mutex);
779 static int i915_getparam(struct drm_device *dev, void *data,
780 struct drm_file *file_priv)
782 drm_i915_private_t *dev_priv = dev->dev_private;
783 drm_i915_getparam_t *param = data;
787 DRM_ERROR("called with no initialization\n");
791 switch (param->param) {
792 case I915_PARAM_IRQ_ACTIVE:
793 value = dev->pdev->irq ? 1 : 0;
795 case I915_PARAM_ALLOW_BATCHBUFFER:
796 value = dev_priv->allow_batchbuffer ? 1 : 0;
798 case I915_PARAM_LAST_DISPATCH:
799 value = READ_BREADCRUMB(dev_priv);
801 case I915_PARAM_CHIPSET_ID:
802 value = dev->pci_device;
804 case I915_PARAM_HAS_GEM:
805 value = dev_priv->has_gem;
807 case I915_PARAM_NUM_FENCES_AVAIL:
808 value = dev_priv->num_fence_regs - dev_priv->fence_reg_start;
810 case I915_PARAM_HAS_OVERLAY:
811 value = dev_priv->overlay ? 1 : 0;
814 DRM_DEBUG_DRIVER("Unknown parameter %d\n",
819 if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) {
820 DRM_ERROR("DRM_COPY_TO_USER failed\n");
827 static int i915_setparam(struct drm_device *dev, void *data,
828 struct drm_file *file_priv)
830 drm_i915_private_t *dev_priv = dev->dev_private;
831 drm_i915_setparam_t *param = data;
834 DRM_ERROR("called with no initialization\n");
838 switch (param->param) {
839 case I915_SETPARAM_USE_MI_BATCHBUFFER_START:
841 case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY:
842 dev_priv->tex_lru_log_granularity = param->value;
844 case I915_SETPARAM_ALLOW_BATCHBUFFER:
845 dev_priv->allow_batchbuffer = param->value;
847 case I915_SETPARAM_NUM_USED_FENCES:
848 if (param->value > dev_priv->num_fence_regs ||
851 /* Userspace can use first N regs */
852 dev_priv->fence_reg_start = param->value;
855 DRM_DEBUG_DRIVER("unknown parameter %d\n",
863 static int i915_set_status_page(struct drm_device *dev, void *data,
864 struct drm_file *file_priv)
866 drm_i915_private_t *dev_priv = dev->dev_private;
867 drm_i915_hws_addr_t *hws = data;
869 if (!I915_NEED_GFX_HWS(dev))
873 DRM_ERROR("called with no initialization\n");
877 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
878 WARN(1, "tried to set status page when mode setting active\n");
882 DRM_DEBUG_DRIVER("set status page addr 0x%08x\n", (u32)hws->addr);
884 dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12);
886 dev_priv->hws_map.offset = dev->agp->base + hws->addr;
887 dev_priv->hws_map.size = 4*1024;
888 dev_priv->hws_map.type = 0;
889 dev_priv->hws_map.flags = 0;
890 dev_priv->hws_map.mtrr = 0;
892 drm_core_ioremap_wc(&dev_priv->hws_map, dev);
893 if (dev_priv->hws_map.handle == NULL) {
894 i915_dma_cleanup(dev);
895 dev_priv->status_gfx_addr = 0;
896 DRM_ERROR("can not ioremap virtual address for"
897 " G33 hw status page\n");
900 dev_priv->hw_status_page = dev_priv->hws_map.handle;
902 memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
903 I915_WRITE(HWS_PGA, dev_priv->status_gfx_addr);
904 DRM_DEBUG_DRIVER("load hws HWS_PGA with gfx mem 0x%x\n",
905 dev_priv->status_gfx_addr);
906 DRM_DEBUG_DRIVER("load hws at %p\n",
907 dev_priv->hw_status_page);
911 static int i915_get_bridge_dev(struct drm_device *dev)
913 struct drm_i915_private *dev_priv = dev->dev_private;
915 dev_priv->bridge_dev = pci_get_bus_and_slot(0, PCI_DEVFN(0,0));
916 if (!dev_priv->bridge_dev) {
917 DRM_ERROR("bridge device not found\n");
924 * i915_probe_agp - get AGP bootup configuration
926 * @aperture_size: returns AGP aperture configured size
927 * @preallocated_size: returns size of BIOS preallocated AGP space
929 * Since Intel integrated graphics are UMA, the BIOS has to set aside
930 * some RAM for the framebuffer at early boot. This code figures out
931 * how much was set aside so we can use it for our own purposes.
933 static int i915_probe_agp(struct drm_device *dev, uint32_t *aperture_size,
934 uint32_t *preallocated_size,
937 struct drm_i915_private *dev_priv = dev->dev_private;
939 unsigned long overhead;
940 unsigned long stolen;
942 /* Get the fb aperture size and "stolen" memory amount. */
943 pci_read_config_word(dev_priv->bridge_dev, INTEL_GMCH_CTRL, &tmp);
945 *aperture_size = 1024 * 1024;
946 *preallocated_size = 1024 * 1024;
948 switch (dev->pdev->device) {
949 case PCI_DEVICE_ID_INTEL_82830_CGC:
950 case PCI_DEVICE_ID_INTEL_82845G_IG:
951 case PCI_DEVICE_ID_INTEL_82855GM_IG:
952 case PCI_DEVICE_ID_INTEL_82865_IG:
953 if ((tmp & INTEL_GMCH_MEM_MASK) == INTEL_GMCH_MEM_64M)
954 *aperture_size *= 64;
956 *aperture_size *= 128;
959 /* 9xx supports large sizes, just look at the length */
960 *aperture_size = pci_resource_len(dev->pdev, 2);
965 * Some of the preallocated space is taken by the GTT
966 * and popup. GTT is 1K per MB of aperture size, and popup is 4K.
968 if (IS_G4X(dev) || IS_IGD(dev) || IS_IGDNG(dev))
971 overhead = (*aperture_size / 1024) + 4096;
973 switch (tmp & INTEL_GMCH_GMS_MASK) {
974 case INTEL_855_GMCH_GMS_DISABLED:
975 DRM_ERROR("video memory is disabled\n");
977 case INTEL_855_GMCH_GMS_STOLEN_1M:
978 stolen = 1 * 1024 * 1024;
980 case INTEL_855_GMCH_GMS_STOLEN_4M:
981 stolen = 4 * 1024 * 1024;
983 case INTEL_855_GMCH_GMS_STOLEN_8M:
984 stolen = 8 * 1024 * 1024;
986 case INTEL_855_GMCH_GMS_STOLEN_16M:
987 stolen = 16 * 1024 * 1024;
989 case INTEL_855_GMCH_GMS_STOLEN_32M:
990 stolen = 32 * 1024 * 1024;
992 case INTEL_915G_GMCH_GMS_STOLEN_48M:
993 stolen = 48 * 1024 * 1024;
995 case INTEL_915G_GMCH_GMS_STOLEN_64M:
996 stolen = 64 * 1024 * 1024;
998 case INTEL_GMCH_GMS_STOLEN_128M:
999 stolen = 128 * 1024 * 1024;
1001 case INTEL_GMCH_GMS_STOLEN_256M:
1002 stolen = 256 * 1024 * 1024;
1004 case INTEL_GMCH_GMS_STOLEN_96M:
1005 stolen = 96 * 1024 * 1024;
1007 case INTEL_GMCH_GMS_STOLEN_160M:
1008 stolen = 160 * 1024 * 1024;
1010 case INTEL_GMCH_GMS_STOLEN_224M:
1011 stolen = 224 * 1024 * 1024;
1013 case INTEL_GMCH_GMS_STOLEN_352M:
1014 stolen = 352 * 1024 * 1024;
1017 DRM_ERROR("unexpected GMCH_GMS value: 0x%02x\n",
1018 tmp & INTEL_GMCH_GMS_MASK);
1021 *preallocated_size = stolen - overhead;
1027 #define PTE_ADDRESS_MASK 0xfffff000
1028 #define PTE_ADDRESS_MASK_HIGH 0x000000f0 /* i915+ */
1029 #define PTE_MAPPING_TYPE_UNCACHED (0 << 1)
1030 #define PTE_MAPPING_TYPE_DCACHE (1 << 1) /* i830 only */
1031 #define PTE_MAPPING_TYPE_CACHED (3 << 1)
1032 #define PTE_MAPPING_TYPE_MASK (3 << 1)
1033 #define PTE_VALID (1 << 0)
1036 * i915_gtt_to_phys - take a GTT address and turn it into a physical one
1038 * @gtt_addr: address to translate
1040 * Some chip functions require allocations from stolen space but need the
1041 * physical address of the memory in question. We use this routine
1042 * to get a physical address suitable for register programming from a given
1045 static unsigned long i915_gtt_to_phys(struct drm_device *dev,
1046 unsigned long gtt_addr)
1049 unsigned long entry, phys;
1050 int gtt_bar = IS_I9XX(dev) ? 0 : 1;
1051 int gtt_offset, gtt_size;
1053 if (IS_I965G(dev)) {
1054 if (IS_G4X(dev) || IS_IGDNG(dev)) {
1055 gtt_offset = 2*1024*1024;
1056 gtt_size = 2*1024*1024;
1058 gtt_offset = 512*1024;
1059 gtt_size = 512*1024;
1064 gtt_size = pci_resource_len(dev->pdev, gtt_bar);
1067 gtt = ioremap_wc(pci_resource_start(dev->pdev, gtt_bar) + gtt_offset,
1070 DRM_ERROR("ioremap of GTT failed\n");
1074 entry = *(volatile u32 *)(gtt + (gtt_addr / 1024));
1076 DRM_DEBUG("GTT addr: 0x%08lx, PTE: 0x%08lx\n", gtt_addr, entry);
1078 /* Mask out these reserved bits on this hardware. */
1079 if (!IS_I9XX(dev) || IS_I915G(dev) || IS_I915GM(dev) ||
1080 IS_I945G(dev) || IS_I945GM(dev)) {
1081 entry &= ~PTE_ADDRESS_MASK_HIGH;
1084 /* If it's not a mapping type we know, then bail. */
1085 if ((entry & PTE_MAPPING_TYPE_MASK) != PTE_MAPPING_TYPE_UNCACHED &&
1086 (entry & PTE_MAPPING_TYPE_MASK) != PTE_MAPPING_TYPE_CACHED) {
1091 if (!(entry & PTE_VALID)) {
1092 DRM_ERROR("bad GTT entry in stolen space\n");
1099 phys =(entry & PTE_ADDRESS_MASK) |
1100 ((uint64_t)(entry & PTE_ADDRESS_MASK_HIGH) << (32 - 4));
1102 DRM_DEBUG("GTT addr: 0x%08lx, phys addr: 0x%08lx\n", gtt_addr, phys);
1107 static void i915_warn_stolen(struct drm_device *dev)
1109 DRM_ERROR("not enough stolen space for compressed buffer, disabling\n");
1110 DRM_ERROR("hint: you may be able to increase stolen memory size in the BIOS to avoid this\n");
1113 static void i915_setup_compression(struct drm_device *dev, int size)
1115 struct drm_i915_private *dev_priv = dev->dev_private;
1116 struct drm_mm_node *compressed_fb, *compressed_llb;
1117 unsigned long cfb_base, ll_base;
1119 /* Leave 1M for line length buffer & misc. */
1120 compressed_fb = drm_mm_search_free(&dev_priv->vram, size, 4096, 0);
1121 if (!compressed_fb) {
1122 i915_warn_stolen(dev);
1126 compressed_fb = drm_mm_get_block(compressed_fb, size, 4096);
1127 if (!compressed_fb) {
1128 i915_warn_stolen(dev);
1132 cfb_base = i915_gtt_to_phys(dev, compressed_fb->start);
1134 DRM_ERROR("failed to get stolen phys addr, disabling FBC\n");
1135 drm_mm_put_block(compressed_fb);
1138 if (!IS_GM45(dev)) {
1139 compressed_llb = drm_mm_search_free(&dev_priv->vram, 4096,
1141 if (!compressed_llb) {
1142 i915_warn_stolen(dev);
1146 compressed_llb = drm_mm_get_block(compressed_llb, 4096, 4096);
1147 if (!compressed_llb) {
1148 i915_warn_stolen(dev);
1152 ll_base = i915_gtt_to_phys(dev, compressed_llb->start);
1154 DRM_ERROR("failed to get stolen phys addr, disabling FBC\n");
1155 drm_mm_put_block(compressed_fb);
1156 drm_mm_put_block(compressed_llb);
1160 dev_priv->cfb_size = size;
1163 g4x_disable_fbc(dev);
1164 I915_WRITE(DPFC_CB_BASE, compressed_fb->start);
1166 i8xx_disable_fbc(dev);
1167 I915_WRITE(FBC_CFB_BASE, cfb_base);
1168 I915_WRITE(FBC_LL_BASE, ll_base);
1171 DRM_DEBUG("FBC base 0x%08lx, ll base 0x%08lx, size %dM\n", cfb_base,
1172 ll_base, size >> 20);
1175 /* true = enable decode, false = disable decoder */
1176 static unsigned int i915_vga_set_decode(void *cookie, bool state)
1178 struct drm_device *dev = cookie;
1180 intel_modeset_vga_set_state(dev, state);
1182 return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
1183 VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
1185 return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
1188 static int i915_load_modeset_init(struct drm_device *dev,
1189 unsigned long prealloc_start,
1190 unsigned long prealloc_size,
1191 unsigned long agp_size)
1193 struct drm_i915_private *dev_priv = dev->dev_private;
1194 int fb_bar = IS_I9XX(dev) ? 2 : 0;
1197 dev->mode_config.fb_base = drm_get_resource_start(dev, fb_bar) &
1200 if (IS_MOBILE(dev) || IS_I9XX(dev))
1201 dev_priv->cursor_needs_physical = true;
1203 dev_priv->cursor_needs_physical = false;
1205 if (IS_I965G(dev) || IS_G33(dev))
1206 dev_priv->cursor_needs_physical = false;
1208 /* Basic memrange allocator for stolen space (aka vram) */
1209 drm_mm_init(&dev_priv->vram, 0, prealloc_size);
1210 DRM_INFO("set up %ldM of stolen space\n", prealloc_size / (1024*1024));
1212 /* We're off and running w/KMS */
1213 dev_priv->mm.suspended = 0;
1215 /* Let GEM Manage from end of prealloc space to end of aperture.
1217 * However, leave one page at the end still bound to the scratch page.
1218 * There are a number of places where the hardware apparently
1219 * prefetches past the end of the object, and we've seen multiple
1220 * hangs with the GPU head pointer stuck in a batchbuffer bound
1221 * at the last page of the aperture. One page should be enough to
1222 * keep any prefetching inside of the aperture.
1224 i915_gem_do_init(dev, prealloc_size, agp_size - 4096);
1226 mutex_lock(&dev->struct_mutex);
1227 ret = i915_gem_init_ringbuffer(dev);
1228 mutex_unlock(&dev->struct_mutex);
1232 /* Try to set up FBC with a reasonable compressed buffer size */
1233 if (I915_HAS_FBC(dev) && i915_powersave) {
1236 /* Try to get an 8M buffer... */
1237 if (prealloc_size > (9*1024*1024))
1238 cfb_size = 8*1024*1024;
1239 else /* fall back to 7/8 of the stolen space */
1240 cfb_size = prealloc_size * 7 / 8;
1241 i915_setup_compression(dev, cfb_size);
1244 /* Allow hardware batchbuffers unless told otherwise.
1246 dev_priv->allow_batchbuffer = 1;
1248 ret = intel_init_bios(dev);
1250 DRM_INFO("failed to find VBIOS tables\n");
1252 /* if we have > 1 VGA cards, then disable the radeon VGA resources */
1253 ret = vga_client_register(dev->pdev, dev, NULL, i915_vga_set_decode);
1255 goto destroy_ringbuffer;
1257 ret = drm_irq_install(dev);
1259 goto destroy_ringbuffer;
1261 /* Always safe in the mode setting case. */
1262 /* FIXME: do pre/post-mode set stuff in core KMS code */
1263 dev->vblank_disable_allowed = 1;
1266 * Initialize the hardware status page IRQ location.
1269 I915_WRITE(INSTPM, (1 << 5) | (1 << 21));
1271 intel_modeset_init(dev);
1273 drm_helper_initial_config(dev);
1278 i915_gem_cleanup_ringbuffer(dev);
1283 int i915_master_create(struct drm_device *dev, struct drm_master *master)
1285 struct drm_i915_master_private *master_priv;
1287 master_priv = kzalloc(sizeof(*master_priv), GFP_KERNEL);
1291 master->driver_priv = master_priv;
1295 void i915_master_destroy(struct drm_device *dev, struct drm_master *master)
1297 struct drm_i915_master_private *master_priv = master->driver_priv;
1304 master->driver_priv = NULL;
1307 static void i915_get_mem_freq(struct drm_device *dev)
1309 drm_i915_private_t *dev_priv = dev->dev_private;
1315 tmp = I915_READ(CLKCFG);
1317 switch (tmp & CLKCFG_FSB_MASK) {
1318 case CLKCFG_FSB_533:
1319 dev_priv->fsb_freq = 533; /* 133*4 */
1321 case CLKCFG_FSB_800:
1322 dev_priv->fsb_freq = 800; /* 200*4 */
1324 case CLKCFG_FSB_667:
1325 dev_priv->fsb_freq = 667; /* 167*4 */
1327 case CLKCFG_FSB_400:
1328 dev_priv->fsb_freq = 400; /* 100*4 */
1332 switch (tmp & CLKCFG_MEM_MASK) {
1333 case CLKCFG_MEM_533:
1334 dev_priv->mem_freq = 533;
1336 case CLKCFG_MEM_667:
1337 dev_priv->mem_freq = 667;
1339 case CLKCFG_MEM_800:
1340 dev_priv->mem_freq = 800;
1346 * i915_driver_load - setup chip and create an initial config
1348 * @flags: startup flags
1350 * The driver load routine has to do several things:
1351 * - drive output discovery via intel_modeset_init()
1352 * - initialize the memory manager
1353 * - allocate initial config memory
1354 * - setup the DRM framebuffer with the allocated memory
1356 int i915_driver_load(struct drm_device *dev, unsigned long flags)
1358 struct drm_i915_private *dev_priv = dev->dev_private;
1359 resource_size_t base, size;
1360 int ret = 0, mmio_bar = IS_I9XX(dev) ? 0 : 1;
1361 uint32_t agp_size, prealloc_size, prealloc_start;
1363 /* i915 has 4 more counters */
1365 dev->types[6] = _DRM_STAT_IRQ;
1366 dev->types[7] = _DRM_STAT_PRIMARY;
1367 dev->types[8] = _DRM_STAT_SECONDARY;
1368 dev->types[9] = _DRM_STAT_DMA;
1370 dev_priv = kzalloc(sizeof(drm_i915_private_t), GFP_KERNEL);
1371 if (dev_priv == NULL)
1374 dev->dev_private = (void *)dev_priv;
1375 dev_priv->dev = dev;
1377 /* Add register map (needed for suspend/resume) */
1378 base = drm_get_resource_start(dev, mmio_bar);
1379 size = drm_get_resource_len(dev, mmio_bar);
1381 if (i915_get_bridge_dev(dev)) {
1386 dev_priv->regs = ioremap(base, size);
1387 if (!dev_priv->regs) {
1388 DRM_ERROR("failed to map registers\n");
1393 dev_priv->mm.gtt_mapping =
1394 io_mapping_create_wc(dev->agp->base,
1395 dev->agp->agp_info.aper_size * 1024*1024);
1396 if (dev_priv->mm.gtt_mapping == NULL) {
1401 /* Set up a WC MTRR for non-PAT systems. This is more common than
1402 * one would think, because the kernel disables PAT on first
1403 * generation Core chips because WC PAT gets overridden by a UC
1404 * MTRR if present. Even if a UC MTRR isn't present.
1406 dev_priv->mm.gtt_mtrr = mtrr_add(dev->agp->base,
1407 dev->agp->agp_info.aper_size *
1409 MTRR_TYPE_WRCOMB, 1);
1410 if (dev_priv->mm.gtt_mtrr < 0) {
1411 DRM_INFO("MTRR allocation failed. Graphics "
1412 "performance may suffer.\n");
1415 ret = i915_probe_agp(dev, &agp_size, &prealloc_size, &prealloc_start);
1419 dev_priv->wq = create_workqueue("i915");
1420 if (dev_priv->wq == NULL) {
1421 DRM_ERROR("Failed to create our workqueue.\n");
1426 /* enable GEM by default */
1427 dev_priv->has_gem = 1;
1429 if (prealloc_size > agp_size * 3 / 4) {
1430 DRM_ERROR("Detected broken video BIOS with %d/%dkB of video "
1432 prealloc_size / 1024, agp_size / 1024);
1433 DRM_ERROR("Disabling GEM. (try reducing stolen memory or "
1434 "updating the BIOS to fix).\n");
1435 dev_priv->has_gem = 0;
1438 dev->driver->get_vblank_counter = i915_get_vblank_counter;
1439 dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
1440 if (IS_G4X(dev) || IS_IGDNG(dev)) {
1441 dev->max_vblank_count = 0xffffffff; /* full 32 bit counter */
1442 dev->driver->get_vblank_counter = gm45_get_vblank_counter;
1448 if (!I915_NEED_GFX_HWS(dev)) {
1449 ret = i915_init_phys_hws(dev);
1451 goto out_workqueue_free;
1454 i915_get_mem_freq(dev);
1456 /* On the 945G/GM, the chipset reports the MSI capability on the
1457 * integrated graphics even though the support isn't actually there
1458 * according to the published specs. It doesn't appear to function
1459 * correctly in testing on 945G.
1460 * This may be a side effect of MSI having been made available for PEG
1461 * and the registers being closely associated.
1463 * According to chipset errata, on the 965GM, MSI interrupts may
1464 * be lost or delayed, but we use them anyways to avoid
1465 * stuck interrupts on some machines.
1467 if (!IS_I945G(dev) && !IS_I945GM(dev))
1468 pci_enable_msi(dev->pdev);
1470 spin_lock_init(&dev_priv->user_irq_lock);
1471 spin_lock_init(&dev_priv->error_lock);
1472 dev_priv->user_irq_refcount = 0;
1473 dev_priv->trace_irq_seqno = 0;
1475 ret = drm_vblank_init(dev, I915_NUM_PIPE);
1478 (void) i915_driver_unload(dev);
1482 /* Start out suspended */
1483 dev_priv->mm.suspended = 1;
1485 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
1486 ret = i915_load_modeset_init(dev, prealloc_start,
1487 prealloc_size, agp_size);
1489 DRM_ERROR("failed to init modeset\n");
1490 goto out_workqueue_free;
1494 /* Must be done after probing outputs */
1495 /* FIXME: verify on IGDNG */
1497 intel_opregion_init(dev, 0);
1499 setup_timer(&dev_priv->hangcheck_timer, i915_hangcheck_elapsed,
1500 (unsigned long) dev);
1504 destroy_workqueue(dev_priv->wq);
1506 io_mapping_free(dev_priv->mm.gtt_mapping);
1508 iounmap(dev_priv->regs);
1510 pci_dev_put(dev_priv->bridge_dev);
1516 int i915_driver_unload(struct drm_device *dev)
1518 struct drm_i915_private *dev_priv = dev->dev_private;
1520 destroy_workqueue(dev_priv->wq);
1521 del_timer_sync(&dev_priv->hangcheck_timer);
1523 io_mapping_free(dev_priv->mm.gtt_mapping);
1524 if (dev_priv->mm.gtt_mtrr >= 0) {
1525 mtrr_del(dev_priv->mm.gtt_mtrr, dev->agp->base,
1526 dev->agp->agp_info.aper_size * 1024 * 1024);
1527 dev_priv->mm.gtt_mtrr = -1;
1530 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
1531 drm_irq_uninstall(dev);
1532 vga_client_register(dev->pdev, NULL, NULL, NULL);
1535 if (dev->pdev->msi_enabled)
1536 pci_disable_msi(dev->pdev);
1538 if (dev_priv->regs != NULL)
1539 iounmap(dev_priv->regs);
1542 intel_opregion_free(dev, 0);
1544 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
1545 intel_modeset_cleanup(dev);
1547 i915_gem_free_all_phys_object(dev);
1549 mutex_lock(&dev->struct_mutex);
1550 i915_gem_cleanup_ringbuffer(dev);
1551 mutex_unlock(&dev->struct_mutex);
1552 drm_mm_takedown(&dev_priv->vram);
1553 i915_gem_lastclose(dev);
1555 intel_cleanup_overlay(dev);
1558 pci_dev_put(dev_priv->bridge_dev);
1559 kfree(dev->dev_private);
1564 int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv)
1566 struct drm_i915_file_private *i915_file_priv;
1568 DRM_DEBUG_DRIVER("\n");
1569 i915_file_priv = (struct drm_i915_file_private *)
1570 kmalloc(sizeof(*i915_file_priv), GFP_KERNEL);
1572 if (!i915_file_priv)
1575 file_priv->driver_priv = i915_file_priv;
1577 INIT_LIST_HEAD(&i915_file_priv->mm.request_list);
1583 * i915_driver_lastclose - clean up after all DRM clients have exited
1586 * Take care of cleaning up after all DRM clients have exited. In the
1587 * mode setting case, we want to restore the kernel's initial mode (just
1588 * in case the last client left us in a bad state).
1590 * Additionally, in the non-mode setting case, we'll tear down the AGP
1591 * and DMA structures, since the kernel won't be using them, and clea
1594 void i915_driver_lastclose(struct drm_device * dev)
1596 drm_i915_private_t *dev_priv = dev->dev_private;
1598 if (!dev_priv || drm_core_check_feature(dev, DRIVER_MODESET)) {
1599 drm_fb_helper_restore();
1603 i915_gem_lastclose(dev);
1605 if (dev_priv->agp_heap)
1606 i915_mem_takedown(&(dev_priv->agp_heap));
1608 i915_dma_cleanup(dev);
1611 void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
1613 drm_i915_private_t *dev_priv = dev->dev_private;
1614 i915_gem_release(dev, file_priv);
1615 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1616 i915_mem_release(dev, file_priv, dev_priv->agp_heap);
1619 void i915_driver_postclose(struct drm_device *dev, struct drm_file *file_priv)
1621 struct drm_i915_file_private *i915_file_priv = file_priv->driver_priv;
1623 kfree(i915_file_priv);
1626 struct drm_ioctl_desc i915_ioctls[] = {
1627 DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1628 DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH),
1629 DRM_IOCTL_DEF(DRM_I915_FLIP, i915_flip_bufs, DRM_AUTH),
1630 DRM_IOCTL_DEF(DRM_I915_BATCHBUFFER, i915_batchbuffer, DRM_AUTH),
1631 DRM_IOCTL_DEF(DRM_I915_IRQ_EMIT, i915_irq_emit, DRM_AUTH),
1632 DRM_IOCTL_DEF(DRM_I915_IRQ_WAIT, i915_irq_wait, DRM_AUTH),
1633 DRM_IOCTL_DEF(DRM_I915_GETPARAM, i915_getparam, DRM_AUTH),
1634 DRM_IOCTL_DEF(DRM_I915_SETPARAM, i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1635 DRM_IOCTL_DEF(DRM_I915_ALLOC, i915_mem_alloc, DRM_AUTH),
1636 DRM_IOCTL_DEF(DRM_I915_FREE, i915_mem_free, DRM_AUTH),
1637 DRM_IOCTL_DEF(DRM_I915_INIT_HEAP, i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1638 DRM_IOCTL_DEF(DRM_I915_CMDBUFFER, i915_cmdbuffer, DRM_AUTH),
1639 DRM_IOCTL_DEF(DRM_I915_DESTROY_HEAP, i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ),
1640 DRM_IOCTL_DEF(DRM_I915_SET_VBLANK_PIPE, i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ),
1641 DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ),
1642 DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH),
1643 DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1644 DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1645 DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH),
1646 DRM_IOCTL_DEF(DRM_I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY),
1647 DRM_IOCTL_DEF(DRM_I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY),
1648 DRM_IOCTL_DEF(DRM_I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH),
1649 DRM_IOCTL_DEF(DRM_I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH),
1650 DRM_IOCTL_DEF(DRM_I915_GEM_ENTERVT, i915_gem_entervt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1651 DRM_IOCTL_DEF(DRM_I915_GEM_LEAVEVT, i915_gem_leavevt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1652 DRM_IOCTL_DEF(DRM_I915_GEM_CREATE, i915_gem_create_ioctl, 0),
1653 DRM_IOCTL_DEF(DRM_I915_GEM_PREAD, i915_gem_pread_ioctl, 0),
1654 DRM_IOCTL_DEF(DRM_I915_GEM_PWRITE, i915_gem_pwrite_ioctl, 0),
1655 DRM_IOCTL_DEF(DRM_I915_GEM_MMAP, i915_gem_mmap_ioctl, 0),
1656 DRM_IOCTL_DEF(DRM_I915_GEM_MMAP_GTT, i915_gem_mmap_gtt_ioctl, 0),
1657 DRM_IOCTL_DEF(DRM_I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, 0),
1658 DRM_IOCTL_DEF(DRM_I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, 0),
1659 DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0),
1660 DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0),
1661 DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0),
1662 DRM_IOCTL_DEF(DRM_I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, 0),
1663 DRM_IOCTL_DEF(DRM_I915_GEM_MADVISE, i915_gem_madvise_ioctl, 0),
1664 DRM_IOCTL_DEF(DRM_I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, DRM_MASTER|DRM_CONTROL_ALLOW),
1665 DRM_IOCTL_DEF(DRM_I915_OVERLAY_ATTRS, intel_overlay_attrs, DRM_MASTER|DRM_CONTROL_ALLOW),
1668 int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
1671 * Determine if the device really is AGP or not.
1673 * All Intel graphics chipsets are treated as AGP, even if they are really
1676 * \param dev The device to be tested.
1679 * A value of 1 is always retured to indictate every i9x5 is AGP.
1681 int i915_driver_device_is_agp(struct drm_device * dev)