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 #define IS_I965G(dev) (dev->pci_device == 0x2972 || \
35 dev->pci_device == 0x2982 || \
36 dev->pci_device == 0x2992 || \
37 dev->pci_device == 0x29A2 || \
38 dev->pci_device == 0x2A02 || \
39 dev->pci_device == 0x2A12)
41 #define IS_G33(dev) (dev->pci_device == 0x29b2 || \
42 dev->pci_device == 0x29c2 || \
43 dev->pci_device == 0x29d2)
45 /* Really want an OS-independent resettable timer. Would like to have
46 * this loop run for (eg) 3 sec, but have the timer reset every time
47 * the head pointer changes, so that EBUSY only happens if the ring
48 * actually stalls for (eg) 3 seconds.
50 int i915_wait_ring(struct drm_device
* dev
, int n
, const char *caller
)
52 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
53 drm_i915_ring_buffer_t
*ring
= &(dev_priv
->ring
);
54 u32 last_head
= I915_READ(LP_RING
+ RING_HEAD
) & HEAD_ADDR
;
57 for (i
= 0; i
< 10000; i
++) {
58 ring
->head
= I915_READ(LP_RING
+ RING_HEAD
) & HEAD_ADDR
;
59 ring
->space
= ring
->head
- (ring
->tail
+ 8);
61 ring
->space
+= ring
->Size
;
65 dev_priv
->sarea_priv
->perf_boxes
|= I915_BOX_WAIT
;
67 if (ring
->head
!= last_head
)
70 last_head
= ring
->head
;
76 void i915_kernel_lost_context(struct drm_device
* dev
)
78 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
79 drm_i915_ring_buffer_t
*ring
= &(dev_priv
->ring
);
81 ring
->head
= I915_READ(LP_RING
+ RING_HEAD
) & HEAD_ADDR
;
82 ring
->tail
= I915_READ(LP_RING
+ RING_TAIL
) & TAIL_ADDR
;
83 ring
->space
= ring
->head
- (ring
->tail
+ 8);
85 ring
->space
+= ring
->Size
;
87 if (ring
->head
== ring
->tail
)
88 dev_priv
->sarea_priv
->perf_boxes
|= I915_BOX_RING_EMPTY
;
91 static int i915_dma_cleanup(struct drm_device
* dev
)
93 /* Make sure interrupts are disabled here because the uninstall ioctl
94 * may not have been called from userspace and after dev_private
95 * is freed, it's too late.
98 drm_irq_uninstall(dev
);
100 if (dev
->dev_private
) {
101 drm_i915_private_t
*dev_priv
=
102 (drm_i915_private_t
*) dev
->dev_private
;
104 if (dev_priv
->ring
.virtual_start
) {
105 drm_core_ioremapfree(&dev_priv
->ring
.map
, dev
);
108 if (dev_priv
->status_page_dmah
) {
109 drm_pci_free(dev
, dev_priv
->status_page_dmah
);
110 /* Need to rewrite hardware status page */
111 I915_WRITE(0x02080, 0x1ffff000);
114 if (dev_priv
->status_gfx_addr
) {
115 dev_priv
->status_gfx_addr
= 0;
116 drm_core_ioremapfree(&dev_priv
->hws_map
, dev
);
117 I915_WRITE(0x2080, 0x1ffff000);
120 drm_free(dev
->dev_private
, sizeof(drm_i915_private_t
),
123 dev
->dev_private
= NULL
;
129 static int i915_initialize(struct drm_device
* dev
,
130 drm_i915_private_t
* dev_priv
,
131 drm_i915_init_t
* init
)
133 memset(dev_priv
, 0, sizeof(drm_i915_private_t
));
135 dev_priv
->sarea
= drm_getsarea(dev
);
136 if (!dev_priv
->sarea
) {
137 DRM_ERROR("can not find sarea!\n");
138 dev
->dev_private
= (void *)dev_priv
;
139 i915_dma_cleanup(dev
);
143 dev_priv
->mmio_map
= drm_core_findmap(dev
, init
->mmio_offset
);
144 if (!dev_priv
->mmio_map
) {
145 dev
->dev_private
= (void *)dev_priv
;
146 i915_dma_cleanup(dev
);
147 DRM_ERROR("can not find mmio map!\n");
151 dev_priv
->sarea_priv
= (drm_i915_sarea_t
*)
152 ((u8
*) dev_priv
->sarea
->handle
+ init
->sarea_priv_offset
);
154 dev_priv
->ring
.Start
= init
->ring_start
;
155 dev_priv
->ring
.End
= init
->ring_end
;
156 dev_priv
->ring
.Size
= init
->ring_size
;
157 dev_priv
->ring
.tail_mask
= dev_priv
->ring
.Size
- 1;
159 dev_priv
->ring
.map
.offset
= init
->ring_start
;
160 dev_priv
->ring
.map
.size
= init
->ring_size
;
161 dev_priv
->ring
.map
.type
= 0;
162 dev_priv
->ring
.map
.flags
= 0;
163 dev_priv
->ring
.map
.mtrr
= 0;
165 drm_core_ioremap(&dev_priv
->ring
.map
, dev
);
167 if (dev_priv
->ring
.map
.handle
== NULL
) {
168 dev
->dev_private
= (void *)dev_priv
;
169 i915_dma_cleanup(dev
);
170 DRM_ERROR("can not ioremap virtual address for"
175 dev_priv
->ring
.virtual_start
= dev_priv
->ring
.map
.handle
;
177 dev_priv
->cpp
= init
->cpp
;
178 dev_priv
->back_offset
= init
->back_offset
;
179 dev_priv
->front_offset
= init
->front_offset
;
180 dev_priv
->current_page
= 0;
181 dev_priv
->sarea_priv
->pf_current_page
= dev_priv
->current_page
;
183 /* We are using separate values as placeholders for mechanisms for
184 * private backbuffer/depthbuffer usage.
186 dev_priv
->use_mi_batchbuffer_start
= 0;
187 if (IS_I965G(dev
)) /* 965 doesn't support older method */
188 dev_priv
->use_mi_batchbuffer_start
= 1;
190 /* Allow hardware batchbuffers unless told otherwise.
192 dev_priv
->allow_batchbuffer
= 1;
194 /* Program Hardware Status Page */
196 dev_priv
->status_page_dmah
=
197 drm_pci_alloc(dev
, PAGE_SIZE
, PAGE_SIZE
, 0xffffffff);
199 if (!dev_priv
->status_page_dmah
) {
200 dev
->dev_private
= (void *)dev_priv
;
201 i915_dma_cleanup(dev
);
202 DRM_ERROR("Can not allocate hardware status page\n");
205 dev_priv
->hw_status_page
= dev_priv
->status_page_dmah
->vaddr
;
206 dev_priv
->dma_status_page
= dev_priv
->status_page_dmah
->busaddr
;
208 memset(dev_priv
->hw_status_page
, 0, PAGE_SIZE
);
209 I915_WRITE(0x02080, dev_priv
->dma_status_page
);
211 DRM_DEBUG("Enabled hardware status page\n");
212 dev
->dev_private
= (void *)dev_priv
;
216 static int i915_dma_resume(struct drm_device
* dev
)
218 drm_i915_private_t
*dev_priv
= (drm_i915_private_t
*) dev
->dev_private
;
220 DRM_DEBUG("%s\n", __FUNCTION__
);
222 if (!dev_priv
->sarea
) {
223 DRM_ERROR("can not find sarea!\n");
227 if (!dev_priv
->mmio_map
) {
228 DRM_ERROR("can not find mmio map!\n");
232 if (dev_priv
->ring
.map
.handle
== NULL
) {
233 DRM_ERROR("can not ioremap virtual address for"
238 /* Program Hardware Status Page */
239 if (!dev_priv
->hw_status_page
) {
240 DRM_ERROR("Can not find hardware status page\n");
243 DRM_DEBUG("hw status page @ %p\n", dev_priv
->hw_status_page
);
245 if (dev_priv
->status_gfx_addr
!= 0)
246 I915_WRITE(0x02080, dev_priv
->status_gfx_addr
);
248 I915_WRITE(0x02080, dev_priv
->dma_status_page
);
249 DRM_DEBUG("Enabled hardware status page\n");
254 static int i915_dma_init(DRM_IOCTL_ARGS
)
257 drm_i915_private_t
*dev_priv
;
258 drm_i915_init_t init
;
261 DRM_COPY_FROM_USER_IOCTL(init
, (drm_i915_init_t __user
*) data
,
266 dev_priv
= drm_alloc(sizeof(drm_i915_private_t
),
268 if (dev_priv
== NULL
)
270 retcode
= i915_initialize(dev
, dev_priv
, &init
);
272 case I915_CLEANUP_DMA
:
273 retcode
= i915_dma_cleanup(dev
);
275 case I915_RESUME_DMA
:
276 retcode
= i915_dma_resume(dev
);
286 /* Implement basically the same security restrictions as hardware does
287 * for MI_BATCH_NON_SECURE. These can be made stricter at any time.
289 * Most of the calculations below involve calculating the size of a
290 * particular instruction. It's important to get the size right as
291 * that tells us where the next instruction to check is. Any illegal
292 * instruction detected will be given a size of zero, which is a
293 * signal to abort the rest of the buffer.
295 static int do_validate_cmd(int cmd
)
297 switch (((cmd
>> 29) & 0x7)) {
299 switch ((cmd
>> 23) & 0x3f) {
301 return 1; /* MI_NOOP */
303 return 1; /* MI_FLUSH */
305 return 0; /* disallow everything else */
309 return 0; /* reserved */
311 return (cmd
& 0xff) + 2; /* 2d commands */
313 if (((cmd
>> 24) & 0x1f) <= 0x18)
316 switch ((cmd
>> 24) & 0x1f) {
320 switch ((cmd
>> 16) & 0xff) {
322 return (cmd
& 0x1f) + 2;
324 return (cmd
& 0xf) + 2;
326 return (cmd
& 0xffff) + 2;
330 return (cmd
& 0xffff) + 1;
334 if ((cmd
& (1 << 23)) == 0) /* inline vertices */
335 return (cmd
& 0x1ffff) + 2;
336 else if (cmd
& (1 << 17)) /* indirect random */
337 if ((cmd
& 0xffff) == 0)
338 return 0; /* unknown length, too hard */
340 return (((cmd
& 0xffff) + 1) / 2) + 1;
342 return 2; /* indirect sequential */
353 static int validate_cmd(int cmd
)
355 int ret
= do_validate_cmd(cmd
);
357 /* printk("validate_cmd( %x ): %d\n", cmd, ret); */
362 static int i915_emit_cmds(struct drm_device
* dev
, int __user
* buffer
, int dwords
)
364 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
368 if ((dwords
+1) * sizeof(int) >= dev_priv
->ring
.Size
- 8)
371 BEGIN_LP_RING((dwords
+1)&~1);
373 for (i
= 0; i
< dwords
;) {
376 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd
, &buffer
[i
], sizeof(cmd
)))
379 if ((sz
= validate_cmd(cmd
)) == 0 || i
+ sz
> dwords
)
385 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd
, &buffer
[i
],
401 static int i915_emit_box(struct drm_device
* dev
,
402 struct drm_clip_rect __user
* boxes
,
403 int i
, int DR1
, int DR4
)
405 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
406 struct drm_clip_rect box
;
409 if (DRM_COPY_FROM_USER_UNCHECKED(&box
, &boxes
[i
], sizeof(box
))) {
413 if (box
.y2
<= box
.y1
|| box
.x2
<= box
.x1
|| box
.y2
<= 0 || box
.x2
<= 0) {
414 DRM_ERROR("Bad box %d,%d..%d,%d\n",
415 box
.x1
, box
.y1
, box
.x2
, box
.y2
);
421 OUT_RING(GFX_OP_DRAWRECT_INFO_I965
);
422 OUT_RING((box
.x1
& 0xffff) | (box
.y1
<< 16));
423 OUT_RING(((box
.x2
- 1) & 0xffff) | ((box
.y2
- 1) << 16));
428 OUT_RING(GFX_OP_DRAWRECT_INFO
);
430 OUT_RING((box
.x1
& 0xffff) | (box
.y1
<< 16));
431 OUT_RING(((box
.x2
- 1) & 0xffff) | ((box
.y2
- 1) << 16));
440 /* XXX: Emitting the counter should really be moved to part of the IRQ
441 * emit. For now, do it in both places:
444 static void i915_emit_breadcrumb(struct drm_device
*dev
)
446 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
449 dev_priv
->sarea_priv
->last_enqueue
= ++dev_priv
->counter
;
451 if (dev_priv
->counter
> 0x7FFFFFFFUL
)
452 dev_priv
->sarea_priv
->last_enqueue
= dev_priv
->counter
= 1;
455 OUT_RING(CMD_STORE_DWORD_IDX
);
457 OUT_RING(dev_priv
->counter
);
462 static int i915_dispatch_cmdbuffer(struct drm_device
* dev
,
463 drm_i915_cmdbuffer_t
* cmd
)
465 int nbox
= cmd
->num_cliprects
;
466 int i
= 0, count
, ret
;
469 DRM_ERROR("alignment");
473 i915_kernel_lost_context(dev
);
475 count
= nbox
? nbox
: 1;
477 for (i
= 0; i
< count
; i
++) {
479 ret
= i915_emit_box(dev
, cmd
->cliprects
, i
,
485 ret
= i915_emit_cmds(dev
, (int __user
*)cmd
->buf
, cmd
->sz
/ 4);
490 i915_emit_breadcrumb(dev
);
494 static int i915_dispatch_batchbuffer(struct drm_device
* dev
,
495 drm_i915_batchbuffer_t
* batch
)
497 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
498 struct drm_clip_rect __user
*boxes
= batch
->cliprects
;
499 int nbox
= batch
->num_cliprects
;
503 if ((batch
->start
| batch
->used
) & 0x7) {
504 DRM_ERROR("alignment");
508 i915_kernel_lost_context(dev
);
510 count
= nbox
? nbox
: 1;
512 for (i
= 0; i
< count
; i
++) {
514 int ret
= i915_emit_box(dev
, boxes
, i
,
515 batch
->DR1
, batch
->DR4
);
520 if (dev_priv
->use_mi_batchbuffer_start
) {
523 OUT_RING(MI_BATCH_BUFFER_START
| (2 << 6) | MI_BATCH_NON_SECURE_I965
);
524 OUT_RING(batch
->start
);
526 OUT_RING(MI_BATCH_BUFFER_START
| (2 << 6));
527 OUT_RING(batch
->start
| MI_BATCH_NON_SECURE
);
532 OUT_RING(MI_BATCH_BUFFER
);
533 OUT_RING(batch
->start
| MI_BATCH_NON_SECURE
);
534 OUT_RING(batch
->start
+ batch
->used
- 4);
540 i915_emit_breadcrumb(dev
);
545 static int i915_dispatch_flip(struct drm_device
* dev
)
547 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
550 DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n",
552 dev_priv
->current_page
,
553 dev_priv
->sarea_priv
->pf_current_page
);
555 i915_kernel_lost_context(dev
);
558 OUT_RING(INST_PARSER_CLIENT
| INST_OP_FLUSH
| INST_FLUSH_MAP_CACHE
);
563 OUT_RING(CMD_OP_DISPLAYBUFFER_INFO
| ASYNC_FLIP
);
565 if (dev_priv
->current_page
== 0) {
566 OUT_RING(dev_priv
->back_offset
);
567 dev_priv
->current_page
= 1;
569 OUT_RING(dev_priv
->front_offset
);
570 dev_priv
->current_page
= 0;
576 OUT_RING(MI_WAIT_FOR_EVENT
| MI_WAIT_FOR_PLANE_A_FLIP
);
580 dev_priv
->sarea_priv
->last_enqueue
= dev_priv
->counter
++;
583 OUT_RING(CMD_STORE_DWORD_IDX
);
585 OUT_RING(dev_priv
->counter
);
589 dev_priv
->sarea_priv
->pf_current_page
= dev_priv
->current_page
;
593 static int i915_quiescent(struct drm_device
* dev
)
595 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
597 i915_kernel_lost_context(dev
);
598 return i915_wait_ring(dev
, dev_priv
->ring
.Size
- 8, __FUNCTION__
);
601 static int i915_flush_ioctl(DRM_IOCTL_ARGS
)
605 LOCK_TEST_WITH_RETURN(dev
, filp
);
607 return i915_quiescent(dev
);
610 static int i915_batchbuffer(DRM_IOCTL_ARGS
)
613 drm_i915_private_t
*dev_priv
= (drm_i915_private_t
*) dev
->dev_private
;
614 u32
*hw_status
= dev_priv
->hw_status_page
;
615 drm_i915_sarea_t
*sarea_priv
= (drm_i915_sarea_t
*)
616 dev_priv
->sarea_priv
;
617 drm_i915_batchbuffer_t batch
;
620 if (!dev_priv
->allow_batchbuffer
) {
621 DRM_ERROR("Batchbuffer ioctl disabled\n");
625 DRM_COPY_FROM_USER_IOCTL(batch
, (drm_i915_batchbuffer_t __user
*) data
,
628 DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n",
629 batch
.start
, batch
.used
, batch
.num_cliprects
);
631 LOCK_TEST_WITH_RETURN(dev
, filp
);
633 if (batch
.num_cliprects
&& DRM_VERIFYAREA_READ(batch
.cliprects
,
634 batch
.num_cliprects
*
635 sizeof(struct drm_clip_rect
)))
638 ret
= i915_dispatch_batchbuffer(dev
, &batch
);
640 sarea_priv
->last_dispatch
= (int)hw_status
[5];
644 static int i915_cmdbuffer(DRM_IOCTL_ARGS
)
647 drm_i915_private_t
*dev_priv
= (drm_i915_private_t
*) dev
->dev_private
;
648 u32
*hw_status
= dev_priv
->hw_status_page
;
649 drm_i915_sarea_t
*sarea_priv
= (drm_i915_sarea_t
*)
650 dev_priv
->sarea_priv
;
651 drm_i915_cmdbuffer_t cmdbuf
;
654 DRM_COPY_FROM_USER_IOCTL(cmdbuf
, (drm_i915_cmdbuffer_t __user
*) data
,
657 DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n",
658 cmdbuf
.buf
, cmdbuf
.sz
, cmdbuf
.num_cliprects
);
660 LOCK_TEST_WITH_RETURN(dev
, filp
);
662 if (cmdbuf
.num_cliprects
&&
663 DRM_VERIFYAREA_READ(cmdbuf
.cliprects
,
664 cmdbuf
.num_cliprects
*
665 sizeof(struct drm_clip_rect
))) {
666 DRM_ERROR("Fault accessing cliprects\n");
670 ret
= i915_dispatch_cmdbuffer(dev
, &cmdbuf
);
672 DRM_ERROR("i915_dispatch_cmdbuffer failed\n");
676 sarea_priv
->last_dispatch
= (int)hw_status
[5];
680 static int i915_flip_bufs(DRM_IOCTL_ARGS
)
684 DRM_DEBUG("%s\n", __FUNCTION__
);
686 LOCK_TEST_WITH_RETURN(dev
, filp
);
688 return i915_dispatch_flip(dev
);
691 static int i915_getparam(DRM_IOCTL_ARGS
)
694 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
695 drm_i915_getparam_t param
;
699 DRM_ERROR("%s called with no initialization\n", __FUNCTION__
);
703 DRM_COPY_FROM_USER_IOCTL(param
, (drm_i915_getparam_t __user
*) data
,
706 switch (param
.param
) {
707 case I915_PARAM_IRQ_ACTIVE
:
708 value
= dev
->irq
? 1 : 0;
710 case I915_PARAM_ALLOW_BATCHBUFFER
:
711 value
= dev_priv
->allow_batchbuffer
? 1 : 0;
713 case I915_PARAM_LAST_DISPATCH
:
714 value
= READ_BREADCRUMB(dev_priv
);
717 DRM_ERROR("Unknown parameter %d\n", param
.param
);
721 if (DRM_COPY_TO_USER(param
.value
, &value
, sizeof(int))) {
722 DRM_ERROR("DRM_COPY_TO_USER failed\n");
729 static int i915_setparam(DRM_IOCTL_ARGS
)
732 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
733 drm_i915_setparam_t param
;
736 DRM_ERROR("%s called with no initialization\n", __FUNCTION__
);
740 DRM_COPY_FROM_USER_IOCTL(param
, (drm_i915_setparam_t __user
*) data
,
743 switch (param
.param
) {
744 case I915_SETPARAM_USE_MI_BATCHBUFFER_START
:
746 dev_priv
->use_mi_batchbuffer_start
= param
.value
;
748 case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY
:
749 dev_priv
->tex_lru_log_granularity
= param
.value
;
751 case I915_SETPARAM_ALLOW_BATCHBUFFER
:
752 dev_priv
->allow_batchbuffer
= param
.value
;
755 DRM_ERROR("unknown parameter %d\n", param
.param
);
762 static int i915_set_status_page(DRM_IOCTL_ARGS
)
765 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
766 drm_i915_hws_addr_t hws
;
769 DRM_ERROR("%s called with no initialization\n", __FUNCTION__
);
772 DRM_COPY_FROM_USER_IOCTL(hws
, (drm_i915_hws_addr_t __user
*) data
,
774 printk(KERN_DEBUG
"set status page addr 0x%08x\n", (u32
)hws
.addr
);
776 dev_priv
->status_gfx_addr
= hws
.addr
& (0x1ffff<<12);
778 dev_priv
->hws_map
.offset
= dev
->agp
->agp_info
.aper_base
+ hws
.addr
;
779 dev_priv
->hws_map
.size
= 4*1024;
780 dev_priv
->hws_map
.type
= 0;
781 dev_priv
->hws_map
.flags
= 0;
782 dev_priv
->hws_map
.mtrr
= 0;
784 drm_core_ioremap(&dev_priv
->hws_map
, dev
);
785 if (dev_priv
->hws_map
.handle
== NULL
) {
786 dev
->dev_private
= (void *)dev_priv
;
787 i915_dma_cleanup(dev
);
788 dev_priv
->status_gfx_addr
= 0;
789 DRM_ERROR("can not ioremap virtual address for"
790 " G33 hw status page\n");
793 dev_priv
->hw_status_page
= dev_priv
->hws_map
.handle
;
795 memset(dev_priv
->hw_status_page
, 0, PAGE_SIZE
);
796 I915_WRITE(0x02080, dev_priv
->status_gfx_addr
);
797 DRM_DEBUG("load hws 0x2080 with gfx mem 0x%x\n",
798 dev_priv
->status_gfx_addr
);
799 DRM_DEBUG("load hws at %p\n", dev_priv
->hw_status_page
);
803 int i915_driver_load(struct drm_device
*dev
, unsigned long flags
)
805 /* i915 has 4 more counters */
807 dev
->types
[6] = _DRM_STAT_IRQ
;
808 dev
->types
[7] = _DRM_STAT_PRIMARY
;
809 dev
->types
[8] = _DRM_STAT_SECONDARY
;
810 dev
->types
[9] = _DRM_STAT_DMA
;
815 void i915_driver_lastclose(struct drm_device
* dev
)
817 if (dev
->dev_private
) {
818 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
819 i915_mem_takedown(&(dev_priv
->agp_heap
));
821 i915_dma_cleanup(dev
);
824 void i915_driver_preclose(struct drm_device
* dev
, DRMFILE filp
)
826 if (dev
->dev_private
) {
827 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
828 i915_mem_release(dev
, filp
, dev_priv
->agp_heap
);
832 drm_ioctl_desc_t i915_ioctls
[] = {
833 [DRM_IOCTL_NR(DRM_I915_INIT
)] = {i915_dma_init
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
},
834 [DRM_IOCTL_NR(DRM_I915_FLUSH
)] = {i915_flush_ioctl
, DRM_AUTH
},
835 [DRM_IOCTL_NR(DRM_I915_FLIP
)] = {i915_flip_bufs
, DRM_AUTH
},
836 [DRM_IOCTL_NR(DRM_I915_BATCHBUFFER
)] = {i915_batchbuffer
, DRM_AUTH
},
837 [DRM_IOCTL_NR(DRM_I915_IRQ_EMIT
)] = {i915_irq_emit
, DRM_AUTH
},
838 [DRM_IOCTL_NR(DRM_I915_IRQ_WAIT
)] = {i915_irq_wait
, DRM_AUTH
},
839 [DRM_IOCTL_NR(DRM_I915_GETPARAM
)] = {i915_getparam
, DRM_AUTH
},
840 [DRM_IOCTL_NR(DRM_I915_SETPARAM
)] = {i915_setparam
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
},
841 [DRM_IOCTL_NR(DRM_I915_ALLOC
)] = {i915_mem_alloc
, DRM_AUTH
},
842 [DRM_IOCTL_NR(DRM_I915_FREE
)] = {i915_mem_free
, DRM_AUTH
},
843 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP
)] = {i915_mem_init_heap
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
},
844 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER
)] = {i915_cmdbuffer
, DRM_AUTH
},
845 [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP
)] = { i915_mem_destroy_heap
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
},
846 [DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE
)] = { i915_vblank_pipe_set
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
},
847 [DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE
)] = { i915_vblank_pipe_get
, DRM_AUTH
},
848 [DRM_IOCTL_NR(DRM_I915_VBLANK_SWAP
)] = {i915_vblank_swap
, DRM_AUTH
},
849 [DRM_IOCTL_NR(DRM_I915_HWS_ADDR
)] = {i915_set_status_page
, DRM_AUTH
},
852 int i915_max_ioctl
= DRM_ARRAY_SIZE(i915_ioctls
);
855 * Determine if the device really is AGP or not.
857 * All Intel graphics chipsets are treated as AGP, even if they are really
860 * \param dev The device to be tested.
863 * A value of 1 is always retured to indictate every i9x5 is AGP.
865 int i915_driver_device_is_agp(struct drm_device
* dev
)