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.
29 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
33 #include "drm_crtc_helper.h"
34 #include "drm_fb_helper.h"
35 #include "intel_drv.h"
38 #include "i915_trace.h"
39 #include "../../../platform/x86/intel_ips.h"
40 #include <linux/pci.h>
41 #include <linux/vgaarb.h>
42 #include <linux/acpi.h>
43 #include <linux/pnp.h>
44 #include <linux/vga_switcheroo.h>
45 #include <linux/slab.h>
46 #include <linux/module.h>
47 #include <acpi/video.h>
50 void i915_update_dri1_breadcrumb(struct drm_device
*dev
)
52 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
53 struct drm_i915_master_private
*master_priv
;
55 if (dev
->primary
->master
) {
56 master_priv
= dev
->primary
->master
->driver_priv
;
57 if (master_priv
->sarea_priv
)
58 master_priv
->sarea_priv
->last_dispatch
=
59 READ_BREADCRUMB(dev_priv
);
63 static void i915_write_hws_pga(struct drm_device
*dev
)
65 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
68 addr
= dev_priv
->status_page_dmah
->busaddr
;
69 if (INTEL_INFO(dev
)->gen
>= 4)
70 addr
|= (dev_priv
->status_page_dmah
->busaddr
>> 28) & 0xf0;
71 I915_WRITE(HWS_PGA
, addr
);
75 * Sets up the hardware status page for devices that need a physical address
78 static int i915_init_phys_hws(struct drm_device
*dev
)
80 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
82 /* Program Hardware Status Page */
83 dev_priv
->status_page_dmah
=
84 drm_pci_alloc(dev
, PAGE_SIZE
, PAGE_SIZE
);
86 if (!dev_priv
->status_page_dmah
) {
87 DRM_ERROR("Can not allocate hardware status page\n");
91 memset_io((void __force __iomem
*)dev_priv
->status_page_dmah
->vaddr
,
94 i915_write_hws_pga(dev
);
96 DRM_DEBUG_DRIVER("Enabled hardware status page\n");
101 * Frees the hardware status page, whether it's a physical address or a virtual
102 * address set up by the X Server.
104 static void i915_free_hws(struct drm_device
*dev
)
106 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
107 struct intel_ring_buffer
*ring
= LP_RING(dev_priv
);
109 if (dev_priv
->status_page_dmah
) {
110 drm_pci_free(dev
, dev_priv
->status_page_dmah
);
111 dev_priv
->status_page_dmah
= NULL
;
114 if (ring
->status_page
.gfx_addr
) {
115 ring
->status_page
.gfx_addr
= 0;
116 drm_core_ioremapfree(&dev_priv
->hws_map
, dev
);
119 /* Need to rewrite hardware status page */
120 I915_WRITE(HWS_PGA
, 0x1ffff000);
123 void i915_kernel_lost_context(struct drm_device
* dev
)
125 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
126 struct drm_i915_master_private
*master_priv
;
127 struct intel_ring_buffer
*ring
= LP_RING(dev_priv
);
130 * We should never lose context on the ring with modesetting
131 * as we don't expose it to userspace
133 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
136 ring
->head
= I915_READ_HEAD(ring
) & HEAD_ADDR
;
137 ring
->tail
= I915_READ_TAIL(ring
) & TAIL_ADDR
;
138 ring
->space
= ring
->head
- (ring
->tail
+ 8);
140 ring
->space
+= ring
->size
;
142 if (!dev
->primary
->master
)
145 master_priv
= dev
->primary
->master
->driver_priv
;
146 if (ring
->head
== ring
->tail
&& master_priv
->sarea_priv
)
147 master_priv
->sarea_priv
->perf_boxes
|= I915_BOX_RING_EMPTY
;
150 static int i915_dma_cleanup(struct drm_device
* dev
)
152 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
155 /* Make sure interrupts are disabled here because the uninstall ioctl
156 * may not have been called from userspace and after dev_private
157 * is freed, it's too late.
159 if (dev
->irq_enabled
)
160 drm_irq_uninstall(dev
);
162 mutex_lock(&dev
->struct_mutex
);
163 for (i
= 0; i
< I915_NUM_RINGS
; i
++)
164 intel_cleanup_ring_buffer(&dev_priv
->ring
[i
]);
165 mutex_unlock(&dev
->struct_mutex
);
167 /* Clear the HWS virtual address at teardown */
168 if (I915_NEED_GFX_HWS(dev
))
174 static int i915_initialize(struct drm_device
* dev
, drm_i915_init_t
* init
)
176 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
177 struct drm_i915_master_private
*master_priv
= dev
->primary
->master
->driver_priv
;
180 master_priv
->sarea
= drm_getsarea(dev
);
181 if (master_priv
->sarea
) {
182 master_priv
->sarea_priv
= (drm_i915_sarea_t
*)
183 ((u8
*)master_priv
->sarea
->handle
+ init
->sarea_priv_offset
);
185 DRM_DEBUG_DRIVER("sarea not found assuming DRI2 userspace\n");
188 if (init
->ring_size
!= 0) {
189 if (LP_RING(dev_priv
)->obj
!= NULL
) {
190 i915_dma_cleanup(dev
);
191 DRM_ERROR("Client tried to initialize ringbuffer in "
196 ret
= intel_render_ring_init_dri(dev
,
200 i915_dma_cleanup(dev
);
205 dev_priv
->cpp
= init
->cpp
;
206 dev_priv
->back_offset
= init
->back_offset
;
207 dev_priv
->front_offset
= init
->front_offset
;
208 dev_priv
->current_page
= 0;
209 if (master_priv
->sarea_priv
)
210 master_priv
->sarea_priv
->pf_current_page
= 0;
212 /* Allow hardware batchbuffers unless told otherwise.
214 dev_priv
->dri1
.allow_batchbuffer
= 1;
219 static int i915_dma_resume(struct drm_device
* dev
)
221 drm_i915_private_t
*dev_priv
= (drm_i915_private_t
*) dev
->dev_private
;
222 struct intel_ring_buffer
*ring
= LP_RING(dev_priv
);
224 DRM_DEBUG_DRIVER("%s\n", __func__
);
226 if (ring
->map
.handle
== NULL
) {
227 DRM_ERROR("can not ioremap virtual address for"
232 /* Program Hardware Status Page */
233 if (!ring
->status_page
.page_addr
) {
234 DRM_ERROR("Can not find hardware status page\n");
237 DRM_DEBUG_DRIVER("hw status page @ %p\n",
238 ring
->status_page
.page_addr
);
239 if (ring
->status_page
.gfx_addr
!= 0)
240 intel_ring_setup_status_page(ring
);
242 i915_write_hws_pga(dev
);
244 DRM_DEBUG_DRIVER("Enabled hardware status page\n");
249 static int i915_dma_init(struct drm_device
*dev
, void *data
,
250 struct drm_file
*file_priv
)
252 drm_i915_init_t
*init
= data
;
255 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
258 switch (init
->func
) {
260 retcode
= i915_initialize(dev
, init
);
262 case I915_CLEANUP_DMA
:
263 retcode
= i915_dma_cleanup(dev
);
265 case I915_RESUME_DMA
:
266 retcode
= i915_dma_resume(dev
);
276 /* Implement basically the same security restrictions as hardware does
277 * for MI_BATCH_NON_SECURE. These can be made stricter at any time.
279 * Most of the calculations below involve calculating the size of a
280 * particular instruction. It's important to get the size right as
281 * that tells us where the next instruction to check is. Any illegal
282 * instruction detected will be given a size of zero, which is a
283 * signal to abort the rest of the buffer.
285 static int validate_cmd(int cmd
)
287 switch (((cmd
>> 29) & 0x7)) {
289 switch ((cmd
>> 23) & 0x3f) {
291 return 1; /* MI_NOOP */
293 return 1; /* MI_FLUSH */
295 return 0; /* disallow everything else */
299 return 0; /* reserved */
301 return (cmd
& 0xff) + 2; /* 2d commands */
303 if (((cmd
>> 24) & 0x1f) <= 0x18)
306 switch ((cmd
>> 24) & 0x1f) {
310 switch ((cmd
>> 16) & 0xff) {
312 return (cmd
& 0x1f) + 2;
314 return (cmd
& 0xf) + 2;
316 return (cmd
& 0xffff) + 2;
320 return (cmd
& 0xffff) + 1;
324 if ((cmd
& (1 << 23)) == 0) /* inline vertices */
325 return (cmd
& 0x1ffff) + 2;
326 else if (cmd
& (1 << 17)) /* indirect random */
327 if ((cmd
& 0xffff) == 0)
328 return 0; /* unknown length, too hard */
330 return (((cmd
& 0xffff) + 1) / 2) + 1;
332 return 2; /* indirect sequential */
343 static int i915_emit_cmds(struct drm_device
* dev
, int *buffer
, int dwords
)
345 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
348 if ((dwords
+1) * sizeof(int) >= LP_RING(dev_priv
)->size
- 8)
351 for (i
= 0; i
< dwords
;) {
352 int sz
= validate_cmd(buffer
[i
]);
353 if (sz
== 0 || i
+ sz
> dwords
)
358 ret
= BEGIN_LP_RING((dwords
+1)&~1);
362 for (i
= 0; i
< dwords
; i
++)
373 i915_emit_box(struct drm_device
*dev
,
374 struct drm_clip_rect
*box
,
377 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
380 if (box
->y2
<= box
->y1
|| box
->x2
<= box
->x1
||
381 box
->y2
<= 0 || box
->x2
<= 0) {
382 DRM_ERROR("Bad box %d,%d..%d,%d\n",
383 box
->x1
, box
->y1
, box
->x2
, box
->y2
);
387 if (INTEL_INFO(dev
)->gen
>= 4) {
388 ret
= BEGIN_LP_RING(4);
392 OUT_RING(GFX_OP_DRAWRECT_INFO_I965
);
393 OUT_RING((box
->x1
& 0xffff) | (box
->y1
<< 16));
394 OUT_RING(((box
->x2
- 1) & 0xffff) | ((box
->y2
- 1) << 16));
397 ret
= BEGIN_LP_RING(6);
401 OUT_RING(GFX_OP_DRAWRECT_INFO
);
403 OUT_RING((box
->x1
& 0xffff) | (box
->y1
<< 16));
404 OUT_RING(((box
->x2
- 1) & 0xffff) | ((box
->y2
- 1) << 16));
413 /* XXX: Emitting the counter should really be moved to part of the IRQ
414 * emit. For now, do it in both places:
417 static void i915_emit_breadcrumb(struct drm_device
*dev
)
419 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
420 struct drm_i915_master_private
*master_priv
= dev
->primary
->master
->driver_priv
;
423 if (dev_priv
->counter
> 0x7FFFFFFFUL
)
424 dev_priv
->counter
= 0;
425 if (master_priv
->sarea_priv
)
426 master_priv
->sarea_priv
->last_enqueue
= dev_priv
->counter
;
428 if (BEGIN_LP_RING(4) == 0) {
429 OUT_RING(MI_STORE_DWORD_INDEX
);
430 OUT_RING(I915_BREADCRUMB_INDEX
<< MI_STORE_DWORD_INDEX_SHIFT
);
431 OUT_RING(dev_priv
->counter
);
437 static int i915_dispatch_cmdbuffer(struct drm_device
* dev
,
438 drm_i915_cmdbuffer_t
*cmd
,
439 struct drm_clip_rect
*cliprects
,
442 int nbox
= cmd
->num_cliprects
;
443 int i
= 0, count
, ret
;
446 DRM_ERROR("alignment");
450 i915_kernel_lost_context(dev
);
452 count
= nbox
? nbox
: 1;
454 for (i
= 0; i
< count
; i
++) {
456 ret
= i915_emit_box(dev
, &cliprects
[i
],
462 ret
= i915_emit_cmds(dev
, cmdbuf
, cmd
->sz
/ 4);
467 i915_emit_breadcrumb(dev
);
471 static int i915_dispatch_batchbuffer(struct drm_device
* dev
,
472 drm_i915_batchbuffer_t
* batch
,
473 struct drm_clip_rect
*cliprects
)
475 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
476 int nbox
= batch
->num_cliprects
;
479 if ((batch
->start
| batch
->used
) & 0x7) {
480 DRM_ERROR("alignment");
484 i915_kernel_lost_context(dev
);
486 count
= nbox
? nbox
: 1;
487 for (i
= 0; i
< count
; i
++) {
489 ret
= i915_emit_box(dev
, &cliprects
[i
],
490 batch
->DR1
, batch
->DR4
);
495 if (!IS_I830(dev
) && !IS_845G(dev
)) {
496 ret
= BEGIN_LP_RING(2);
500 if (INTEL_INFO(dev
)->gen
>= 4) {
501 OUT_RING(MI_BATCH_BUFFER_START
| (2 << 6) | MI_BATCH_NON_SECURE_I965
);
502 OUT_RING(batch
->start
);
504 OUT_RING(MI_BATCH_BUFFER_START
| (2 << 6));
505 OUT_RING(batch
->start
| MI_BATCH_NON_SECURE
);
508 ret
= BEGIN_LP_RING(4);
512 OUT_RING(MI_BATCH_BUFFER
);
513 OUT_RING(batch
->start
| MI_BATCH_NON_SECURE
);
514 OUT_RING(batch
->start
+ batch
->used
- 4);
521 if (IS_G4X(dev
) || IS_GEN5(dev
)) {
522 if (BEGIN_LP_RING(2) == 0) {
523 OUT_RING(MI_FLUSH
| MI_NO_WRITE_FLUSH
| MI_INVALIDATE_ISP
);
529 i915_emit_breadcrumb(dev
);
533 static int i915_dispatch_flip(struct drm_device
* dev
)
535 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
536 struct drm_i915_master_private
*master_priv
=
537 dev
->primary
->master
->driver_priv
;
540 if (!master_priv
->sarea_priv
)
543 DRM_DEBUG_DRIVER("%s: page=%d pfCurrentPage=%d\n",
545 dev_priv
->current_page
,
546 master_priv
->sarea_priv
->pf_current_page
);
548 i915_kernel_lost_context(dev
);
550 ret
= BEGIN_LP_RING(10);
554 OUT_RING(MI_FLUSH
| MI_READ_FLUSH
);
557 OUT_RING(CMD_OP_DISPLAYBUFFER_INFO
| ASYNC_FLIP
);
559 if (dev_priv
->current_page
== 0) {
560 OUT_RING(dev_priv
->back_offset
);
561 dev_priv
->current_page
= 1;
563 OUT_RING(dev_priv
->front_offset
);
564 dev_priv
->current_page
= 0;
568 OUT_RING(MI_WAIT_FOR_EVENT
| MI_WAIT_FOR_PLANE_A_FLIP
);
573 master_priv
->sarea_priv
->last_enqueue
= dev_priv
->counter
++;
575 if (BEGIN_LP_RING(4) == 0) {
576 OUT_RING(MI_STORE_DWORD_INDEX
);
577 OUT_RING(I915_BREADCRUMB_INDEX
<< MI_STORE_DWORD_INDEX_SHIFT
);
578 OUT_RING(dev_priv
->counter
);
583 master_priv
->sarea_priv
->pf_current_page
= dev_priv
->current_page
;
587 static int i915_quiescent(struct drm_device
*dev
)
589 struct intel_ring_buffer
*ring
= LP_RING(dev
->dev_private
);
591 i915_kernel_lost_context(dev
);
592 return intel_wait_ring_idle(ring
);
595 static int i915_flush_ioctl(struct drm_device
*dev
, void *data
,
596 struct drm_file
*file_priv
)
600 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
603 RING_LOCK_TEST_WITH_RETURN(dev
, file_priv
);
605 mutex_lock(&dev
->struct_mutex
);
606 ret
= i915_quiescent(dev
);
607 mutex_unlock(&dev
->struct_mutex
);
612 static int i915_batchbuffer(struct drm_device
*dev
, void *data
,
613 struct drm_file
*file_priv
)
615 drm_i915_private_t
*dev_priv
= (drm_i915_private_t
*) dev
->dev_private
;
616 struct drm_i915_master_private
*master_priv
= dev
->primary
->master
->driver_priv
;
617 drm_i915_sarea_t
*sarea_priv
= (drm_i915_sarea_t
*)
618 master_priv
->sarea_priv
;
619 drm_i915_batchbuffer_t
*batch
= data
;
621 struct drm_clip_rect
*cliprects
= NULL
;
623 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
626 if (!dev_priv
->dri1
.allow_batchbuffer
) {
627 DRM_ERROR("Batchbuffer ioctl disabled\n");
631 DRM_DEBUG_DRIVER("i915 batchbuffer, start %x used %d cliprects %d\n",
632 batch
->start
, batch
->used
, batch
->num_cliprects
);
634 RING_LOCK_TEST_WITH_RETURN(dev
, file_priv
);
636 if (batch
->num_cliprects
< 0)
639 if (batch
->num_cliprects
) {
640 cliprects
= kcalloc(batch
->num_cliprects
,
641 sizeof(struct drm_clip_rect
),
643 if (cliprects
== NULL
)
646 ret
= copy_from_user(cliprects
, batch
->cliprects
,
647 batch
->num_cliprects
*
648 sizeof(struct drm_clip_rect
));
655 mutex_lock(&dev
->struct_mutex
);
656 ret
= i915_dispatch_batchbuffer(dev
, batch
, cliprects
);
657 mutex_unlock(&dev
->struct_mutex
);
660 sarea_priv
->last_dispatch
= READ_BREADCRUMB(dev_priv
);
668 static int i915_cmdbuffer(struct drm_device
*dev
, void *data
,
669 struct drm_file
*file_priv
)
671 drm_i915_private_t
*dev_priv
= (drm_i915_private_t
*) dev
->dev_private
;
672 struct drm_i915_master_private
*master_priv
= dev
->primary
->master
->driver_priv
;
673 drm_i915_sarea_t
*sarea_priv
= (drm_i915_sarea_t
*)
674 master_priv
->sarea_priv
;
675 drm_i915_cmdbuffer_t
*cmdbuf
= data
;
676 struct drm_clip_rect
*cliprects
= NULL
;
680 DRM_DEBUG_DRIVER("i915 cmdbuffer, buf %p sz %d cliprects %d\n",
681 cmdbuf
->buf
, cmdbuf
->sz
, cmdbuf
->num_cliprects
);
683 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
686 RING_LOCK_TEST_WITH_RETURN(dev
, file_priv
);
688 if (cmdbuf
->num_cliprects
< 0)
691 batch_data
= kmalloc(cmdbuf
->sz
, GFP_KERNEL
);
692 if (batch_data
== NULL
)
695 ret
= copy_from_user(batch_data
, cmdbuf
->buf
, cmdbuf
->sz
);
698 goto fail_batch_free
;
701 if (cmdbuf
->num_cliprects
) {
702 cliprects
= kcalloc(cmdbuf
->num_cliprects
,
703 sizeof(struct drm_clip_rect
), GFP_KERNEL
);
704 if (cliprects
== NULL
) {
706 goto fail_batch_free
;
709 ret
= copy_from_user(cliprects
, cmdbuf
->cliprects
,
710 cmdbuf
->num_cliprects
*
711 sizeof(struct drm_clip_rect
));
718 mutex_lock(&dev
->struct_mutex
);
719 ret
= i915_dispatch_cmdbuffer(dev
, cmdbuf
, cliprects
, batch_data
);
720 mutex_unlock(&dev
->struct_mutex
);
722 DRM_ERROR("i915_dispatch_cmdbuffer failed\n");
727 sarea_priv
->last_dispatch
= READ_BREADCRUMB(dev_priv
);
737 static int i915_emit_irq(struct drm_device
* dev
)
739 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
740 struct drm_i915_master_private
*master_priv
= dev
->primary
->master
->driver_priv
;
742 i915_kernel_lost_context(dev
);
744 DRM_DEBUG_DRIVER("\n");
747 if (dev_priv
->counter
> 0x7FFFFFFFUL
)
748 dev_priv
->counter
= 1;
749 if (master_priv
->sarea_priv
)
750 master_priv
->sarea_priv
->last_enqueue
= dev_priv
->counter
;
752 if (BEGIN_LP_RING(4) == 0) {
753 OUT_RING(MI_STORE_DWORD_INDEX
);
754 OUT_RING(I915_BREADCRUMB_INDEX
<< MI_STORE_DWORD_INDEX_SHIFT
);
755 OUT_RING(dev_priv
->counter
);
756 OUT_RING(MI_USER_INTERRUPT
);
760 return dev_priv
->counter
;
763 static int i915_wait_irq(struct drm_device
* dev
, int irq_nr
)
765 drm_i915_private_t
*dev_priv
= (drm_i915_private_t
*) dev
->dev_private
;
766 struct drm_i915_master_private
*master_priv
= dev
->primary
->master
->driver_priv
;
768 struct intel_ring_buffer
*ring
= LP_RING(dev_priv
);
770 DRM_DEBUG_DRIVER("irq_nr=%d breadcrumb=%d\n", irq_nr
,
771 READ_BREADCRUMB(dev_priv
));
773 if (READ_BREADCRUMB(dev_priv
) >= irq_nr
) {
774 if (master_priv
->sarea_priv
)
775 master_priv
->sarea_priv
->last_dispatch
= READ_BREADCRUMB(dev_priv
);
779 if (master_priv
->sarea_priv
)
780 master_priv
->sarea_priv
->perf_boxes
|= I915_BOX_WAIT
;
782 if (ring
->irq_get(ring
)) {
783 DRM_WAIT_ON(ret
, ring
->irq_queue
, 3 * DRM_HZ
,
784 READ_BREADCRUMB(dev_priv
) >= irq_nr
);
786 } else if (wait_for(READ_BREADCRUMB(dev_priv
) >= irq_nr
, 3000))
790 DRM_ERROR("EBUSY -- rec: %d emitted: %d\n",
791 READ_BREADCRUMB(dev_priv
), (int)dev_priv
->counter
);
797 /* Needs the lock as it touches the ring.
799 static int i915_irq_emit(struct drm_device
*dev
, void *data
,
800 struct drm_file
*file_priv
)
802 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
803 drm_i915_irq_emit_t
*emit
= data
;
806 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
809 if (!dev_priv
|| !LP_RING(dev_priv
)->virtual_start
) {
810 DRM_ERROR("called with no initialization\n");
814 RING_LOCK_TEST_WITH_RETURN(dev
, file_priv
);
816 mutex_lock(&dev
->struct_mutex
);
817 result
= i915_emit_irq(dev
);
818 mutex_unlock(&dev
->struct_mutex
);
820 if (DRM_COPY_TO_USER(emit
->irq_seq
, &result
, sizeof(int))) {
821 DRM_ERROR("copy_to_user\n");
828 /* Doesn't need the hardware lock.
830 static int i915_irq_wait(struct drm_device
*dev
, void *data
,
831 struct drm_file
*file_priv
)
833 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
834 drm_i915_irq_wait_t
*irqwait
= data
;
836 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
840 DRM_ERROR("called with no initialization\n");
844 return i915_wait_irq(dev
, irqwait
->irq_seq
);
847 static int i915_vblank_pipe_get(struct drm_device
*dev
, void *data
,
848 struct drm_file
*file_priv
)
850 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
851 drm_i915_vblank_pipe_t
*pipe
= data
;
853 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
857 DRM_ERROR("called with no initialization\n");
861 pipe
->pipe
= DRM_I915_VBLANK_PIPE_A
| DRM_I915_VBLANK_PIPE_B
;
867 * Schedule buffer swap at given vertical blank.
869 static int i915_vblank_swap(struct drm_device
*dev
, void *data
,
870 struct drm_file
*file_priv
)
872 /* The delayed swap mechanism was fundamentally racy, and has been
873 * removed. The model was that the client requested a delayed flip/swap
874 * from the kernel, then waited for vblank before continuing to perform
875 * rendering. The problem was that the kernel might wake the client
876 * up before it dispatched the vblank swap (since the lock has to be
877 * held while touching the ringbuffer), in which case the client would
878 * clear and start the next frame before the swap occurred, and
879 * flicker would occur in addition to likely missing the vblank.
881 * In the absence of this ioctl, userland falls back to a correct path
882 * of waiting for a vblank, then dispatching the swap on its own.
883 * Context switching to userland and back is plenty fast enough for
884 * meeting the requirements of vblank swapping.
889 static int i915_flip_bufs(struct drm_device
*dev
, void *data
,
890 struct drm_file
*file_priv
)
894 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
897 DRM_DEBUG_DRIVER("%s\n", __func__
);
899 RING_LOCK_TEST_WITH_RETURN(dev
, file_priv
);
901 mutex_lock(&dev
->struct_mutex
);
902 ret
= i915_dispatch_flip(dev
);
903 mutex_unlock(&dev
->struct_mutex
);
908 static int i915_getparam(struct drm_device
*dev
, void *data
,
909 struct drm_file
*file_priv
)
911 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
912 drm_i915_getparam_t
*param
= data
;
916 DRM_ERROR("called with no initialization\n");
920 switch (param
->param
) {
921 case I915_PARAM_IRQ_ACTIVE
:
922 value
= dev
->pdev
->irq
? 1 : 0;
924 case I915_PARAM_ALLOW_BATCHBUFFER
:
925 value
= dev_priv
->dri1
.allow_batchbuffer
? 1 : 0;
927 case I915_PARAM_LAST_DISPATCH
:
928 value
= READ_BREADCRUMB(dev_priv
);
930 case I915_PARAM_CHIPSET_ID
:
931 value
= dev
->pci_device
;
933 case I915_PARAM_HAS_GEM
:
936 case I915_PARAM_NUM_FENCES_AVAIL
:
937 value
= dev_priv
->num_fence_regs
- dev_priv
->fence_reg_start
;
939 case I915_PARAM_HAS_OVERLAY
:
940 value
= dev_priv
->overlay
? 1 : 0;
942 case I915_PARAM_HAS_PAGEFLIPPING
:
945 case I915_PARAM_HAS_EXECBUF2
:
949 case I915_PARAM_HAS_BSD
:
950 value
= HAS_BSD(dev
);
952 case I915_PARAM_HAS_BLT
:
953 value
= HAS_BLT(dev
);
955 case I915_PARAM_HAS_RELAXED_FENCING
:
958 case I915_PARAM_HAS_COHERENT_RINGS
:
961 case I915_PARAM_HAS_EXEC_CONSTANTS
:
962 value
= INTEL_INFO(dev
)->gen
>= 4;
964 case I915_PARAM_HAS_RELAXED_DELTA
:
967 case I915_PARAM_HAS_GEN7_SOL_RESET
:
970 case I915_PARAM_HAS_LLC
:
971 value
= HAS_LLC(dev
);
973 case I915_PARAM_HAS_ALIASING_PPGTT
:
974 value
= dev_priv
->mm
.aliasing_ppgtt
? 1 : 0;
977 DRM_DEBUG_DRIVER("Unknown parameter %d\n",
982 if (DRM_COPY_TO_USER(param
->value
, &value
, sizeof(int))) {
983 DRM_ERROR("DRM_COPY_TO_USER failed\n");
990 static int i915_setparam(struct drm_device
*dev
, void *data
,
991 struct drm_file
*file_priv
)
993 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
994 drm_i915_setparam_t
*param
= data
;
997 DRM_ERROR("called with no initialization\n");
1001 switch (param
->param
) {
1002 case I915_SETPARAM_USE_MI_BATCHBUFFER_START
:
1004 case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY
:
1006 case I915_SETPARAM_ALLOW_BATCHBUFFER
:
1007 dev_priv
->dri1
.allow_batchbuffer
= param
->value
? 1 : 0;
1009 case I915_SETPARAM_NUM_USED_FENCES
:
1010 if (param
->value
> dev_priv
->num_fence_regs
||
1013 /* Userspace can use first N regs */
1014 dev_priv
->fence_reg_start
= param
->value
;
1017 DRM_DEBUG_DRIVER("unknown parameter %d\n",
1025 static int i915_set_status_page(struct drm_device
*dev
, void *data
,
1026 struct drm_file
*file_priv
)
1028 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1029 drm_i915_hws_addr_t
*hws
= data
;
1030 struct intel_ring_buffer
*ring
= LP_RING(dev_priv
);
1032 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
1035 if (!I915_NEED_GFX_HWS(dev
))
1039 DRM_ERROR("called with no initialization\n");
1043 if (drm_core_check_feature(dev
, DRIVER_MODESET
)) {
1044 WARN(1, "tried to set status page when mode setting active\n");
1048 DRM_DEBUG_DRIVER("set status page addr 0x%08x\n", (u32
)hws
->addr
);
1050 ring
->status_page
.gfx_addr
= hws
->addr
& (0x1ffff<<12);
1052 dev_priv
->hws_map
.offset
= dev
->agp
->base
+ hws
->addr
;
1053 dev_priv
->hws_map
.size
= 4*1024;
1054 dev_priv
->hws_map
.type
= 0;
1055 dev_priv
->hws_map
.flags
= 0;
1056 dev_priv
->hws_map
.mtrr
= 0;
1058 drm_core_ioremap_wc(&dev_priv
->hws_map
, dev
);
1059 if (dev_priv
->hws_map
.handle
== NULL
) {
1060 i915_dma_cleanup(dev
);
1061 ring
->status_page
.gfx_addr
= 0;
1062 DRM_ERROR("can not ioremap virtual address for"
1063 " G33 hw status page\n");
1066 ring
->status_page
.page_addr
=
1067 (void __force __iomem
*)dev_priv
->hws_map
.handle
;
1068 memset_io(ring
->status_page
.page_addr
, 0, PAGE_SIZE
);
1069 I915_WRITE(HWS_PGA
, ring
->status_page
.gfx_addr
);
1071 DRM_DEBUG_DRIVER("load hws HWS_PGA with gfx mem 0x%x\n",
1072 ring
->status_page
.gfx_addr
);
1073 DRM_DEBUG_DRIVER("load hws at %p\n",
1074 ring
->status_page
.page_addr
);
1078 static int i915_get_bridge_dev(struct drm_device
*dev
)
1080 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1082 dev_priv
->bridge_dev
= pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
1083 if (!dev_priv
->bridge_dev
) {
1084 DRM_ERROR("bridge device not found\n");
1090 #define MCHBAR_I915 0x44
1091 #define MCHBAR_I965 0x48
1092 #define MCHBAR_SIZE (4*4096)
1094 #define DEVEN_REG 0x54
1095 #define DEVEN_MCHBAR_EN (1 << 28)
1097 /* Allocate space for the MCH regs if needed, return nonzero on error */
1099 intel_alloc_mchbar_resource(struct drm_device
*dev
)
1101 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1102 int reg
= INTEL_INFO(dev
)->gen
>= 4 ? MCHBAR_I965
: MCHBAR_I915
;
1103 u32 temp_lo
, temp_hi
= 0;
1107 if (INTEL_INFO(dev
)->gen
>= 4)
1108 pci_read_config_dword(dev_priv
->bridge_dev
, reg
+ 4, &temp_hi
);
1109 pci_read_config_dword(dev_priv
->bridge_dev
, reg
, &temp_lo
);
1110 mchbar_addr
= ((u64
)temp_hi
<< 32) | temp_lo
;
1112 /* If ACPI doesn't have it, assume we need to allocate it ourselves */
1115 pnp_range_reserved(mchbar_addr
, mchbar_addr
+ MCHBAR_SIZE
))
1119 /* Get some space for it */
1120 dev_priv
->mch_res
.name
= "i915 MCHBAR";
1121 dev_priv
->mch_res
.flags
= IORESOURCE_MEM
;
1122 ret
= pci_bus_alloc_resource(dev_priv
->bridge_dev
->bus
,
1124 MCHBAR_SIZE
, MCHBAR_SIZE
,
1126 0, pcibios_align_resource
,
1127 dev_priv
->bridge_dev
);
1129 DRM_DEBUG_DRIVER("failed bus alloc: %d\n", ret
);
1130 dev_priv
->mch_res
.start
= 0;
1134 if (INTEL_INFO(dev
)->gen
>= 4)
1135 pci_write_config_dword(dev_priv
->bridge_dev
, reg
+ 4,
1136 upper_32_bits(dev_priv
->mch_res
.start
));
1138 pci_write_config_dword(dev_priv
->bridge_dev
, reg
,
1139 lower_32_bits(dev_priv
->mch_res
.start
));
1143 /* Setup MCHBAR if possible, return true if we should disable it again */
1145 intel_setup_mchbar(struct drm_device
*dev
)
1147 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1148 int mchbar_reg
= INTEL_INFO(dev
)->gen
>= 4 ? MCHBAR_I965
: MCHBAR_I915
;
1152 dev_priv
->mchbar_need_disable
= false;
1154 if (IS_I915G(dev
) || IS_I915GM(dev
)) {
1155 pci_read_config_dword(dev_priv
->bridge_dev
, DEVEN_REG
, &temp
);
1156 enabled
= !!(temp
& DEVEN_MCHBAR_EN
);
1158 pci_read_config_dword(dev_priv
->bridge_dev
, mchbar_reg
, &temp
);
1162 /* If it's already enabled, don't have to do anything */
1166 if (intel_alloc_mchbar_resource(dev
))
1169 dev_priv
->mchbar_need_disable
= true;
1171 /* Space is allocated or reserved, so enable it. */
1172 if (IS_I915G(dev
) || IS_I915GM(dev
)) {
1173 pci_write_config_dword(dev_priv
->bridge_dev
, DEVEN_REG
,
1174 temp
| DEVEN_MCHBAR_EN
);
1176 pci_read_config_dword(dev_priv
->bridge_dev
, mchbar_reg
, &temp
);
1177 pci_write_config_dword(dev_priv
->bridge_dev
, mchbar_reg
, temp
| 1);
1182 intel_teardown_mchbar(struct drm_device
*dev
)
1184 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1185 int mchbar_reg
= INTEL_INFO(dev
)->gen
>= 4 ? MCHBAR_I965
: MCHBAR_I915
;
1188 if (dev_priv
->mchbar_need_disable
) {
1189 if (IS_I915G(dev
) || IS_I915GM(dev
)) {
1190 pci_read_config_dword(dev_priv
->bridge_dev
, DEVEN_REG
, &temp
);
1191 temp
&= ~DEVEN_MCHBAR_EN
;
1192 pci_write_config_dword(dev_priv
->bridge_dev
, DEVEN_REG
, temp
);
1194 pci_read_config_dword(dev_priv
->bridge_dev
, mchbar_reg
, &temp
);
1196 pci_write_config_dword(dev_priv
->bridge_dev
, mchbar_reg
, temp
);
1200 if (dev_priv
->mch_res
.start
)
1201 release_resource(&dev_priv
->mch_res
);
1204 /* true = enable decode, false = disable decoder */
1205 static unsigned int i915_vga_set_decode(void *cookie
, bool state
)
1207 struct drm_device
*dev
= cookie
;
1209 intel_modeset_vga_set_state(dev
, state
);
1211 return VGA_RSRC_LEGACY_IO
| VGA_RSRC_LEGACY_MEM
|
1212 VGA_RSRC_NORMAL_IO
| VGA_RSRC_NORMAL_MEM
;
1214 return VGA_RSRC_NORMAL_IO
| VGA_RSRC_NORMAL_MEM
;
1217 static void i915_switcheroo_set_state(struct pci_dev
*pdev
, enum vga_switcheroo_state state
)
1219 struct drm_device
*dev
= pci_get_drvdata(pdev
);
1220 pm_message_t pmm
= { .event
= PM_EVENT_SUSPEND
};
1221 if (state
== VGA_SWITCHEROO_ON
) {
1222 pr_info("switched on\n");
1223 dev
->switch_power_state
= DRM_SWITCH_POWER_CHANGING
;
1224 /* i915 resume handler doesn't set to D0 */
1225 pci_set_power_state(dev
->pdev
, PCI_D0
);
1227 dev
->switch_power_state
= DRM_SWITCH_POWER_ON
;
1229 pr_err("switched off\n");
1230 dev
->switch_power_state
= DRM_SWITCH_POWER_CHANGING
;
1231 i915_suspend(dev
, pmm
);
1232 dev
->switch_power_state
= DRM_SWITCH_POWER_OFF
;
1236 static bool i915_switcheroo_can_switch(struct pci_dev
*pdev
)
1238 struct drm_device
*dev
= pci_get_drvdata(pdev
);
1241 spin_lock(&dev
->count_lock
);
1242 can_switch
= (dev
->open_count
== 0);
1243 spin_unlock(&dev
->count_lock
);
1247 static int i915_load_modeset_init(struct drm_device
*dev
)
1249 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1252 ret
= intel_parse_bios(dev
);
1254 DRM_INFO("failed to find VBIOS tables\n");
1256 /* If we have > 1 VGA cards, then we need to arbitrate access
1257 * to the common VGA resources.
1259 * If we are a secondary display controller (!PCI_DISPLAY_CLASS_VGA),
1260 * then we do not take part in VGA arbitration and the
1261 * vga_client_register() fails with -ENODEV.
1263 ret
= vga_client_register(dev
->pdev
, dev
, NULL
, i915_vga_set_decode
);
1264 if (ret
&& ret
!= -ENODEV
)
1267 intel_register_dsm_handler();
1269 ret
= vga_switcheroo_register_client(dev
->pdev
,
1270 i915_switcheroo_set_state
,
1272 i915_switcheroo_can_switch
);
1274 goto cleanup_vga_client
;
1276 /* Initialise stolen first so that we may reserve preallocated
1277 * objects for the BIOS to KMS transition.
1279 ret
= i915_gem_init_stolen(dev
);
1281 goto cleanup_vga_switcheroo
;
1283 intel_modeset_init(dev
);
1285 ret
= i915_gem_init(dev
);
1287 goto cleanup_gem_stolen
;
1289 intel_modeset_gem_init(dev
);
1291 ret
= drm_irq_install(dev
);
1295 /* Always safe in the mode setting case. */
1296 /* FIXME: do pre/post-mode set stuff in core KMS code */
1297 dev
->vblank_disable_allowed
= 1;
1299 ret
= intel_fbdev_init(dev
);
1303 drm_kms_helper_poll_init(dev
);
1305 /* We're off and running w/KMS */
1306 dev_priv
->mm
.suspended
= 0;
1311 drm_irq_uninstall(dev
);
1313 mutex_lock(&dev
->struct_mutex
);
1314 i915_gem_cleanup_ringbuffer(dev
);
1315 mutex_unlock(&dev
->struct_mutex
);
1316 i915_gem_cleanup_aliasing_ppgtt(dev
);
1318 i915_gem_cleanup_stolen(dev
);
1319 cleanup_vga_switcheroo
:
1320 vga_switcheroo_unregister_client(dev
->pdev
);
1322 vga_client_register(dev
->pdev
, NULL
, NULL
, NULL
);
1327 int i915_master_create(struct drm_device
*dev
, struct drm_master
*master
)
1329 struct drm_i915_master_private
*master_priv
;
1331 master_priv
= kzalloc(sizeof(*master_priv
), GFP_KERNEL
);
1335 master
->driver_priv
= master_priv
;
1339 void i915_master_destroy(struct drm_device
*dev
, struct drm_master
*master
)
1341 struct drm_i915_master_private
*master_priv
= master
->driver_priv
;
1348 master
->driver_priv
= NULL
;
1351 static void i915_pineview_get_mem_freq(struct drm_device
*dev
)
1353 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1356 tmp
= I915_READ(CLKCFG
);
1358 switch (tmp
& CLKCFG_FSB_MASK
) {
1359 case CLKCFG_FSB_533
:
1360 dev_priv
->fsb_freq
= 533; /* 133*4 */
1362 case CLKCFG_FSB_800
:
1363 dev_priv
->fsb_freq
= 800; /* 200*4 */
1365 case CLKCFG_FSB_667
:
1366 dev_priv
->fsb_freq
= 667; /* 167*4 */
1368 case CLKCFG_FSB_400
:
1369 dev_priv
->fsb_freq
= 400; /* 100*4 */
1373 switch (tmp
& CLKCFG_MEM_MASK
) {
1374 case CLKCFG_MEM_533
:
1375 dev_priv
->mem_freq
= 533;
1377 case CLKCFG_MEM_667
:
1378 dev_priv
->mem_freq
= 667;
1380 case CLKCFG_MEM_800
:
1381 dev_priv
->mem_freq
= 800;
1385 /* detect pineview DDR3 setting */
1386 tmp
= I915_READ(CSHRDDR3CTL
);
1387 dev_priv
->is_ddr3
= (tmp
& CSHRDDR3CTL_DDR3
) ? 1 : 0;
1390 static void i915_ironlake_get_mem_freq(struct drm_device
*dev
)
1392 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1395 ddrpll
= I915_READ16(DDRMPLL1
);
1396 csipll
= I915_READ16(CSIPLL0
);
1398 switch (ddrpll
& 0xff) {
1400 dev_priv
->mem_freq
= 800;
1403 dev_priv
->mem_freq
= 1066;
1406 dev_priv
->mem_freq
= 1333;
1409 dev_priv
->mem_freq
= 1600;
1412 DRM_DEBUG_DRIVER("unknown memory frequency 0x%02x\n",
1414 dev_priv
->mem_freq
= 0;
1418 dev_priv
->r_t
= dev_priv
->mem_freq
;
1420 switch (csipll
& 0x3ff) {
1422 dev_priv
->fsb_freq
= 3200;
1425 dev_priv
->fsb_freq
= 3733;
1428 dev_priv
->fsb_freq
= 4266;
1431 dev_priv
->fsb_freq
= 4800;
1434 dev_priv
->fsb_freq
= 5333;
1437 dev_priv
->fsb_freq
= 5866;
1440 dev_priv
->fsb_freq
= 6400;
1443 DRM_DEBUG_DRIVER("unknown fsb frequency 0x%04x\n",
1445 dev_priv
->fsb_freq
= 0;
1449 if (dev_priv
->fsb_freq
== 3200) {
1451 } else if (dev_priv
->fsb_freq
> 3200 && dev_priv
->fsb_freq
<= 4800) {
1458 static const struct cparams
{
1464 { 1, 1333, 301, 28664 },
1465 { 1, 1066, 294, 24460 },
1466 { 1, 800, 294, 25192 },
1467 { 0, 1333, 276, 27605 },
1468 { 0, 1066, 276, 27605 },
1469 { 0, 800, 231, 23784 },
1472 unsigned long i915_chipset_val(struct drm_i915_private
*dev_priv
)
1474 u64 total_count
, diff
, ret
;
1475 u32 count1
, count2
, count3
, m
= 0, c
= 0;
1476 unsigned long now
= jiffies_to_msecs(jiffies
), diff1
;
1479 diff1
= now
- dev_priv
->last_time1
;
1481 /* Prevent division-by-zero if we are asking too fast.
1482 * Also, we don't get interesting results if we are polling
1483 * faster than once in 10ms, so just return the saved value
1487 return dev_priv
->chipset_power
;
1489 count1
= I915_READ(DMIEC
);
1490 count2
= I915_READ(DDREC
);
1491 count3
= I915_READ(CSIEC
);
1493 total_count
= count1
+ count2
+ count3
;
1495 /* FIXME: handle per-counter overflow */
1496 if (total_count
< dev_priv
->last_count1
) {
1497 diff
= ~0UL - dev_priv
->last_count1
;
1498 diff
+= total_count
;
1500 diff
= total_count
- dev_priv
->last_count1
;
1503 for (i
= 0; i
< ARRAY_SIZE(cparams
); i
++) {
1504 if (cparams
[i
].i
== dev_priv
->c_m
&&
1505 cparams
[i
].t
== dev_priv
->r_t
) {
1512 diff
= div_u64(diff
, diff1
);
1513 ret
= ((m
* diff
) + c
);
1514 ret
= div_u64(ret
, 10);
1516 dev_priv
->last_count1
= total_count
;
1517 dev_priv
->last_time1
= now
;
1519 dev_priv
->chipset_power
= ret
;
1524 unsigned long i915_mch_val(struct drm_i915_private
*dev_priv
)
1526 unsigned long m
, x
, b
;
1529 tsfs
= I915_READ(TSFS
);
1531 m
= ((tsfs
& TSFS_SLOPE_MASK
) >> TSFS_SLOPE_SHIFT
);
1532 x
= I915_READ8(TR1
);
1534 b
= tsfs
& TSFS_INTR_MASK
;
1536 return ((m
* x
) / 127) - b
;
1539 static u16
pvid_to_extvid(struct drm_i915_private
*dev_priv
, u8 pxvid
)
1541 static const struct v_table
{
1542 u16 vd
; /* in .1 mil */
1543 u16 vm
; /* in .1 mil */
1674 if (dev_priv
->info
->is_mobile
)
1675 return v_table
[pxvid
].vm
;
1677 return v_table
[pxvid
].vd
;
1680 void i915_update_gfx_val(struct drm_i915_private
*dev_priv
)
1682 struct timespec now
, diff1
;
1684 unsigned long diffms
;
1687 if (dev_priv
->info
->gen
!= 5)
1690 getrawmonotonic(&now
);
1691 diff1
= timespec_sub(now
, dev_priv
->last_time2
);
1693 /* Don't divide by 0 */
1694 diffms
= diff1
.tv_sec
* 1000 + diff1
.tv_nsec
/ 1000000;
1698 count
= I915_READ(GFXEC
);
1700 if (count
< dev_priv
->last_count2
) {
1701 diff
= ~0UL - dev_priv
->last_count2
;
1704 diff
= count
- dev_priv
->last_count2
;
1707 dev_priv
->last_count2
= count
;
1708 dev_priv
->last_time2
= now
;
1710 /* More magic constants... */
1712 diff
= div_u64(diff
, diffms
* 10);
1713 dev_priv
->gfx_power
= diff
;
1716 unsigned long i915_gfx_val(struct drm_i915_private
*dev_priv
)
1718 unsigned long t
, corr
, state1
, corr2
, state2
;
1721 pxvid
= I915_READ(PXVFREQ_BASE
+ (dev_priv
->cur_delay
* 4));
1722 pxvid
= (pxvid
>> 24) & 0x7f;
1723 ext_v
= pvid_to_extvid(dev_priv
, pxvid
);
1727 t
= i915_mch_val(dev_priv
);
1729 /* Revel in the empirically derived constants */
1731 /* Correction factor in 1/100000 units */
1733 corr
= ((t
* 2349) + 135940);
1735 corr
= ((t
* 964) + 29317);
1737 corr
= ((t
* 301) + 1004);
1739 corr
= corr
* ((150142 * state1
) / 10000 - 78642);
1741 corr2
= (corr
* dev_priv
->corr
);
1743 state2
= (corr2
* state1
) / 10000;
1744 state2
/= 100; /* convert to mW */
1746 i915_update_gfx_val(dev_priv
);
1748 return dev_priv
->gfx_power
+ state2
;
1751 /* Global for IPS driver to get at the current i915 device */
1752 static struct drm_i915_private
*i915_mch_dev
;
1754 * Lock protecting IPS related data structures
1756 * - dev_priv->max_delay
1757 * - dev_priv->min_delay
1759 * - dev_priv->gpu_busy
1761 static DEFINE_SPINLOCK(mchdev_lock
);
1764 * i915_read_mch_val - return value for IPS use
1766 * Calculate and return a value for the IPS driver to use when deciding whether
1767 * we have thermal and power headroom to increase CPU or GPU power budget.
1769 unsigned long i915_read_mch_val(void)
1771 struct drm_i915_private
*dev_priv
;
1772 unsigned long chipset_val
, graphics_val
, ret
= 0;
1774 spin_lock(&mchdev_lock
);
1777 dev_priv
= i915_mch_dev
;
1779 chipset_val
= i915_chipset_val(dev_priv
);
1780 graphics_val
= i915_gfx_val(dev_priv
);
1782 ret
= chipset_val
+ graphics_val
;
1785 spin_unlock(&mchdev_lock
);
1789 EXPORT_SYMBOL_GPL(i915_read_mch_val
);
1792 * i915_gpu_raise - raise GPU frequency limit
1794 * Raise the limit; IPS indicates we have thermal headroom.
1796 bool i915_gpu_raise(void)
1798 struct drm_i915_private
*dev_priv
;
1801 spin_lock(&mchdev_lock
);
1802 if (!i915_mch_dev
) {
1806 dev_priv
= i915_mch_dev
;
1808 if (dev_priv
->max_delay
> dev_priv
->fmax
)
1809 dev_priv
->max_delay
--;
1812 spin_unlock(&mchdev_lock
);
1816 EXPORT_SYMBOL_GPL(i915_gpu_raise
);
1819 * i915_gpu_lower - lower GPU frequency limit
1821 * IPS indicates we're close to a thermal limit, so throttle back the GPU
1822 * frequency maximum.
1824 bool i915_gpu_lower(void)
1826 struct drm_i915_private
*dev_priv
;
1829 spin_lock(&mchdev_lock
);
1830 if (!i915_mch_dev
) {
1834 dev_priv
= i915_mch_dev
;
1836 if (dev_priv
->max_delay
< dev_priv
->min_delay
)
1837 dev_priv
->max_delay
++;
1840 spin_unlock(&mchdev_lock
);
1844 EXPORT_SYMBOL_GPL(i915_gpu_lower
);
1847 * i915_gpu_busy - indicate GPU business to IPS
1849 * Tell the IPS driver whether or not the GPU is busy.
1851 bool i915_gpu_busy(void)
1853 struct drm_i915_private
*dev_priv
;
1856 spin_lock(&mchdev_lock
);
1859 dev_priv
= i915_mch_dev
;
1861 ret
= dev_priv
->busy
;
1864 spin_unlock(&mchdev_lock
);
1868 EXPORT_SYMBOL_GPL(i915_gpu_busy
);
1871 * i915_gpu_turbo_disable - disable graphics turbo
1873 * Disable graphics turbo by resetting the max frequency and setting the
1874 * current frequency to the default.
1876 bool i915_gpu_turbo_disable(void)
1878 struct drm_i915_private
*dev_priv
;
1881 spin_lock(&mchdev_lock
);
1882 if (!i915_mch_dev
) {
1886 dev_priv
= i915_mch_dev
;
1888 dev_priv
->max_delay
= dev_priv
->fstart
;
1890 if (!ironlake_set_drps(dev_priv
->dev
, dev_priv
->fstart
))
1894 spin_unlock(&mchdev_lock
);
1898 EXPORT_SYMBOL_GPL(i915_gpu_turbo_disable
);
1901 * Tells the intel_ips driver that the i915 driver is now loaded, if
1902 * IPS got loaded first.
1904 * This awkward dance is so that neither module has to depend on the
1905 * other in order for IPS to do the appropriate communication of
1906 * GPU turbo limits to i915.
1909 ips_ping_for_i915_load(void)
1913 link
= symbol_get(ips_link_to_i915_driver
);
1916 symbol_put(ips_link_to_i915_driver
);
1921 i915_mtrr_setup(struct drm_i915_private
*dev_priv
, unsigned long base
,
1924 dev_priv
->mm
.gtt_mtrr
= -1;
1926 #if defined(CONFIG_X86_PAT)
1931 /* Set up a WC MTRR for non-PAT systems. This is more common than
1932 * one would think, because the kernel disables PAT on first
1933 * generation Core chips because WC PAT gets overridden by a UC
1934 * MTRR if present. Even if a UC MTRR isn't present.
1936 dev_priv
->mm
.gtt_mtrr
= mtrr_add(base
, size
, MTRR_TYPE_WRCOMB
, 1);
1937 if (dev_priv
->mm
.gtt_mtrr
< 0) {
1938 DRM_INFO("MTRR allocation failed. Graphics "
1939 "performance may suffer.\n");
1944 * i915_driver_load - setup chip and create an initial config
1946 * @flags: startup flags
1948 * The driver load routine has to do several things:
1949 * - drive output discovery via intel_modeset_init()
1950 * - initialize the memory manager
1951 * - allocate initial config memory
1952 * - setup the DRM framebuffer with the allocated memory
1954 int i915_driver_load(struct drm_device
*dev
, unsigned long flags
)
1956 struct drm_i915_private
*dev_priv
;
1957 struct intel_device_info
*info
;
1958 int ret
= 0, mmio_bar
;
1959 uint32_t aperture_size
;
1961 info
= (struct intel_device_info
*) flags
;
1963 /* Refuse to load on gen6+ without kms enabled. */
1964 if (info
->gen
>= 6 && !drm_core_check_feature(dev
, DRIVER_MODESET
))
1968 /* i915 has 4 more counters */
1970 dev
->types
[6] = _DRM_STAT_IRQ
;
1971 dev
->types
[7] = _DRM_STAT_PRIMARY
;
1972 dev
->types
[8] = _DRM_STAT_SECONDARY
;
1973 dev
->types
[9] = _DRM_STAT_DMA
;
1975 dev_priv
= kzalloc(sizeof(drm_i915_private_t
), GFP_KERNEL
);
1976 if (dev_priv
== NULL
)
1979 dev
->dev_private
= (void *)dev_priv
;
1980 dev_priv
->dev
= dev
;
1981 dev_priv
->info
= info
;
1983 if (i915_get_bridge_dev(dev
)) {
1988 pci_set_master(dev
->pdev
);
1990 /* overlay on gen2 is broken and can't address above 1G */
1992 dma_set_coherent_mask(&dev
->pdev
->dev
, DMA_BIT_MASK(30));
1994 /* 965GM sometimes incorrectly writes to hardware status page (HWS)
1995 * using 32bit addressing, overwriting memory if HWS is located
1998 * The documentation also mentions an issue with undefined
1999 * behaviour if any general state is accessed within a page above 4GB,
2000 * which also needs to be handled carefully.
2002 if (IS_BROADWATER(dev
) || IS_CRESTLINE(dev
))
2003 dma_set_coherent_mask(&dev
->pdev
->dev
, DMA_BIT_MASK(32));
2005 mmio_bar
= IS_GEN2(dev
) ? 1 : 0;
2006 dev_priv
->regs
= pci_iomap(dev
->pdev
, mmio_bar
, 0);
2007 if (!dev_priv
->regs
) {
2008 DRM_ERROR("failed to map registers\n");
2013 dev_priv
->mm
.gtt
= intel_gtt_get();
2014 if (!dev_priv
->mm
.gtt
) {
2015 DRM_ERROR("Failed to initialize GTT\n");
2020 aperture_size
= dev_priv
->mm
.gtt
->gtt_mappable_entries
<< PAGE_SHIFT
;
2022 dev_priv
->mm
.gtt_mapping
=
2023 io_mapping_create_wc(dev
->agp
->base
, aperture_size
);
2024 if (dev_priv
->mm
.gtt_mapping
== NULL
) {
2029 i915_mtrr_setup(dev_priv
, dev
->agp
->base
, aperture_size
);
2031 /* The i915 workqueue is primarily used for batched retirement of
2032 * requests (and thus managing bo) once the task has been completed
2033 * by the GPU. i915_gem_retire_requests() is called directly when we
2034 * need high-priority retirement, such as waiting for an explicit
2037 * It is also used for periodic low-priority events, such as
2038 * idle-timers and recording error state.
2040 * All tasks on the workqueue are expected to acquire the dev mutex
2041 * so there is no point in running more than one instance of the
2042 * workqueue at any time: max_active = 1 and NON_REENTRANT.
2044 dev_priv
->wq
= alloc_workqueue("i915",
2045 WQ_UNBOUND
| WQ_NON_REENTRANT
,
2047 if (dev_priv
->wq
== NULL
) {
2048 DRM_ERROR("Failed to create our workqueue.\n");
2053 intel_irq_init(dev
);
2055 /* Try to make sure MCHBAR is enabled before poking at it */
2056 intel_setup_mchbar(dev
);
2057 intel_setup_gmbus(dev
);
2058 intel_opregion_setup(dev
);
2060 /* Make sure the bios did its job and set up vital registers */
2061 intel_setup_bios(dev
);
2066 if (!I915_NEED_GFX_HWS(dev
)) {
2067 ret
= i915_init_phys_hws(dev
);
2069 goto out_gem_unload
;
2072 if (IS_PINEVIEW(dev
))
2073 i915_pineview_get_mem_freq(dev
);
2074 else if (IS_GEN5(dev
))
2075 i915_ironlake_get_mem_freq(dev
);
2077 /* On the 945G/GM, the chipset reports the MSI capability on the
2078 * integrated graphics even though the support isn't actually there
2079 * according to the published specs. It doesn't appear to function
2080 * correctly in testing on 945G.
2081 * This may be a side effect of MSI having been made available for PEG
2082 * and the registers being closely associated.
2084 * According to chipset errata, on the 965GM, MSI interrupts may
2085 * be lost or delayed, but we use them anyways to avoid
2086 * stuck interrupts on some machines.
2088 if (!IS_I945G(dev
) && !IS_I945GM(dev
))
2089 pci_enable_msi(dev
->pdev
);
2091 spin_lock_init(&dev_priv
->gt_lock
);
2092 spin_lock_init(&dev_priv
->irq_lock
);
2093 spin_lock_init(&dev_priv
->error_lock
);
2094 spin_lock_init(&dev_priv
->rps_lock
);
2096 if (IS_IVYBRIDGE(dev
) || IS_HASWELL(dev
))
2097 dev_priv
->num_pipe
= 3;
2098 else if (IS_MOBILE(dev
) || !IS_GEN2(dev
))
2099 dev_priv
->num_pipe
= 2;
2101 dev_priv
->num_pipe
= 1;
2103 ret
= drm_vblank_init(dev
, dev_priv
->num_pipe
);
2105 goto out_gem_unload
;
2107 /* Start out suspended */
2108 dev_priv
->mm
.suspended
= 1;
2110 intel_detect_pch(dev
);
2112 if (drm_core_check_feature(dev
, DRIVER_MODESET
)) {
2113 ret
= i915_load_modeset_init(dev
);
2115 DRM_ERROR("failed to init modeset\n");
2116 goto out_gem_unload
;
2120 i915_setup_sysfs(dev
);
2122 /* Must be done after probing outputs */
2123 intel_opregion_init(dev
);
2124 acpi_video_register();
2126 setup_timer(&dev_priv
->hangcheck_timer
, i915_hangcheck_elapsed
,
2127 (unsigned long) dev
);
2130 spin_lock(&mchdev_lock
);
2131 i915_mch_dev
= dev_priv
;
2132 dev_priv
->mchdev_lock
= &mchdev_lock
;
2133 spin_unlock(&mchdev_lock
);
2135 ips_ping_for_i915_load();
2141 if (dev_priv
->mm
.inactive_shrinker
.shrink
)
2142 unregister_shrinker(&dev_priv
->mm
.inactive_shrinker
);
2144 if (dev
->pdev
->msi_enabled
)
2145 pci_disable_msi(dev
->pdev
);
2147 intel_teardown_gmbus(dev
);
2148 intel_teardown_mchbar(dev
);
2149 destroy_workqueue(dev_priv
->wq
);
2151 if (dev_priv
->mm
.gtt_mtrr
>= 0) {
2152 mtrr_del(dev_priv
->mm
.gtt_mtrr
, dev
->agp
->base
,
2153 dev
->agp
->agp_info
.aper_size
* 1024 * 1024);
2154 dev_priv
->mm
.gtt_mtrr
= -1;
2156 io_mapping_free(dev_priv
->mm
.gtt_mapping
);
2158 pci_iounmap(dev
->pdev
, dev_priv
->regs
);
2160 pci_dev_put(dev_priv
->bridge_dev
);
2166 int i915_driver_unload(struct drm_device
*dev
)
2168 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2171 spin_lock(&mchdev_lock
);
2172 i915_mch_dev
= NULL
;
2173 spin_unlock(&mchdev_lock
);
2175 i915_teardown_sysfs(dev
);
2177 if (dev_priv
->mm
.inactive_shrinker
.shrink
)
2178 unregister_shrinker(&dev_priv
->mm
.inactive_shrinker
);
2180 mutex_lock(&dev
->struct_mutex
);
2181 ret
= i915_gpu_idle(dev
);
2183 DRM_ERROR("failed to idle hardware: %d\n", ret
);
2184 i915_gem_retire_requests(dev
);
2185 mutex_unlock(&dev
->struct_mutex
);
2187 /* Cancel the retire work handler, which should be idle now. */
2188 cancel_delayed_work_sync(&dev_priv
->mm
.retire_work
);
2190 io_mapping_free(dev_priv
->mm
.gtt_mapping
);
2191 if (dev_priv
->mm
.gtt_mtrr
>= 0) {
2192 mtrr_del(dev_priv
->mm
.gtt_mtrr
, dev
->agp
->base
,
2193 dev
->agp
->agp_info
.aper_size
* 1024 * 1024);
2194 dev_priv
->mm
.gtt_mtrr
= -1;
2197 acpi_video_unregister();
2199 if (drm_core_check_feature(dev
, DRIVER_MODESET
)) {
2200 intel_fbdev_fini(dev
);
2201 intel_modeset_cleanup(dev
);
2204 * free the memory space allocated for the child device
2205 * config parsed from VBT
2207 if (dev_priv
->child_dev
&& dev_priv
->child_dev_num
) {
2208 kfree(dev_priv
->child_dev
);
2209 dev_priv
->child_dev
= NULL
;
2210 dev_priv
->child_dev_num
= 0;
2213 vga_switcheroo_unregister_client(dev
->pdev
);
2214 vga_client_register(dev
->pdev
, NULL
, NULL
, NULL
);
2217 /* Free error state after interrupts are fully disabled. */
2218 del_timer_sync(&dev_priv
->hangcheck_timer
);
2219 cancel_work_sync(&dev_priv
->error_work
);
2220 i915_destroy_error_state(dev
);
2222 if (dev
->pdev
->msi_enabled
)
2223 pci_disable_msi(dev
->pdev
);
2225 intel_opregion_fini(dev
);
2227 if (drm_core_check_feature(dev
, DRIVER_MODESET
)) {
2228 /* Flush any outstanding unpin_work. */
2229 flush_workqueue(dev_priv
->wq
);
2231 mutex_lock(&dev
->struct_mutex
);
2232 i915_gem_free_all_phys_object(dev
);
2233 i915_gem_cleanup_ringbuffer(dev
);
2234 mutex_unlock(&dev
->struct_mutex
);
2235 i915_gem_cleanup_aliasing_ppgtt(dev
);
2236 i915_gem_cleanup_stolen(dev
);
2237 drm_mm_takedown(&dev_priv
->mm
.stolen
);
2239 intel_cleanup_overlay(dev
);
2241 if (!I915_NEED_GFX_HWS(dev
))
2245 if (dev_priv
->regs
!= NULL
)
2246 pci_iounmap(dev
->pdev
, dev_priv
->regs
);
2248 intel_teardown_gmbus(dev
);
2249 intel_teardown_mchbar(dev
);
2251 destroy_workqueue(dev_priv
->wq
);
2253 pci_dev_put(dev_priv
->bridge_dev
);
2254 kfree(dev
->dev_private
);
2259 int i915_driver_open(struct drm_device
*dev
, struct drm_file
*file
)
2261 struct drm_i915_file_private
*file_priv
;
2263 DRM_DEBUG_DRIVER("\n");
2264 file_priv
= kmalloc(sizeof(*file_priv
), GFP_KERNEL
);
2268 file
->driver_priv
= file_priv
;
2270 spin_lock_init(&file_priv
->mm
.lock
);
2271 INIT_LIST_HEAD(&file_priv
->mm
.request_list
);
2277 * i915_driver_lastclose - clean up after all DRM clients have exited
2280 * Take care of cleaning up after all DRM clients have exited. In the
2281 * mode setting case, we want to restore the kernel's initial mode (just
2282 * in case the last client left us in a bad state).
2284 * Additionally, in the non-mode setting case, we'll tear down the GTT
2285 * and DMA structures, since the kernel won't be using them, and clea
2288 void i915_driver_lastclose(struct drm_device
* dev
)
2290 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
2292 if (!dev_priv
|| drm_core_check_feature(dev
, DRIVER_MODESET
)) {
2293 intel_fb_restore_mode(dev
);
2294 vga_switcheroo_process_delayed_switch();
2298 i915_gem_lastclose(dev
);
2300 i915_dma_cleanup(dev
);
2303 void i915_driver_preclose(struct drm_device
* dev
, struct drm_file
*file_priv
)
2305 i915_gem_release(dev
, file_priv
);
2308 void i915_driver_postclose(struct drm_device
*dev
, struct drm_file
*file
)
2310 struct drm_i915_file_private
*file_priv
= file
->driver_priv
;
2315 struct drm_ioctl_desc i915_ioctls
[] = {
2316 DRM_IOCTL_DEF_DRV(I915_INIT
, i915_dma_init
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2317 DRM_IOCTL_DEF_DRV(I915_FLUSH
, i915_flush_ioctl
, DRM_AUTH
),
2318 DRM_IOCTL_DEF_DRV(I915_FLIP
, i915_flip_bufs
, DRM_AUTH
),
2319 DRM_IOCTL_DEF_DRV(I915_BATCHBUFFER
, i915_batchbuffer
, DRM_AUTH
),
2320 DRM_IOCTL_DEF_DRV(I915_IRQ_EMIT
, i915_irq_emit
, DRM_AUTH
),
2321 DRM_IOCTL_DEF_DRV(I915_IRQ_WAIT
, i915_irq_wait
, DRM_AUTH
),
2322 DRM_IOCTL_DEF_DRV(I915_GETPARAM
, i915_getparam
, DRM_AUTH
),
2323 DRM_IOCTL_DEF_DRV(I915_SETPARAM
, i915_setparam
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2324 DRM_IOCTL_DEF_DRV(I915_ALLOC
, drm_noop
, DRM_AUTH
),
2325 DRM_IOCTL_DEF_DRV(I915_FREE
, drm_noop
, DRM_AUTH
),
2326 DRM_IOCTL_DEF_DRV(I915_INIT_HEAP
, drm_noop
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2327 DRM_IOCTL_DEF_DRV(I915_CMDBUFFER
, i915_cmdbuffer
, DRM_AUTH
),
2328 DRM_IOCTL_DEF_DRV(I915_DESTROY_HEAP
, drm_noop
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2329 DRM_IOCTL_DEF_DRV(I915_SET_VBLANK_PIPE
, drm_noop
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2330 DRM_IOCTL_DEF_DRV(I915_GET_VBLANK_PIPE
, i915_vblank_pipe_get
, DRM_AUTH
),
2331 DRM_IOCTL_DEF_DRV(I915_VBLANK_SWAP
, i915_vblank_swap
, DRM_AUTH
),
2332 DRM_IOCTL_DEF_DRV(I915_HWS_ADDR
, i915_set_status_page
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2333 DRM_IOCTL_DEF_DRV(I915_GEM_INIT
, i915_gem_init_ioctl
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
|DRM_UNLOCKED
),
2334 DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER
, i915_gem_execbuffer
, DRM_AUTH
|DRM_UNLOCKED
),
2335 DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER2
, i915_gem_execbuffer2
, DRM_AUTH
|DRM_UNLOCKED
),
2336 DRM_IOCTL_DEF_DRV(I915_GEM_PIN
, i915_gem_pin_ioctl
, DRM_AUTH
|DRM_ROOT_ONLY
|DRM_UNLOCKED
),
2337 DRM_IOCTL_DEF_DRV(I915_GEM_UNPIN
, i915_gem_unpin_ioctl
, DRM_AUTH
|DRM_ROOT_ONLY
|DRM_UNLOCKED
),
2338 DRM_IOCTL_DEF_DRV(I915_GEM_BUSY
, i915_gem_busy_ioctl
, DRM_AUTH
|DRM_UNLOCKED
),
2339 DRM_IOCTL_DEF_DRV(I915_GEM_THROTTLE
, i915_gem_throttle_ioctl
, DRM_AUTH
|DRM_UNLOCKED
),
2340 DRM_IOCTL_DEF_DRV(I915_GEM_ENTERVT
, i915_gem_entervt_ioctl
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
|DRM_UNLOCKED
),
2341 DRM_IOCTL_DEF_DRV(I915_GEM_LEAVEVT
, i915_gem_leavevt_ioctl
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
|DRM_UNLOCKED
),
2342 DRM_IOCTL_DEF_DRV(I915_GEM_CREATE
, i915_gem_create_ioctl
, DRM_UNLOCKED
),
2343 DRM_IOCTL_DEF_DRV(I915_GEM_PREAD
, i915_gem_pread_ioctl
, DRM_UNLOCKED
),
2344 DRM_IOCTL_DEF_DRV(I915_GEM_PWRITE
, i915_gem_pwrite_ioctl
, DRM_UNLOCKED
),
2345 DRM_IOCTL_DEF_DRV(I915_GEM_MMAP
, i915_gem_mmap_ioctl
, DRM_UNLOCKED
),
2346 DRM_IOCTL_DEF_DRV(I915_GEM_MMAP_GTT
, i915_gem_mmap_gtt_ioctl
, DRM_UNLOCKED
),
2347 DRM_IOCTL_DEF_DRV(I915_GEM_SET_DOMAIN
, i915_gem_set_domain_ioctl
, DRM_UNLOCKED
),
2348 DRM_IOCTL_DEF_DRV(I915_GEM_SW_FINISH
, i915_gem_sw_finish_ioctl
, DRM_UNLOCKED
),
2349 DRM_IOCTL_DEF_DRV(I915_GEM_SET_TILING
, i915_gem_set_tiling
, DRM_UNLOCKED
),
2350 DRM_IOCTL_DEF_DRV(I915_GEM_GET_TILING
, i915_gem_get_tiling
, DRM_UNLOCKED
),
2351 DRM_IOCTL_DEF_DRV(I915_GEM_GET_APERTURE
, i915_gem_get_aperture_ioctl
, DRM_UNLOCKED
),
2352 DRM_IOCTL_DEF_DRV(I915_GET_PIPE_FROM_CRTC_ID
, intel_get_pipe_from_crtc_id
, DRM_UNLOCKED
),
2353 DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE
, i915_gem_madvise_ioctl
, DRM_UNLOCKED
),
2354 DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE
, intel_overlay_put_image
, DRM_MASTER
|DRM_CONTROL_ALLOW
|DRM_UNLOCKED
),
2355 DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS
, intel_overlay_attrs
, DRM_MASTER
|DRM_CONTROL_ALLOW
|DRM_UNLOCKED
),
2356 DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_COLORKEY
, intel_sprite_set_colorkey
, DRM_MASTER
|DRM_CONTROL_ALLOW
|DRM_UNLOCKED
),
2357 DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_COLORKEY
, intel_sprite_get_colorkey
, DRM_MASTER
|DRM_CONTROL_ALLOW
|DRM_UNLOCKED
),
2360 int i915_max_ioctl
= DRM_ARRAY_SIZE(i915_ioctls
);
2363 * This is really ugly: Because old userspace abused the linux agp interface to
2364 * manage the gtt, we need to claim that all intel devices are agp. For
2365 * otherwise the drm core refuses to initialize the agp support code.
2367 int i915_driver_device_is_agp(struct drm_device
* dev
)