2 * Copyright © 2008 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eric Anholt <eric@anholt.net>
25 * Keith Packard <keithp@keithp.com>
29 #include <linux/seq_file.h>
30 #include <linux/debugfs.h>
31 #include <linux/slab.h>
32 #include <linux/export.h>
35 #include "intel_drv.h"
36 #include "intel_ringbuffer.h"
40 #define DRM_I915_RING_DEBUG 1
43 #if defined(CONFIG_DEBUG_FS)
53 static const char *yesno(int v
)
55 return v
? "yes" : "no";
58 static int i915_capabilities(struct seq_file
*m
, void *data
)
60 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
61 struct drm_device
*dev
= node
->minor
->dev
;
62 const struct intel_device_info
*info
= INTEL_INFO(dev
);
64 seq_printf(m
, "gen: %d\n", info
->gen
);
65 seq_printf(m
, "pch: %d\n", INTEL_PCH_TYPE(dev
));
66 #define B(x) seq_printf(m, #x ": %s\n", yesno(info->x))
80 B(cursor_needs_physical
);
82 B(overlay_needs_physical
);
91 static const char *get_pin_flag(struct drm_i915_gem_object
*obj
)
93 if (obj
->user_pin_count
> 0)
95 else if (obj
->pin_count
> 0)
101 static const char *get_tiling_flag(struct drm_i915_gem_object
*obj
)
103 switch (obj
->tiling_mode
) {
105 case I915_TILING_NONE
: return " ";
106 case I915_TILING_X
: return "X";
107 case I915_TILING_Y
: return "Y";
111 static const char *cache_level_str(int type
)
114 case I915_CACHE_NONE
: return " uncached";
115 case I915_CACHE_LLC
: return " snooped (LLC)";
116 case I915_CACHE_LLC_MLC
: return " snooped (LLC+MLC)";
122 describe_obj(struct seq_file
*m
, struct drm_i915_gem_object
*obj
)
124 seq_printf(m
, "%p: %s%s %8zdKiB %04x %04x %d %d%s%s%s",
127 get_tiling_flag(obj
),
128 obj
->base
.size
/ 1024,
129 obj
->base
.read_domains
,
130 obj
->base
.write_domain
,
131 obj
->last_rendering_seqno
,
132 obj
->last_fenced_seqno
,
133 cache_level_str(obj
->cache_level
),
134 obj
->dirty
? " dirty" : "",
135 obj
->madv
== I915_MADV_DONTNEED
? " purgeable" : "");
137 seq_printf(m
, " (name: %d)", obj
->base
.name
);
138 if (obj
->fence_reg
!= I915_FENCE_REG_NONE
)
139 seq_printf(m
, " (fence: %d)", obj
->fence_reg
);
140 if (obj
->gtt_space
!= NULL
)
141 seq_printf(m
, " (gtt offset: %08x, size: %08x)",
142 obj
->gtt_offset
, (unsigned int)obj
->gtt_space
->size
);
143 if (obj
->pin_mappable
|| obj
->fault_mappable
) {
145 if (obj
->pin_mappable
)
147 if (obj
->fault_mappable
)
150 seq_printf(m
, " (%s mappable)", s
);
152 if (obj
->ring
!= NULL
)
153 seq_printf(m
, " (%s)", obj
->ring
->name
);
156 static int i915_gem_object_list_info(struct seq_file
*m
, void *data
)
158 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
159 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
160 struct list_head
*head
;
161 struct drm_device
*dev
= node
->minor
->dev
;
162 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
163 struct drm_i915_gem_object
*obj
;
164 size_t total_obj_size
, total_gtt_size
;
167 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
173 seq_printf(m
, "Active:\n");
174 head
= &dev_priv
->mm
.active_list
;
177 seq_printf(m
, "Inactive:\n");
178 head
= &dev_priv
->mm
.inactive_list
;
181 seq_printf(m
, "Pinned:\n");
182 head
= &dev_priv
->mm
.pinned_list
;
185 seq_printf(m
, "Flushing:\n");
186 head
= &dev_priv
->mm
.flushing_list
;
188 case DEFERRED_FREE_LIST
:
189 seq_printf(m
, "Deferred free:\n");
190 head
= &dev_priv
->mm
.deferred_free_list
;
193 mutex_unlock(&dev
->struct_mutex
);
197 total_obj_size
= total_gtt_size
= count
= 0;
198 list_for_each_entry(obj
, head
, mm_list
) {
200 describe_obj(m
, obj
);
202 total_obj_size
+= obj
->base
.size
;
203 total_gtt_size
+= obj
->gtt_space
->size
;
206 mutex_unlock(&dev
->struct_mutex
);
208 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
209 count
, total_obj_size
, total_gtt_size
);
213 #define count_objects(list, member) do { \
214 list_for_each_entry(obj, list, member) { \
215 size += obj->gtt_space->size; \
217 if (obj->map_and_fenceable) { \
218 mappable_size += obj->gtt_space->size; \
224 static int i915_gem_object_info(struct seq_file
*m
, void* data
)
226 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
227 struct drm_device
*dev
= node
->minor
->dev
;
228 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
229 u32 count
, mappable_count
;
230 size_t size
, mappable_size
;
231 struct drm_i915_gem_object
*obj
;
234 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
238 seq_printf(m
, "%u objects, %zu bytes\n",
239 dev_priv
->mm
.object_count
,
240 dev_priv
->mm
.object_memory
);
242 size
= count
= mappable_size
= mappable_count
= 0;
243 count_objects(&dev_priv
->mm
.gtt_list
, gtt_list
);
244 seq_printf(m
, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
245 count
, mappable_count
, size
, mappable_size
);
247 size
= count
= mappable_size
= mappable_count
= 0;
248 count_objects(&dev_priv
->mm
.active_list
, mm_list
);
249 count_objects(&dev_priv
->mm
.flushing_list
, mm_list
);
250 seq_printf(m
, " %u [%u] active objects, %zu [%zu] bytes\n",
251 count
, mappable_count
, size
, mappable_size
);
253 size
= count
= mappable_size
= mappable_count
= 0;
254 count_objects(&dev_priv
->mm
.pinned_list
, mm_list
);
255 seq_printf(m
, " %u [%u] pinned objects, %zu [%zu] bytes\n",
256 count
, mappable_count
, size
, mappable_size
);
258 size
= count
= mappable_size
= mappable_count
= 0;
259 count_objects(&dev_priv
->mm
.inactive_list
, mm_list
);
260 seq_printf(m
, " %u [%u] inactive objects, %zu [%zu] bytes\n",
261 count
, mappable_count
, size
, mappable_size
);
263 size
= count
= mappable_size
= mappable_count
= 0;
264 count_objects(&dev_priv
->mm
.deferred_free_list
, mm_list
);
265 seq_printf(m
, " %u [%u] freed objects, %zu [%zu] bytes\n",
266 count
, mappable_count
, size
, mappable_size
);
268 size
= count
= mappable_size
= mappable_count
= 0;
269 list_for_each_entry(obj
, &dev_priv
->mm
.gtt_list
, gtt_list
) {
270 if (obj
->fault_mappable
) {
271 size
+= obj
->gtt_space
->size
;
274 if (obj
->pin_mappable
) {
275 mappable_size
+= obj
->gtt_space
->size
;
279 seq_printf(m
, "%u pinned mappable objects, %zu bytes\n",
280 mappable_count
, mappable_size
);
281 seq_printf(m
, "%u fault mappable objects, %zu bytes\n",
284 seq_printf(m
, "%zu [%zu] gtt total\n",
285 dev_priv
->mm
.gtt_total
, dev_priv
->mm
.mappable_gtt_total
);
287 mutex_unlock(&dev
->struct_mutex
);
292 static int i915_gem_gtt_info(struct seq_file
*m
, void* data
)
294 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
295 struct drm_device
*dev
= node
->minor
->dev
;
296 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
297 struct drm_i915_gem_object
*obj
;
298 size_t total_obj_size
, total_gtt_size
;
301 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
305 total_obj_size
= total_gtt_size
= count
= 0;
306 list_for_each_entry(obj
, &dev_priv
->mm
.gtt_list
, gtt_list
) {
308 describe_obj(m
, obj
);
310 total_obj_size
+= obj
->base
.size
;
311 total_gtt_size
+= obj
->gtt_space
->size
;
315 mutex_unlock(&dev
->struct_mutex
);
317 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
318 count
, total_obj_size
, total_gtt_size
);
324 static int i915_gem_pageflip_info(struct seq_file
*m
, void *data
)
326 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
327 struct drm_device
*dev
= node
->minor
->dev
;
329 struct intel_crtc
*crtc
;
331 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, base
.head
) {
332 const char pipe
= pipe_name(crtc
->pipe
);
333 const char plane
= plane_name(crtc
->plane
);
334 struct intel_unpin_work
*work
;
336 spin_lock_irqsave(&dev
->event_lock
, flags
);
337 work
= crtc
->unpin_work
;
339 seq_printf(m
, "No flip due on pipe %c (plane %c)\n",
342 if (!work
->pending
) {
343 seq_printf(m
, "Flip queued on pipe %c (plane %c)\n",
346 seq_printf(m
, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
349 if (work
->enable_stall_check
)
350 seq_printf(m
, "Stall check enabled, ");
352 seq_printf(m
, "Stall check waiting for page flip ioctl, ");
353 seq_printf(m
, "%d prepares\n", work
->pending
);
355 if (work
->old_fb_obj
) {
356 struct drm_i915_gem_object
*obj
= work
->old_fb_obj
;
358 seq_printf(m
, "Old framebuffer gtt_offset 0x%08x\n", obj
->gtt_offset
);
360 if (work
->pending_flip_obj
) {
361 struct drm_i915_gem_object
*obj
= work
->pending_flip_obj
;
363 seq_printf(m
, "New framebuffer gtt_offset 0x%08x\n", obj
->gtt_offset
);
366 spin_unlock_irqrestore(&dev
->event_lock
, flags
);
372 static int i915_gem_request_info(struct seq_file
*m
, void *data
)
374 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
375 struct drm_device
*dev
= node
->minor
->dev
;
376 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
377 struct drm_i915_gem_request
*gem_request
;
380 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
385 if (!list_empty(&dev_priv
->ring
[RCS
].request_list
)) {
386 seq_printf(m
, "Render requests:\n");
387 list_for_each_entry(gem_request
,
388 &dev_priv
->ring
[RCS
].request_list
,
390 seq_printf(m
, " %d @ %d\n",
392 (int) (jiffies
- gem_request
->emitted_jiffies
));
396 if (!list_empty(&dev_priv
->ring
[VCS
].request_list
)) {
397 seq_printf(m
, "BSD requests:\n");
398 list_for_each_entry(gem_request
,
399 &dev_priv
->ring
[VCS
].request_list
,
401 seq_printf(m
, " %d @ %d\n",
403 (int) (jiffies
- gem_request
->emitted_jiffies
));
407 if (!list_empty(&dev_priv
->ring
[BCS
].request_list
)) {
408 seq_printf(m
, "BLT requests:\n");
409 list_for_each_entry(gem_request
,
410 &dev_priv
->ring
[BCS
].request_list
,
412 seq_printf(m
, " %d @ %d\n",
414 (int) (jiffies
- gem_request
->emitted_jiffies
));
418 mutex_unlock(&dev
->struct_mutex
);
421 seq_printf(m
, "No requests\n");
426 static void i915_ring_seqno_info(struct seq_file
*m
,
427 struct intel_ring_buffer
*ring
)
429 if (ring
->get_seqno
) {
430 seq_printf(m
, "Current sequence (%s): %d\n",
431 ring
->name
, ring
->get_seqno(ring
));
432 seq_printf(m
, "Waiter sequence (%s): %d\n",
433 ring
->name
, ring
->waiting_seqno
);
434 seq_printf(m
, "IRQ sequence (%s): %d\n",
435 ring
->name
, ring
->irq_seqno
);
439 static int i915_gem_seqno_info(struct seq_file
*m
, void *data
)
441 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
442 struct drm_device
*dev
= node
->minor
->dev
;
443 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
446 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
450 for (i
= 0; i
< I915_NUM_RINGS
; i
++)
451 i915_ring_seqno_info(m
, &dev_priv
->ring
[i
]);
453 mutex_unlock(&dev
->struct_mutex
);
459 static int i915_interrupt_info(struct seq_file
*m
, void *data
)
461 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
462 struct drm_device
*dev
= node
->minor
->dev
;
463 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
466 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
470 if (!HAS_PCH_SPLIT(dev
)) {
471 seq_printf(m
, "Interrupt enable: %08x\n",
473 seq_printf(m
, "Interrupt identity: %08x\n",
475 seq_printf(m
, "Interrupt mask: %08x\n",
478 seq_printf(m
, "Pipe %c stat: %08x\n",
480 I915_READ(PIPESTAT(pipe
)));
482 seq_printf(m
, "North Display Interrupt enable: %08x\n",
484 seq_printf(m
, "North Display Interrupt identity: %08x\n",
486 seq_printf(m
, "North Display Interrupt mask: %08x\n",
488 seq_printf(m
, "South Display Interrupt enable: %08x\n",
490 seq_printf(m
, "South Display Interrupt identity: %08x\n",
492 seq_printf(m
, "South Display Interrupt mask: %08x\n",
494 seq_printf(m
, "Graphics Interrupt enable: %08x\n",
496 seq_printf(m
, "Graphics Interrupt identity: %08x\n",
498 seq_printf(m
, "Graphics Interrupt mask: %08x\n",
501 seq_printf(m
, "Interrupts received: %d\n",
502 atomic_read(&dev_priv
->irq_received
));
503 for (i
= 0; i
< I915_NUM_RINGS
; i
++) {
504 if (IS_GEN6(dev
) || IS_GEN7(dev
)) {
505 seq_printf(m
, "Graphics Interrupt mask (%s): %08x\n",
506 dev_priv
->ring
[i
].name
,
507 I915_READ_IMR(&dev_priv
->ring
[i
]));
509 i915_ring_seqno_info(m
, &dev_priv
->ring
[i
]);
511 mutex_unlock(&dev
->struct_mutex
);
516 static int i915_gem_fence_regs_info(struct seq_file
*m
, void *data
)
518 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
519 struct drm_device
*dev
= node
->minor
->dev
;
520 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
523 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
527 seq_printf(m
, "Reserved fences = %d\n", dev_priv
->fence_reg_start
);
528 seq_printf(m
, "Total fences = %d\n", dev_priv
->num_fence_regs
);
529 for (i
= 0; i
< dev_priv
->num_fence_regs
; i
++) {
530 struct drm_i915_gem_object
*obj
= dev_priv
->fence_regs
[i
].obj
;
532 seq_printf(m
, "Fenced object[%2d] = ", i
);
534 seq_printf(m
, "unused");
536 describe_obj(m
, obj
);
540 mutex_unlock(&dev
->struct_mutex
);
544 static int i915_hws_info(struct seq_file
*m
, void *data
)
546 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
547 struct drm_device
*dev
= node
->minor
->dev
;
548 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
549 struct intel_ring_buffer
*ring
;
550 const volatile u32 __iomem
*hws
;
553 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
554 hws
= (volatile u32 __iomem
*)ring
->status_page
.page_addr
;
558 for (i
= 0; i
< 4096 / sizeof(u32
) / 4; i
+= 4) {
559 seq_printf(m
, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
561 hws
[i
], hws
[i
+ 1], hws
[i
+ 2], hws
[i
+ 3]);
566 static void i915_dump_object(struct seq_file
*m
,
567 struct io_mapping
*mapping
,
568 struct drm_i915_gem_object
*obj
)
570 int page
, page_count
, i
;
572 page_count
= obj
->base
.size
/ PAGE_SIZE
;
573 for (page
= 0; page
< page_count
; page
++) {
574 u32
*mem
= io_mapping_map_wc(mapping
,
575 obj
->gtt_offset
+ page
* PAGE_SIZE
);
576 for (i
= 0; i
< PAGE_SIZE
; i
+= 4)
577 seq_printf(m
, "%08x : %08x\n", i
, mem
[i
/ 4]);
578 io_mapping_unmap(mem
);
582 static int i915_batchbuffer_info(struct seq_file
*m
, void *data
)
584 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
585 struct drm_device
*dev
= node
->minor
->dev
;
586 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
587 struct drm_i915_gem_object
*obj
;
590 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
594 list_for_each_entry(obj
, &dev_priv
->mm
.active_list
, mm_list
) {
595 if (obj
->base
.read_domains
& I915_GEM_DOMAIN_COMMAND
) {
596 seq_printf(m
, "--- gtt_offset = 0x%08x\n", obj
->gtt_offset
);
597 i915_dump_object(m
, dev_priv
->mm
.gtt_mapping
, obj
);
601 mutex_unlock(&dev
->struct_mutex
);
605 static int i915_ringbuffer_data(struct seq_file
*m
, void *data
)
607 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
608 struct drm_device
*dev
= node
->minor
->dev
;
609 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
610 struct intel_ring_buffer
*ring
;
613 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
617 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
619 seq_printf(m
, "No ringbuffer setup\n");
621 const u8 __iomem
*virt
= ring
->virtual_start
;
624 for (off
= 0; off
< ring
->size
; off
+= 4) {
625 uint32_t *ptr
= (uint32_t *)(virt
+ off
);
626 seq_printf(m
, "%08x : %08x\n", off
, *ptr
);
629 mutex_unlock(&dev
->struct_mutex
);
634 static int i915_ringbuffer_info(struct seq_file
*m
, void *data
)
636 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
637 struct drm_device
*dev
= node
->minor
->dev
;
638 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
639 struct intel_ring_buffer
*ring
;
642 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
646 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
650 seq_printf(m
, "Ring %s:\n", ring
->name
);
651 seq_printf(m
, " Head : %08x\n", I915_READ_HEAD(ring
) & HEAD_ADDR
);
652 seq_printf(m
, " Tail : %08x\n", I915_READ_TAIL(ring
) & TAIL_ADDR
);
653 seq_printf(m
, " Size : %08x\n", ring
->size
);
654 seq_printf(m
, " Active : %08x\n", intel_ring_get_active_head(ring
));
655 seq_printf(m
, " NOPID : %08x\n", I915_READ_NOPID(ring
));
656 if (IS_GEN6(dev
) || IS_GEN7(dev
)) {
657 seq_printf(m
, " Sync 0 : %08x\n", I915_READ_SYNC_0(ring
));
658 seq_printf(m
, " Sync 1 : %08x\n", I915_READ_SYNC_1(ring
));
660 seq_printf(m
, " Control : %08x\n", I915_READ_CTL(ring
));
661 seq_printf(m
, " Start : %08x\n", I915_READ_START(ring
));
663 mutex_unlock(&dev
->struct_mutex
);
668 static const char *ring_str(int ring
)
671 case RING_RENDER
: return " render";
672 case RING_BSD
: return " bsd";
673 case RING_BLT
: return " blt";
678 static const char *pin_flag(int pinned
)
688 static const char *tiling_flag(int tiling
)
692 case I915_TILING_NONE
: return "";
693 case I915_TILING_X
: return " X";
694 case I915_TILING_Y
: return " Y";
698 static const char *dirty_flag(int dirty
)
700 return dirty
? " dirty" : "";
703 static const char *purgeable_flag(int purgeable
)
705 return purgeable
? " purgeable" : "";
708 static void print_error_buffers(struct seq_file
*m
,
710 struct drm_i915_error_buffer
*err
,
713 seq_printf(m
, "%s [%d]:\n", name
, count
);
716 seq_printf(m
, " %08x %8u %04x %04x %08x%s%s%s%s%s%s",
722 pin_flag(err
->pinned
),
723 tiling_flag(err
->tiling
),
724 dirty_flag(err
->dirty
),
725 purgeable_flag(err
->purgeable
),
727 cache_level_str(err
->cache_level
));
730 seq_printf(m
, " (name: %d)", err
->name
);
731 if (err
->fence_reg
!= I915_FENCE_REG_NONE
)
732 seq_printf(m
, " (fence: %d)", err
->fence_reg
);
739 static int i915_error_state(struct seq_file
*m
, void *unused
)
741 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
742 struct drm_device
*dev
= node
->minor
->dev
;
743 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
744 struct drm_i915_error_state
*error
;
746 int i
, page
, offset
, elt
;
748 spin_lock_irqsave(&dev_priv
->error_lock
, flags
);
749 if (!dev_priv
->first_error
) {
750 seq_printf(m
, "no error state collected\n");
754 error
= dev_priv
->first_error
;
756 seq_printf(m
, "Time: %ld s %ld us\n", error
->time
.tv_sec
,
757 error
->time
.tv_usec
);
758 seq_printf(m
, "PCI ID: 0x%04x\n", dev
->pci_device
);
759 seq_printf(m
, "EIR: 0x%08x\n", error
->eir
);
760 seq_printf(m
, "PGTBL_ER: 0x%08x\n", error
->pgtbl_er
);
761 if (INTEL_INFO(dev
)->gen
>= 6) {
762 seq_printf(m
, "ERROR: 0x%08x\n", error
->error
);
763 seq_printf(m
, "Blitter command stream:\n");
764 seq_printf(m
, " ACTHD: 0x%08x\n", error
->bcs_acthd
);
765 seq_printf(m
, " IPEIR: 0x%08x\n", error
->bcs_ipeir
);
766 seq_printf(m
, " IPEHR: 0x%08x\n", error
->bcs_ipehr
);
767 seq_printf(m
, " INSTDONE: 0x%08x\n", error
->bcs_instdone
);
768 seq_printf(m
, " seqno: 0x%08x\n", error
->bcs_seqno
);
769 seq_printf(m
, "Video (BSD) command stream:\n");
770 seq_printf(m
, " ACTHD: 0x%08x\n", error
->vcs_acthd
);
771 seq_printf(m
, " IPEIR: 0x%08x\n", error
->vcs_ipeir
);
772 seq_printf(m
, " IPEHR: 0x%08x\n", error
->vcs_ipehr
);
773 seq_printf(m
, " INSTDONE: 0x%08x\n", error
->vcs_instdone
);
774 seq_printf(m
, " seqno: 0x%08x\n", error
->vcs_seqno
);
776 seq_printf(m
, "Render command stream:\n");
777 seq_printf(m
, " ACTHD: 0x%08x\n", error
->acthd
);
778 seq_printf(m
, " IPEIR: 0x%08x\n", error
->ipeir
);
779 seq_printf(m
, " IPEHR: 0x%08x\n", error
->ipehr
);
780 seq_printf(m
, " INSTDONE: 0x%08x\n", error
->instdone
);
781 if (INTEL_INFO(dev
)->gen
>= 4) {
782 seq_printf(m
, " INSTDONE1: 0x%08x\n", error
->instdone1
);
783 seq_printf(m
, " INSTPS: 0x%08x\n", error
->instps
);
785 seq_printf(m
, " INSTPM: 0x%08x\n", error
->instpm
);
786 seq_printf(m
, " seqno: 0x%08x\n", error
->seqno
);
788 for (i
= 0; i
< dev_priv
->num_fence_regs
; i
++)
789 seq_printf(m
, " fence[%d] = %08llx\n", i
, error
->fence
[i
]);
791 if (error
->active_bo
)
792 print_error_buffers(m
, "Active",
794 error
->active_bo_count
);
796 if (error
->pinned_bo
)
797 print_error_buffers(m
, "Pinned",
799 error
->pinned_bo_count
);
801 for (i
= 0; i
< ARRAY_SIZE(error
->batchbuffer
); i
++) {
802 if (error
->batchbuffer
[i
]) {
803 struct drm_i915_error_object
*obj
= error
->batchbuffer
[i
];
805 seq_printf(m
, "%s --- gtt_offset = 0x%08x\n",
806 dev_priv
->ring
[i
].name
,
809 for (page
= 0; page
< obj
->page_count
; page
++) {
810 for (elt
= 0; elt
< PAGE_SIZE
/4; elt
++) {
811 seq_printf(m
, "%08x : %08x\n", offset
, obj
->pages
[page
][elt
]);
818 for (i
= 0; i
< ARRAY_SIZE(error
->ringbuffer
); i
++) {
819 if (error
->ringbuffer
[i
]) {
820 struct drm_i915_error_object
*obj
= error
->ringbuffer
[i
];
821 seq_printf(m
, "%s --- ringbuffer = 0x%08x\n",
822 dev_priv
->ring
[i
].name
,
825 for (page
= 0; page
< obj
->page_count
; page
++) {
826 for (elt
= 0; elt
< PAGE_SIZE
/4; elt
++) {
827 seq_printf(m
, "%08x : %08x\n",
829 obj
->pages
[page
][elt
]);
837 intel_overlay_print_error_state(m
, error
->overlay
);
840 intel_display_print_error_state(m
, dev
, error
->display
);
843 spin_unlock_irqrestore(&dev_priv
->error_lock
, flags
);
848 static int i915_rstdby_delays(struct seq_file
*m
, void *unused
)
850 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
851 struct drm_device
*dev
= node
->minor
->dev
;
852 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
856 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
860 crstanddelay
= I915_READ16(CRSTANDVID
);
862 mutex_unlock(&dev
->struct_mutex
);
864 seq_printf(m
, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay
>> 8) & 0x3f, (crstanddelay
& 0x3f));
869 static int i915_cur_delayinfo(struct seq_file
*m
, void *unused
)
871 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
872 struct drm_device
*dev
= node
->minor
->dev
;
873 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
877 u16 rgvswctl
= I915_READ16(MEMSWCTL
);
878 u16 rgvstat
= I915_READ16(MEMSTAT_ILK
);
880 seq_printf(m
, "Requested P-state: %d\n", (rgvswctl
>> 8) & 0xf);
881 seq_printf(m
, "Requested VID: %d\n", rgvswctl
& 0x3f);
882 seq_printf(m
, "Current VID: %d\n", (rgvstat
& MEMSTAT_VID_MASK
) >>
884 seq_printf(m
, "Current P-state: %d\n",
885 (rgvstat
& MEMSTAT_PSTATE_MASK
) >> MEMSTAT_PSTATE_SHIFT
);
886 } else if (IS_GEN6(dev
) || IS_GEN7(dev
)) {
887 u32 gt_perf_status
= I915_READ(GEN6_GT_PERF_STATUS
);
888 u32 rp_state_limits
= I915_READ(GEN6_RP_STATE_LIMITS
);
889 u32 rp_state_cap
= I915_READ(GEN6_RP_STATE_CAP
);
891 u32 rpupei
, rpcurup
, rpprevup
;
892 u32 rpdownei
, rpcurdown
, rpprevdown
;
895 /* RPSTAT1 is in the GT power well */
896 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
900 gen6_gt_force_wake_get(dev_priv
);
902 rpstat
= I915_READ(GEN6_RPSTAT1
);
903 rpupei
= I915_READ(GEN6_RP_CUR_UP_EI
);
904 rpcurup
= I915_READ(GEN6_RP_CUR_UP
);
905 rpprevup
= I915_READ(GEN6_RP_PREV_UP
);
906 rpdownei
= I915_READ(GEN6_RP_CUR_DOWN_EI
);
907 rpcurdown
= I915_READ(GEN6_RP_CUR_DOWN
);
908 rpprevdown
= I915_READ(GEN6_RP_PREV_DOWN
);
910 gen6_gt_force_wake_put(dev_priv
);
911 mutex_unlock(&dev
->struct_mutex
);
913 seq_printf(m
, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status
);
914 seq_printf(m
, "RPSTAT1: 0x%08x\n", rpstat
);
915 seq_printf(m
, "Render p-state ratio: %d\n",
916 (gt_perf_status
& 0xff00) >> 8);
917 seq_printf(m
, "Render p-state VID: %d\n",
918 gt_perf_status
& 0xff);
919 seq_printf(m
, "Render p-state limit: %d\n",
920 rp_state_limits
& 0xff);
921 seq_printf(m
, "CAGF: %dMHz\n", ((rpstat
& GEN6_CAGF_MASK
) >>
922 GEN6_CAGF_SHIFT
) * 50);
923 seq_printf(m
, "RP CUR UP EI: %dus\n", rpupei
&
925 seq_printf(m
, "RP CUR UP: %dus\n", rpcurup
&
926 GEN6_CURBSYTAVG_MASK
);
927 seq_printf(m
, "RP PREV UP: %dus\n", rpprevup
&
928 GEN6_CURBSYTAVG_MASK
);
929 seq_printf(m
, "RP CUR DOWN EI: %dus\n", rpdownei
&
931 seq_printf(m
, "RP CUR DOWN: %dus\n", rpcurdown
&
932 GEN6_CURBSYTAVG_MASK
);
933 seq_printf(m
, "RP PREV DOWN: %dus\n", rpprevdown
&
934 GEN6_CURBSYTAVG_MASK
);
936 max_freq
= (rp_state_cap
& 0xff0000) >> 16;
937 seq_printf(m
, "Lowest (RPN) frequency: %dMHz\n",
940 max_freq
= (rp_state_cap
& 0xff00) >> 8;
941 seq_printf(m
, "Nominal (RP1) frequency: %dMHz\n",
944 max_freq
= rp_state_cap
& 0xff;
945 seq_printf(m
, "Max non-overclocked (RP0) frequency: %dMHz\n",
948 seq_printf(m
, "no P-state info available\n");
954 static int i915_delayfreq_table(struct seq_file
*m
, void *unused
)
956 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
957 struct drm_device
*dev
= node
->minor
->dev
;
958 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
962 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
966 for (i
= 0; i
< 16; i
++) {
967 delayfreq
= I915_READ(PXVFREQ_BASE
+ i
* 4);
968 seq_printf(m
, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i
, delayfreq
,
969 (delayfreq
& PXVFREQ_PX_MASK
) >> PXVFREQ_PX_SHIFT
);
972 mutex_unlock(&dev
->struct_mutex
);
977 static inline int MAP_TO_MV(int map
)
979 return 1250 - (map
* 25);
982 static int i915_inttoext_table(struct seq_file
*m
, void *unused
)
984 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
985 struct drm_device
*dev
= node
->minor
->dev
;
986 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
990 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
994 for (i
= 1; i
<= 32; i
++) {
995 inttoext
= I915_READ(INTTOEXT_BASE_ILK
+ i
* 4);
996 seq_printf(m
, "INTTOEXT%02d: 0x%08x\n", i
, inttoext
);
999 mutex_unlock(&dev
->struct_mutex
);
1004 static int ironlake_drpc_info(struct seq_file
*m
)
1006 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1007 struct drm_device
*dev
= node
->minor
->dev
;
1008 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1009 u32 rgvmodectl
, rstdbyctl
;
1013 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1017 rgvmodectl
= I915_READ(MEMMODECTL
);
1018 rstdbyctl
= I915_READ(RSTDBYCTL
);
1019 crstandvid
= I915_READ16(CRSTANDVID
);
1021 mutex_unlock(&dev
->struct_mutex
);
1023 seq_printf(m
, "HD boost: %s\n", (rgvmodectl
& MEMMODE_BOOST_EN
) ?
1025 seq_printf(m
, "Boost freq: %d\n",
1026 (rgvmodectl
& MEMMODE_BOOST_FREQ_MASK
) >>
1027 MEMMODE_BOOST_FREQ_SHIFT
);
1028 seq_printf(m
, "HW control enabled: %s\n",
1029 rgvmodectl
& MEMMODE_HWIDLE_EN
? "yes" : "no");
1030 seq_printf(m
, "SW control enabled: %s\n",
1031 rgvmodectl
& MEMMODE_SWMODE_EN
? "yes" : "no");
1032 seq_printf(m
, "Gated voltage change: %s\n",
1033 rgvmodectl
& MEMMODE_RCLK_GATE
? "yes" : "no");
1034 seq_printf(m
, "Starting frequency: P%d\n",
1035 (rgvmodectl
& MEMMODE_FSTART_MASK
) >> MEMMODE_FSTART_SHIFT
);
1036 seq_printf(m
, "Max P-state: P%d\n",
1037 (rgvmodectl
& MEMMODE_FMAX_MASK
) >> MEMMODE_FMAX_SHIFT
);
1038 seq_printf(m
, "Min P-state: P%d\n", (rgvmodectl
& MEMMODE_FMIN_MASK
));
1039 seq_printf(m
, "RS1 VID: %d\n", (crstandvid
& 0x3f));
1040 seq_printf(m
, "RS2 VID: %d\n", ((crstandvid
>> 8) & 0x3f));
1041 seq_printf(m
, "Render standby enabled: %s\n",
1042 (rstdbyctl
& RCX_SW_EXIT
) ? "no" : "yes");
1043 seq_printf(m
, "Current RS state: ");
1044 switch (rstdbyctl
& RSX_STATUS_MASK
) {
1046 seq_printf(m
, "on\n");
1048 case RSX_STATUS_RC1
:
1049 seq_printf(m
, "RC1\n");
1051 case RSX_STATUS_RC1E
:
1052 seq_printf(m
, "RC1E\n");
1054 case RSX_STATUS_RS1
:
1055 seq_printf(m
, "RS1\n");
1057 case RSX_STATUS_RS2
:
1058 seq_printf(m
, "RS2 (RC6)\n");
1060 case RSX_STATUS_RS3
:
1061 seq_printf(m
, "RC3 (RC6+)\n");
1064 seq_printf(m
, "unknown\n");
1071 static int gen6_drpc_info(struct seq_file
*m
)
1074 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1075 struct drm_device
*dev
= node
->minor
->dev
;
1076 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1077 u32 rpmodectl1
, gt_core_status
, rcctl1
;
1078 unsigned forcewake_count
;
1082 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1086 spin_lock_irq(&dev_priv
->gt_lock
);
1087 forcewake_count
= dev_priv
->forcewake_count
;
1088 spin_unlock_irq(&dev_priv
->gt_lock
);
1090 if (forcewake_count
) {
1091 seq_printf(m
, "RC information inaccurate because somebody "
1092 "holds a forcewake reference \n");
1094 /* NB: we cannot use forcewake, else we read the wrong values */
1095 while (count
++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK
) & 1))
1097 seq_printf(m
, "RC information accurate: %s\n", yesno(count
< 51));
1100 gt_core_status
= readl(dev_priv
->regs
+ GEN6_GT_CORE_STATUS
);
1101 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS
, gt_core_status
, 4);
1103 rpmodectl1
= I915_READ(GEN6_RP_CONTROL
);
1104 rcctl1
= I915_READ(GEN6_RC_CONTROL
);
1105 mutex_unlock(&dev
->struct_mutex
);
1107 seq_printf(m
, "Video Turbo Mode: %s\n",
1108 yesno(rpmodectl1
& GEN6_RP_MEDIA_TURBO
));
1109 seq_printf(m
, "HW control enabled: %s\n",
1110 yesno(rpmodectl1
& GEN6_RP_ENABLE
));
1111 seq_printf(m
, "SW control enabled: %s\n",
1112 yesno((rpmodectl1
& GEN6_RP_MEDIA_MODE_MASK
) ==
1113 GEN6_RP_MEDIA_SW_MODE
));
1114 seq_printf(m
, "RC1e Enabled: %s\n",
1115 yesno(rcctl1
& GEN6_RC_CTL_RC1e_ENABLE
));
1116 seq_printf(m
, "RC6 Enabled: %s\n",
1117 yesno(rcctl1
& GEN6_RC_CTL_RC6_ENABLE
));
1118 seq_printf(m
, "Deep RC6 Enabled: %s\n",
1119 yesno(rcctl1
& GEN6_RC_CTL_RC6p_ENABLE
));
1120 seq_printf(m
, "Deepest RC6 Enabled: %s\n",
1121 yesno(rcctl1
& GEN6_RC_CTL_RC6pp_ENABLE
));
1122 seq_printf(m
, "Current RC state: ");
1123 switch (gt_core_status
& GEN6_RCn_MASK
) {
1125 if (gt_core_status
& GEN6_CORE_CPD_STATE_MASK
)
1126 seq_printf(m
, "Core Power Down\n");
1128 seq_printf(m
, "on\n");
1131 seq_printf(m
, "RC3\n");
1134 seq_printf(m
, "RC6\n");
1137 seq_printf(m
, "RC7\n");
1140 seq_printf(m
, "Unknown\n");
1144 seq_printf(m
, "Core Power Down: %s\n",
1145 yesno(gt_core_status
& GEN6_CORE_CPD_STATE_MASK
));
1149 static int i915_drpc_info(struct seq_file
*m
, void *unused
)
1151 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1152 struct drm_device
*dev
= node
->minor
->dev
;
1154 if (IS_GEN6(dev
) || IS_GEN7(dev
))
1155 return gen6_drpc_info(m
);
1157 return ironlake_drpc_info(m
);
1160 static int i915_fbc_status(struct seq_file
*m
, void *unused
)
1162 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1163 struct drm_device
*dev
= node
->minor
->dev
;
1164 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1166 if (!I915_HAS_FBC(dev
)) {
1167 seq_printf(m
, "FBC unsupported on this chipset\n");
1171 if (intel_fbc_enabled(dev
)) {
1172 seq_printf(m
, "FBC enabled\n");
1174 seq_printf(m
, "FBC disabled: ");
1175 switch (dev_priv
->no_fbc_reason
) {
1177 seq_printf(m
, "no outputs");
1179 case FBC_STOLEN_TOO_SMALL
:
1180 seq_printf(m
, "not enough stolen memory");
1182 case FBC_UNSUPPORTED_MODE
:
1183 seq_printf(m
, "mode not supported");
1185 case FBC_MODE_TOO_LARGE
:
1186 seq_printf(m
, "mode too large");
1189 seq_printf(m
, "FBC unsupported on plane");
1192 seq_printf(m
, "scanout buffer not tiled");
1194 case FBC_MULTIPLE_PIPES
:
1195 seq_printf(m
, "multiple pipes are enabled");
1197 case FBC_MODULE_PARAM
:
1198 seq_printf(m
, "disabled per module param (default off)");
1201 seq_printf(m
, "unknown reason");
1203 seq_printf(m
, "\n");
1208 static int i915_sr_status(struct seq_file
*m
, void *unused
)
1210 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1211 struct drm_device
*dev
= node
->minor
->dev
;
1212 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1213 bool sr_enabled
= false;
1215 if (HAS_PCH_SPLIT(dev
))
1216 sr_enabled
= I915_READ(WM1_LP_ILK
) & WM1_LP_SR_EN
;
1217 else if (IS_CRESTLINE(dev
) || IS_I945G(dev
) || IS_I945GM(dev
))
1218 sr_enabled
= I915_READ(FW_BLC_SELF
) & FW_BLC_SELF_EN
;
1219 else if (IS_I915GM(dev
))
1220 sr_enabled
= I915_READ(INSTPM
) & INSTPM_SELF_EN
;
1221 else if (IS_PINEVIEW(dev
))
1222 sr_enabled
= I915_READ(DSPFW3
) & PINEVIEW_SELF_REFRESH_EN
;
1224 seq_printf(m
, "self-refresh: %s\n",
1225 sr_enabled
? "enabled" : "disabled");
1230 static int i915_emon_status(struct seq_file
*m
, void *unused
)
1232 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1233 struct drm_device
*dev
= node
->minor
->dev
;
1234 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1235 unsigned long temp
, chipset
, gfx
;
1238 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1242 temp
= i915_mch_val(dev_priv
);
1243 chipset
= i915_chipset_val(dev_priv
);
1244 gfx
= i915_gfx_val(dev_priv
);
1245 mutex_unlock(&dev
->struct_mutex
);
1247 seq_printf(m
, "GMCH temp: %ld\n", temp
);
1248 seq_printf(m
, "Chipset power: %ld\n", chipset
);
1249 seq_printf(m
, "GFX power: %ld\n", gfx
);
1250 seq_printf(m
, "Total power: %ld\n", chipset
+ gfx
);
1255 static int i915_ring_freq_table(struct seq_file
*m
, void *unused
)
1257 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1258 struct drm_device
*dev
= node
->minor
->dev
;
1259 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1261 int gpu_freq
, ia_freq
;
1263 if (!(IS_GEN6(dev
) || IS_GEN7(dev
))) {
1264 seq_printf(m
, "unsupported on this chipset\n");
1268 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1272 seq_printf(m
, "GPU freq (MHz)\tEffective CPU freq (MHz)\n");
1274 for (gpu_freq
= dev_priv
->min_delay
; gpu_freq
<= dev_priv
->max_delay
;
1276 I915_WRITE(GEN6_PCODE_DATA
, gpu_freq
);
1277 I915_WRITE(GEN6_PCODE_MAILBOX
, GEN6_PCODE_READY
|
1278 GEN6_PCODE_READ_MIN_FREQ_TABLE
);
1279 if (wait_for((I915_READ(GEN6_PCODE_MAILBOX
) &
1280 GEN6_PCODE_READY
) == 0, 10)) {
1281 DRM_ERROR("pcode read of freq table timed out\n");
1284 ia_freq
= I915_READ(GEN6_PCODE_DATA
);
1285 seq_printf(m
, "%d\t\t%d\n", gpu_freq
* 50, ia_freq
* 100);
1288 mutex_unlock(&dev
->struct_mutex
);
1293 static int i915_gfxec(struct seq_file
*m
, void *unused
)
1295 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1296 struct drm_device
*dev
= node
->minor
->dev
;
1297 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1300 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1304 seq_printf(m
, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
1306 mutex_unlock(&dev
->struct_mutex
);
1311 static int i915_opregion(struct seq_file
*m
, void *unused
)
1313 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1314 struct drm_device
*dev
= node
->minor
->dev
;
1315 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1316 struct intel_opregion
*opregion
= &dev_priv
->opregion
;
1319 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1323 if (opregion
->header
)
1324 seq_write(m
, opregion
->header
, OPREGION_SIZE
);
1326 mutex_unlock(&dev
->struct_mutex
);
1331 static int i915_gem_framebuffer_info(struct seq_file
*m
, void *data
)
1333 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1334 struct drm_device
*dev
= node
->minor
->dev
;
1335 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1336 struct intel_fbdev
*ifbdev
;
1337 struct intel_framebuffer
*fb
;
1340 ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1344 ifbdev
= dev_priv
->fbdev
;
1345 fb
= to_intel_framebuffer(ifbdev
->helper
.fb
);
1347 seq_printf(m
, "fbcon size: %d x %d, depth %d, %d bpp, obj ",
1351 fb
->base
.bits_per_pixel
);
1352 describe_obj(m
, fb
->obj
);
1353 seq_printf(m
, "\n");
1355 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, base
.head
) {
1356 if (&fb
->base
== ifbdev
->helper
.fb
)
1359 seq_printf(m
, "user size: %d x %d, depth %d, %d bpp, obj ",
1363 fb
->base
.bits_per_pixel
);
1364 describe_obj(m
, fb
->obj
);
1365 seq_printf(m
, "\n");
1368 mutex_unlock(&dev
->mode_config
.mutex
);
1373 static int i915_context_status(struct seq_file
*m
, void *unused
)
1375 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1376 struct drm_device
*dev
= node
->minor
->dev
;
1377 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1380 ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1384 if (dev_priv
->pwrctx
) {
1385 seq_printf(m
, "power context ");
1386 describe_obj(m
, dev_priv
->pwrctx
);
1387 seq_printf(m
, "\n");
1390 if (dev_priv
->renderctx
) {
1391 seq_printf(m
, "render context ");
1392 describe_obj(m
, dev_priv
->renderctx
);
1393 seq_printf(m
, "\n");
1396 mutex_unlock(&dev
->mode_config
.mutex
);
1401 static int i915_gen6_forcewake_count_info(struct seq_file
*m
, void *data
)
1403 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1404 struct drm_device
*dev
= node
->minor
->dev
;
1405 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1406 unsigned forcewake_count
;
1408 spin_lock_irq(&dev_priv
->gt_lock
);
1409 forcewake_count
= dev_priv
->forcewake_count
;
1410 spin_unlock_irq(&dev_priv
->gt_lock
);
1412 seq_printf(m
, "forcewake count = %u\n", forcewake_count
);
1418 i915_wedged_open(struct inode
*inode
,
1421 filp
->private_data
= inode
->i_private
;
1426 i915_wedged_read(struct file
*filp
,
1431 struct drm_device
*dev
= filp
->private_data
;
1432 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1436 len
= snprintf(buf
, sizeof(buf
),
1438 atomic_read(&dev_priv
->mm
.wedged
));
1440 if (len
> sizeof(buf
))
1443 return simple_read_from_buffer(ubuf
, max
, ppos
, buf
, len
);
1447 i915_wedged_write(struct file
*filp
,
1448 const char __user
*ubuf
,
1452 struct drm_device
*dev
= filp
->private_data
;
1457 if (cnt
> sizeof(buf
) - 1)
1460 if (copy_from_user(buf
, ubuf
, cnt
))
1464 val
= simple_strtoul(buf
, NULL
, 0);
1467 DRM_INFO("Manually setting wedged to %d\n", val
);
1468 i915_handle_error(dev
, val
);
1473 static const struct file_operations i915_wedged_fops
= {
1474 .owner
= THIS_MODULE
,
1475 .open
= i915_wedged_open
,
1476 .read
= i915_wedged_read
,
1477 .write
= i915_wedged_write
,
1478 .llseek
= default_llseek
,
1482 i915_max_freq_open(struct inode
*inode
,
1485 filp
->private_data
= inode
->i_private
;
1490 i915_max_freq_read(struct file
*filp
,
1495 struct drm_device
*dev
= filp
->private_data
;
1496 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1500 len
= snprintf(buf
, sizeof(buf
),
1501 "max freq: %d\n", dev_priv
->max_delay
* 50);
1503 if (len
> sizeof(buf
))
1506 return simple_read_from_buffer(ubuf
, max
, ppos
, buf
, len
);
1510 i915_max_freq_write(struct file
*filp
,
1511 const char __user
*ubuf
,
1515 struct drm_device
*dev
= filp
->private_data
;
1516 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1521 if (cnt
> sizeof(buf
) - 1)
1524 if (copy_from_user(buf
, ubuf
, cnt
))
1528 val
= simple_strtoul(buf
, NULL
, 0);
1531 DRM_DEBUG_DRIVER("Manually setting max freq to %d\n", val
);
1534 * Turbo will still be enabled, but won't go above the set value.
1536 dev_priv
->max_delay
= val
/ 50;
1538 gen6_set_rps(dev
, val
/ 50);
1543 static const struct file_operations i915_max_freq_fops
= {
1544 .owner
= THIS_MODULE
,
1545 .open
= i915_max_freq_open
,
1546 .read
= i915_max_freq_read
,
1547 .write
= i915_max_freq_write
,
1548 .llseek
= default_llseek
,
1552 i915_cache_sharing_open(struct inode
*inode
,
1555 filp
->private_data
= inode
->i_private
;
1560 i915_cache_sharing_read(struct file
*filp
,
1565 struct drm_device
*dev
= filp
->private_data
;
1566 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1571 mutex_lock(&dev_priv
->dev
->struct_mutex
);
1572 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
1573 mutex_unlock(&dev_priv
->dev
->struct_mutex
);
1575 len
= snprintf(buf
, sizeof(buf
),
1576 "%d\n", (snpcr
& GEN6_MBC_SNPCR_MASK
) >>
1577 GEN6_MBC_SNPCR_SHIFT
);
1579 if (len
> sizeof(buf
))
1582 return simple_read_from_buffer(ubuf
, max
, ppos
, buf
, len
);
1586 i915_cache_sharing_write(struct file
*filp
,
1587 const char __user
*ubuf
,
1591 struct drm_device
*dev
= filp
->private_data
;
1592 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1598 if (cnt
> sizeof(buf
) - 1)
1601 if (copy_from_user(buf
, ubuf
, cnt
))
1605 val
= simple_strtoul(buf
, NULL
, 0);
1608 if (val
< 0 || val
> 3)
1611 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %d\n", val
);
1613 /* Update the cache sharing policy here as well */
1614 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
1615 snpcr
&= ~GEN6_MBC_SNPCR_MASK
;
1616 snpcr
|= (val
<< GEN6_MBC_SNPCR_SHIFT
);
1617 I915_WRITE(GEN6_MBCUNIT_SNPCR
, snpcr
);
1622 static const struct file_operations i915_cache_sharing_fops
= {
1623 .owner
= THIS_MODULE
,
1624 .open
= i915_cache_sharing_open
,
1625 .read
= i915_cache_sharing_read
,
1626 .write
= i915_cache_sharing_write
,
1627 .llseek
= default_llseek
,
1630 /* As the drm_debugfs_init() routines are called before dev->dev_private is
1631 * allocated we need to hook into the minor for release. */
1633 drm_add_fake_info_node(struct drm_minor
*minor
,
1637 struct drm_info_node
*node
;
1639 node
= kmalloc(sizeof(struct drm_info_node
), GFP_KERNEL
);
1641 debugfs_remove(ent
);
1645 node
->minor
= minor
;
1647 node
->info_ent
= (void *) key
;
1649 mutex_lock(&minor
->debugfs_lock
);
1650 list_add(&node
->list
, &minor
->debugfs_list
);
1651 mutex_unlock(&minor
->debugfs_lock
);
1656 static int i915_wedged_create(struct dentry
*root
, struct drm_minor
*minor
)
1658 struct drm_device
*dev
= minor
->dev
;
1661 ent
= debugfs_create_file("i915_wedged",
1666 return PTR_ERR(ent
);
1668 return drm_add_fake_info_node(minor
, ent
, &i915_wedged_fops
);
1671 static int i915_forcewake_open(struct inode
*inode
, struct file
*file
)
1673 struct drm_device
*dev
= inode
->i_private
;
1674 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1677 if (INTEL_INFO(dev
)->gen
< 6)
1680 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1683 gen6_gt_force_wake_get(dev_priv
);
1684 mutex_unlock(&dev
->struct_mutex
);
1689 int i915_forcewake_release(struct inode
*inode
, struct file
*file
)
1691 struct drm_device
*dev
= inode
->i_private
;
1692 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1694 if (INTEL_INFO(dev
)->gen
< 6)
1698 * It's bad that we can potentially hang userspace if struct_mutex gets
1699 * forever stuck. However, if we cannot acquire this lock it means that
1700 * almost certainly the driver has hung, is not unload-able. Therefore
1701 * hanging here is probably a minor inconvenience not to be seen my
1702 * almost every user.
1704 mutex_lock(&dev
->struct_mutex
);
1705 gen6_gt_force_wake_put(dev_priv
);
1706 mutex_unlock(&dev
->struct_mutex
);
1711 static const struct file_operations i915_forcewake_fops
= {
1712 .owner
= THIS_MODULE
,
1713 .open
= i915_forcewake_open
,
1714 .release
= i915_forcewake_release
,
1717 static int i915_forcewake_create(struct dentry
*root
, struct drm_minor
*minor
)
1719 struct drm_device
*dev
= minor
->dev
;
1722 ent
= debugfs_create_file("i915_forcewake_user",
1725 &i915_forcewake_fops
);
1727 return PTR_ERR(ent
);
1729 return drm_add_fake_info_node(minor
, ent
, &i915_forcewake_fops
);
1732 static int i915_max_freq_create(struct dentry
*root
, struct drm_minor
*minor
)
1734 struct drm_device
*dev
= minor
->dev
;
1737 ent
= debugfs_create_file("i915_max_freq",
1740 &i915_max_freq_fops
);
1742 return PTR_ERR(ent
);
1744 return drm_add_fake_info_node(minor
, ent
, &i915_max_freq_fops
);
1747 static int i915_cache_sharing_create(struct dentry
*root
, struct drm_minor
*minor
)
1749 struct drm_device
*dev
= minor
->dev
;
1752 ent
= debugfs_create_file("i915_cache_sharing",
1755 &i915_cache_sharing_fops
);
1757 return PTR_ERR(ent
);
1759 return drm_add_fake_info_node(minor
, ent
, &i915_cache_sharing_fops
);
1762 static struct drm_info_list i915_debugfs_list
[] = {
1763 {"i915_capabilities", i915_capabilities
, 0},
1764 {"i915_gem_objects", i915_gem_object_info
, 0},
1765 {"i915_gem_gtt", i915_gem_gtt_info
, 0},
1766 {"i915_gem_active", i915_gem_object_list_info
, 0, (void *) ACTIVE_LIST
},
1767 {"i915_gem_flushing", i915_gem_object_list_info
, 0, (void *) FLUSHING_LIST
},
1768 {"i915_gem_inactive", i915_gem_object_list_info
, 0, (void *) INACTIVE_LIST
},
1769 {"i915_gem_pinned", i915_gem_object_list_info
, 0, (void *) PINNED_LIST
},
1770 {"i915_gem_deferred_free", i915_gem_object_list_info
, 0, (void *) DEFERRED_FREE_LIST
},
1771 {"i915_gem_pageflip", i915_gem_pageflip_info
, 0},
1772 {"i915_gem_request", i915_gem_request_info
, 0},
1773 {"i915_gem_seqno", i915_gem_seqno_info
, 0},
1774 {"i915_gem_fence_regs", i915_gem_fence_regs_info
, 0},
1775 {"i915_gem_interrupt", i915_interrupt_info
, 0},
1776 {"i915_gem_hws", i915_hws_info
, 0, (void *)RCS
},
1777 {"i915_gem_hws_blt", i915_hws_info
, 0, (void *)BCS
},
1778 {"i915_gem_hws_bsd", i915_hws_info
, 0, (void *)VCS
},
1779 {"i915_ringbuffer_data", i915_ringbuffer_data
, 0, (void *)RCS
},
1780 {"i915_ringbuffer_info", i915_ringbuffer_info
, 0, (void *)RCS
},
1781 {"i915_bsd_ringbuffer_data", i915_ringbuffer_data
, 0, (void *)VCS
},
1782 {"i915_bsd_ringbuffer_info", i915_ringbuffer_info
, 0, (void *)VCS
},
1783 {"i915_blt_ringbuffer_data", i915_ringbuffer_data
, 0, (void *)BCS
},
1784 {"i915_blt_ringbuffer_info", i915_ringbuffer_info
, 0, (void *)BCS
},
1785 {"i915_batchbuffers", i915_batchbuffer_info
, 0},
1786 {"i915_error_state", i915_error_state
, 0},
1787 {"i915_rstdby_delays", i915_rstdby_delays
, 0},
1788 {"i915_cur_delayinfo", i915_cur_delayinfo
, 0},
1789 {"i915_delayfreq_table", i915_delayfreq_table
, 0},
1790 {"i915_inttoext_table", i915_inttoext_table
, 0},
1791 {"i915_drpc_info", i915_drpc_info
, 0},
1792 {"i915_emon_status", i915_emon_status
, 0},
1793 {"i915_ring_freq_table", i915_ring_freq_table
, 0},
1794 {"i915_gfxec", i915_gfxec
, 0},
1795 {"i915_fbc_status", i915_fbc_status
, 0},
1796 {"i915_sr_status", i915_sr_status
, 0},
1797 {"i915_opregion", i915_opregion
, 0},
1798 {"i915_gem_framebuffer", i915_gem_framebuffer_info
, 0},
1799 {"i915_context_status", i915_context_status
, 0},
1800 {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info
, 0},
1802 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
1804 int i915_debugfs_init(struct drm_minor
*minor
)
1808 ret
= i915_wedged_create(minor
->debugfs_root
, minor
);
1812 ret
= i915_forcewake_create(minor
->debugfs_root
, minor
);
1815 ret
= i915_max_freq_create(minor
->debugfs_root
, minor
);
1818 ret
= i915_cache_sharing_create(minor
->debugfs_root
, minor
);
1822 return drm_debugfs_create_files(i915_debugfs_list
,
1823 I915_DEBUGFS_ENTRIES
,
1824 minor
->debugfs_root
, minor
);
1827 void i915_debugfs_cleanup(struct drm_minor
*minor
)
1829 drm_debugfs_remove_files(i915_debugfs_list
,
1830 I915_DEBUGFS_ENTRIES
, minor
);
1831 drm_debugfs_remove_files((struct drm_info_list
*) &i915_forcewake_fops
,
1833 drm_debugfs_remove_files((struct drm_info_list
*) &i915_wedged_fops
,
1835 drm_debugfs_remove_files((struct drm_info_list
*) &i915_max_freq_fops
,
1837 drm_debugfs_remove_files((struct drm_info_list
*) &i915_cache_sharing_fops
,
1841 #endif /* CONFIG_DEBUG_FS */