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
32 #include <drm/drm_crtc_helper.h>
33 #include <drm/drm_fb_helper.h>
34 #include "intel_drv.h"
35 #include <drm/i915_drm.h>
37 #include "i915_trace.h"
38 #include <linux/pci.h>
39 #include <linux/console.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 <acpi/video.h>
48 #include <linux/pm_runtime.h>
49 #include <linux/oom.h>
51 #define LP_RING(d) (&((struct drm_i915_private *)(d))->ring[RCS])
53 #define BEGIN_LP_RING(n) \
54 intel_ring_begin(LP_RING(dev_priv), (n))
57 intel_ring_emit(LP_RING(dev_priv), x)
59 #define ADVANCE_LP_RING() \
60 __intel_ring_advance(LP_RING(dev_priv))
63 * Lock test for when it's just for synchronization of ring access.
65 * In that case, we don't need to do it when GEM is initialized as nobody else
66 * has access to the ring.
68 #define RING_LOCK_TEST_WITH_RETURN(dev, file) do { \
69 if (LP_RING(dev->dev_private)->buffer->obj == NULL) \
70 LOCK_TEST_WITH_RETURN(dev, file); \
74 intel_read_legacy_status_page(struct drm_i915_private
*dev_priv
, int reg
)
76 if (I915_NEED_GFX_HWS(dev_priv
->dev
))
77 return ioread32(dev_priv
->dri1
.gfx_hws_cpu_addr
+ reg
);
79 return intel_read_status_page(LP_RING(dev_priv
), reg
);
82 #define READ_HWSP(dev_priv, reg) intel_read_legacy_status_page(dev_priv, reg)
83 #define READ_BREADCRUMB(dev_priv) READ_HWSP(dev_priv, I915_BREADCRUMB_INDEX)
84 #define I915_BREADCRUMB_INDEX 0x21
86 void i915_update_dri1_breadcrumb(struct drm_device
*dev
)
88 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
89 struct drm_i915_master_private
*master_priv
;
92 * The dri breadcrumb update races against the drm master disappearing.
93 * Instead of trying to fix this (this is by far not the only ums issue)
94 * just don't do the update in kms mode.
96 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
99 if (dev
->primary
->master
) {
100 master_priv
= dev
->primary
->master
->driver_priv
;
101 if (master_priv
->sarea_priv
)
102 master_priv
->sarea_priv
->last_dispatch
=
103 READ_BREADCRUMB(dev_priv
);
107 static void i915_write_hws_pga(struct drm_device
*dev
)
109 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
112 addr
= dev_priv
->status_page_dmah
->busaddr
;
113 if (INTEL_INFO(dev
)->gen
>= 4)
114 addr
|= (dev_priv
->status_page_dmah
->busaddr
>> 28) & 0xf0;
115 I915_WRITE(HWS_PGA
, addr
);
119 * Frees the hardware status page, whether it's a physical address or a virtual
120 * address set up by the X Server.
122 static void i915_free_hws(struct drm_device
*dev
)
124 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
125 struct intel_engine_cs
*ring
= LP_RING(dev_priv
);
127 if (dev_priv
->status_page_dmah
) {
128 drm_pci_free(dev
, dev_priv
->status_page_dmah
);
129 dev_priv
->status_page_dmah
= NULL
;
132 if (ring
->status_page
.gfx_addr
) {
133 ring
->status_page
.gfx_addr
= 0;
134 iounmap(dev_priv
->dri1
.gfx_hws_cpu_addr
);
137 /* Need to rewrite hardware status page */
138 I915_WRITE(HWS_PGA
, 0x1ffff000);
141 void i915_kernel_lost_context(struct drm_device
*dev
)
143 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
144 struct drm_i915_master_private
*master_priv
;
145 struct intel_engine_cs
*ring
= LP_RING(dev_priv
);
146 struct intel_ringbuffer
*ringbuf
= ring
->buffer
;
149 * We should never lose context on the ring with modesetting
150 * as we don't expose it to userspace
152 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
155 ringbuf
->head
= I915_READ_HEAD(ring
) & HEAD_ADDR
;
156 ringbuf
->tail
= I915_READ_TAIL(ring
) & TAIL_ADDR
;
157 ringbuf
->space
= ringbuf
->head
- (ringbuf
->tail
+ I915_RING_FREE_SPACE
);
158 if (ringbuf
->space
< 0)
159 ringbuf
->space
+= ringbuf
->size
;
161 if (!dev
->primary
->master
)
164 master_priv
= dev
->primary
->master
->driver_priv
;
165 if (ringbuf
->head
== ringbuf
->tail
&& master_priv
->sarea_priv
)
166 master_priv
->sarea_priv
->perf_boxes
|= I915_BOX_RING_EMPTY
;
169 static int i915_dma_cleanup(struct drm_device
*dev
)
171 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
174 /* Make sure interrupts are disabled here because the uninstall ioctl
175 * may not have been called from userspace and after dev_private
176 * is freed, it's too late.
178 if (dev
->irq_enabled
)
179 drm_irq_uninstall(dev
);
181 mutex_lock(&dev
->struct_mutex
);
182 for (i
= 0; i
< I915_NUM_RINGS
; i
++)
183 intel_cleanup_ring_buffer(&dev_priv
->ring
[i
]);
184 mutex_unlock(&dev
->struct_mutex
);
186 /* Clear the HWS virtual address at teardown */
187 if (I915_NEED_GFX_HWS(dev
))
193 static int i915_initialize(struct drm_device
*dev
, drm_i915_init_t
*init
)
195 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
196 struct drm_i915_master_private
*master_priv
= dev
->primary
->master
->driver_priv
;
199 master_priv
->sarea
= drm_getsarea(dev
);
200 if (master_priv
->sarea
) {
201 master_priv
->sarea_priv
= (drm_i915_sarea_t
*)
202 ((u8
*)master_priv
->sarea
->handle
+ init
->sarea_priv_offset
);
204 DRM_DEBUG_DRIVER("sarea not found assuming DRI2 userspace\n");
207 if (init
->ring_size
!= 0) {
208 if (LP_RING(dev_priv
)->buffer
->obj
!= NULL
) {
209 i915_dma_cleanup(dev
);
210 DRM_ERROR("Client tried to initialize ringbuffer in "
215 ret
= intel_render_ring_init_dri(dev
,
219 i915_dma_cleanup(dev
);
224 dev_priv
->dri1
.cpp
= init
->cpp
;
225 dev_priv
->dri1
.back_offset
= init
->back_offset
;
226 dev_priv
->dri1
.front_offset
= init
->front_offset
;
227 dev_priv
->dri1
.current_page
= 0;
228 if (master_priv
->sarea_priv
)
229 master_priv
->sarea_priv
->pf_current_page
= 0;
231 /* Allow hardware batchbuffers unless told otherwise.
233 dev_priv
->dri1
.allow_batchbuffer
= 1;
238 static int i915_dma_resume(struct drm_device
*dev
)
240 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
241 struct intel_engine_cs
*ring
= LP_RING(dev_priv
);
243 DRM_DEBUG_DRIVER("%s\n", __func__
);
245 if (ring
->buffer
->virtual_start
== NULL
) {
246 DRM_ERROR("can not ioremap virtual address for"
251 /* Program Hardware Status Page */
252 if (!ring
->status_page
.page_addr
) {
253 DRM_ERROR("Can not find hardware status page\n");
256 DRM_DEBUG_DRIVER("hw status page @ %p\n",
257 ring
->status_page
.page_addr
);
258 if (ring
->status_page
.gfx_addr
!= 0)
259 intel_ring_setup_status_page(ring
);
261 i915_write_hws_pga(dev
);
263 DRM_DEBUG_DRIVER("Enabled hardware status page\n");
268 static int i915_dma_init(struct drm_device
*dev
, void *data
,
269 struct drm_file
*file_priv
)
271 drm_i915_init_t
*init
= data
;
274 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
277 switch (init
->func
) {
279 retcode
= i915_initialize(dev
, init
);
281 case I915_CLEANUP_DMA
:
282 retcode
= i915_dma_cleanup(dev
);
284 case I915_RESUME_DMA
:
285 retcode
= i915_dma_resume(dev
);
295 /* Implement basically the same security restrictions as hardware does
296 * for MI_BATCH_NON_SECURE. These can be made stricter at any time.
298 * Most of the calculations below involve calculating the size of a
299 * particular instruction. It's important to get the size right as
300 * that tells us where the next instruction to check is. Any illegal
301 * instruction detected will be given a size of zero, which is a
302 * signal to abort the rest of the buffer.
304 static int validate_cmd(int cmd
)
306 switch (((cmd
>> 29) & 0x7)) {
308 switch ((cmd
>> 23) & 0x3f) {
310 return 1; /* MI_NOOP */
312 return 1; /* MI_FLUSH */
314 return 0; /* disallow everything else */
318 return 0; /* reserved */
320 return (cmd
& 0xff) + 2; /* 2d commands */
322 if (((cmd
>> 24) & 0x1f) <= 0x18)
325 switch ((cmd
>> 24) & 0x1f) {
329 switch ((cmd
>> 16) & 0xff) {
331 return (cmd
& 0x1f) + 2;
333 return (cmd
& 0xf) + 2;
335 return (cmd
& 0xffff) + 2;
339 return (cmd
& 0xffff) + 1;
343 if ((cmd
& (1 << 23)) == 0) /* inline vertices */
344 return (cmd
& 0x1ffff) + 2;
345 else if (cmd
& (1 << 17)) /* indirect random */
346 if ((cmd
& 0xffff) == 0)
347 return 0; /* unknown length, too hard */
349 return (((cmd
& 0xffff) + 1) / 2) + 1;
351 return 2; /* indirect sequential */
362 static int i915_emit_cmds(struct drm_device
*dev
, int *buffer
, int dwords
)
364 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
367 if ((dwords
+1) * sizeof(int) >= LP_RING(dev_priv
)->buffer
->size
- 8)
370 for (i
= 0; i
< dwords
;) {
371 int sz
= validate_cmd(buffer
[i
]);
373 if (sz
== 0 || i
+ sz
> dwords
)
378 ret
= BEGIN_LP_RING((dwords
+1)&~1);
382 for (i
= 0; i
< dwords
; i
++)
393 i915_emit_box(struct drm_device
*dev
,
394 struct drm_clip_rect
*box
,
397 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
400 if (box
->y2
<= box
->y1
|| box
->x2
<= box
->x1
||
401 box
->y2
<= 0 || box
->x2
<= 0) {
402 DRM_ERROR("Bad box %d,%d..%d,%d\n",
403 box
->x1
, box
->y1
, box
->x2
, box
->y2
);
407 if (INTEL_INFO(dev
)->gen
>= 4) {
408 ret
= BEGIN_LP_RING(4);
412 OUT_RING(GFX_OP_DRAWRECT_INFO_I965
);
413 OUT_RING((box
->x1
& 0xffff) | (box
->y1
<< 16));
414 OUT_RING(((box
->x2
- 1) & 0xffff) | ((box
->y2
- 1) << 16));
417 ret
= BEGIN_LP_RING(6);
421 OUT_RING(GFX_OP_DRAWRECT_INFO
);
423 OUT_RING((box
->x1
& 0xffff) | (box
->y1
<< 16));
424 OUT_RING(((box
->x2
- 1) & 0xffff) | ((box
->y2
- 1) << 16));
433 /* XXX: Emitting the counter should really be moved to part of the IRQ
434 * emit. For now, do it in both places:
437 static void i915_emit_breadcrumb(struct drm_device
*dev
)
439 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
440 struct drm_i915_master_private
*master_priv
= dev
->primary
->master
->driver_priv
;
442 dev_priv
->dri1
.counter
++;
443 if (dev_priv
->dri1
.counter
> 0x7FFFFFFFUL
)
444 dev_priv
->dri1
.counter
= 0;
445 if (master_priv
->sarea_priv
)
446 master_priv
->sarea_priv
->last_enqueue
= dev_priv
->dri1
.counter
;
448 if (BEGIN_LP_RING(4) == 0) {
449 OUT_RING(MI_STORE_DWORD_INDEX
);
450 OUT_RING(I915_BREADCRUMB_INDEX
<< MI_STORE_DWORD_INDEX_SHIFT
);
451 OUT_RING(dev_priv
->dri1
.counter
);
457 static int i915_dispatch_cmdbuffer(struct drm_device
*dev
,
458 drm_i915_cmdbuffer_t
*cmd
,
459 struct drm_clip_rect
*cliprects
,
462 int nbox
= cmd
->num_cliprects
;
463 int i
= 0, count
, ret
;
466 DRM_ERROR("alignment");
470 i915_kernel_lost_context(dev
);
472 count
= nbox
? nbox
: 1;
474 for (i
= 0; i
< count
; i
++) {
476 ret
= i915_emit_box(dev
, &cliprects
[i
],
482 ret
= i915_emit_cmds(dev
, cmdbuf
, cmd
->sz
/ 4);
487 i915_emit_breadcrumb(dev
);
491 static int i915_dispatch_batchbuffer(struct drm_device
*dev
,
492 drm_i915_batchbuffer_t
*batch
,
493 struct drm_clip_rect
*cliprects
)
495 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
496 int nbox
= batch
->num_cliprects
;
499 if ((batch
->start
| batch
->used
) & 0x7) {
500 DRM_ERROR("alignment");
504 i915_kernel_lost_context(dev
);
506 count
= nbox
? nbox
: 1;
507 for (i
= 0; i
< count
; i
++) {
509 ret
= i915_emit_box(dev
, &cliprects
[i
],
510 batch
->DR1
, batch
->DR4
);
515 if (!IS_I830(dev
) && !IS_845G(dev
)) {
516 ret
= BEGIN_LP_RING(2);
520 if (INTEL_INFO(dev
)->gen
>= 4) {
521 OUT_RING(MI_BATCH_BUFFER_START
| (2 << 6) | MI_BATCH_NON_SECURE_I965
);
522 OUT_RING(batch
->start
);
524 OUT_RING(MI_BATCH_BUFFER_START
| (2 << 6));
525 OUT_RING(batch
->start
| MI_BATCH_NON_SECURE
);
528 ret
= BEGIN_LP_RING(4);
532 OUT_RING(MI_BATCH_BUFFER
);
533 OUT_RING(batch
->start
| MI_BATCH_NON_SECURE
);
534 OUT_RING(batch
->start
+ batch
->used
- 4);
541 if (IS_G4X(dev
) || IS_GEN5(dev
)) {
542 if (BEGIN_LP_RING(2) == 0) {
543 OUT_RING(MI_FLUSH
| MI_NO_WRITE_FLUSH
| MI_INVALIDATE_ISP
);
549 i915_emit_breadcrumb(dev
);
553 static int i915_dispatch_flip(struct drm_device
*dev
)
555 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
556 struct drm_i915_master_private
*master_priv
=
557 dev
->primary
->master
->driver_priv
;
560 if (!master_priv
->sarea_priv
)
563 DRM_DEBUG_DRIVER("%s: page=%d pfCurrentPage=%d\n",
565 dev_priv
->dri1
.current_page
,
566 master_priv
->sarea_priv
->pf_current_page
);
568 i915_kernel_lost_context(dev
);
570 ret
= BEGIN_LP_RING(10);
574 OUT_RING(MI_FLUSH
| MI_READ_FLUSH
);
577 OUT_RING(CMD_OP_DISPLAYBUFFER_INFO
| ASYNC_FLIP
);
579 if (dev_priv
->dri1
.current_page
== 0) {
580 OUT_RING(dev_priv
->dri1
.back_offset
);
581 dev_priv
->dri1
.current_page
= 1;
583 OUT_RING(dev_priv
->dri1
.front_offset
);
584 dev_priv
->dri1
.current_page
= 0;
588 OUT_RING(MI_WAIT_FOR_EVENT
| MI_WAIT_FOR_PLANE_A_FLIP
);
593 master_priv
->sarea_priv
->last_enqueue
= dev_priv
->dri1
.counter
++;
595 if (BEGIN_LP_RING(4) == 0) {
596 OUT_RING(MI_STORE_DWORD_INDEX
);
597 OUT_RING(I915_BREADCRUMB_INDEX
<< MI_STORE_DWORD_INDEX_SHIFT
);
598 OUT_RING(dev_priv
->dri1
.counter
);
603 master_priv
->sarea_priv
->pf_current_page
= dev_priv
->dri1
.current_page
;
607 static int i915_quiescent(struct drm_device
*dev
)
609 i915_kernel_lost_context(dev
);
610 return intel_ring_idle(LP_RING(dev
->dev_private
));
613 static int i915_flush_ioctl(struct drm_device
*dev
, void *data
,
614 struct drm_file
*file_priv
)
618 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
621 RING_LOCK_TEST_WITH_RETURN(dev
, file_priv
);
623 mutex_lock(&dev
->struct_mutex
);
624 ret
= i915_quiescent(dev
);
625 mutex_unlock(&dev
->struct_mutex
);
630 static int i915_batchbuffer(struct drm_device
*dev
, void *data
,
631 struct drm_file
*file_priv
)
633 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
634 struct drm_i915_master_private
*master_priv
;
635 drm_i915_sarea_t
*sarea_priv
;
636 drm_i915_batchbuffer_t
*batch
= data
;
638 struct drm_clip_rect
*cliprects
= NULL
;
640 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
643 master_priv
= dev
->primary
->master
->driver_priv
;
644 sarea_priv
= (drm_i915_sarea_t
*) master_priv
->sarea_priv
;
646 if (!dev_priv
->dri1
.allow_batchbuffer
) {
647 DRM_ERROR("Batchbuffer ioctl disabled\n");
651 DRM_DEBUG_DRIVER("i915 batchbuffer, start %x used %d cliprects %d\n",
652 batch
->start
, batch
->used
, batch
->num_cliprects
);
654 RING_LOCK_TEST_WITH_RETURN(dev
, file_priv
);
656 if (batch
->num_cliprects
< 0)
659 if (batch
->num_cliprects
) {
660 cliprects
= kcalloc(batch
->num_cliprects
,
663 if (cliprects
== NULL
)
666 ret
= copy_from_user(cliprects
, batch
->cliprects
,
667 batch
->num_cliprects
*
668 sizeof(struct drm_clip_rect
));
675 mutex_lock(&dev
->struct_mutex
);
676 ret
= i915_dispatch_batchbuffer(dev
, batch
, cliprects
);
677 mutex_unlock(&dev
->struct_mutex
);
680 sarea_priv
->last_dispatch
= READ_BREADCRUMB(dev_priv
);
688 static int i915_cmdbuffer(struct drm_device
*dev
, void *data
,
689 struct drm_file
*file_priv
)
691 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
692 struct drm_i915_master_private
*master_priv
;
693 drm_i915_sarea_t
*sarea_priv
;
694 drm_i915_cmdbuffer_t
*cmdbuf
= data
;
695 struct drm_clip_rect
*cliprects
= NULL
;
699 DRM_DEBUG_DRIVER("i915 cmdbuffer, buf %p sz %d cliprects %d\n",
700 cmdbuf
->buf
, cmdbuf
->sz
, cmdbuf
->num_cliprects
);
702 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
705 master_priv
= dev
->primary
->master
->driver_priv
;
706 sarea_priv
= (drm_i915_sarea_t
*) master_priv
->sarea_priv
;
708 RING_LOCK_TEST_WITH_RETURN(dev
, file_priv
);
710 if (cmdbuf
->num_cliprects
< 0)
713 batch_data
= kmalloc(cmdbuf
->sz
, GFP_KERNEL
);
714 if (batch_data
== NULL
)
717 ret
= copy_from_user(batch_data
, cmdbuf
->buf
, cmdbuf
->sz
);
720 goto fail_batch_free
;
723 if (cmdbuf
->num_cliprects
) {
724 cliprects
= kcalloc(cmdbuf
->num_cliprects
,
725 sizeof(*cliprects
), GFP_KERNEL
);
726 if (cliprects
== NULL
) {
728 goto fail_batch_free
;
731 ret
= copy_from_user(cliprects
, cmdbuf
->cliprects
,
732 cmdbuf
->num_cliprects
*
733 sizeof(struct drm_clip_rect
));
740 mutex_lock(&dev
->struct_mutex
);
741 ret
= i915_dispatch_cmdbuffer(dev
, cmdbuf
, cliprects
, batch_data
);
742 mutex_unlock(&dev
->struct_mutex
);
744 DRM_ERROR("i915_dispatch_cmdbuffer failed\n");
749 sarea_priv
->last_dispatch
= READ_BREADCRUMB(dev_priv
);
759 static int i915_emit_irq(struct drm_device
*dev
)
761 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
762 struct drm_i915_master_private
*master_priv
= dev
->primary
->master
->driver_priv
;
764 i915_kernel_lost_context(dev
);
766 DRM_DEBUG_DRIVER("\n");
768 dev_priv
->dri1
.counter
++;
769 if (dev_priv
->dri1
.counter
> 0x7FFFFFFFUL
)
770 dev_priv
->dri1
.counter
= 1;
771 if (master_priv
->sarea_priv
)
772 master_priv
->sarea_priv
->last_enqueue
= dev_priv
->dri1
.counter
;
774 if (BEGIN_LP_RING(4) == 0) {
775 OUT_RING(MI_STORE_DWORD_INDEX
);
776 OUT_RING(I915_BREADCRUMB_INDEX
<< MI_STORE_DWORD_INDEX_SHIFT
);
777 OUT_RING(dev_priv
->dri1
.counter
);
778 OUT_RING(MI_USER_INTERRUPT
);
782 return dev_priv
->dri1
.counter
;
785 static int i915_wait_irq(struct drm_device
*dev
, int irq_nr
)
787 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
788 struct drm_i915_master_private
*master_priv
= dev
->primary
->master
->driver_priv
;
790 struct intel_engine_cs
*ring
= LP_RING(dev_priv
);
792 DRM_DEBUG_DRIVER("irq_nr=%d breadcrumb=%d\n", irq_nr
,
793 READ_BREADCRUMB(dev_priv
));
795 if (READ_BREADCRUMB(dev_priv
) >= irq_nr
) {
796 if (master_priv
->sarea_priv
)
797 master_priv
->sarea_priv
->last_dispatch
= READ_BREADCRUMB(dev_priv
);
801 if (master_priv
->sarea_priv
)
802 master_priv
->sarea_priv
->perf_boxes
|= I915_BOX_WAIT
;
804 if (ring
->irq_get(ring
)) {
805 DRM_WAIT_ON(ret
, ring
->irq_queue
, 3 * HZ
,
806 READ_BREADCRUMB(dev_priv
) >= irq_nr
);
808 } else if (wait_for(READ_BREADCRUMB(dev_priv
) >= irq_nr
, 3000))
812 DRM_ERROR("EBUSY -- rec: %d emitted: %d\n",
813 READ_BREADCRUMB(dev_priv
), (int)dev_priv
->dri1
.counter
);
819 /* Needs the lock as it touches the ring.
821 static int i915_irq_emit(struct drm_device
*dev
, void *data
,
822 struct drm_file
*file_priv
)
824 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
825 drm_i915_irq_emit_t
*emit
= data
;
828 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
831 if (!dev_priv
|| !LP_RING(dev_priv
)->buffer
->virtual_start
) {
832 DRM_ERROR("called with no initialization\n");
836 RING_LOCK_TEST_WITH_RETURN(dev
, file_priv
);
838 mutex_lock(&dev
->struct_mutex
);
839 result
= i915_emit_irq(dev
);
840 mutex_unlock(&dev
->struct_mutex
);
842 if (copy_to_user(emit
->irq_seq
, &result
, sizeof(int))) {
843 DRM_ERROR("copy_to_user\n");
850 /* Doesn't need the hardware lock.
852 static int i915_irq_wait(struct drm_device
*dev
, void *data
,
853 struct drm_file
*file_priv
)
855 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
856 drm_i915_irq_wait_t
*irqwait
= data
;
858 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
862 DRM_ERROR("called with no initialization\n");
866 return i915_wait_irq(dev
, irqwait
->irq_seq
);
869 static int i915_vblank_pipe_get(struct drm_device
*dev
, void *data
,
870 struct drm_file
*file_priv
)
872 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
873 drm_i915_vblank_pipe_t
*pipe
= data
;
875 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
879 DRM_ERROR("called with no initialization\n");
883 pipe
->pipe
= DRM_I915_VBLANK_PIPE_A
| DRM_I915_VBLANK_PIPE_B
;
889 * Schedule buffer swap at given vertical blank.
891 static int i915_vblank_swap(struct drm_device
*dev
, void *data
,
892 struct drm_file
*file_priv
)
894 /* The delayed swap mechanism was fundamentally racy, and has been
895 * removed. The model was that the client requested a delayed flip/swap
896 * from the kernel, then waited for vblank before continuing to perform
897 * rendering. The problem was that the kernel might wake the client
898 * up before it dispatched the vblank swap (since the lock has to be
899 * held while touching the ringbuffer), in which case the client would
900 * clear and start the next frame before the swap occurred, and
901 * flicker would occur in addition to likely missing the vblank.
903 * In the absence of this ioctl, userland falls back to a correct path
904 * of waiting for a vblank, then dispatching the swap on its own.
905 * Context switching to userland and back is plenty fast enough for
906 * meeting the requirements of vblank swapping.
911 static int i915_flip_bufs(struct drm_device
*dev
, void *data
,
912 struct drm_file
*file_priv
)
916 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
919 DRM_DEBUG_DRIVER("%s\n", __func__
);
921 RING_LOCK_TEST_WITH_RETURN(dev
, file_priv
);
923 mutex_lock(&dev
->struct_mutex
);
924 ret
= i915_dispatch_flip(dev
);
925 mutex_unlock(&dev
->struct_mutex
);
930 static int i915_getparam(struct drm_device
*dev
, void *data
,
931 struct drm_file
*file_priv
)
933 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
934 drm_i915_getparam_t
*param
= data
;
938 DRM_ERROR("called with no initialization\n");
942 switch (param
->param
) {
943 case I915_PARAM_IRQ_ACTIVE
:
944 value
= dev
->pdev
->irq
? 1 : 0;
946 case I915_PARAM_ALLOW_BATCHBUFFER
:
947 value
= dev_priv
->dri1
.allow_batchbuffer
? 1 : 0;
949 case I915_PARAM_LAST_DISPATCH
:
950 value
= READ_BREADCRUMB(dev_priv
);
952 case I915_PARAM_CHIPSET_ID
:
953 value
= dev
->pdev
->device
;
955 case I915_PARAM_HAS_GEM
:
958 case I915_PARAM_NUM_FENCES_AVAIL
:
959 value
= dev_priv
->num_fence_regs
- dev_priv
->fence_reg_start
;
961 case I915_PARAM_HAS_OVERLAY
:
962 value
= dev_priv
->overlay
? 1 : 0;
964 case I915_PARAM_HAS_PAGEFLIPPING
:
967 case I915_PARAM_HAS_EXECBUF2
:
971 case I915_PARAM_HAS_BSD
:
972 value
= intel_ring_initialized(&dev_priv
->ring
[VCS
]);
974 case I915_PARAM_HAS_BLT
:
975 value
= intel_ring_initialized(&dev_priv
->ring
[BCS
]);
977 case I915_PARAM_HAS_VEBOX
:
978 value
= intel_ring_initialized(&dev_priv
->ring
[VECS
]);
980 case I915_PARAM_HAS_RELAXED_FENCING
:
983 case I915_PARAM_HAS_COHERENT_RINGS
:
986 case I915_PARAM_HAS_EXEC_CONSTANTS
:
987 value
= INTEL_INFO(dev
)->gen
>= 4;
989 case I915_PARAM_HAS_RELAXED_DELTA
:
992 case I915_PARAM_HAS_GEN7_SOL_RESET
:
995 case I915_PARAM_HAS_LLC
:
996 value
= HAS_LLC(dev
);
998 case I915_PARAM_HAS_WT
:
1001 case I915_PARAM_HAS_ALIASING_PPGTT
:
1002 value
= USES_PPGTT(dev
);
1004 case I915_PARAM_HAS_WAIT_TIMEOUT
:
1007 case I915_PARAM_HAS_SEMAPHORES
:
1008 value
= i915_semaphore_is_enabled(dev
);
1010 case I915_PARAM_HAS_PRIME_VMAP_FLUSH
:
1013 case I915_PARAM_HAS_SECURE_BATCHES
:
1014 value
= capable(CAP_SYS_ADMIN
);
1016 case I915_PARAM_HAS_PINNED_BATCHES
:
1019 case I915_PARAM_HAS_EXEC_NO_RELOC
:
1022 case I915_PARAM_HAS_EXEC_HANDLE_LUT
:
1025 case I915_PARAM_CMD_PARSER_VERSION
:
1026 value
= i915_cmd_parser_get_version();
1029 DRM_DEBUG("Unknown parameter %d\n", param
->param
);
1033 if (copy_to_user(param
->value
, &value
, sizeof(int))) {
1034 DRM_ERROR("copy_to_user failed\n");
1041 static int i915_setparam(struct drm_device
*dev
, void *data
,
1042 struct drm_file
*file_priv
)
1044 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1045 drm_i915_setparam_t
*param
= data
;
1048 DRM_ERROR("called with no initialization\n");
1052 switch (param
->param
) {
1053 case I915_SETPARAM_USE_MI_BATCHBUFFER_START
:
1055 case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY
:
1057 case I915_SETPARAM_ALLOW_BATCHBUFFER
:
1058 dev_priv
->dri1
.allow_batchbuffer
= param
->value
? 1 : 0;
1060 case I915_SETPARAM_NUM_USED_FENCES
:
1061 if (param
->value
> dev_priv
->num_fence_regs
||
1064 /* Userspace can use first N regs */
1065 dev_priv
->fence_reg_start
= param
->value
;
1068 DRM_DEBUG_DRIVER("unknown parameter %d\n",
1076 static int i915_set_status_page(struct drm_device
*dev
, void *data
,
1077 struct drm_file
*file_priv
)
1079 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1080 drm_i915_hws_addr_t
*hws
= data
;
1081 struct intel_engine_cs
*ring
;
1083 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
1086 if (!I915_NEED_GFX_HWS(dev
))
1090 DRM_ERROR("called with no initialization\n");
1094 if (drm_core_check_feature(dev
, DRIVER_MODESET
)) {
1095 WARN(1, "tried to set status page when mode setting active\n");
1099 DRM_DEBUG_DRIVER("set status page addr 0x%08x\n", (u32
)hws
->addr
);
1101 ring
= LP_RING(dev_priv
);
1102 ring
->status_page
.gfx_addr
= hws
->addr
& (0x1ffff<<12);
1104 dev_priv
->dri1
.gfx_hws_cpu_addr
=
1105 ioremap_wc(dev_priv
->gtt
.mappable_base
+ hws
->addr
, 4096);
1106 if (dev_priv
->dri1
.gfx_hws_cpu_addr
== NULL
) {
1107 i915_dma_cleanup(dev
);
1108 ring
->status_page
.gfx_addr
= 0;
1109 DRM_ERROR("can not ioremap virtual address for"
1110 " G33 hw status page\n");
1114 memset_io(dev_priv
->dri1
.gfx_hws_cpu_addr
, 0, PAGE_SIZE
);
1115 I915_WRITE(HWS_PGA
, ring
->status_page
.gfx_addr
);
1117 DRM_DEBUG_DRIVER("load hws HWS_PGA with gfx mem 0x%x\n",
1118 ring
->status_page
.gfx_addr
);
1119 DRM_DEBUG_DRIVER("load hws at %p\n",
1120 ring
->status_page
.page_addr
);
1124 static int i915_get_bridge_dev(struct drm_device
*dev
)
1126 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1128 dev_priv
->bridge_dev
= pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
1129 if (!dev_priv
->bridge_dev
) {
1130 DRM_ERROR("bridge device not found\n");
1136 #define MCHBAR_I915 0x44
1137 #define MCHBAR_I965 0x48
1138 #define MCHBAR_SIZE (4*4096)
1140 #define DEVEN_REG 0x54
1141 #define DEVEN_MCHBAR_EN (1 << 28)
1143 /* Allocate space for the MCH regs if needed, return nonzero on error */
1145 intel_alloc_mchbar_resource(struct drm_device
*dev
)
1147 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1148 int reg
= INTEL_INFO(dev
)->gen
>= 4 ? MCHBAR_I965
: MCHBAR_I915
;
1149 u32 temp_lo
, temp_hi
= 0;
1153 if (INTEL_INFO(dev
)->gen
>= 4)
1154 pci_read_config_dword(dev_priv
->bridge_dev
, reg
+ 4, &temp_hi
);
1155 pci_read_config_dword(dev_priv
->bridge_dev
, reg
, &temp_lo
);
1156 mchbar_addr
= ((u64
)temp_hi
<< 32) | temp_lo
;
1158 /* If ACPI doesn't have it, assume we need to allocate it ourselves */
1161 pnp_range_reserved(mchbar_addr
, mchbar_addr
+ MCHBAR_SIZE
))
1165 /* Get some space for it */
1166 dev_priv
->mch_res
.name
= "i915 MCHBAR";
1167 dev_priv
->mch_res
.flags
= IORESOURCE_MEM
;
1168 ret
= pci_bus_alloc_resource(dev_priv
->bridge_dev
->bus
,
1170 MCHBAR_SIZE
, MCHBAR_SIZE
,
1172 0, pcibios_align_resource
,
1173 dev_priv
->bridge_dev
);
1175 DRM_DEBUG_DRIVER("failed bus alloc: %d\n", ret
);
1176 dev_priv
->mch_res
.start
= 0;
1180 if (INTEL_INFO(dev
)->gen
>= 4)
1181 pci_write_config_dword(dev_priv
->bridge_dev
, reg
+ 4,
1182 upper_32_bits(dev_priv
->mch_res
.start
));
1184 pci_write_config_dword(dev_priv
->bridge_dev
, reg
,
1185 lower_32_bits(dev_priv
->mch_res
.start
));
1189 /* Setup MCHBAR if possible, return true if we should disable it again */
1191 intel_setup_mchbar(struct drm_device
*dev
)
1193 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1194 int mchbar_reg
= INTEL_INFO(dev
)->gen
>= 4 ? MCHBAR_I965
: MCHBAR_I915
;
1198 if (IS_VALLEYVIEW(dev
))
1201 dev_priv
->mchbar_need_disable
= false;
1203 if (IS_I915G(dev
) || IS_I915GM(dev
)) {
1204 pci_read_config_dword(dev_priv
->bridge_dev
, DEVEN_REG
, &temp
);
1205 enabled
= !!(temp
& DEVEN_MCHBAR_EN
);
1207 pci_read_config_dword(dev_priv
->bridge_dev
, mchbar_reg
, &temp
);
1211 /* If it's already enabled, don't have to do anything */
1215 if (intel_alloc_mchbar_resource(dev
))
1218 dev_priv
->mchbar_need_disable
= true;
1220 /* Space is allocated or reserved, so enable it. */
1221 if (IS_I915G(dev
) || IS_I915GM(dev
)) {
1222 pci_write_config_dword(dev_priv
->bridge_dev
, DEVEN_REG
,
1223 temp
| DEVEN_MCHBAR_EN
);
1225 pci_read_config_dword(dev_priv
->bridge_dev
, mchbar_reg
, &temp
);
1226 pci_write_config_dword(dev_priv
->bridge_dev
, mchbar_reg
, temp
| 1);
1231 intel_teardown_mchbar(struct drm_device
*dev
)
1233 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1234 int mchbar_reg
= INTEL_INFO(dev
)->gen
>= 4 ? MCHBAR_I965
: MCHBAR_I915
;
1237 if (dev_priv
->mchbar_need_disable
) {
1238 if (IS_I915G(dev
) || IS_I915GM(dev
)) {
1239 pci_read_config_dword(dev_priv
->bridge_dev
, DEVEN_REG
, &temp
);
1240 temp
&= ~DEVEN_MCHBAR_EN
;
1241 pci_write_config_dword(dev_priv
->bridge_dev
, DEVEN_REG
, temp
);
1243 pci_read_config_dword(dev_priv
->bridge_dev
, mchbar_reg
, &temp
);
1245 pci_write_config_dword(dev_priv
->bridge_dev
, mchbar_reg
, temp
);
1249 if (dev_priv
->mch_res
.start
)
1250 release_resource(&dev_priv
->mch_res
);
1253 /* true = enable decode, false = disable decoder */
1254 static unsigned int i915_vga_set_decode(void *cookie
, bool state
)
1256 struct drm_device
*dev
= cookie
;
1258 intel_modeset_vga_set_state(dev
, state
);
1260 return VGA_RSRC_LEGACY_IO
| VGA_RSRC_LEGACY_MEM
|
1261 VGA_RSRC_NORMAL_IO
| VGA_RSRC_NORMAL_MEM
;
1263 return VGA_RSRC_NORMAL_IO
| VGA_RSRC_NORMAL_MEM
;
1266 static void i915_switcheroo_set_state(struct pci_dev
*pdev
, enum vga_switcheroo_state state
)
1268 struct drm_device
*dev
= pci_get_drvdata(pdev
);
1269 pm_message_t pmm
= { .event
= PM_EVENT_SUSPEND
};
1271 if (state
== VGA_SWITCHEROO_ON
) {
1272 pr_info("switched on\n");
1273 dev
->switch_power_state
= DRM_SWITCH_POWER_CHANGING
;
1274 /* i915 resume handler doesn't set to D0 */
1275 pci_set_power_state(dev
->pdev
, PCI_D0
);
1277 dev
->switch_power_state
= DRM_SWITCH_POWER_ON
;
1279 pr_err("switched off\n");
1280 dev
->switch_power_state
= DRM_SWITCH_POWER_CHANGING
;
1281 i915_suspend(dev
, pmm
);
1282 dev
->switch_power_state
= DRM_SWITCH_POWER_OFF
;
1286 static bool i915_switcheroo_can_switch(struct pci_dev
*pdev
)
1288 struct drm_device
*dev
= pci_get_drvdata(pdev
);
1291 * FIXME: open_count is protected by drm_global_mutex but that would lead to
1292 * locking inversion with the driver load path. And the access here is
1293 * completely racy anyway. So don't bother with locking for now.
1295 return dev
->open_count
== 0;
1298 static const struct vga_switcheroo_client_ops i915_switcheroo_ops
= {
1299 .set_gpu_state
= i915_switcheroo_set_state
,
1301 .can_switch
= i915_switcheroo_can_switch
,
1304 static int i915_load_modeset_init(struct drm_device
*dev
)
1306 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1309 ret
= intel_parse_bios(dev
);
1311 DRM_INFO("failed to find VBIOS tables\n");
1313 /* If we have > 1 VGA cards, then we need to arbitrate access
1314 * to the common VGA resources.
1316 * If we are a secondary display controller (!PCI_DISPLAY_CLASS_VGA),
1317 * then we do not take part in VGA arbitration and the
1318 * vga_client_register() fails with -ENODEV.
1320 ret
= vga_client_register(dev
->pdev
, dev
, NULL
, i915_vga_set_decode
);
1321 if (ret
&& ret
!= -ENODEV
)
1324 intel_register_dsm_handler();
1326 ret
= vga_switcheroo_register_client(dev
->pdev
, &i915_switcheroo_ops
, false);
1328 goto cleanup_vga_client
;
1330 /* Initialise stolen first so that we may reserve preallocated
1331 * objects for the BIOS to KMS transition.
1333 ret
= i915_gem_init_stolen(dev
);
1335 goto cleanup_vga_switcheroo
;
1337 intel_power_domains_init_hw(dev_priv
);
1339 ret
= drm_irq_install(dev
, dev
->pdev
->irq
);
1341 goto cleanup_gem_stolen
;
1343 dev_priv
->pm
._irqs_disabled
= false;
1345 /* Important: The output setup functions called by modeset_init need
1346 * working irqs for e.g. gmbus and dp aux transfers. */
1347 intel_modeset_init(dev
);
1349 ret
= i915_gem_init(dev
);
1353 INIT_WORK(&dev_priv
->console_resume_work
, intel_console_resume
);
1355 intel_modeset_gem_init(dev
);
1357 /* Always safe in the mode setting case. */
1358 /* FIXME: do pre/post-mode set stuff in core KMS code */
1359 dev
->vblank_disable_allowed
= true;
1360 if (INTEL_INFO(dev
)->num_pipes
== 0)
1363 ret
= intel_fbdev_init(dev
);
1367 /* Only enable hotplug handling once the fbdev is fully set up. */
1368 intel_hpd_init(dev
);
1371 * Some ports require correctly set-up hpd registers for detection to
1372 * work properly (leading to ghost connected connector status), e.g. VGA
1373 * on gm45. Hence we can only set up the initial fbdev config after hpd
1374 * irqs are fully enabled. Now we should scan for the initial config
1375 * only once hotplug handling is enabled, but due to screwed-up locking
1376 * around kms/fbdev init we can't protect the fdbev initial config
1377 * scanning against hotplug events. Hence do this first and ignore the
1378 * tiny window where we will loose hotplug notifactions.
1380 intel_fbdev_initial_config(dev
);
1382 drm_kms_helper_poll_init(dev
);
1387 mutex_lock(&dev
->struct_mutex
);
1388 i915_gem_cleanup_ringbuffer(dev
);
1389 i915_gem_context_fini(dev
);
1390 mutex_unlock(&dev
->struct_mutex
);
1392 drm_irq_uninstall(dev
);
1394 i915_gem_cleanup_stolen(dev
);
1395 cleanup_vga_switcheroo
:
1396 vga_switcheroo_unregister_client(dev
->pdev
);
1398 vga_client_register(dev
->pdev
, NULL
, NULL
, NULL
);
1403 int i915_master_create(struct drm_device
*dev
, struct drm_master
*master
)
1405 struct drm_i915_master_private
*master_priv
;
1407 master_priv
= kzalloc(sizeof(*master_priv
), GFP_KERNEL
);
1411 master
->driver_priv
= master_priv
;
1415 void i915_master_destroy(struct drm_device
*dev
, struct drm_master
*master
)
1417 struct drm_i915_master_private
*master_priv
= master
->driver_priv
;
1424 master
->driver_priv
= NULL
;
1427 #if IS_ENABLED(CONFIG_FB)
1428 static int i915_kick_out_firmware_fb(struct drm_i915_private
*dev_priv
)
1430 struct apertures_struct
*ap
;
1431 struct pci_dev
*pdev
= dev_priv
->dev
->pdev
;
1435 ap
= alloc_apertures(1);
1439 ap
->ranges
[0].base
= dev_priv
->gtt
.mappable_base
;
1440 ap
->ranges
[0].size
= dev_priv
->gtt
.mappable_end
;
1443 pdev
->resource
[PCI_ROM_RESOURCE
].flags
& IORESOURCE_ROM_SHADOW
;
1445 ret
= remove_conflicting_framebuffers(ap
, "inteldrmfb", primary
);
1452 static int i915_kick_out_firmware_fb(struct drm_i915_private
*dev_priv
)
1458 #if !defined(CONFIG_VGA_CONSOLE)
1459 static int i915_kick_out_vgacon(struct drm_i915_private
*dev_priv
)
1463 #elif !defined(CONFIG_DUMMY_CONSOLE)
1464 static int i915_kick_out_vgacon(struct drm_i915_private
*dev_priv
)
1469 static int i915_kick_out_vgacon(struct drm_i915_private
*dev_priv
)
1473 DRM_INFO("Replacing VGA console driver\n");
1476 if (con_is_bound(&vga_con
))
1477 ret
= do_take_over_console(&dummy_con
, 0, MAX_NR_CONSOLES
- 1, 1);
1479 ret
= do_unregister_con_driver(&vga_con
);
1481 /* Ignore "already unregistered". */
1491 static void i915_dump_device_info(struct drm_i915_private
*dev_priv
)
1493 const struct intel_device_info
*info
= &dev_priv
->info
;
1495 #define PRINT_S(name) "%s"
1497 #define PRINT_FLAG(name) info->name ? #name "," : ""
1499 DRM_DEBUG_DRIVER("i915 device info: gen=%i, pciid=0x%04x rev=0x%02x flags="
1500 DEV_INFO_FOR_EACH_FLAG(PRINT_S
, SEP_EMPTY
),
1502 dev_priv
->dev
->pdev
->device
,
1503 dev_priv
->dev
->pdev
->revision
,
1504 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG
, SEP_COMMA
));
1512 * Determine various intel_device_info fields at runtime.
1514 * Use it when either:
1515 * - it's judged too laborious to fill n static structures with the limit
1516 * when a simple if statement does the job,
1517 * - run-time checks (eg read fuse/strap registers) are needed.
1519 * This function needs to be called:
1520 * - after the MMIO has been setup as we are reading registers,
1521 * - after the PCH has been detected,
1522 * - before the first usage of the fields it can tweak.
1524 static void intel_device_info_runtime_init(struct drm_device
*dev
)
1526 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1527 struct intel_device_info
*info
;
1530 info
= (struct intel_device_info
*)&dev_priv
->info
;
1532 if (IS_VALLEYVIEW(dev
))
1534 info
->num_sprites
[pipe
] = 2;
1537 info
->num_sprites
[pipe
] = 1;
1539 if (i915
.disable_display
) {
1540 DRM_INFO("Display disabled (module parameter)\n");
1541 info
->num_pipes
= 0;
1542 } else if (info
->num_pipes
> 0 &&
1543 (INTEL_INFO(dev
)->gen
== 7 || INTEL_INFO(dev
)->gen
== 8) &&
1544 !IS_VALLEYVIEW(dev
)) {
1545 u32 fuse_strap
= I915_READ(FUSE_STRAP
);
1546 u32 sfuse_strap
= I915_READ(SFUSE_STRAP
);
1549 * SFUSE_STRAP is supposed to have a bit signalling the display
1550 * is fused off. Unfortunately it seems that, at least in
1551 * certain cases, fused off display means that PCH display
1552 * reads don't land anywhere. In that case, we read 0s.
1554 * On CPT/PPT, we can detect this case as SFUSE_STRAP_FUSE_LOCK
1555 * should be set when taking over after the firmware.
1557 if (fuse_strap
& ILK_INTERNAL_DISPLAY_DISABLE
||
1558 sfuse_strap
& SFUSE_STRAP_DISPLAY_DISABLED
||
1559 (dev_priv
->pch_type
== PCH_CPT
&&
1560 !(sfuse_strap
& SFUSE_STRAP_FUSE_LOCK
))) {
1561 DRM_INFO("Display fused off, disabling\n");
1562 info
->num_pipes
= 0;
1568 * i915_driver_load - setup chip and create an initial config
1570 * @flags: startup flags
1572 * The driver load routine has to do several things:
1573 * - drive output discovery via intel_modeset_init()
1574 * - initialize the memory manager
1575 * - allocate initial config memory
1576 * - setup the DRM framebuffer with the allocated memory
1578 int i915_driver_load(struct drm_device
*dev
, unsigned long flags
)
1580 struct drm_i915_private
*dev_priv
;
1581 struct intel_device_info
*info
, *device_info
;
1582 int ret
= 0, mmio_bar
, mmio_size
;
1583 uint32_t aperture_size
;
1585 info
= (struct intel_device_info
*) flags
;
1587 /* Refuse to load on gen6+ without kms enabled. */
1588 if (info
->gen
>= 6 && !drm_core_check_feature(dev
, DRIVER_MODESET
)) {
1589 DRM_INFO("Your hardware requires kernel modesetting (KMS)\n");
1590 DRM_INFO("See CONFIG_DRM_I915_KMS, nomodeset, and i915.modeset parameters\n");
1594 /* UMS needs agp support. */
1595 if (!drm_core_check_feature(dev
, DRIVER_MODESET
) && !dev
->agp
)
1598 dev_priv
= kzalloc(sizeof(*dev_priv
), GFP_KERNEL
);
1599 if (dev_priv
== NULL
)
1602 dev
->dev_private
= dev_priv
;
1603 dev_priv
->dev
= dev
;
1605 /* Setup the write-once "constant" device info */
1606 device_info
= (struct intel_device_info
*)&dev_priv
->info
;
1607 memcpy(device_info
, info
, sizeof(dev_priv
->info
));
1608 device_info
->device_id
= dev
->pdev
->device
;
1610 spin_lock_init(&dev_priv
->irq_lock
);
1611 spin_lock_init(&dev_priv
->gpu_error
.lock
);
1612 spin_lock_init(&dev_priv
->backlight_lock
);
1613 spin_lock_init(&dev_priv
->uncore
.lock
);
1614 spin_lock_init(&dev_priv
->mm
.object_stat_lock
);
1615 spin_lock_init(&dev_priv
->mmio_flip_lock
);
1616 mutex_init(&dev_priv
->dpio_lock
);
1617 mutex_init(&dev_priv
->modeset_restore_lock
);
1619 intel_pm_setup(dev
);
1621 intel_display_crc_init(dev
);
1623 i915_dump_device_info(dev_priv
);
1625 /* Not all pre-production machines fall into this category, only the
1626 * very first ones. Almost everything should work, except for maybe
1627 * suspend/resume. And we don't implement workarounds that affect only
1628 * pre-production machines. */
1629 if (IS_HSW_EARLY_SDV(dev
))
1630 DRM_INFO("This is an early pre-production Haswell machine. "
1631 "It may not be fully functional.\n");
1633 if (i915_get_bridge_dev(dev
)) {
1638 mmio_bar
= IS_GEN2(dev
) ? 1 : 0;
1639 /* Before gen4, the registers and the GTT are behind different BARs.
1640 * However, from gen4 onwards, the registers and the GTT are shared
1641 * in the same BAR, so we want to restrict this ioremap from
1642 * clobbering the GTT which we want ioremap_wc instead. Fortunately,
1643 * the register BAR remains the same size for all the earlier
1644 * generations up to Ironlake.
1647 mmio_size
= 512*1024;
1649 mmio_size
= 2*1024*1024;
1651 dev_priv
->regs
= pci_iomap(dev
->pdev
, mmio_bar
, mmio_size
);
1652 if (!dev_priv
->regs
) {
1653 DRM_ERROR("failed to map registers\n");
1658 /* This must be called before any calls to HAS_PCH_* */
1659 intel_detect_pch(dev
);
1661 intel_uncore_init(dev
);
1663 ret
= i915_gem_gtt_init(dev
);
1667 if (drm_core_check_feature(dev
, DRIVER_MODESET
)) {
1668 ret
= i915_kick_out_vgacon(dev_priv
);
1670 DRM_ERROR("failed to remove conflicting VGA console\n");
1674 ret
= i915_kick_out_firmware_fb(dev_priv
);
1676 DRM_ERROR("failed to remove conflicting framebuffer drivers\n");
1681 pci_set_master(dev
->pdev
);
1683 /* overlay on gen2 is broken and can't address above 1G */
1685 dma_set_coherent_mask(&dev
->pdev
->dev
, DMA_BIT_MASK(30));
1687 /* 965GM sometimes incorrectly writes to hardware status page (HWS)
1688 * using 32bit addressing, overwriting memory if HWS is located
1691 * The documentation also mentions an issue with undefined
1692 * behaviour if any general state is accessed within a page above 4GB,
1693 * which also needs to be handled carefully.
1695 if (IS_BROADWATER(dev
) || IS_CRESTLINE(dev
))
1696 dma_set_coherent_mask(&dev
->pdev
->dev
, DMA_BIT_MASK(32));
1698 aperture_size
= dev_priv
->gtt
.mappable_end
;
1700 dev_priv
->gtt
.mappable
=
1701 io_mapping_create_wc(dev_priv
->gtt
.mappable_base
,
1703 if (dev_priv
->gtt
.mappable
== NULL
) {
1708 dev_priv
->gtt
.mtrr
= arch_phys_wc_add(dev_priv
->gtt
.mappable_base
,
1711 /* The i915 workqueue is primarily used for batched retirement of
1712 * requests (and thus managing bo) once the task has been completed
1713 * by the GPU. i915_gem_retire_requests() is called directly when we
1714 * need high-priority retirement, such as waiting for an explicit
1717 * It is also used for periodic low-priority events, such as
1718 * idle-timers and recording error state.
1720 * All tasks on the workqueue are expected to acquire the dev mutex
1721 * so there is no point in running more than one instance of the
1722 * workqueue at any time. Use an ordered one.
1724 dev_priv
->wq
= alloc_ordered_workqueue("i915", 0);
1725 if (dev_priv
->wq
== NULL
) {
1726 DRM_ERROR("Failed to create our workqueue.\n");
1731 dev_priv
->dp_wq
= alloc_ordered_workqueue("i915-dp", 0);
1732 if (dev_priv
->dp_wq
== NULL
) {
1733 DRM_ERROR("Failed to create our dp workqueue.\n");
1738 intel_irq_init(dev
);
1739 intel_uncore_sanitize(dev
);
1741 /* Try to make sure MCHBAR is enabled before poking at it */
1742 intel_setup_mchbar(dev
);
1743 intel_setup_gmbus(dev
);
1744 intel_opregion_setup(dev
);
1746 intel_setup_bios(dev
);
1750 /* On the 945G/GM, the chipset reports the MSI capability on the
1751 * integrated graphics even though the support isn't actually there
1752 * according to the published specs. It doesn't appear to function
1753 * correctly in testing on 945G.
1754 * This may be a side effect of MSI having been made available for PEG
1755 * and the registers being closely associated.
1757 * According to chipset errata, on the 965GM, MSI interrupts may
1758 * be lost or delayed, but we use them anyways to avoid
1759 * stuck interrupts on some machines.
1761 if (!IS_I945G(dev
) && !IS_I945GM(dev
))
1762 pci_enable_msi(dev
->pdev
);
1764 intel_device_info_runtime_init(dev
);
1766 if (INTEL_INFO(dev
)->num_pipes
) {
1767 ret
= drm_vblank_init(dev
, INTEL_INFO(dev
)->num_pipes
);
1769 goto out_gem_unload
;
1772 intel_power_domains_init(dev_priv
);
1774 if (drm_core_check_feature(dev
, DRIVER_MODESET
)) {
1775 ret
= i915_load_modeset_init(dev
);
1777 DRM_ERROR("failed to init modeset\n");
1778 goto out_power_well
;
1781 /* Start out suspended in ums mode. */
1782 dev_priv
->ums
.mm_suspended
= 1;
1785 i915_setup_sysfs(dev
);
1787 if (INTEL_INFO(dev
)->num_pipes
) {
1788 /* Must be done after probing outputs */
1789 intel_opregion_init(dev
);
1790 acpi_video_register();
1794 intel_gpu_ips_init(dev_priv
);
1796 intel_init_runtime_pm(dev_priv
);
1801 intel_power_domains_remove(dev_priv
);
1802 drm_vblank_cleanup(dev
);
1804 WARN_ON(unregister_oom_notifier(&dev_priv
->mm
.oom_notifier
));
1805 unregister_shrinker(&dev_priv
->mm
.shrinker
);
1807 if (dev
->pdev
->msi_enabled
)
1808 pci_disable_msi(dev
->pdev
);
1810 intel_teardown_gmbus(dev
);
1811 intel_teardown_mchbar(dev
);
1812 pm_qos_remove_request(&dev_priv
->pm_qos
);
1813 destroy_workqueue(dev_priv
->dp_wq
);
1815 destroy_workqueue(dev_priv
->wq
);
1817 arch_phys_wc_del(dev_priv
->gtt
.mtrr
);
1818 io_mapping_free(dev_priv
->gtt
.mappable
);
1820 i915_global_gtt_cleanup(dev
);
1822 intel_uncore_fini(dev
);
1823 pci_iounmap(dev
->pdev
, dev_priv
->regs
);
1825 pci_dev_put(dev_priv
->bridge_dev
);
1828 kmem_cache_destroy(dev_priv
->slab
);
1833 int i915_driver_unload(struct drm_device
*dev
)
1835 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1838 ret
= i915_gem_suspend(dev
);
1840 DRM_ERROR("failed to idle hardware: %d\n", ret
);
1844 intel_fini_runtime_pm(dev_priv
);
1846 intel_gpu_ips_teardown();
1848 /* The i915.ko module is still not prepared to be loaded when
1849 * the power well is not enabled, so just enable it in case
1850 * we're going to unload/reload. */
1851 intel_display_set_init_power(dev_priv
, true);
1852 intel_power_domains_remove(dev_priv
);
1854 i915_teardown_sysfs(dev
);
1856 WARN_ON(unregister_oom_notifier(&dev_priv
->mm
.oom_notifier
));
1857 unregister_shrinker(&dev_priv
->mm
.shrinker
);
1859 io_mapping_free(dev_priv
->gtt
.mappable
);
1860 arch_phys_wc_del(dev_priv
->gtt
.mtrr
);
1862 acpi_video_unregister();
1864 if (drm_core_check_feature(dev
, DRIVER_MODESET
)) {
1865 intel_fbdev_fini(dev
);
1866 intel_modeset_cleanup(dev
);
1867 cancel_work_sync(&dev_priv
->console_resume_work
);
1870 * free the memory space allocated for the child device
1871 * config parsed from VBT
1873 if (dev_priv
->vbt
.child_dev
&& dev_priv
->vbt
.child_dev_num
) {
1874 kfree(dev_priv
->vbt
.child_dev
);
1875 dev_priv
->vbt
.child_dev
= NULL
;
1876 dev_priv
->vbt
.child_dev_num
= 0;
1879 vga_switcheroo_unregister_client(dev
->pdev
);
1880 vga_client_register(dev
->pdev
, NULL
, NULL
, NULL
);
1883 /* Free error state after interrupts are fully disabled. */
1884 del_timer_sync(&dev_priv
->gpu_error
.hangcheck_timer
);
1885 cancel_work_sync(&dev_priv
->gpu_error
.work
);
1886 i915_destroy_error_state(dev
);
1888 if (dev
->pdev
->msi_enabled
)
1889 pci_disable_msi(dev
->pdev
);
1891 intel_opregion_fini(dev
);
1893 if (drm_core_check_feature(dev
, DRIVER_MODESET
)) {
1894 /* Flush any outstanding unpin_work. */
1895 flush_workqueue(dev_priv
->wq
);
1897 mutex_lock(&dev
->struct_mutex
);
1898 i915_gem_cleanup_ringbuffer(dev
);
1899 i915_gem_context_fini(dev
);
1900 mutex_unlock(&dev
->struct_mutex
);
1901 i915_gem_cleanup_stolen(dev
);
1903 if (!I915_NEED_GFX_HWS(dev
))
1907 drm_vblank_cleanup(dev
);
1909 intel_teardown_gmbus(dev
);
1910 intel_teardown_mchbar(dev
);
1912 destroy_workqueue(dev_priv
->dp_wq
);
1913 destroy_workqueue(dev_priv
->wq
);
1914 pm_qos_remove_request(&dev_priv
->pm_qos
);
1916 i915_global_gtt_cleanup(dev
);
1918 intel_uncore_fini(dev
);
1919 if (dev_priv
->regs
!= NULL
)
1920 pci_iounmap(dev
->pdev
, dev_priv
->regs
);
1923 kmem_cache_destroy(dev_priv
->slab
);
1925 pci_dev_put(dev_priv
->bridge_dev
);
1931 int i915_driver_open(struct drm_device
*dev
, struct drm_file
*file
)
1935 ret
= i915_gem_open(dev
, file
);
1943 * i915_driver_lastclose - clean up after all DRM clients have exited
1946 * Take care of cleaning up after all DRM clients have exited. In the
1947 * mode setting case, we want to restore the kernel's initial mode (just
1948 * in case the last client left us in a bad state).
1950 * Additionally, in the non-mode setting case, we'll tear down the GTT
1951 * and DMA structures, since the kernel won't be using them, and clea
1954 void i915_driver_lastclose(struct drm_device
*dev
)
1956 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1958 /* On gen6+ we refuse to init without kms enabled, but then the drm core
1959 * goes right around and calls lastclose. Check for this and don't clean
1964 if (drm_core_check_feature(dev
, DRIVER_MODESET
)) {
1965 intel_fbdev_restore_mode(dev
);
1966 vga_switcheroo_process_delayed_switch();
1970 i915_gem_lastclose(dev
);
1972 i915_dma_cleanup(dev
);
1975 void i915_driver_preclose(struct drm_device
*dev
, struct drm_file
*file
)
1977 mutex_lock(&dev
->struct_mutex
);
1978 i915_gem_context_close(dev
, file
);
1979 i915_gem_release(dev
, file
);
1980 mutex_unlock(&dev
->struct_mutex
);
1982 if (drm_core_check_feature(dev
, DRIVER_MODESET
))
1983 intel_modeset_preclose(dev
, file
);
1986 void i915_driver_postclose(struct drm_device
*dev
, struct drm_file
*file
)
1988 struct drm_i915_file_private
*file_priv
= file
->driver_priv
;
1990 if (file_priv
&& file_priv
->bsd_ring
)
1991 file_priv
->bsd_ring
= NULL
;
1995 const struct drm_ioctl_desc i915_ioctls
[] = {
1996 DRM_IOCTL_DEF_DRV(I915_INIT
, i915_dma_init
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
1997 DRM_IOCTL_DEF_DRV(I915_FLUSH
, i915_flush_ioctl
, DRM_AUTH
),
1998 DRM_IOCTL_DEF_DRV(I915_FLIP
, i915_flip_bufs
, DRM_AUTH
),
1999 DRM_IOCTL_DEF_DRV(I915_BATCHBUFFER
, i915_batchbuffer
, DRM_AUTH
),
2000 DRM_IOCTL_DEF_DRV(I915_IRQ_EMIT
, i915_irq_emit
, DRM_AUTH
),
2001 DRM_IOCTL_DEF_DRV(I915_IRQ_WAIT
, i915_irq_wait
, DRM_AUTH
),
2002 DRM_IOCTL_DEF_DRV(I915_GETPARAM
, i915_getparam
, DRM_AUTH
|DRM_RENDER_ALLOW
),
2003 DRM_IOCTL_DEF_DRV(I915_SETPARAM
, i915_setparam
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2004 DRM_IOCTL_DEF_DRV(I915_ALLOC
, drm_noop
, DRM_AUTH
),
2005 DRM_IOCTL_DEF_DRV(I915_FREE
, drm_noop
, DRM_AUTH
),
2006 DRM_IOCTL_DEF_DRV(I915_INIT_HEAP
, drm_noop
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2007 DRM_IOCTL_DEF_DRV(I915_CMDBUFFER
, i915_cmdbuffer
, DRM_AUTH
),
2008 DRM_IOCTL_DEF_DRV(I915_DESTROY_HEAP
, drm_noop
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2009 DRM_IOCTL_DEF_DRV(I915_SET_VBLANK_PIPE
, drm_noop
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2010 DRM_IOCTL_DEF_DRV(I915_GET_VBLANK_PIPE
, i915_vblank_pipe_get
, DRM_AUTH
),
2011 DRM_IOCTL_DEF_DRV(I915_VBLANK_SWAP
, i915_vblank_swap
, DRM_AUTH
),
2012 DRM_IOCTL_DEF_DRV(I915_HWS_ADDR
, i915_set_status_page
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
2013 DRM_IOCTL_DEF_DRV(I915_GEM_INIT
, i915_gem_init_ioctl
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
|DRM_UNLOCKED
),
2014 DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER
, i915_gem_execbuffer
, DRM_AUTH
|DRM_UNLOCKED
),
2015 DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER2
, i915_gem_execbuffer2
, DRM_AUTH
|DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2016 DRM_IOCTL_DEF_DRV(I915_GEM_PIN
, i915_gem_pin_ioctl
, DRM_AUTH
|DRM_ROOT_ONLY
|DRM_UNLOCKED
),
2017 DRM_IOCTL_DEF_DRV(I915_GEM_UNPIN
, i915_gem_unpin_ioctl
, DRM_AUTH
|DRM_ROOT_ONLY
|DRM_UNLOCKED
),
2018 DRM_IOCTL_DEF_DRV(I915_GEM_BUSY
, i915_gem_busy_ioctl
, DRM_AUTH
|DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2019 DRM_IOCTL_DEF_DRV(I915_GEM_SET_CACHING
, i915_gem_set_caching_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2020 DRM_IOCTL_DEF_DRV(I915_GEM_GET_CACHING
, i915_gem_get_caching_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2021 DRM_IOCTL_DEF_DRV(I915_GEM_THROTTLE
, i915_gem_throttle_ioctl
, DRM_AUTH
|DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2022 DRM_IOCTL_DEF_DRV(I915_GEM_ENTERVT
, i915_gem_entervt_ioctl
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
|DRM_UNLOCKED
),
2023 DRM_IOCTL_DEF_DRV(I915_GEM_LEAVEVT
, i915_gem_leavevt_ioctl
, DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
|DRM_UNLOCKED
),
2024 DRM_IOCTL_DEF_DRV(I915_GEM_CREATE
, i915_gem_create_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2025 DRM_IOCTL_DEF_DRV(I915_GEM_PREAD
, i915_gem_pread_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2026 DRM_IOCTL_DEF_DRV(I915_GEM_PWRITE
, i915_gem_pwrite_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2027 DRM_IOCTL_DEF_DRV(I915_GEM_MMAP
, i915_gem_mmap_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2028 DRM_IOCTL_DEF_DRV(I915_GEM_MMAP_GTT
, i915_gem_mmap_gtt_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2029 DRM_IOCTL_DEF_DRV(I915_GEM_SET_DOMAIN
, i915_gem_set_domain_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2030 DRM_IOCTL_DEF_DRV(I915_GEM_SW_FINISH
, i915_gem_sw_finish_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2031 DRM_IOCTL_DEF_DRV(I915_GEM_SET_TILING
, i915_gem_set_tiling
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2032 DRM_IOCTL_DEF_DRV(I915_GEM_GET_TILING
, i915_gem_get_tiling
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2033 DRM_IOCTL_DEF_DRV(I915_GEM_GET_APERTURE
, i915_gem_get_aperture_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2034 DRM_IOCTL_DEF_DRV(I915_GET_PIPE_FROM_CRTC_ID
, intel_get_pipe_from_crtc_id
, DRM_UNLOCKED
),
2035 DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE
, i915_gem_madvise_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2036 DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE
, intel_overlay_put_image
, DRM_MASTER
|DRM_CONTROL_ALLOW
|DRM_UNLOCKED
),
2037 DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS
, intel_overlay_attrs
, DRM_MASTER
|DRM_CONTROL_ALLOW
|DRM_UNLOCKED
),
2038 DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_COLORKEY
, intel_sprite_set_colorkey
, DRM_MASTER
|DRM_CONTROL_ALLOW
|DRM_UNLOCKED
),
2039 DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_COLORKEY
, intel_sprite_get_colorkey
, DRM_MASTER
|DRM_CONTROL_ALLOW
|DRM_UNLOCKED
),
2040 DRM_IOCTL_DEF_DRV(I915_GEM_WAIT
, i915_gem_wait_ioctl
, DRM_AUTH
|DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2041 DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_CREATE
, i915_gem_context_create_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2042 DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_DESTROY
, i915_gem_context_destroy_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2043 DRM_IOCTL_DEF_DRV(I915_REG_READ
, i915_reg_read_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2044 DRM_IOCTL_DEF_DRV(I915_GET_RESET_STATS
, i915_get_reset_stats_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2045 DRM_IOCTL_DEF_DRV(I915_GEM_USERPTR
, i915_gem_userptr_ioctl
, DRM_UNLOCKED
|DRM_RENDER_ALLOW
),
2048 int i915_max_ioctl
= ARRAY_SIZE(i915_ioctls
);
2051 * This is really ugly: Because old userspace abused the linux agp interface to
2052 * manage the gtt, we need to claim that all intel devices are agp. For
2053 * otherwise the drm core refuses to initialize the agp support code.
2055 int i915_driver_device_is_agp(struct drm_device
*dev
)