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>
34 #include "intel_drv.h"
35 #include "intel_ringbuffer.h"
39 #define DRM_I915_RING_DEBUG 1
42 #if defined(CONFIG_DEBUG_FS)
52 static const char *yesno(int v
)
54 return v
? "yes" : "no";
57 static int i915_capabilities(struct seq_file
*m
, void *data
)
59 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
60 struct drm_device
*dev
= node
->minor
->dev
;
61 const struct intel_device_info
*info
= INTEL_INFO(dev
);
63 seq_printf(m
, "gen: %d\n", info
->gen
);
64 #define B(x) seq_printf(m, #x ": %s\n", yesno(info->x))
78 B(cursor_needs_physical
);
80 B(overlay_needs_physical
);
89 static const char *get_pin_flag(struct drm_i915_gem_object
*obj
)
91 if (obj
->user_pin_count
> 0)
93 else if (obj
->pin_count
> 0)
99 static const char *get_tiling_flag(struct drm_i915_gem_object
*obj
)
101 switch (obj
->tiling_mode
) {
103 case I915_TILING_NONE
: return " ";
104 case I915_TILING_X
: return "X";
105 case I915_TILING_Y
: return "Y";
109 static const char *agp_type_str(int type
)
112 case 0: return " uncached";
113 case 1: return " snooped";
119 describe_obj(struct seq_file
*m
, struct drm_i915_gem_object
*obj
)
121 seq_printf(m
, "%p: %s%s %8zd %04x %04x %d %d%s%s%s",
124 get_tiling_flag(obj
),
126 obj
->base
.read_domains
,
127 obj
->base
.write_domain
,
128 obj
->last_rendering_seqno
,
129 obj
->last_fenced_seqno
,
130 agp_type_str(obj
->agp_type
== AGP_USER_CACHED_MEMORY
),
131 obj
->dirty
? " dirty" : "",
132 obj
->madv
== I915_MADV_DONTNEED
? " purgeable" : "");
134 seq_printf(m
, " (name: %d)", obj
->base
.name
);
135 if (obj
->fence_reg
!= I915_FENCE_REG_NONE
)
136 seq_printf(m
, " (fence: %d)", obj
->fence_reg
);
137 if (obj
->gtt_space
!= NULL
)
138 seq_printf(m
, " (gtt offset: %08x, size: %08x)",
139 obj
->gtt_offset
, (unsigned int)obj
->gtt_space
->size
);
140 if (obj
->pin_mappable
|| obj
->fault_mappable
) {
142 if (obj
->pin_mappable
)
144 if (obj
->fault_mappable
)
147 seq_printf(m
, " (%s mappable)", s
);
149 if (obj
->ring
!= NULL
)
150 seq_printf(m
, " (%s)", obj
->ring
->name
);
153 static int i915_gem_object_list_info(struct seq_file
*m
, void *data
)
155 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
156 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
157 struct list_head
*head
;
158 struct drm_device
*dev
= node
->minor
->dev
;
159 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
160 struct drm_i915_gem_object
*obj
;
161 size_t total_obj_size
, total_gtt_size
;
164 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
170 seq_printf(m
, "Active:\n");
171 head
= &dev_priv
->mm
.active_list
;
174 seq_printf(m
, "Inactive:\n");
175 head
= &dev_priv
->mm
.inactive_list
;
178 seq_printf(m
, "Pinned:\n");
179 head
= &dev_priv
->mm
.pinned_list
;
182 seq_printf(m
, "Flushing:\n");
183 head
= &dev_priv
->mm
.flushing_list
;
185 case DEFERRED_FREE_LIST
:
186 seq_printf(m
, "Deferred free:\n");
187 head
= &dev_priv
->mm
.deferred_free_list
;
190 mutex_unlock(&dev
->struct_mutex
);
194 total_obj_size
= total_gtt_size
= count
= 0;
195 list_for_each_entry(obj
, head
, mm_list
) {
197 describe_obj(m
, obj
);
199 total_obj_size
+= obj
->base
.size
;
200 total_gtt_size
+= obj
->gtt_space
->size
;
203 mutex_unlock(&dev
->struct_mutex
);
205 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
206 count
, total_obj_size
, total_gtt_size
);
210 #define count_objects(list, member) do { \
211 list_for_each_entry(obj, list, member) { \
212 size += obj->gtt_space->size; \
214 if (obj->map_and_fenceable) { \
215 mappable_size += obj->gtt_space->size; \
221 static int i915_gem_object_info(struct seq_file
*m
, void* data
)
223 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
224 struct drm_device
*dev
= node
->minor
->dev
;
225 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
226 u32 count
, mappable_count
;
227 size_t size
, mappable_size
;
228 struct drm_i915_gem_object
*obj
;
231 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
235 seq_printf(m
, "%u objects, %zu bytes\n",
236 dev_priv
->mm
.object_count
,
237 dev_priv
->mm
.object_memory
);
239 size
= count
= mappable_size
= mappable_count
= 0;
240 count_objects(&dev_priv
->mm
.gtt_list
, gtt_list
);
241 seq_printf(m
, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
242 count
, mappable_count
, size
, mappable_size
);
244 size
= count
= mappable_size
= mappable_count
= 0;
245 count_objects(&dev_priv
->mm
.active_list
, mm_list
);
246 count_objects(&dev_priv
->mm
.flushing_list
, mm_list
);
247 seq_printf(m
, " %u [%u] active objects, %zu [%zu] bytes\n",
248 count
, mappable_count
, size
, mappable_size
);
250 size
= count
= mappable_size
= mappable_count
= 0;
251 count_objects(&dev_priv
->mm
.pinned_list
, mm_list
);
252 seq_printf(m
, " %u [%u] pinned objects, %zu [%zu] bytes\n",
253 count
, mappable_count
, size
, mappable_size
);
255 size
= count
= mappable_size
= mappable_count
= 0;
256 count_objects(&dev_priv
->mm
.inactive_list
, mm_list
);
257 seq_printf(m
, " %u [%u] inactive objects, %zu [%zu] bytes\n",
258 count
, mappable_count
, size
, mappable_size
);
260 size
= count
= mappable_size
= mappable_count
= 0;
261 count_objects(&dev_priv
->mm
.deferred_free_list
, mm_list
);
262 seq_printf(m
, " %u [%u] freed objects, %zu [%zu] bytes\n",
263 count
, mappable_count
, size
, mappable_size
);
265 size
= count
= mappable_size
= mappable_count
= 0;
266 list_for_each_entry(obj
, &dev_priv
->mm
.gtt_list
, gtt_list
) {
267 if (obj
->fault_mappable
) {
268 size
+= obj
->gtt_space
->size
;
271 if (obj
->pin_mappable
) {
272 mappable_size
+= obj
->gtt_space
->size
;
276 seq_printf(m
, "%u pinned mappable objects, %zu bytes\n",
277 mappable_count
, mappable_size
);
278 seq_printf(m
, "%u fault mappable objects, %zu bytes\n",
281 seq_printf(m
, "%zu [%zu] gtt total\n",
282 dev_priv
->mm
.gtt_total
, dev_priv
->mm
.mappable_gtt_total
);
284 mutex_unlock(&dev
->struct_mutex
);
289 static int i915_gem_gtt_info(struct seq_file
*m
, void* data
)
291 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
292 struct drm_device
*dev
= node
->minor
->dev
;
293 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
294 struct drm_i915_gem_object
*obj
;
295 size_t total_obj_size
, total_gtt_size
;
298 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
302 total_obj_size
= total_gtt_size
= count
= 0;
303 list_for_each_entry(obj
, &dev_priv
->mm
.gtt_list
, gtt_list
) {
305 describe_obj(m
, obj
);
307 total_obj_size
+= obj
->base
.size
;
308 total_gtt_size
+= obj
->gtt_space
->size
;
312 mutex_unlock(&dev
->struct_mutex
);
314 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
315 count
, total_obj_size
, total_gtt_size
);
321 static int i915_gem_pageflip_info(struct seq_file
*m
, void *data
)
323 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
324 struct drm_device
*dev
= node
->minor
->dev
;
326 struct intel_crtc
*crtc
;
328 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, base
.head
) {
329 const char pipe
= pipe_name(crtc
->pipe
);
330 const char plane
= plane_name(crtc
->plane
);
331 struct intel_unpin_work
*work
;
333 spin_lock_irqsave(&dev
->event_lock
, flags
);
334 work
= crtc
->unpin_work
;
336 seq_printf(m
, "No flip due on pipe %c (plane %c)\n",
339 if (!work
->pending
) {
340 seq_printf(m
, "Flip queued on pipe %c (plane %c)\n",
343 seq_printf(m
, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
346 if (work
->enable_stall_check
)
347 seq_printf(m
, "Stall check enabled, ");
349 seq_printf(m
, "Stall check waiting for page flip ioctl, ");
350 seq_printf(m
, "%d prepares\n", work
->pending
);
352 if (work
->old_fb_obj
) {
353 struct drm_i915_gem_object
*obj
= work
->old_fb_obj
;
355 seq_printf(m
, "Old framebuffer gtt_offset 0x%08x\n", obj
->gtt_offset
);
357 if (work
->pending_flip_obj
) {
358 struct drm_i915_gem_object
*obj
= work
->pending_flip_obj
;
360 seq_printf(m
, "New framebuffer gtt_offset 0x%08x\n", obj
->gtt_offset
);
363 spin_unlock_irqrestore(&dev
->event_lock
, flags
);
369 static int i915_gem_request_info(struct seq_file
*m
, void *data
)
371 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
372 struct drm_device
*dev
= node
->minor
->dev
;
373 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
374 struct drm_i915_gem_request
*gem_request
;
377 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
382 if (!list_empty(&dev_priv
->ring
[RCS
].request_list
)) {
383 seq_printf(m
, "Render requests:\n");
384 list_for_each_entry(gem_request
,
385 &dev_priv
->ring
[RCS
].request_list
,
387 seq_printf(m
, " %d @ %d\n",
389 (int) (jiffies
- gem_request
->emitted_jiffies
));
393 if (!list_empty(&dev_priv
->ring
[VCS
].request_list
)) {
394 seq_printf(m
, "BSD requests:\n");
395 list_for_each_entry(gem_request
,
396 &dev_priv
->ring
[VCS
].request_list
,
398 seq_printf(m
, " %d @ %d\n",
400 (int) (jiffies
- gem_request
->emitted_jiffies
));
404 if (!list_empty(&dev_priv
->ring
[BCS
].request_list
)) {
405 seq_printf(m
, "BLT requests:\n");
406 list_for_each_entry(gem_request
,
407 &dev_priv
->ring
[BCS
].request_list
,
409 seq_printf(m
, " %d @ %d\n",
411 (int) (jiffies
- gem_request
->emitted_jiffies
));
415 mutex_unlock(&dev
->struct_mutex
);
418 seq_printf(m
, "No requests\n");
423 static void i915_ring_seqno_info(struct seq_file
*m
,
424 struct intel_ring_buffer
*ring
)
426 if (ring
->get_seqno
) {
427 seq_printf(m
, "Current sequence (%s): %d\n",
428 ring
->name
, ring
->get_seqno(ring
));
429 seq_printf(m
, "Waiter sequence (%s): %d\n",
430 ring
->name
, ring
->waiting_seqno
);
431 seq_printf(m
, "IRQ sequence (%s): %d\n",
432 ring
->name
, ring
->irq_seqno
);
436 static int i915_gem_seqno_info(struct seq_file
*m
, void *data
)
438 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
439 struct drm_device
*dev
= node
->minor
->dev
;
440 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
443 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
447 for (i
= 0; i
< I915_NUM_RINGS
; i
++)
448 i915_ring_seqno_info(m
, &dev_priv
->ring
[i
]);
450 mutex_unlock(&dev
->struct_mutex
);
456 static int i915_interrupt_info(struct seq_file
*m
, void *data
)
458 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
459 struct drm_device
*dev
= node
->minor
->dev
;
460 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
463 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
467 if (!HAS_PCH_SPLIT(dev
)) {
468 seq_printf(m
, "Interrupt enable: %08x\n",
470 seq_printf(m
, "Interrupt identity: %08x\n",
472 seq_printf(m
, "Interrupt mask: %08x\n",
475 seq_printf(m
, "Pipe %c stat: %08x\n",
477 I915_READ(PIPESTAT(pipe
)));
479 seq_printf(m
, "North Display Interrupt enable: %08x\n",
481 seq_printf(m
, "North Display Interrupt identity: %08x\n",
483 seq_printf(m
, "North Display Interrupt mask: %08x\n",
485 seq_printf(m
, "South Display Interrupt enable: %08x\n",
487 seq_printf(m
, "South Display Interrupt identity: %08x\n",
489 seq_printf(m
, "South Display Interrupt mask: %08x\n",
491 seq_printf(m
, "Graphics Interrupt enable: %08x\n",
493 seq_printf(m
, "Graphics Interrupt identity: %08x\n",
495 seq_printf(m
, "Graphics Interrupt mask: %08x\n",
498 seq_printf(m
, "Interrupts received: %d\n",
499 atomic_read(&dev_priv
->irq_received
));
500 for (i
= 0; i
< I915_NUM_RINGS
; i
++) {
502 seq_printf(m
, "Graphics Interrupt mask (%s): %08x\n",
503 dev_priv
->ring
[i
].name
,
504 I915_READ_IMR(&dev_priv
->ring
[i
]));
506 i915_ring_seqno_info(m
, &dev_priv
->ring
[i
]);
508 mutex_unlock(&dev
->struct_mutex
);
513 static int i915_gem_fence_regs_info(struct seq_file
*m
, void *data
)
515 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
516 struct drm_device
*dev
= node
->minor
->dev
;
517 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
520 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
524 seq_printf(m
, "Reserved fences = %d\n", dev_priv
->fence_reg_start
);
525 seq_printf(m
, "Total fences = %d\n", dev_priv
->num_fence_regs
);
526 for (i
= 0; i
< dev_priv
->num_fence_regs
; i
++) {
527 struct drm_i915_gem_object
*obj
= dev_priv
->fence_regs
[i
].obj
;
529 seq_printf(m
, "Fenced object[%2d] = ", i
);
531 seq_printf(m
, "unused");
533 describe_obj(m
, obj
);
537 mutex_unlock(&dev
->struct_mutex
);
541 static int i915_hws_info(struct seq_file
*m
, void *data
)
543 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
544 struct drm_device
*dev
= node
->minor
->dev
;
545 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
546 struct intel_ring_buffer
*ring
;
547 const volatile u32 __iomem
*hws
;
550 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
551 hws
= (volatile u32 __iomem
*)ring
->status_page
.page_addr
;
555 for (i
= 0; i
< 4096 / sizeof(u32
) / 4; i
+= 4) {
556 seq_printf(m
, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
558 hws
[i
], hws
[i
+ 1], hws
[i
+ 2], hws
[i
+ 3]);
563 static void i915_dump_object(struct seq_file
*m
,
564 struct io_mapping
*mapping
,
565 struct drm_i915_gem_object
*obj
)
567 int page
, page_count
, i
;
569 page_count
= obj
->base
.size
/ PAGE_SIZE
;
570 for (page
= 0; page
< page_count
; page
++) {
571 u32
*mem
= io_mapping_map_wc(mapping
,
572 obj
->gtt_offset
+ page
* PAGE_SIZE
);
573 for (i
= 0; i
< PAGE_SIZE
; i
+= 4)
574 seq_printf(m
, "%08x : %08x\n", i
, mem
[i
/ 4]);
575 io_mapping_unmap(mem
);
579 static int i915_batchbuffer_info(struct seq_file
*m
, void *data
)
581 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
582 struct drm_device
*dev
= node
->minor
->dev
;
583 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
584 struct drm_i915_gem_object
*obj
;
587 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
591 list_for_each_entry(obj
, &dev_priv
->mm
.active_list
, mm_list
) {
592 if (obj
->base
.read_domains
& I915_GEM_DOMAIN_COMMAND
) {
593 seq_printf(m
, "--- gtt_offset = 0x%08x\n", obj
->gtt_offset
);
594 i915_dump_object(m
, dev_priv
->mm
.gtt_mapping
, obj
);
598 mutex_unlock(&dev
->struct_mutex
);
602 static int i915_ringbuffer_data(struct seq_file
*m
, void *data
)
604 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
605 struct drm_device
*dev
= node
->minor
->dev
;
606 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
607 struct intel_ring_buffer
*ring
;
610 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
614 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
616 seq_printf(m
, "No ringbuffer setup\n");
618 const u8 __iomem
*virt
= ring
->virtual_start
;
621 for (off
= 0; off
< ring
->size
; off
+= 4) {
622 uint32_t *ptr
= (uint32_t *)(virt
+ off
);
623 seq_printf(m
, "%08x : %08x\n", off
, *ptr
);
626 mutex_unlock(&dev
->struct_mutex
);
631 static int i915_ringbuffer_info(struct seq_file
*m
, void *data
)
633 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
634 struct drm_device
*dev
= node
->minor
->dev
;
635 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
636 struct intel_ring_buffer
*ring
;
638 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
642 seq_printf(m
, "Ring %s:\n", ring
->name
);
643 seq_printf(m
, " Head : %08x\n", I915_READ_HEAD(ring
) & HEAD_ADDR
);
644 seq_printf(m
, " Tail : %08x\n", I915_READ_TAIL(ring
) & TAIL_ADDR
);
645 seq_printf(m
, " Size : %08x\n", ring
->size
);
646 seq_printf(m
, " Active : %08x\n", intel_ring_get_active_head(ring
));
647 seq_printf(m
, " NOPID : %08x\n", I915_READ_NOPID(ring
));
649 seq_printf(m
, " Sync 0 : %08x\n", I915_READ_SYNC_0(ring
));
650 seq_printf(m
, " Sync 1 : %08x\n", I915_READ_SYNC_1(ring
));
652 seq_printf(m
, " Control : %08x\n", I915_READ_CTL(ring
));
653 seq_printf(m
, " Start : %08x\n", I915_READ_START(ring
));
658 static const char *ring_str(int ring
)
661 case RING_RENDER
: return " render";
662 case RING_BSD
: return " bsd";
663 case RING_BLT
: return " blt";
668 static const char *pin_flag(int pinned
)
678 static const char *tiling_flag(int tiling
)
682 case I915_TILING_NONE
: return "";
683 case I915_TILING_X
: return " X";
684 case I915_TILING_Y
: return " Y";
688 static const char *dirty_flag(int dirty
)
690 return dirty
? " dirty" : "";
693 static const char *purgeable_flag(int purgeable
)
695 return purgeable
? " purgeable" : "";
698 static void print_error_buffers(struct seq_file
*m
,
700 struct drm_i915_error_buffer
*err
,
703 seq_printf(m
, "%s [%d]:\n", name
, count
);
706 seq_printf(m
, " %08x %8u %04x %04x %08x%s%s%s%s%s%s",
712 pin_flag(err
->pinned
),
713 tiling_flag(err
->tiling
),
714 dirty_flag(err
->dirty
),
715 purgeable_flag(err
->purgeable
),
717 agp_type_str(err
->agp_type
));
720 seq_printf(m
, " (name: %d)", err
->name
);
721 if (err
->fence_reg
!= I915_FENCE_REG_NONE
)
722 seq_printf(m
, " (fence: %d)", err
->fence_reg
);
729 static int i915_error_state(struct seq_file
*m
, void *unused
)
731 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
732 struct drm_device
*dev
= node
->minor
->dev
;
733 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
734 struct drm_i915_error_state
*error
;
736 int i
, page
, offset
, elt
;
738 spin_lock_irqsave(&dev_priv
->error_lock
, flags
);
739 if (!dev_priv
->first_error
) {
740 seq_printf(m
, "no error state collected\n");
744 error
= dev_priv
->first_error
;
746 seq_printf(m
, "Time: %ld s %ld us\n", error
->time
.tv_sec
,
747 error
->time
.tv_usec
);
748 seq_printf(m
, "PCI ID: 0x%04x\n", dev
->pci_device
);
749 seq_printf(m
, "EIR: 0x%08x\n", error
->eir
);
750 seq_printf(m
, "PGTBL_ER: 0x%08x\n", error
->pgtbl_er
);
751 if (INTEL_INFO(dev
)->gen
>= 6) {
752 seq_printf(m
, "ERROR: 0x%08x\n", error
->error
);
753 seq_printf(m
, "Blitter command stream:\n");
754 seq_printf(m
, " ACTHD: 0x%08x\n", error
->bcs_acthd
);
755 seq_printf(m
, " IPEIR: 0x%08x\n", error
->bcs_ipeir
);
756 seq_printf(m
, " IPEHR: 0x%08x\n", error
->bcs_ipehr
);
757 seq_printf(m
, " INSTDONE: 0x%08x\n", error
->bcs_instdone
);
758 seq_printf(m
, " seqno: 0x%08x\n", error
->bcs_seqno
);
759 seq_printf(m
, "Video (BSD) command stream:\n");
760 seq_printf(m
, " ACTHD: 0x%08x\n", error
->vcs_acthd
);
761 seq_printf(m
, " IPEIR: 0x%08x\n", error
->vcs_ipeir
);
762 seq_printf(m
, " IPEHR: 0x%08x\n", error
->vcs_ipehr
);
763 seq_printf(m
, " INSTDONE: 0x%08x\n", error
->vcs_instdone
);
764 seq_printf(m
, " seqno: 0x%08x\n", error
->vcs_seqno
);
766 seq_printf(m
, "Render command stream:\n");
767 seq_printf(m
, " ACTHD: 0x%08x\n", error
->acthd
);
768 seq_printf(m
, " IPEIR: 0x%08x\n", error
->ipeir
);
769 seq_printf(m
, " IPEHR: 0x%08x\n", error
->ipehr
);
770 seq_printf(m
, " INSTDONE: 0x%08x\n", error
->instdone
);
771 if (INTEL_INFO(dev
)->gen
>= 4) {
772 seq_printf(m
, " INSTDONE1: 0x%08x\n", error
->instdone1
);
773 seq_printf(m
, " INSTPS: 0x%08x\n", error
->instps
);
775 seq_printf(m
, " INSTPM: 0x%08x\n", error
->instpm
);
776 seq_printf(m
, " seqno: 0x%08x\n", error
->seqno
);
778 for (i
= 0; i
< 16; i
++)
779 seq_printf(m
, " fence[%d] = %08llx\n", i
, error
->fence
[i
]);
781 if (error
->active_bo
)
782 print_error_buffers(m
, "Active",
784 error
->active_bo_count
);
786 if (error
->pinned_bo
)
787 print_error_buffers(m
, "Pinned",
789 error
->pinned_bo_count
);
791 for (i
= 0; i
< ARRAY_SIZE(error
->batchbuffer
); i
++) {
792 if (error
->batchbuffer
[i
]) {
793 struct drm_i915_error_object
*obj
= error
->batchbuffer
[i
];
795 seq_printf(m
, "%s --- gtt_offset = 0x%08x\n",
796 dev_priv
->ring
[i
].name
,
799 for (page
= 0; page
< obj
->page_count
; page
++) {
800 for (elt
= 0; elt
< PAGE_SIZE
/4; elt
++) {
801 seq_printf(m
, "%08x : %08x\n", offset
, obj
->pages
[page
][elt
]);
808 for (i
= 0; i
< ARRAY_SIZE(error
->ringbuffer
); i
++) {
809 if (error
->ringbuffer
[i
]) {
810 struct drm_i915_error_object
*obj
= error
->ringbuffer
[i
];
811 seq_printf(m
, "%s --- ringbuffer = 0x%08x\n",
812 dev_priv
->ring
[i
].name
,
815 for (page
= 0; page
< obj
->page_count
; page
++) {
816 for (elt
= 0; elt
< PAGE_SIZE
/4; elt
++) {
817 seq_printf(m
, "%08x : %08x\n",
819 obj
->pages
[page
][elt
]);
827 intel_overlay_print_error_state(m
, error
->overlay
);
830 intel_display_print_error_state(m
, dev
, error
->display
);
833 spin_unlock_irqrestore(&dev_priv
->error_lock
, flags
);
838 static int i915_rstdby_delays(struct seq_file
*m
, void *unused
)
840 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
841 struct drm_device
*dev
= node
->minor
->dev
;
842 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
843 u16 crstanddelay
= I915_READ16(CRSTANDVID
);
845 seq_printf(m
, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay
>> 8) & 0x3f, (crstanddelay
& 0x3f));
850 static int i915_cur_delayinfo(struct seq_file
*m
, void *unused
)
852 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
853 struct drm_device
*dev
= node
->minor
->dev
;
854 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
857 u16 rgvswctl
= I915_READ16(MEMSWCTL
);
858 u16 rgvstat
= I915_READ16(MEMSTAT_ILK
);
860 seq_printf(m
, "Requested P-state: %d\n", (rgvswctl
>> 8) & 0xf);
861 seq_printf(m
, "Requested VID: %d\n", rgvswctl
& 0x3f);
862 seq_printf(m
, "Current VID: %d\n", (rgvstat
& MEMSTAT_VID_MASK
) >>
864 seq_printf(m
, "Current P-state: %d\n",
865 (rgvstat
& MEMSTAT_PSTATE_MASK
) >> MEMSTAT_PSTATE_SHIFT
);
866 } else if (IS_GEN6(dev
)) {
867 u32 gt_perf_status
= I915_READ(GEN6_GT_PERF_STATUS
);
868 u32 rp_state_limits
= I915_READ(GEN6_RP_STATE_LIMITS
);
869 u32 rp_state_cap
= I915_READ(GEN6_RP_STATE_CAP
);
871 u32 rpupei
, rpcurup
, rpprevup
;
872 u32 rpdownei
, rpcurdown
, rpprevdown
;
875 /* RPSTAT1 is in the GT power well */
876 __gen6_gt_force_wake_get(dev_priv
);
878 rpstat
= I915_READ(GEN6_RPSTAT1
);
879 rpupei
= I915_READ(GEN6_RP_CUR_UP_EI
);
880 rpcurup
= I915_READ(GEN6_RP_CUR_UP
);
881 rpprevup
= I915_READ(GEN6_RP_PREV_UP
);
882 rpdownei
= I915_READ(GEN6_RP_CUR_DOWN_EI
);
883 rpcurdown
= I915_READ(GEN6_RP_CUR_DOWN
);
884 rpprevdown
= I915_READ(GEN6_RP_PREV_DOWN
);
886 seq_printf(m
, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status
);
887 seq_printf(m
, "RPSTAT1: 0x%08x\n", rpstat
);
888 seq_printf(m
, "Render p-state ratio: %d\n",
889 (gt_perf_status
& 0xff00) >> 8);
890 seq_printf(m
, "Render p-state VID: %d\n",
891 gt_perf_status
& 0xff);
892 seq_printf(m
, "Render p-state limit: %d\n",
893 rp_state_limits
& 0xff);
894 seq_printf(m
, "CAGF: %dMHz\n", ((rpstat
& GEN6_CAGF_MASK
) >>
895 GEN6_CAGF_SHIFT
) * 50);
896 seq_printf(m
, "RP CUR UP EI: %dus\n", rpupei
&
898 seq_printf(m
, "RP CUR UP: %dus\n", rpcurup
&
899 GEN6_CURBSYTAVG_MASK
);
900 seq_printf(m
, "RP PREV UP: %dus\n", rpprevup
&
901 GEN6_CURBSYTAVG_MASK
);
902 seq_printf(m
, "RP CUR DOWN EI: %dus\n", rpdownei
&
904 seq_printf(m
, "RP CUR DOWN: %dus\n", rpcurdown
&
905 GEN6_CURBSYTAVG_MASK
);
906 seq_printf(m
, "RP PREV DOWN: %dus\n", rpprevdown
&
907 GEN6_CURBSYTAVG_MASK
);
909 max_freq
= (rp_state_cap
& 0xff0000) >> 16;
910 seq_printf(m
, "Lowest (RPN) frequency: %dMHz\n",
913 max_freq
= (rp_state_cap
& 0xff00) >> 8;
914 seq_printf(m
, "Nominal (RP1) frequency: %dMHz\n",
917 max_freq
= rp_state_cap
& 0xff;
918 seq_printf(m
, "Max non-overclocked (RP0) frequency: %dMHz\n",
921 __gen6_gt_force_wake_put(dev_priv
);
923 seq_printf(m
, "no P-state info available\n");
929 static int i915_delayfreq_table(struct seq_file
*m
, void *unused
)
931 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
932 struct drm_device
*dev
= node
->minor
->dev
;
933 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
937 for (i
= 0; i
< 16; i
++) {
938 delayfreq
= I915_READ(PXVFREQ_BASE
+ i
* 4);
939 seq_printf(m
, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i
, delayfreq
,
940 (delayfreq
& PXVFREQ_PX_MASK
) >> PXVFREQ_PX_SHIFT
);
946 static inline int MAP_TO_MV(int map
)
948 return 1250 - (map
* 25);
951 static int i915_inttoext_table(struct seq_file
*m
, void *unused
)
953 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
954 struct drm_device
*dev
= node
->minor
->dev
;
955 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
959 for (i
= 1; i
<= 32; i
++) {
960 inttoext
= I915_READ(INTTOEXT_BASE_ILK
+ i
* 4);
961 seq_printf(m
, "INTTOEXT%02d: 0x%08x\n", i
, inttoext
);
967 static int i915_drpc_info(struct seq_file
*m
, void *unused
)
969 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
970 struct drm_device
*dev
= node
->minor
->dev
;
971 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
972 u32 rgvmodectl
= I915_READ(MEMMODECTL
);
973 u32 rstdbyctl
= I915_READ(RSTDBYCTL
);
974 u16 crstandvid
= I915_READ16(CRSTANDVID
);
976 seq_printf(m
, "HD boost: %s\n", (rgvmodectl
& MEMMODE_BOOST_EN
) ?
978 seq_printf(m
, "Boost freq: %d\n",
979 (rgvmodectl
& MEMMODE_BOOST_FREQ_MASK
) >>
980 MEMMODE_BOOST_FREQ_SHIFT
);
981 seq_printf(m
, "HW control enabled: %s\n",
982 rgvmodectl
& MEMMODE_HWIDLE_EN
? "yes" : "no");
983 seq_printf(m
, "SW control enabled: %s\n",
984 rgvmodectl
& MEMMODE_SWMODE_EN
? "yes" : "no");
985 seq_printf(m
, "Gated voltage change: %s\n",
986 rgvmodectl
& MEMMODE_RCLK_GATE
? "yes" : "no");
987 seq_printf(m
, "Starting frequency: P%d\n",
988 (rgvmodectl
& MEMMODE_FSTART_MASK
) >> MEMMODE_FSTART_SHIFT
);
989 seq_printf(m
, "Max P-state: P%d\n",
990 (rgvmodectl
& MEMMODE_FMAX_MASK
) >> MEMMODE_FMAX_SHIFT
);
991 seq_printf(m
, "Min P-state: P%d\n", (rgvmodectl
& MEMMODE_FMIN_MASK
));
992 seq_printf(m
, "RS1 VID: %d\n", (crstandvid
& 0x3f));
993 seq_printf(m
, "RS2 VID: %d\n", ((crstandvid
>> 8) & 0x3f));
994 seq_printf(m
, "Render standby enabled: %s\n",
995 (rstdbyctl
& RCX_SW_EXIT
) ? "no" : "yes");
996 seq_printf(m
, "Current RS state: ");
997 switch (rstdbyctl
& RSX_STATUS_MASK
) {
999 seq_printf(m
, "on\n");
1001 case RSX_STATUS_RC1
:
1002 seq_printf(m
, "RC1\n");
1004 case RSX_STATUS_RC1E
:
1005 seq_printf(m
, "RC1E\n");
1007 case RSX_STATUS_RS1
:
1008 seq_printf(m
, "RS1\n");
1010 case RSX_STATUS_RS2
:
1011 seq_printf(m
, "RS2 (RC6)\n");
1013 case RSX_STATUS_RS3
:
1014 seq_printf(m
, "RC3 (RC6+)\n");
1017 seq_printf(m
, "unknown\n");
1024 static int i915_fbc_status(struct seq_file
*m
, void *unused
)
1026 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1027 struct drm_device
*dev
= node
->minor
->dev
;
1028 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1030 if (!I915_HAS_FBC(dev
)) {
1031 seq_printf(m
, "FBC unsupported on this chipset\n");
1035 if (intel_fbc_enabled(dev
)) {
1036 seq_printf(m
, "FBC enabled\n");
1038 seq_printf(m
, "FBC disabled: ");
1039 switch (dev_priv
->no_fbc_reason
) {
1041 seq_printf(m
, "no outputs");
1043 case FBC_STOLEN_TOO_SMALL
:
1044 seq_printf(m
, "not enough stolen memory");
1046 case FBC_UNSUPPORTED_MODE
:
1047 seq_printf(m
, "mode not supported");
1049 case FBC_MODE_TOO_LARGE
:
1050 seq_printf(m
, "mode too large");
1053 seq_printf(m
, "FBC unsupported on plane");
1056 seq_printf(m
, "scanout buffer not tiled");
1058 case FBC_MULTIPLE_PIPES
:
1059 seq_printf(m
, "multiple pipes are enabled");
1062 seq_printf(m
, "unknown reason");
1064 seq_printf(m
, "\n");
1069 static int i915_sr_status(struct seq_file
*m
, void *unused
)
1071 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1072 struct drm_device
*dev
= node
->minor
->dev
;
1073 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1074 bool sr_enabled
= false;
1076 if (HAS_PCH_SPLIT(dev
))
1077 sr_enabled
= I915_READ(WM1_LP_ILK
) & WM1_LP_SR_EN
;
1078 else if (IS_CRESTLINE(dev
) || IS_I945G(dev
) || IS_I945GM(dev
))
1079 sr_enabled
= I915_READ(FW_BLC_SELF
) & FW_BLC_SELF_EN
;
1080 else if (IS_I915GM(dev
))
1081 sr_enabled
= I915_READ(INSTPM
) & INSTPM_SELF_EN
;
1082 else if (IS_PINEVIEW(dev
))
1083 sr_enabled
= I915_READ(DSPFW3
) & PINEVIEW_SELF_REFRESH_EN
;
1085 seq_printf(m
, "self-refresh: %s\n",
1086 sr_enabled
? "enabled" : "disabled");
1091 static int i915_emon_status(struct seq_file
*m
, void *unused
)
1093 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1094 struct drm_device
*dev
= node
->minor
->dev
;
1095 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1096 unsigned long temp
, chipset
, gfx
;
1099 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1103 temp
= i915_mch_val(dev_priv
);
1104 chipset
= i915_chipset_val(dev_priv
);
1105 gfx
= i915_gfx_val(dev_priv
);
1106 mutex_unlock(&dev
->struct_mutex
);
1108 seq_printf(m
, "GMCH temp: %ld\n", temp
);
1109 seq_printf(m
, "Chipset power: %ld\n", chipset
);
1110 seq_printf(m
, "GFX power: %ld\n", gfx
);
1111 seq_printf(m
, "Total power: %ld\n", chipset
+ gfx
);
1116 static int i915_gfxec(struct seq_file
*m
, void *unused
)
1118 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1119 struct drm_device
*dev
= node
->minor
->dev
;
1120 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1122 seq_printf(m
, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
1127 static int i915_opregion(struct seq_file
*m
, void *unused
)
1129 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1130 struct drm_device
*dev
= node
->minor
->dev
;
1131 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1132 struct intel_opregion
*opregion
= &dev_priv
->opregion
;
1135 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1139 if (opregion
->header
)
1140 seq_write(m
, opregion
->header
, OPREGION_SIZE
);
1142 mutex_unlock(&dev
->struct_mutex
);
1147 static int i915_gem_framebuffer_info(struct seq_file
*m
, void *data
)
1149 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1150 struct drm_device
*dev
= node
->minor
->dev
;
1151 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1152 struct intel_fbdev
*ifbdev
;
1153 struct intel_framebuffer
*fb
;
1156 ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1160 ifbdev
= dev_priv
->fbdev
;
1161 fb
= to_intel_framebuffer(ifbdev
->helper
.fb
);
1163 seq_printf(m
, "fbcon size: %d x %d, depth %d, %d bpp, obj ",
1167 fb
->base
.bits_per_pixel
);
1168 describe_obj(m
, fb
->obj
);
1169 seq_printf(m
, "\n");
1171 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, base
.head
) {
1172 if (&fb
->base
== ifbdev
->helper
.fb
)
1175 seq_printf(m
, "user size: %d x %d, depth %d, %d bpp, obj ",
1179 fb
->base
.bits_per_pixel
);
1180 describe_obj(m
, fb
->obj
);
1181 seq_printf(m
, "\n");
1184 mutex_unlock(&dev
->mode_config
.mutex
);
1190 i915_wedged_open(struct inode
*inode
,
1193 filp
->private_data
= inode
->i_private
;
1198 i915_wedged_read(struct file
*filp
,
1203 struct drm_device
*dev
= filp
->private_data
;
1204 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1208 len
= snprintf(buf
, sizeof (buf
),
1210 atomic_read(&dev_priv
->mm
.wedged
));
1212 if (len
> sizeof (buf
))
1215 return simple_read_from_buffer(ubuf
, max
, ppos
, buf
, len
);
1219 i915_wedged_write(struct file
*filp
,
1220 const char __user
*ubuf
,
1224 struct drm_device
*dev
= filp
->private_data
;
1229 if (cnt
> sizeof (buf
) - 1)
1232 if (copy_from_user(buf
, ubuf
, cnt
))
1236 val
= simple_strtoul(buf
, NULL
, 0);
1239 DRM_INFO("Manually setting wedged to %d\n", val
);
1240 i915_handle_error(dev
, val
);
1245 static const struct file_operations i915_wedged_fops
= {
1246 .owner
= THIS_MODULE
,
1247 .open
= i915_wedged_open
,
1248 .read
= i915_wedged_read
,
1249 .write
= i915_wedged_write
,
1250 .llseek
= default_llseek
,
1253 /* As the drm_debugfs_init() routines are called before dev->dev_private is
1254 * allocated we need to hook into the minor for release. */
1256 drm_add_fake_info_node(struct drm_minor
*minor
,
1260 struct drm_info_node
*node
;
1262 node
= kmalloc(sizeof(struct drm_info_node
), GFP_KERNEL
);
1264 debugfs_remove(ent
);
1268 node
->minor
= minor
;
1270 node
->info_ent
= (void *) key
;
1271 list_add(&node
->list
, &minor
->debugfs_nodes
.list
);
1276 static int i915_wedged_create(struct dentry
*root
, struct drm_minor
*minor
)
1278 struct drm_device
*dev
= minor
->dev
;
1281 ent
= debugfs_create_file("i915_wedged",
1286 return PTR_ERR(ent
);
1288 return drm_add_fake_info_node(minor
, ent
, &i915_wedged_fops
);
1291 static struct drm_info_list i915_debugfs_list
[] = {
1292 {"i915_capabilities", i915_capabilities
, 0},
1293 {"i915_gem_objects", i915_gem_object_info
, 0},
1294 {"i915_gem_gtt", i915_gem_gtt_info
, 0},
1295 {"i915_gem_active", i915_gem_object_list_info
, 0, (void *) ACTIVE_LIST
},
1296 {"i915_gem_flushing", i915_gem_object_list_info
, 0, (void *) FLUSHING_LIST
},
1297 {"i915_gem_inactive", i915_gem_object_list_info
, 0, (void *) INACTIVE_LIST
},
1298 {"i915_gem_pinned", i915_gem_object_list_info
, 0, (void *) PINNED_LIST
},
1299 {"i915_gem_deferred_free", i915_gem_object_list_info
, 0, (void *) DEFERRED_FREE_LIST
},
1300 {"i915_gem_pageflip", i915_gem_pageflip_info
, 0},
1301 {"i915_gem_request", i915_gem_request_info
, 0},
1302 {"i915_gem_seqno", i915_gem_seqno_info
, 0},
1303 {"i915_gem_fence_regs", i915_gem_fence_regs_info
, 0},
1304 {"i915_gem_interrupt", i915_interrupt_info
, 0},
1305 {"i915_gem_hws", i915_hws_info
, 0, (void *)RCS
},
1306 {"i915_gem_hws_blt", i915_hws_info
, 0, (void *)BCS
},
1307 {"i915_gem_hws_bsd", i915_hws_info
, 0, (void *)VCS
},
1308 {"i915_ringbuffer_data", i915_ringbuffer_data
, 0, (void *)RCS
},
1309 {"i915_ringbuffer_info", i915_ringbuffer_info
, 0, (void *)RCS
},
1310 {"i915_bsd_ringbuffer_data", i915_ringbuffer_data
, 0, (void *)VCS
},
1311 {"i915_bsd_ringbuffer_info", i915_ringbuffer_info
, 0, (void *)VCS
},
1312 {"i915_blt_ringbuffer_data", i915_ringbuffer_data
, 0, (void *)BCS
},
1313 {"i915_blt_ringbuffer_info", i915_ringbuffer_info
, 0, (void *)BCS
},
1314 {"i915_batchbuffers", i915_batchbuffer_info
, 0},
1315 {"i915_error_state", i915_error_state
, 0},
1316 {"i915_rstdby_delays", i915_rstdby_delays
, 0},
1317 {"i915_cur_delayinfo", i915_cur_delayinfo
, 0},
1318 {"i915_delayfreq_table", i915_delayfreq_table
, 0},
1319 {"i915_inttoext_table", i915_inttoext_table
, 0},
1320 {"i915_drpc_info", i915_drpc_info
, 0},
1321 {"i915_emon_status", i915_emon_status
, 0},
1322 {"i915_gfxec", i915_gfxec
, 0},
1323 {"i915_fbc_status", i915_fbc_status
, 0},
1324 {"i915_sr_status", i915_sr_status
, 0},
1325 {"i915_opregion", i915_opregion
, 0},
1326 {"i915_gem_framebuffer", i915_gem_framebuffer_info
, 0},
1328 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
1330 int i915_debugfs_init(struct drm_minor
*minor
)
1334 ret
= i915_wedged_create(minor
->debugfs_root
, minor
);
1338 return drm_debugfs_create_files(i915_debugfs_list
,
1339 I915_DEBUGFS_ENTRIES
,
1340 minor
->debugfs_root
, minor
);
1343 void i915_debugfs_cleanup(struct drm_minor
*minor
)
1345 drm_debugfs_remove_files(i915_debugfs_list
,
1346 I915_DEBUGFS_ENTRIES
, minor
);
1347 drm_debugfs_remove_files((struct drm_info_list
*) &i915_wedged_fops
,
1351 #endif /* CONFIG_DEBUG_FS */