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>
34 #include "intel_drv.h"
35 #include "intel_ringbuffer.h"
36 #include <drm/i915_drm.h>
39 #define DRM_I915_RING_DEBUG 1
42 #if defined(CONFIG_DEBUG_FS)
50 static const char *yesno(int v
)
52 return v
? "yes" : "no";
55 static int i915_capabilities(struct seq_file
*m
, void *data
)
57 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
58 struct drm_device
*dev
= node
->minor
->dev
;
59 const struct intel_device_info
*info
= INTEL_INFO(dev
);
61 seq_printf(m
, "gen: %d\n", info
->gen
);
62 seq_printf(m
, "pch: %d\n", INTEL_PCH_TYPE(dev
));
63 #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
64 #define SEP_SEMICOLON ;
65 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG
, SEP_SEMICOLON
);
72 static const char *get_pin_flag(struct drm_i915_gem_object
*obj
)
74 if (obj
->user_pin_count
> 0)
76 else if (obj
->pin_count
> 0)
82 static const char *get_tiling_flag(struct drm_i915_gem_object
*obj
)
84 switch (obj
->tiling_mode
) {
86 case I915_TILING_NONE
: return " ";
87 case I915_TILING_X
: return "X";
88 case I915_TILING_Y
: return "Y";
92 static inline const char *get_global_flag(struct drm_i915_gem_object
*obj
)
94 return obj
->has_global_gtt_mapping
? "g" : " ";
98 describe_obj(struct seq_file
*m
, struct drm_i915_gem_object
*obj
)
100 struct i915_vma
*vma
;
101 seq_printf(m
, "%pK: %s%s%s %8zdKiB %02x %02x %d %d %d%s%s%s",
104 get_tiling_flag(obj
),
105 get_global_flag(obj
),
106 obj
->base
.size
/ 1024,
107 obj
->base
.read_domains
,
108 obj
->base
.write_domain
,
109 obj
->last_read_seqno
,
110 obj
->last_write_seqno
,
111 obj
->last_fenced_seqno
,
112 i915_cache_level_str(obj
->cache_level
),
113 obj
->dirty
? " dirty" : "",
114 obj
->madv
== I915_MADV_DONTNEED
? " purgeable" : "");
116 seq_printf(m
, " (name: %d)", obj
->base
.name
);
118 seq_printf(m
, " (pinned x %d)", obj
->pin_count
);
119 if (obj
->fence_reg
!= I915_FENCE_REG_NONE
)
120 seq_printf(m
, " (fence: %d)", obj
->fence_reg
);
121 list_for_each_entry(vma
, &obj
->vma_list
, vma_link
) {
122 if (!i915_is_ggtt(vma
->vm
))
126 seq_printf(m
, "gtt offset: %08lx, size: %08lx)",
127 vma
->node
.start
, vma
->node
.size
);
130 seq_printf(m
, " (stolen: %08lx)", obj
->stolen
->start
);
131 if (obj
->pin_mappable
|| obj
->fault_mappable
) {
133 if (obj
->pin_mappable
)
135 if (obj
->fault_mappable
)
138 seq_printf(m
, " (%s mappable)", s
);
140 if (obj
->ring
!= NULL
)
141 seq_printf(m
, " (%s)", obj
->ring
->name
);
144 static int i915_gem_object_list_info(struct seq_file
*m
, void *data
)
146 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
147 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
148 struct list_head
*head
;
149 struct drm_device
*dev
= node
->minor
->dev
;
150 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
151 struct i915_address_space
*vm
= &dev_priv
->gtt
.base
;
152 struct drm_i915_gem_object
*obj
;
153 size_t total_obj_size
, total_gtt_size
;
156 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
162 seq_puts(m
, "Active:\n");
163 head
= &vm
->active_list
;
166 seq_puts(m
, "Inactive:\n");
167 head
= &vm
->inactive_list
;
170 mutex_unlock(&dev
->struct_mutex
);
174 total_obj_size
= total_gtt_size
= count
= 0;
175 list_for_each_entry(obj
, head
, mm_list
) {
177 describe_obj(m
, obj
);
179 total_obj_size
+= obj
->base
.size
;
180 total_gtt_size
+= i915_gem_obj_ggtt_size(obj
);
183 mutex_unlock(&dev
->struct_mutex
);
185 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
186 count
, total_obj_size
, total_gtt_size
);
190 #define count_objects(list, member) do { \
191 list_for_each_entry(obj, list, member) { \
192 size += i915_gem_obj_ggtt_size(obj); \
194 if (obj->map_and_fenceable) { \
195 mappable_size += i915_gem_obj_ggtt_size(obj); \
203 size_t total
, active
, inactive
, unbound
;
206 static int per_file_stats(int id
, void *ptr
, void *data
)
208 struct drm_i915_gem_object
*obj
= ptr
;
209 struct file_stats
*stats
= data
;
212 stats
->total
+= obj
->base
.size
;
214 if (i915_gem_obj_ggtt_bound(obj
)) {
215 if (!list_empty(&obj
->ring_list
))
216 stats
->active
+= obj
->base
.size
;
218 stats
->inactive
+= obj
->base
.size
;
220 if (!list_empty(&obj
->global_list
))
221 stats
->unbound
+= obj
->base
.size
;
227 static int i915_gem_object_info(struct seq_file
*m
, void *data
)
229 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
230 struct drm_device
*dev
= node
->minor
->dev
;
231 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
232 u32 count
, mappable_count
, purgeable_count
;
233 size_t size
, mappable_size
, purgeable_size
;
234 struct drm_i915_gem_object
*obj
;
235 struct i915_address_space
*vm
= &dev_priv
->gtt
.base
;
236 struct drm_file
*file
;
239 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
243 seq_printf(m
, "%u objects, %zu bytes\n",
244 dev_priv
->mm
.object_count
,
245 dev_priv
->mm
.object_memory
);
247 size
= count
= mappable_size
= mappable_count
= 0;
248 count_objects(&dev_priv
->mm
.bound_list
, global_list
);
249 seq_printf(m
, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
250 count
, mappable_count
, size
, mappable_size
);
252 size
= count
= mappable_size
= mappable_count
= 0;
253 count_objects(&vm
->active_list
, mm_list
);
254 seq_printf(m
, " %u [%u] active objects, %zu [%zu] bytes\n",
255 count
, mappable_count
, size
, mappable_size
);
257 size
= count
= mappable_size
= mappable_count
= 0;
258 count_objects(&vm
->inactive_list
, mm_list
);
259 seq_printf(m
, " %u [%u] inactive objects, %zu [%zu] bytes\n",
260 count
, mappable_count
, size
, mappable_size
);
262 size
= count
= purgeable_size
= purgeable_count
= 0;
263 list_for_each_entry(obj
, &dev_priv
->mm
.unbound_list
, global_list
) {
264 size
+= obj
->base
.size
, ++count
;
265 if (obj
->madv
== I915_MADV_DONTNEED
)
266 purgeable_size
+= obj
->base
.size
, ++purgeable_count
;
268 seq_printf(m
, "%u unbound objects, %zu bytes\n", count
, size
);
270 size
= count
= mappable_size
= mappable_count
= 0;
271 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
272 if (obj
->fault_mappable
) {
273 size
+= i915_gem_obj_ggtt_size(obj
);
276 if (obj
->pin_mappable
) {
277 mappable_size
+= i915_gem_obj_ggtt_size(obj
);
280 if (obj
->madv
== I915_MADV_DONTNEED
) {
281 purgeable_size
+= obj
->base
.size
;
285 seq_printf(m
, "%u purgeable objects, %zu bytes\n",
286 purgeable_count
, purgeable_size
);
287 seq_printf(m
, "%u pinned mappable objects, %zu bytes\n",
288 mappable_count
, mappable_size
);
289 seq_printf(m
, "%u fault mappable objects, %zu bytes\n",
292 seq_printf(m
, "%zu [%lu] gtt total\n",
293 dev_priv
->gtt
.base
.total
,
294 dev_priv
->gtt
.mappable_end
- dev_priv
->gtt
.base
.start
);
297 list_for_each_entry_reverse(file
, &dev
->filelist
, lhead
) {
298 struct file_stats stats
;
300 memset(&stats
, 0, sizeof(stats
));
301 idr_for_each(&file
->object_idr
, per_file_stats
, &stats
);
302 seq_printf(m
, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu unbound)\n",
303 get_pid_task(file
->pid
, PIDTYPE_PID
)->comm
,
311 mutex_unlock(&dev
->struct_mutex
);
316 static int i915_gem_gtt_info(struct seq_file
*m
, void *data
)
318 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
319 struct drm_device
*dev
= node
->minor
->dev
;
320 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
321 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
322 struct drm_i915_gem_object
*obj
;
323 size_t total_obj_size
, total_gtt_size
;
326 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
330 total_obj_size
= total_gtt_size
= count
= 0;
331 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
332 if (list
== PINNED_LIST
&& obj
->pin_count
== 0)
336 describe_obj(m
, obj
);
338 total_obj_size
+= obj
->base
.size
;
339 total_gtt_size
+= i915_gem_obj_ggtt_size(obj
);
343 mutex_unlock(&dev
->struct_mutex
);
345 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
346 count
, total_obj_size
, total_gtt_size
);
351 static int i915_gem_pageflip_info(struct seq_file
*m
, void *data
)
353 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
354 struct drm_device
*dev
= node
->minor
->dev
;
356 struct intel_crtc
*crtc
;
358 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, base
.head
) {
359 const char pipe
= pipe_name(crtc
->pipe
);
360 const char plane
= plane_name(crtc
->plane
);
361 struct intel_unpin_work
*work
;
363 spin_lock_irqsave(&dev
->event_lock
, flags
);
364 work
= crtc
->unpin_work
;
366 seq_printf(m
, "No flip due on pipe %c (plane %c)\n",
369 if (atomic_read(&work
->pending
) < INTEL_FLIP_COMPLETE
) {
370 seq_printf(m
, "Flip queued on pipe %c (plane %c)\n",
373 seq_printf(m
, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
376 if (work
->enable_stall_check
)
377 seq_puts(m
, "Stall check enabled, ");
379 seq_puts(m
, "Stall check waiting for page flip ioctl, ");
380 seq_printf(m
, "%d prepares\n", atomic_read(&work
->pending
));
382 if (work
->old_fb_obj
) {
383 struct drm_i915_gem_object
*obj
= work
->old_fb_obj
;
385 seq_printf(m
, "Old framebuffer gtt_offset 0x%08lx\n",
386 i915_gem_obj_ggtt_offset(obj
));
388 if (work
->pending_flip_obj
) {
389 struct drm_i915_gem_object
*obj
= work
->pending_flip_obj
;
391 seq_printf(m
, "New framebuffer gtt_offset 0x%08lx\n",
392 i915_gem_obj_ggtt_offset(obj
));
395 spin_unlock_irqrestore(&dev
->event_lock
, flags
);
401 static int i915_gem_request_info(struct seq_file
*m
, void *data
)
403 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
404 struct drm_device
*dev
= node
->minor
->dev
;
405 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
406 struct intel_ring_buffer
*ring
;
407 struct drm_i915_gem_request
*gem_request
;
410 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
415 for_each_ring(ring
, dev_priv
, i
) {
416 if (list_empty(&ring
->request_list
))
419 seq_printf(m
, "%s requests:\n", ring
->name
);
420 list_for_each_entry(gem_request
,
423 seq_printf(m
, " %d @ %d\n",
425 (int) (jiffies
- gem_request
->emitted_jiffies
));
429 mutex_unlock(&dev
->struct_mutex
);
432 seq_puts(m
, "No requests\n");
437 static void i915_ring_seqno_info(struct seq_file
*m
,
438 struct intel_ring_buffer
*ring
)
440 if (ring
->get_seqno
) {
441 seq_printf(m
, "Current sequence (%s): %u\n",
442 ring
->name
, ring
->get_seqno(ring
, false));
446 static int i915_gem_seqno_info(struct seq_file
*m
, void *data
)
448 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
449 struct drm_device
*dev
= node
->minor
->dev
;
450 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
451 struct intel_ring_buffer
*ring
;
454 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
458 for_each_ring(ring
, dev_priv
, i
)
459 i915_ring_seqno_info(m
, ring
);
461 mutex_unlock(&dev
->struct_mutex
);
467 static int i915_interrupt_info(struct seq_file
*m
, void *data
)
469 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
470 struct drm_device
*dev
= node
->minor
->dev
;
471 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
472 struct intel_ring_buffer
*ring
;
475 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
479 if (IS_VALLEYVIEW(dev
)) {
480 seq_printf(m
, "Display IER:\t%08x\n",
482 seq_printf(m
, "Display IIR:\t%08x\n",
484 seq_printf(m
, "Display IIR_RW:\t%08x\n",
485 I915_READ(VLV_IIR_RW
));
486 seq_printf(m
, "Display IMR:\t%08x\n",
489 seq_printf(m
, "Pipe %c stat:\t%08x\n",
491 I915_READ(PIPESTAT(pipe
)));
493 seq_printf(m
, "Master IER:\t%08x\n",
494 I915_READ(VLV_MASTER_IER
));
496 seq_printf(m
, "Render IER:\t%08x\n",
498 seq_printf(m
, "Render IIR:\t%08x\n",
500 seq_printf(m
, "Render IMR:\t%08x\n",
503 seq_printf(m
, "PM IER:\t\t%08x\n",
504 I915_READ(GEN6_PMIER
));
505 seq_printf(m
, "PM IIR:\t\t%08x\n",
506 I915_READ(GEN6_PMIIR
));
507 seq_printf(m
, "PM IMR:\t\t%08x\n",
508 I915_READ(GEN6_PMIMR
));
510 seq_printf(m
, "Port hotplug:\t%08x\n",
511 I915_READ(PORT_HOTPLUG_EN
));
512 seq_printf(m
, "DPFLIPSTAT:\t%08x\n",
513 I915_READ(VLV_DPFLIPSTAT
));
514 seq_printf(m
, "DPINVGTT:\t%08x\n",
515 I915_READ(DPINVGTT
));
517 } else if (!HAS_PCH_SPLIT(dev
)) {
518 seq_printf(m
, "Interrupt enable: %08x\n",
520 seq_printf(m
, "Interrupt identity: %08x\n",
522 seq_printf(m
, "Interrupt mask: %08x\n",
525 seq_printf(m
, "Pipe %c stat: %08x\n",
527 I915_READ(PIPESTAT(pipe
)));
529 seq_printf(m
, "North Display Interrupt enable: %08x\n",
531 seq_printf(m
, "North Display Interrupt identity: %08x\n",
533 seq_printf(m
, "North Display Interrupt mask: %08x\n",
535 seq_printf(m
, "South Display Interrupt enable: %08x\n",
537 seq_printf(m
, "South Display Interrupt identity: %08x\n",
539 seq_printf(m
, "South Display Interrupt mask: %08x\n",
541 seq_printf(m
, "Graphics Interrupt enable: %08x\n",
543 seq_printf(m
, "Graphics Interrupt identity: %08x\n",
545 seq_printf(m
, "Graphics Interrupt mask: %08x\n",
548 seq_printf(m
, "Interrupts received: %d\n",
549 atomic_read(&dev_priv
->irq_received
));
550 for_each_ring(ring
, dev_priv
, i
) {
551 if (IS_GEN6(dev
) || IS_GEN7(dev
)) {
553 "Graphics Interrupt mask (%s): %08x\n",
554 ring
->name
, I915_READ_IMR(ring
));
556 i915_ring_seqno_info(m
, ring
);
558 mutex_unlock(&dev
->struct_mutex
);
563 static int i915_gem_fence_regs_info(struct seq_file
*m
, void *data
)
565 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
566 struct drm_device
*dev
= node
->minor
->dev
;
567 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
570 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
574 seq_printf(m
, "Reserved fences = %d\n", dev_priv
->fence_reg_start
);
575 seq_printf(m
, "Total fences = %d\n", dev_priv
->num_fence_regs
);
576 for (i
= 0; i
< dev_priv
->num_fence_regs
; i
++) {
577 struct drm_i915_gem_object
*obj
= dev_priv
->fence_regs
[i
].obj
;
579 seq_printf(m
, "Fence %d, pin count = %d, object = ",
580 i
, dev_priv
->fence_regs
[i
].pin_count
);
582 seq_puts(m
, "unused");
584 describe_obj(m
, obj
);
588 mutex_unlock(&dev
->struct_mutex
);
592 static int i915_hws_info(struct seq_file
*m
, void *data
)
594 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
595 struct drm_device
*dev
= node
->minor
->dev
;
596 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
597 struct intel_ring_buffer
*ring
;
601 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
602 hws
= ring
->status_page
.page_addr
;
606 for (i
= 0; i
< 4096 / sizeof(u32
) / 4; i
+= 4) {
607 seq_printf(m
, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
609 hws
[i
], hws
[i
+ 1], hws
[i
+ 2], hws
[i
+ 3]);
615 i915_error_state_write(struct file
*filp
,
616 const char __user
*ubuf
,
620 struct i915_error_state_file_priv
*error_priv
= filp
->private_data
;
621 struct drm_device
*dev
= error_priv
->dev
;
624 DRM_DEBUG_DRIVER("Resetting error state\n");
626 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
630 i915_destroy_error_state(dev
);
631 mutex_unlock(&dev
->struct_mutex
);
636 static int i915_error_state_open(struct inode
*inode
, struct file
*file
)
638 struct drm_device
*dev
= inode
->i_private
;
639 struct i915_error_state_file_priv
*error_priv
;
641 error_priv
= kzalloc(sizeof(*error_priv
), GFP_KERNEL
);
645 error_priv
->dev
= dev
;
647 i915_error_state_get(dev
, error_priv
);
649 file
->private_data
= error_priv
;
654 static int i915_error_state_release(struct inode
*inode
, struct file
*file
)
656 struct i915_error_state_file_priv
*error_priv
= file
->private_data
;
658 i915_error_state_put(error_priv
);
664 static ssize_t
i915_error_state_read(struct file
*file
, char __user
*userbuf
,
665 size_t count
, loff_t
*pos
)
667 struct i915_error_state_file_priv
*error_priv
= file
->private_data
;
668 struct drm_i915_error_state_buf error_str
;
670 ssize_t ret_count
= 0;
673 ret
= i915_error_state_buf_init(&error_str
, count
, *pos
);
677 ret
= i915_error_state_to_str(&error_str
, error_priv
);
681 ret_count
= simple_read_from_buffer(userbuf
, count
, &tmp_pos
,
688 *pos
= error_str
.start
+ ret_count
;
690 i915_error_state_buf_release(&error_str
);
691 return ret
?: ret_count
;
694 static const struct file_operations i915_error_state_fops
= {
695 .owner
= THIS_MODULE
,
696 .open
= i915_error_state_open
,
697 .read
= i915_error_state_read
,
698 .write
= i915_error_state_write
,
699 .llseek
= default_llseek
,
700 .release
= i915_error_state_release
,
704 i915_next_seqno_get(void *data
, u64
*val
)
706 struct drm_device
*dev
= data
;
707 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
710 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
714 *val
= dev_priv
->next_seqno
;
715 mutex_unlock(&dev
->struct_mutex
);
721 i915_next_seqno_set(void *data
, u64 val
)
723 struct drm_device
*dev
= data
;
726 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
730 ret
= i915_gem_set_seqno(dev
, val
);
731 mutex_unlock(&dev
->struct_mutex
);
736 DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops
,
737 i915_next_seqno_get
, i915_next_seqno_set
,
740 static int i915_rstdby_delays(struct seq_file
*m
, void *unused
)
742 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
743 struct drm_device
*dev
= node
->minor
->dev
;
744 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
748 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
752 crstanddelay
= I915_READ16(CRSTANDVID
);
754 mutex_unlock(&dev
->struct_mutex
);
756 seq_printf(m
, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay
>> 8) & 0x3f, (crstanddelay
& 0x3f));
761 static int i915_cur_delayinfo(struct seq_file
*m
, void *unused
)
763 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
764 struct drm_device
*dev
= node
->minor
->dev
;
765 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
769 u16 rgvswctl
= I915_READ16(MEMSWCTL
);
770 u16 rgvstat
= I915_READ16(MEMSTAT_ILK
);
772 seq_printf(m
, "Requested P-state: %d\n", (rgvswctl
>> 8) & 0xf);
773 seq_printf(m
, "Requested VID: %d\n", rgvswctl
& 0x3f);
774 seq_printf(m
, "Current VID: %d\n", (rgvstat
& MEMSTAT_VID_MASK
) >>
776 seq_printf(m
, "Current P-state: %d\n",
777 (rgvstat
& MEMSTAT_PSTATE_MASK
) >> MEMSTAT_PSTATE_SHIFT
);
778 } else if ((IS_GEN6(dev
) || IS_GEN7(dev
)) && !IS_VALLEYVIEW(dev
)) {
779 u32 gt_perf_status
= I915_READ(GEN6_GT_PERF_STATUS
);
780 u32 rp_state_limits
= I915_READ(GEN6_RP_STATE_LIMITS
);
781 u32 rp_state_cap
= I915_READ(GEN6_RP_STATE_CAP
);
783 u32 rpupei
, rpcurup
, rpprevup
;
784 u32 rpdownei
, rpcurdown
, rpprevdown
;
787 /* RPSTAT1 is in the GT power well */
788 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
792 gen6_gt_force_wake_get(dev_priv
);
794 rpstat
= I915_READ(GEN6_RPSTAT1
);
795 rpupei
= I915_READ(GEN6_RP_CUR_UP_EI
);
796 rpcurup
= I915_READ(GEN6_RP_CUR_UP
);
797 rpprevup
= I915_READ(GEN6_RP_PREV_UP
);
798 rpdownei
= I915_READ(GEN6_RP_CUR_DOWN_EI
);
799 rpcurdown
= I915_READ(GEN6_RP_CUR_DOWN
);
800 rpprevdown
= I915_READ(GEN6_RP_PREV_DOWN
);
802 cagf
= (rpstat
& HSW_CAGF_MASK
) >> HSW_CAGF_SHIFT
;
804 cagf
= (rpstat
& GEN6_CAGF_MASK
) >> GEN6_CAGF_SHIFT
;
805 cagf
*= GT_FREQUENCY_MULTIPLIER
;
807 gen6_gt_force_wake_put(dev_priv
);
808 mutex_unlock(&dev
->struct_mutex
);
810 seq_printf(m
, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status
);
811 seq_printf(m
, "RPSTAT1: 0x%08x\n", rpstat
);
812 seq_printf(m
, "Render p-state ratio: %d\n",
813 (gt_perf_status
& 0xff00) >> 8);
814 seq_printf(m
, "Render p-state VID: %d\n",
815 gt_perf_status
& 0xff);
816 seq_printf(m
, "Render p-state limit: %d\n",
817 rp_state_limits
& 0xff);
818 seq_printf(m
, "CAGF: %dMHz\n", cagf
);
819 seq_printf(m
, "RP CUR UP EI: %dus\n", rpupei
&
821 seq_printf(m
, "RP CUR UP: %dus\n", rpcurup
&
822 GEN6_CURBSYTAVG_MASK
);
823 seq_printf(m
, "RP PREV UP: %dus\n", rpprevup
&
824 GEN6_CURBSYTAVG_MASK
);
825 seq_printf(m
, "RP CUR DOWN EI: %dus\n", rpdownei
&
827 seq_printf(m
, "RP CUR DOWN: %dus\n", rpcurdown
&
828 GEN6_CURBSYTAVG_MASK
);
829 seq_printf(m
, "RP PREV DOWN: %dus\n", rpprevdown
&
830 GEN6_CURBSYTAVG_MASK
);
832 max_freq
= (rp_state_cap
& 0xff0000) >> 16;
833 seq_printf(m
, "Lowest (RPN) frequency: %dMHz\n",
834 max_freq
* GT_FREQUENCY_MULTIPLIER
);
836 max_freq
= (rp_state_cap
& 0xff00) >> 8;
837 seq_printf(m
, "Nominal (RP1) frequency: %dMHz\n",
838 max_freq
* GT_FREQUENCY_MULTIPLIER
);
840 max_freq
= rp_state_cap
& 0xff;
841 seq_printf(m
, "Max non-overclocked (RP0) frequency: %dMHz\n",
842 max_freq
* GT_FREQUENCY_MULTIPLIER
);
844 seq_printf(m
, "Max overclocked frequency: %dMHz\n",
845 dev_priv
->rps
.hw_max
* GT_FREQUENCY_MULTIPLIER
);
846 } else if (IS_VALLEYVIEW(dev
)) {
849 mutex_lock(&dev_priv
->rps
.hw_lock
);
850 freq_sts
= vlv_punit_read(dev_priv
, PUNIT_REG_GPU_FREQ_STS
);
851 seq_printf(m
, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts
);
852 seq_printf(m
, "DDR freq: %d MHz\n", dev_priv
->mem_freq
);
854 val
= vlv_punit_read(dev_priv
, PUNIT_FUSE_BUS1
);
855 seq_printf(m
, "max GPU freq: %d MHz\n",
856 vlv_gpu_freq(dev_priv
->mem_freq
, val
));
858 val
= vlv_punit_read(dev_priv
, PUNIT_REG_GPU_LFM
);
859 seq_printf(m
, "min GPU freq: %d MHz\n",
860 vlv_gpu_freq(dev_priv
->mem_freq
, val
));
862 seq_printf(m
, "current GPU freq: %d MHz\n",
863 vlv_gpu_freq(dev_priv
->mem_freq
,
864 (freq_sts
>> 8) & 0xff));
865 mutex_unlock(&dev_priv
->rps
.hw_lock
);
867 seq_puts(m
, "no P-state info available\n");
873 static int i915_delayfreq_table(struct seq_file
*m
, void *unused
)
875 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
876 struct drm_device
*dev
= node
->minor
->dev
;
877 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
881 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
885 for (i
= 0; i
< 16; i
++) {
886 delayfreq
= I915_READ(PXVFREQ_BASE
+ i
* 4);
887 seq_printf(m
, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i
, delayfreq
,
888 (delayfreq
& PXVFREQ_PX_MASK
) >> PXVFREQ_PX_SHIFT
);
891 mutex_unlock(&dev
->struct_mutex
);
896 static inline int MAP_TO_MV(int map
)
898 return 1250 - (map
* 25);
901 static int i915_inttoext_table(struct seq_file
*m
, void *unused
)
903 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
904 struct drm_device
*dev
= node
->minor
->dev
;
905 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
909 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
913 for (i
= 1; i
<= 32; i
++) {
914 inttoext
= I915_READ(INTTOEXT_BASE_ILK
+ i
* 4);
915 seq_printf(m
, "INTTOEXT%02d: 0x%08x\n", i
, inttoext
);
918 mutex_unlock(&dev
->struct_mutex
);
923 static int ironlake_drpc_info(struct seq_file
*m
)
925 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
926 struct drm_device
*dev
= node
->minor
->dev
;
927 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
928 u32 rgvmodectl
, rstdbyctl
;
932 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
936 rgvmodectl
= I915_READ(MEMMODECTL
);
937 rstdbyctl
= I915_READ(RSTDBYCTL
);
938 crstandvid
= I915_READ16(CRSTANDVID
);
940 mutex_unlock(&dev
->struct_mutex
);
942 seq_printf(m
, "HD boost: %s\n", (rgvmodectl
& MEMMODE_BOOST_EN
) ?
944 seq_printf(m
, "Boost freq: %d\n",
945 (rgvmodectl
& MEMMODE_BOOST_FREQ_MASK
) >>
946 MEMMODE_BOOST_FREQ_SHIFT
);
947 seq_printf(m
, "HW control enabled: %s\n",
948 rgvmodectl
& MEMMODE_HWIDLE_EN
? "yes" : "no");
949 seq_printf(m
, "SW control enabled: %s\n",
950 rgvmodectl
& MEMMODE_SWMODE_EN
? "yes" : "no");
951 seq_printf(m
, "Gated voltage change: %s\n",
952 rgvmodectl
& MEMMODE_RCLK_GATE
? "yes" : "no");
953 seq_printf(m
, "Starting frequency: P%d\n",
954 (rgvmodectl
& MEMMODE_FSTART_MASK
) >> MEMMODE_FSTART_SHIFT
);
955 seq_printf(m
, "Max P-state: P%d\n",
956 (rgvmodectl
& MEMMODE_FMAX_MASK
) >> MEMMODE_FMAX_SHIFT
);
957 seq_printf(m
, "Min P-state: P%d\n", (rgvmodectl
& MEMMODE_FMIN_MASK
));
958 seq_printf(m
, "RS1 VID: %d\n", (crstandvid
& 0x3f));
959 seq_printf(m
, "RS2 VID: %d\n", ((crstandvid
>> 8) & 0x3f));
960 seq_printf(m
, "Render standby enabled: %s\n",
961 (rstdbyctl
& RCX_SW_EXIT
) ? "no" : "yes");
962 seq_puts(m
, "Current RS state: ");
963 switch (rstdbyctl
& RSX_STATUS_MASK
) {
968 seq_puts(m
, "RC1\n");
970 case RSX_STATUS_RC1E
:
971 seq_puts(m
, "RC1E\n");
974 seq_puts(m
, "RS1\n");
977 seq_puts(m
, "RS2 (RC6)\n");
980 seq_puts(m
, "RC3 (RC6+)\n");
983 seq_puts(m
, "unknown\n");
990 static int gen6_drpc_info(struct seq_file
*m
)
993 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
994 struct drm_device
*dev
= node
->minor
->dev
;
995 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
996 u32 rpmodectl1
, gt_core_status
, rcctl1
, rc6vids
= 0;
997 unsigned forcewake_count
;
1000 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1004 spin_lock_irq(&dev_priv
->uncore
.lock
);
1005 forcewake_count
= dev_priv
->uncore
.forcewake_count
;
1006 spin_unlock_irq(&dev_priv
->uncore
.lock
);
1008 if (forcewake_count
) {
1009 seq_puts(m
, "RC information inaccurate because somebody "
1010 "holds a forcewake reference \n");
1012 /* NB: we cannot use forcewake, else we read the wrong values */
1013 while (count
++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK
) & 1))
1015 seq_printf(m
, "RC information accurate: %s\n", yesno(count
< 51));
1018 gt_core_status
= readl(dev_priv
->regs
+ GEN6_GT_CORE_STATUS
);
1019 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS
, gt_core_status
, 4, true);
1021 rpmodectl1
= I915_READ(GEN6_RP_CONTROL
);
1022 rcctl1
= I915_READ(GEN6_RC_CONTROL
);
1023 mutex_unlock(&dev
->struct_mutex
);
1024 mutex_lock(&dev_priv
->rps
.hw_lock
);
1025 sandybridge_pcode_read(dev_priv
, GEN6_PCODE_READ_RC6VIDS
, &rc6vids
);
1026 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1028 seq_printf(m
, "Video Turbo Mode: %s\n",
1029 yesno(rpmodectl1
& GEN6_RP_MEDIA_TURBO
));
1030 seq_printf(m
, "HW control enabled: %s\n",
1031 yesno(rpmodectl1
& GEN6_RP_ENABLE
));
1032 seq_printf(m
, "SW control enabled: %s\n",
1033 yesno((rpmodectl1
& GEN6_RP_MEDIA_MODE_MASK
) ==
1034 GEN6_RP_MEDIA_SW_MODE
));
1035 seq_printf(m
, "RC1e Enabled: %s\n",
1036 yesno(rcctl1
& GEN6_RC_CTL_RC1e_ENABLE
));
1037 seq_printf(m
, "RC6 Enabled: %s\n",
1038 yesno(rcctl1
& GEN6_RC_CTL_RC6_ENABLE
));
1039 seq_printf(m
, "Deep RC6 Enabled: %s\n",
1040 yesno(rcctl1
& GEN6_RC_CTL_RC6p_ENABLE
));
1041 seq_printf(m
, "Deepest RC6 Enabled: %s\n",
1042 yesno(rcctl1
& GEN6_RC_CTL_RC6pp_ENABLE
));
1043 seq_puts(m
, "Current RC state: ");
1044 switch (gt_core_status
& GEN6_RCn_MASK
) {
1046 if (gt_core_status
& GEN6_CORE_CPD_STATE_MASK
)
1047 seq_puts(m
, "Core Power Down\n");
1049 seq_puts(m
, "on\n");
1052 seq_puts(m
, "RC3\n");
1055 seq_puts(m
, "RC6\n");
1058 seq_puts(m
, "RC7\n");
1061 seq_puts(m
, "Unknown\n");
1065 seq_printf(m
, "Core Power Down: %s\n",
1066 yesno(gt_core_status
& GEN6_CORE_CPD_STATE_MASK
));
1068 /* Not exactly sure what this is */
1069 seq_printf(m
, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1070 I915_READ(GEN6_GT_GFX_RC6_LOCKED
));
1071 seq_printf(m
, "RC6 residency since boot: %u\n",
1072 I915_READ(GEN6_GT_GFX_RC6
));
1073 seq_printf(m
, "RC6+ residency since boot: %u\n",
1074 I915_READ(GEN6_GT_GFX_RC6p
));
1075 seq_printf(m
, "RC6++ residency since boot: %u\n",
1076 I915_READ(GEN6_GT_GFX_RC6pp
));
1078 seq_printf(m
, "RC6 voltage: %dmV\n",
1079 GEN6_DECODE_RC6_VID(((rc6vids
>> 0) & 0xff)));
1080 seq_printf(m
, "RC6+ voltage: %dmV\n",
1081 GEN6_DECODE_RC6_VID(((rc6vids
>> 8) & 0xff)));
1082 seq_printf(m
, "RC6++ voltage: %dmV\n",
1083 GEN6_DECODE_RC6_VID(((rc6vids
>> 16) & 0xff)));
1087 static int i915_drpc_info(struct seq_file
*m
, void *unused
)
1089 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1090 struct drm_device
*dev
= node
->minor
->dev
;
1092 if (IS_GEN6(dev
) || IS_GEN7(dev
))
1093 return gen6_drpc_info(m
);
1095 return ironlake_drpc_info(m
);
1098 static int i915_fbc_status(struct seq_file
*m
, void *unused
)
1100 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1101 struct drm_device
*dev
= node
->minor
->dev
;
1102 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1104 if (!I915_HAS_FBC(dev
)) {
1105 seq_puts(m
, "FBC unsupported on this chipset\n");
1109 if (intel_fbc_enabled(dev
)) {
1110 seq_puts(m
, "FBC enabled\n");
1112 seq_puts(m
, "FBC disabled: ");
1113 switch (dev_priv
->fbc
.no_fbc_reason
) {
1115 seq_puts(m
, "FBC actived, but currently disabled in hardware");
1117 case FBC_UNSUPPORTED
:
1118 seq_puts(m
, "unsupported by this chipset");
1121 seq_puts(m
, "no outputs");
1123 case FBC_STOLEN_TOO_SMALL
:
1124 seq_puts(m
, "not enough stolen memory");
1126 case FBC_UNSUPPORTED_MODE
:
1127 seq_puts(m
, "mode not supported");
1129 case FBC_MODE_TOO_LARGE
:
1130 seq_puts(m
, "mode too large");
1133 seq_puts(m
, "FBC unsupported on plane");
1136 seq_puts(m
, "scanout buffer not tiled");
1138 case FBC_MULTIPLE_PIPES
:
1139 seq_puts(m
, "multiple pipes are enabled");
1141 case FBC_MODULE_PARAM
:
1142 seq_puts(m
, "disabled per module param (default off)");
1144 case FBC_CHIP_DEFAULT
:
1145 seq_puts(m
, "disabled per chip default");
1148 seq_puts(m
, "unknown reason");
1155 static int i915_ips_status(struct seq_file
*m
, void *unused
)
1157 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1158 struct drm_device
*dev
= node
->minor
->dev
;
1159 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1161 if (!HAS_IPS(dev
)) {
1162 seq_puts(m
, "not supported\n");
1166 if (I915_READ(IPS_CTL
) & IPS_ENABLE
)
1167 seq_puts(m
, "enabled\n");
1169 seq_puts(m
, "disabled\n");
1174 static int i915_sr_status(struct seq_file
*m
, void *unused
)
1176 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1177 struct drm_device
*dev
= node
->minor
->dev
;
1178 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1179 bool sr_enabled
= false;
1181 if (HAS_PCH_SPLIT(dev
))
1182 sr_enabled
= I915_READ(WM1_LP_ILK
) & WM1_LP_SR_EN
;
1183 else if (IS_CRESTLINE(dev
) || IS_I945G(dev
) || IS_I945GM(dev
))
1184 sr_enabled
= I915_READ(FW_BLC_SELF
) & FW_BLC_SELF_EN
;
1185 else if (IS_I915GM(dev
))
1186 sr_enabled
= I915_READ(INSTPM
) & INSTPM_SELF_EN
;
1187 else if (IS_PINEVIEW(dev
))
1188 sr_enabled
= I915_READ(DSPFW3
) & PINEVIEW_SELF_REFRESH_EN
;
1190 seq_printf(m
, "self-refresh: %s\n",
1191 sr_enabled
? "enabled" : "disabled");
1196 static int i915_emon_status(struct seq_file
*m
, void *unused
)
1198 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1199 struct drm_device
*dev
= node
->minor
->dev
;
1200 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1201 unsigned long temp
, chipset
, gfx
;
1207 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1211 temp
= i915_mch_val(dev_priv
);
1212 chipset
= i915_chipset_val(dev_priv
);
1213 gfx
= i915_gfx_val(dev_priv
);
1214 mutex_unlock(&dev
->struct_mutex
);
1216 seq_printf(m
, "GMCH temp: %ld\n", temp
);
1217 seq_printf(m
, "Chipset power: %ld\n", chipset
);
1218 seq_printf(m
, "GFX power: %ld\n", gfx
);
1219 seq_printf(m
, "Total power: %ld\n", chipset
+ gfx
);
1224 static int i915_ring_freq_table(struct seq_file
*m
, void *unused
)
1226 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1227 struct drm_device
*dev
= node
->minor
->dev
;
1228 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1230 int gpu_freq
, ia_freq
;
1232 if (!(IS_GEN6(dev
) || IS_GEN7(dev
))) {
1233 seq_puts(m
, "unsupported on this chipset\n");
1237 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
1241 seq_puts(m
, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
1243 for (gpu_freq
= dev_priv
->rps
.min_delay
;
1244 gpu_freq
<= dev_priv
->rps
.max_delay
;
1247 sandybridge_pcode_read(dev_priv
,
1248 GEN6_PCODE_READ_MIN_FREQ_TABLE
,
1250 seq_printf(m
, "%d\t\t%d\t\t\t\t%d\n",
1251 gpu_freq
* GT_FREQUENCY_MULTIPLIER
,
1252 ((ia_freq
>> 0) & 0xff) * 100,
1253 ((ia_freq
>> 8) & 0xff) * 100);
1256 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1261 static int i915_gfxec(struct seq_file
*m
, void *unused
)
1263 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1264 struct drm_device
*dev
= node
->minor
->dev
;
1265 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1268 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1272 seq_printf(m
, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
1274 mutex_unlock(&dev
->struct_mutex
);
1279 static int i915_opregion(struct seq_file
*m
, void *unused
)
1281 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1282 struct drm_device
*dev
= node
->minor
->dev
;
1283 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1284 struct intel_opregion
*opregion
= &dev_priv
->opregion
;
1285 void *data
= kmalloc(OPREGION_SIZE
, GFP_KERNEL
);
1291 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1295 if (opregion
->header
) {
1296 memcpy_fromio(data
, opregion
->header
, OPREGION_SIZE
);
1297 seq_write(m
, data
, OPREGION_SIZE
);
1300 mutex_unlock(&dev
->struct_mutex
);
1307 static int i915_gem_framebuffer_info(struct seq_file
*m
, void *data
)
1309 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1310 struct drm_device
*dev
= node
->minor
->dev
;
1311 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1312 struct intel_fbdev
*ifbdev
;
1313 struct intel_framebuffer
*fb
;
1316 ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1320 ifbdev
= dev_priv
->fbdev
;
1321 fb
= to_intel_framebuffer(ifbdev
->helper
.fb
);
1323 seq_printf(m
, "fbcon size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
1327 fb
->base
.bits_per_pixel
,
1328 atomic_read(&fb
->base
.refcount
.refcount
));
1329 describe_obj(m
, fb
->obj
);
1331 mutex_unlock(&dev
->mode_config
.mutex
);
1333 mutex_lock(&dev
->mode_config
.fb_lock
);
1334 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, base
.head
) {
1335 if (&fb
->base
== ifbdev
->helper
.fb
)
1338 seq_printf(m
, "user size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
1342 fb
->base
.bits_per_pixel
,
1343 atomic_read(&fb
->base
.refcount
.refcount
));
1344 describe_obj(m
, fb
->obj
);
1347 mutex_unlock(&dev
->mode_config
.fb_lock
);
1352 static int i915_context_status(struct seq_file
*m
, void *unused
)
1354 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1355 struct drm_device
*dev
= node
->minor
->dev
;
1356 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1357 struct intel_ring_buffer
*ring
;
1360 ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1364 if (dev_priv
->ips
.pwrctx
) {
1365 seq_puts(m
, "power context ");
1366 describe_obj(m
, dev_priv
->ips
.pwrctx
);
1370 if (dev_priv
->ips
.renderctx
) {
1371 seq_puts(m
, "render context ");
1372 describe_obj(m
, dev_priv
->ips
.renderctx
);
1376 for_each_ring(ring
, dev_priv
, i
) {
1377 if (ring
->default_context
) {
1378 seq_printf(m
, "HW default context %s ring ", ring
->name
);
1379 describe_obj(m
, ring
->default_context
->obj
);
1384 mutex_unlock(&dev
->mode_config
.mutex
);
1389 static int i915_gen6_forcewake_count_info(struct seq_file
*m
, void *data
)
1391 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1392 struct drm_device
*dev
= node
->minor
->dev
;
1393 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1394 unsigned forcewake_count
;
1396 spin_lock_irq(&dev_priv
->uncore
.lock
);
1397 forcewake_count
= dev_priv
->uncore
.forcewake_count
;
1398 spin_unlock_irq(&dev_priv
->uncore
.lock
);
1400 seq_printf(m
, "forcewake count = %u\n", forcewake_count
);
1405 static const char *swizzle_string(unsigned swizzle
)
1408 case I915_BIT_6_SWIZZLE_NONE
:
1410 case I915_BIT_6_SWIZZLE_9
:
1412 case I915_BIT_6_SWIZZLE_9_10
:
1413 return "bit9/bit10";
1414 case I915_BIT_6_SWIZZLE_9_11
:
1415 return "bit9/bit11";
1416 case I915_BIT_6_SWIZZLE_9_10_11
:
1417 return "bit9/bit10/bit11";
1418 case I915_BIT_6_SWIZZLE_9_17
:
1419 return "bit9/bit17";
1420 case I915_BIT_6_SWIZZLE_9_10_17
:
1421 return "bit9/bit10/bit17";
1422 case I915_BIT_6_SWIZZLE_UNKNOWN
:
1429 static int i915_swizzle_info(struct seq_file
*m
, void *data
)
1431 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1432 struct drm_device
*dev
= node
->minor
->dev
;
1433 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1436 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1440 seq_printf(m
, "bit6 swizzle for X-tiling = %s\n",
1441 swizzle_string(dev_priv
->mm
.bit_6_swizzle_x
));
1442 seq_printf(m
, "bit6 swizzle for Y-tiling = %s\n",
1443 swizzle_string(dev_priv
->mm
.bit_6_swizzle_y
));
1445 if (IS_GEN3(dev
) || IS_GEN4(dev
)) {
1446 seq_printf(m
, "DDC = 0x%08x\n",
1448 seq_printf(m
, "C0DRB3 = 0x%04x\n",
1449 I915_READ16(C0DRB3
));
1450 seq_printf(m
, "C1DRB3 = 0x%04x\n",
1451 I915_READ16(C1DRB3
));
1452 } else if (IS_GEN6(dev
) || IS_GEN7(dev
)) {
1453 seq_printf(m
, "MAD_DIMM_C0 = 0x%08x\n",
1454 I915_READ(MAD_DIMM_C0
));
1455 seq_printf(m
, "MAD_DIMM_C1 = 0x%08x\n",
1456 I915_READ(MAD_DIMM_C1
));
1457 seq_printf(m
, "MAD_DIMM_C2 = 0x%08x\n",
1458 I915_READ(MAD_DIMM_C2
));
1459 seq_printf(m
, "TILECTL = 0x%08x\n",
1460 I915_READ(TILECTL
));
1461 seq_printf(m
, "ARB_MODE = 0x%08x\n",
1462 I915_READ(ARB_MODE
));
1463 seq_printf(m
, "DISP_ARB_CTL = 0x%08x\n",
1464 I915_READ(DISP_ARB_CTL
));
1466 mutex_unlock(&dev
->struct_mutex
);
1471 static int i915_ppgtt_info(struct seq_file
*m
, void *data
)
1473 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1474 struct drm_device
*dev
= node
->minor
->dev
;
1475 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1476 struct intel_ring_buffer
*ring
;
1480 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1483 if (INTEL_INFO(dev
)->gen
== 6)
1484 seq_printf(m
, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE
));
1486 for_each_ring(ring
, dev_priv
, i
) {
1487 seq_printf(m
, "%s\n", ring
->name
);
1488 if (INTEL_INFO(dev
)->gen
== 7)
1489 seq_printf(m
, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring
)));
1490 seq_printf(m
, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring
)));
1491 seq_printf(m
, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring
)));
1492 seq_printf(m
, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring
)));
1494 if (dev_priv
->mm
.aliasing_ppgtt
) {
1495 struct i915_hw_ppgtt
*ppgtt
= dev_priv
->mm
.aliasing_ppgtt
;
1497 seq_puts(m
, "aliasing PPGTT:\n");
1498 seq_printf(m
, "pd gtt offset: 0x%08x\n", ppgtt
->pd_offset
);
1500 seq_printf(m
, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK
));
1501 mutex_unlock(&dev
->struct_mutex
);
1506 static int i915_dpio_info(struct seq_file
*m
, void *data
)
1508 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1509 struct drm_device
*dev
= node
->minor
->dev
;
1510 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1514 if (!IS_VALLEYVIEW(dev
)) {
1515 seq_puts(m
, "unsupported\n");
1519 ret
= mutex_lock_interruptible(&dev_priv
->dpio_lock
);
1523 seq_printf(m
, "DPIO_CTL: 0x%08x\n", I915_READ(DPIO_CTL
));
1525 seq_printf(m
, "DPIO_DIV_A: 0x%08x\n",
1526 vlv_dpio_read(dev_priv
, _DPIO_DIV_A
));
1527 seq_printf(m
, "DPIO_DIV_B: 0x%08x\n",
1528 vlv_dpio_read(dev_priv
, _DPIO_DIV_B
));
1530 seq_printf(m
, "DPIO_REFSFR_A: 0x%08x\n",
1531 vlv_dpio_read(dev_priv
, _DPIO_REFSFR_A
));
1532 seq_printf(m
, "DPIO_REFSFR_B: 0x%08x\n",
1533 vlv_dpio_read(dev_priv
, _DPIO_REFSFR_B
));
1535 seq_printf(m
, "DPIO_CORE_CLK_A: 0x%08x\n",
1536 vlv_dpio_read(dev_priv
, _DPIO_CORE_CLK_A
));
1537 seq_printf(m
, "DPIO_CORE_CLK_B: 0x%08x\n",
1538 vlv_dpio_read(dev_priv
, _DPIO_CORE_CLK_B
));
1540 seq_printf(m
, "DPIO_LPF_COEFF_A: 0x%08x\n",
1541 vlv_dpio_read(dev_priv
, _DPIO_LPF_COEFF_A
));
1542 seq_printf(m
, "DPIO_LPF_COEFF_B: 0x%08x\n",
1543 vlv_dpio_read(dev_priv
, _DPIO_LPF_COEFF_B
));
1545 seq_printf(m
, "DPIO_FASTCLK_DISABLE: 0x%08x\n",
1546 vlv_dpio_read(dev_priv
, DPIO_FASTCLK_DISABLE
));
1548 mutex_unlock(&dev_priv
->dpio_lock
);
1553 static int i915_llc(struct seq_file
*m
, void *data
)
1555 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1556 struct drm_device
*dev
= node
->minor
->dev
;
1557 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1559 /* Size calculation for LLC is a bit of a pain. Ignore for now. */
1560 seq_printf(m
, "LLC: %s\n", yesno(HAS_LLC(dev
)));
1561 seq_printf(m
, "eLLC: %zuMB\n", dev_priv
->ellc_size
);
1566 static int i915_edp_psr_status(struct seq_file
*m
, void *data
)
1568 struct drm_info_node
*node
= m
->private;
1569 struct drm_device
*dev
= node
->minor
->dev
;
1570 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1571 u32 psrstat
, psrperf
;
1573 if (!IS_HASWELL(dev
)) {
1574 seq_puts(m
, "PSR not supported on this platform\n");
1575 } else if (IS_HASWELL(dev
) && I915_READ(EDP_PSR_CTL
) & EDP_PSR_ENABLE
) {
1576 seq_puts(m
, "PSR enabled\n");
1578 seq_puts(m
, "PSR disabled: ");
1579 switch (dev_priv
->no_psr_reason
) {
1581 seq_puts(m
, "not supported on this platform");
1584 seq_puts(m
, "not supported by panel");
1586 case PSR_MODULE_PARAM
:
1587 seq_puts(m
, "disabled by flag");
1589 case PSR_CRTC_NOT_ACTIVE
:
1590 seq_puts(m
, "crtc not active");
1592 case PSR_PWR_WELL_ENABLED
:
1593 seq_puts(m
, "power well enabled");
1596 seq_puts(m
, "not tiled");
1598 case PSR_SPRITE_ENABLED
:
1599 seq_puts(m
, "sprite enabled");
1601 case PSR_S3D_ENABLED
:
1602 seq_puts(m
, "stereo 3d enabled");
1604 case PSR_INTERLACED_ENABLED
:
1605 seq_puts(m
, "interlaced enabled");
1607 case PSR_HSW_NOT_DDIA
:
1608 seq_puts(m
, "HSW ties PSR to DDI A (eDP)");
1611 seq_puts(m
, "unknown reason");
1617 psrstat
= I915_READ(EDP_PSR_STATUS_CTL
);
1619 seq_puts(m
, "PSR Current State: ");
1620 switch (psrstat
& EDP_PSR_STATUS_STATE_MASK
) {
1621 case EDP_PSR_STATUS_STATE_IDLE
:
1622 seq_puts(m
, "Reset state\n");
1624 case EDP_PSR_STATUS_STATE_SRDONACK
:
1625 seq_puts(m
, "Wait for TG/Stream to send on frame of data after SRD conditions are met\n");
1627 case EDP_PSR_STATUS_STATE_SRDENT
:
1628 seq_puts(m
, "SRD entry\n");
1630 case EDP_PSR_STATUS_STATE_BUFOFF
:
1631 seq_puts(m
, "Wait for buffer turn off\n");
1633 case EDP_PSR_STATUS_STATE_BUFON
:
1634 seq_puts(m
, "Wait for buffer turn on\n");
1636 case EDP_PSR_STATUS_STATE_AUXACK
:
1637 seq_puts(m
, "Wait for AUX to acknowledge on SRD exit\n");
1639 case EDP_PSR_STATUS_STATE_SRDOFFACK
:
1640 seq_puts(m
, "Wait for TG/Stream to acknowledge the SRD VDM exit\n");
1643 seq_puts(m
, "Unknown\n");
1647 seq_puts(m
, "Link Status: ");
1648 switch (psrstat
& EDP_PSR_STATUS_LINK_MASK
) {
1649 case EDP_PSR_STATUS_LINK_FULL_OFF
:
1650 seq_puts(m
, "Link is fully off\n");
1652 case EDP_PSR_STATUS_LINK_FULL_ON
:
1653 seq_puts(m
, "Link is fully on\n");
1655 case EDP_PSR_STATUS_LINK_STANDBY
:
1656 seq_puts(m
, "Link is in standby\n");
1659 seq_puts(m
, "Unknown\n");
1663 seq_printf(m
, "PSR Entry Count: %u\n",
1664 psrstat
>> EDP_PSR_STATUS_COUNT_SHIFT
&
1665 EDP_PSR_STATUS_COUNT_MASK
);
1667 seq_printf(m
, "Max Sleep Timer Counter: %u\n",
1668 psrstat
>> EDP_PSR_STATUS_MAX_SLEEP_TIMER_SHIFT
&
1669 EDP_PSR_STATUS_MAX_SLEEP_TIMER_MASK
);
1671 seq_printf(m
, "Had AUX error: %s\n",
1672 yesno(psrstat
& EDP_PSR_STATUS_AUX_ERROR
));
1674 seq_printf(m
, "Sending AUX: %s\n",
1675 yesno(psrstat
& EDP_PSR_STATUS_AUX_SENDING
));
1677 seq_printf(m
, "Sending Idle: %s\n",
1678 yesno(psrstat
& EDP_PSR_STATUS_SENDING_IDLE
));
1680 seq_printf(m
, "Sending TP2 TP3: %s\n",
1681 yesno(psrstat
& EDP_PSR_STATUS_SENDING_TP2_TP3
));
1683 seq_printf(m
, "Sending TP1: %s\n",
1684 yesno(psrstat
& EDP_PSR_STATUS_SENDING_TP1
));
1686 seq_printf(m
, "Idle Count: %u\n",
1687 psrstat
& EDP_PSR_STATUS_IDLE_MASK
);
1689 psrperf
= (I915_READ(EDP_PSR_PERF_CNT
)) & EDP_PSR_PERF_CNT_MASK
;
1690 seq_printf(m
, "Performance Counter: %u\n", psrperf
);
1696 i915_wedged_get(void *data
, u64
*val
)
1698 struct drm_device
*dev
= data
;
1699 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1701 *val
= atomic_read(&dev_priv
->gpu_error
.reset_counter
);
1707 i915_wedged_set(void *data
, u64 val
)
1709 struct drm_device
*dev
= data
;
1711 DRM_INFO("Manually setting wedged to %llu\n", val
);
1712 i915_handle_error(dev
, val
);
1717 DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops
,
1718 i915_wedged_get
, i915_wedged_set
,
1722 i915_ring_stop_get(void *data
, u64
*val
)
1724 struct drm_device
*dev
= data
;
1725 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1727 *val
= dev_priv
->gpu_error
.stop_rings
;
1733 i915_ring_stop_set(void *data
, u64 val
)
1735 struct drm_device
*dev
= data
;
1736 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1739 DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val
);
1741 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1745 dev_priv
->gpu_error
.stop_rings
= val
;
1746 mutex_unlock(&dev
->struct_mutex
);
1751 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops
,
1752 i915_ring_stop_get
, i915_ring_stop_set
,
1755 #define DROP_UNBOUND 0x1
1756 #define DROP_BOUND 0x2
1757 #define DROP_RETIRE 0x4
1758 #define DROP_ACTIVE 0x8
1759 #define DROP_ALL (DROP_UNBOUND | \
1764 i915_drop_caches_get(void *data
, u64
*val
)
1772 i915_drop_caches_set(void *data
, u64 val
)
1774 struct drm_device
*dev
= data
;
1775 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1776 struct drm_i915_gem_object
*obj
, *next
;
1777 struct i915_address_space
*vm
= &dev_priv
->gtt
.base
;
1780 DRM_DEBUG_DRIVER("Dropping caches: 0x%08llx\n", val
);
1782 /* No need to check and wait for gpu resets, only libdrm auto-restarts
1783 * on ioctls on -EAGAIN. */
1784 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1788 if (val
& DROP_ACTIVE
) {
1789 ret
= i915_gpu_idle(dev
);
1794 if (val
& (DROP_RETIRE
| DROP_ACTIVE
))
1795 i915_gem_retire_requests(dev
);
1797 if (val
& DROP_BOUND
) {
1798 list_for_each_entry_safe(obj
, next
, &vm
->inactive_list
,
1803 ret
= i915_gem_object_unbind(obj
);
1809 if (val
& DROP_UNBOUND
) {
1810 list_for_each_entry_safe(obj
, next
, &dev_priv
->mm
.unbound_list
,
1812 if (obj
->pages_pin_count
== 0) {
1813 ret
= i915_gem_object_put_pages(obj
);
1820 mutex_unlock(&dev
->struct_mutex
);
1825 DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops
,
1826 i915_drop_caches_get
, i915_drop_caches_set
,
1830 i915_max_freq_get(void *data
, u64
*val
)
1832 struct drm_device
*dev
= data
;
1833 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1836 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
1839 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
1843 if (IS_VALLEYVIEW(dev
))
1844 *val
= vlv_gpu_freq(dev_priv
->mem_freq
,
1845 dev_priv
->rps
.max_delay
);
1847 *val
= dev_priv
->rps
.max_delay
* GT_FREQUENCY_MULTIPLIER
;
1848 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1854 i915_max_freq_set(void *data
, u64 val
)
1856 struct drm_device
*dev
= data
;
1857 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1860 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
1863 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val
);
1865 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
1870 * Turbo will still be enabled, but won't go above the set value.
1872 if (IS_VALLEYVIEW(dev
)) {
1873 val
= vlv_freq_opcode(dev_priv
->mem_freq
, val
);
1874 dev_priv
->rps
.max_delay
= val
;
1875 gen6_set_rps(dev
, val
);
1877 do_div(val
, GT_FREQUENCY_MULTIPLIER
);
1878 dev_priv
->rps
.max_delay
= val
;
1879 gen6_set_rps(dev
, val
);
1882 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1887 DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops
,
1888 i915_max_freq_get
, i915_max_freq_set
,
1892 i915_min_freq_get(void *data
, u64
*val
)
1894 struct drm_device
*dev
= data
;
1895 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1898 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
1901 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
1905 if (IS_VALLEYVIEW(dev
))
1906 *val
= vlv_gpu_freq(dev_priv
->mem_freq
,
1907 dev_priv
->rps
.min_delay
);
1909 *val
= dev_priv
->rps
.min_delay
* GT_FREQUENCY_MULTIPLIER
;
1910 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1916 i915_min_freq_set(void *data
, u64 val
)
1918 struct drm_device
*dev
= data
;
1919 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1922 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
1925 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val
);
1927 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
1932 * Turbo will still be enabled, but won't go below the set value.
1934 if (IS_VALLEYVIEW(dev
)) {
1935 val
= vlv_freq_opcode(dev_priv
->mem_freq
, val
);
1936 dev_priv
->rps
.min_delay
= val
;
1937 valleyview_set_rps(dev
, val
);
1939 do_div(val
, GT_FREQUENCY_MULTIPLIER
);
1940 dev_priv
->rps
.min_delay
= val
;
1941 gen6_set_rps(dev
, val
);
1943 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1948 DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops
,
1949 i915_min_freq_get
, i915_min_freq_set
,
1953 i915_cache_sharing_get(void *data
, u64
*val
)
1955 struct drm_device
*dev
= data
;
1956 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1960 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
1963 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1967 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
1968 mutex_unlock(&dev_priv
->dev
->struct_mutex
);
1970 *val
= (snpcr
& GEN6_MBC_SNPCR_MASK
) >> GEN6_MBC_SNPCR_SHIFT
;
1976 i915_cache_sharing_set(void *data
, u64 val
)
1978 struct drm_device
*dev
= data
;
1979 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1982 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
1988 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val
);
1990 /* Update the cache sharing policy here as well */
1991 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
1992 snpcr
&= ~GEN6_MBC_SNPCR_MASK
;
1993 snpcr
|= (val
<< GEN6_MBC_SNPCR_SHIFT
);
1994 I915_WRITE(GEN6_MBCUNIT_SNPCR
, snpcr
);
1999 DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops
,
2000 i915_cache_sharing_get
, i915_cache_sharing_set
,
2003 /* As the drm_debugfs_init() routines are called before dev->dev_private is
2004 * allocated we need to hook into the minor for release. */
2006 drm_add_fake_info_node(struct drm_minor
*minor
,
2010 struct drm_info_node
*node
;
2012 node
= kmalloc(sizeof(struct drm_info_node
), GFP_KERNEL
);
2014 debugfs_remove(ent
);
2018 node
->minor
= minor
;
2020 node
->info_ent
= (void *) key
;
2022 mutex_lock(&minor
->debugfs_lock
);
2023 list_add(&node
->list
, &minor
->debugfs_list
);
2024 mutex_unlock(&minor
->debugfs_lock
);
2029 static int i915_forcewake_open(struct inode
*inode
, struct file
*file
)
2031 struct drm_device
*dev
= inode
->i_private
;
2032 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2034 if (INTEL_INFO(dev
)->gen
< 6)
2037 gen6_gt_force_wake_get(dev_priv
);
2042 static int i915_forcewake_release(struct inode
*inode
, struct file
*file
)
2044 struct drm_device
*dev
= inode
->i_private
;
2045 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2047 if (INTEL_INFO(dev
)->gen
< 6)
2050 gen6_gt_force_wake_put(dev_priv
);
2055 static const struct file_operations i915_forcewake_fops
= {
2056 .owner
= THIS_MODULE
,
2057 .open
= i915_forcewake_open
,
2058 .release
= i915_forcewake_release
,
2061 static int i915_forcewake_create(struct dentry
*root
, struct drm_minor
*minor
)
2063 struct drm_device
*dev
= minor
->dev
;
2066 ent
= debugfs_create_file("i915_forcewake_user",
2069 &i915_forcewake_fops
);
2071 return PTR_ERR(ent
);
2073 return drm_add_fake_info_node(minor
, ent
, &i915_forcewake_fops
);
2076 static int i915_debugfs_create(struct dentry
*root
,
2077 struct drm_minor
*minor
,
2079 const struct file_operations
*fops
)
2081 struct drm_device
*dev
= minor
->dev
;
2084 ent
= debugfs_create_file(name
,
2089 return PTR_ERR(ent
);
2091 return drm_add_fake_info_node(minor
, ent
, fops
);
2094 static struct drm_info_list i915_debugfs_list
[] = {
2095 {"i915_capabilities", i915_capabilities
, 0},
2096 {"i915_gem_objects", i915_gem_object_info
, 0},
2097 {"i915_gem_gtt", i915_gem_gtt_info
, 0},
2098 {"i915_gem_pinned", i915_gem_gtt_info
, 0, (void *) PINNED_LIST
},
2099 {"i915_gem_active", i915_gem_object_list_info
, 0, (void *) ACTIVE_LIST
},
2100 {"i915_gem_inactive", i915_gem_object_list_info
, 0, (void *) INACTIVE_LIST
},
2101 {"i915_gem_pageflip", i915_gem_pageflip_info
, 0},
2102 {"i915_gem_request", i915_gem_request_info
, 0},
2103 {"i915_gem_seqno", i915_gem_seqno_info
, 0},
2104 {"i915_gem_fence_regs", i915_gem_fence_regs_info
, 0},
2105 {"i915_gem_interrupt", i915_interrupt_info
, 0},
2106 {"i915_gem_hws", i915_hws_info
, 0, (void *)RCS
},
2107 {"i915_gem_hws_blt", i915_hws_info
, 0, (void *)BCS
},
2108 {"i915_gem_hws_bsd", i915_hws_info
, 0, (void *)VCS
},
2109 {"i915_gem_hws_vebox", i915_hws_info
, 0, (void *)VECS
},
2110 {"i915_rstdby_delays", i915_rstdby_delays
, 0},
2111 {"i915_cur_delayinfo", i915_cur_delayinfo
, 0},
2112 {"i915_delayfreq_table", i915_delayfreq_table
, 0},
2113 {"i915_inttoext_table", i915_inttoext_table
, 0},
2114 {"i915_drpc_info", i915_drpc_info
, 0},
2115 {"i915_emon_status", i915_emon_status
, 0},
2116 {"i915_ring_freq_table", i915_ring_freq_table
, 0},
2117 {"i915_gfxec", i915_gfxec
, 0},
2118 {"i915_fbc_status", i915_fbc_status
, 0},
2119 {"i915_ips_status", i915_ips_status
, 0},
2120 {"i915_sr_status", i915_sr_status
, 0},
2121 {"i915_opregion", i915_opregion
, 0},
2122 {"i915_gem_framebuffer", i915_gem_framebuffer_info
, 0},
2123 {"i915_context_status", i915_context_status
, 0},
2124 {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info
, 0},
2125 {"i915_swizzle_info", i915_swizzle_info
, 0},
2126 {"i915_ppgtt_info", i915_ppgtt_info
, 0},
2127 {"i915_dpio", i915_dpio_info
, 0},
2128 {"i915_llc", i915_llc
, 0},
2129 {"i915_edp_psr_status", i915_edp_psr_status
, 0},
2131 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
2133 struct i915_debugfs_files
{
2135 const struct file_operations
*fops
;
2136 } i915_debugfs_files
[] = {
2137 {"i915_wedged", &i915_wedged_fops
},
2138 {"i915_max_freq", &i915_max_freq_fops
},
2139 {"i915_min_freq", &i915_min_freq_fops
},
2140 {"i915_cache_sharing", &i915_cache_sharing_fops
},
2141 {"i915_ring_stop", &i915_ring_stop_fops
},
2142 {"i915_gem_drop_caches", &i915_drop_caches_fops
},
2143 {"i915_error_state", &i915_error_state_fops
},
2144 {"i915_next_seqno", &i915_next_seqno_fops
},
2147 int i915_debugfs_init(struct drm_minor
*minor
)
2151 ret
= i915_forcewake_create(minor
->debugfs_root
, minor
);
2155 for (i
= 0; i
< ARRAY_SIZE(i915_debugfs_files
); i
++) {
2156 ret
= i915_debugfs_create(minor
->debugfs_root
, minor
,
2157 i915_debugfs_files
[i
].name
,
2158 i915_debugfs_files
[i
].fops
);
2163 return drm_debugfs_create_files(i915_debugfs_list
,
2164 I915_DEBUGFS_ENTRIES
,
2165 minor
->debugfs_root
, minor
);
2168 void i915_debugfs_cleanup(struct drm_minor
*minor
)
2172 drm_debugfs_remove_files(i915_debugfs_list
,
2173 I915_DEBUGFS_ENTRIES
, minor
);
2174 drm_debugfs_remove_files((struct drm_info_list
*) &i915_forcewake_fops
,
2176 for (i
= 0; i
< ARRAY_SIZE(i915_debugfs_files
); i
++) {
2177 struct drm_info_list
*info_list
=
2178 (struct drm_info_list
*) i915_debugfs_files
[i
].fops
;
2180 drm_debugfs_remove_files(info_list
, 1, minor
);
2184 #endif /* CONFIG_DEBUG_FS */