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 *cache_level_str(int type
)
112 case I915_CACHE_NONE
: return " uncached";
113 case I915_CACHE_LLC
: return " snooped (LLC)";
114 case I915_CACHE_LLC_MLC
: return " snooped (LLC+MLC)";
120 describe_obj(struct seq_file
*m
, struct drm_i915_gem_object
*obj
)
122 seq_printf(m
, "%p: %s%s %8zd %04x %04x %d %d%s%s%s",
125 get_tiling_flag(obj
),
127 obj
->base
.read_domains
,
128 obj
->base
.write_domain
,
129 obj
->last_rendering_seqno
,
130 obj
->last_fenced_seqno
,
131 cache_level_str(obj
->cache_level
),
132 obj
->dirty
? " dirty" : "",
133 obj
->madv
== I915_MADV_DONTNEED
? " purgeable" : "");
135 seq_printf(m
, " (name: %d)", obj
->base
.name
);
136 if (obj
->fence_reg
!= I915_FENCE_REG_NONE
)
137 seq_printf(m
, " (fence: %d)", obj
->fence_reg
);
138 if (obj
->gtt_space
!= NULL
)
139 seq_printf(m
, " (gtt offset: %08x, size: %08x)",
140 obj
->gtt_offset
, (unsigned int)obj
->gtt_space
->size
);
141 if (obj
->pin_mappable
|| obj
->fault_mappable
) {
143 if (obj
->pin_mappable
)
145 if (obj
->fault_mappable
)
148 seq_printf(m
, " (%s mappable)", s
);
150 if (obj
->ring
!= NULL
)
151 seq_printf(m
, " (%s)", obj
->ring
->name
);
154 static int i915_gem_object_list_info(struct seq_file
*m
, void *data
)
156 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
157 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
158 struct list_head
*head
;
159 struct drm_device
*dev
= node
->minor
->dev
;
160 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
161 struct drm_i915_gem_object
*obj
;
162 size_t total_obj_size
, total_gtt_size
;
165 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
171 seq_printf(m
, "Active:\n");
172 head
= &dev_priv
->mm
.active_list
;
175 seq_printf(m
, "Inactive:\n");
176 head
= &dev_priv
->mm
.inactive_list
;
179 seq_printf(m
, "Pinned:\n");
180 head
= &dev_priv
->mm
.pinned_list
;
183 seq_printf(m
, "Flushing:\n");
184 head
= &dev_priv
->mm
.flushing_list
;
186 case DEFERRED_FREE_LIST
:
187 seq_printf(m
, "Deferred free:\n");
188 head
= &dev_priv
->mm
.deferred_free_list
;
191 mutex_unlock(&dev
->struct_mutex
);
195 total_obj_size
= total_gtt_size
= count
= 0;
196 list_for_each_entry(obj
, head
, mm_list
) {
198 describe_obj(m
, obj
);
200 total_obj_size
+= obj
->base
.size
;
201 total_gtt_size
+= obj
->gtt_space
->size
;
204 mutex_unlock(&dev
->struct_mutex
);
206 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
207 count
, total_obj_size
, total_gtt_size
);
211 #define count_objects(list, member) do { \
212 list_for_each_entry(obj, list, member) { \
213 size += obj->gtt_space->size; \
215 if (obj->map_and_fenceable) { \
216 mappable_size += obj->gtt_space->size; \
222 static int i915_gem_object_info(struct seq_file
*m
, void* data
)
224 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
225 struct drm_device
*dev
= node
->minor
->dev
;
226 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
227 u32 count
, mappable_count
;
228 size_t size
, mappable_size
;
229 struct drm_i915_gem_object
*obj
;
232 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
236 seq_printf(m
, "%u objects, %zu bytes\n",
237 dev_priv
->mm
.object_count
,
238 dev_priv
->mm
.object_memory
);
240 size
= count
= mappable_size
= mappable_count
= 0;
241 count_objects(&dev_priv
->mm
.gtt_list
, gtt_list
);
242 seq_printf(m
, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
243 count
, mappable_count
, size
, mappable_size
);
245 size
= count
= mappable_size
= mappable_count
= 0;
246 count_objects(&dev_priv
->mm
.active_list
, mm_list
);
247 count_objects(&dev_priv
->mm
.flushing_list
, mm_list
);
248 seq_printf(m
, " %u [%u] active objects, %zu [%zu] bytes\n",
249 count
, mappable_count
, size
, mappable_size
);
251 size
= count
= mappable_size
= mappable_count
= 0;
252 count_objects(&dev_priv
->mm
.pinned_list
, mm_list
);
253 seq_printf(m
, " %u [%u] pinned objects, %zu [%zu] bytes\n",
254 count
, mappable_count
, size
, mappable_size
);
256 size
= count
= mappable_size
= mappable_count
= 0;
257 count_objects(&dev_priv
->mm
.inactive_list
, mm_list
);
258 seq_printf(m
, " %u [%u] inactive objects, %zu [%zu] bytes\n",
259 count
, mappable_count
, size
, mappable_size
);
261 size
= count
= mappable_size
= mappable_count
= 0;
262 count_objects(&dev_priv
->mm
.deferred_free_list
, mm_list
);
263 seq_printf(m
, " %u [%u] freed objects, %zu [%zu] bytes\n",
264 count
, mappable_count
, size
, mappable_size
);
266 size
= count
= mappable_size
= mappable_count
= 0;
267 list_for_each_entry(obj
, &dev_priv
->mm
.gtt_list
, gtt_list
) {
268 if (obj
->fault_mappable
) {
269 size
+= obj
->gtt_space
->size
;
272 if (obj
->pin_mappable
) {
273 mappable_size
+= obj
->gtt_space
->size
;
277 seq_printf(m
, "%u pinned mappable objects, %zu bytes\n",
278 mappable_count
, mappable_size
);
279 seq_printf(m
, "%u fault mappable objects, %zu bytes\n",
282 seq_printf(m
, "%zu [%zu] gtt total\n",
283 dev_priv
->mm
.gtt_total
, dev_priv
->mm
.mappable_gtt_total
);
285 mutex_unlock(&dev
->struct_mutex
);
290 static int i915_gem_gtt_info(struct seq_file
*m
, void* data
)
292 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
293 struct drm_device
*dev
= node
->minor
->dev
;
294 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
295 struct drm_i915_gem_object
*obj
;
296 size_t total_obj_size
, total_gtt_size
;
299 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
303 total_obj_size
= total_gtt_size
= count
= 0;
304 list_for_each_entry(obj
, &dev_priv
->mm
.gtt_list
, gtt_list
) {
306 describe_obj(m
, obj
);
308 total_obj_size
+= obj
->base
.size
;
309 total_gtt_size
+= obj
->gtt_space
->size
;
313 mutex_unlock(&dev
->struct_mutex
);
315 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
316 count
, total_obj_size
, total_gtt_size
);
322 static int i915_gem_pageflip_info(struct seq_file
*m
, void *data
)
324 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
325 struct drm_device
*dev
= node
->minor
->dev
;
327 struct intel_crtc
*crtc
;
329 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, base
.head
) {
330 const char pipe
= pipe_name(crtc
->pipe
);
331 const char plane
= plane_name(crtc
->plane
);
332 struct intel_unpin_work
*work
;
334 spin_lock_irqsave(&dev
->event_lock
, flags
);
335 work
= crtc
->unpin_work
;
337 seq_printf(m
, "No flip due on pipe %c (plane %c)\n",
340 if (!work
->pending
) {
341 seq_printf(m
, "Flip queued on pipe %c (plane %c)\n",
344 seq_printf(m
, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
347 if (work
->enable_stall_check
)
348 seq_printf(m
, "Stall check enabled, ");
350 seq_printf(m
, "Stall check waiting for page flip ioctl, ");
351 seq_printf(m
, "%d prepares\n", work
->pending
);
353 if (work
->old_fb_obj
) {
354 struct drm_i915_gem_object
*obj
= work
->old_fb_obj
;
356 seq_printf(m
, "Old framebuffer gtt_offset 0x%08x\n", obj
->gtt_offset
);
358 if (work
->pending_flip_obj
) {
359 struct drm_i915_gem_object
*obj
= work
->pending_flip_obj
;
361 seq_printf(m
, "New framebuffer gtt_offset 0x%08x\n", obj
->gtt_offset
);
364 spin_unlock_irqrestore(&dev
->event_lock
, flags
);
370 static int i915_gem_request_info(struct seq_file
*m
, void *data
)
372 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
373 struct drm_device
*dev
= node
->minor
->dev
;
374 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
375 struct drm_i915_gem_request
*gem_request
;
378 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
383 if (!list_empty(&dev_priv
->ring
[RCS
].request_list
)) {
384 seq_printf(m
, "Render requests:\n");
385 list_for_each_entry(gem_request
,
386 &dev_priv
->ring
[RCS
].request_list
,
388 seq_printf(m
, " %d @ %d\n",
390 (int) (jiffies
- gem_request
->emitted_jiffies
));
394 if (!list_empty(&dev_priv
->ring
[VCS
].request_list
)) {
395 seq_printf(m
, "BSD requests:\n");
396 list_for_each_entry(gem_request
,
397 &dev_priv
->ring
[VCS
].request_list
,
399 seq_printf(m
, " %d @ %d\n",
401 (int) (jiffies
- gem_request
->emitted_jiffies
));
405 if (!list_empty(&dev_priv
->ring
[BCS
].request_list
)) {
406 seq_printf(m
, "BLT requests:\n");
407 list_for_each_entry(gem_request
,
408 &dev_priv
->ring
[BCS
].request_list
,
410 seq_printf(m
, " %d @ %d\n",
412 (int) (jiffies
- gem_request
->emitted_jiffies
));
416 mutex_unlock(&dev
->struct_mutex
);
419 seq_printf(m
, "No requests\n");
424 static void i915_ring_seqno_info(struct seq_file
*m
,
425 struct intel_ring_buffer
*ring
)
427 if (ring
->get_seqno
) {
428 seq_printf(m
, "Current sequence (%s): %d\n",
429 ring
->name
, ring
->get_seqno(ring
));
430 seq_printf(m
, "Waiter sequence (%s): %d\n",
431 ring
->name
, ring
->waiting_seqno
);
432 seq_printf(m
, "IRQ sequence (%s): %d\n",
433 ring
->name
, ring
->irq_seqno
);
437 static int i915_gem_seqno_info(struct seq_file
*m
, void *data
)
439 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
440 struct drm_device
*dev
= node
->minor
->dev
;
441 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
444 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
448 for (i
= 0; i
< I915_NUM_RINGS
; i
++)
449 i915_ring_seqno_info(m
, &dev_priv
->ring
[i
]);
451 mutex_unlock(&dev
->struct_mutex
);
457 static int i915_interrupt_info(struct seq_file
*m
, void *data
)
459 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
460 struct drm_device
*dev
= node
->minor
->dev
;
461 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
464 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
468 if (!HAS_PCH_SPLIT(dev
)) {
469 seq_printf(m
, "Interrupt enable: %08x\n",
471 seq_printf(m
, "Interrupt identity: %08x\n",
473 seq_printf(m
, "Interrupt mask: %08x\n",
476 seq_printf(m
, "Pipe %c stat: %08x\n",
478 I915_READ(PIPESTAT(pipe
)));
480 seq_printf(m
, "North Display Interrupt enable: %08x\n",
482 seq_printf(m
, "North Display Interrupt identity: %08x\n",
484 seq_printf(m
, "North Display Interrupt mask: %08x\n",
486 seq_printf(m
, "South Display Interrupt enable: %08x\n",
488 seq_printf(m
, "South Display Interrupt identity: %08x\n",
490 seq_printf(m
, "South Display Interrupt mask: %08x\n",
492 seq_printf(m
, "Graphics Interrupt enable: %08x\n",
494 seq_printf(m
, "Graphics Interrupt identity: %08x\n",
496 seq_printf(m
, "Graphics Interrupt mask: %08x\n",
499 seq_printf(m
, "Interrupts received: %d\n",
500 atomic_read(&dev_priv
->irq_received
));
501 for (i
= 0; i
< I915_NUM_RINGS
; i
++) {
503 seq_printf(m
, "Graphics Interrupt mask (%s): %08x\n",
504 dev_priv
->ring
[i
].name
,
505 I915_READ_IMR(&dev_priv
->ring
[i
]));
507 i915_ring_seqno_info(m
, &dev_priv
->ring
[i
]);
509 mutex_unlock(&dev
->struct_mutex
);
514 static int i915_gem_fence_regs_info(struct seq_file
*m
, void *data
)
516 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
517 struct drm_device
*dev
= node
->minor
->dev
;
518 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
521 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
525 seq_printf(m
, "Reserved fences = %d\n", dev_priv
->fence_reg_start
);
526 seq_printf(m
, "Total fences = %d\n", dev_priv
->num_fence_regs
);
527 for (i
= 0; i
< dev_priv
->num_fence_regs
; i
++) {
528 struct drm_i915_gem_object
*obj
= dev_priv
->fence_regs
[i
].obj
;
530 seq_printf(m
, "Fenced object[%2d] = ", i
);
532 seq_printf(m
, "unused");
534 describe_obj(m
, obj
);
538 mutex_unlock(&dev
->struct_mutex
);
542 static int i915_hws_info(struct seq_file
*m
, void *data
)
544 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
545 struct drm_device
*dev
= node
->minor
->dev
;
546 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
547 struct intel_ring_buffer
*ring
;
548 const volatile u32 __iomem
*hws
;
551 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
552 hws
= (volatile u32 __iomem
*)ring
->status_page
.page_addr
;
556 for (i
= 0; i
< 4096 / sizeof(u32
) / 4; i
+= 4) {
557 seq_printf(m
, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
559 hws
[i
], hws
[i
+ 1], hws
[i
+ 2], hws
[i
+ 3]);
564 static void i915_dump_object(struct seq_file
*m
,
565 struct io_mapping
*mapping
,
566 struct drm_i915_gem_object
*obj
)
568 int page
, page_count
, i
;
570 page_count
= obj
->base
.size
/ PAGE_SIZE
;
571 for (page
= 0; page
< page_count
; page
++) {
572 u32
*mem
= io_mapping_map_wc(mapping
,
573 obj
->gtt_offset
+ page
* PAGE_SIZE
);
574 for (i
= 0; i
< PAGE_SIZE
; i
+= 4)
575 seq_printf(m
, "%08x : %08x\n", i
, mem
[i
/ 4]);
576 io_mapping_unmap(mem
);
580 static int i915_batchbuffer_info(struct seq_file
*m
, void *data
)
582 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
583 struct drm_device
*dev
= node
->minor
->dev
;
584 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
585 struct drm_i915_gem_object
*obj
;
588 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
592 list_for_each_entry(obj
, &dev_priv
->mm
.active_list
, mm_list
) {
593 if (obj
->base
.read_domains
& I915_GEM_DOMAIN_COMMAND
) {
594 seq_printf(m
, "--- gtt_offset = 0x%08x\n", obj
->gtt_offset
);
595 i915_dump_object(m
, dev_priv
->mm
.gtt_mapping
, obj
);
599 mutex_unlock(&dev
->struct_mutex
);
603 static int i915_ringbuffer_data(struct seq_file
*m
, void *data
)
605 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
606 struct drm_device
*dev
= node
->minor
->dev
;
607 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
608 struct intel_ring_buffer
*ring
;
611 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
615 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
617 seq_printf(m
, "No ringbuffer setup\n");
619 const u8 __iomem
*virt
= ring
->virtual_start
;
622 for (off
= 0; off
< ring
->size
; off
+= 4) {
623 uint32_t *ptr
= (uint32_t *)(virt
+ off
);
624 seq_printf(m
, "%08x : %08x\n", off
, *ptr
);
627 mutex_unlock(&dev
->struct_mutex
);
632 static int i915_ringbuffer_info(struct seq_file
*m
, void *data
)
634 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
635 struct drm_device
*dev
= node
->minor
->dev
;
636 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
637 struct intel_ring_buffer
*ring
;
639 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
643 seq_printf(m
, "Ring %s:\n", ring
->name
);
644 seq_printf(m
, " Head : %08x\n", I915_READ_HEAD(ring
) & HEAD_ADDR
);
645 seq_printf(m
, " Tail : %08x\n", I915_READ_TAIL(ring
) & TAIL_ADDR
);
646 seq_printf(m
, " Size : %08x\n", ring
->size
);
647 seq_printf(m
, " Active : %08x\n", intel_ring_get_active_head(ring
));
648 seq_printf(m
, " NOPID : %08x\n", I915_READ_NOPID(ring
));
650 seq_printf(m
, " Sync 0 : %08x\n", I915_READ_SYNC_0(ring
));
651 seq_printf(m
, " Sync 1 : %08x\n", I915_READ_SYNC_1(ring
));
653 seq_printf(m
, " Control : %08x\n", I915_READ_CTL(ring
));
654 seq_printf(m
, " Start : %08x\n", I915_READ_START(ring
));
659 static const char *ring_str(int ring
)
662 case RING_RENDER
: return " render";
663 case RING_BSD
: return " bsd";
664 case RING_BLT
: return " blt";
669 static const char *pin_flag(int pinned
)
679 static const char *tiling_flag(int tiling
)
683 case I915_TILING_NONE
: return "";
684 case I915_TILING_X
: return " X";
685 case I915_TILING_Y
: return " Y";
689 static const char *dirty_flag(int dirty
)
691 return dirty
? " dirty" : "";
694 static const char *purgeable_flag(int purgeable
)
696 return purgeable
? " purgeable" : "";
699 static void print_error_buffers(struct seq_file
*m
,
701 struct drm_i915_error_buffer
*err
,
704 seq_printf(m
, "%s [%d]:\n", name
, count
);
707 seq_printf(m
, " %08x %8u %04x %04x %08x%s%s%s%s%s%s",
713 pin_flag(err
->pinned
),
714 tiling_flag(err
->tiling
),
715 dirty_flag(err
->dirty
),
716 purgeable_flag(err
->purgeable
),
718 cache_level_str(err
->cache_level
));
721 seq_printf(m
, " (name: %d)", err
->name
);
722 if (err
->fence_reg
!= I915_FENCE_REG_NONE
)
723 seq_printf(m
, " (fence: %d)", err
->fence_reg
);
730 static int i915_error_state(struct seq_file
*m
, void *unused
)
732 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
733 struct drm_device
*dev
= node
->minor
->dev
;
734 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
735 struct drm_i915_error_state
*error
;
737 int i
, page
, offset
, elt
;
739 spin_lock_irqsave(&dev_priv
->error_lock
, flags
);
740 if (!dev_priv
->first_error
) {
741 seq_printf(m
, "no error state collected\n");
745 error
= dev_priv
->first_error
;
747 seq_printf(m
, "Time: %ld s %ld us\n", error
->time
.tv_sec
,
748 error
->time
.tv_usec
);
749 seq_printf(m
, "PCI ID: 0x%04x\n", dev
->pci_device
);
750 seq_printf(m
, "EIR: 0x%08x\n", error
->eir
);
751 seq_printf(m
, "PGTBL_ER: 0x%08x\n", error
->pgtbl_er
);
752 if (INTEL_INFO(dev
)->gen
>= 6) {
753 seq_printf(m
, "ERROR: 0x%08x\n", error
->error
);
754 seq_printf(m
, "Blitter command stream:\n");
755 seq_printf(m
, " ACTHD: 0x%08x\n", error
->bcs_acthd
);
756 seq_printf(m
, " IPEIR: 0x%08x\n", error
->bcs_ipeir
);
757 seq_printf(m
, " IPEHR: 0x%08x\n", error
->bcs_ipehr
);
758 seq_printf(m
, " INSTDONE: 0x%08x\n", error
->bcs_instdone
);
759 seq_printf(m
, " seqno: 0x%08x\n", error
->bcs_seqno
);
760 seq_printf(m
, "Video (BSD) command stream:\n");
761 seq_printf(m
, " ACTHD: 0x%08x\n", error
->vcs_acthd
);
762 seq_printf(m
, " IPEIR: 0x%08x\n", error
->vcs_ipeir
);
763 seq_printf(m
, " IPEHR: 0x%08x\n", error
->vcs_ipehr
);
764 seq_printf(m
, " INSTDONE: 0x%08x\n", error
->vcs_instdone
);
765 seq_printf(m
, " seqno: 0x%08x\n", error
->vcs_seqno
);
767 seq_printf(m
, "Render command stream:\n");
768 seq_printf(m
, " ACTHD: 0x%08x\n", error
->acthd
);
769 seq_printf(m
, " IPEIR: 0x%08x\n", error
->ipeir
);
770 seq_printf(m
, " IPEHR: 0x%08x\n", error
->ipehr
);
771 seq_printf(m
, " INSTDONE: 0x%08x\n", error
->instdone
);
772 if (INTEL_INFO(dev
)->gen
>= 4) {
773 seq_printf(m
, " INSTDONE1: 0x%08x\n", error
->instdone1
);
774 seq_printf(m
, " INSTPS: 0x%08x\n", error
->instps
);
776 seq_printf(m
, " INSTPM: 0x%08x\n", error
->instpm
);
777 seq_printf(m
, " seqno: 0x%08x\n", error
->seqno
);
779 for (i
= 0; i
< dev_priv
->num_fence_regs
; i
++)
780 seq_printf(m
, " fence[%d] = %08llx\n", i
, error
->fence
[i
]);
782 if (error
->active_bo
)
783 print_error_buffers(m
, "Active",
785 error
->active_bo_count
);
787 if (error
->pinned_bo
)
788 print_error_buffers(m
, "Pinned",
790 error
->pinned_bo_count
);
792 for (i
= 0; i
< ARRAY_SIZE(error
->batchbuffer
); i
++) {
793 if (error
->batchbuffer
[i
]) {
794 struct drm_i915_error_object
*obj
= error
->batchbuffer
[i
];
796 seq_printf(m
, "%s --- gtt_offset = 0x%08x\n",
797 dev_priv
->ring
[i
].name
,
800 for (page
= 0; page
< obj
->page_count
; page
++) {
801 for (elt
= 0; elt
< PAGE_SIZE
/4; elt
++) {
802 seq_printf(m
, "%08x : %08x\n", offset
, obj
->pages
[page
][elt
]);
809 for (i
= 0; i
< ARRAY_SIZE(error
->ringbuffer
); i
++) {
810 if (error
->ringbuffer
[i
]) {
811 struct drm_i915_error_object
*obj
= error
->ringbuffer
[i
];
812 seq_printf(m
, "%s --- ringbuffer = 0x%08x\n",
813 dev_priv
->ring
[i
].name
,
816 for (page
= 0; page
< obj
->page_count
; page
++) {
817 for (elt
= 0; elt
< PAGE_SIZE
/4; elt
++) {
818 seq_printf(m
, "%08x : %08x\n",
820 obj
->pages
[page
][elt
]);
828 intel_overlay_print_error_state(m
, error
->overlay
);
831 intel_display_print_error_state(m
, dev
, error
->display
);
834 spin_unlock_irqrestore(&dev_priv
->error_lock
, flags
);
839 static int i915_rstdby_delays(struct seq_file
*m
, void *unused
)
841 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
842 struct drm_device
*dev
= node
->minor
->dev
;
843 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
844 u16 crstanddelay
= I915_READ16(CRSTANDVID
);
846 seq_printf(m
, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay
>> 8) & 0x3f, (crstanddelay
& 0x3f));
851 static int i915_cur_delayinfo(struct seq_file
*m
, void *unused
)
853 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
854 struct drm_device
*dev
= node
->minor
->dev
;
855 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
859 u16 rgvswctl
= I915_READ16(MEMSWCTL
);
860 u16 rgvstat
= I915_READ16(MEMSTAT_ILK
);
862 seq_printf(m
, "Requested P-state: %d\n", (rgvswctl
>> 8) & 0xf);
863 seq_printf(m
, "Requested VID: %d\n", rgvswctl
& 0x3f);
864 seq_printf(m
, "Current VID: %d\n", (rgvstat
& MEMSTAT_VID_MASK
) >>
866 seq_printf(m
, "Current P-state: %d\n",
867 (rgvstat
& MEMSTAT_PSTATE_MASK
) >> MEMSTAT_PSTATE_SHIFT
);
868 } else if (IS_GEN6(dev
) || IS_GEN7(dev
)) {
869 u32 gt_perf_status
= I915_READ(GEN6_GT_PERF_STATUS
);
870 u32 rp_state_limits
= I915_READ(GEN6_RP_STATE_LIMITS
);
871 u32 rp_state_cap
= I915_READ(GEN6_RP_STATE_CAP
);
873 u32 rpupei
, rpcurup
, rpprevup
;
874 u32 rpdownei
, rpcurdown
, rpprevdown
;
877 /* RPSTAT1 is in the GT power well */
878 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
882 gen6_gt_force_wake_get(dev_priv
);
884 rpstat
= I915_READ(GEN6_RPSTAT1
);
885 rpupei
= I915_READ(GEN6_RP_CUR_UP_EI
);
886 rpcurup
= I915_READ(GEN6_RP_CUR_UP
);
887 rpprevup
= I915_READ(GEN6_RP_PREV_UP
);
888 rpdownei
= I915_READ(GEN6_RP_CUR_DOWN_EI
);
889 rpcurdown
= I915_READ(GEN6_RP_CUR_DOWN
);
890 rpprevdown
= I915_READ(GEN6_RP_PREV_DOWN
);
892 gen6_gt_force_wake_put(dev_priv
);
893 mutex_unlock(&dev
->struct_mutex
);
895 seq_printf(m
, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status
);
896 seq_printf(m
, "RPSTAT1: 0x%08x\n", rpstat
);
897 seq_printf(m
, "Render p-state ratio: %d\n",
898 (gt_perf_status
& 0xff00) >> 8);
899 seq_printf(m
, "Render p-state VID: %d\n",
900 gt_perf_status
& 0xff);
901 seq_printf(m
, "Render p-state limit: %d\n",
902 rp_state_limits
& 0xff);
903 seq_printf(m
, "CAGF: %dMHz\n", ((rpstat
& GEN6_CAGF_MASK
) >>
904 GEN6_CAGF_SHIFT
) * 50);
905 seq_printf(m
, "RP CUR UP EI: %dus\n", rpupei
&
907 seq_printf(m
, "RP CUR UP: %dus\n", rpcurup
&
908 GEN6_CURBSYTAVG_MASK
);
909 seq_printf(m
, "RP PREV UP: %dus\n", rpprevup
&
910 GEN6_CURBSYTAVG_MASK
);
911 seq_printf(m
, "RP CUR DOWN EI: %dus\n", rpdownei
&
913 seq_printf(m
, "RP CUR DOWN: %dus\n", rpcurdown
&
914 GEN6_CURBSYTAVG_MASK
);
915 seq_printf(m
, "RP PREV DOWN: %dus\n", rpprevdown
&
916 GEN6_CURBSYTAVG_MASK
);
918 max_freq
= (rp_state_cap
& 0xff0000) >> 16;
919 seq_printf(m
, "Lowest (RPN) frequency: %dMHz\n",
922 max_freq
= (rp_state_cap
& 0xff00) >> 8;
923 seq_printf(m
, "Nominal (RP1) frequency: %dMHz\n",
926 max_freq
= rp_state_cap
& 0xff;
927 seq_printf(m
, "Max non-overclocked (RP0) frequency: %dMHz\n",
930 seq_printf(m
, "no P-state info available\n");
936 static int i915_delayfreq_table(struct seq_file
*m
, void *unused
)
938 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
939 struct drm_device
*dev
= node
->minor
->dev
;
940 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
944 for (i
= 0; i
< 16; i
++) {
945 delayfreq
= I915_READ(PXVFREQ_BASE
+ i
* 4);
946 seq_printf(m
, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i
, delayfreq
,
947 (delayfreq
& PXVFREQ_PX_MASK
) >> PXVFREQ_PX_SHIFT
);
953 static inline int MAP_TO_MV(int map
)
955 return 1250 - (map
* 25);
958 static int i915_inttoext_table(struct seq_file
*m
, void *unused
)
960 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
961 struct drm_device
*dev
= node
->minor
->dev
;
962 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
966 for (i
= 1; i
<= 32; i
++) {
967 inttoext
= I915_READ(INTTOEXT_BASE_ILK
+ i
* 4);
968 seq_printf(m
, "INTTOEXT%02d: 0x%08x\n", i
, inttoext
);
974 static int i915_drpc_info(struct seq_file
*m
, void *unused
)
976 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
977 struct drm_device
*dev
= node
->minor
->dev
;
978 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
979 u32 rgvmodectl
= I915_READ(MEMMODECTL
);
980 u32 rstdbyctl
= I915_READ(RSTDBYCTL
);
981 u16 crstandvid
= I915_READ16(CRSTANDVID
);
983 seq_printf(m
, "HD boost: %s\n", (rgvmodectl
& MEMMODE_BOOST_EN
) ?
985 seq_printf(m
, "Boost freq: %d\n",
986 (rgvmodectl
& MEMMODE_BOOST_FREQ_MASK
) >>
987 MEMMODE_BOOST_FREQ_SHIFT
);
988 seq_printf(m
, "HW control enabled: %s\n",
989 rgvmodectl
& MEMMODE_HWIDLE_EN
? "yes" : "no");
990 seq_printf(m
, "SW control enabled: %s\n",
991 rgvmodectl
& MEMMODE_SWMODE_EN
? "yes" : "no");
992 seq_printf(m
, "Gated voltage change: %s\n",
993 rgvmodectl
& MEMMODE_RCLK_GATE
? "yes" : "no");
994 seq_printf(m
, "Starting frequency: P%d\n",
995 (rgvmodectl
& MEMMODE_FSTART_MASK
) >> MEMMODE_FSTART_SHIFT
);
996 seq_printf(m
, "Max P-state: P%d\n",
997 (rgvmodectl
& MEMMODE_FMAX_MASK
) >> MEMMODE_FMAX_SHIFT
);
998 seq_printf(m
, "Min P-state: P%d\n", (rgvmodectl
& MEMMODE_FMIN_MASK
));
999 seq_printf(m
, "RS1 VID: %d\n", (crstandvid
& 0x3f));
1000 seq_printf(m
, "RS2 VID: %d\n", ((crstandvid
>> 8) & 0x3f));
1001 seq_printf(m
, "Render standby enabled: %s\n",
1002 (rstdbyctl
& RCX_SW_EXIT
) ? "no" : "yes");
1003 seq_printf(m
, "Current RS state: ");
1004 switch (rstdbyctl
& RSX_STATUS_MASK
) {
1006 seq_printf(m
, "on\n");
1008 case RSX_STATUS_RC1
:
1009 seq_printf(m
, "RC1\n");
1011 case RSX_STATUS_RC1E
:
1012 seq_printf(m
, "RC1E\n");
1014 case RSX_STATUS_RS1
:
1015 seq_printf(m
, "RS1\n");
1017 case RSX_STATUS_RS2
:
1018 seq_printf(m
, "RS2 (RC6)\n");
1020 case RSX_STATUS_RS3
:
1021 seq_printf(m
, "RC3 (RC6+)\n");
1024 seq_printf(m
, "unknown\n");
1031 static int i915_fbc_status(struct seq_file
*m
, void *unused
)
1033 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1034 struct drm_device
*dev
= node
->minor
->dev
;
1035 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1037 if (!I915_HAS_FBC(dev
)) {
1038 seq_printf(m
, "FBC unsupported on this chipset\n");
1042 if (intel_fbc_enabled(dev
)) {
1043 seq_printf(m
, "FBC enabled\n");
1045 seq_printf(m
, "FBC disabled: ");
1046 switch (dev_priv
->no_fbc_reason
) {
1048 seq_printf(m
, "no outputs");
1050 case FBC_STOLEN_TOO_SMALL
:
1051 seq_printf(m
, "not enough stolen memory");
1053 case FBC_UNSUPPORTED_MODE
:
1054 seq_printf(m
, "mode not supported");
1056 case FBC_MODE_TOO_LARGE
:
1057 seq_printf(m
, "mode too large");
1060 seq_printf(m
, "FBC unsupported on plane");
1063 seq_printf(m
, "scanout buffer not tiled");
1065 case FBC_MULTIPLE_PIPES
:
1066 seq_printf(m
, "multiple pipes are enabled");
1068 case FBC_MODULE_PARAM
:
1069 seq_printf(m
, "disabled per module param (default off)");
1072 seq_printf(m
, "unknown reason");
1074 seq_printf(m
, "\n");
1079 static int i915_sr_status(struct seq_file
*m
, void *unused
)
1081 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1082 struct drm_device
*dev
= node
->minor
->dev
;
1083 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1084 bool sr_enabled
= false;
1086 if (HAS_PCH_SPLIT(dev
))
1087 sr_enabled
= I915_READ(WM1_LP_ILK
) & WM1_LP_SR_EN
;
1088 else if (IS_CRESTLINE(dev
) || IS_I945G(dev
) || IS_I945GM(dev
))
1089 sr_enabled
= I915_READ(FW_BLC_SELF
) & FW_BLC_SELF_EN
;
1090 else if (IS_I915GM(dev
))
1091 sr_enabled
= I915_READ(INSTPM
) & INSTPM_SELF_EN
;
1092 else if (IS_PINEVIEW(dev
))
1093 sr_enabled
= I915_READ(DSPFW3
) & PINEVIEW_SELF_REFRESH_EN
;
1095 seq_printf(m
, "self-refresh: %s\n",
1096 sr_enabled
? "enabled" : "disabled");
1101 static int i915_emon_status(struct seq_file
*m
, void *unused
)
1103 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1104 struct drm_device
*dev
= node
->minor
->dev
;
1105 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1106 unsigned long temp
, chipset
, gfx
;
1109 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1113 temp
= i915_mch_val(dev_priv
);
1114 chipset
= i915_chipset_val(dev_priv
);
1115 gfx
= i915_gfx_val(dev_priv
);
1116 mutex_unlock(&dev
->struct_mutex
);
1118 seq_printf(m
, "GMCH temp: %ld\n", temp
);
1119 seq_printf(m
, "Chipset power: %ld\n", chipset
);
1120 seq_printf(m
, "GFX power: %ld\n", gfx
);
1121 seq_printf(m
, "Total power: %ld\n", chipset
+ gfx
);
1126 static int i915_ring_freq_table(struct seq_file
*m
, void *unused
)
1128 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1129 struct drm_device
*dev
= node
->minor
->dev
;
1130 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1132 int gpu_freq
, ia_freq
;
1134 if (!(IS_GEN6(dev
) || IS_GEN7(dev
))) {
1135 seq_printf(m
, "unsupported on this chipset\n");
1139 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1143 seq_printf(m
, "GPU freq (MHz)\tEffective CPU freq (MHz)\n");
1145 for (gpu_freq
= dev_priv
->min_delay
; gpu_freq
<= dev_priv
->max_delay
;
1147 I915_WRITE(GEN6_PCODE_DATA
, gpu_freq
);
1148 I915_WRITE(GEN6_PCODE_MAILBOX
, GEN6_PCODE_READY
|
1149 GEN6_PCODE_READ_MIN_FREQ_TABLE
);
1150 if (wait_for((I915_READ(GEN6_PCODE_MAILBOX
) &
1151 GEN6_PCODE_READY
) == 0, 10)) {
1152 DRM_ERROR("pcode read of freq table timed out\n");
1155 ia_freq
= I915_READ(GEN6_PCODE_DATA
);
1156 seq_printf(m
, "%d\t\t%d\n", gpu_freq
* 50, ia_freq
* 100);
1159 mutex_unlock(&dev
->struct_mutex
);
1164 static int i915_gfxec(struct seq_file
*m
, void *unused
)
1166 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1167 struct drm_device
*dev
= node
->minor
->dev
;
1168 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1170 seq_printf(m
, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
1175 static int i915_opregion(struct seq_file
*m
, void *unused
)
1177 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1178 struct drm_device
*dev
= node
->minor
->dev
;
1179 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1180 struct intel_opregion
*opregion
= &dev_priv
->opregion
;
1183 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1187 if (opregion
->header
)
1188 seq_write(m
, opregion
->header
, OPREGION_SIZE
);
1190 mutex_unlock(&dev
->struct_mutex
);
1195 static int i915_gem_framebuffer_info(struct seq_file
*m
, void *data
)
1197 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1198 struct drm_device
*dev
= node
->minor
->dev
;
1199 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1200 struct intel_fbdev
*ifbdev
;
1201 struct intel_framebuffer
*fb
;
1204 ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1208 ifbdev
= dev_priv
->fbdev
;
1209 fb
= to_intel_framebuffer(ifbdev
->helper
.fb
);
1211 seq_printf(m
, "fbcon size: %d x %d, depth %d, %d bpp, obj ",
1215 fb
->base
.bits_per_pixel
);
1216 describe_obj(m
, fb
->obj
);
1217 seq_printf(m
, "\n");
1219 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, base
.head
) {
1220 if (&fb
->base
== ifbdev
->helper
.fb
)
1223 seq_printf(m
, "user size: %d x %d, depth %d, %d bpp, obj ",
1227 fb
->base
.bits_per_pixel
);
1228 describe_obj(m
, fb
->obj
);
1229 seq_printf(m
, "\n");
1232 mutex_unlock(&dev
->mode_config
.mutex
);
1237 static int i915_context_status(struct seq_file
*m
, void *unused
)
1239 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1240 struct drm_device
*dev
= node
->minor
->dev
;
1241 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1244 ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1248 if (dev_priv
->pwrctx
) {
1249 seq_printf(m
, "power context ");
1250 describe_obj(m
, dev_priv
->pwrctx
);
1251 seq_printf(m
, "\n");
1254 if (dev_priv
->renderctx
) {
1255 seq_printf(m
, "render context ");
1256 describe_obj(m
, dev_priv
->renderctx
);
1257 seq_printf(m
, "\n");
1260 mutex_unlock(&dev
->mode_config
.mutex
);
1265 static int i915_gen6_forcewake_count_info(struct seq_file
*m
, void *data
)
1267 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1268 struct drm_device
*dev
= node
->minor
->dev
;
1269 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1271 seq_printf(m
, "forcewake count = %d\n",
1272 atomic_read(&dev_priv
->forcewake_count
));
1278 i915_wedged_open(struct inode
*inode
,
1281 filp
->private_data
= inode
->i_private
;
1286 i915_wedged_read(struct file
*filp
,
1291 struct drm_device
*dev
= filp
->private_data
;
1292 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1296 len
= snprintf(buf
, sizeof (buf
),
1298 atomic_read(&dev_priv
->mm
.wedged
));
1300 if (len
> sizeof (buf
))
1303 return simple_read_from_buffer(ubuf
, max
, ppos
, buf
, len
);
1307 i915_wedged_write(struct file
*filp
,
1308 const char __user
*ubuf
,
1312 struct drm_device
*dev
= filp
->private_data
;
1317 if (cnt
> sizeof (buf
) - 1)
1320 if (copy_from_user(buf
, ubuf
, cnt
))
1324 val
= simple_strtoul(buf
, NULL
, 0);
1327 DRM_INFO("Manually setting wedged to %d\n", val
);
1328 i915_handle_error(dev
, val
);
1333 static const struct file_operations i915_wedged_fops
= {
1334 .owner
= THIS_MODULE
,
1335 .open
= i915_wedged_open
,
1336 .read
= i915_wedged_read
,
1337 .write
= i915_wedged_write
,
1338 .llseek
= default_llseek
,
1342 i915_max_freq_open(struct inode
*inode
,
1345 filp
->private_data
= inode
->i_private
;
1350 i915_max_freq_read(struct file
*filp
,
1355 struct drm_device
*dev
= filp
->private_data
;
1356 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1360 len
= snprintf(buf
, sizeof (buf
),
1361 "max freq: %d\n", dev_priv
->max_delay
* 50);
1363 if (len
> sizeof (buf
))
1366 return simple_read_from_buffer(ubuf
, max
, ppos
, buf
, len
);
1370 i915_max_freq_write(struct file
*filp
,
1371 const char __user
*ubuf
,
1375 struct drm_device
*dev
= filp
->private_data
;
1376 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1381 if (cnt
> sizeof (buf
) - 1)
1384 if (copy_from_user(buf
, ubuf
, cnt
))
1388 val
= simple_strtoul(buf
, NULL
, 0);
1391 DRM_DEBUG_DRIVER("Manually setting max freq to %d\n", val
);
1394 * Turbo will still be enabled, but won't go above the set value.
1396 dev_priv
->max_delay
= val
/ 50;
1398 gen6_set_rps(dev
, val
/ 50);
1403 static const struct file_operations i915_max_freq_fops
= {
1404 .owner
= THIS_MODULE
,
1405 .open
= i915_max_freq_open
,
1406 .read
= i915_max_freq_read
,
1407 .write
= i915_max_freq_write
,
1408 .llseek
= default_llseek
,
1412 i915_cache_sharing_open(struct inode
*inode
,
1415 filp
->private_data
= inode
->i_private
;
1420 i915_cache_sharing_read(struct file
*filp
,
1425 struct drm_device
*dev
= filp
->private_data
;
1426 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1431 mutex_lock(&dev_priv
->dev
->struct_mutex
);
1432 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
1433 mutex_unlock(&dev_priv
->dev
->struct_mutex
);
1435 len
= snprintf(buf
, sizeof (buf
),
1436 "%d\n", (snpcr
& GEN6_MBC_SNPCR_MASK
) >>
1437 GEN6_MBC_SNPCR_SHIFT
);
1439 if (len
> sizeof (buf
))
1442 return simple_read_from_buffer(ubuf
, max
, ppos
, buf
, len
);
1446 i915_cache_sharing_write(struct file
*filp
,
1447 const char __user
*ubuf
,
1451 struct drm_device
*dev
= filp
->private_data
;
1452 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1458 if (cnt
> sizeof (buf
) - 1)
1461 if (copy_from_user(buf
, ubuf
, cnt
))
1465 val
= simple_strtoul(buf
, NULL
, 0);
1468 if (val
< 0 || val
> 3)
1471 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %d\n", val
);
1473 /* Update the cache sharing policy here as well */
1474 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
1475 snpcr
&= ~GEN6_MBC_SNPCR_MASK
;
1476 snpcr
|= (val
<< GEN6_MBC_SNPCR_SHIFT
);
1477 I915_WRITE(GEN6_MBCUNIT_SNPCR
, snpcr
);
1482 static const struct file_operations i915_cache_sharing_fops
= {
1483 .owner
= THIS_MODULE
,
1484 .open
= i915_cache_sharing_open
,
1485 .read
= i915_cache_sharing_read
,
1486 .write
= i915_cache_sharing_write
,
1487 .llseek
= default_llseek
,
1490 /* As the drm_debugfs_init() routines are called before dev->dev_private is
1491 * allocated we need to hook into the minor for release. */
1493 drm_add_fake_info_node(struct drm_minor
*minor
,
1497 struct drm_info_node
*node
;
1499 node
= kmalloc(sizeof(struct drm_info_node
), GFP_KERNEL
);
1501 debugfs_remove(ent
);
1505 node
->minor
= minor
;
1507 node
->info_ent
= (void *) key
;
1508 list_add(&node
->list
, &minor
->debugfs_nodes
.list
);
1513 static int i915_wedged_create(struct dentry
*root
, struct drm_minor
*minor
)
1515 struct drm_device
*dev
= minor
->dev
;
1518 ent
= debugfs_create_file("i915_wedged",
1523 return PTR_ERR(ent
);
1525 return drm_add_fake_info_node(minor
, ent
, &i915_wedged_fops
);
1528 static int i915_forcewake_open(struct inode
*inode
, struct file
*file
)
1530 struct drm_device
*dev
= inode
->i_private
;
1531 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1537 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1540 gen6_gt_force_wake_get(dev_priv
);
1541 mutex_unlock(&dev
->struct_mutex
);
1546 int i915_forcewake_release(struct inode
*inode
, struct file
*file
)
1548 struct drm_device
*dev
= inode
->i_private
;
1549 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1555 * It's bad that we can potentially hang userspace if struct_mutex gets
1556 * forever stuck. However, if we cannot acquire this lock it means that
1557 * almost certainly the driver has hung, is not unload-able. Therefore
1558 * hanging here is probably a minor inconvenience not to be seen my
1559 * almost every user.
1561 mutex_lock(&dev
->struct_mutex
);
1562 gen6_gt_force_wake_put(dev_priv
);
1563 mutex_unlock(&dev
->struct_mutex
);
1568 static const struct file_operations i915_forcewake_fops
= {
1569 .owner
= THIS_MODULE
,
1570 .open
= i915_forcewake_open
,
1571 .release
= i915_forcewake_release
,
1574 static int i915_forcewake_create(struct dentry
*root
, struct drm_minor
*minor
)
1576 struct drm_device
*dev
= minor
->dev
;
1579 ent
= debugfs_create_file("i915_forcewake_user",
1582 &i915_forcewake_fops
);
1584 return PTR_ERR(ent
);
1586 return drm_add_fake_info_node(minor
, ent
, &i915_forcewake_fops
);
1589 static int i915_max_freq_create(struct dentry
*root
, struct drm_minor
*minor
)
1591 struct drm_device
*dev
= minor
->dev
;
1594 ent
= debugfs_create_file("i915_max_freq",
1597 &i915_max_freq_fops
);
1599 return PTR_ERR(ent
);
1601 return drm_add_fake_info_node(minor
, ent
, &i915_max_freq_fops
);
1604 static int i915_cache_sharing_create(struct dentry
*root
, struct drm_minor
*minor
)
1606 struct drm_device
*dev
= minor
->dev
;
1609 ent
= debugfs_create_file("i915_cache_sharing",
1612 &i915_cache_sharing_fops
);
1614 return PTR_ERR(ent
);
1616 return drm_add_fake_info_node(minor
, ent
, &i915_cache_sharing_fops
);
1619 static struct drm_info_list i915_debugfs_list
[] = {
1620 {"i915_capabilities", i915_capabilities
, 0},
1621 {"i915_gem_objects", i915_gem_object_info
, 0},
1622 {"i915_gem_gtt", i915_gem_gtt_info
, 0},
1623 {"i915_gem_active", i915_gem_object_list_info
, 0, (void *) ACTIVE_LIST
},
1624 {"i915_gem_flushing", i915_gem_object_list_info
, 0, (void *) FLUSHING_LIST
},
1625 {"i915_gem_inactive", i915_gem_object_list_info
, 0, (void *) INACTIVE_LIST
},
1626 {"i915_gem_pinned", i915_gem_object_list_info
, 0, (void *) PINNED_LIST
},
1627 {"i915_gem_deferred_free", i915_gem_object_list_info
, 0, (void *) DEFERRED_FREE_LIST
},
1628 {"i915_gem_pageflip", i915_gem_pageflip_info
, 0},
1629 {"i915_gem_request", i915_gem_request_info
, 0},
1630 {"i915_gem_seqno", i915_gem_seqno_info
, 0},
1631 {"i915_gem_fence_regs", i915_gem_fence_regs_info
, 0},
1632 {"i915_gem_interrupt", i915_interrupt_info
, 0},
1633 {"i915_gem_hws", i915_hws_info
, 0, (void *)RCS
},
1634 {"i915_gem_hws_blt", i915_hws_info
, 0, (void *)BCS
},
1635 {"i915_gem_hws_bsd", i915_hws_info
, 0, (void *)VCS
},
1636 {"i915_ringbuffer_data", i915_ringbuffer_data
, 0, (void *)RCS
},
1637 {"i915_ringbuffer_info", i915_ringbuffer_info
, 0, (void *)RCS
},
1638 {"i915_bsd_ringbuffer_data", i915_ringbuffer_data
, 0, (void *)VCS
},
1639 {"i915_bsd_ringbuffer_info", i915_ringbuffer_info
, 0, (void *)VCS
},
1640 {"i915_blt_ringbuffer_data", i915_ringbuffer_data
, 0, (void *)BCS
},
1641 {"i915_blt_ringbuffer_info", i915_ringbuffer_info
, 0, (void *)BCS
},
1642 {"i915_batchbuffers", i915_batchbuffer_info
, 0},
1643 {"i915_error_state", i915_error_state
, 0},
1644 {"i915_rstdby_delays", i915_rstdby_delays
, 0},
1645 {"i915_cur_delayinfo", i915_cur_delayinfo
, 0},
1646 {"i915_delayfreq_table", i915_delayfreq_table
, 0},
1647 {"i915_inttoext_table", i915_inttoext_table
, 0},
1648 {"i915_drpc_info", i915_drpc_info
, 0},
1649 {"i915_emon_status", i915_emon_status
, 0},
1650 {"i915_ring_freq_table", i915_ring_freq_table
, 0},
1651 {"i915_gfxec", i915_gfxec
, 0},
1652 {"i915_fbc_status", i915_fbc_status
, 0},
1653 {"i915_sr_status", i915_sr_status
, 0},
1654 {"i915_opregion", i915_opregion
, 0},
1655 {"i915_gem_framebuffer", i915_gem_framebuffer_info
, 0},
1656 {"i915_context_status", i915_context_status
, 0},
1657 {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info
, 0},
1659 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
1661 int i915_debugfs_init(struct drm_minor
*minor
)
1665 ret
= i915_wedged_create(minor
->debugfs_root
, minor
);
1669 ret
= i915_forcewake_create(minor
->debugfs_root
, minor
);
1672 ret
= i915_max_freq_create(minor
->debugfs_root
, minor
);
1675 ret
= i915_cache_sharing_create(minor
->debugfs_root
, minor
);
1679 return drm_debugfs_create_files(i915_debugfs_list
,
1680 I915_DEBUGFS_ENTRIES
,
1681 minor
->debugfs_root
, minor
);
1684 void i915_debugfs_cleanup(struct drm_minor
*minor
)
1686 drm_debugfs_remove_files(i915_debugfs_list
,
1687 I915_DEBUGFS_ENTRIES
, minor
);
1688 drm_debugfs_remove_files((struct drm_info_list
*) &i915_forcewake_fops
,
1690 drm_debugfs_remove_files((struct drm_info_list
*) &i915_wedged_fops
,
1692 drm_debugfs_remove_files((struct drm_info_list
*) &i915_max_freq_fops
,
1694 drm_debugfs_remove_files((struct drm_info_list
*) &i915_cache_sharing_fops
,
1698 #endif /* CONFIG_DEBUG_FS */