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>
33 #include <linux/list_sort.h>
34 #include <asm/msr-index.h>
36 #include "intel_drv.h"
37 #include "intel_ringbuffer.h"
38 #include <drm/i915_drm.h>
41 #define DRM_I915_RING_DEBUG 1
44 #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 seq_printf(m
, "pch: %d\n", INTEL_PCH_TYPE(dev
));
65 #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
66 #define SEP_SEMICOLON ;
67 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG
, SEP_SEMICOLON
);
74 static const char *get_pin_flag(struct drm_i915_gem_object
*obj
)
76 if (obj
->user_pin_count
> 0)
78 else if (obj
->pin_count
> 0)
84 static const char *get_tiling_flag(struct drm_i915_gem_object
*obj
)
86 switch (obj
->tiling_mode
) {
88 case I915_TILING_NONE
: return " ";
89 case I915_TILING_X
: return "X";
90 case I915_TILING_Y
: return "Y";
94 static inline const char *get_global_flag(struct drm_i915_gem_object
*obj
)
96 return obj
->has_global_gtt_mapping
? "g" : " ";
100 describe_obj(struct seq_file
*m
, struct drm_i915_gem_object
*obj
)
102 struct i915_vma
*vma
;
103 seq_printf(m
, "%pK: %s%s%s %8zdKiB %02x %02x %u %u %u%s%s%s",
106 get_tiling_flag(obj
),
107 get_global_flag(obj
),
108 obj
->base
.size
/ 1024,
109 obj
->base
.read_domains
,
110 obj
->base
.write_domain
,
111 obj
->last_read_seqno
,
112 obj
->last_write_seqno
,
113 obj
->last_fenced_seqno
,
114 i915_cache_level_str(obj
->cache_level
),
115 obj
->dirty
? " dirty" : "",
116 obj
->madv
== I915_MADV_DONTNEED
? " purgeable" : "");
118 seq_printf(m
, " (name: %d)", obj
->base
.name
);
120 seq_printf(m
, " (pinned x %d)", obj
->pin_count
);
121 if (obj
->pin_display
)
122 seq_printf(m
, " (display)");
123 if (obj
->fence_reg
!= I915_FENCE_REG_NONE
)
124 seq_printf(m
, " (fence: %d)", obj
->fence_reg
);
125 list_for_each_entry(vma
, &obj
->vma_list
, vma_link
) {
126 if (!i915_is_ggtt(vma
->vm
))
130 seq_printf(m
, "gtt offset: %08lx, size: %08lx)",
131 vma
->node
.start
, vma
->node
.size
);
134 seq_printf(m
, " (stolen: %08lx)", obj
->stolen
->start
);
135 if (obj
->pin_mappable
|| obj
->fault_mappable
) {
137 if (obj
->pin_mappable
)
139 if (obj
->fault_mappable
)
142 seq_printf(m
, " (%s mappable)", s
);
144 if (obj
->ring
!= NULL
)
145 seq_printf(m
, " (%s)", obj
->ring
->name
);
148 static int i915_gem_object_list_info(struct seq_file
*m
, void *data
)
150 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
151 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
152 struct list_head
*head
;
153 struct drm_device
*dev
= node
->minor
->dev
;
154 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
155 struct i915_address_space
*vm
= &dev_priv
->gtt
.base
;
156 struct i915_vma
*vma
;
157 size_t total_obj_size
, total_gtt_size
;
160 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
164 /* FIXME: the user of this interface might want more than just GGTT */
167 seq_puts(m
, "Active:\n");
168 head
= &vm
->active_list
;
171 seq_puts(m
, "Inactive:\n");
172 head
= &vm
->inactive_list
;
175 mutex_unlock(&dev
->struct_mutex
);
179 total_obj_size
= total_gtt_size
= count
= 0;
180 list_for_each_entry(vma
, head
, mm_list
) {
182 describe_obj(m
, vma
->obj
);
184 total_obj_size
+= vma
->obj
->base
.size
;
185 total_gtt_size
+= vma
->node
.size
;
188 mutex_unlock(&dev
->struct_mutex
);
190 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
191 count
, total_obj_size
, total_gtt_size
);
195 static int obj_rank_by_stolen(void *priv
,
196 struct list_head
*A
, struct list_head
*B
)
198 struct drm_i915_gem_object
*a
=
199 container_of(A
, struct drm_i915_gem_object
, obj_exec_link
);
200 struct drm_i915_gem_object
*b
=
201 container_of(B
, struct drm_i915_gem_object
, obj_exec_link
);
203 return a
->stolen
->start
- b
->stolen
->start
;
206 static int i915_gem_stolen_list_info(struct seq_file
*m
, void *data
)
208 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
209 struct drm_device
*dev
= node
->minor
->dev
;
210 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
211 struct drm_i915_gem_object
*obj
;
212 size_t total_obj_size
, total_gtt_size
;
216 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
220 total_obj_size
= total_gtt_size
= count
= 0;
221 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
222 if (obj
->stolen
== NULL
)
225 list_add(&obj
->obj_exec_link
, &stolen
);
227 total_obj_size
+= obj
->base
.size
;
228 total_gtt_size
+= i915_gem_obj_ggtt_size(obj
);
231 list_for_each_entry(obj
, &dev_priv
->mm
.unbound_list
, global_list
) {
232 if (obj
->stolen
== NULL
)
235 list_add(&obj
->obj_exec_link
, &stolen
);
237 total_obj_size
+= obj
->base
.size
;
240 list_sort(NULL
, &stolen
, obj_rank_by_stolen
);
241 seq_puts(m
, "Stolen:\n");
242 while (!list_empty(&stolen
)) {
243 obj
= list_first_entry(&stolen
, typeof(*obj
), obj_exec_link
);
245 describe_obj(m
, obj
);
247 list_del_init(&obj
->obj_exec_link
);
249 mutex_unlock(&dev
->struct_mutex
);
251 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
252 count
, total_obj_size
, total_gtt_size
);
256 #define count_objects(list, member) do { \
257 list_for_each_entry(obj, list, member) { \
258 size += i915_gem_obj_ggtt_size(obj); \
260 if (obj->map_and_fenceable) { \
261 mappable_size += i915_gem_obj_ggtt_size(obj); \
269 size_t total
, active
, inactive
, unbound
;
272 static int per_file_stats(int id
, void *ptr
, void *data
)
274 struct drm_i915_gem_object
*obj
= ptr
;
275 struct file_stats
*stats
= data
;
278 stats
->total
+= obj
->base
.size
;
280 if (i915_gem_obj_ggtt_bound(obj
)) {
281 if (!list_empty(&obj
->ring_list
))
282 stats
->active
+= obj
->base
.size
;
284 stats
->inactive
+= obj
->base
.size
;
286 if (!list_empty(&obj
->global_list
))
287 stats
->unbound
+= obj
->base
.size
;
293 #define count_vmas(list, member) do { \
294 list_for_each_entry(vma, list, member) { \
295 size += i915_gem_obj_ggtt_size(vma->obj); \
297 if (vma->obj->map_and_fenceable) { \
298 mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
304 static int i915_gem_object_info(struct seq_file
*m
, void* data
)
306 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
307 struct drm_device
*dev
= node
->minor
->dev
;
308 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
309 u32 count
, mappable_count
, purgeable_count
;
310 size_t size
, mappable_size
, purgeable_size
;
311 struct drm_i915_gem_object
*obj
;
312 struct i915_address_space
*vm
= &dev_priv
->gtt
.base
;
313 struct drm_file
*file
;
314 struct i915_vma
*vma
;
317 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
321 seq_printf(m
, "%u objects, %zu bytes\n",
322 dev_priv
->mm
.object_count
,
323 dev_priv
->mm
.object_memory
);
325 size
= count
= mappable_size
= mappable_count
= 0;
326 count_objects(&dev_priv
->mm
.bound_list
, global_list
);
327 seq_printf(m
, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
328 count
, mappable_count
, size
, mappable_size
);
330 size
= count
= mappable_size
= mappable_count
= 0;
331 count_vmas(&vm
->active_list
, mm_list
);
332 seq_printf(m
, " %u [%u] active objects, %zu [%zu] bytes\n",
333 count
, mappable_count
, size
, mappable_size
);
335 size
= count
= mappable_size
= mappable_count
= 0;
336 count_vmas(&vm
->inactive_list
, mm_list
);
337 seq_printf(m
, " %u [%u] inactive objects, %zu [%zu] bytes\n",
338 count
, mappable_count
, size
, mappable_size
);
340 size
= count
= purgeable_size
= purgeable_count
= 0;
341 list_for_each_entry(obj
, &dev_priv
->mm
.unbound_list
, global_list
) {
342 size
+= obj
->base
.size
, ++count
;
343 if (obj
->madv
== I915_MADV_DONTNEED
)
344 purgeable_size
+= obj
->base
.size
, ++purgeable_count
;
346 seq_printf(m
, "%u unbound objects, %zu bytes\n", count
, size
);
348 size
= count
= mappable_size
= mappable_count
= 0;
349 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
350 if (obj
->fault_mappable
) {
351 size
+= i915_gem_obj_ggtt_size(obj
);
354 if (obj
->pin_mappable
) {
355 mappable_size
+= i915_gem_obj_ggtt_size(obj
);
358 if (obj
->madv
== I915_MADV_DONTNEED
) {
359 purgeable_size
+= obj
->base
.size
;
363 seq_printf(m
, "%u purgeable objects, %zu bytes\n",
364 purgeable_count
, purgeable_size
);
365 seq_printf(m
, "%u pinned mappable objects, %zu bytes\n",
366 mappable_count
, mappable_size
);
367 seq_printf(m
, "%u fault mappable objects, %zu bytes\n",
370 seq_printf(m
, "%zu [%lu] gtt total\n",
371 dev_priv
->gtt
.base
.total
,
372 dev_priv
->gtt
.mappable_end
- dev_priv
->gtt
.base
.start
);
375 list_for_each_entry_reverse(file
, &dev
->filelist
, lhead
) {
376 struct file_stats stats
;
378 memset(&stats
, 0, sizeof(stats
));
379 idr_for_each(&file
->object_idr
, per_file_stats
, &stats
);
380 seq_printf(m
, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu unbound)\n",
381 get_pid_task(file
->pid
, PIDTYPE_PID
)->comm
,
389 mutex_unlock(&dev
->struct_mutex
);
394 static int i915_gem_gtt_info(struct seq_file
*m
, void *data
)
396 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
397 struct drm_device
*dev
= node
->minor
->dev
;
398 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
399 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
400 struct drm_i915_gem_object
*obj
;
401 size_t total_obj_size
, total_gtt_size
;
404 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
408 total_obj_size
= total_gtt_size
= count
= 0;
409 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
410 if (list
== PINNED_LIST
&& obj
->pin_count
== 0)
414 describe_obj(m
, obj
);
416 total_obj_size
+= obj
->base
.size
;
417 total_gtt_size
+= i915_gem_obj_ggtt_size(obj
);
421 mutex_unlock(&dev
->struct_mutex
);
423 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
424 count
, total_obj_size
, total_gtt_size
);
429 static int i915_gem_pageflip_info(struct seq_file
*m
, void *data
)
431 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
432 struct drm_device
*dev
= node
->minor
->dev
;
434 struct intel_crtc
*crtc
;
436 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, base
.head
) {
437 const char pipe
= pipe_name(crtc
->pipe
);
438 const char plane
= plane_name(crtc
->plane
);
439 struct intel_unpin_work
*work
;
441 spin_lock_irqsave(&dev
->event_lock
, flags
);
442 work
= crtc
->unpin_work
;
444 seq_printf(m
, "No flip due on pipe %c (plane %c)\n",
447 if (atomic_read(&work
->pending
) < INTEL_FLIP_COMPLETE
) {
448 seq_printf(m
, "Flip queued on pipe %c (plane %c)\n",
451 seq_printf(m
, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
454 if (work
->enable_stall_check
)
455 seq_puts(m
, "Stall check enabled, ");
457 seq_puts(m
, "Stall check waiting for page flip ioctl, ");
458 seq_printf(m
, "%d prepares\n", atomic_read(&work
->pending
));
460 if (work
->old_fb_obj
) {
461 struct drm_i915_gem_object
*obj
= work
->old_fb_obj
;
463 seq_printf(m
, "Old framebuffer gtt_offset 0x%08lx\n",
464 i915_gem_obj_ggtt_offset(obj
));
466 if (work
->pending_flip_obj
) {
467 struct drm_i915_gem_object
*obj
= work
->pending_flip_obj
;
469 seq_printf(m
, "New framebuffer gtt_offset 0x%08lx\n",
470 i915_gem_obj_ggtt_offset(obj
));
473 spin_unlock_irqrestore(&dev
->event_lock
, flags
);
479 static int i915_gem_request_info(struct seq_file
*m
, void *data
)
481 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
482 struct drm_device
*dev
= node
->minor
->dev
;
483 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
484 struct intel_ring_buffer
*ring
;
485 struct drm_i915_gem_request
*gem_request
;
488 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
493 for_each_ring(ring
, dev_priv
, i
) {
494 if (list_empty(&ring
->request_list
))
497 seq_printf(m
, "%s requests:\n", ring
->name
);
498 list_for_each_entry(gem_request
,
501 seq_printf(m
, " %d @ %d\n",
503 (int) (jiffies
- gem_request
->emitted_jiffies
));
507 mutex_unlock(&dev
->struct_mutex
);
510 seq_puts(m
, "No requests\n");
515 static void i915_ring_seqno_info(struct seq_file
*m
,
516 struct intel_ring_buffer
*ring
)
518 if (ring
->get_seqno
) {
519 seq_printf(m
, "Current sequence (%s): %u\n",
520 ring
->name
, ring
->get_seqno(ring
, false));
524 static int i915_gem_seqno_info(struct seq_file
*m
, void *data
)
526 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
527 struct drm_device
*dev
= node
->minor
->dev
;
528 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
529 struct intel_ring_buffer
*ring
;
532 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
536 for_each_ring(ring
, dev_priv
, i
)
537 i915_ring_seqno_info(m
, ring
);
539 mutex_unlock(&dev
->struct_mutex
);
545 static int i915_interrupt_info(struct seq_file
*m
, void *data
)
547 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
548 struct drm_device
*dev
= node
->minor
->dev
;
549 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
550 struct intel_ring_buffer
*ring
;
553 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
557 if (IS_VALLEYVIEW(dev
)) {
558 seq_printf(m
, "Display IER:\t%08x\n",
560 seq_printf(m
, "Display IIR:\t%08x\n",
562 seq_printf(m
, "Display IIR_RW:\t%08x\n",
563 I915_READ(VLV_IIR_RW
));
564 seq_printf(m
, "Display IMR:\t%08x\n",
567 seq_printf(m
, "Pipe %c stat:\t%08x\n",
569 I915_READ(PIPESTAT(pipe
)));
571 seq_printf(m
, "Master IER:\t%08x\n",
572 I915_READ(VLV_MASTER_IER
));
574 seq_printf(m
, "Render IER:\t%08x\n",
576 seq_printf(m
, "Render IIR:\t%08x\n",
578 seq_printf(m
, "Render IMR:\t%08x\n",
581 seq_printf(m
, "PM IER:\t\t%08x\n",
582 I915_READ(GEN6_PMIER
));
583 seq_printf(m
, "PM IIR:\t\t%08x\n",
584 I915_READ(GEN6_PMIIR
));
585 seq_printf(m
, "PM IMR:\t\t%08x\n",
586 I915_READ(GEN6_PMIMR
));
588 seq_printf(m
, "Port hotplug:\t%08x\n",
589 I915_READ(PORT_HOTPLUG_EN
));
590 seq_printf(m
, "DPFLIPSTAT:\t%08x\n",
591 I915_READ(VLV_DPFLIPSTAT
));
592 seq_printf(m
, "DPINVGTT:\t%08x\n",
593 I915_READ(DPINVGTT
));
595 } else if (!HAS_PCH_SPLIT(dev
)) {
596 seq_printf(m
, "Interrupt enable: %08x\n",
598 seq_printf(m
, "Interrupt identity: %08x\n",
600 seq_printf(m
, "Interrupt mask: %08x\n",
603 seq_printf(m
, "Pipe %c stat: %08x\n",
605 I915_READ(PIPESTAT(pipe
)));
607 seq_printf(m
, "North Display Interrupt enable: %08x\n",
609 seq_printf(m
, "North Display Interrupt identity: %08x\n",
611 seq_printf(m
, "North Display Interrupt mask: %08x\n",
613 seq_printf(m
, "South Display Interrupt enable: %08x\n",
615 seq_printf(m
, "South Display Interrupt identity: %08x\n",
617 seq_printf(m
, "South Display Interrupt mask: %08x\n",
619 seq_printf(m
, "Graphics Interrupt enable: %08x\n",
621 seq_printf(m
, "Graphics Interrupt identity: %08x\n",
623 seq_printf(m
, "Graphics Interrupt mask: %08x\n",
626 seq_printf(m
, "Interrupts received: %d\n",
627 atomic_read(&dev_priv
->irq_received
));
628 for_each_ring(ring
, dev_priv
, i
) {
629 if (IS_GEN6(dev
) || IS_GEN7(dev
)) {
631 "Graphics Interrupt mask (%s): %08x\n",
632 ring
->name
, I915_READ_IMR(ring
));
634 i915_ring_seqno_info(m
, ring
);
636 mutex_unlock(&dev
->struct_mutex
);
641 static int i915_gem_fence_regs_info(struct seq_file
*m
, void *data
)
643 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
644 struct drm_device
*dev
= node
->minor
->dev
;
645 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
648 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
652 seq_printf(m
, "Reserved fences = %d\n", dev_priv
->fence_reg_start
);
653 seq_printf(m
, "Total fences = %d\n", dev_priv
->num_fence_regs
);
654 for (i
= 0; i
< dev_priv
->num_fence_regs
; i
++) {
655 struct drm_i915_gem_object
*obj
= dev_priv
->fence_regs
[i
].obj
;
657 seq_printf(m
, "Fence %d, pin count = %d, object = ",
658 i
, dev_priv
->fence_regs
[i
].pin_count
);
660 seq_puts(m
, "unused");
662 describe_obj(m
, obj
);
666 mutex_unlock(&dev
->struct_mutex
);
670 static int i915_hws_info(struct seq_file
*m
, void *data
)
672 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
673 struct drm_device
*dev
= node
->minor
->dev
;
674 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
675 struct intel_ring_buffer
*ring
;
679 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
680 hws
= ring
->status_page
.page_addr
;
684 for (i
= 0; i
< 4096 / sizeof(u32
) / 4; i
+= 4) {
685 seq_printf(m
, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
687 hws
[i
], hws
[i
+ 1], hws
[i
+ 2], hws
[i
+ 3]);
693 i915_error_state_write(struct file
*filp
,
694 const char __user
*ubuf
,
698 struct i915_error_state_file_priv
*error_priv
= filp
->private_data
;
699 struct drm_device
*dev
= error_priv
->dev
;
702 DRM_DEBUG_DRIVER("Resetting error state\n");
704 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
708 i915_destroy_error_state(dev
);
709 mutex_unlock(&dev
->struct_mutex
);
714 static int i915_error_state_open(struct inode
*inode
, struct file
*file
)
716 struct drm_device
*dev
= inode
->i_private
;
717 struct i915_error_state_file_priv
*error_priv
;
719 error_priv
= kzalloc(sizeof(*error_priv
), GFP_KERNEL
);
723 error_priv
->dev
= dev
;
725 i915_error_state_get(dev
, error_priv
);
727 file
->private_data
= error_priv
;
732 static int i915_error_state_release(struct inode
*inode
, struct file
*file
)
734 struct i915_error_state_file_priv
*error_priv
= file
->private_data
;
736 i915_error_state_put(error_priv
);
742 static ssize_t
i915_error_state_read(struct file
*file
, char __user
*userbuf
,
743 size_t count
, loff_t
*pos
)
745 struct i915_error_state_file_priv
*error_priv
= file
->private_data
;
746 struct drm_i915_error_state_buf error_str
;
748 ssize_t ret_count
= 0;
751 ret
= i915_error_state_buf_init(&error_str
, count
, *pos
);
755 ret
= i915_error_state_to_str(&error_str
, error_priv
);
759 ret_count
= simple_read_from_buffer(userbuf
, count
, &tmp_pos
,
766 *pos
= error_str
.start
+ ret_count
;
768 i915_error_state_buf_release(&error_str
);
769 return ret
?: ret_count
;
772 static const struct file_operations i915_error_state_fops
= {
773 .owner
= THIS_MODULE
,
774 .open
= i915_error_state_open
,
775 .read
= i915_error_state_read
,
776 .write
= i915_error_state_write
,
777 .llseek
= default_llseek
,
778 .release
= i915_error_state_release
,
782 i915_next_seqno_get(void *data
, u64
*val
)
784 struct drm_device
*dev
= data
;
785 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
788 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
792 *val
= dev_priv
->next_seqno
;
793 mutex_unlock(&dev
->struct_mutex
);
799 i915_next_seqno_set(void *data
, u64 val
)
801 struct drm_device
*dev
= data
;
804 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
808 ret
= i915_gem_set_seqno(dev
, val
);
809 mutex_unlock(&dev
->struct_mutex
);
814 DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops
,
815 i915_next_seqno_get
, i915_next_seqno_set
,
818 static int i915_rstdby_delays(struct seq_file
*m
, void *unused
)
820 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
821 struct drm_device
*dev
= node
->minor
->dev
;
822 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
826 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
830 crstanddelay
= I915_READ16(CRSTANDVID
);
832 mutex_unlock(&dev
->struct_mutex
);
834 seq_printf(m
, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay
>> 8) & 0x3f, (crstanddelay
& 0x3f));
839 static int i915_cur_delayinfo(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
;
847 u16 rgvswctl
= I915_READ16(MEMSWCTL
);
848 u16 rgvstat
= I915_READ16(MEMSTAT_ILK
);
850 seq_printf(m
, "Requested P-state: %d\n", (rgvswctl
>> 8) & 0xf);
851 seq_printf(m
, "Requested VID: %d\n", rgvswctl
& 0x3f);
852 seq_printf(m
, "Current VID: %d\n", (rgvstat
& MEMSTAT_VID_MASK
) >>
854 seq_printf(m
, "Current P-state: %d\n",
855 (rgvstat
& MEMSTAT_PSTATE_MASK
) >> MEMSTAT_PSTATE_SHIFT
);
856 } else if ((IS_GEN6(dev
) || IS_GEN7(dev
)) && !IS_VALLEYVIEW(dev
)) {
857 u32 gt_perf_status
= I915_READ(GEN6_GT_PERF_STATUS
);
858 u32 rp_state_limits
= I915_READ(GEN6_RP_STATE_LIMITS
);
859 u32 rp_state_cap
= I915_READ(GEN6_RP_STATE_CAP
);
860 u32 rpstat
, cagf
, reqf
;
861 u32 rpupei
, rpcurup
, rpprevup
;
862 u32 rpdownei
, rpcurdown
, rpprevdown
;
865 /* RPSTAT1 is in the GT power well */
866 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
870 gen6_gt_force_wake_get(dev_priv
);
872 reqf
= I915_READ(GEN6_RPNSWREQ
);
873 reqf
&= ~GEN6_TURBO_DISABLE
;
878 reqf
*= GT_FREQUENCY_MULTIPLIER
;
880 rpstat
= I915_READ(GEN6_RPSTAT1
);
881 rpupei
= I915_READ(GEN6_RP_CUR_UP_EI
);
882 rpcurup
= I915_READ(GEN6_RP_CUR_UP
);
883 rpprevup
= I915_READ(GEN6_RP_PREV_UP
);
884 rpdownei
= I915_READ(GEN6_RP_CUR_DOWN_EI
);
885 rpcurdown
= I915_READ(GEN6_RP_CUR_DOWN
);
886 rpprevdown
= I915_READ(GEN6_RP_PREV_DOWN
);
888 cagf
= (rpstat
& HSW_CAGF_MASK
) >> HSW_CAGF_SHIFT
;
890 cagf
= (rpstat
& GEN6_CAGF_MASK
) >> GEN6_CAGF_SHIFT
;
891 cagf
*= GT_FREQUENCY_MULTIPLIER
;
893 gen6_gt_force_wake_put(dev_priv
);
894 mutex_unlock(&dev
->struct_mutex
);
896 seq_printf(m
, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status
);
897 seq_printf(m
, "RPSTAT1: 0x%08x\n", rpstat
);
898 seq_printf(m
, "Render p-state ratio: %d\n",
899 (gt_perf_status
& 0xff00) >> 8);
900 seq_printf(m
, "Render p-state VID: %d\n",
901 gt_perf_status
& 0xff);
902 seq_printf(m
, "Render p-state limit: %d\n",
903 rp_state_limits
& 0xff);
904 seq_printf(m
, "RPNSWREQ: %dMHz\n", reqf
);
905 seq_printf(m
, "CAGF: %dMHz\n", cagf
);
906 seq_printf(m
, "RP CUR UP EI: %dus\n", rpupei
&
908 seq_printf(m
, "RP CUR UP: %dus\n", rpcurup
&
909 GEN6_CURBSYTAVG_MASK
);
910 seq_printf(m
, "RP PREV UP: %dus\n", rpprevup
&
911 GEN6_CURBSYTAVG_MASK
);
912 seq_printf(m
, "RP CUR DOWN EI: %dus\n", rpdownei
&
914 seq_printf(m
, "RP CUR DOWN: %dus\n", rpcurdown
&
915 GEN6_CURBSYTAVG_MASK
);
916 seq_printf(m
, "RP PREV DOWN: %dus\n", rpprevdown
&
917 GEN6_CURBSYTAVG_MASK
);
919 max_freq
= (rp_state_cap
& 0xff0000) >> 16;
920 seq_printf(m
, "Lowest (RPN) frequency: %dMHz\n",
921 max_freq
* GT_FREQUENCY_MULTIPLIER
);
923 max_freq
= (rp_state_cap
& 0xff00) >> 8;
924 seq_printf(m
, "Nominal (RP1) frequency: %dMHz\n",
925 max_freq
* GT_FREQUENCY_MULTIPLIER
);
927 max_freq
= rp_state_cap
& 0xff;
928 seq_printf(m
, "Max non-overclocked (RP0) frequency: %dMHz\n",
929 max_freq
* GT_FREQUENCY_MULTIPLIER
);
931 seq_printf(m
, "Max overclocked frequency: %dMHz\n",
932 dev_priv
->rps
.hw_max
* GT_FREQUENCY_MULTIPLIER
);
933 } else if (IS_VALLEYVIEW(dev
)) {
936 mutex_lock(&dev_priv
->rps
.hw_lock
);
937 freq_sts
= vlv_punit_read(dev_priv
, PUNIT_REG_GPU_FREQ_STS
);
938 seq_printf(m
, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts
);
939 seq_printf(m
, "DDR freq: %d MHz\n", dev_priv
->mem_freq
);
941 val
= vlv_punit_read(dev_priv
, PUNIT_FUSE_BUS1
);
942 seq_printf(m
, "max GPU freq: %d MHz\n",
943 vlv_gpu_freq(dev_priv
->mem_freq
, val
));
945 val
= vlv_punit_read(dev_priv
, PUNIT_REG_GPU_LFM
);
946 seq_printf(m
, "min GPU freq: %d MHz\n",
947 vlv_gpu_freq(dev_priv
->mem_freq
, val
));
949 seq_printf(m
, "current GPU freq: %d MHz\n",
950 vlv_gpu_freq(dev_priv
->mem_freq
,
951 (freq_sts
>> 8) & 0xff));
952 mutex_unlock(&dev_priv
->rps
.hw_lock
);
954 seq_puts(m
, "no P-state info available\n");
960 static int i915_delayfreq_table(struct seq_file
*m
, void *unused
)
962 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
963 struct drm_device
*dev
= node
->minor
->dev
;
964 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
968 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
972 for (i
= 0; i
< 16; i
++) {
973 delayfreq
= I915_READ(PXVFREQ_BASE
+ i
* 4);
974 seq_printf(m
, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i
, delayfreq
,
975 (delayfreq
& PXVFREQ_PX_MASK
) >> PXVFREQ_PX_SHIFT
);
978 mutex_unlock(&dev
->struct_mutex
);
983 static inline int MAP_TO_MV(int map
)
985 return 1250 - (map
* 25);
988 static int i915_inttoext_table(struct seq_file
*m
, void *unused
)
990 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
991 struct drm_device
*dev
= node
->minor
->dev
;
992 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
996 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1000 for (i
= 1; i
<= 32; i
++) {
1001 inttoext
= I915_READ(INTTOEXT_BASE_ILK
+ i
* 4);
1002 seq_printf(m
, "INTTOEXT%02d: 0x%08x\n", i
, inttoext
);
1005 mutex_unlock(&dev
->struct_mutex
);
1010 static int ironlake_drpc_info(struct seq_file
*m
)
1012 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1013 struct drm_device
*dev
= node
->minor
->dev
;
1014 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1015 u32 rgvmodectl
, rstdbyctl
;
1019 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1023 rgvmodectl
= I915_READ(MEMMODECTL
);
1024 rstdbyctl
= I915_READ(RSTDBYCTL
);
1025 crstandvid
= I915_READ16(CRSTANDVID
);
1027 mutex_unlock(&dev
->struct_mutex
);
1029 seq_printf(m
, "HD boost: %s\n", (rgvmodectl
& MEMMODE_BOOST_EN
) ?
1031 seq_printf(m
, "Boost freq: %d\n",
1032 (rgvmodectl
& MEMMODE_BOOST_FREQ_MASK
) >>
1033 MEMMODE_BOOST_FREQ_SHIFT
);
1034 seq_printf(m
, "HW control enabled: %s\n",
1035 rgvmodectl
& MEMMODE_HWIDLE_EN
? "yes" : "no");
1036 seq_printf(m
, "SW control enabled: %s\n",
1037 rgvmodectl
& MEMMODE_SWMODE_EN
? "yes" : "no");
1038 seq_printf(m
, "Gated voltage change: %s\n",
1039 rgvmodectl
& MEMMODE_RCLK_GATE
? "yes" : "no");
1040 seq_printf(m
, "Starting frequency: P%d\n",
1041 (rgvmodectl
& MEMMODE_FSTART_MASK
) >> MEMMODE_FSTART_SHIFT
);
1042 seq_printf(m
, "Max P-state: P%d\n",
1043 (rgvmodectl
& MEMMODE_FMAX_MASK
) >> MEMMODE_FMAX_SHIFT
);
1044 seq_printf(m
, "Min P-state: P%d\n", (rgvmodectl
& MEMMODE_FMIN_MASK
));
1045 seq_printf(m
, "RS1 VID: %d\n", (crstandvid
& 0x3f));
1046 seq_printf(m
, "RS2 VID: %d\n", ((crstandvid
>> 8) & 0x3f));
1047 seq_printf(m
, "Render standby enabled: %s\n",
1048 (rstdbyctl
& RCX_SW_EXIT
) ? "no" : "yes");
1049 seq_puts(m
, "Current RS state: ");
1050 switch (rstdbyctl
& RSX_STATUS_MASK
) {
1052 seq_puts(m
, "on\n");
1054 case RSX_STATUS_RC1
:
1055 seq_puts(m
, "RC1\n");
1057 case RSX_STATUS_RC1E
:
1058 seq_puts(m
, "RC1E\n");
1060 case RSX_STATUS_RS1
:
1061 seq_puts(m
, "RS1\n");
1063 case RSX_STATUS_RS2
:
1064 seq_puts(m
, "RS2 (RC6)\n");
1066 case RSX_STATUS_RS3
:
1067 seq_puts(m
, "RC3 (RC6+)\n");
1070 seq_puts(m
, "unknown\n");
1077 static int gen6_drpc_info(struct seq_file
*m
)
1080 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1081 struct drm_device
*dev
= node
->minor
->dev
;
1082 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1083 u32 rpmodectl1
, gt_core_status
, rcctl1
, rc6vids
= 0;
1084 unsigned forcewake_count
;
1087 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1091 spin_lock_irq(&dev_priv
->uncore
.lock
);
1092 forcewake_count
= dev_priv
->uncore
.forcewake_count
;
1093 spin_unlock_irq(&dev_priv
->uncore
.lock
);
1095 if (forcewake_count
) {
1096 seq_puts(m
, "RC information inaccurate because somebody "
1097 "holds a forcewake reference \n");
1099 /* NB: we cannot use forcewake, else we read the wrong values */
1100 while (count
++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK
) & 1))
1102 seq_printf(m
, "RC information accurate: %s\n", yesno(count
< 51));
1105 gt_core_status
= readl(dev_priv
->regs
+ GEN6_GT_CORE_STATUS
);
1106 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS
, gt_core_status
, 4, true);
1108 rpmodectl1
= I915_READ(GEN6_RP_CONTROL
);
1109 rcctl1
= I915_READ(GEN6_RC_CONTROL
);
1110 mutex_unlock(&dev
->struct_mutex
);
1111 mutex_lock(&dev_priv
->rps
.hw_lock
);
1112 sandybridge_pcode_read(dev_priv
, GEN6_PCODE_READ_RC6VIDS
, &rc6vids
);
1113 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1115 seq_printf(m
, "Video Turbo Mode: %s\n",
1116 yesno(rpmodectl1
& GEN6_RP_MEDIA_TURBO
));
1117 seq_printf(m
, "HW control enabled: %s\n",
1118 yesno(rpmodectl1
& GEN6_RP_ENABLE
));
1119 seq_printf(m
, "SW control enabled: %s\n",
1120 yesno((rpmodectl1
& GEN6_RP_MEDIA_MODE_MASK
) ==
1121 GEN6_RP_MEDIA_SW_MODE
));
1122 seq_printf(m
, "RC1e Enabled: %s\n",
1123 yesno(rcctl1
& GEN6_RC_CTL_RC1e_ENABLE
));
1124 seq_printf(m
, "RC6 Enabled: %s\n",
1125 yesno(rcctl1
& GEN6_RC_CTL_RC6_ENABLE
));
1126 seq_printf(m
, "Deep RC6 Enabled: %s\n",
1127 yesno(rcctl1
& GEN6_RC_CTL_RC6p_ENABLE
));
1128 seq_printf(m
, "Deepest RC6 Enabled: %s\n",
1129 yesno(rcctl1
& GEN6_RC_CTL_RC6pp_ENABLE
));
1130 seq_puts(m
, "Current RC state: ");
1131 switch (gt_core_status
& GEN6_RCn_MASK
) {
1133 if (gt_core_status
& GEN6_CORE_CPD_STATE_MASK
)
1134 seq_puts(m
, "Core Power Down\n");
1136 seq_puts(m
, "on\n");
1139 seq_puts(m
, "RC3\n");
1142 seq_puts(m
, "RC6\n");
1145 seq_puts(m
, "RC7\n");
1148 seq_puts(m
, "Unknown\n");
1152 seq_printf(m
, "Core Power Down: %s\n",
1153 yesno(gt_core_status
& GEN6_CORE_CPD_STATE_MASK
));
1155 /* Not exactly sure what this is */
1156 seq_printf(m
, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1157 I915_READ(GEN6_GT_GFX_RC6_LOCKED
));
1158 seq_printf(m
, "RC6 residency since boot: %u\n",
1159 I915_READ(GEN6_GT_GFX_RC6
));
1160 seq_printf(m
, "RC6+ residency since boot: %u\n",
1161 I915_READ(GEN6_GT_GFX_RC6p
));
1162 seq_printf(m
, "RC6++ residency since boot: %u\n",
1163 I915_READ(GEN6_GT_GFX_RC6pp
));
1165 seq_printf(m
, "RC6 voltage: %dmV\n",
1166 GEN6_DECODE_RC6_VID(((rc6vids
>> 0) & 0xff)));
1167 seq_printf(m
, "RC6+ voltage: %dmV\n",
1168 GEN6_DECODE_RC6_VID(((rc6vids
>> 8) & 0xff)));
1169 seq_printf(m
, "RC6++ voltage: %dmV\n",
1170 GEN6_DECODE_RC6_VID(((rc6vids
>> 16) & 0xff)));
1174 static int i915_drpc_info(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
;
1179 if (IS_GEN6(dev
) || IS_GEN7(dev
))
1180 return gen6_drpc_info(m
);
1182 return ironlake_drpc_info(m
);
1185 static int i915_fbc_status(struct seq_file
*m
, void *unused
)
1187 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1188 struct drm_device
*dev
= node
->minor
->dev
;
1189 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1191 if (!I915_HAS_FBC(dev
)) {
1192 seq_puts(m
, "FBC unsupported on this chipset\n");
1196 if (intel_fbc_enabled(dev
)) {
1197 seq_puts(m
, "FBC enabled\n");
1199 seq_puts(m
, "FBC disabled: ");
1200 switch (dev_priv
->fbc
.no_fbc_reason
) {
1202 seq_puts(m
, "FBC actived, but currently disabled in hardware");
1204 case FBC_UNSUPPORTED
:
1205 seq_puts(m
, "unsupported by this chipset");
1208 seq_puts(m
, "no outputs");
1210 case FBC_STOLEN_TOO_SMALL
:
1211 seq_puts(m
, "not enough stolen memory");
1213 case FBC_UNSUPPORTED_MODE
:
1214 seq_puts(m
, "mode not supported");
1216 case FBC_MODE_TOO_LARGE
:
1217 seq_puts(m
, "mode too large");
1220 seq_puts(m
, "FBC unsupported on plane");
1223 seq_puts(m
, "scanout buffer not tiled");
1225 case FBC_MULTIPLE_PIPES
:
1226 seq_puts(m
, "multiple pipes are enabled");
1228 case FBC_MODULE_PARAM
:
1229 seq_puts(m
, "disabled per module param (default off)");
1231 case FBC_CHIP_DEFAULT
:
1232 seq_puts(m
, "disabled per chip default");
1235 seq_puts(m
, "unknown reason");
1242 static int i915_ips_status(struct seq_file
*m
, void *unused
)
1244 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1245 struct drm_device
*dev
= node
->minor
->dev
;
1246 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1248 if (!HAS_IPS(dev
)) {
1249 seq_puts(m
, "not supported\n");
1253 if (I915_READ(IPS_CTL
) & IPS_ENABLE
)
1254 seq_puts(m
, "enabled\n");
1256 seq_puts(m
, "disabled\n");
1261 static int i915_sr_status(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
;
1266 bool sr_enabled
= false;
1268 if (HAS_PCH_SPLIT(dev
))
1269 sr_enabled
= I915_READ(WM1_LP_ILK
) & WM1_LP_SR_EN
;
1270 else if (IS_CRESTLINE(dev
) || IS_I945G(dev
) || IS_I945GM(dev
))
1271 sr_enabled
= I915_READ(FW_BLC_SELF
) & FW_BLC_SELF_EN
;
1272 else if (IS_I915GM(dev
))
1273 sr_enabled
= I915_READ(INSTPM
) & INSTPM_SELF_EN
;
1274 else if (IS_PINEVIEW(dev
))
1275 sr_enabled
= I915_READ(DSPFW3
) & PINEVIEW_SELF_REFRESH_EN
;
1277 seq_printf(m
, "self-refresh: %s\n",
1278 sr_enabled
? "enabled" : "disabled");
1283 static int i915_emon_status(struct seq_file
*m
, void *unused
)
1285 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1286 struct drm_device
*dev
= node
->minor
->dev
;
1287 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1288 unsigned long temp
, chipset
, gfx
;
1294 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1298 temp
= i915_mch_val(dev_priv
);
1299 chipset
= i915_chipset_val(dev_priv
);
1300 gfx
= i915_gfx_val(dev_priv
);
1301 mutex_unlock(&dev
->struct_mutex
);
1303 seq_printf(m
, "GMCH temp: %ld\n", temp
);
1304 seq_printf(m
, "Chipset power: %ld\n", chipset
);
1305 seq_printf(m
, "GFX power: %ld\n", gfx
);
1306 seq_printf(m
, "Total power: %ld\n", chipset
+ gfx
);
1311 static int i915_ring_freq_table(struct seq_file
*m
, void *unused
)
1313 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1314 struct drm_device
*dev
= node
->minor
->dev
;
1315 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1317 int gpu_freq
, ia_freq
;
1319 if (!(IS_GEN6(dev
) || IS_GEN7(dev
))) {
1320 seq_puts(m
, "unsupported on this chipset\n");
1324 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
1328 seq_puts(m
, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
1330 for (gpu_freq
= dev_priv
->rps
.min_delay
;
1331 gpu_freq
<= dev_priv
->rps
.max_delay
;
1334 sandybridge_pcode_read(dev_priv
,
1335 GEN6_PCODE_READ_MIN_FREQ_TABLE
,
1337 seq_printf(m
, "%d\t\t%d\t\t\t\t%d\n",
1338 gpu_freq
* GT_FREQUENCY_MULTIPLIER
,
1339 ((ia_freq
>> 0) & 0xff) * 100,
1340 ((ia_freq
>> 8) & 0xff) * 100);
1343 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1348 static int i915_gfxec(struct seq_file
*m
, void *unused
)
1350 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1351 struct drm_device
*dev
= node
->minor
->dev
;
1352 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1355 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1359 seq_printf(m
, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
1361 mutex_unlock(&dev
->struct_mutex
);
1366 static int i915_opregion(struct seq_file
*m
, void *unused
)
1368 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1369 struct drm_device
*dev
= node
->minor
->dev
;
1370 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1371 struct intel_opregion
*opregion
= &dev_priv
->opregion
;
1372 void *data
= kmalloc(OPREGION_SIZE
, GFP_KERNEL
);
1378 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1382 if (opregion
->header
) {
1383 memcpy_fromio(data
, opregion
->header
, OPREGION_SIZE
);
1384 seq_write(m
, data
, OPREGION_SIZE
);
1387 mutex_unlock(&dev
->struct_mutex
);
1394 static int i915_gem_framebuffer_info(struct seq_file
*m
, void *data
)
1396 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1397 struct drm_device
*dev
= node
->minor
->dev
;
1398 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1399 struct intel_fbdev
*ifbdev
;
1400 struct intel_framebuffer
*fb
;
1403 ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1407 ifbdev
= dev_priv
->fbdev
;
1408 fb
= to_intel_framebuffer(ifbdev
->helper
.fb
);
1410 seq_printf(m
, "fbcon size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
1414 fb
->base
.bits_per_pixel
,
1415 atomic_read(&fb
->base
.refcount
.refcount
));
1416 describe_obj(m
, fb
->obj
);
1418 mutex_unlock(&dev
->mode_config
.mutex
);
1420 mutex_lock(&dev
->mode_config
.fb_lock
);
1421 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, base
.head
) {
1422 if (&fb
->base
== ifbdev
->helper
.fb
)
1425 seq_printf(m
, "user size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
1429 fb
->base
.bits_per_pixel
,
1430 atomic_read(&fb
->base
.refcount
.refcount
));
1431 describe_obj(m
, fb
->obj
);
1434 mutex_unlock(&dev
->mode_config
.fb_lock
);
1439 static int i915_context_status(struct seq_file
*m
, void *unused
)
1441 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1442 struct drm_device
*dev
= node
->minor
->dev
;
1443 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1444 struct intel_ring_buffer
*ring
;
1447 ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1451 if (dev_priv
->ips
.pwrctx
) {
1452 seq_puts(m
, "power context ");
1453 describe_obj(m
, dev_priv
->ips
.pwrctx
);
1457 if (dev_priv
->ips
.renderctx
) {
1458 seq_puts(m
, "render context ");
1459 describe_obj(m
, dev_priv
->ips
.renderctx
);
1463 for_each_ring(ring
, dev_priv
, i
) {
1464 if (ring
->default_context
) {
1465 seq_printf(m
, "HW default context %s ring ", ring
->name
);
1466 describe_obj(m
, ring
->default_context
->obj
);
1471 mutex_unlock(&dev
->mode_config
.mutex
);
1476 static int i915_gen6_forcewake_count_info(struct seq_file
*m
, void *data
)
1478 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1479 struct drm_device
*dev
= node
->minor
->dev
;
1480 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1481 unsigned forcewake_count
;
1483 spin_lock_irq(&dev_priv
->uncore
.lock
);
1484 forcewake_count
= dev_priv
->uncore
.forcewake_count
;
1485 spin_unlock_irq(&dev_priv
->uncore
.lock
);
1487 seq_printf(m
, "forcewake count = %u\n", forcewake_count
);
1492 static const char *swizzle_string(unsigned swizzle
)
1495 case I915_BIT_6_SWIZZLE_NONE
:
1497 case I915_BIT_6_SWIZZLE_9
:
1499 case I915_BIT_6_SWIZZLE_9_10
:
1500 return "bit9/bit10";
1501 case I915_BIT_6_SWIZZLE_9_11
:
1502 return "bit9/bit11";
1503 case I915_BIT_6_SWIZZLE_9_10_11
:
1504 return "bit9/bit10/bit11";
1505 case I915_BIT_6_SWIZZLE_9_17
:
1506 return "bit9/bit17";
1507 case I915_BIT_6_SWIZZLE_9_10_17
:
1508 return "bit9/bit10/bit17";
1509 case I915_BIT_6_SWIZZLE_UNKNOWN
:
1516 static int i915_swizzle_info(struct seq_file
*m
, void *data
)
1518 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1519 struct drm_device
*dev
= node
->minor
->dev
;
1520 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1523 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1527 seq_printf(m
, "bit6 swizzle for X-tiling = %s\n",
1528 swizzle_string(dev_priv
->mm
.bit_6_swizzle_x
));
1529 seq_printf(m
, "bit6 swizzle for Y-tiling = %s\n",
1530 swizzle_string(dev_priv
->mm
.bit_6_swizzle_y
));
1532 if (IS_GEN3(dev
) || IS_GEN4(dev
)) {
1533 seq_printf(m
, "DDC = 0x%08x\n",
1535 seq_printf(m
, "C0DRB3 = 0x%04x\n",
1536 I915_READ16(C0DRB3
));
1537 seq_printf(m
, "C1DRB3 = 0x%04x\n",
1538 I915_READ16(C1DRB3
));
1539 } else if (IS_GEN6(dev
) || IS_GEN7(dev
)) {
1540 seq_printf(m
, "MAD_DIMM_C0 = 0x%08x\n",
1541 I915_READ(MAD_DIMM_C0
));
1542 seq_printf(m
, "MAD_DIMM_C1 = 0x%08x\n",
1543 I915_READ(MAD_DIMM_C1
));
1544 seq_printf(m
, "MAD_DIMM_C2 = 0x%08x\n",
1545 I915_READ(MAD_DIMM_C2
));
1546 seq_printf(m
, "TILECTL = 0x%08x\n",
1547 I915_READ(TILECTL
));
1548 seq_printf(m
, "ARB_MODE = 0x%08x\n",
1549 I915_READ(ARB_MODE
));
1550 seq_printf(m
, "DISP_ARB_CTL = 0x%08x\n",
1551 I915_READ(DISP_ARB_CTL
));
1553 mutex_unlock(&dev
->struct_mutex
);
1558 static int i915_ppgtt_info(struct seq_file
*m
, void *data
)
1560 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1561 struct drm_device
*dev
= node
->minor
->dev
;
1562 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1563 struct intel_ring_buffer
*ring
;
1567 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1570 if (INTEL_INFO(dev
)->gen
== 6)
1571 seq_printf(m
, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE
));
1573 for_each_ring(ring
, dev_priv
, i
) {
1574 seq_printf(m
, "%s\n", ring
->name
);
1575 if (INTEL_INFO(dev
)->gen
== 7)
1576 seq_printf(m
, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring
)));
1577 seq_printf(m
, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring
)));
1578 seq_printf(m
, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring
)));
1579 seq_printf(m
, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring
)));
1581 if (dev_priv
->mm
.aliasing_ppgtt
) {
1582 struct i915_hw_ppgtt
*ppgtt
= dev_priv
->mm
.aliasing_ppgtt
;
1584 seq_puts(m
, "aliasing PPGTT:\n");
1585 seq_printf(m
, "pd gtt offset: 0x%08x\n", ppgtt
->pd_offset
);
1587 seq_printf(m
, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK
));
1588 mutex_unlock(&dev
->struct_mutex
);
1593 static int i915_dpio_info(struct seq_file
*m
, void *data
)
1595 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1596 struct drm_device
*dev
= node
->minor
->dev
;
1597 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1601 if (!IS_VALLEYVIEW(dev
)) {
1602 seq_puts(m
, "unsupported\n");
1606 ret
= mutex_lock_interruptible(&dev_priv
->dpio_lock
);
1610 seq_printf(m
, "DPIO_CTL: 0x%08x\n", I915_READ(DPIO_CTL
));
1612 seq_printf(m
, "DPIO_DIV_A: 0x%08x\n",
1613 vlv_dpio_read(dev_priv
, _DPIO_DIV_A
));
1614 seq_printf(m
, "DPIO_DIV_B: 0x%08x\n",
1615 vlv_dpio_read(dev_priv
, _DPIO_DIV_B
));
1617 seq_printf(m
, "DPIO_REFSFR_A: 0x%08x\n",
1618 vlv_dpio_read(dev_priv
, _DPIO_REFSFR_A
));
1619 seq_printf(m
, "DPIO_REFSFR_B: 0x%08x\n",
1620 vlv_dpio_read(dev_priv
, _DPIO_REFSFR_B
));
1622 seq_printf(m
, "DPIO_CORE_CLK_A: 0x%08x\n",
1623 vlv_dpio_read(dev_priv
, _DPIO_CORE_CLK_A
));
1624 seq_printf(m
, "DPIO_CORE_CLK_B: 0x%08x\n",
1625 vlv_dpio_read(dev_priv
, _DPIO_CORE_CLK_B
));
1627 seq_printf(m
, "DPIO_LPF_COEFF_A: 0x%08x\n",
1628 vlv_dpio_read(dev_priv
, _DPIO_LPF_COEFF_A
));
1629 seq_printf(m
, "DPIO_LPF_COEFF_B: 0x%08x\n",
1630 vlv_dpio_read(dev_priv
, _DPIO_LPF_COEFF_B
));
1632 seq_printf(m
, "DPIO_FASTCLK_DISABLE: 0x%08x\n",
1633 vlv_dpio_read(dev_priv
, DPIO_FASTCLK_DISABLE
));
1635 mutex_unlock(&dev_priv
->dpio_lock
);
1640 static int i915_llc(struct seq_file
*m
, void *data
)
1642 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1643 struct drm_device
*dev
= node
->minor
->dev
;
1644 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1646 /* Size calculation for LLC is a bit of a pain. Ignore for now. */
1647 seq_printf(m
, "LLC: %s\n", yesno(HAS_LLC(dev
)));
1648 seq_printf(m
, "eLLC: %zuMB\n", dev_priv
->ellc_size
);
1653 static int i915_edp_psr_status(struct seq_file
*m
, void *data
)
1655 struct drm_info_node
*node
= m
->private;
1656 struct drm_device
*dev
= node
->minor
->dev
;
1657 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1658 u32 psrstat
, psrperf
;
1660 if (!IS_HASWELL(dev
)) {
1661 seq_puts(m
, "PSR not supported on this platform\n");
1662 } else if (IS_HASWELL(dev
) && I915_READ(EDP_PSR_CTL
) & EDP_PSR_ENABLE
) {
1663 seq_puts(m
, "PSR enabled\n");
1665 seq_puts(m
, "PSR disabled: ");
1666 switch (dev_priv
->no_psr_reason
) {
1668 seq_puts(m
, "not supported on this platform");
1671 seq_puts(m
, "not supported by panel");
1673 case PSR_MODULE_PARAM
:
1674 seq_puts(m
, "disabled by flag");
1676 case PSR_CRTC_NOT_ACTIVE
:
1677 seq_puts(m
, "crtc not active");
1679 case PSR_PWR_WELL_ENABLED
:
1680 seq_puts(m
, "power well enabled");
1683 seq_puts(m
, "not tiled");
1685 case PSR_SPRITE_ENABLED
:
1686 seq_puts(m
, "sprite enabled");
1688 case PSR_S3D_ENABLED
:
1689 seq_puts(m
, "stereo 3d enabled");
1691 case PSR_INTERLACED_ENABLED
:
1692 seq_puts(m
, "interlaced enabled");
1694 case PSR_HSW_NOT_DDIA
:
1695 seq_puts(m
, "HSW ties PSR to DDI A (eDP)");
1698 seq_puts(m
, "unknown reason");
1704 psrstat
= I915_READ(EDP_PSR_STATUS_CTL
);
1706 seq_puts(m
, "PSR Current State: ");
1707 switch (psrstat
& EDP_PSR_STATUS_STATE_MASK
) {
1708 case EDP_PSR_STATUS_STATE_IDLE
:
1709 seq_puts(m
, "Reset state\n");
1711 case EDP_PSR_STATUS_STATE_SRDONACK
:
1712 seq_puts(m
, "Wait for TG/Stream to send on frame of data after SRD conditions are met\n");
1714 case EDP_PSR_STATUS_STATE_SRDENT
:
1715 seq_puts(m
, "SRD entry\n");
1717 case EDP_PSR_STATUS_STATE_BUFOFF
:
1718 seq_puts(m
, "Wait for buffer turn off\n");
1720 case EDP_PSR_STATUS_STATE_BUFON
:
1721 seq_puts(m
, "Wait for buffer turn on\n");
1723 case EDP_PSR_STATUS_STATE_AUXACK
:
1724 seq_puts(m
, "Wait for AUX to acknowledge on SRD exit\n");
1726 case EDP_PSR_STATUS_STATE_SRDOFFACK
:
1727 seq_puts(m
, "Wait for TG/Stream to acknowledge the SRD VDM exit\n");
1730 seq_puts(m
, "Unknown\n");
1734 seq_puts(m
, "Link Status: ");
1735 switch (psrstat
& EDP_PSR_STATUS_LINK_MASK
) {
1736 case EDP_PSR_STATUS_LINK_FULL_OFF
:
1737 seq_puts(m
, "Link is fully off\n");
1739 case EDP_PSR_STATUS_LINK_FULL_ON
:
1740 seq_puts(m
, "Link is fully on\n");
1742 case EDP_PSR_STATUS_LINK_STANDBY
:
1743 seq_puts(m
, "Link is in standby\n");
1746 seq_puts(m
, "Unknown\n");
1750 seq_printf(m
, "PSR Entry Count: %u\n",
1751 psrstat
>> EDP_PSR_STATUS_COUNT_SHIFT
&
1752 EDP_PSR_STATUS_COUNT_MASK
);
1754 seq_printf(m
, "Max Sleep Timer Counter: %u\n",
1755 psrstat
>> EDP_PSR_STATUS_MAX_SLEEP_TIMER_SHIFT
&
1756 EDP_PSR_STATUS_MAX_SLEEP_TIMER_MASK
);
1758 seq_printf(m
, "Had AUX error: %s\n",
1759 yesno(psrstat
& EDP_PSR_STATUS_AUX_ERROR
));
1761 seq_printf(m
, "Sending AUX: %s\n",
1762 yesno(psrstat
& EDP_PSR_STATUS_AUX_SENDING
));
1764 seq_printf(m
, "Sending Idle: %s\n",
1765 yesno(psrstat
& EDP_PSR_STATUS_SENDING_IDLE
));
1767 seq_printf(m
, "Sending TP2 TP3: %s\n",
1768 yesno(psrstat
& EDP_PSR_STATUS_SENDING_TP2_TP3
));
1770 seq_printf(m
, "Sending TP1: %s\n",
1771 yesno(psrstat
& EDP_PSR_STATUS_SENDING_TP1
));
1773 seq_printf(m
, "Idle Count: %u\n",
1774 psrstat
& EDP_PSR_STATUS_IDLE_MASK
);
1776 psrperf
= (I915_READ(EDP_PSR_PERF_CNT
)) & EDP_PSR_PERF_CNT_MASK
;
1777 seq_printf(m
, "Performance Counter: %u\n", psrperf
);
1782 static int i915_energy_uJ(struct seq_file
*m
, void *data
)
1784 struct drm_info_node
*node
= m
->private;
1785 struct drm_device
*dev
= node
->minor
->dev
;
1786 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1790 if (INTEL_INFO(dev
)->gen
< 6)
1793 rdmsrl(MSR_RAPL_POWER_UNIT
, power
);
1794 power
= (power
& 0x1f00) >> 8;
1795 units
= 1000000 / (1 << power
); /* convert to uJ */
1796 power
= I915_READ(MCH_SECP_NRG_STTS
);
1799 seq_printf(m
, "%llu", (long long unsigned)power
);
1804 static int i915_pc8_status(struct seq_file
*m
, void *unused
)
1806 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1807 struct drm_device
*dev
= node
->minor
->dev
;
1808 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1810 if (!IS_HASWELL(dev
)) {
1811 seq_puts(m
, "not supported\n");
1815 mutex_lock(&dev_priv
->pc8
.lock
);
1816 seq_printf(m
, "Requirements met: %s\n",
1817 yesno(dev_priv
->pc8
.requirements_met
));
1818 seq_printf(m
, "GPU idle: %s\n", yesno(dev_priv
->pc8
.gpu_idle
));
1819 seq_printf(m
, "Disable count: %d\n", dev_priv
->pc8
.disable_count
);
1820 seq_printf(m
, "IRQs disabled: %s\n",
1821 yesno(dev_priv
->pc8
.irqs_disabled
));
1822 seq_printf(m
, "Enabled: %s\n", yesno(dev_priv
->pc8
.enabled
));
1823 mutex_unlock(&dev_priv
->pc8
.lock
);
1829 i915_wedged_get(void *data
, u64
*val
)
1831 struct drm_device
*dev
= data
;
1832 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1834 *val
= atomic_read(&dev_priv
->gpu_error
.reset_counter
);
1840 i915_wedged_set(void *data
, u64 val
)
1842 struct drm_device
*dev
= data
;
1844 DRM_INFO("Manually setting wedged to %llu\n", val
);
1845 i915_handle_error(dev
, val
);
1850 DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops
,
1851 i915_wedged_get
, i915_wedged_set
,
1855 i915_ring_stop_get(void *data
, u64
*val
)
1857 struct drm_device
*dev
= data
;
1858 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1860 *val
= dev_priv
->gpu_error
.stop_rings
;
1866 i915_ring_stop_set(void *data
, u64 val
)
1868 struct drm_device
*dev
= data
;
1869 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1872 DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val
);
1874 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1878 dev_priv
->gpu_error
.stop_rings
= val
;
1879 mutex_unlock(&dev
->struct_mutex
);
1884 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops
,
1885 i915_ring_stop_get
, i915_ring_stop_set
,
1888 #define DROP_UNBOUND 0x1
1889 #define DROP_BOUND 0x2
1890 #define DROP_RETIRE 0x4
1891 #define DROP_ACTIVE 0x8
1892 #define DROP_ALL (DROP_UNBOUND | \
1897 i915_drop_caches_get(void *data
, u64
*val
)
1905 i915_drop_caches_set(void *data
, u64 val
)
1907 struct drm_device
*dev
= data
;
1908 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1909 struct drm_i915_gem_object
*obj
, *next
;
1910 struct i915_address_space
*vm
;
1911 struct i915_vma
*vma
, *x
;
1914 DRM_DEBUG_DRIVER("Dropping caches: 0x%08llx\n", val
);
1916 /* No need to check and wait for gpu resets, only libdrm auto-restarts
1917 * on ioctls on -EAGAIN. */
1918 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1922 if (val
& DROP_ACTIVE
) {
1923 ret
= i915_gpu_idle(dev
);
1928 if (val
& (DROP_RETIRE
| DROP_ACTIVE
))
1929 i915_gem_retire_requests(dev
);
1931 if (val
& DROP_BOUND
) {
1932 list_for_each_entry(vm
, &dev_priv
->vm_list
, global_link
) {
1933 list_for_each_entry_safe(vma
, x
, &vm
->inactive_list
,
1935 if (vma
->obj
->pin_count
)
1938 ret
= i915_vma_unbind(vma
);
1945 if (val
& DROP_UNBOUND
) {
1946 list_for_each_entry_safe(obj
, next
, &dev_priv
->mm
.unbound_list
,
1948 if (obj
->pages_pin_count
== 0) {
1949 ret
= i915_gem_object_put_pages(obj
);
1956 mutex_unlock(&dev
->struct_mutex
);
1961 DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops
,
1962 i915_drop_caches_get
, i915_drop_caches_set
,
1966 i915_max_freq_get(void *data
, u64
*val
)
1968 struct drm_device
*dev
= data
;
1969 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1972 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
1975 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
1979 if (IS_VALLEYVIEW(dev
))
1980 *val
= vlv_gpu_freq(dev_priv
->mem_freq
,
1981 dev_priv
->rps
.max_delay
);
1983 *val
= dev_priv
->rps
.max_delay
* GT_FREQUENCY_MULTIPLIER
;
1984 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1990 i915_max_freq_set(void *data
, u64 val
)
1992 struct drm_device
*dev
= data
;
1993 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1996 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
1999 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val
);
2001 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
2006 * Turbo will still be enabled, but won't go above the set value.
2008 if (IS_VALLEYVIEW(dev
)) {
2009 val
= vlv_freq_opcode(dev_priv
->mem_freq
, val
);
2010 dev_priv
->rps
.max_delay
= val
;
2011 gen6_set_rps(dev
, val
);
2013 do_div(val
, GT_FREQUENCY_MULTIPLIER
);
2014 dev_priv
->rps
.max_delay
= val
;
2015 gen6_set_rps(dev
, val
);
2018 mutex_unlock(&dev_priv
->rps
.hw_lock
);
2023 DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops
,
2024 i915_max_freq_get
, i915_max_freq_set
,
2028 i915_min_freq_get(void *data
, u64
*val
)
2030 struct drm_device
*dev
= data
;
2031 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
2034 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
2037 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
2041 if (IS_VALLEYVIEW(dev
))
2042 *val
= vlv_gpu_freq(dev_priv
->mem_freq
,
2043 dev_priv
->rps
.min_delay
);
2045 *val
= dev_priv
->rps
.min_delay
* GT_FREQUENCY_MULTIPLIER
;
2046 mutex_unlock(&dev_priv
->rps
.hw_lock
);
2052 i915_min_freq_set(void *data
, u64 val
)
2054 struct drm_device
*dev
= data
;
2055 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2058 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
2061 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val
);
2063 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
2068 * Turbo will still be enabled, but won't go below the set value.
2070 if (IS_VALLEYVIEW(dev
)) {
2071 val
= vlv_freq_opcode(dev_priv
->mem_freq
, val
);
2072 dev_priv
->rps
.min_delay
= val
;
2073 valleyview_set_rps(dev
, val
);
2075 do_div(val
, GT_FREQUENCY_MULTIPLIER
);
2076 dev_priv
->rps
.min_delay
= val
;
2077 gen6_set_rps(dev
, val
);
2079 mutex_unlock(&dev_priv
->rps
.hw_lock
);
2084 DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops
,
2085 i915_min_freq_get
, i915_min_freq_set
,
2089 i915_cache_sharing_get(void *data
, u64
*val
)
2091 struct drm_device
*dev
= data
;
2092 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
2096 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
2099 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
2103 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
2104 mutex_unlock(&dev_priv
->dev
->struct_mutex
);
2106 *val
= (snpcr
& GEN6_MBC_SNPCR_MASK
) >> GEN6_MBC_SNPCR_SHIFT
;
2112 i915_cache_sharing_set(void *data
, u64 val
)
2114 struct drm_device
*dev
= data
;
2115 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2118 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
2124 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val
);
2126 /* Update the cache sharing policy here as well */
2127 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
2128 snpcr
&= ~GEN6_MBC_SNPCR_MASK
;
2129 snpcr
|= (val
<< GEN6_MBC_SNPCR_SHIFT
);
2130 I915_WRITE(GEN6_MBCUNIT_SNPCR
, snpcr
);
2135 DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops
,
2136 i915_cache_sharing_get
, i915_cache_sharing_set
,
2139 /* As the drm_debugfs_init() routines are called before dev->dev_private is
2140 * allocated we need to hook into the minor for release. */
2142 drm_add_fake_info_node(struct drm_minor
*minor
,
2146 struct drm_info_node
*node
;
2148 node
= kmalloc(sizeof(struct drm_info_node
), GFP_KERNEL
);
2150 debugfs_remove(ent
);
2154 node
->minor
= minor
;
2156 node
->info_ent
= (void *) key
;
2158 mutex_lock(&minor
->debugfs_lock
);
2159 list_add(&node
->list
, &minor
->debugfs_list
);
2160 mutex_unlock(&minor
->debugfs_lock
);
2165 static int i915_forcewake_open(struct inode
*inode
, struct file
*file
)
2167 struct drm_device
*dev
= inode
->i_private
;
2168 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2170 if (INTEL_INFO(dev
)->gen
< 6)
2173 gen6_gt_force_wake_get(dev_priv
);
2178 static int i915_forcewake_release(struct inode
*inode
, struct file
*file
)
2180 struct drm_device
*dev
= inode
->i_private
;
2181 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2183 if (INTEL_INFO(dev
)->gen
< 6)
2186 gen6_gt_force_wake_put(dev_priv
);
2191 static const struct file_operations i915_forcewake_fops
= {
2192 .owner
= THIS_MODULE
,
2193 .open
= i915_forcewake_open
,
2194 .release
= i915_forcewake_release
,
2197 static int i915_forcewake_create(struct dentry
*root
, struct drm_minor
*minor
)
2199 struct drm_device
*dev
= minor
->dev
;
2202 ent
= debugfs_create_file("i915_forcewake_user",
2205 &i915_forcewake_fops
);
2207 return PTR_ERR(ent
);
2209 return drm_add_fake_info_node(minor
, ent
, &i915_forcewake_fops
);
2212 static int i915_debugfs_create(struct dentry
*root
,
2213 struct drm_minor
*minor
,
2215 const struct file_operations
*fops
)
2217 struct drm_device
*dev
= minor
->dev
;
2220 ent
= debugfs_create_file(name
,
2225 return PTR_ERR(ent
);
2227 return drm_add_fake_info_node(minor
, ent
, fops
);
2230 static struct drm_info_list i915_debugfs_list
[] = {
2231 {"i915_capabilities", i915_capabilities
, 0},
2232 {"i915_gem_objects", i915_gem_object_info
, 0},
2233 {"i915_gem_gtt", i915_gem_gtt_info
, 0},
2234 {"i915_gem_pinned", i915_gem_gtt_info
, 0, (void *) PINNED_LIST
},
2235 {"i915_gem_active", i915_gem_object_list_info
, 0, (void *) ACTIVE_LIST
},
2236 {"i915_gem_inactive", i915_gem_object_list_info
, 0, (void *) INACTIVE_LIST
},
2237 {"i915_gem_stolen", i915_gem_stolen_list_info
},
2238 {"i915_gem_pageflip", i915_gem_pageflip_info
, 0},
2239 {"i915_gem_request", i915_gem_request_info
, 0},
2240 {"i915_gem_seqno", i915_gem_seqno_info
, 0},
2241 {"i915_gem_fence_regs", i915_gem_fence_regs_info
, 0},
2242 {"i915_gem_interrupt", i915_interrupt_info
, 0},
2243 {"i915_gem_hws", i915_hws_info
, 0, (void *)RCS
},
2244 {"i915_gem_hws_blt", i915_hws_info
, 0, (void *)BCS
},
2245 {"i915_gem_hws_bsd", i915_hws_info
, 0, (void *)VCS
},
2246 {"i915_gem_hws_vebox", i915_hws_info
, 0, (void *)VECS
},
2247 {"i915_rstdby_delays", i915_rstdby_delays
, 0},
2248 {"i915_cur_delayinfo", i915_cur_delayinfo
, 0},
2249 {"i915_delayfreq_table", i915_delayfreq_table
, 0},
2250 {"i915_inttoext_table", i915_inttoext_table
, 0},
2251 {"i915_drpc_info", i915_drpc_info
, 0},
2252 {"i915_emon_status", i915_emon_status
, 0},
2253 {"i915_ring_freq_table", i915_ring_freq_table
, 0},
2254 {"i915_gfxec", i915_gfxec
, 0},
2255 {"i915_fbc_status", i915_fbc_status
, 0},
2256 {"i915_ips_status", i915_ips_status
, 0},
2257 {"i915_sr_status", i915_sr_status
, 0},
2258 {"i915_opregion", i915_opregion
, 0},
2259 {"i915_gem_framebuffer", i915_gem_framebuffer_info
, 0},
2260 {"i915_context_status", i915_context_status
, 0},
2261 {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info
, 0},
2262 {"i915_swizzle_info", i915_swizzle_info
, 0},
2263 {"i915_ppgtt_info", i915_ppgtt_info
, 0},
2264 {"i915_dpio", i915_dpio_info
, 0},
2265 {"i915_llc", i915_llc
, 0},
2266 {"i915_edp_psr_status", i915_edp_psr_status
, 0},
2267 {"i915_energy_uJ", i915_energy_uJ
, 0},
2268 {"i915_pc8_status", i915_pc8_status
, 0},
2270 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
2272 static struct i915_debugfs_files
{
2274 const struct file_operations
*fops
;
2275 } i915_debugfs_files
[] = {
2276 {"i915_wedged", &i915_wedged_fops
},
2277 {"i915_max_freq", &i915_max_freq_fops
},
2278 {"i915_min_freq", &i915_min_freq_fops
},
2279 {"i915_cache_sharing", &i915_cache_sharing_fops
},
2280 {"i915_ring_stop", &i915_ring_stop_fops
},
2281 {"i915_gem_drop_caches", &i915_drop_caches_fops
},
2282 {"i915_error_state", &i915_error_state_fops
},
2283 {"i915_next_seqno", &i915_next_seqno_fops
},
2286 int i915_debugfs_init(struct drm_minor
*minor
)
2290 ret
= i915_forcewake_create(minor
->debugfs_root
, minor
);
2294 for (i
= 0; i
< ARRAY_SIZE(i915_debugfs_files
); i
++) {
2295 ret
= i915_debugfs_create(minor
->debugfs_root
, minor
,
2296 i915_debugfs_files
[i
].name
,
2297 i915_debugfs_files
[i
].fops
);
2302 return drm_debugfs_create_files(i915_debugfs_list
,
2303 I915_DEBUGFS_ENTRIES
,
2304 minor
->debugfs_root
, minor
);
2307 void i915_debugfs_cleanup(struct drm_minor
*minor
)
2311 drm_debugfs_remove_files(i915_debugfs_list
,
2312 I915_DEBUGFS_ENTRIES
, minor
);
2313 drm_debugfs_remove_files((struct drm_info_list
*) &i915_forcewake_fops
,
2315 for (i
= 0; i
< ARRAY_SIZE(i915_debugfs_files
); i
++) {
2316 struct drm_info_list
*info_list
=
2317 (struct drm_info_list
*) i915_debugfs_files
[i
].fops
;
2319 drm_debugfs_remove_files(info_list
, 1, minor
);
2323 #endif /* CONFIG_DEBUG_FS */