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/circ_buf.h>
31 #include <linux/ctype.h>
32 #include <linux/debugfs.h>
33 #include <linux/slab.h>
34 #include <linux/export.h>
35 #include <linux/list_sort.h>
36 #include <asm/msr-index.h>
38 #include "intel_drv.h"
39 #include "intel_ringbuffer.h"
40 #include <drm/i915_drm.h>
49 static const char *yesno(int v
)
51 return v
? "yes" : "no";
54 /* As the drm_debugfs_init() routines are called before dev->dev_private is
55 * allocated we need to hook into the minor for release. */
57 drm_add_fake_info_node(struct drm_minor
*minor
,
61 struct drm_info_node
*node
;
63 node
= kmalloc(sizeof(*node
), GFP_KERNEL
);
71 node
->info_ent
= (void *) key
;
73 mutex_lock(&minor
->debugfs_lock
);
74 list_add(&node
->list
, &minor
->debugfs_list
);
75 mutex_unlock(&minor
->debugfs_lock
);
80 static int i915_capabilities(struct seq_file
*m
, void *data
)
82 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
83 struct drm_device
*dev
= node
->minor
->dev
;
84 const struct intel_device_info
*info
= INTEL_INFO(dev
);
86 seq_printf(m
, "gen: %d\n", info
->gen
);
87 seq_printf(m
, "pch: %d\n", INTEL_PCH_TYPE(dev
));
88 #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
89 #define SEP_SEMICOLON ;
90 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG
, SEP_SEMICOLON
);
97 static const char *get_pin_flag(struct drm_i915_gem_object
*obj
)
99 if (obj
->user_pin_count
> 0)
101 else if (obj
->pin_count
> 0)
107 static const char *get_tiling_flag(struct drm_i915_gem_object
*obj
)
109 switch (obj
->tiling_mode
) {
111 case I915_TILING_NONE
: return " ";
112 case I915_TILING_X
: return "X";
113 case I915_TILING_Y
: return "Y";
117 static inline const char *get_global_flag(struct drm_i915_gem_object
*obj
)
119 return obj
->has_global_gtt_mapping
? "g" : " ";
123 describe_obj(struct seq_file
*m
, struct drm_i915_gem_object
*obj
)
125 struct i915_vma
*vma
;
126 seq_printf(m
, "%pK: %s%s%s %8zdKiB %02x %02x %u %u %u%s%s%s",
129 get_tiling_flag(obj
),
130 get_global_flag(obj
),
131 obj
->base
.size
/ 1024,
132 obj
->base
.read_domains
,
133 obj
->base
.write_domain
,
134 obj
->last_read_seqno
,
135 obj
->last_write_seqno
,
136 obj
->last_fenced_seqno
,
137 i915_cache_level_str(obj
->cache_level
),
138 obj
->dirty
? " dirty" : "",
139 obj
->madv
== I915_MADV_DONTNEED
? " purgeable" : "");
141 seq_printf(m
, " (name: %d)", obj
->base
.name
);
143 seq_printf(m
, " (pinned x %d)", obj
->pin_count
);
144 if (obj
->pin_display
)
145 seq_printf(m
, " (display)");
146 if (obj
->fence_reg
!= I915_FENCE_REG_NONE
)
147 seq_printf(m
, " (fence: %d)", obj
->fence_reg
);
148 list_for_each_entry(vma
, &obj
->vma_list
, vma_link
) {
149 if (!i915_is_ggtt(vma
->vm
))
153 seq_printf(m
, "gtt offset: %08lx, size: %08lx)",
154 vma
->node
.start
, vma
->node
.size
);
157 seq_printf(m
, " (stolen: %08lx)", obj
->stolen
->start
);
158 if (obj
->pin_mappable
|| obj
->fault_mappable
) {
160 if (obj
->pin_mappable
)
162 if (obj
->fault_mappable
)
165 seq_printf(m
, " (%s mappable)", s
);
167 if (obj
->ring
!= NULL
)
168 seq_printf(m
, " (%s)", obj
->ring
->name
);
171 static void describe_ctx(struct seq_file
*m
, struct i915_hw_context
*ctx
)
173 seq_putc(m
, ctx
->is_initialized
? 'I' : 'i');
174 seq_putc(m
, ctx
->remap_slice
? 'R' : 'r');
178 static int i915_gem_object_list_info(struct seq_file
*m
, void *data
)
180 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
181 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
182 struct list_head
*head
;
183 struct drm_device
*dev
= node
->minor
->dev
;
184 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
185 struct i915_address_space
*vm
= &dev_priv
->gtt
.base
;
186 struct i915_vma
*vma
;
187 size_t total_obj_size
, total_gtt_size
;
190 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
194 /* FIXME: the user of this interface might want more than just GGTT */
197 seq_puts(m
, "Active:\n");
198 head
= &vm
->active_list
;
201 seq_puts(m
, "Inactive:\n");
202 head
= &vm
->inactive_list
;
205 mutex_unlock(&dev
->struct_mutex
);
209 total_obj_size
= total_gtt_size
= count
= 0;
210 list_for_each_entry(vma
, head
, mm_list
) {
212 describe_obj(m
, vma
->obj
);
214 total_obj_size
+= vma
->obj
->base
.size
;
215 total_gtt_size
+= vma
->node
.size
;
218 mutex_unlock(&dev
->struct_mutex
);
220 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
221 count
, total_obj_size
, total_gtt_size
);
225 static int obj_rank_by_stolen(void *priv
,
226 struct list_head
*A
, struct list_head
*B
)
228 struct drm_i915_gem_object
*a
=
229 container_of(A
, struct drm_i915_gem_object
, obj_exec_link
);
230 struct drm_i915_gem_object
*b
=
231 container_of(B
, struct drm_i915_gem_object
, obj_exec_link
);
233 return a
->stolen
->start
- b
->stolen
->start
;
236 static int i915_gem_stolen_list_info(struct seq_file
*m
, void *data
)
238 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
239 struct drm_device
*dev
= node
->minor
->dev
;
240 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
241 struct drm_i915_gem_object
*obj
;
242 size_t total_obj_size
, total_gtt_size
;
246 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
250 total_obj_size
= total_gtt_size
= count
= 0;
251 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
252 if (obj
->stolen
== NULL
)
255 list_add(&obj
->obj_exec_link
, &stolen
);
257 total_obj_size
+= obj
->base
.size
;
258 total_gtt_size
+= i915_gem_obj_ggtt_size(obj
);
261 list_for_each_entry(obj
, &dev_priv
->mm
.unbound_list
, global_list
) {
262 if (obj
->stolen
== NULL
)
265 list_add(&obj
->obj_exec_link
, &stolen
);
267 total_obj_size
+= obj
->base
.size
;
270 list_sort(NULL
, &stolen
, obj_rank_by_stolen
);
271 seq_puts(m
, "Stolen:\n");
272 while (!list_empty(&stolen
)) {
273 obj
= list_first_entry(&stolen
, typeof(*obj
), obj_exec_link
);
275 describe_obj(m
, obj
);
277 list_del_init(&obj
->obj_exec_link
);
279 mutex_unlock(&dev
->struct_mutex
);
281 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
282 count
, total_obj_size
, total_gtt_size
);
286 #define count_objects(list, member) do { \
287 list_for_each_entry(obj, list, member) { \
288 size += i915_gem_obj_ggtt_size(obj); \
290 if (obj->map_and_fenceable) { \
291 mappable_size += i915_gem_obj_ggtt_size(obj); \
299 size_t total
, active
, inactive
, unbound
;
302 static int per_file_stats(int id
, void *ptr
, void *data
)
304 struct drm_i915_gem_object
*obj
= ptr
;
305 struct file_stats
*stats
= data
;
308 stats
->total
+= obj
->base
.size
;
310 if (i915_gem_obj_ggtt_bound(obj
)) {
311 if (!list_empty(&obj
->ring_list
))
312 stats
->active
+= obj
->base
.size
;
314 stats
->inactive
+= obj
->base
.size
;
316 if (!list_empty(&obj
->global_list
))
317 stats
->unbound
+= obj
->base
.size
;
323 #define count_vmas(list, member) do { \
324 list_for_each_entry(vma, list, member) { \
325 size += i915_gem_obj_ggtt_size(vma->obj); \
327 if (vma->obj->map_and_fenceable) { \
328 mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
334 static int i915_gem_object_info(struct seq_file
*m
, void* data
)
336 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
337 struct drm_device
*dev
= node
->minor
->dev
;
338 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
339 u32 count
, mappable_count
, purgeable_count
;
340 size_t size
, mappable_size
, purgeable_size
;
341 struct drm_i915_gem_object
*obj
;
342 struct i915_address_space
*vm
= &dev_priv
->gtt
.base
;
343 struct drm_file
*file
;
344 struct i915_vma
*vma
;
347 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
351 seq_printf(m
, "%u objects, %zu bytes\n",
352 dev_priv
->mm
.object_count
,
353 dev_priv
->mm
.object_memory
);
355 size
= count
= mappable_size
= mappable_count
= 0;
356 count_objects(&dev_priv
->mm
.bound_list
, global_list
);
357 seq_printf(m
, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
358 count
, mappable_count
, size
, mappable_size
);
360 size
= count
= mappable_size
= mappable_count
= 0;
361 count_vmas(&vm
->active_list
, mm_list
);
362 seq_printf(m
, " %u [%u] active objects, %zu [%zu] bytes\n",
363 count
, mappable_count
, size
, mappable_size
);
365 size
= count
= mappable_size
= mappable_count
= 0;
366 count_vmas(&vm
->inactive_list
, mm_list
);
367 seq_printf(m
, " %u [%u] inactive objects, %zu [%zu] bytes\n",
368 count
, mappable_count
, size
, mappable_size
);
370 size
= count
= purgeable_size
= purgeable_count
= 0;
371 list_for_each_entry(obj
, &dev_priv
->mm
.unbound_list
, global_list
) {
372 size
+= obj
->base
.size
, ++count
;
373 if (obj
->madv
== I915_MADV_DONTNEED
)
374 purgeable_size
+= obj
->base
.size
, ++purgeable_count
;
376 seq_printf(m
, "%u unbound objects, %zu bytes\n", count
, size
);
378 size
= count
= mappable_size
= mappable_count
= 0;
379 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
380 if (obj
->fault_mappable
) {
381 size
+= i915_gem_obj_ggtt_size(obj
);
384 if (obj
->pin_mappable
) {
385 mappable_size
+= i915_gem_obj_ggtt_size(obj
);
388 if (obj
->madv
== I915_MADV_DONTNEED
) {
389 purgeable_size
+= obj
->base
.size
;
393 seq_printf(m
, "%u purgeable objects, %zu bytes\n",
394 purgeable_count
, purgeable_size
);
395 seq_printf(m
, "%u pinned mappable objects, %zu bytes\n",
396 mappable_count
, mappable_size
);
397 seq_printf(m
, "%u fault mappable objects, %zu bytes\n",
400 seq_printf(m
, "%zu [%lu] gtt total\n",
401 dev_priv
->gtt
.base
.total
,
402 dev_priv
->gtt
.mappable_end
- dev_priv
->gtt
.base
.start
);
405 list_for_each_entry_reverse(file
, &dev
->filelist
, lhead
) {
406 struct file_stats stats
;
407 struct task_struct
*task
;
409 memset(&stats
, 0, sizeof(stats
));
410 idr_for_each(&file
->object_idr
, per_file_stats
, &stats
);
412 * Although we have a valid reference on file->pid, that does
413 * not guarantee that the task_struct who called get_pid() is
414 * still alive (e.g. get_pid(current) => fork() => exit()).
415 * Therefore, we need to protect this ->comm access using RCU.
418 task
= pid_task(file
->pid
, PIDTYPE_PID
);
419 seq_printf(m
, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu unbound)\n",
420 task
? task
->comm
: "<unknown>",
429 mutex_unlock(&dev
->struct_mutex
);
434 static int i915_gem_gtt_info(struct seq_file
*m
, void *data
)
436 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
437 struct drm_device
*dev
= node
->minor
->dev
;
438 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
439 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
440 struct drm_i915_gem_object
*obj
;
441 size_t total_obj_size
, total_gtt_size
;
444 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
448 total_obj_size
= total_gtt_size
= count
= 0;
449 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
450 if (list
== PINNED_LIST
&& obj
->pin_count
== 0)
454 describe_obj(m
, obj
);
456 total_obj_size
+= obj
->base
.size
;
457 total_gtt_size
+= i915_gem_obj_ggtt_size(obj
);
461 mutex_unlock(&dev
->struct_mutex
);
463 seq_printf(m
, "Total %d objects, %zu bytes, %zu GTT size\n",
464 count
, total_obj_size
, total_gtt_size
);
469 static int i915_gem_pageflip_info(struct seq_file
*m
, void *data
)
471 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
472 struct drm_device
*dev
= node
->minor
->dev
;
474 struct intel_crtc
*crtc
;
476 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, base
.head
) {
477 const char pipe
= pipe_name(crtc
->pipe
);
478 const char plane
= plane_name(crtc
->plane
);
479 struct intel_unpin_work
*work
;
481 spin_lock_irqsave(&dev
->event_lock
, flags
);
482 work
= crtc
->unpin_work
;
484 seq_printf(m
, "No flip due on pipe %c (plane %c)\n",
487 if (atomic_read(&work
->pending
) < INTEL_FLIP_COMPLETE
) {
488 seq_printf(m
, "Flip queued on pipe %c (plane %c)\n",
491 seq_printf(m
, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
494 if (work
->enable_stall_check
)
495 seq_puts(m
, "Stall check enabled, ");
497 seq_puts(m
, "Stall check waiting for page flip ioctl, ");
498 seq_printf(m
, "%d prepares\n", atomic_read(&work
->pending
));
500 if (work
->old_fb_obj
) {
501 struct drm_i915_gem_object
*obj
= work
->old_fb_obj
;
503 seq_printf(m
, "Old framebuffer gtt_offset 0x%08lx\n",
504 i915_gem_obj_ggtt_offset(obj
));
506 if (work
->pending_flip_obj
) {
507 struct drm_i915_gem_object
*obj
= work
->pending_flip_obj
;
509 seq_printf(m
, "New framebuffer gtt_offset 0x%08lx\n",
510 i915_gem_obj_ggtt_offset(obj
));
513 spin_unlock_irqrestore(&dev
->event_lock
, flags
);
519 static int i915_gem_request_info(struct seq_file
*m
, void *data
)
521 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
522 struct drm_device
*dev
= node
->minor
->dev
;
523 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
524 struct intel_ring_buffer
*ring
;
525 struct drm_i915_gem_request
*gem_request
;
528 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
533 for_each_ring(ring
, dev_priv
, i
) {
534 if (list_empty(&ring
->request_list
))
537 seq_printf(m
, "%s requests:\n", ring
->name
);
538 list_for_each_entry(gem_request
,
541 seq_printf(m
, " %d @ %d\n",
543 (int) (jiffies
- gem_request
->emitted_jiffies
));
547 mutex_unlock(&dev
->struct_mutex
);
550 seq_puts(m
, "No requests\n");
555 static void i915_ring_seqno_info(struct seq_file
*m
,
556 struct intel_ring_buffer
*ring
)
558 if (ring
->get_seqno
) {
559 seq_printf(m
, "Current sequence (%s): %u\n",
560 ring
->name
, ring
->get_seqno(ring
, false));
564 static int i915_gem_seqno_info(struct seq_file
*m
, void *data
)
566 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
567 struct drm_device
*dev
= node
->minor
->dev
;
568 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
569 struct intel_ring_buffer
*ring
;
572 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
575 intel_runtime_pm_get(dev_priv
);
577 for_each_ring(ring
, dev_priv
, i
)
578 i915_ring_seqno_info(m
, ring
);
580 intel_runtime_pm_put(dev_priv
);
581 mutex_unlock(&dev
->struct_mutex
);
587 static int i915_interrupt_info(struct seq_file
*m
, void *data
)
589 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
590 struct drm_device
*dev
= node
->minor
->dev
;
591 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
592 struct intel_ring_buffer
*ring
;
595 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
598 intel_runtime_pm_get(dev_priv
);
600 if (INTEL_INFO(dev
)->gen
>= 8) {
602 seq_printf(m
, "Master Interrupt Control:\t%08x\n",
603 I915_READ(GEN8_MASTER_IRQ
));
605 for (i
= 0; i
< 4; i
++) {
606 seq_printf(m
, "GT Interrupt IMR %d:\t%08x\n",
607 i
, I915_READ(GEN8_GT_IMR(i
)));
608 seq_printf(m
, "GT Interrupt IIR %d:\t%08x\n",
609 i
, I915_READ(GEN8_GT_IIR(i
)));
610 seq_printf(m
, "GT Interrupt IER %d:\t%08x\n",
611 i
, I915_READ(GEN8_GT_IER(i
)));
615 seq_printf(m
, "Pipe %c IMR:\t%08x\n",
617 I915_READ(GEN8_DE_PIPE_IMR(i
)));
618 seq_printf(m
, "Pipe %c IIR:\t%08x\n",
620 I915_READ(GEN8_DE_PIPE_IIR(i
)));
621 seq_printf(m
, "Pipe %c IER:\t%08x\n",
623 I915_READ(GEN8_DE_PIPE_IER(i
)));
626 seq_printf(m
, "Display Engine port interrupt mask:\t%08x\n",
627 I915_READ(GEN8_DE_PORT_IMR
));
628 seq_printf(m
, "Display Engine port interrupt identity:\t%08x\n",
629 I915_READ(GEN8_DE_PORT_IIR
));
630 seq_printf(m
, "Display Engine port interrupt enable:\t%08x\n",
631 I915_READ(GEN8_DE_PORT_IER
));
633 seq_printf(m
, "Display Engine misc interrupt mask:\t%08x\n",
634 I915_READ(GEN8_DE_MISC_IMR
));
635 seq_printf(m
, "Display Engine misc interrupt identity:\t%08x\n",
636 I915_READ(GEN8_DE_MISC_IIR
));
637 seq_printf(m
, "Display Engine misc interrupt enable:\t%08x\n",
638 I915_READ(GEN8_DE_MISC_IER
));
640 seq_printf(m
, "PCU interrupt mask:\t%08x\n",
641 I915_READ(GEN8_PCU_IMR
));
642 seq_printf(m
, "PCU interrupt identity:\t%08x\n",
643 I915_READ(GEN8_PCU_IIR
));
644 seq_printf(m
, "PCU interrupt enable:\t%08x\n",
645 I915_READ(GEN8_PCU_IER
));
646 } else if (IS_VALLEYVIEW(dev
)) {
647 seq_printf(m
, "Display IER:\t%08x\n",
649 seq_printf(m
, "Display IIR:\t%08x\n",
651 seq_printf(m
, "Display IIR_RW:\t%08x\n",
652 I915_READ(VLV_IIR_RW
));
653 seq_printf(m
, "Display IMR:\t%08x\n",
656 seq_printf(m
, "Pipe %c stat:\t%08x\n",
658 I915_READ(PIPESTAT(pipe
)));
660 seq_printf(m
, "Master IER:\t%08x\n",
661 I915_READ(VLV_MASTER_IER
));
663 seq_printf(m
, "Render IER:\t%08x\n",
665 seq_printf(m
, "Render IIR:\t%08x\n",
667 seq_printf(m
, "Render IMR:\t%08x\n",
670 seq_printf(m
, "PM IER:\t\t%08x\n",
671 I915_READ(GEN6_PMIER
));
672 seq_printf(m
, "PM IIR:\t\t%08x\n",
673 I915_READ(GEN6_PMIIR
));
674 seq_printf(m
, "PM IMR:\t\t%08x\n",
675 I915_READ(GEN6_PMIMR
));
677 seq_printf(m
, "Port hotplug:\t%08x\n",
678 I915_READ(PORT_HOTPLUG_EN
));
679 seq_printf(m
, "DPFLIPSTAT:\t%08x\n",
680 I915_READ(VLV_DPFLIPSTAT
));
681 seq_printf(m
, "DPINVGTT:\t%08x\n",
682 I915_READ(DPINVGTT
));
684 } else if (!HAS_PCH_SPLIT(dev
)) {
685 seq_printf(m
, "Interrupt enable: %08x\n",
687 seq_printf(m
, "Interrupt identity: %08x\n",
689 seq_printf(m
, "Interrupt mask: %08x\n",
692 seq_printf(m
, "Pipe %c stat: %08x\n",
694 I915_READ(PIPESTAT(pipe
)));
696 seq_printf(m
, "North Display Interrupt enable: %08x\n",
698 seq_printf(m
, "North Display Interrupt identity: %08x\n",
700 seq_printf(m
, "North Display Interrupt mask: %08x\n",
702 seq_printf(m
, "South Display Interrupt enable: %08x\n",
704 seq_printf(m
, "South Display Interrupt identity: %08x\n",
706 seq_printf(m
, "South Display Interrupt mask: %08x\n",
708 seq_printf(m
, "Graphics Interrupt enable: %08x\n",
710 seq_printf(m
, "Graphics Interrupt identity: %08x\n",
712 seq_printf(m
, "Graphics Interrupt mask: %08x\n",
715 seq_printf(m
, "Interrupts received: %d\n",
716 atomic_read(&dev_priv
->irq_received
));
717 for_each_ring(ring
, dev_priv
, i
) {
718 if (INTEL_INFO(dev
)->gen
>= 6) {
720 "Graphics Interrupt mask (%s): %08x\n",
721 ring
->name
, I915_READ_IMR(ring
));
723 i915_ring_seqno_info(m
, ring
);
725 intel_runtime_pm_put(dev_priv
);
726 mutex_unlock(&dev
->struct_mutex
);
731 static int i915_gem_fence_regs_info(struct seq_file
*m
, void *data
)
733 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
734 struct drm_device
*dev
= node
->minor
->dev
;
735 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
738 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
742 seq_printf(m
, "Reserved fences = %d\n", dev_priv
->fence_reg_start
);
743 seq_printf(m
, "Total fences = %d\n", dev_priv
->num_fence_regs
);
744 for (i
= 0; i
< dev_priv
->num_fence_regs
; i
++) {
745 struct drm_i915_gem_object
*obj
= dev_priv
->fence_regs
[i
].obj
;
747 seq_printf(m
, "Fence %d, pin count = %d, object = ",
748 i
, dev_priv
->fence_regs
[i
].pin_count
);
750 seq_puts(m
, "unused");
752 describe_obj(m
, obj
);
756 mutex_unlock(&dev
->struct_mutex
);
760 static int i915_hws_info(struct seq_file
*m
, void *data
)
762 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
763 struct drm_device
*dev
= node
->minor
->dev
;
764 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
765 struct intel_ring_buffer
*ring
;
769 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
770 hws
= ring
->status_page
.page_addr
;
774 for (i
= 0; i
< 4096 / sizeof(u32
) / 4; i
+= 4) {
775 seq_printf(m
, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
777 hws
[i
], hws
[i
+ 1], hws
[i
+ 2], hws
[i
+ 3]);
783 i915_error_state_write(struct file
*filp
,
784 const char __user
*ubuf
,
788 struct i915_error_state_file_priv
*error_priv
= filp
->private_data
;
789 struct drm_device
*dev
= error_priv
->dev
;
792 DRM_DEBUG_DRIVER("Resetting error state\n");
794 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
798 i915_destroy_error_state(dev
);
799 mutex_unlock(&dev
->struct_mutex
);
804 static int i915_error_state_open(struct inode
*inode
, struct file
*file
)
806 struct drm_device
*dev
= inode
->i_private
;
807 struct i915_error_state_file_priv
*error_priv
;
809 error_priv
= kzalloc(sizeof(*error_priv
), GFP_KERNEL
);
813 error_priv
->dev
= dev
;
815 i915_error_state_get(dev
, error_priv
);
817 file
->private_data
= error_priv
;
822 static int i915_error_state_release(struct inode
*inode
, struct file
*file
)
824 struct i915_error_state_file_priv
*error_priv
= file
->private_data
;
826 i915_error_state_put(error_priv
);
832 static ssize_t
i915_error_state_read(struct file
*file
, char __user
*userbuf
,
833 size_t count
, loff_t
*pos
)
835 struct i915_error_state_file_priv
*error_priv
= file
->private_data
;
836 struct drm_i915_error_state_buf error_str
;
838 ssize_t ret_count
= 0;
841 ret
= i915_error_state_buf_init(&error_str
, count
, *pos
);
845 ret
= i915_error_state_to_str(&error_str
, error_priv
);
849 ret_count
= simple_read_from_buffer(userbuf
, count
, &tmp_pos
,
856 *pos
= error_str
.start
+ ret_count
;
858 i915_error_state_buf_release(&error_str
);
859 return ret
?: ret_count
;
862 static const struct file_operations i915_error_state_fops
= {
863 .owner
= THIS_MODULE
,
864 .open
= i915_error_state_open
,
865 .read
= i915_error_state_read
,
866 .write
= i915_error_state_write
,
867 .llseek
= default_llseek
,
868 .release
= i915_error_state_release
,
872 i915_next_seqno_get(void *data
, u64
*val
)
874 struct drm_device
*dev
= data
;
875 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
878 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
882 *val
= dev_priv
->next_seqno
;
883 mutex_unlock(&dev
->struct_mutex
);
889 i915_next_seqno_set(void *data
, u64 val
)
891 struct drm_device
*dev
= data
;
894 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
898 ret
= i915_gem_set_seqno(dev
, val
);
899 mutex_unlock(&dev
->struct_mutex
);
904 DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops
,
905 i915_next_seqno_get
, i915_next_seqno_set
,
908 static int i915_rstdby_delays(struct seq_file
*m
, void *unused
)
910 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
911 struct drm_device
*dev
= node
->minor
->dev
;
912 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
916 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
919 intel_runtime_pm_get(dev_priv
);
921 crstanddelay
= I915_READ16(CRSTANDVID
);
923 intel_runtime_pm_put(dev_priv
);
924 mutex_unlock(&dev
->struct_mutex
);
926 seq_printf(m
, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay
>> 8) & 0x3f, (crstanddelay
& 0x3f));
931 static int i915_cur_delayinfo(struct seq_file
*m
, void *unused
)
933 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
934 struct drm_device
*dev
= node
->minor
->dev
;
935 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
938 intel_runtime_pm_get(dev_priv
);
940 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
943 u16 rgvswctl
= I915_READ16(MEMSWCTL
);
944 u16 rgvstat
= I915_READ16(MEMSTAT_ILK
);
946 seq_printf(m
, "Requested P-state: %d\n", (rgvswctl
>> 8) & 0xf);
947 seq_printf(m
, "Requested VID: %d\n", rgvswctl
& 0x3f);
948 seq_printf(m
, "Current VID: %d\n", (rgvstat
& MEMSTAT_VID_MASK
) >>
950 seq_printf(m
, "Current P-state: %d\n",
951 (rgvstat
& MEMSTAT_PSTATE_MASK
) >> MEMSTAT_PSTATE_SHIFT
);
952 } else if ((IS_GEN6(dev
) || IS_GEN7(dev
)) && !IS_VALLEYVIEW(dev
)) {
953 u32 gt_perf_status
= I915_READ(GEN6_GT_PERF_STATUS
);
954 u32 rp_state_limits
= I915_READ(GEN6_RP_STATE_LIMITS
);
955 u32 rp_state_cap
= I915_READ(GEN6_RP_STATE_CAP
);
956 u32 rpstat
, cagf
, reqf
;
957 u32 rpupei
, rpcurup
, rpprevup
;
958 u32 rpdownei
, rpcurdown
, rpprevdown
;
961 /* RPSTAT1 is in the GT power well */
962 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
966 gen6_gt_force_wake_get(dev_priv
, FORCEWAKE_ALL
);
968 reqf
= I915_READ(GEN6_RPNSWREQ
);
969 reqf
&= ~GEN6_TURBO_DISABLE
;
974 reqf
*= GT_FREQUENCY_MULTIPLIER
;
976 rpstat
= I915_READ(GEN6_RPSTAT1
);
977 rpupei
= I915_READ(GEN6_RP_CUR_UP_EI
);
978 rpcurup
= I915_READ(GEN6_RP_CUR_UP
);
979 rpprevup
= I915_READ(GEN6_RP_PREV_UP
);
980 rpdownei
= I915_READ(GEN6_RP_CUR_DOWN_EI
);
981 rpcurdown
= I915_READ(GEN6_RP_CUR_DOWN
);
982 rpprevdown
= I915_READ(GEN6_RP_PREV_DOWN
);
984 cagf
= (rpstat
& HSW_CAGF_MASK
) >> HSW_CAGF_SHIFT
;
986 cagf
= (rpstat
& GEN6_CAGF_MASK
) >> GEN6_CAGF_SHIFT
;
987 cagf
*= GT_FREQUENCY_MULTIPLIER
;
989 gen6_gt_force_wake_put(dev_priv
, FORCEWAKE_ALL
);
990 mutex_unlock(&dev
->struct_mutex
);
992 seq_printf(m
, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status
);
993 seq_printf(m
, "RPSTAT1: 0x%08x\n", rpstat
);
994 seq_printf(m
, "Render p-state ratio: %d\n",
995 (gt_perf_status
& 0xff00) >> 8);
996 seq_printf(m
, "Render p-state VID: %d\n",
997 gt_perf_status
& 0xff);
998 seq_printf(m
, "Render p-state limit: %d\n",
999 rp_state_limits
& 0xff);
1000 seq_printf(m
, "RPNSWREQ: %dMHz\n", reqf
);
1001 seq_printf(m
, "CAGF: %dMHz\n", cagf
);
1002 seq_printf(m
, "RP CUR UP EI: %dus\n", rpupei
&
1003 GEN6_CURICONT_MASK
);
1004 seq_printf(m
, "RP CUR UP: %dus\n", rpcurup
&
1005 GEN6_CURBSYTAVG_MASK
);
1006 seq_printf(m
, "RP PREV UP: %dus\n", rpprevup
&
1007 GEN6_CURBSYTAVG_MASK
);
1008 seq_printf(m
, "RP CUR DOWN EI: %dus\n", rpdownei
&
1010 seq_printf(m
, "RP CUR DOWN: %dus\n", rpcurdown
&
1011 GEN6_CURBSYTAVG_MASK
);
1012 seq_printf(m
, "RP PREV DOWN: %dus\n", rpprevdown
&
1013 GEN6_CURBSYTAVG_MASK
);
1015 max_freq
= (rp_state_cap
& 0xff0000) >> 16;
1016 seq_printf(m
, "Lowest (RPN) frequency: %dMHz\n",
1017 max_freq
* GT_FREQUENCY_MULTIPLIER
);
1019 max_freq
= (rp_state_cap
& 0xff00) >> 8;
1020 seq_printf(m
, "Nominal (RP1) frequency: %dMHz\n",
1021 max_freq
* GT_FREQUENCY_MULTIPLIER
);
1023 max_freq
= rp_state_cap
& 0xff;
1024 seq_printf(m
, "Max non-overclocked (RP0) frequency: %dMHz\n",
1025 max_freq
* GT_FREQUENCY_MULTIPLIER
);
1027 seq_printf(m
, "Max overclocked frequency: %dMHz\n",
1028 dev_priv
->rps
.hw_max
* GT_FREQUENCY_MULTIPLIER
);
1029 } else if (IS_VALLEYVIEW(dev
)) {
1032 mutex_lock(&dev_priv
->rps
.hw_lock
);
1033 freq_sts
= vlv_punit_read(dev_priv
, PUNIT_REG_GPU_FREQ_STS
);
1034 seq_printf(m
, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts
);
1035 seq_printf(m
, "DDR freq: %d MHz\n", dev_priv
->mem_freq
);
1037 val
= valleyview_rps_max_freq(dev_priv
);
1038 seq_printf(m
, "max GPU freq: %d MHz\n",
1039 vlv_gpu_freq(dev_priv
, val
));
1041 val
= valleyview_rps_min_freq(dev_priv
);
1042 seq_printf(m
, "min GPU freq: %d MHz\n",
1043 vlv_gpu_freq(dev_priv
, val
));
1045 seq_printf(m
, "current GPU freq: %d MHz\n",
1046 vlv_gpu_freq(dev_priv
, (freq_sts
>> 8) & 0xff));
1047 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1049 seq_puts(m
, "no P-state info available\n");
1053 intel_runtime_pm_put(dev_priv
);
1057 static int i915_delayfreq_table(struct seq_file
*m
, void *unused
)
1059 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1060 struct drm_device
*dev
= node
->minor
->dev
;
1061 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1065 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1068 intel_runtime_pm_get(dev_priv
);
1070 for (i
= 0; i
< 16; i
++) {
1071 delayfreq
= I915_READ(PXVFREQ_BASE
+ i
* 4);
1072 seq_printf(m
, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i
, delayfreq
,
1073 (delayfreq
& PXVFREQ_PX_MASK
) >> PXVFREQ_PX_SHIFT
);
1076 intel_runtime_pm_put(dev_priv
);
1078 mutex_unlock(&dev
->struct_mutex
);
1083 static inline int MAP_TO_MV(int map
)
1085 return 1250 - (map
* 25);
1088 static int i915_inttoext_table(struct seq_file
*m
, void *unused
)
1090 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1091 struct drm_device
*dev
= node
->minor
->dev
;
1092 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1096 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1099 intel_runtime_pm_get(dev_priv
);
1101 for (i
= 1; i
<= 32; i
++) {
1102 inttoext
= I915_READ(INTTOEXT_BASE_ILK
+ i
* 4);
1103 seq_printf(m
, "INTTOEXT%02d: 0x%08x\n", i
, inttoext
);
1106 intel_runtime_pm_put(dev_priv
);
1107 mutex_unlock(&dev
->struct_mutex
);
1112 static int ironlake_drpc_info(struct seq_file
*m
)
1114 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1115 struct drm_device
*dev
= node
->minor
->dev
;
1116 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1117 u32 rgvmodectl
, rstdbyctl
;
1121 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1124 intel_runtime_pm_get(dev_priv
);
1126 rgvmodectl
= I915_READ(MEMMODECTL
);
1127 rstdbyctl
= I915_READ(RSTDBYCTL
);
1128 crstandvid
= I915_READ16(CRSTANDVID
);
1130 intel_runtime_pm_put(dev_priv
);
1131 mutex_unlock(&dev
->struct_mutex
);
1133 seq_printf(m
, "HD boost: %s\n", (rgvmodectl
& MEMMODE_BOOST_EN
) ?
1135 seq_printf(m
, "Boost freq: %d\n",
1136 (rgvmodectl
& MEMMODE_BOOST_FREQ_MASK
) >>
1137 MEMMODE_BOOST_FREQ_SHIFT
);
1138 seq_printf(m
, "HW control enabled: %s\n",
1139 rgvmodectl
& MEMMODE_HWIDLE_EN
? "yes" : "no");
1140 seq_printf(m
, "SW control enabled: %s\n",
1141 rgvmodectl
& MEMMODE_SWMODE_EN
? "yes" : "no");
1142 seq_printf(m
, "Gated voltage change: %s\n",
1143 rgvmodectl
& MEMMODE_RCLK_GATE
? "yes" : "no");
1144 seq_printf(m
, "Starting frequency: P%d\n",
1145 (rgvmodectl
& MEMMODE_FSTART_MASK
) >> MEMMODE_FSTART_SHIFT
);
1146 seq_printf(m
, "Max P-state: P%d\n",
1147 (rgvmodectl
& MEMMODE_FMAX_MASK
) >> MEMMODE_FMAX_SHIFT
);
1148 seq_printf(m
, "Min P-state: P%d\n", (rgvmodectl
& MEMMODE_FMIN_MASK
));
1149 seq_printf(m
, "RS1 VID: %d\n", (crstandvid
& 0x3f));
1150 seq_printf(m
, "RS2 VID: %d\n", ((crstandvid
>> 8) & 0x3f));
1151 seq_printf(m
, "Render standby enabled: %s\n",
1152 (rstdbyctl
& RCX_SW_EXIT
) ? "no" : "yes");
1153 seq_puts(m
, "Current RS state: ");
1154 switch (rstdbyctl
& RSX_STATUS_MASK
) {
1156 seq_puts(m
, "on\n");
1158 case RSX_STATUS_RC1
:
1159 seq_puts(m
, "RC1\n");
1161 case RSX_STATUS_RC1E
:
1162 seq_puts(m
, "RC1E\n");
1164 case RSX_STATUS_RS1
:
1165 seq_puts(m
, "RS1\n");
1167 case RSX_STATUS_RS2
:
1168 seq_puts(m
, "RS2 (RC6)\n");
1170 case RSX_STATUS_RS3
:
1171 seq_puts(m
, "RC3 (RC6+)\n");
1174 seq_puts(m
, "unknown\n");
1181 static int vlv_drpc_info(struct seq_file
*m
)
1184 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1185 struct drm_device
*dev
= node
->minor
->dev
;
1186 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1187 u32 rpmodectl1
, rcctl1
;
1188 unsigned fw_rendercount
= 0, fw_mediacount
= 0;
1190 rpmodectl1
= I915_READ(GEN6_RP_CONTROL
);
1191 rcctl1
= I915_READ(GEN6_RC_CONTROL
);
1193 seq_printf(m
, "Video Turbo Mode: %s\n",
1194 yesno(rpmodectl1
& GEN6_RP_MEDIA_TURBO
));
1195 seq_printf(m
, "Turbo enabled: %s\n",
1196 yesno(rpmodectl1
& GEN6_RP_ENABLE
));
1197 seq_printf(m
, "HW control enabled: %s\n",
1198 yesno(rpmodectl1
& GEN6_RP_ENABLE
));
1199 seq_printf(m
, "SW control enabled: %s\n",
1200 yesno((rpmodectl1
& GEN6_RP_MEDIA_MODE_MASK
) ==
1201 GEN6_RP_MEDIA_SW_MODE
));
1202 seq_printf(m
, "RC6 Enabled: %s\n",
1203 yesno(rcctl1
& (GEN7_RC_CTL_TO_MODE
|
1204 GEN6_RC_CTL_EI_MODE(1))));
1205 seq_printf(m
, "Render Power Well: %s\n",
1206 (I915_READ(VLV_GTLC_PW_STATUS
) &
1207 VLV_GTLC_PW_RENDER_STATUS_MASK
) ? "Up" : "Down");
1208 seq_printf(m
, "Media Power Well: %s\n",
1209 (I915_READ(VLV_GTLC_PW_STATUS
) &
1210 VLV_GTLC_PW_MEDIA_STATUS_MASK
) ? "Up" : "Down");
1212 spin_lock_irq(&dev_priv
->uncore
.lock
);
1213 fw_rendercount
= dev_priv
->uncore
.fw_rendercount
;
1214 fw_mediacount
= dev_priv
->uncore
.fw_mediacount
;
1215 spin_unlock_irq(&dev_priv
->uncore
.lock
);
1217 seq_printf(m
, "Forcewake Render Count = %u\n", fw_rendercount
);
1218 seq_printf(m
, "Forcewake Media Count = %u\n", fw_mediacount
);
1225 static int gen6_drpc_info(struct seq_file
*m
)
1228 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1229 struct drm_device
*dev
= node
->minor
->dev
;
1230 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1231 u32 rpmodectl1
, gt_core_status
, rcctl1
, rc6vids
= 0;
1232 unsigned forcewake_count
;
1235 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1238 intel_runtime_pm_get(dev_priv
);
1240 spin_lock_irq(&dev_priv
->uncore
.lock
);
1241 forcewake_count
= dev_priv
->uncore
.forcewake_count
;
1242 spin_unlock_irq(&dev_priv
->uncore
.lock
);
1244 if (forcewake_count
) {
1245 seq_puts(m
, "RC information inaccurate because somebody "
1246 "holds a forcewake reference \n");
1248 /* NB: we cannot use forcewake, else we read the wrong values */
1249 while (count
++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK
) & 1))
1251 seq_printf(m
, "RC information accurate: %s\n", yesno(count
< 51));
1254 gt_core_status
= readl(dev_priv
->regs
+ GEN6_GT_CORE_STATUS
);
1255 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS
, gt_core_status
, 4, true);
1257 rpmodectl1
= I915_READ(GEN6_RP_CONTROL
);
1258 rcctl1
= I915_READ(GEN6_RC_CONTROL
);
1259 mutex_unlock(&dev
->struct_mutex
);
1260 mutex_lock(&dev_priv
->rps
.hw_lock
);
1261 sandybridge_pcode_read(dev_priv
, GEN6_PCODE_READ_RC6VIDS
, &rc6vids
);
1262 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1264 intel_runtime_pm_put(dev_priv
);
1266 seq_printf(m
, "Video Turbo Mode: %s\n",
1267 yesno(rpmodectl1
& GEN6_RP_MEDIA_TURBO
));
1268 seq_printf(m
, "HW control enabled: %s\n",
1269 yesno(rpmodectl1
& GEN6_RP_ENABLE
));
1270 seq_printf(m
, "SW control enabled: %s\n",
1271 yesno((rpmodectl1
& GEN6_RP_MEDIA_MODE_MASK
) ==
1272 GEN6_RP_MEDIA_SW_MODE
));
1273 seq_printf(m
, "RC1e Enabled: %s\n",
1274 yesno(rcctl1
& GEN6_RC_CTL_RC1e_ENABLE
));
1275 seq_printf(m
, "RC6 Enabled: %s\n",
1276 yesno(rcctl1
& GEN6_RC_CTL_RC6_ENABLE
));
1277 seq_printf(m
, "Deep RC6 Enabled: %s\n",
1278 yesno(rcctl1
& GEN6_RC_CTL_RC6p_ENABLE
));
1279 seq_printf(m
, "Deepest RC6 Enabled: %s\n",
1280 yesno(rcctl1
& GEN6_RC_CTL_RC6pp_ENABLE
));
1281 seq_puts(m
, "Current RC state: ");
1282 switch (gt_core_status
& GEN6_RCn_MASK
) {
1284 if (gt_core_status
& GEN6_CORE_CPD_STATE_MASK
)
1285 seq_puts(m
, "Core Power Down\n");
1287 seq_puts(m
, "on\n");
1290 seq_puts(m
, "RC3\n");
1293 seq_puts(m
, "RC6\n");
1296 seq_puts(m
, "RC7\n");
1299 seq_puts(m
, "Unknown\n");
1303 seq_printf(m
, "Core Power Down: %s\n",
1304 yesno(gt_core_status
& GEN6_CORE_CPD_STATE_MASK
));
1306 /* Not exactly sure what this is */
1307 seq_printf(m
, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1308 I915_READ(GEN6_GT_GFX_RC6_LOCKED
));
1309 seq_printf(m
, "RC6 residency since boot: %u\n",
1310 I915_READ(GEN6_GT_GFX_RC6
));
1311 seq_printf(m
, "RC6+ residency since boot: %u\n",
1312 I915_READ(GEN6_GT_GFX_RC6p
));
1313 seq_printf(m
, "RC6++ residency since boot: %u\n",
1314 I915_READ(GEN6_GT_GFX_RC6pp
));
1316 seq_printf(m
, "RC6 voltage: %dmV\n",
1317 GEN6_DECODE_RC6_VID(((rc6vids
>> 0) & 0xff)));
1318 seq_printf(m
, "RC6+ voltage: %dmV\n",
1319 GEN6_DECODE_RC6_VID(((rc6vids
>> 8) & 0xff)));
1320 seq_printf(m
, "RC6++ voltage: %dmV\n",
1321 GEN6_DECODE_RC6_VID(((rc6vids
>> 16) & 0xff)));
1325 static int i915_drpc_info(struct seq_file
*m
, void *unused
)
1327 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1328 struct drm_device
*dev
= node
->minor
->dev
;
1330 if (IS_VALLEYVIEW(dev
))
1331 return vlv_drpc_info(m
);
1332 else if (IS_GEN6(dev
) || IS_GEN7(dev
))
1333 return gen6_drpc_info(m
);
1335 return ironlake_drpc_info(m
);
1338 static int i915_fbc_status(struct seq_file
*m
, void *unused
)
1340 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1341 struct drm_device
*dev
= node
->minor
->dev
;
1342 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1344 if (!HAS_FBC(dev
)) {
1345 seq_puts(m
, "FBC unsupported on this chipset\n");
1349 if (intel_fbc_enabled(dev
)) {
1350 seq_puts(m
, "FBC enabled\n");
1352 seq_puts(m
, "FBC disabled: ");
1353 switch (dev_priv
->fbc
.no_fbc_reason
) {
1355 seq_puts(m
, "FBC actived, but currently disabled in hardware");
1357 case FBC_UNSUPPORTED
:
1358 seq_puts(m
, "unsupported by this chipset");
1361 seq_puts(m
, "no outputs");
1363 case FBC_STOLEN_TOO_SMALL
:
1364 seq_puts(m
, "not enough stolen memory");
1366 case FBC_UNSUPPORTED_MODE
:
1367 seq_puts(m
, "mode not supported");
1369 case FBC_MODE_TOO_LARGE
:
1370 seq_puts(m
, "mode too large");
1373 seq_puts(m
, "FBC unsupported on plane");
1376 seq_puts(m
, "scanout buffer not tiled");
1378 case FBC_MULTIPLE_PIPES
:
1379 seq_puts(m
, "multiple pipes are enabled");
1381 case FBC_MODULE_PARAM
:
1382 seq_puts(m
, "disabled per module param (default off)");
1384 case FBC_CHIP_DEFAULT
:
1385 seq_puts(m
, "disabled per chip default");
1388 seq_puts(m
, "unknown reason");
1395 static int i915_ips_status(struct seq_file
*m
, void *unused
)
1397 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1398 struct drm_device
*dev
= node
->minor
->dev
;
1399 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1401 if (!HAS_IPS(dev
)) {
1402 seq_puts(m
, "not supported\n");
1406 if (IS_BROADWELL(dev
) || I915_READ(IPS_CTL
) & IPS_ENABLE
)
1407 seq_puts(m
, "enabled\n");
1409 seq_puts(m
, "disabled\n");
1414 static int i915_sr_status(struct seq_file
*m
, void *unused
)
1416 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1417 struct drm_device
*dev
= node
->minor
->dev
;
1418 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1419 bool sr_enabled
= false;
1421 if (HAS_PCH_SPLIT(dev
))
1422 sr_enabled
= I915_READ(WM1_LP_ILK
) & WM1_LP_SR_EN
;
1423 else if (IS_CRESTLINE(dev
) || IS_I945G(dev
) || IS_I945GM(dev
))
1424 sr_enabled
= I915_READ(FW_BLC_SELF
) & FW_BLC_SELF_EN
;
1425 else if (IS_I915GM(dev
))
1426 sr_enabled
= I915_READ(INSTPM
) & INSTPM_SELF_EN
;
1427 else if (IS_PINEVIEW(dev
))
1428 sr_enabled
= I915_READ(DSPFW3
) & PINEVIEW_SELF_REFRESH_EN
;
1430 seq_printf(m
, "self-refresh: %s\n",
1431 sr_enabled
? "enabled" : "disabled");
1436 static int i915_emon_status(struct seq_file
*m
, void *unused
)
1438 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1439 struct drm_device
*dev
= node
->minor
->dev
;
1440 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1441 unsigned long temp
, chipset
, gfx
;
1447 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1451 temp
= i915_mch_val(dev_priv
);
1452 chipset
= i915_chipset_val(dev_priv
);
1453 gfx
= i915_gfx_val(dev_priv
);
1454 mutex_unlock(&dev
->struct_mutex
);
1456 seq_printf(m
, "GMCH temp: %ld\n", temp
);
1457 seq_printf(m
, "Chipset power: %ld\n", chipset
);
1458 seq_printf(m
, "GFX power: %ld\n", gfx
);
1459 seq_printf(m
, "Total power: %ld\n", chipset
+ gfx
);
1464 static int i915_ring_freq_table(struct seq_file
*m
, void *unused
)
1466 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1467 struct drm_device
*dev
= node
->minor
->dev
;
1468 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1470 int gpu_freq
, ia_freq
;
1472 if (!(IS_GEN6(dev
) || IS_GEN7(dev
))) {
1473 seq_puts(m
, "unsupported on this chipset\n");
1477 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
1479 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
1482 intel_runtime_pm_get(dev_priv
);
1484 seq_puts(m
, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
1486 for (gpu_freq
= dev_priv
->rps
.min_delay
;
1487 gpu_freq
<= dev_priv
->rps
.max_delay
;
1490 sandybridge_pcode_read(dev_priv
,
1491 GEN6_PCODE_READ_MIN_FREQ_TABLE
,
1493 seq_printf(m
, "%d\t\t%d\t\t\t\t%d\n",
1494 gpu_freq
* GT_FREQUENCY_MULTIPLIER
,
1495 ((ia_freq
>> 0) & 0xff) * 100,
1496 ((ia_freq
>> 8) & 0xff) * 100);
1499 intel_runtime_pm_put(dev_priv
);
1500 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1505 static int i915_gfxec(struct seq_file
*m
, void *unused
)
1507 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1508 struct drm_device
*dev
= node
->minor
->dev
;
1509 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1512 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1515 intel_runtime_pm_get(dev_priv
);
1517 seq_printf(m
, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
1518 intel_runtime_pm_put(dev_priv
);
1520 mutex_unlock(&dev
->struct_mutex
);
1525 static int i915_opregion(struct seq_file
*m
, void *unused
)
1527 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1528 struct drm_device
*dev
= node
->minor
->dev
;
1529 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1530 struct intel_opregion
*opregion
= &dev_priv
->opregion
;
1531 void *data
= kmalloc(OPREGION_SIZE
, GFP_KERNEL
);
1537 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1541 if (opregion
->header
) {
1542 memcpy_fromio(data
, opregion
->header
, OPREGION_SIZE
);
1543 seq_write(m
, data
, OPREGION_SIZE
);
1546 mutex_unlock(&dev
->struct_mutex
);
1553 static int i915_gem_framebuffer_info(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 intel_fbdev
*ifbdev
= NULL
;
1558 struct intel_framebuffer
*fb
;
1560 #ifdef CONFIG_DRM_I915_FBDEV
1561 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1562 int ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1566 ifbdev
= dev_priv
->fbdev
;
1567 fb
= to_intel_framebuffer(ifbdev
->helper
.fb
);
1569 seq_printf(m
, "fbcon size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
1573 fb
->base
.bits_per_pixel
,
1574 atomic_read(&fb
->base
.refcount
.refcount
));
1575 describe_obj(m
, fb
->obj
);
1577 mutex_unlock(&dev
->mode_config
.mutex
);
1580 mutex_lock(&dev
->mode_config
.fb_lock
);
1581 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, base
.head
) {
1582 if (ifbdev
&& &fb
->base
== ifbdev
->helper
.fb
)
1585 seq_printf(m
, "user size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
1589 fb
->base
.bits_per_pixel
,
1590 atomic_read(&fb
->base
.refcount
.refcount
));
1591 describe_obj(m
, fb
->obj
);
1594 mutex_unlock(&dev
->mode_config
.fb_lock
);
1599 static int i915_context_status(struct seq_file
*m
, void *unused
)
1601 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1602 struct drm_device
*dev
= node
->minor
->dev
;
1603 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
1604 struct intel_ring_buffer
*ring
;
1605 struct i915_hw_context
*ctx
;
1608 ret
= mutex_lock_interruptible(&dev
->mode_config
.mutex
);
1612 if (dev_priv
->ips
.pwrctx
) {
1613 seq_puts(m
, "power context ");
1614 describe_obj(m
, dev_priv
->ips
.pwrctx
);
1618 if (dev_priv
->ips
.renderctx
) {
1619 seq_puts(m
, "render context ");
1620 describe_obj(m
, dev_priv
->ips
.renderctx
);
1624 list_for_each_entry(ctx
, &dev_priv
->context_list
, link
) {
1625 seq_puts(m
, "HW context ");
1626 describe_ctx(m
, ctx
);
1627 for_each_ring(ring
, dev_priv
, i
)
1628 if (ring
->default_context
== ctx
)
1629 seq_printf(m
, "(default context %s) ", ring
->name
);
1631 describe_obj(m
, ctx
->obj
);
1635 mutex_unlock(&dev
->mode_config
.mutex
);
1640 static int i915_gen6_forcewake_count_info(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
;
1645 unsigned forcewake_count
= 0, fw_rendercount
= 0, fw_mediacount
= 0;
1647 spin_lock_irq(&dev_priv
->uncore
.lock
);
1648 if (IS_VALLEYVIEW(dev
)) {
1649 fw_rendercount
= dev_priv
->uncore
.fw_rendercount
;
1650 fw_mediacount
= dev_priv
->uncore
.fw_mediacount
;
1652 forcewake_count
= dev_priv
->uncore
.forcewake_count
;
1653 spin_unlock_irq(&dev_priv
->uncore
.lock
);
1655 if (IS_VALLEYVIEW(dev
)) {
1656 seq_printf(m
, "fw_rendercount = %u\n", fw_rendercount
);
1657 seq_printf(m
, "fw_mediacount = %u\n", fw_mediacount
);
1659 seq_printf(m
, "forcewake count = %u\n", forcewake_count
);
1664 static const char *swizzle_string(unsigned swizzle
)
1667 case I915_BIT_6_SWIZZLE_NONE
:
1669 case I915_BIT_6_SWIZZLE_9
:
1671 case I915_BIT_6_SWIZZLE_9_10
:
1672 return "bit9/bit10";
1673 case I915_BIT_6_SWIZZLE_9_11
:
1674 return "bit9/bit11";
1675 case I915_BIT_6_SWIZZLE_9_10_11
:
1676 return "bit9/bit10/bit11";
1677 case I915_BIT_6_SWIZZLE_9_17
:
1678 return "bit9/bit17";
1679 case I915_BIT_6_SWIZZLE_9_10_17
:
1680 return "bit9/bit10/bit17";
1681 case I915_BIT_6_SWIZZLE_UNKNOWN
:
1688 static int i915_swizzle_info(struct seq_file
*m
, void *data
)
1690 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1691 struct drm_device
*dev
= node
->minor
->dev
;
1692 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1695 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1698 intel_runtime_pm_get(dev_priv
);
1700 seq_printf(m
, "bit6 swizzle for X-tiling = %s\n",
1701 swizzle_string(dev_priv
->mm
.bit_6_swizzle_x
));
1702 seq_printf(m
, "bit6 swizzle for Y-tiling = %s\n",
1703 swizzle_string(dev_priv
->mm
.bit_6_swizzle_y
));
1705 if (IS_GEN3(dev
) || IS_GEN4(dev
)) {
1706 seq_printf(m
, "DDC = 0x%08x\n",
1708 seq_printf(m
, "C0DRB3 = 0x%04x\n",
1709 I915_READ16(C0DRB3
));
1710 seq_printf(m
, "C1DRB3 = 0x%04x\n",
1711 I915_READ16(C1DRB3
));
1712 } else if (INTEL_INFO(dev
)->gen
>= 6) {
1713 seq_printf(m
, "MAD_DIMM_C0 = 0x%08x\n",
1714 I915_READ(MAD_DIMM_C0
));
1715 seq_printf(m
, "MAD_DIMM_C1 = 0x%08x\n",
1716 I915_READ(MAD_DIMM_C1
));
1717 seq_printf(m
, "MAD_DIMM_C2 = 0x%08x\n",
1718 I915_READ(MAD_DIMM_C2
));
1719 seq_printf(m
, "TILECTL = 0x%08x\n",
1720 I915_READ(TILECTL
));
1722 seq_printf(m
, "GAMTARBMODE = 0x%08x\n",
1723 I915_READ(GAMTARBMODE
));
1725 seq_printf(m
, "ARB_MODE = 0x%08x\n",
1726 I915_READ(ARB_MODE
));
1727 seq_printf(m
, "DISP_ARB_CTL = 0x%08x\n",
1728 I915_READ(DISP_ARB_CTL
));
1730 intel_runtime_pm_put(dev_priv
);
1731 mutex_unlock(&dev
->struct_mutex
);
1736 static void gen8_ppgtt_info(struct seq_file
*m
, struct drm_device
*dev
)
1738 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1739 struct intel_ring_buffer
*ring
;
1740 struct i915_hw_ppgtt
*ppgtt
= dev_priv
->mm
.aliasing_ppgtt
;
1746 seq_printf(m
, "Page directories: %d\n", ppgtt
->num_pd_pages
);
1747 seq_printf(m
, "Page tables: %d\n", ppgtt
->num_pt_pages
);
1748 for_each_ring(ring
, dev_priv
, unused
) {
1749 seq_printf(m
, "%s\n", ring
->name
);
1750 for (i
= 0; i
< 4; i
++) {
1751 u32 offset
= 0x270 + i
* 8;
1752 u64 pdp
= I915_READ(ring
->mmio_base
+ offset
+ 4);
1754 pdp
|= I915_READ(ring
->mmio_base
+ offset
);
1755 for (i
= 0; i
< 4; i
++)
1756 seq_printf(m
, "\tPDP%d 0x%016llx\n", i
, pdp
);
1761 static void gen6_ppgtt_info(struct seq_file
*m
, struct drm_device
*dev
)
1763 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1764 struct intel_ring_buffer
*ring
;
1767 if (INTEL_INFO(dev
)->gen
== 6)
1768 seq_printf(m
, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE
));
1770 for_each_ring(ring
, dev_priv
, i
) {
1771 seq_printf(m
, "%s\n", ring
->name
);
1772 if (INTEL_INFO(dev
)->gen
== 7)
1773 seq_printf(m
, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring
)));
1774 seq_printf(m
, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring
)));
1775 seq_printf(m
, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring
)));
1776 seq_printf(m
, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring
)));
1778 if (dev_priv
->mm
.aliasing_ppgtt
) {
1779 struct i915_hw_ppgtt
*ppgtt
= dev_priv
->mm
.aliasing_ppgtt
;
1781 seq_puts(m
, "aliasing PPGTT:\n");
1782 seq_printf(m
, "pd gtt offset: 0x%08x\n", ppgtt
->pd_offset
);
1784 seq_printf(m
, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK
));
1787 static int i915_ppgtt_info(struct seq_file
*m
, void *data
)
1789 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1790 struct drm_device
*dev
= node
->minor
->dev
;
1791 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1793 int ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1796 intel_runtime_pm_get(dev_priv
);
1798 if (INTEL_INFO(dev
)->gen
>= 8)
1799 gen8_ppgtt_info(m
, dev
);
1800 else if (INTEL_INFO(dev
)->gen
>= 6)
1801 gen6_ppgtt_info(m
, dev
);
1803 intel_runtime_pm_put(dev_priv
);
1804 mutex_unlock(&dev
->struct_mutex
);
1809 static int i915_dpio_info(struct seq_file
*m
, void *data
)
1811 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1812 struct drm_device
*dev
= node
->minor
->dev
;
1813 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1817 if (!IS_VALLEYVIEW(dev
)) {
1818 seq_puts(m
, "unsupported\n");
1822 ret
= mutex_lock_interruptible(&dev_priv
->dpio_lock
);
1826 seq_printf(m
, "DPIO_CTL: 0x%08x\n", I915_READ(DPIO_CTL
));
1828 seq_printf(m
, "DPIO PLL DW3 CH0 : 0x%08x\n",
1829 vlv_dpio_read(dev_priv
, PIPE_A
, VLV_PLL_DW3(0)));
1830 seq_printf(m
, "DPIO PLL DW3 CH1: 0x%08x\n",
1831 vlv_dpio_read(dev_priv
, PIPE_A
, VLV_PLL_DW3(1)));
1833 seq_printf(m
, "DPIO PLL DW5 CH0: 0x%08x\n",
1834 vlv_dpio_read(dev_priv
, PIPE_A
, VLV_PLL_DW5(0)));
1835 seq_printf(m
, "DPIO PLL DW5 CH1: 0x%08x\n",
1836 vlv_dpio_read(dev_priv
, PIPE_A
, VLV_PLL_DW5(1)));
1838 seq_printf(m
, "DPIO PLL DW7 CH0: 0x%08x\n",
1839 vlv_dpio_read(dev_priv
, PIPE_A
, VLV_PLL_DW7(0)));
1840 seq_printf(m
, "DPIO PLL DW7 CH1: 0x%08x\n",
1841 vlv_dpio_read(dev_priv
, PIPE_A
, VLV_PLL_DW7(1)));
1843 seq_printf(m
, "DPIO PLL DW10 CH0: 0x%08x\n",
1844 vlv_dpio_read(dev_priv
, PIPE_A
, VLV_PLL_DW10(0)));
1845 seq_printf(m
, "DPIO PLL DW10 CH1: 0x%08x\n",
1846 vlv_dpio_read(dev_priv
, PIPE_A
, VLV_PLL_DW10(1)));
1848 seq_printf(m
, "DPIO_FASTCLK_DISABLE: 0x%08x\n",
1849 vlv_dpio_read(dev_priv
, PIPE_A
, VLV_CMN_DW0
));
1851 mutex_unlock(&dev_priv
->dpio_lock
);
1856 static int i915_llc(struct seq_file
*m
, void *data
)
1858 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1859 struct drm_device
*dev
= node
->minor
->dev
;
1860 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1862 /* Size calculation for LLC is a bit of a pain. Ignore for now. */
1863 seq_printf(m
, "LLC: %s\n", yesno(HAS_LLC(dev
)));
1864 seq_printf(m
, "eLLC: %zuMB\n", dev_priv
->ellc_size
);
1869 static int i915_edp_psr_status(struct seq_file
*m
, void *data
)
1871 struct drm_info_node
*node
= m
->private;
1872 struct drm_device
*dev
= node
->minor
->dev
;
1873 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1875 bool enabled
= false;
1877 intel_runtime_pm_get(dev_priv
);
1879 seq_printf(m
, "Sink_Support: %s\n", yesno(dev_priv
->psr
.sink_support
));
1880 seq_printf(m
, "Source_OK: %s\n", yesno(dev_priv
->psr
.source_ok
));
1882 enabled
= HAS_PSR(dev
) &&
1883 I915_READ(EDP_PSR_CTL(dev
)) & EDP_PSR_ENABLE
;
1884 seq_printf(m
, "Enabled: %s\n", yesno(enabled
));
1887 psrperf
= I915_READ(EDP_PSR_PERF_CNT(dev
)) &
1888 EDP_PSR_PERF_CNT_MASK
;
1889 seq_printf(m
, "Performance_Counter: %u\n", psrperf
);
1891 intel_runtime_pm_put(dev_priv
);
1895 static int i915_energy_uJ(struct seq_file
*m
, void *data
)
1897 struct drm_info_node
*node
= m
->private;
1898 struct drm_device
*dev
= node
->minor
->dev
;
1899 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1903 if (INTEL_INFO(dev
)->gen
< 6)
1906 rdmsrl(MSR_RAPL_POWER_UNIT
, power
);
1907 power
= (power
& 0x1f00) >> 8;
1908 units
= 1000000 / (1 << power
); /* convert to uJ */
1909 power
= I915_READ(MCH_SECP_NRG_STTS
);
1912 seq_printf(m
, "%llu", (long long unsigned)power
);
1917 static int i915_pc8_status(struct seq_file
*m
, void *unused
)
1919 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1920 struct drm_device
*dev
= node
->minor
->dev
;
1921 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1923 if (!IS_HASWELL(dev
)) {
1924 seq_puts(m
, "not supported\n");
1928 mutex_lock(&dev_priv
->pc8
.lock
);
1929 seq_printf(m
, "Requirements met: %s\n",
1930 yesno(dev_priv
->pc8
.requirements_met
));
1931 seq_printf(m
, "GPU idle: %s\n", yesno(dev_priv
->pc8
.gpu_idle
));
1932 seq_printf(m
, "Disable count: %d\n", dev_priv
->pc8
.disable_count
);
1933 seq_printf(m
, "IRQs disabled: %s\n",
1934 yesno(dev_priv
->pc8
.irqs_disabled
));
1935 seq_printf(m
, "Enabled: %s\n", yesno(dev_priv
->pc8
.enabled
));
1936 mutex_unlock(&dev_priv
->pc8
.lock
);
1941 static const char *power_domain_str(enum intel_display_power_domain domain
)
1944 case POWER_DOMAIN_PIPE_A
:
1946 case POWER_DOMAIN_PIPE_B
:
1948 case POWER_DOMAIN_PIPE_C
:
1950 case POWER_DOMAIN_PIPE_A_PANEL_FITTER
:
1951 return "PIPE_A_PANEL_FITTER";
1952 case POWER_DOMAIN_PIPE_B_PANEL_FITTER
:
1953 return "PIPE_B_PANEL_FITTER";
1954 case POWER_DOMAIN_PIPE_C_PANEL_FITTER
:
1955 return "PIPE_C_PANEL_FITTER";
1956 case POWER_DOMAIN_TRANSCODER_A
:
1957 return "TRANSCODER_A";
1958 case POWER_DOMAIN_TRANSCODER_B
:
1959 return "TRANSCODER_B";
1960 case POWER_DOMAIN_TRANSCODER_C
:
1961 return "TRANSCODER_C";
1962 case POWER_DOMAIN_TRANSCODER_EDP
:
1963 return "TRANSCODER_EDP";
1964 case POWER_DOMAIN_VGA
:
1966 case POWER_DOMAIN_AUDIO
:
1968 case POWER_DOMAIN_INIT
:
1976 static int i915_power_domain_info(struct seq_file
*m
, void *unused
)
1978 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1979 struct drm_device
*dev
= node
->minor
->dev
;
1980 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1981 struct i915_power_domains
*power_domains
= &dev_priv
->power_domains
;
1984 mutex_lock(&power_domains
->lock
);
1986 seq_printf(m
, "%-25s %s\n", "Power well/domain", "Use count");
1987 for (i
= 0; i
< power_domains
->power_well_count
; i
++) {
1988 struct i915_power_well
*power_well
;
1989 enum intel_display_power_domain power_domain
;
1991 power_well
= &power_domains
->power_wells
[i
];
1992 seq_printf(m
, "%-25s %d\n", power_well
->name
,
1995 for (power_domain
= 0; power_domain
< POWER_DOMAIN_NUM
;
1997 if (!(BIT(power_domain
) & power_well
->domains
))
2000 seq_printf(m
, " %-23s %d\n",
2001 power_domain_str(power_domain
),
2002 power_domains
->domain_use_count
[power_domain
]);
2006 mutex_unlock(&power_domains
->lock
);
2011 struct pipe_crc_info
{
2013 struct drm_device
*dev
;
2017 static int i915_pipe_crc_open(struct inode
*inode
, struct file
*filep
)
2019 struct pipe_crc_info
*info
= inode
->i_private
;
2020 struct drm_i915_private
*dev_priv
= info
->dev
->dev_private
;
2021 struct intel_pipe_crc
*pipe_crc
= &dev_priv
->pipe_crc
[info
->pipe
];
2023 if (info
->pipe
>= INTEL_INFO(info
->dev
)->num_pipes
)
2026 spin_lock_irq(&pipe_crc
->lock
);
2028 if (pipe_crc
->opened
) {
2029 spin_unlock_irq(&pipe_crc
->lock
);
2030 return -EBUSY
; /* already open */
2033 pipe_crc
->opened
= true;
2034 filep
->private_data
= inode
->i_private
;
2036 spin_unlock_irq(&pipe_crc
->lock
);
2041 static int i915_pipe_crc_release(struct inode
*inode
, struct file
*filep
)
2043 struct pipe_crc_info
*info
= inode
->i_private
;
2044 struct drm_i915_private
*dev_priv
= info
->dev
->dev_private
;
2045 struct intel_pipe_crc
*pipe_crc
= &dev_priv
->pipe_crc
[info
->pipe
];
2047 spin_lock_irq(&pipe_crc
->lock
);
2048 pipe_crc
->opened
= false;
2049 spin_unlock_irq(&pipe_crc
->lock
);
2054 /* (6 fields, 8 chars each, space separated (5) + '\n') */
2055 #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1)
2056 /* account for \'0' */
2057 #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1)
2059 static int pipe_crc_data_count(struct intel_pipe_crc
*pipe_crc
)
2061 assert_spin_locked(&pipe_crc
->lock
);
2062 return CIRC_CNT(pipe_crc
->head
, pipe_crc
->tail
,
2063 INTEL_PIPE_CRC_ENTRIES_NR
);
2067 i915_pipe_crc_read(struct file
*filep
, char __user
*user_buf
, size_t count
,
2070 struct pipe_crc_info
*info
= filep
->private_data
;
2071 struct drm_device
*dev
= info
->dev
;
2072 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2073 struct intel_pipe_crc
*pipe_crc
= &dev_priv
->pipe_crc
[info
->pipe
];
2074 char buf
[PIPE_CRC_BUFFER_LEN
];
2075 int head
, tail
, n_entries
, n
;
2079 * Don't allow user space to provide buffers not big enough to hold
2082 if (count
< PIPE_CRC_LINE_LEN
)
2085 if (pipe_crc
->source
== INTEL_PIPE_CRC_SOURCE_NONE
)
2088 /* nothing to read */
2089 spin_lock_irq(&pipe_crc
->lock
);
2090 while (pipe_crc_data_count(pipe_crc
) == 0) {
2093 if (filep
->f_flags
& O_NONBLOCK
) {
2094 spin_unlock_irq(&pipe_crc
->lock
);
2098 ret
= wait_event_interruptible_lock_irq(pipe_crc
->wq
,
2099 pipe_crc_data_count(pipe_crc
), pipe_crc
->lock
);
2101 spin_unlock_irq(&pipe_crc
->lock
);
2106 /* We now have one or more entries to read */
2107 head
= pipe_crc
->head
;
2108 tail
= pipe_crc
->tail
;
2109 n_entries
= min((size_t)CIRC_CNT(head
, tail
, INTEL_PIPE_CRC_ENTRIES_NR
),
2110 count
/ PIPE_CRC_LINE_LEN
);
2111 spin_unlock_irq(&pipe_crc
->lock
);
2116 struct intel_pipe_crc_entry
*entry
= &pipe_crc
->entries
[tail
];
2119 bytes_read
+= snprintf(buf
, PIPE_CRC_BUFFER_LEN
,
2120 "%8u %8x %8x %8x %8x %8x\n",
2121 entry
->frame
, entry
->crc
[0],
2122 entry
->crc
[1], entry
->crc
[2],
2123 entry
->crc
[3], entry
->crc
[4]);
2125 ret
= copy_to_user(user_buf
+ n
* PIPE_CRC_LINE_LEN
,
2126 buf
, PIPE_CRC_LINE_LEN
);
2127 if (ret
== PIPE_CRC_LINE_LEN
)
2130 BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR
);
2131 tail
= (tail
+ 1) & (INTEL_PIPE_CRC_ENTRIES_NR
- 1);
2133 } while (--n_entries
);
2135 spin_lock_irq(&pipe_crc
->lock
);
2136 pipe_crc
->tail
= tail
;
2137 spin_unlock_irq(&pipe_crc
->lock
);
2142 static const struct file_operations i915_pipe_crc_fops
= {
2143 .owner
= THIS_MODULE
,
2144 .open
= i915_pipe_crc_open
,
2145 .read
= i915_pipe_crc_read
,
2146 .release
= i915_pipe_crc_release
,
2149 static struct pipe_crc_info i915_pipe_crc_data
[I915_MAX_PIPES
] = {
2151 .name
= "i915_pipe_A_crc",
2155 .name
= "i915_pipe_B_crc",
2159 .name
= "i915_pipe_C_crc",
2164 static int i915_pipe_crc_create(struct dentry
*root
, struct drm_minor
*minor
,
2167 struct drm_device
*dev
= minor
->dev
;
2169 struct pipe_crc_info
*info
= &i915_pipe_crc_data
[pipe
];
2172 ent
= debugfs_create_file(info
->name
, S_IRUGO
, root
, info
,
2173 &i915_pipe_crc_fops
);
2177 return drm_add_fake_info_node(minor
, ent
, info
);
2180 static const char * const pipe_crc_sources
[] = {
2193 static const char *pipe_crc_source_name(enum intel_pipe_crc_source source
)
2195 BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources
) != INTEL_PIPE_CRC_SOURCE_MAX
);
2196 return pipe_crc_sources
[source
];
2199 static int display_crc_ctl_show(struct seq_file
*m
, void *data
)
2201 struct drm_device
*dev
= m
->private;
2202 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2205 for (i
= 0; i
< I915_MAX_PIPES
; i
++)
2206 seq_printf(m
, "%c %s\n", pipe_name(i
),
2207 pipe_crc_source_name(dev_priv
->pipe_crc
[i
].source
));
2212 static int display_crc_ctl_open(struct inode
*inode
, struct file
*file
)
2214 struct drm_device
*dev
= inode
->i_private
;
2216 return single_open(file
, display_crc_ctl_show
, dev
);
2219 static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source
*source
,
2222 if (*source
== INTEL_PIPE_CRC_SOURCE_AUTO
)
2223 *source
= INTEL_PIPE_CRC_SOURCE_PIPE
;
2226 case INTEL_PIPE_CRC_SOURCE_PIPE
:
2227 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_INCLUDE_BORDER_I8XX
;
2229 case INTEL_PIPE_CRC_SOURCE_NONE
:
2239 static int i9xx_pipe_crc_auto_source(struct drm_device
*dev
, enum pipe pipe
,
2240 enum intel_pipe_crc_source
*source
)
2242 struct intel_encoder
*encoder
;
2243 struct intel_crtc
*crtc
;
2244 struct intel_digital_port
*dig_port
;
2247 *source
= INTEL_PIPE_CRC_SOURCE_PIPE
;
2249 mutex_lock(&dev
->mode_config
.mutex
);
2250 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
,
2252 if (!encoder
->base
.crtc
)
2255 crtc
= to_intel_crtc(encoder
->base
.crtc
);
2257 if (crtc
->pipe
!= pipe
)
2260 switch (encoder
->type
) {
2261 case INTEL_OUTPUT_TVOUT
:
2262 *source
= INTEL_PIPE_CRC_SOURCE_TV
;
2264 case INTEL_OUTPUT_DISPLAYPORT
:
2265 case INTEL_OUTPUT_EDP
:
2266 dig_port
= enc_to_dig_port(&encoder
->base
);
2267 switch (dig_port
->port
) {
2269 *source
= INTEL_PIPE_CRC_SOURCE_DP_B
;
2272 *source
= INTEL_PIPE_CRC_SOURCE_DP_C
;
2275 *source
= INTEL_PIPE_CRC_SOURCE_DP_D
;
2278 WARN(1, "nonexisting DP port %c\n",
2279 port_name(dig_port
->port
));
2285 mutex_unlock(&dev
->mode_config
.mutex
);
2290 static int vlv_pipe_crc_ctl_reg(struct drm_device
*dev
,
2292 enum intel_pipe_crc_source
*source
,
2295 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2296 bool need_stable_symbols
= false;
2298 if (*source
== INTEL_PIPE_CRC_SOURCE_AUTO
) {
2299 int ret
= i9xx_pipe_crc_auto_source(dev
, pipe
, source
);
2305 case INTEL_PIPE_CRC_SOURCE_PIPE
:
2306 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PIPE_VLV
;
2308 case INTEL_PIPE_CRC_SOURCE_DP_B
:
2309 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_B_VLV
;
2310 need_stable_symbols
= true;
2312 case INTEL_PIPE_CRC_SOURCE_DP_C
:
2313 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_C_VLV
;
2314 need_stable_symbols
= true;
2316 case INTEL_PIPE_CRC_SOURCE_NONE
:
2324 * When the pipe CRC tap point is after the transcoders we need
2325 * to tweak symbol-level features to produce a deterministic series of
2326 * symbols for a given frame. We need to reset those features only once
2327 * a frame (instead of every nth symbol):
2328 * - DC-balance: used to ensure a better clock recovery from the data
2330 * - DisplayPort scrambling: used for EMI reduction
2332 if (need_stable_symbols
) {
2333 uint32_t tmp
= I915_READ(PORT_DFT2_G4X
);
2335 WARN_ON(!IS_G4X(dev
));
2337 tmp
|= DC_BALANCE_RESET_VLV
;
2339 tmp
|= PIPE_A_SCRAMBLE_RESET
;
2341 tmp
|= PIPE_B_SCRAMBLE_RESET
;
2343 I915_WRITE(PORT_DFT2_G4X
, tmp
);
2349 static int i9xx_pipe_crc_ctl_reg(struct drm_device
*dev
,
2351 enum intel_pipe_crc_source
*source
,
2354 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2355 bool need_stable_symbols
= false;
2357 if (*source
== INTEL_PIPE_CRC_SOURCE_AUTO
) {
2358 int ret
= i9xx_pipe_crc_auto_source(dev
, pipe
, source
);
2364 case INTEL_PIPE_CRC_SOURCE_PIPE
:
2365 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PIPE_I9XX
;
2367 case INTEL_PIPE_CRC_SOURCE_TV
:
2368 if (!SUPPORTS_TV(dev
))
2370 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_TV_PRE
;
2372 case INTEL_PIPE_CRC_SOURCE_DP_B
:
2375 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_B_G4X
;
2376 need_stable_symbols
= true;
2378 case INTEL_PIPE_CRC_SOURCE_DP_C
:
2381 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_C_G4X
;
2382 need_stable_symbols
= true;
2384 case INTEL_PIPE_CRC_SOURCE_DP_D
:
2387 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_D_G4X
;
2388 need_stable_symbols
= true;
2390 case INTEL_PIPE_CRC_SOURCE_NONE
:
2398 * When the pipe CRC tap point is after the transcoders we need
2399 * to tweak symbol-level features to produce a deterministic series of
2400 * symbols for a given frame. We need to reset those features only once
2401 * a frame (instead of every nth symbol):
2402 * - DC-balance: used to ensure a better clock recovery from the data
2404 * - DisplayPort scrambling: used for EMI reduction
2406 if (need_stable_symbols
) {
2407 uint32_t tmp
= I915_READ(PORT_DFT2_G4X
);
2409 WARN_ON(!IS_G4X(dev
));
2411 I915_WRITE(PORT_DFT_I9XX
,
2412 I915_READ(PORT_DFT_I9XX
) | DC_BALANCE_RESET
);
2415 tmp
|= PIPE_A_SCRAMBLE_RESET
;
2417 tmp
|= PIPE_B_SCRAMBLE_RESET
;
2419 I915_WRITE(PORT_DFT2_G4X
, tmp
);
2425 static void vlv_undo_pipe_scramble_reset(struct drm_device
*dev
,
2428 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2429 uint32_t tmp
= I915_READ(PORT_DFT2_G4X
);
2432 tmp
&= ~PIPE_A_SCRAMBLE_RESET
;
2434 tmp
&= ~PIPE_B_SCRAMBLE_RESET
;
2435 if (!(tmp
& PIPE_SCRAMBLE_RESET_MASK
))
2436 tmp
&= ~DC_BALANCE_RESET_VLV
;
2437 I915_WRITE(PORT_DFT2_G4X
, tmp
);
2441 static void g4x_undo_pipe_scramble_reset(struct drm_device
*dev
,
2444 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2445 uint32_t tmp
= I915_READ(PORT_DFT2_G4X
);
2448 tmp
&= ~PIPE_A_SCRAMBLE_RESET
;
2450 tmp
&= ~PIPE_B_SCRAMBLE_RESET
;
2451 I915_WRITE(PORT_DFT2_G4X
, tmp
);
2453 if (!(tmp
& PIPE_SCRAMBLE_RESET_MASK
)) {
2454 I915_WRITE(PORT_DFT_I9XX
,
2455 I915_READ(PORT_DFT_I9XX
) & ~DC_BALANCE_RESET
);
2459 static int ilk_pipe_crc_ctl_reg(enum intel_pipe_crc_source
*source
,
2462 if (*source
== INTEL_PIPE_CRC_SOURCE_AUTO
)
2463 *source
= INTEL_PIPE_CRC_SOURCE_PIPE
;
2466 case INTEL_PIPE_CRC_SOURCE_PLANE1
:
2467 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PRIMARY_ILK
;
2469 case INTEL_PIPE_CRC_SOURCE_PLANE2
:
2470 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_SPRITE_ILK
;
2472 case INTEL_PIPE_CRC_SOURCE_PIPE
:
2473 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PIPE_ILK
;
2475 case INTEL_PIPE_CRC_SOURCE_NONE
:
2485 static int ivb_pipe_crc_ctl_reg(enum intel_pipe_crc_source
*source
,
2488 if (*source
== INTEL_PIPE_CRC_SOURCE_AUTO
)
2489 *source
= INTEL_PIPE_CRC_SOURCE_PF
;
2492 case INTEL_PIPE_CRC_SOURCE_PLANE1
:
2493 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PRIMARY_IVB
;
2495 case INTEL_PIPE_CRC_SOURCE_PLANE2
:
2496 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_SPRITE_IVB
;
2498 case INTEL_PIPE_CRC_SOURCE_PF
:
2499 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PF_IVB
;
2501 case INTEL_PIPE_CRC_SOURCE_NONE
:
2511 static int pipe_crc_set_source(struct drm_device
*dev
, enum pipe pipe
,
2512 enum intel_pipe_crc_source source
)
2514 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2515 struct intel_pipe_crc
*pipe_crc
= &dev_priv
->pipe_crc
[pipe
];
2516 u32 val
= 0; /* shut up gcc */
2519 if (pipe_crc
->source
== source
)
2522 /* forbid changing the source without going back to 'none' */
2523 if (pipe_crc
->source
&& source
)
2527 ret
= i8xx_pipe_crc_ctl_reg(&source
, &val
);
2528 else if (INTEL_INFO(dev
)->gen
< 5)
2529 ret
= i9xx_pipe_crc_ctl_reg(dev
, pipe
, &source
, &val
);
2530 else if (IS_VALLEYVIEW(dev
))
2531 ret
= vlv_pipe_crc_ctl_reg(dev
,pipe
, &source
, &val
);
2532 else if (IS_GEN5(dev
) || IS_GEN6(dev
))
2533 ret
= ilk_pipe_crc_ctl_reg(&source
, &val
);
2535 ret
= ivb_pipe_crc_ctl_reg(&source
, &val
);
2540 /* none -> real source transition */
2542 DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n",
2543 pipe_name(pipe
), pipe_crc_source_name(source
));
2545 pipe_crc
->entries
= kzalloc(sizeof(*pipe_crc
->entries
) *
2546 INTEL_PIPE_CRC_ENTRIES_NR
,
2548 if (!pipe_crc
->entries
)
2551 spin_lock_irq(&pipe_crc
->lock
);
2554 spin_unlock_irq(&pipe_crc
->lock
);
2557 pipe_crc
->source
= source
;
2559 I915_WRITE(PIPE_CRC_CTL(pipe
), val
);
2560 POSTING_READ(PIPE_CRC_CTL(pipe
));
2562 /* real source -> none transition */
2563 if (source
== INTEL_PIPE_CRC_SOURCE_NONE
) {
2564 struct intel_pipe_crc_entry
*entries
;
2566 DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n",
2569 intel_wait_for_vblank(dev
, pipe
);
2571 spin_lock_irq(&pipe_crc
->lock
);
2572 entries
= pipe_crc
->entries
;
2573 pipe_crc
->entries
= NULL
;
2574 spin_unlock_irq(&pipe_crc
->lock
);
2579 g4x_undo_pipe_scramble_reset(dev
, pipe
);
2580 else if (IS_VALLEYVIEW(dev
))
2581 vlv_undo_pipe_scramble_reset(dev
, pipe
);
2588 * Parse pipe CRC command strings:
2589 * command: wsp* object wsp+ name wsp+ source wsp*
2592 * source: (none | plane1 | plane2 | pf)
2593 * wsp: (#0x20 | #0x9 | #0xA)+
2596 * "pipe A plane1" -> Start CRC computations on plane1 of pipe A
2597 * "pipe A none" -> Stop CRC
2599 static int display_crc_ctl_tokenize(char *buf
, char *words
[], int max_words
)
2606 /* skip leading white space */
2607 buf
= skip_spaces(buf
);
2609 break; /* end of buffer */
2611 /* find end of word */
2612 for (end
= buf
; *end
&& !isspace(*end
); end
++)
2615 if (n_words
== max_words
) {
2616 DRM_DEBUG_DRIVER("too many words, allowed <= %d\n",
2618 return -EINVAL
; /* ran out of words[] before bytes */
2623 words
[n_words
++] = buf
;
2630 enum intel_pipe_crc_object
{
2631 PIPE_CRC_OBJECT_PIPE
,
2634 static const char * const pipe_crc_objects
[] = {
2639 display_crc_ctl_parse_object(const char *buf
, enum intel_pipe_crc_object
*o
)
2643 for (i
= 0; i
< ARRAY_SIZE(pipe_crc_objects
); i
++)
2644 if (!strcmp(buf
, pipe_crc_objects
[i
])) {
2652 static int display_crc_ctl_parse_pipe(const char *buf
, enum pipe
*pipe
)
2654 const char name
= buf
[0];
2656 if (name
< 'A' || name
>= pipe_name(I915_MAX_PIPES
))
2665 display_crc_ctl_parse_source(const char *buf
, enum intel_pipe_crc_source
*s
)
2669 for (i
= 0; i
< ARRAY_SIZE(pipe_crc_sources
); i
++)
2670 if (!strcmp(buf
, pipe_crc_sources
[i
])) {
2678 static int display_crc_ctl_parse(struct drm_device
*dev
, char *buf
, size_t len
)
2682 char *words
[N_WORDS
];
2684 enum intel_pipe_crc_object object
;
2685 enum intel_pipe_crc_source source
;
2687 n_words
= display_crc_ctl_tokenize(buf
, words
, N_WORDS
);
2688 if (n_words
!= N_WORDS
) {
2689 DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n",
2694 if (display_crc_ctl_parse_object(words
[0], &object
) < 0) {
2695 DRM_DEBUG_DRIVER("unknown object %s\n", words
[0]);
2699 if (display_crc_ctl_parse_pipe(words
[1], &pipe
) < 0) {
2700 DRM_DEBUG_DRIVER("unknown pipe %s\n", words
[1]);
2704 if (display_crc_ctl_parse_source(words
[2], &source
) < 0) {
2705 DRM_DEBUG_DRIVER("unknown source %s\n", words
[2]);
2709 return pipe_crc_set_source(dev
, pipe
, source
);
2712 static ssize_t
display_crc_ctl_write(struct file
*file
, const char __user
*ubuf
,
2713 size_t len
, loff_t
*offp
)
2715 struct seq_file
*m
= file
->private_data
;
2716 struct drm_device
*dev
= m
->private;
2723 if (len
> PAGE_SIZE
- 1) {
2724 DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n",
2729 tmpbuf
= kmalloc(len
+ 1, GFP_KERNEL
);
2733 if (copy_from_user(tmpbuf
, ubuf
, len
)) {
2739 ret
= display_crc_ctl_parse(dev
, tmpbuf
, len
);
2750 static const struct file_operations i915_display_crc_ctl_fops
= {
2751 .owner
= THIS_MODULE
,
2752 .open
= display_crc_ctl_open
,
2754 .llseek
= seq_lseek
,
2755 .release
= single_release
,
2756 .write
= display_crc_ctl_write
2760 i915_wedged_get(void *data
, u64
*val
)
2762 struct drm_device
*dev
= data
;
2763 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
2765 *val
= atomic_read(&dev_priv
->gpu_error
.reset_counter
);
2771 i915_wedged_set(void *data
, u64 val
)
2773 struct drm_device
*dev
= data
;
2775 DRM_INFO("Manually setting wedged to %llu\n", val
);
2776 i915_handle_error(dev
, val
);
2781 DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops
,
2782 i915_wedged_get
, i915_wedged_set
,
2786 i915_ring_stop_get(void *data
, u64
*val
)
2788 struct drm_device
*dev
= data
;
2789 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
2791 *val
= dev_priv
->gpu_error
.stop_rings
;
2797 i915_ring_stop_set(void *data
, u64 val
)
2799 struct drm_device
*dev
= data
;
2800 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2803 DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val
);
2805 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
2809 dev_priv
->gpu_error
.stop_rings
= val
;
2810 mutex_unlock(&dev
->struct_mutex
);
2815 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops
,
2816 i915_ring_stop_get
, i915_ring_stop_set
,
2820 i915_ring_missed_irq_get(void *data
, u64
*val
)
2822 struct drm_device
*dev
= data
;
2823 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2825 *val
= dev_priv
->gpu_error
.missed_irq_rings
;
2830 i915_ring_missed_irq_set(void *data
, u64 val
)
2832 struct drm_device
*dev
= data
;
2833 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2836 /* Lock against concurrent debugfs callers */
2837 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
2840 dev_priv
->gpu_error
.missed_irq_rings
= val
;
2841 mutex_unlock(&dev
->struct_mutex
);
2846 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops
,
2847 i915_ring_missed_irq_get
, i915_ring_missed_irq_set
,
2851 i915_ring_test_irq_get(void *data
, u64
*val
)
2853 struct drm_device
*dev
= data
;
2854 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2856 *val
= dev_priv
->gpu_error
.test_irq_rings
;
2862 i915_ring_test_irq_set(void *data
, u64 val
)
2864 struct drm_device
*dev
= data
;
2865 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2868 DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val
);
2870 /* Lock against concurrent debugfs callers */
2871 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
2875 dev_priv
->gpu_error
.test_irq_rings
= val
;
2876 mutex_unlock(&dev
->struct_mutex
);
2881 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops
,
2882 i915_ring_test_irq_get
, i915_ring_test_irq_set
,
2885 #define DROP_UNBOUND 0x1
2886 #define DROP_BOUND 0x2
2887 #define DROP_RETIRE 0x4
2888 #define DROP_ACTIVE 0x8
2889 #define DROP_ALL (DROP_UNBOUND | \
2894 i915_drop_caches_get(void *data
, u64
*val
)
2902 i915_drop_caches_set(void *data
, u64 val
)
2904 struct drm_device
*dev
= data
;
2905 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2906 struct drm_i915_gem_object
*obj
, *next
;
2907 struct i915_address_space
*vm
;
2908 struct i915_vma
*vma
, *x
;
2911 DRM_DEBUG("Dropping caches: 0x%08llx\n", val
);
2913 /* No need to check and wait for gpu resets, only libdrm auto-restarts
2914 * on ioctls on -EAGAIN. */
2915 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
2919 if (val
& DROP_ACTIVE
) {
2920 ret
= i915_gpu_idle(dev
);
2925 if (val
& (DROP_RETIRE
| DROP_ACTIVE
))
2926 i915_gem_retire_requests(dev
);
2928 if (val
& DROP_BOUND
) {
2929 list_for_each_entry(vm
, &dev_priv
->vm_list
, global_link
) {
2930 list_for_each_entry_safe(vma
, x
, &vm
->inactive_list
,
2932 if (vma
->obj
->pin_count
)
2935 ret
= i915_vma_unbind(vma
);
2942 if (val
& DROP_UNBOUND
) {
2943 list_for_each_entry_safe(obj
, next
, &dev_priv
->mm
.unbound_list
,
2945 if (obj
->pages_pin_count
== 0) {
2946 ret
= i915_gem_object_put_pages(obj
);
2953 mutex_unlock(&dev
->struct_mutex
);
2958 DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops
,
2959 i915_drop_caches_get
, i915_drop_caches_set
,
2963 i915_max_freq_get(void *data
, u64
*val
)
2965 struct drm_device
*dev
= data
;
2966 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
2969 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
2972 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
2974 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
2978 if (IS_VALLEYVIEW(dev
))
2979 *val
= vlv_gpu_freq(dev_priv
, dev_priv
->rps
.max_delay
);
2981 *val
= dev_priv
->rps
.max_delay
* GT_FREQUENCY_MULTIPLIER
;
2982 mutex_unlock(&dev_priv
->rps
.hw_lock
);
2988 i915_max_freq_set(void *data
, u64 val
)
2990 struct drm_device
*dev
= data
;
2991 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2994 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
2997 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
2999 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val
);
3001 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
3006 * Turbo will still be enabled, but won't go above the set value.
3008 if (IS_VALLEYVIEW(dev
)) {
3009 val
= vlv_freq_opcode(dev_priv
, val
);
3010 dev_priv
->rps
.max_delay
= val
;
3011 valleyview_set_rps(dev
, val
);
3013 do_div(val
, GT_FREQUENCY_MULTIPLIER
);
3014 dev_priv
->rps
.max_delay
= val
;
3015 gen6_set_rps(dev
, val
);
3018 mutex_unlock(&dev_priv
->rps
.hw_lock
);
3023 DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops
,
3024 i915_max_freq_get
, i915_max_freq_set
,
3028 i915_min_freq_get(void *data
, u64
*val
)
3030 struct drm_device
*dev
= data
;
3031 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
3034 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
3037 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
3039 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
3043 if (IS_VALLEYVIEW(dev
))
3044 *val
= vlv_gpu_freq(dev_priv
, dev_priv
->rps
.min_delay
);
3046 *val
= dev_priv
->rps
.min_delay
* GT_FREQUENCY_MULTIPLIER
;
3047 mutex_unlock(&dev_priv
->rps
.hw_lock
);
3053 i915_min_freq_set(void *data
, u64 val
)
3055 struct drm_device
*dev
= data
;
3056 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3059 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
3062 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
3064 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val
);
3066 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
3071 * Turbo will still be enabled, but won't go below the set value.
3073 if (IS_VALLEYVIEW(dev
)) {
3074 val
= vlv_freq_opcode(dev_priv
, val
);
3075 dev_priv
->rps
.min_delay
= val
;
3076 valleyview_set_rps(dev
, val
);
3078 do_div(val
, GT_FREQUENCY_MULTIPLIER
);
3079 dev_priv
->rps
.min_delay
= val
;
3080 gen6_set_rps(dev
, val
);
3082 mutex_unlock(&dev_priv
->rps
.hw_lock
);
3087 DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops
,
3088 i915_min_freq_get
, i915_min_freq_set
,
3092 i915_cache_sharing_get(void *data
, u64
*val
)
3094 struct drm_device
*dev
= data
;
3095 drm_i915_private_t
*dev_priv
= dev
->dev_private
;
3099 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
3102 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
3105 intel_runtime_pm_get(dev_priv
);
3107 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
3109 intel_runtime_pm_put(dev_priv
);
3110 mutex_unlock(&dev_priv
->dev
->struct_mutex
);
3112 *val
= (snpcr
& GEN6_MBC_SNPCR_MASK
) >> GEN6_MBC_SNPCR_SHIFT
;
3118 i915_cache_sharing_set(void *data
, u64 val
)
3120 struct drm_device
*dev
= data
;
3121 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3124 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
3130 intel_runtime_pm_get(dev_priv
);
3131 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val
);
3133 /* Update the cache sharing policy here as well */
3134 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
3135 snpcr
&= ~GEN6_MBC_SNPCR_MASK
;
3136 snpcr
|= (val
<< GEN6_MBC_SNPCR_SHIFT
);
3137 I915_WRITE(GEN6_MBCUNIT_SNPCR
, snpcr
);
3139 intel_runtime_pm_put(dev_priv
);
3143 DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops
,
3144 i915_cache_sharing_get
, i915_cache_sharing_set
,
3147 static int i915_forcewake_open(struct inode
*inode
, struct file
*file
)
3149 struct drm_device
*dev
= inode
->i_private
;
3150 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3152 if (INTEL_INFO(dev
)->gen
< 6)
3155 intel_runtime_pm_get(dev_priv
);
3156 gen6_gt_force_wake_get(dev_priv
, FORCEWAKE_ALL
);
3161 static int i915_forcewake_release(struct inode
*inode
, struct file
*file
)
3163 struct drm_device
*dev
= inode
->i_private
;
3164 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3166 if (INTEL_INFO(dev
)->gen
< 6)
3169 gen6_gt_force_wake_put(dev_priv
, FORCEWAKE_ALL
);
3170 intel_runtime_pm_put(dev_priv
);
3175 static const struct file_operations i915_forcewake_fops
= {
3176 .owner
= THIS_MODULE
,
3177 .open
= i915_forcewake_open
,
3178 .release
= i915_forcewake_release
,
3181 static int i915_forcewake_create(struct dentry
*root
, struct drm_minor
*minor
)
3183 struct drm_device
*dev
= minor
->dev
;
3186 ent
= debugfs_create_file("i915_forcewake_user",
3189 &i915_forcewake_fops
);
3193 return drm_add_fake_info_node(minor
, ent
, &i915_forcewake_fops
);
3196 static int i915_debugfs_create(struct dentry
*root
,
3197 struct drm_minor
*minor
,
3199 const struct file_operations
*fops
)
3201 struct drm_device
*dev
= minor
->dev
;
3204 ent
= debugfs_create_file(name
,
3211 return drm_add_fake_info_node(minor
, ent
, fops
);
3214 static const struct drm_info_list i915_debugfs_list
[] = {
3215 {"i915_capabilities", i915_capabilities
, 0},
3216 {"i915_gem_objects", i915_gem_object_info
, 0},
3217 {"i915_gem_gtt", i915_gem_gtt_info
, 0},
3218 {"i915_gem_pinned", i915_gem_gtt_info
, 0, (void *) PINNED_LIST
},
3219 {"i915_gem_active", i915_gem_object_list_info
, 0, (void *) ACTIVE_LIST
},
3220 {"i915_gem_inactive", i915_gem_object_list_info
, 0, (void *) INACTIVE_LIST
},
3221 {"i915_gem_stolen", i915_gem_stolen_list_info
},
3222 {"i915_gem_pageflip", i915_gem_pageflip_info
, 0},
3223 {"i915_gem_request", i915_gem_request_info
, 0},
3224 {"i915_gem_seqno", i915_gem_seqno_info
, 0},
3225 {"i915_gem_fence_regs", i915_gem_fence_regs_info
, 0},
3226 {"i915_gem_interrupt", i915_interrupt_info
, 0},
3227 {"i915_gem_hws", i915_hws_info
, 0, (void *)RCS
},
3228 {"i915_gem_hws_blt", i915_hws_info
, 0, (void *)BCS
},
3229 {"i915_gem_hws_bsd", i915_hws_info
, 0, (void *)VCS
},
3230 {"i915_gem_hws_vebox", i915_hws_info
, 0, (void *)VECS
},
3231 {"i915_rstdby_delays", i915_rstdby_delays
, 0},
3232 {"i915_cur_delayinfo", i915_cur_delayinfo
, 0},
3233 {"i915_delayfreq_table", i915_delayfreq_table
, 0},
3234 {"i915_inttoext_table", i915_inttoext_table
, 0},
3235 {"i915_drpc_info", i915_drpc_info
, 0},
3236 {"i915_emon_status", i915_emon_status
, 0},
3237 {"i915_ring_freq_table", i915_ring_freq_table
, 0},
3238 {"i915_gfxec", i915_gfxec
, 0},
3239 {"i915_fbc_status", i915_fbc_status
, 0},
3240 {"i915_ips_status", i915_ips_status
, 0},
3241 {"i915_sr_status", i915_sr_status
, 0},
3242 {"i915_opregion", i915_opregion
, 0},
3243 {"i915_gem_framebuffer", i915_gem_framebuffer_info
, 0},
3244 {"i915_context_status", i915_context_status
, 0},
3245 {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info
, 0},
3246 {"i915_swizzle_info", i915_swizzle_info
, 0},
3247 {"i915_ppgtt_info", i915_ppgtt_info
, 0},
3248 {"i915_dpio", i915_dpio_info
, 0},
3249 {"i915_llc", i915_llc
, 0},
3250 {"i915_edp_psr_status", i915_edp_psr_status
, 0},
3251 {"i915_energy_uJ", i915_energy_uJ
, 0},
3252 {"i915_pc8_status", i915_pc8_status
, 0},
3253 {"i915_power_domain_info", i915_power_domain_info
, 0},
3255 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
3257 static const struct i915_debugfs_files
{
3259 const struct file_operations
*fops
;
3260 } i915_debugfs_files
[] = {
3261 {"i915_wedged", &i915_wedged_fops
},
3262 {"i915_max_freq", &i915_max_freq_fops
},
3263 {"i915_min_freq", &i915_min_freq_fops
},
3264 {"i915_cache_sharing", &i915_cache_sharing_fops
},
3265 {"i915_ring_stop", &i915_ring_stop_fops
},
3266 {"i915_ring_missed_irq", &i915_ring_missed_irq_fops
},
3267 {"i915_ring_test_irq", &i915_ring_test_irq_fops
},
3268 {"i915_gem_drop_caches", &i915_drop_caches_fops
},
3269 {"i915_error_state", &i915_error_state_fops
},
3270 {"i915_next_seqno", &i915_next_seqno_fops
},
3271 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops
},
3274 void intel_display_crc_init(struct drm_device
*dev
)
3276 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3279 for_each_pipe(pipe
) {
3280 struct intel_pipe_crc
*pipe_crc
= &dev_priv
->pipe_crc
[pipe
];
3282 pipe_crc
->opened
= false;
3283 spin_lock_init(&pipe_crc
->lock
);
3284 init_waitqueue_head(&pipe_crc
->wq
);
3288 int i915_debugfs_init(struct drm_minor
*minor
)
3292 ret
= i915_forcewake_create(minor
->debugfs_root
, minor
);
3296 for (i
= 0; i
< ARRAY_SIZE(i915_pipe_crc_data
); i
++) {
3297 ret
= i915_pipe_crc_create(minor
->debugfs_root
, minor
, i
);
3302 for (i
= 0; i
< ARRAY_SIZE(i915_debugfs_files
); i
++) {
3303 ret
= i915_debugfs_create(minor
->debugfs_root
, minor
,
3304 i915_debugfs_files
[i
].name
,
3305 i915_debugfs_files
[i
].fops
);
3310 return drm_debugfs_create_files(i915_debugfs_list
,
3311 I915_DEBUGFS_ENTRIES
,
3312 minor
->debugfs_root
, minor
);
3315 void i915_debugfs_cleanup(struct drm_minor
*minor
)
3319 drm_debugfs_remove_files(i915_debugfs_list
,
3320 I915_DEBUGFS_ENTRIES
, minor
);
3322 drm_debugfs_remove_files((struct drm_info_list
*) &i915_forcewake_fops
,
3325 for (i
= 0; i
< ARRAY_SIZE(i915_pipe_crc_data
); i
++) {
3326 struct drm_info_list
*info_list
=
3327 (struct drm_info_list
*)&i915_pipe_crc_data
[i
];
3329 drm_debugfs_remove_files(info_list
, 1, minor
);
3332 for (i
= 0; i
< ARRAY_SIZE(i915_debugfs_files
); i
++) {
3333 struct drm_info_list
*info_list
=
3334 (struct drm_info_list
*) i915_debugfs_files
[i
].fops
;
3336 drm_debugfs_remove_files(info_list
, 1, minor
);