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>
43 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
45 return to_i915(node->minor->dev);
48 /* As the drm_debugfs_init() routines are called before dev->dev_private is
49 * allocated we need to hook into the minor for release. */
51 drm_add_fake_info_node(struct drm_minor *minor,
55 struct drm_info_node *node;
57 node = kmalloc(sizeof(*node), GFP_KERNEL);
65 node->info_ent = (void *)key;
67 mutex_lock(&minor->debugfs_lock);
68 list_add(&node->list, &minor->debugfs_list);
69 mutex_unlock(&minor->debugfs_lock);
74 static int i915_capabilities(struct seq_file *m, void *data)
76 struct drm_i915_private *dev_priv = node_to_i915(m->private);
77 const struct intel_device_info *info = INTEL_INFO(dev_priv);
79 seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv));
80 seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv));
81 #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
82 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
88 static char get_active_flag(struct drm_i915_gem_object *obj)
90 return i915_gem_object_is_active(obj) ? '*' : ' ';
93 static char get_pin_flag(struct drm_i915_gem_object *obj)
95 return obj->pin_display ? 'p' : ' ';
98 static char get_tiling_flag(struct drm_i915_gem_object *obj)
100 switch (i915_gem_object_get_tiling(obj)) {
102 case I915_TILING_NONE: return ' ';
103 case I915_TILING_X: return 'X';
104 case I915_TILING_Y: return 'Y';
108 static char get_global_flag(struct drm_i915_gem_object *obj)
110 return !list_empty(&obj->userfault_link) ? 'g' : ' ';
113 static char get_pin_mapped_flag(struct drm_i915_gem_object *obj)
115 return obj->mapping ? 'M' : ' ';
118 static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
121 struct i915_vma *vma;
123 list_for_each_entry(vma, &obj->vma_list, obj_link) {
124 if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node))
125 size += vma->node.size;
132 describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
134 struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
135 struct intel_engine_cs *engine;
136 struct i915_vma *vma;
137 unsigned int frontbuffer_bits;
139 enum intel_engine_id id;
141 lockdep_assert_held(&obj->base.dev->struct_mutex);
143 seq_printf(m, "%pK: %c%c%c%c%c %8zdKiB %02x %02x [ ",
145 get_active_flag(obj),
147 get_tiling_flag(obj),
148 get_global_flag(obj),
149 get_pin_mapped_flag(obj),
150 obj->base.size / 1024,
151 obj->base.read_domains,
152 obj->base.write_domain);
153 for_each_engine(engine, dev_priv, id)
155 i915_gem_active_get_seqno(&obj->last_read[id],
156 &obj->base.dev->struct_mutex));
157 seq_printf(m, "] %x %s%s%s",
158 i915_gem_active_get_seqno(&obj->last_write,
159 &obj->base.dev->struct_mutex),
160 i915_cache_level_str(dev_priv, obj->cache_level),
161 obj->dirty ? " dirty" : "",
162 obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
164 seq_printf(m, " (name: %d)", obj->base.name);
165 list_for_each_entry(vma, &obj->vma_list, obj_link) {
166 if (i915_vma_is_pinned(vma))
169 seq_printf(m, " (pinned x %d)", pin_count);
170 if (obj->pin_display)
171 seq_printf(m, " (display)");
172 list_for_each_entry(vma, &obj->vma_list, obj_link) {
173 if (!drm_mm_node_allocated(&vma->node))
176 seq_printf(m, " (%sgtt offset: %08llx, size: %08llx",
177 i915_vma_is_ggtt(vma) ? "g" : "pp",
178 vma->node.start, vma->node.size);
179 if (i915_vma_is_ggtt(vma))
180 seq_printf(m, ", type: %u", vma->ggtt_view.type);
182 seq_printf(m, " , fence: %d%s",
184 i915_gem_active_isset(&vma->last_fence) ? "*" : "");
188 seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
190 engine = i915_gem_active_get_engine(&obj->last_write,
191 &dev_priv->drm.struct_mutex);
193 seq_printf(m, " (%s)", engine->name);
195 frontbuffer_bits = atomic_read(&obj->frontbuffer_bits);
196 if (frontbuffer_bits)
197 seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits);
200 static int obj_rank_by_stolen(void *priv,
201 struct list_head *A, struct list_head *B)
203 struct drm_i915_gem_object *a =
204 container_of(A, struct drm_i915_gem_object, obj_exec_link);
205 struct drm_i915_gem_object *b =
206 container_of(B, struct drm_i915_gem_object, obj_exec_link);
208 if (a->stolen->start < b->stolen->start)
210 if (a->stolen->start > b->stolen->start)
215 static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
217 struct drm_i915_private *dev_priv = node_to_i915(m->private);
218 struct drm_device *dev = &dev_priv->drm;
219 struct drm_i915_gem_object *obj;
220 u64 total_obj_size, total_gtt_size;
224 ret = mutex_lock_interruptible(&dev->struct_mutex);
228 total_obj_size = total_gtt_size = count = 0;
229 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
230 if (obj->stolen == NULL)
233 list_add(&obj->obj_exec_link, &stolen);
235 total_obj_size += obj->base.size;
236 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
239 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
240 if (obj->stolen == NULL)
243 list_add(&obj->obj_exec_link, &stolen);
245 total_obj_size += obj->base.size;
248 list_sort(NULL, &stolen, obj_rank_by_stolen);
249 seq_puts(m, "Stolen:\n");
250 while (!list_empty(&stolen)) {
251 obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link);
253 describe_obj(m, obj);
255 list_del_init(&obj->obj_exec_link);
257 mutex_unlock(&dev->struct_mutex);
259 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
260 count, total_obj_size, total_gtt_size);
265 struct drm_i915_file_private *file_priv;
269 u64 active, inactive;
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;
276 struct i915_vma *vma;
279 stats->total += obj->base.size;
280 if (!obj->bind_count)
281 stats->unbound += obj->base.size;
282 if (obj->base.name || obj->base.dma_buf)
283 stats->shared += obj->base.size;
285 list_for_each_entry(vma, &obj->vma_list, obj_link) {
286 if (!drm_mm_node_allocated(&vma->node))
289 if (i915_vma_is_ggtt(vma)) {
290 stats->global += vma->node.size;
292 struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm);
294 if (ppgtt->base.file != stats->file_priv)
298 if (i915_vma_is_active(vma))
299 stats->active += vma->node.size;
301 stats->inactive += vma->node.size;
307 #define print_file_stats(m, name, stats) do { \
309 seq_printf(m, "%s: %lu objects, %llu bytes (%llu active, %llu inactive, %llu global, %llu shared, %llu unbound)\n", \
320 static void print_batch_pool_stats(struct seq_file *m,
321 struct drm_i915_private *dev_priv)
323 struct drm_i915_gem_object *obj;
324 struct file_stats stats;
325 struct intel_engine_cs *engine;
326 enum intel_engine_id id;
329 memset(&stats, 0, sizeof(stats));
331 for_each_engine(engine, dev_priv, id) {
332 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
333 list_for_each_entry(obj,
334 &engine->batch_pool.cache_list[j],
336 per_file_stats(0, obj, &stats);
340 print_file_stats(m, "[k]batch pool", stats);
343 static int per_file_ctx_stats(int id, void *ptr, void *data)
345 struct i915_gem_context *ctx = ptr;
348 for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) {
349 if (ctx->engine[n].state)
350 per_file_stats(0, ctx->engine[n].state->obj, data);
351 if (ctx->engine[n].ring)
352 per_file_stats(0, ctx->engine[n].ring->vma->obj, data);
358 static void print_context_stats(struct seq_file *m,
359 struct drm_i915_private *dev_priv)
361 struct drm_device *dev = &dev_priv->drm;
362 struct file_stats stats;
363 struct drm_file *file;
365 memset(&stats, 0, sizeof(stats));
367 mutex_lock(&dev->struct_mutex);
368 if (dev_priv->kernel_context)
369 per_file_ctx_stats(0, dev_priv->kernel_context, &stats);
371 list_for_each_entry(file, &dev->filelist, lhead) {
372 struct drm_i915_file_private *fpriv = file->driver_priv;
373 idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats);
375 mutex_unlock(&dev->struct_mutex);
377 print_file_stats(m, "[k]contexts", stats);
380 static int i915_gem_object_info(struct seq_file *m, void *data)
382 struct drm_i915_private *dev_priv = node_to_i915(m->private);
383 struct drm_device *dev = &dev_priv->drm;
384 struct i915_ggtt *ggtt = &dev_priv->ggtt;
385 u32 count, mapped_count, purgeable_count, dpy_count;
386 u64 size, mapped_size, purgeable_size, dpy_size;
387 struct drm_i915_gem_object *obj;
388 struct drm_file *file;
391 ret = mutex_lock_interruptible(&dev->struct_mutex);
395 seq_printf(m, "%u objects, %llu bytes\n",
396 dev_priv->mm.object_count,
397 dev_priv->mm.object_memory);
400 mapped_size = mapped_count = 0;
401 purgeable_size = purgeable_count = 0;
402 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
403 size += obj->base.size;
406 if (obj->madv == I915_MADV_DONTNEED) {
407 purgeable_size += obj->base.size;
413 mapped_size += obj->base.size;
416 seq_printf(m, "%u unbound objects, %llu bytes\n", count, size);
418 size = count = dpy_size = dpy_count = 0;
419 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
420 size += obj->base.size;
423 if (obj->pin_display) {
424 dpy_size += obj->base.size;
428 if (obj->madv == I915_MADV_DONTNEED) {
429 purgeable_size += obj->base.size;
435 mapped_size += obj->base.size;
438 seq_printf(m, "%u bound objects, %llu bytes\n",
440 seq_printf(m, "%u purgeable objects, %llu bytes\n",
441 purgeable_count, purgeable_size);
442 seq_printf(m, "%u mapped objects, %llu bytes\n",
443 mapped_count, mapped_size);
444 seq_printf(m, "%u display objects (pinned), %llu bytes\n",
445 dpy_count, dpy_size);
447 seq_printf(m, "%llu [%llu] gtt total\n",
448 ggtt->base.total, ggtt->mappable_end - ggtt->base.start);
451 print_batch_pool_stats(m, dev_priv);
452 mutex_unlock(&dev->struct_mutex);
454 mutex_lock(&dev->filelist_mutex);
455 print_context_stats(m, dev_priv);
456 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
457 struct file_stats stats;
458 struct drm_i915_file_private *file_priv = file->driver_priv;
459 struct drm_i915_gem_request *request;
460 struct task_struct *task;
462 memset(&stats, 0, sizeof(stats));
463 stats.file_priv = file->driver_priv;
464 spin_lock(&file->table_lock);
465 idr_for_each(&file->object_idr, per_file_stats, &stats);
466 spin_unlock(&file->table_lock);
468 * Although we have a valid reference on file->pid, that does
469 * not guarantee that the task_struct who called get_pid() is
470 * still alive (e.g. get_pid(current) => fork() => exit()).
471 * Therefore, we need to protect this ->comm access using RCU.
473 mutex_lock(&dev->struct_mutex);
474 request = list_first_entry_or_null(&file_priv->mm.request_list,
475 struct drm_i915_gem_request,
478 task = pid_task(request && request->ctx->pid ?
479 request->ctx->pid : file->pid,
481 print_file_stats(m, task ? task->comm : "<unknown>", stats);
483 mutex_unlock(&dev->struct_mutex);
485 mutex_unlock(&dev->filelist_mutex);
490 static int i915_gem_gtt_info(struct seq_file *m, void *data)
492 struct drm_info_node *node = m->private;
493 struct drm_i915_private *dev_priv = node_to_i915(node);
494 struct drm_device *dev = &dev_priv->drm;
495 bool show_pin_display_only = !!node->info_ent->data;
496 struct drm_i915_gem_object *obj;
497 u64 total_obj_size, total_gtt_size;
500 ret = mutex_lock_interruptible(&dev->struct_mutex);
504 total_obj_size = total_gtt_size = count = 0;
505 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
506 if (show_pin_display_only && !obj->pin_display)
510 describe_obj(m, obj);
512 total_obj_size += obj->base.size;
513 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
517 mutex_unlock(&dev->struct_mutex);
519 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
520 count, total_obj_size, total_gtt_size);
525 static int i915_gem_pageflip_info(struct seq_file *m, void *data)
527 struct drm_i915_private *dev_priv = node_to_i915(m->private);
528 struct drm_device *dev = &dev_priv->drm;
529 struct intel_crtc *crtc;
532 ret = mutex_lock_interruptible(&dev->struct_mutex);
536 for_each_intel_crtc(dev, crtc) {
537 const char pipe = pipe_name(crtc->pipe);
538 const char plane = plane_name(crtc->plane);
539 struct intel_flip_work *work;
541 spin_lock_irq(&dev->event_lock);
542 work = crtc->flip_work;
544 seq_printf(m, "No flip due on pipe %c (plane %c)\n",
550 pending = atomic_read(&work->pending);
552 seq_printf(m, "Flip ioctl preparing on pipe %c (plane %c)\n",
555 seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
558 if (work->flip_queued_req) {
559 struct intel_engine_cs *engine = i915_gem_request_get_engine(work->flip_queued_req);
561 seq_printf(m, "Flip queued on %s at seqno %x, next seqno %x [current breadcrumb %x], completed? %d\n",
563 i915_gem_request_get_seqno(work->flip_queued_req),
564 dev_priv->next_seqno,
565 intel_engine_get_seqno(engine),
566 i915_gem_request_completed(work->flip_queued_req));
568 seq_printf(m, "Flip not associated with any ring\n");
569 seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n",
570 work->flip_queued_vblank,
571 work->flip_ready_vblank,
572 intel_crtc_get_vblank_counter(crtc));
573 seq_printf(m, "%d prepares\n", atomic_read(&work->pending));
575 if (INTEL_GEN(dev_priv) >= 4)
576 addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane)));
578 addr = I915_READ(DSPADDR(crtc->plane));
579 seq_printf(m, "Current scanout address 0x%08x\n", addr);
581 if (work->pending_flip_obj) {
582 seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset);
583 seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset);
586 spin_unlock_irq(&dev->event_lock);
589 mutex_unlock(&dev->struct_mutex);
594 static int i915_gem_batch_pool_info(struct seq_file *m, void *data)
596 struct drm_i915_private *dev_priv = node_to_i915(m->private);
597 struct drm_device *dev = &dev_priv->drm;
598 struct drm_i915_gem_object *obj;
599 struct intel_engine_cs *engine;
600 enum intel_engine_id id;
604 ret = mutex_lock_interruptible(&dev->struct_mutex);
608 for_each_engine(engine, dev_priv, id) {
609 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
613 list_for_each_entry(obj,
614 &engine->batch_pool.cache_list[j],
617 seq_printf(m, "%s cache[%d]: %d objects\n",
618 engine->name, j, count);
620 list_for_each_entry(obj,
621 &engine->batch_pool.cache_list[j],
624 describe_obj(m, obj);
632 seq_printf(m, "total: %d\n", total);
634 mutex_unlock(&dev->struct_mutex);
639 static void print_request(struct seq_file *m,
640 struct drm_i915_gem_request *rq,
643 struct pid *pid = rq->ctx->pid;
644 struct task_struct *task;
647 task = pid ? pid_task(pid, PIDTYPE_PID) : NULL;
648 seq_printf(m, "%s%x [%x:%x] @ %d: %s [%d]\n", prefix,
649 rq->fence.seqno, rq->ctx->hw_id, rq->fence.seqno,
650 jiffies_to_msecs(jiffies - rq->emitted_jiffies),
651 task ? task->comm : "<unknown>",
652 task ? task->pid : -1);
656 static int i915_gem_request_info(struct seq_file *m, void *data)
658 struct drm_i915_private *dev_priv = node_to_i915(m->private);
659 struct drm_device *dev = &dev_priv->drm;
660 struct drm_i915_gem_request *req;
661 struct intel_engine_cs *engine;
662 enum intel_engine_id id;
665 ret = mutex_lock_interruptible(&dev->struct_mutex);
670 for_each_engine(engine, dev_priv, id) {
674 list_for_each_entry(req, &engine->request_list, link)
679 seq_printf(m, "%s requests: %d\n", engine->name, count);
680 list_for_each_entry(req, &engine->request_list, link)
681 print_request(m, req, " ");
685 mutex_unlock(&dev->struct_mutex);
688 seq_puts(m, "No requests\n");
693 static void i915_ring_seqno_info(struct seq_file *m,
694 struct intel_engine_cs *engine)
696 struct intel_breadcrumbs *b = &engine->breadcrumbs;
699 seq_printf(m, "Current sequence (%s): %x\n",
700 engine->name, intel_engine_get_seqno(engine));
703 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
704 struct intel_wait *w = container_of(rb, typeof(*w), node);
706 seq_printf(m, "Waiting (%s): %s [%d] on %x\n",
707 engine->name, w->tsk->comm, w->tsk->pid, w->seqno);
709 spin_unlock(&b->lock);
712 static int i915_gem_seqno_info(struct seq_file *m, void *data)
714 struct drm_i915_private *dev_priv = node_to_i915(m->private);
715 struct intel_engine_cs *engine;
716 enum intel_engine_id id;
718 for_each_engine(engine, dev_priv, id)
719 i915_ring_seqno_info(m, engine);
725 static int i915_interrupt_info(struct seq_file *m, void *data)
727 struct drm_i915_private *dev_priv = node_to_i915(m->private);
728 struct intel_engine_cs *engine;
729 enum intel_engine_id id;
732 intel_runtime_pm_get(dev_priv);
734 if (IS_CHERRYVIEW(dev_priv)) {
735 seq_printf(m, "Master Interrupt Control:\t%08x\n",
736 I915_READ(GEN8_MASTER_IRQ));
738 seq_printf(m, "Display IER:\t%08x\n",
740 seq_printf(m, "Display IIR:\t%08x\n",
742 seq_printf(m, "Display IIR_RW:\t%08x\n",
743 I915_READ(VLV_IIR_RW));
744 seq_printf(m, "Display IMR:\t%08x\n",
746 for_each_pipe(dev_priv, pipe) {
747 enum intel_display_power_domain power_domain;
749 power_domain = POWER_DOMAIN_PIPE(pipe);
750 if (!intel_display_power_get_if_enabled(dev_priv,
752 seq_printf(m, "Pipe %c power disabled\n",
757 seq_printf(m, "Pipe %c stat:\t%08x\n",
759 I915_READ(PIPESTAT(pipe)));
761 intel_display_power_put(dev_priv, power_domain);
764 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
765 seq_printf(m, "Port hotplug:\t%08x\n",
766 I915_READ(PORT_HOTPLUG_EN));
767 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
768 I915_READ(VLV_DPFLIPSTAT));
769 seq_printf(m, "DPINVGTT:\t%08x\n",
770 I915_READ(DPINVGTT));
771 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
773 for (i = 0; i < 4; i++) {
774 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
775 i, I915_READ(GEN8_GT_IMR(i)));
776 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
777 i, I915_READ(GEN8_GT_IIR(i)));
778 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
779 i, I915_READ(GEN8_GT_IER(i)));
782 seq_printf(m, "PCU interrupt mask:\t%08x\n",
783 I915_READ(GEN8_PCU_IMR));
784 seq_printf(m, "PCU interrupt identity:\t%08x\n",
785 I915_READ(GEN8_PCU_IIR));
786 seq_printf(m, "PCU interrupt enable:\t%08x\n",
787 I915_READ(GEN8_PCU_IER));
788 } else if (INTEL_GEN(dev_priv) >= 8) {
789 seq_printf(m, "Master Interrupt Control:\t%08x\n",
790 I915_READ(GEN8_MASTER_IRQ));
792 for (i = 0; i < 4; i++) {
793 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
794 i, I915_READ(GEN8_GT_IMR(i)));
795 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
796 i, I915_READ(GEN8_GT_IIR(i)));
797 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
798 i, I915_READ(GEN8_GT_IER(i)));
801 for_each_pipe(dev_priv, pipe) {
802 enum intel_display_power_domain power_domain;
804 power_domain = POWER_DOMAIN_PIPE(pipe);
805 if (!intel_display_power_get_if_enabled(dev_priv,
807 seq_printf(m, "Pipe %c power disabled\n",
811 seq_printf(m, "Pipe %c IMR:\t%08x\n",
813 I915_READ(GEN8_DE_PIPE_IMR(pipe)));
814 seq_printf(m, "Pipe %c IIR:\t%08x\n",
816 I915_READ(GEN8_DE_PIPE_IIR(pipe)));
817 seq_printf(m, "Pipe %c IER:\t%08x\n",
819 I915_READ(GEN8_DE_PIPE_IER(pipe)));
821 intel_display_power_put(dev_priv, power_domain);
824 seq_printf(m, "Display Engine port interrupt mask:\t%08x\n",
825 I915_READ(GEN8_DE_PORT_IMR));
826 seq_printf(m, "Display Engine port interrupt identity:\t%08x\n",
827 I915_READ(GEN8_DE_PORT_IIR));
828 seq_printf(m, "Display Engine port interrupt enable:\t%08x\n",
829 I915_READ(GEN8_DE_PORT_IER));
831 seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n",
832 I915_READ(GEN8_DE_MISC_IMR));
833 seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n",
834 I915_READ(GEN8_DE_MISC_IIR));
835 seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n",
836 I915_READ(GEN8_DE_MISC_IER));
838 seq_printf(m, "PCU interrupt mask:\t%08x\n",
839 I915_READ(GEN8_PCU_IMR));
840 seq_printf(m, "PCU interrupt identity:\t%08x\n",
841 I915_READ(GEN8_PCU_IIR));
842 seq_printf(m, "PCU interrupt enable:\t%08x\n",
843 I915_READ(GEN8_PCU_IER));
844 } else if (IS_VALLEYVIEW(dev_priv)) {
845 seq_printf(m, "Display IER:\t%08x\n",
847 seq_printf(m, "Display IIR:\t%08x\n",
849 seq_printf(m, "Display IIR_RW:\t%08x\n",
850 I915_READ(VLV_IIR_RW));
851 seq_printf(m, "Display IMR:\t%08x\n",
853 for_each_pipe(dev_priv, pipe)
854 seq_printf(m, "Pipe %c stat:\t%08x\n",
856 I915_READ(PIPESTAT(pipe)));
858 seq_printf(m, "Master IER:\t%08x\n",
859 I915_READ(VLV_MASTER_IER));
861 seq_printf(m, "Render IER:\t%08x\n",
863 seq_printf(m, "Render IIR:\t%08x\n",
865 seq_printf(m, "Render IMR:\t%08x\n",
868 seq_printf(m, "PM IER:\t\t%08x\n",
869 I915_READ(GEN6_PMIER));
870 seq_printf(m, "PM IIR:\t\t%08x\n",
871 I915_READ(GEN6_PMIIR));
872 seq_printf(m, "PM IMR:\t\t%08x\n",
873 I915_READ(GEN6_PMIMR));
875 seq_printf(m, "Port hotplug:\t%08x\n",
876 I915_READ(PORT_HOTPLUG_EN));
877 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
878 I915_READ(VLV_DPFLIPSTAT));
879 seq_printf(m, "DPINVGTT:\t%08x\n",
880 I915_READ(DPINVGTT));
882 } else if (!HAS_PCH_SPLIT(dev_priv)) {
883 seq_printf(m, "Interrupt enable: %08x\n",
885 seq_printf(m, "Interrupt identity: %08x\n",
887 seq_printf(m, "Interrupt mask: %08x\n",
889 for_each_pipe(dev_priv, pipe)
890 seq_printf(m, "Pipe %c stat: %08x\n",
892 I915_READ(PIPESTAT(pipe)));
894 seq_printf(m, "North Display Interrupt enable: %08x\n",
896 seq_printf(m, "North Display Interrupt identity: %08x\n",
898 seq_printf(m, "North Display Interrupt mask: %08x\n",
900 seq_printf(m, "South Display Interrupt enable: %08x\n",
902 seq_printf(m, "South Display Interrupt identity: %08x\n",
904 seq_printf(m, "South Display Interrupt mask: %08x\n",
906 seq_printf(m, "Graphics Interrupt enable: %08x\n",
908 seq_printf(m, "Graphics Interrupt identity: %08x\n",
910 seq_printf(m, "Graphics Interrupt mask: %08x\n",
913 for_each_engine(engine, dev_priv, id) {
914 if (INTEL_GEN(dev_priv) >= 6) {
916 "Graphics Interrupt mask (%s): %08x\n",
917 engine->name, I915_READ_IMR(engine));
919 i915_ring_seqno_info(m, engine);
921 intel_runtime_pm_put(dev_priv);
926 static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
928 struct drm_i915_private *dev_priv = node_to_i915(m->private);
929 struct drm_device *dev = &dev_priv->drm;
932 ret = mutex_lock_interruptible(&dev->struct_mutex);
936 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
937 for (i = 0; i < dev_priv->num_fence_regs; i++) {
938 struct i915_vma *vma = dev_priv->fence_regs[i].vma;
940 seq_printf(m, "Fence %d, pin count = %d, object = ",
941 i, dev_priv->fence_regs[i].pin_count);
943 seq_puts(m, "unused");
945 describe_obj(m, vma->obj);
949 mutex_unlock(&dev->struct_mutex);
953 static int i915_hws_info(struct seq_file *m, void *data)
955 struct drm_info_node *node = m->private;
956 struct drm_i915_private *dev_priv = node_to_i915(node);
957 struct intel_engine_cs *engine;
961 engine = dev_priv->engine[(uintptr_t)node->info_ent->data];
962 hws = engine->status_page.page_addr;
966 for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
967 seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
969 hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
974 #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
977 i915_error_state_write(struct file *filp,
978 const char __user *ubuf,
982 struct i915_error_state_file_priv *error_priv = filp->private_data;
984 DRM_DEBUG_DRIVER("Resetting error state\n");
985 i915_destroy_error_state(error_priv->dev);
990 static int i915_error_state_open(struct inode *inode, struct file *file)
992 struct drm_i915_private *dev_priv = inode->i_private;
993 struct i915_error_state_file_priv *error_priv;
995 error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL);
999 error_priv->dev = &dev_priv->drm;
1001 i915_error_state_get(&dev_priv->drm, error_priv);
1003 file->private_data = error_priv;
1008 static int i915_error_state_release(struct inode *inode, struct file *file)
1010 struct i915_error_state_file_priv *error_priv = file->private_data;
1012 i915_error_state_put(error_priv);
1018 static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
1019 size_t count, loff_t *pos)
1021 struct i915_error_state_file_priv *error_priv = file->private_data;
1022 struct drm_i915_error_state_buf error_str;
1024 ssize_t ret_count = 0;
1027 ret = i915_error_state_buf_init(&error_str,
1028 to_i915(error_priv->dev), count, *pos);
1032 ret = i915_error_state_to_str(&error_str, error_priv);
1036 ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos,
1043 *pos = error_str.start + ret_count;
1045 i915_error_state_buf_release(&error_str);
1046 return ret ?: ret_count;
1049 static const struct file_operations i915_error_state_fops = {
1050 .owner = THIS_MODULE,
1051 .open = i915_error_state_open,
1052 .read = i915_error_state_read,
1053 .write = i915_error_state_write,
1054 .llseek = default_llseek,
1055 .release = i915_error_state_release,
1061 i915_next_seqno_get(void *data, u64 *val)
1063 struct drm_i915_private *dev_priv = data;
1066 ret = mutex_lock_interruptible(&dev_priv->drm.struct_mutex);
1070 *val = dev_priv->next_seqno;
1071 mutex_unlock(&dev_priv->drm.struct_mutex);
1077 i915_next_seqno_set(void *data, u64 val)
1079 struct drm_i915_private *dev_priv = data;
1080 struct drm_device *dev = &dev_priv->drm;
1083 ret = mutex_lock_interruptible(&dev->struct_mutex);
1087 ret = i915_gem_set_seqno(dev, val);
1088 mutex_unlock(&dev->struct_mutex);
1093 DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
1094 i915_next_seqno_get, i915_next_seqno_set,
1097 static int i915_frequency_info(struct seq_file *m, void *unused)
1099 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1100 struct drm_device *dev = &dev_priv->drm;
1103 intel_runtime_pm_get(dev_priv);
1105 if (IS_GEN5(dev_priv)) {
1106 u16 rgvswctl = I915_READ16(MEMSWCTL);
1107 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
1109 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
1110 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
1111 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
1113 seq_printf(m, "Current P-state: %d\n",
1114 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
1115 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
1118 mutex_lock(&dev_priv->rps.hw_lock);
1119 freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
1120 seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts);
1121 seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq);
1123 seq_printf(m, "actual GPU freq: %d MHz\n",
1124 intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff));
1126 seq_printf(m, "current GPU freq: %d MHz\n",
1127 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1129 seq_printf(m, "max GPU freq: %d MHz\n",
1130 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1132 seq_printf(m, "min GPU freq: %d MHz\n",
1133 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
1135 seq_printf(m, "idle GPU freq: %d MHz\n",
1136 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
1139 "efficient (RPe) frequency: %d MHz\n",
1140 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
1141 mutex_unlock(&dev_priv->rps.hw_lock);
1142 } else if (INTEL_GEN(dev_priv) >= 6) {
1143 u32 rp_state_limits;
1146 u32 rpmodectl, rpinclimit, rpdeclimit;
1147 u32 rpstat, cagf, reqf;
1148 u32 rpupei, rpcurup, rpprevup;
1149 u32 rpdownei, rpcurdown, rpprevdown;
1150 u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask;
1153 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
1154 if (IS_BROXTON(dev_priv)) {
1155 rp_state_cap = I915_READ(BXT_RP_STATE_CAP);
1156 gt_perf_status = I915_READ(BXT_GT_PERF_STATUS);
1158 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
1159 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
1162 /* RPSTAT1 is in the GT power well */
1163 ret = mutex_lock_interruptible(&dev->struct_mutex);
1167 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
1169 reqf = I915_READ(GEN6_RPNSWREQ);
1170 if (IS_GEN9(dev_priv))
1173 reqf &= ~GEN6_TURBO_DISABLE;
1174 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
1179 reqf = intel_gpu_freq(dev_priv, reqf);
1181 rpmodectl = I915_READ(GEN6_RP_CONTROL);
1182 rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD);
1183 rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD);
1185 rpstat = I915_READ(GEN6_RPSTAT1);
1186 rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK;
1187 rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK;
1188 rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK;
1189 rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK;
1190 rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK;
1191 rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK;
1192 if (IS_GEN9(dev_priv))
1193 cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT;
1194 else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
1195 cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT;
1197 cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT;
1198 cagf = intel_gpu_freq(dev_priv, cagf);
1200 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
1201 mutex_unlock(&dev->struct_mutex);
1203 if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) {
1204 pm_ier = I915_READ(GEN6_PMIER);
1205 pm_imr = I915_READ(GEN6_PMIMR);
1206 pm_isr = I915_READ(GEN6_PMISR);
1207 pm_iir = I915_READ(GEN6_PMIIR);
1208 pm_mask = I915_READ(GEN6_PMINTRMSK);
1210 pm_ier = I915_READ(GEN8_GT_IER(2));
1211 pm_imr = I915_READ(GEN8_GT_IMR(2));
1212 pm_isr = I915_READ(GEN8_GT_ISR(2));
1213 pm_iir = I915_READ(GEN8_GT_IIR(2));
1214 pm_mask = I915_READ(GEN6_PMINTRMSK);
1216 seq_printf(m, "PM IER=0x%08x IMR=0x%08x ISR=0x%08x IIR=0x%08x, MASK=0x%08x\n",
1217 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask);
1218 seq_printf(m, "pm_intr_keep: 0x%08x\n", dev_priv->rps.pm_intr_keep);
1219 seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
1220 seq_printf(m, "Render p-state ratio: %d\n",
1221 (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8);
1222 seq_printf(m, "Render p-state VID: %d\n",
1223 gt_perf_status & 0xff);
1224 seq_printf(m, "Render p-state limit: %d\n",
1225 rp_state_limits & 0xff);
1226 seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
1227 seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl);
1228 seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit);
1229 seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit);
1230 seq_printf(m, "RPNSWREQ: %dMHz\n", reqf);
1231 seq_printf(m, "CAGF: %dMHz\n", cagf);
1232 seq_printf(m, "RP CUR UP EI: %d (%dus)\n",
1233 rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei));
1234 seq_printf(m, "RP CUR UP: %d (%dus)\n",
1235 rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup));
1236 seq_printf(m, "RP PREV UP: %d (%dus)\n",
1237 rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup));
1238 seq_printf(m, "Up threshold: %d%%\n",
1239 dev_priv->rps.up_threshold);
1241 seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n",
1242 rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei));
1243 seq_printf(m, "RP CUR DOWN: %d (%dus)\n",
1244 rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown));
1245 seq_printf(m, "RP PREV DOWN: %d (%dus)\n",
1246 rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown));
1247 seq_printf(m, "Down threshold: %d%%\n",
1248 dev_priv->rps.down_threshold);
1250 max_freq = (IS_BROXTON(dev_priv) ? rp_state_cap >> 0 :
1251 rp_state_cap >> 16) & 0xff;
1252 max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
1253 GEN9_FREQ_SCALER : 1);
1254 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
1255 intel_gpu_freq(dev_priv, max_freq));
1257 max_freq = (rp_state_cap & 0xff00) >> 8;
1258 max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
1259 GEN9_FREQ_SCALER : 1);
1260 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
1261 intel_gpu_freq(dev_priv, max_freq));
1263 max_freq = (IS_BROXTON(dev_priv) ? rp_state_cap >> 16 :
1264 rp_state_cap >> 0) & 0xff;
1265 max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
1266 GEN9_FREQ_SCALER : 1);
1267 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
1268 intel_gpu_freq(dev_priv, max_freq));
1269 seq_printf(m, "Max overclocked frequency: %dMHz\n",
1270 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1272 seq_printf(m, "Current freq: %d MHz\n",
1273 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1274 seq_printf(m, "Actual freq: %d MHz\n", cagf);
1275 seq_printf(m, "Idle freq: %d MHz\n",
1276 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
1277 seq_printf(m, "Min freq: %d MHz\n",
1278 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
1279 seq_printf(m, "Boost freq: %d MHz\n",
1280 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
1281 seq_printf(m, "Max freq: %d MHz\n",
1282 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1284 "efficient (RPe) frequency: %d MHz\n",
1285 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
1287 seq_puts(m, "no P-state info available\n");
1290 seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq);
1291 seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq);
1292 seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq);
1295 intel_runtime_pm_put(dev_priv);
1299 static void i915_instdone_info(struct drm_i915_private *dev_priv,
1301 struct intel_instdone *instdone)
1306 seq_printf(m, "\t\tINSTDONE: 0x%08x\n",
1307 instdone->instdone);
1309 if (INTEL_GEN(dev_priv) <= 3)
1312 seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n",
1313 instdone->slice_common);
1315 if (INTEL_GEN(dev_priv) <= 6)
1318 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1319 seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n",
1320 slice, subslice, instdone->sampler[slice][subslice]);
1322 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1323 seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n",
1324 slice, subslice, instdone->row[slice][subslice]);
1327 static int i915_hangcheck_info(struct seq_file *m, void *unused)
1329 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1330 struct intel_engine_cs *engine;
1331 u64 acthd[I915_NUM_ENGINES];
1332 u32 seqno[I915_NUM_ENGINES];
1333 struct intel_instdone instdone;
1334 enum intel_engine_id id;
1336 if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags))
1337 seq_printf(m, "Wedged\n");
1338 if (test_bit(I915_RESET_IN_PROGRESS, &dev_priv->gpu_error.flags))
1339 seq_printf(m, "Reset in progress\n");
1340 if (waitqueue_active(&dev_priv->gpu_error.wait_queue))
1341 seq_printf(m, "Waiter holding struct mutex\n");
1342 if (waitqueue_active(&dev_priv->gpu_error.reset_queue))
1343 seq_printf(m, "struct_mutex blocked for reset\n");
1345 if (!i915.enable_hangcheck) {
1346 seq_printf(m, "Hangcheck disabled\n");
1350 intel_runtime_pm_get(dev_priv);
1352 for_each_engine(engine, dev_priv, id) {
1353 acthd[id] = intel_engine_get_active_head(engine);
1354 seqno[id] = intel_engine_get_seqno(engine);
1357 intel_engine_get_instdone(dev_priv->engine[RCS], &instdone);
1359 intel_runtime_pm_put(dev_priv);
1361 if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) {
1362 seq_printf(m, "Hangcheck active, fires in %dms\n",
1363 jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires -
1366 seq_printf(m, "Hangcheck inactive\n");
1368 for_each_engine(engine, dev_priv, id) {
1369 struct intel_breadcrumbs *b = &engine->breadcrumbs;
1372 seq_printf(m, "%s:\n", engine->name);
1373 seq_printf(m, "\tseqno = %x [current %x, last %x]\n",
1374 engine->hangcheck.seqno,
1376 engine->last_submitted_seqno);
1377 seq_printf(m, "\twaiters? %s, fake irq active? %s\n",
1378 yesno(intel_engine_has_waiter(engine)),
1379 yesno(test_bit(engine->id,
1380 &dev_priv->gpu_error.missed_irq_rings)));
1381 spin_lock(&b->lock);
1382 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
1383 struct intel_wait *w = container_of(rb, typeof(*w), node);
1385 seq_printf(m, "\t%s [%d] waiting for %x\n",
1386 w->tsk->comm, w->tsk->pid, w->seqno);
1388 spin_unlock(&b->lock);
1390 seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n",
1391 (long long)engine->hangcheck.acthd,
1392 (long long)acthd[id]);
1393 seq_printf(m, "\tscore = %d\n", engine->hangcheck.score);
1394 seq_printf(m, "\taction = %d\n", engine->hangcheck.action);
1396 if (engine->id == RCS) {
1397 seq_puts(m, "\tinstdone read =\n");
1399 i915_instdone_info(dev_priv, m, &instdone);
1401 seq_puts(m, "\tinstdone accu =\n");
1403 i915_instdone_info(dev_priv, m,
1404 &engine->hangcheck.instdone);
1411 static int ironlake_drpc_info(struct seq_file *m)
1413 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1414 u32 rgvmodectl, rstdbyctl;
1417 intel_runtime_pm_get(dev_priv);
1419 rgvmodectl = I915_READ(MEMMODECTL);
1420 rstdbyctl = I915_READ(RSTDBYCTL);
1421 crstandvid = I915_READ16(CRSTANDVID);
1423 intel_runtime_pm_put(dev_priv);
1425 seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN));
1426 seq_printf(m, "Boost freq: %d\n",
1427 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
1428 MEMMODE_BOOST_FREQ_SHIFT);
1429 seq_printf(m, "HW control enabled: %s\n",
1430 yesno(rgvmodectl & MEMMODE_HWIDLE_EN));
1431 seq_printf(m, "SW control enabled: %s\n",
1432 yesno(rgvmodectl & MEMMODE_SWMODE_EN));
1433 seq_printf(m, "Gated voltage change: %s\n",
1434 yesno(rgvmodectl & MEMMODE_RCLK_GATE));
1435 seq_printf(m, "Starting frequency: P%d\n",
1436 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
1437 seq_printf(m, "Max P-state: P%d\n",
1438 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
1439 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
1440 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
1441 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
1442 seq_printf(m, "Render standby enabled: %s\n",
1443 yesno(!(rstdbyctl & RCX_SW_EXIT)));
1444 seq_puts(m, "Current RS state: ");
1445 switch (rstdbyctl & RSX_STATUS_MASK) {
1447 seq_puts(m, "on\n");
1449 case RSX_STATUS_RC1:
1450 seq_puts(m, "RC1\n");
1452 case RSX_STATUS_RC1E:
1453 seq_puts(m, "RC1E\n");
1455 case RSX_STATUS_RS1:
1456 seq_puts(m, "RS1\n");
1458 case RSX_STATUS_RS2:
1459 seq_puts(m, "RS2 (RC6)\n");
1461 case RSX_STATUS_RS3:
1462 seq_puts(m, "RC3 (RC6+)\n");
1465 seq_puts(m, "unknown\n");
1472 static int i915_forcewake_domains(struct seq_file *m, void *data)
1474 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1475 struct intel_uncore_forcewake_domain *fw_domain;
1477 spin_lock_irq(&dev_priv->uncore.lock);
1478 for_each_fw_domain(fw_domain, dev_priv) {
1479 seq_printf(m, "%s.wake_count = %u\n",
1480 intel_uncore_forcewake_domain_to_str(fw_domain->id),
1481 fw_domain->wake_count);
1483 spin_unlock_irq(&dev_priv->uncore.lock);
1488 static int vlv_drpc_info(struct seq_file *m)
1490 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1491 u32 rpmodectl1, rcctl1, pw_status;
1493 intel_runtime_pm_get(dev_priv);
1495 pw_status = I915_READ(VLV_GTLC_PW_STATUS);
1496 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1497 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1499 intel_runtime_pm_put(dev_priv);
1501 seq_printf(m, "Video Turbo Mode: %s\n",
1502 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1503 seq_printf(m, "Turbo enabled: %s\n",
1504 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1505 seq_printf(m, "HW control enabled: %s\n",
1506 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1507 seq_printf(m, "SW control enabled: %s\n",
1508 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1509 GEN6_RP_MEDIA_SW_MODE));
1510 seq_printf(m, "RC6 Enabled: %s\n",
1511 yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE |
1512 GEN6_RC_CTL_EI_MODE(1))));
1513 seq_printf(m, "Render Power Well: %s\n",
1514 (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down");
1515 seq_printf(m, "Media Power Well: %s\n",
1516 (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down");
1518 seq_printf(m, "Render RC6 residency since boot: %u\n",
1519 I915_READ(VLV_GT_RENDER_RC6));
1520 seq_printf(m, "Media RC6 residency since boot: %u\n",
1521 I915_READ(VLV_GT_MEDIA_RC6));
1523 return i915_forcewake_domains(m, NULL);
1526 static int gen6_drpc_info(struct seq_file *m)
1528 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1529 struct drm_device *dev = &dev_priv->drm;
1530 u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0;
1531 u32 gen9_powergate_enable = 0, gen9_powergate_status = 0;
1532 unsigned forcewake_count;
1535 ret = mutex_lock_interruptible(&dev->struct_mutex);
1538 intel_runtime_pm_get(dev_priv);
1540 spin_lock_irq(&dev_priv->uncore.lock);
1541 forcewake_count = dev_priv->uncore.fw_domain[FW_DOMAIN_ID_RENDER].wake_count;
1542 spin_unlock_irq(&dev_priv->uncore.lock);
1544 if (forcewake_count) {
1545 seq_puts(m, "RC information inaccurate because somebody "
1546 "holds a forcewake reference \n");
1548 /* NB: we cannot use forcewake, else we read the wrong values */
1549 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
1551 seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
1554 gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS);
1555 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4, true);
1557 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1558 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1559 if (INTEL_GEN(dev_priv) >= 9) {
1560 gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE);
1561 gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS);
1563 mutex_unlock(&dev->struct_mutex);
1564 mutex_lock(&dev_priv->rps.hw_lock);
1565 sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
1566 mutex_unlock(&dev_priv->rps.hw_lock);
1568 intel_runtime_pm_put(dev_priv);
1570 seq_printf(m, "Video Turbo Mode: %s\n",
1571 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1572 seq_printf(m, "HW control enabled: %s\n",
1573 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1574 seq_printf(m, "SW control enabled: %s\n",
1575 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1576 GEN6_RP_MEDIA_SW_MODE));
1577 seq_printf(m, "RC1e Enabled: %s\n",
1578 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1579 seq_printf(m, "RC6 Enabled: %s\n",
1580 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
1581 if (INTEL_GEN(dev_priv) >= 9) {
1582 seq_printf(m, "Render Well Gating Enabled: %s\n",
1583 yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE));
1584 seq_printf(m, "Media Well Gating Enabled: %s\n",
1585 yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE));
1587 seq_printf(m, "Deep RC6 Enabled: %s\n",
1588 yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
1589 seq_printf(m, "Deepest RC6 Enabled: %s\n",
1590 yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
1591 seq_puts(m, "Current RC state: ");
1592 switch (gt_core_status & GEN6_RCn_MASK) {
1594 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
1595 seq_puts(m, "Core Power Down\n");
1597 seq_puts(m, "on\n");
1600 seq_puts(m, "RC3\n");
1603 seq_puts(m, "RC6\n");
1606 seq_puts(m, "RC7\n");
1609 seq_puts(m, "Unknown\n");
1613 seq_printf(m, "Core Power Down: %s\n",
1614 yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
1615 if (INTEL_GEN(dev_priv) >= 9) {
1616 seq_printf(m, "Render Power Well: %s\n",
1617 (gen9_powergate_status &
1618 GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down");
1619 seq_printf(m, "Media Power Well: %s\n",
1620 (gen9_powergate_status &
1621 GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down");
1624 /* Not exactly sure what this is */
1625 seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1626 I915_READ(GEN6_GT_GFX_RC6_LOCKED));
1627 seq_printf(m, "RC6 residency since boot: %u\n",
1628 I915_READ(GEN6_GT_GFX_RC6));
1629 seq_printf(m, "RC6+ residency since boot: %u\n",
1630 I915_READ(GEN6_GT_GFX_RC6p));
1631 seq_printf(m, "RC6++ residency since boot: %u\n",
1632 I915_READ(GEN6_GT_GFX_RC6pp));
1634 seq_printf(m, "RC6 voltage: %dmV\n",
1635 GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff)));
1636 seq_printf(m, "RC6+ voltage: %dmV\n",
1637 GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff)));
1638 seq_printf(m, "RC6++ voltage: %dmV\n",
1639 GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff)));
1640 return i915_forcewake_domains(m, NULL);
1643 static int i915_drpc_info(struct seq_file *m, void *unused)
1645 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1647 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
1648 return vlv_drpc_info(m);
1649 else if (INTEL_GEN(dev_priv) >= 6)
1650 return gen6_drpc_info(m);
1652 return ironlake_drpc_info(m);
1655 static int i915_frontbuffer_tracking(struct seq_file *m, void *unused)
1657 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1659 seq_printf(m, "FB tracking busy bits: 0x%08x\n",
1660 dev_priv->fb_tracking.busy_bits);
1662 seq_printf(m, "FB tracking flip bits: 0x%08x\n",
1663 dev_priv->fb_tracking.flip_bits);
1668 static int i915_fbc_status(struct seq_file *m, void *unused)
1670 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1672 if (!HAS_FBC(dev_priv)) {
1673 seq_puts(m, "FBC unsupported on this chipset\n");
1677 intel_runtime_pm_get(dev_priv);
1678 mutex_lock(&dev_priv->fbc.lock);
1680 if (intel_fbc_is_active(dev_priv))
1681 seq_puts(m, "FBC enabled\n");
1683 seq_printf(m, "FBC disabled: %s\n",
1684 dev_priv->fbc.no_fbc_reason);
1686 if (intel_fbc_is_active(dev_priv) && INTEL_GEN(dev_priv) >= 7) {
1687 uint32_t mask = INTEL_GEN(dev_priv) >= 8 ?
1688 BDW_FBC_COMPRESSION_MASK :
1689 IVB_FBC_COMPRESSION_MASK;
1690 seq_printf(m, "Compressing: %s\n",
1691 yesno(I915_READ(FBC_STATUS2) & mask));
1694 mutex_unlock(&dev_priv->fbc.lock);
1695 intel_runtime_pm_put(dev_priv);
1700 static int i915_fbc_fc_get(void *data, u64 *val)
1702 struct drm_i915_private *dev_priv = data;
1704 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
1707 *val = dev_priv->fbc.false_color;
1712 static int i915_fbc_fc_set(void *data, u64 val)
1714 struct drm_i915_private *dev_priv = data;
1717 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
1720 mutex_lock(&dev_priv->fbc.lock);
1722 reg = I915_READ(ILK_DPFC_CONTROL);
1723 dev_priv->fbc.false_color = val;
1725 I915_WRITE(ILK_DPFC_CONTROL, val ?
1726 (reg | FBC_CTL_FALSE_COLOR) :
1727 (reg & ~FBC_CTL_FALSE_COLOR));
1729 mutex_unlock(&dev_priv->fbc.lock);
1733 DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops,
1734 i915_fbc_fc_get, i915_fbc_fc_set,
1737 static int i915_ips_status(struct seq_file *m, void *unused)
1739 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1741 if (!HAS_IPS(dev_priv)) {
1742 seq_puts(m, "not supported\n");
1746 intel_runtime_pm_get(dev_priv);
1748 seq_printf(m, "Enabled by kernel parameter: %s\n",
1749 yesno(i915.enable_ips));
1751 if (INTEL_GEN(dev_priv) >= 8) {
1752 seq_puts(m, "Currently: unknown\n");
1754 if (I915_READ(IPS_CTL) & IPS_ENABLE)
1755 seq_puts(m, "Currently: enabled\n");
1757 seq_puts(m, "Currently: disabled\n");
1760 intel_runtime_pm_put(dev_priv);
1765 static int i915_sr_status(struct seq_file *m, void *unused)
1767 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1768 bool sr_enabled = false;
1770 intel_runtime_pm_get(dev_priv);
1771 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
1773 if (HAS_PCH_SPLIT(dev_priv))
1774 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
1775 else if (IS_CRESTLINE(dev_priv) || IS_G4X(dev_priv) ||
1776 IS_I945G(dev_priv) || IS_I945GM(dev_priv))
1777 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
1778 else if (IS_I915GM(dev_priv))
1779 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
1780 else if (IS_PINEVIEW(dev_priv))
1781 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
1782 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
1783 sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
1785 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
1786 intel_runtime_pm_put(dev_priv);
1788 seq_printf(m, "self-refresh: %s\n",
1789 sr_enabled ? "enabled" : "disabled");
1794 static int i915_emon_status(struct seq_file *m, void *unused)
1796 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1797 struct drm_device *dev = &dev_priv->drm;
1798 unsigned long temp, chipset, gfx;
1801 if (!IS_GEN5(dev_priv))
1804 ret = mutex_lock_interruptible(&dev->struct_mutex);
1808 temp = i915_mch_val(dev_priv);
1809 chipset = i915_chipset_val(dev_priv);
1810 gfx = i915_gfx_val(dev_priv);
1811 mutex_unlock(&dev->struct_mutex);
1813 seq_printf(m, "GMCH temp: %ld\n", temp);
1814 seq_printf(m, "Chipset power: %ld\n", chipset);
1815 seq_printf(m, "GFX power: %ld\n", gfx);
1816 seq_printf(m, "Total power: %ld\n", chipset + gfx);
1821 static int i915_ring_freq_table(struct seq_file *m, void *unused)
1823 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1825 int gpu_freq, ia_freq;
1826 unsigned int max_gpu_freq, min_gpu_freq;
1828 if (!HAS_LLC(dev_priv)) {
1829 seq_puts(m, "unsupported on this chipset\n");
1833 intel_runtime_pm_get(dev_priv);
1835 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
1839 if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
1840 /* Convert GT frequency to 50 HZ units */
1842 dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER;
1844 dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER;
1846 min_gpu_freq = dev_priv->rps.min_freq_softlimit;
1847 max_gpu_freq = dev_priv->rps.max_freq_softlimit;
1850 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
1852 for (gpu_freq = min_gpu_freq; gpu_freq <= max_gpu_freq; gpu_freq++) {
1854 sandybridge_pcode_read(dev_priv,
1855 GEN6_PCODE_READ_MIN_FREQ_TABLE,
1857 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n",
1858 intel_gpu_freq(dev_priv, (gpu_freq *
1859 (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
1860 GEN9_FREQ_SCALER : 1))),
1861 ((ia_freq >> 0) & 0xff) * 100,
1862 ((ia_freq >> 8) & 0xff) * 100);
1865 mutex_unlock(&dev_priv->rps.hw_lock);
1868 intel_runtime_pm_put(dev_priv);
1872 static int i915_opregion(struct seq_file *m, void *unused)
1874 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1875 struct drm_device *dev = &dev_priv->drm;
1876 struct intel_opregion *opregion = &dev_priv->opregion;
1879 ret = mutex_lock_interruptible(&dev->struct_mutex);
1883 if (opregion->header)
1884 seq_write(m, opregion->header, OPREGION_SIZE);
1886 mutex_unlock(&dev->struct_mutex);
1892 static int i915_vbt(struct seq_file *m, void *unused)
1894 struct intel_opregion *opregion = &node_to_i915(m->private)->opregion;
1897 seq_write(m, opregion->vbt, opregion->vbt_size);
1902 static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
1904 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1905 struct drm_device *dev = &dev_priv->drm;
1906 struct intel_framebuffer *fbdev_fb = NULL;
1907 struct drm_framebuffer *drm_fb;
1910 ret = mutex_lock_interruptible(&dev->struct_mutex);
1914 #ifdef CONFIG_DRM_FBDEV_EMULATION
1915 if (dev_priv->fbdev) {
1916 fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb);
1918 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
1919 fbdev_fb->base.width,
1920 fbdev_fb->base.height,
1921 fbdev_fb->base.depth,
1922 fbdev_fb->base.bits_per_pixel,
1923 fbdev_fb->base.modifier[0],
1924 drm_framebuffer_read_refcount(&fbdev_fb->base));
1925 describe_obj(m, fbdev_fb->obj);
1930 mutex_lock(&dev->mode_config.fb_lock);
1931 drm_for_each_fb(drm_fb, dev) {
1932 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
1936 seq_printf(m, "user size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
1940 fb->base.bits_per_pixel,
1941 fb->base.modifier[0],
1942 drm_framebuffer_read_refcount(&fb->base));
1943 describe_obj(m, fb->obj);
1946 mutex_unlock(&dev->mode_config.fb_lock);
1947 mutex_unlock(&dev->struct_mutex);
1952 static void describe_ctx_ring(struct seq_file *m, struct intel_ring *ring)
1954 seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)",
1955 ring->space, ring->head, ring->tail,
1956 ring->last_retired_head);
1959 static int i915_context_status(struct seq_file *m, void *unused)
1961 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1962 struct drm_device *dev = &dev_priv->drm;
1963 struct intel_engine_cs *engine;
1964 struct i915_gem_context *ctx;
1965 enum intel_engine_id id;
1968 ret = mutex_lock_interruptible(&dev->struct_mutex);
1972 list_for_each_entry(ctx, &dev_priv->context_list, link) {
1973 seq_printf(m, "HW context %u ", ctx->hw_id);
1975 struct task_struct *task;
1977 task = get_pid_task(ctx->pid, PIDTYPE_PID);
1979 seq_printf(m, "(%s [%d]) ",
1980 task->comm, task->pid);
1981 put_task_struct(task);
1983 } else if (IS_ERR(ctx->file_priv)) {
1984 seq_puts(m, "(deleted) ");
1986 seq_puts(m, "(kernel) ");
1989 seq_putc(m, ctx->remap_slice ? 'R' : 'r');
1992 for_each_engine(engine, dev_priv, id) {
1993 struct intel_context *ce = &ctx->engine[engine->id];
1995 seq_printf(m, "%s: ", engine->name);
1996 seq_putc(m, ce->initialised ? 'I' : 'i');
1998 describe_obj(m, ce->state->obj);
2000 describe_ctx_ring(m, ce->ring);
2007 mutex_unlock(&dev->struct_mutex);
2012 static void i915_dump_lrc_obj(struct seq_file *m,
2013 struct i915_gem_context *ctx,
2014 struct intel_engine_cs *engine)
2016 struct i915_vma *vma = ctx->engine[engine->id].state;
2020 seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id);
2023 seq_puts(m, "\tFake context\n");
2027 if (vma->flags & I915_VMA_GLOBAL_BIND)
2028 seq_printf(m, "\tBound in GGTT at 0x%08x\n",
2029 i915_ggtt_offset(vma));
2031 if (i915_gem_object_get_pages(vma->obj)) {
2032 seq_puts(m, "\tFailed to get pages for context object\n\n");
2036 page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN);
2038 u32 *reg_state = kmap_atomic(page);
2040 for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
2042 "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n",
2044 reg_state[j], reg_state[j + 1],
2045 reg_state[j + 2], reg_state[j + 3]);
2047 kunmap_atomic(reg_state);
2053 static int i915_dump_lrc(struct seq_file *m, void *unused)
2055 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2056 struct drm_device *dev = &dev_priv->drm;
2057 struct intel_engine_cs *engine;
2058 struct i915_gem_context *ctx;
2059 enum intel_engine_id id;
2062 if (!i915.enable_execlists) {
2063 seq_printf(m, "Logical Ring Contexts are disabled\n");
2067 ret = mutex_lock_interruptible(&dev->struct_mutex);
2071 list_for_each_entry(ctx, &dev_priv->context_list, link)
2072 for_each_engine(engine, dev_priv, id)
2073 i915_dump_lrc_obj(m, ctx, engine);
2075 mutex_unlock(&dev->struct_mutex);
2080 static const char *swizzle_string(unsigned swizzle)
2083 case I915_BIT_6_SWIZZLE_NONE:
2085 case I915_BIT_6_SWIZZLE_9:
2087 case I915_BIT_6_SWIZZLE_9_10:
2088 return "bit9/bit10";
2089 case I915_BIT_6_SWIZZLE_9_11:
2090 return "bit9/bit11";
2091 case I915_BIT_6_SWIZZLE_9_10_11:
2092 return "bit9/bit10/bit11";
2093 case I915_BIT_6_SWIZZLE_9_17:
2094 return "bit9/bit17";
2095 case I915_BIT_6_SWIZZLE_9_10_17:
2096 return "bit9/bit10/bit17";
2097 case I915_BIT_6_SWIZZLE_UNKNOWN:
2104 static int i915_swizzle_info(struct seq_file *m, void *data)
2106 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2108 intel_runtime_pm_get(dev_priv);
2110 seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
2111 swizzle_string(dev_priv->mm.bit_6_swizzle_x));
2112 seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
2113 swizzle_string(dev_priv->mm.bit_6_swizzle_y));
2115 if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) {
2116 seq_printf(m, "DDC = 0x%08x\n",
2118 seq_printf(m, "DDC2 = 0x%08x\n",
2120 seq_printf(m, "C0DRB3 = 0x%04x\n",
2121 I915_READ16(C0DRB3));
2122 seq_printf(m, "C1DRB3 = 0x%04x\n",
2123 I915_READ16(C1DRB3));
2124 } else if (INTEL_GEN(dev_priv) >= 6) {
2125 seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
2126 I915_READ(MAD_DIMM_C0));
2127 seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
2128 I915_READ(MAD_DIMM_C1));
2129 seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
2130 I915_READ(MAD_DIMM_C2));
2131 seq_printf(m, "TILECTL = 0x%08x\n",
2132 I915_READ(TILECTL));
2133 if (INTEL_GEN(dev_priv) >= 8)
2134 seq_printf(m, "GAMTARBMODE = 0x%08x\n",
2135 I915_READ(GAMTARBMODE));
2137 seq_printf(m, "ARB_MODE = 0x%08x\n",
2138 I915_READ(ARB_MODE));
2139 seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
2140 I915_READ(DISP_ARB_CTL));
2143 if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES)
2144 seq_puts(m, "L-shaped memory detected\n");
2146 intel_runtime_pm_put(dev_priv);
2151 static int per_file_ctx(int id, void *ptr, void *data)
2153 struct i915_gem_context *ctx = ptr;
2154 struct seq_file *m = data;
2155 struct i915_hw_ppgtt *ppgtt = ctx->ppgtt;
2158 seq_printf(m, " no ppgtt for context %d\n",
2163 if (i915_gem_context_is_default(ctx))
2164 seq_puts(m, " default context:\n");
2166 seq_printf(m, " context %d:\n", ctx->user_handle);
2167 ppgtt->debug_dump(ppgtt, m);
2172 static void gen8_ppgtt_info(struct seq_file *m,
2173 struct drm_i915_private *dev_priv)
2175 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
2176 struct intel_engine_cs *engine;
2177 enum intel_engine_id id;
2183 for_each_engine(engine, dev_priv, id) {
2184 seq_printf(m, "%s\n", engine->name);
2185 for (i = 0; i < 4; i++) {
2186 u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i));
2188 pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i));
2189 seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp);
2194 static void gen6_ppgtt_info(struct seq_file *m,
2195 struct drm_i915_private *dev_priv)
2197 struct intel_engine_cs *engine;
2198 enum intel_engine_id id;
2200 if (IS_GEN6(dev_priv))
2201 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
2203 for_each_engine(engine, dev_priv, id) {
2204 seq_printf(m, "%s\n", engine->name);
2205 if (IS_GEN7(dev_priv))
2206 seq_printf(m, "GFX_MODE: 0x%08x\n",
2207 I915_READ(RING_MODE_GEN7(engine)));
2208 seq_printf(m, "PP_DIR_BASE: 0x%08x\n",
2209 I915_READ(RING_PP_DIR_BASE(engine)));
2210 seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n",
2211 I915_READ(RING_PP_DIR_BASE_READ(engine)));
2212 seq_printf(m, "PP_DIR_DCLV: 0x%08x\n",
2213 I915_READ(RING_PP_DIR_DCLV(engine)));
2215 if (dev_priv->mm.aliasing_ppgtt) {
2216 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
2218 seq_puts(m, "aliasing PPGTT:\n");
2219 seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd.base.ggtt_offset);
2221 ppgtt->debug_dump(ppgtt, m);
2224 seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
2227 static int i915_ppgtt_info(struct seq_file *m, void *data)
2229 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2230 struct drm_device *dev = &dev_priv->drm;
2231 struct drm_file *file;
2234 mutex_lock(&dev->filelist_mutex);
2235 ret = mutex_lock_interruptible(&dev->struct_mutex);
2239 intel_runtime_pm_get(dev_priv);
2241 if (INTEL_GEN(dev_priv) >= 8)
2242 gen8_ppgtt_info(m, dev_priv);
2243 else if (INTEL_GEN(dev_priv) >= 6)
2244 gen6_ppgtt_info(m, dev_priv);
2246 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2247 struct drm_i915_file_private *file_priv = file->driver_priv;
2248 struct task_struct *task;
2250 task = get_pid_task(file->pid, PIDTYPE_PID);
2255 seq_printf(m, "\nproc: %s\n", task->comm);
2256 put_task_struct(task);
2257 idr_for_each(&file_priv->context_idr, per_file_ctx,
2258 (void *)(unsigned long)m);
2262 intel_runtime_pm_put(dev_priv);
2263 mutex_unlock(&dev->struct_mutex);
2265 mutex_unlock(&dev->filelist_mutex);
2269 static int count_irq_waiters(struct drm_i915_private *i915)
2271 struct intel_engine_cs *engine;
2272 enum intel_engine_id id;
2275 for_each_engine(engine, i915, id)
2276 count += intel_engine_has_waiter(engine);
2281 static const char *rps_power_to_str(unsigned int power)
2283 static const char * const strings[] = {
2284 [LOW_POWER] = "low power",
2285 [BETWEEN] = "mixed",
2286 [HIGH_POWER] = "high power",
2289 if (power >= ARRAY_SIZE(strings) || !strings[power])
2292 return strings[power];
2295 static int i915_rps_boost_info(struct seq_file *m, void *data)
2297 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2298 struct drm_device *dev = &dev_priv->drm;
2299 struct drm_file *file;
2301 seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled);
2302 seq_printf(m, "GPU busy? %s [%x]\n",
2303 yesno(dev_priv->gt.awake), dev_priv->gt.active_engines);
2304 seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv));
2305 seq_printf(m, "Frequency requested %d\n",
2306 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
2307 seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n",
2308 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq),
2309 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit),
2310 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit),
2311 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
2312 seq_printf(m, " idle:%d, efficient:%d, boost:%d\n",
2313 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq),
2314 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq),
2315 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
2317 mutex_lock(&dev->filelist_mutex);
2318 spin_lock(&dev_priv->rps.client_lock);
2319 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2320 struct drm_i915_file_private *file_priv = file->driver_priv;
2321 struct task_struct *task;
2324 task = pid_task(file->pid, PIDTYPE_PID);
2325 seq_printf(m, "%s [%d]: %d boosts%s\n",
2326 task ? task->comm : "<unknown>",
2327 task ? task->pid : -1,
2328 file_priv->rps.boosts,
2329 list_empty(&file_priv->rps.link) ? "" : ", active");
2332 seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts);
2333 spin_unlock(&dev_priv->rps.client_lock);
2334 mutex_unlock(&dev->filelist_mutex);
2336 if (INTEL_GEN(dev_priv) >= 6 &&
2337 dev_priv->rps.enabled &&
2338 dev_priv->gt.active_engines) {
2340 u32 rpdown, rpdownei;
2342 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
2343 rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK;
2344 rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK;
2345 rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK;
2346 rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK;
2347 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
2349 seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n",
2350 rps_power_to_str(dev_priv->rps.power));
2351 seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n",
2352 100 * rpup / rpupei,
2353 dev_priv->rps.up_threshold);
2354 seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n",
2355 100 * rpdown / rpdownei,
2356 dev_priv->rps.down_threshold);
2358 seq_puts(m, "\nRPS Autotuning inactive\n");
2364 static int i915_llc(struct seq_file *m, void *data)
2366 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2367 const bool edram = INTEL_GEN(dev_priv) > 8;
2369 seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv)));
2370 seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC",
2371 intel_uncore_edram_size(dev_priv)/1024/1024);
2376 static int i915_guc_load_status_info(struct seq_file *m, void *data)
2378 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2379 struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
2382 if (!HAS_GUC_UCODE(dev_priv))
2385 seq_printf(m, "GuC firmware status:\n");
2386 seq_printf(m, "\tpath: %s\n",
2387 guc_fw->guc_fw_path);
2388 seq_printf(m, "\tfetch: %s\n",
2389 intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status));
2390 seq_printf(m, "\tload: %s\n",
2391 intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
2392 seq_printf(m, "\tversion wanted: %d.%d\n",
2393 guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted);
2394 seq_printf(m, "\tversion found: %d.%d\n",
2395 guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found);
2396 seq_printf(m, "\theader: offset is %d; size = %d\n",
2397 guc_fw->header_offset, guc_fw->header_size);
2398 seq_printf(m, "\tuCode: offset is %d; size = %d\n",
2399 guc_fw->ucode_offset, guc_fw->ucode_size);
2400 seq_printf(m, "\tRSA: offset is %d; size = %d\n",
2401 guc_fw->rsa_offset, guc_fw->rsa_size);
2403 tmp = I915_READ(GUC_STATUS);
2405 seq_printf(m, "\nGuC status 0x%08x:\n", tmp);
2406 seq_printf(m, "\tBootrom status = 0x%x\n",
2407 (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT);
2408 seq_printf(m, "\tuKernel status = 0x%x\n",
2409 (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT);
2410 seq_printf(m, "\tMIA Core status = 0x%x\n",
2411 (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT);
2412 seq_puts(m, "\nScratch registers:\n");
2413 for (i = 0; i < 16; i++)
2414 seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i)));
2419 static void i915_guc_client_info(struct seq_file *m,
2420 struct drm_i915_private *dev_priv,
2421 struct i915_guc_client *client)
2423 struct intel_engine_cs *engine;
2424 enum intel_engine_id id;
2427 seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n",
2428 client->priority, client->ctx_index, client->proc_desc_offset);
2429 seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n",
2430 client->doorbell_id, client->doorbell_offset, client->cookie);
2431 seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n",
2432 client->wq_size, client->wq_offset, client->wq_tail);
2434 seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space);
2435 seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail);
2436 seq_printf(m, "\tLast submission result: %d\n", client->retcode);
2438 for_each_engine(engine, dev_priv, id) {
2439 u64 submissions = client->submissions[id];
2441 seq_printf(m, "\tSubmissions: %llu %s\n",
2442 submissions, engine->name);
2444 seq_printf(m, "\tTotal: %llu\n", tot);
2447 static int i915_guc_info(struct seq_file *m, void *data)
2449 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2450 struct drm_device *dev = &dev_priv->drm;
2451 struct intel_guc guc;
2452 struct i915_guc_client client = {};
2453 struct intel_engine_cs *engine;
2454 enum intel_engine_id id;
2457 if (!HAS_GUC_SCHED(dev_priv))
2460 if (mutex_lock_interruptible(&dev->struct_mutex))
2463 /* Take a local copy of the GuC data, so we can dump it at leisure */
2464 guc = dev_priv->guc;
2465 if (guc.execbuf_client)
2466 client = *guc.execbuf_client;
2468 mutex_unlock(&dev->struct_mutex);
2470 seq_printf(m, "Doorbell map:\n");
2471 seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc.doorbell_bitmap);
2472 seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc.db_cacheline);
2474 seq_printf(m, "GuC total action count: %llu\n", guc.action_count);
2475 seq_printf(m, "GuC action failure count: %u\n", guc.action_fail);
2476 seq_printf(m, "GuC last action command: 0x%x\n", guc.action_cmd);
2477 seq_printf(m, "GuC last action status: 0x%x\n", guc.action_status);
2478 seq_printf(m, "GuC last action error code: %d\n", guc.action_err);
2480 seq_printf(m, "\nGuC submissions:\n");
2481 for_each_engine(engine, dev_priv, id) {
2482 u64 submissions = guc.submissions[id];
2483 total += submissions;
2484 seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n",
2485 engine->name, submissions, guc.last_seqno[id]);
2487 seq_printf(m, "\t%s: %llu\n", "Total", total);
2489 seq_printf(m, "\nGuC execbuf client @ %p:\n", guc.execbuf_client);
2490 i915_guc_client_info(m, dev_priv, &client);
2492 /* Add more as required ... */
2497 static int i915_guc_log_dump(struct seq_file *m, void *data)
2499 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2500 struct drm_i915_gem_object *obj;
2503 if (!dev_priv->guc.log_vma)
2506 obj = dev_priv->guc.log_vma->obj;
2507 for (pg = 0; pg < obj->base.size / PAGE_SIZE; pg++) {
2508 u32 *log = kmap_atomic(i915_gem_object_get_page(obj, pg));
2510 for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4)
2511 seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n",
2512 *(log + i), *(log + i + 1),
2513 *(log + i + 2), *(log + i + 3));
2523 static int i915_edp_psr_status(struct seq_file *m, void *data)
2525 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2529 bool enabled = false;
2531 if (!HAS_PSR(dev_priv)) {
2532 seq_puts(m, "PSR not supported\n");
2536 intel_runtime_pm_get(dev_priv);
2538 mutex_lock(&dev_priv->psr.lock);
2539 seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support));
2540 seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok));
2541 seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled));
2542 seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
2543 seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
2544 dev_priv->psr.busy_frontbuffer_bits);
2545 seq_printf(m, "Re-enable work scheduled: %s\n",
2546 yesno(work_busy(&dev_priv->psr.work.work)));
2548 if (HAS_DDI(dev_priv))
2549 enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE;
2551 for_each_pipe(dev_priv, pipe) {
2552 enum transcoder cpu_transcoder =
2553 intel_pipe_to_cpu_transcoder(dev_priv, pipe);
2554 enum intel_display_power_domain power_domain;
2556 power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder);
2557 if (!intel_display_power_get_if_enabled(dev_priv,
2561 stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) &
2562 VLV_EDP_PSR_CURR_STATE_MASK;
2563 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2564 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2567 intel_display_power_put(dev_priv, power_domain);
2571 seq_printf(m, "Main link in standby mode: %s\n",
2572 yesno(dev_priv->psr.link_standby));
2574 seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled));
2576 if (!HAS_DDI(dev_priv))
2577 for_each_pipe(dev_priv, pipe) {
2578 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2579 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2580 seq_printf(m, " pipe %c", pipe_name(pipe));
2585 * VLV/CHV PSR has no kind of performance counter
2586 * SKL+ Perf counter is reset to 0 everytime DC state is entered
2588 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
2589 psrperf = I915_READ(EDP_PSR_PERF_CNT) &
2590 EDP_PSR_PERF_CNT_MASK;
2592 seq_printf(m, "Performance_Counter: %u\n", psrperf);
2594 mutex_unlock(&dev_priv->psr.lock);
2596 intel_runtime_pm_put(dev_priv);
2600 static int i915_sink_crc(struct seq_file *m, void *data)
2602 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2603 struct drm_device *dev = &dev_priv->drm;
2604 struct intel_connector *connector;
2605 struct intel_dp *intel_dp = NULL;
2609 drm_modeset_lock_all(dev);
2610 for_each_intel_connector(dev, connector) {
2611 struct drm_crtc *crtc;
2613 if (!connector->base.state->best_encoder)
2616 crtc = connector->base.state->crtc;
2617 if (!crtc->state->active)
2620 if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP)
2623 intel_dp = enc_to_intel_dp(connector->base.state->best_encoder);
2625 ret = intel_dp_sink_crc(intel_dp, crc);
2629 seq_printf(m, "%02x%02x%02x%02x%02x%02x\n",
2630 crc[0], crc[1], crc[2],
2631 crc[3], crc[4], crc[5]);
2636 drm_modeset_unlock_all(dev);
2640 static int i915_energy_uJ(struct seq_file *m, void *data)
2642 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2646 if (INTEL_GEN(dev_priv) < 6)
2649 intel_runtime_pm_get(dev_priv);
2651 rdmsrl(MSR_RAPL_POWER_UNIT, power);
2652 power = (power & 0x1f00) >> 8;
2653 units = 1000000 / (1 << power); /* convert to uJ */
2654 power = I915_READ(MCH_SECP_NRG_STTS);
2657 intel_runtime_pm_put(dev_priv);
2659 seq_printf(m, "%llu", (long long unsigned)power);
2664 static int i915_runtime_pm_status(struct seq_file *m, void *unused)
2666 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2667 struct pci_dev *pdev = dev_priv->drm.pdev;
2669 if (!HAS_RUNTIME_PM(dev_priv))
2670 seq_puts(m, "Runtime power management not supported\n");
2672 seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake));
2673 seq_printf(m, "IRQs disabled: %s\n",
2674 yesno(!intel_irqs_enabled(dev_priv)));
2676 seq_printf(m, "Usage count: %d\n",
2677 atomic_read(&dev_priv->drm.dev->power.usage_count));
2679 seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n");
2681 seq_printf(m, "PCI device power state: %s [%d]\n",
2682 pci_power_name(pdev->current_state),
2683 pdev->current_state);
2688 static int i915_power_domain_info(struct seq_file *m, void *unused)
2690 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2691 struct i915_power_domains *power_domains = &dev_priv->power_domains;
2694 mutex_lock(&power_domains->lock);
2696 seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count");
2697 for (i = 0; i < power_domains->power_well_count; i++) {
2698 struct i915_power_well *power_well;
2699 enum intel_display_power_domain power_domain;
2701 power_well = &power_domains->power_wells[i];
2702 seq_printf(m, "%-25s %d\n", power_well->name,
2705 for (power_domain = 0; power_domain < POWER_DOMAIN_NUM;
2707 if (!(BIT(power_domain) & power_well->domains))
2710 seq_printf(m, " %-23s %d\n",
2711 intel_display_power_domain_str(power_domain),
2712 power_domains->domain_use_count[power_domain]);
2716 mutex_unlock(&power_domains->lock);
2721 static int i915_dmc_info(struct seq_file *m, void *unused)
2723 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2724 struct intel_csr *csr;
2726 if (!HAS_CSR(dev_priv)) {
2727 seq_puts(m, "not supported\n");
2731 csr = &dev_priv->csr;
2733 intel_runtime_pm_get(dev_priv);
2735 seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL));
2736 seq_printf(m, "path: %s\n", csr->fw_path);
2738 if (!csr->dmc_payload)
2741 seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version),
2742 CSR_VERSION_MINOR(csr->version));
2744 if (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6)) {
2745 seq_printf(m, "DC3 -> DC5 count: %d\n",
2746 I915_READ(SKL_CSR_DC3_DC5_COUNT));
2747 seq_printf(m, "DC5 -> DC6 count: %d\n",
2748 I915_READ(SKL_CSR_DC5_DC6_COUNT));
2749 } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) {
2750 seq_printf(m, "DC3 -> DC5 count: %d\n",
2751 I915_READ(BXT_CSR_DC3_DC5_COUNT));
2755 seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0)));
2756 seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE));
2757 seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL));
2759 intel_runtime_pm_put(dev_priv);
2764 static void intel_seq_print_mode(struct seq_file *m, int tabs,
2765 struct drm_display_mode *mode)
2769 for (i = 0; i < tabs; i++)
2772 seq_printf(m, "id %d:\"%s\" freq %d clock %d hdisp %d hss %d hse %d htot %d vdisp %d vss %d vse %d vtot %d type 0x%x flags 0x%x\n",
2773 mode->base.id, mode->name,
2774 mode->vrefresh, mode->clock,
2775 mode->hdisplay, mode->hsync_start,
2776 mode->hsync_end, mode->htotal,
2777 mode->vdisplay, mode->vsync_start,
2778 mode->vsync_end, mode->vtotal,
2779 mode->type, mode->flags);
2782 static void intel_encoder_info(struct seq_file *m,
2783 struct intel_crtc *intel_crtc,
2784 struct intel_encoder *intel_encoder)
2786 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2787 struct drm_device *dev = &dev_priv->drm;
2788 struct drm_crtc *crtc = &intel_crtc->base;
2789 struct intel_connector *intel_connector;
2790 struct drm_encoder *encoder;
2792 encoder = &intel_encoder->base;
2793 seq_printf(m, "\tencoder %d: type: %s, connectors:\n",
2794 encoder->base.id, encoder->name);
2795 for_each_connector_on_encoder(dev, encoder, intel_connector) {
2796 struct drm_connector *connector = &intel_connector->base;
2797 seq_printf(m, "\t\tconnector %d: type: %s, status: %s",
2800 drm_get_connector_status_name(connector->status));
2801 if (connector->status == connector_status_connected) {
2802 struct drm_display_mode *mode = &crtc->mode;
2803 seq_printf(m, ", mode:\n");
2804 intel_seq_print_mode(m, 2, mode);
2811 static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc)
2813 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2814 struct drm_device *dev = &dev_priv->drm;
2815 struct drm_crtc *crtc = &intel_crtc->base;
2816 struct intel_encoder *intel_encoder;
2817 struct drm_plane_state *plane_state = crtc->primary->state;
2818 struct drm_framebuffer *fb = plane_state->fb;
2821 seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n",
2822 fb->base.id, plane_state->src_x >> 16,
2823 plane_state->src_y >> 16, fb->width, fb->height);
2825 seq_puts(m, "\tprimary plane disabled\n");
2826 for_each_encoder_on_crtc(dev, crtc, intel_encoder)
2827 intel_encoder_info(m, intel_crtc, intel_encoder);
2830 static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
2832 struct drm_display_mode *mode = panel->fixed_mode;
2834 seq_printf(m, "\tfixed mode:\n");
2835 intel_seq_print_mode(m, 2, mode);
2838 static void intel_dp_info(struct seq_file *m,
2839 struct intel_connector *intel_connector)
2841 struct intel_encoder *intel_encoder = intel_connector->encoder;
2842 struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
2844 seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]);
2845 seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio));
2846 if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)
2847 intel_panel_info(m, &intel_connector->panel);
2849 drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports,
2853 static void intel_hdmi_info(struct seq_file *m,
2854 struct intel_connector *intel_connector)
2856 struct intel_encoder *intel_encoder = intel_connector->encoder;
2857 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
2859 seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio));
2862 static void intel_lvds_info(struct seq_file *m,
2863 struct intel_connector *intel_connector)
2865 intel_panel_info(m, &intel_connector->panel);
2868 static void intel_connector_info(struct seq_file *m,
2869 struct drm_connector *connector)
2871 struct intel_connector *intel_connector = to_intel_connector(connector);
2872 struct intel_encoder *intel_encoder = intel_connector->encoder;
2873 struct drm_display_mode *mode;
2875 seq_printf(m, "connector %d: type %s, status: %s\n",
2876 connector->base.id, connector->name,
2877 drm_get_connector_status_name(connector->status));
2878 if (connector->status == connector_status_connected) {
2879 seq_printf(m, "\tname: %s\n", connector->display_info.name);
2880 seq_printf(m, "\tphysical dimensions: %dx%dmm\n",
2881 connector->display_info.width_mm,
2882 connector->display_info.height_mm);
2883 seq_printf(m, "\tsubpixel order: %s\n",
2884 drm_get_subpixel_order_name(connector->display_info.subpixel_order));
2885 seq_printf(m, "\tCEA rev: %d\n",
2886 connector->display_info.cea_rev);
2889 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
2892 switch (connector->connector_type) {
2893 case DRM_MODE_CONNECTOR_DisplayPort:
2894 case DRM_MODE_CONNECTOR_eDP:
2895 intel_dp_info(m, intel_connector);
2897 case DRM_MODE_CONNECTOR_LVDS:
2898 if (intel_encoder->type == INTEL_OUTPUT_LVDS)
2899 intel_lvds_info(m, intel_connector);
2901 case DRM_MODE_CONNECTOR_HDMIA:
2902 if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
2903 intel_encoder->type == INTEL_OUTPUT_UNKNOWN)
2904 intel_hdmi_info(m, intel_connector);
2910 seq_printf(m, "\tmodes:\n");
2911 list_for_each_entry(mode, &connector->modes, head)
2912 intel_seq_print_mode(m, 2, mode);
2915 static bool cursor_active(struct drm_i915_private *dev_priv, int pipe)
2919 if (IS_845G(dev_priv) || IS_I865G(dev_priv))
2920 state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE;
2922 state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE;
2927 static bool cursor_position(struct drm_i915_private *dev_priv,
2928 int pipe, int *x, int *y)
2932 pos = I915_READ(CURPOS(pipe));
2934 *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK;
2935 if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT))
2938 *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK;
2939 if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT))
2942 return cursor_active(dev_priv, pipe);
2945 static const char *plane_type(enum drm_plane_type type)
2948 case DRM_PLANE_TYPE_OVERLAY:
2950 case DRM_PLANE_TYPE_PRIMARY:
2952 case DRM_PLANE_TYPE_CURSOR:
2955 * Deliberately omitting default: to generate compiler warnings
2956 * when a new drm_plane_type gets added.
2963 static const char *plane_rotation(unsigned int rotation)
2965 static char buf[48];
2967 * According to doc only one DRM_ROTATE_ is allowed but this
2968 * will print them all to visualize if the values are misused
2970 snprintf(buf, sizeof(buf),
2971 "%s%s%s%s%s%s(0x%08x)",
2972 (rotation & DRM_ROTATE_0) ? "0 " : "",
2973 (rotation & DRM_ROTATE_90) ? "90 " : "",
2974 (rotation & DRM_ROTATE_180) ? "180 " : "",
2975 (rotation & DRM_ROTATE_270) ? "270 " : "",
2976 (rotation & DRM_REFLECT_X) ? "FLIPX " : "",
2977 (rotation & DRM_REFLECT_Y) ? "FLIPY " : "",
2983 static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)
2985 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2986 struct drm_device *dev = &dev_priv->drm;
2987 struct intel_plane *intel_plane;
2989 for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
2990 struct drm_plane_state *state;
2991 struct drm_plane *plane = &intel_plane->base;
2994 if (!plane->state) {
2995 seq_puts(m, "plane->state is NULL!\n");
2999 state = plane->state;
3002 format_name = drm_get_format_name(state->fb->pixel_format);
3004 format_name = kstrdup("N/A", GFP_KERNEL);
3007 seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",
3009 plane_type(intel_plane->base.type),
3010 state->crtc_x, state->crtc_y,
3011 state->crtc_w, state->crtc_h,
3012 (state->src_x >> 16),
3013 ((state->src_x & 0xffff) * 15625) >> 10,
3014 (state->src_y >> 16),
3015 ((state->src_y & 0xffff) * 15625) >> 10,
3016 (state->src_w >> 16),
3017 ((state->src_w & 0xffff) * 15625) >> 10,
3018 (state->src_h >> 16),
3019 ((state->src_h & 0xffff) * 15625) >> 10,
3021 plane_rotation(state->rotation));
3027 static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3029 struct intel_crtc_state *pipe_config;
3030 int num_scalers = intel_crtc->num_scalers;
3033 pipe_config = to_intel_crtc_state(intel_crtc->base.state);
3035 /* Not all platformas have a scaler */
3037 seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d",
3039 pipe_config->scaler_state.scaler_users,
3040 pipe_config->scaler_state.scaler_id);
3042 for (i = 0; i < SKL_NUM_SCALERS; i++) {
3043 struct intel_scaler *sc =
3044 &pipe_config->scaler_state.scalers[i];
3046 seq_printf(m, ", scalers[%d]: use=%s, mode=%x",
3047 i, yesno(sc->in_use), sc->mode);
3051 seq_puts(m, "\tNo scalers available on this platform\n");
3055 static int i915_display_info(struct seq_file *m, void *unused)
3057 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3058 struct drm_device *dev = &dev_priv->drm;
3059 struct intel_crtc *crtc;
3060 struct drm_connector *connector;
3062 intel_runtime_pm_get(dev_priv);
3063 drm_modeset_lock_all(dev);
3064 seq_printf(m, "CRTC info\n");
3065 seq_printf(m, "---------\n");
3066 for_each_intel_crtc(dev, crtc) {
3068 struct intel_crtc_state *pipe_config;
3071 pipe_config = to_intel_crtc_state(crtc->base.state);
3073 seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n",
3074 crtc->base.base.id, pipe_name(crtc->pipe),
3075 yesno(pipe_config->base.active),
3076 pipe_config->pipe_src_w, pipe_config->pipe_src_h,
3077 yesno(pipe_config->dither), pipe_config->pipe_bpp);
3079 if (pipe_config->base.active) {
3080 intel_crtc_info(m, crtc);
3082 active = cursor_position(dev_priv, crtc->pipe, &x, &y);
3083 seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x, active? %s\n",
3084 yesno(crtc->cursor_base),
3085 x, y, crtc->base.cursor->state->crtc_w,
3086 crtc->base.cursor->state->crtc_h,
3087 crtc->cursor_addr, yesno(active));
3088 intel_scaler_info(m, crtc);
3089 intel_plane_info(m, crtc);
3092 seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n",
3093 yesno(!crtc->cpu_fifo_underrun_disabled),
3094 yesno(!crtc->pch_fifo_underrun_disabled));
3097 seq_printf(m, "\n");
3098 seq_printf(m, "Connector info\n");
3099 seq_printf(m, "--------------\n");
3100 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
3101 intel_connector_info(m, connector);
3103 drm_modeset_unlock_all(dev);
3104 intel_runtime_pm_put(dev_priv);
3109 static int i915_engine_info(struct seq_file *m, void *unused)
3111 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3112 struct intel_engine_cs *engine;
3113 enum intel_engine_id id;
3115 intel_runtime_pm_get(dev_priv);
3117 for_each_engine(engine, dev_priv, id) {
3118 struct intel_breadcrumbs *b = &engine->breadcrumbs;
3119 struct drm_i915_gem_request *rq;
3123 seq_printf(m, "%s\n", engine->name);
3124 seq_printf(m, "\tcurrent seqno %x, last %x, hangcheck %x [score %d]\n",
3125 intel_engine_get_seqno(engine),
3126 engine->last_submitted_seqno,
3127 engine->hangcheck.seqno,
3128 engine->hangcheck.score);
3132 seq_printf(m, "\tRequests:\n");
3134 rq = list_first_entry(&engine->request_list,
3135 struct drm_i915_gem_request, link);
3136 if (&rq->link != &engine->request_list)
3137 print_request(m, rq, "\t\tfirst ");
3139 rq = list_last_entry(&engine->request_list,
3140 struct drm_i915_gem_request, link);
3141 if (&rq->link != &engine->request_list)
3142 print_request(m, rq, "\t\tlast ");
3144 rq = i915_gem_find_active_request(engine);
3146 print_request(m, rq, "\t\tactive ");
3148 "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n",
3149 rq->head, rq->postfix, rq->tail,
3150 rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u,
3151 rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u);
3154 seq_printf(m, "\tRING_START: 0x%08x [0x%08x]\n",
3155 I915_READ(RING_START(engine->mmio_base)),
3156 rq ? i915_ggtt_offset(rq->ring->vma) : 0);
3157 seq_printf(m, "\tRING_HEAD: 0x%08x [0x%08x]\n",
3158 I915_READ(RING_HEAD(engine->mmio_base)) & HEAD_ADDR,
3159 rq ? rq->ring->head : 0);
3160 seq_printf(m, "\tRING_TAIL: 0x%08x [0x%08x]\n",
3161 I915_READ(RING_TAIL(engine->mmio_base)) & TAIL_ADDR,
3162 rq ? rq->ring->tail : 0);
3163 seq_printf(m, "\tRING_CTL: 0x%08x [%s]\n",
3164 I915_READ(RING_CTL(engine->mmio_base)),
3165 I915_READ(RING_CTL(engine->mmio_base)) & (RING_WAIT | RING_WAIT_SEMAPHORE) ? "waiting" : "");
3169 addr = intel_engine_get_active_head(engine);
3170 seq_printf(m, "\tACTHD: 0x%08x_%08x\n",
3171 upper_32_bits(addr), lower_32_bits(addr));
3172 addr = intel_engine_get_last_batch_head(engine);
3173 seq_printf(m, "\tBBADDR: 0x%08x_%08x\n",
3174 upper_32_bits(addr), lower_32_bits(addr));
3176 if (i915.enable_execlists) {
3177 u32 ptr, read, write;
3179 seq_printf(m, "\tExeclist status: 0x%08x %08x\n",
3180 I915_READ(RING_EXECLIST_STATUS_LO(engine)),
3181 I915_READ(RING_EXECLIST_STATUS_HI(engine)));
3183 ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine));
3184 read = GEN8_CSB_READ_PTR(ptr);
3185 write = GEN8_CSB_WRITE_PTR(ptr);
3186 seq_printf(m, "\tExeclist CSB read %d, write %d\n",
3188 if (read >= GEN8_CSB_ENTRIES)
3190 if (write >= GEN8_CSB_ENTRIES)
3193 write += GEN8_CSB_ENTRIES;
3194 while (read < write) {
3195 unsigned int idx = ++read % GEN8_CSB_ENTRIES;
3197 seq_printf(m, "\tExeclist CSB[%d]: 0x%08x, context: %d\n",
3199 I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, idx)),
3200 I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, idx)));
3204 rq = READ_ONCE(engine->execlist_port[0].request);
3206 print_request(m, rq, "\t\tELSP[0] ");
3208 seq_printf(m, "\t\tELSP[0] idle\n");
3209 rq = READ_ONCE(engine->execlist_port[1].request);
3211 print_request(m, rq, "\t\tELSP[1] ");
3213 seq_printf(m, "\t\tELSP[1] idle\n");
3215 } else if (INTEL_GEN(dev_priv) > 6) {
3216 seq_printf(m, "\tPP_DIR_BASE: 0x%08x\n",
3217 I915_READ(RING_PP_DIR_BASE(engine)));
3218 seq_printf(m, "\tPP_DIR_BASE_READ: 0x%08x\n",
3219 I915_READ(RING_PP_DIR_BASE_READ(engine)));
3220 seq_printf(m, "\tPP_DIR_DCLV: 0x%08x\n",
3221 I915_READ(RING_PP_DIR_DCLV(engine)));
3224 spin_lock(&b->lock);
3225 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
3226 struct intel_wait *w = container_of(rb, typeof(*w), node);
3228 seq_printf(m, "\t%s [%d] waiting for %x\n",
3229 w->tsk->comm, w->tsk->pid, w->seqno);
3231 spin_unlock(&b->lock);
3236 intel_runtime_pm_put(dev_priv);
3241 static int i915_semaphore_status(struct seq_file *m, void *unused)
3243 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3244 struct drm_device *dev = &dev_priv->drm;
3245 struct intel_engine_cs *engine;
3246 int num_rings = INTEL_INFO(dev_priv)->num_rings;
3247 enum intel_engine_id id;
3250 if (!i915.semaphores) {
3251 seq_puts(m, "Semaphores are disabled\n");
3255 ret = mutex_lock_interruptible(&dev->struct_mutex);
3258 intel_runtime_pm_get(dev_priv);
3260 if (IS_BROADWELL(dev_priv)) {
3264 page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0);
3266 seqno = (uint64_t *)kmap_atomic(page);
3267 for_each_engine(engine, dev_priv, id) {
3270 seq_printf(m, "%s\n", engine->name);
3272 seq_puts(m, " Last signal:");
3273 for (j = 0; j < num_rings; j++) {
3274 offset = id * I915_NUM_ENGINES + j;
3275 seq_printf(m, "0x%08llx (0x%02llx) ",
3276 seqno[offset], offset * 8);
3280 seq_puts(m, " Last wait: ");
3281 for (j = 0; j < num_rings; j++) {
3282 offset = id + (j * I915_NUM_ENGINES);
3283 seq_printf(m, "0x%08llx (0x%02llx) ",
3284 seqno[offset], offset * 8);
3289 kunmap_atomic(seqno);
3291 seq_puts(m, " Last signal:");
3292 for_each_engine(engine, dev_priv, id)
3293 for (j = 0; j < num_rings; j++)
3294 seq_printf(m, "0x%08x\n",
3295 I915_READ(engine->semaphore.mbox.signal[j]));
3299 seq_puts(m, "\nSync seqno:\n");
3300 for_each_engine(engine, dev_priv, id) {
3301 for (j = 0; j < num_rings; j++)
3302 seq_printf(m, " 0x%08x ",
3303 engine->semaphore.sync_seqno[j]);
3308 intel_runtime_pm_put(dev_priv);
3309 mutex_unlock(&dev->struct_mutex);
3313 static int i915_shared_dplls_info(struct seq_file *m, void *unused)
3315 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3316 struct drm_device *dev = &dev_priv->drm;
3319 drm_modeset_lock_all(dev);
3320 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3321 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
3323 seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id);
3324 seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n",
3325 pll->config.crtc_mask, pll->active_mask, yesno(pll->on));
3326 seq_printf(m, " tracked hardware state:\n");
3327 seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll);
3328 seq_printf(m, " dpll_md: 0x%08x\n",
3329 pll->config.hw_state.dpll_md);
3330 seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0);
3331 seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1);
3332 seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll);
3334 drm_modeset_unlock_all(dev);
3339 static int i915_wa_registers(struct seq_file *m, void *unused)
3343 struct intel_engine_cs *engine;
3344 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3345 struct drm_device *dev = &dev_priv->drm;
3346 struct i915_workarounds *workarounds = &dev_priv->workarounds;
3347 enum intel_engine_id id;
3349 ret = mutex_lock_interruptible(&dev->struct_mutex);
3353 intel_runtime_pm_get(dev_priv);
3355 seq_printf(m, "Workarounds applied: %d\n", workarounds->count);
3356 for_each_engine(engine, dev_priv, id)
3357 seq_printf(m, "HW whitelist count for %s: %d\n",
3358 engine->name, workarounds->hw_whitelist_count[id]);
3359 for (i = 0; i < workarounds->count; ++i) {
3361 u32 mask, value, read;
3364 addr = workarounds->reg[i].addr;
3365 mask = workarounds->reg[i].mask;
3366 value = workarounds->reg[i].value;
3367 read = I915_READ(addr);
3368 ok = (value & mask) == (read & mask);
3369 seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n",
3370 i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL");
3373 intel_runtime_pm_put(dev_priv);
3374 mutex_unlock(&dev->struct_mutex);
3379 static int i915_ddb_info(struct seq_file *m, void *unused)
3381 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3382 struct drm_device *dev = &dev_priv->drm;
3383 struct skl_ddb_allocation *ddb;
3384 struct skl_ddb_entry *entry;
3388 if (INTEL_GEN(dev_priv) < 9)
3391 drm_modeset_lock_all(dev);
3393 ddb = &dev_priv->wm.skl_hw.ddb;
3395 seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
3397 for_each_pipe(dev_priv, pipe) {
3398 seq_printf(m, "Pipe %c\n", pipe_name(pipe));
3400 for_each_plane(dev_priv, pipe, plane) {
3401 entry = &ddb->plane[pipe][plane];
3402 seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1,
3403 entry->start, entry->end,
3404 skl_ddb_entry_size(entry));
3407 entry = &ddb->plane[pipe][PLANE_CURSOR];
3408 seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start,
3409 entry->end, skl_ddb_entry_size(entry));
3412 drm_modeset_unlock_all(dev);
3417 static void drrs_status_per_crtc(struct seq_file *m,
3418 struct drm_device *dev,
3419 struct intel_crtc *intel_crtc)
3421 struct drm_i915_private *dev_priv = to_i915(dev);
3422 struct i915_drrs *drrs = &dev_priv->drrs;
3424 struct drm_connector *connector;
3426 drm_for_each_connector(connector, dev) {
3427 if (connector->state->crtc != &intel_crtc->base)
3430 seq_printf(m, "%s:\n", connector->name);
3433 if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT)
3434 seq_puts(m, "\tVBT: DRRS_type: Static");
3435 else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT)
3436 seq_puts(m, "\tVBT: DRRS_type: Seamless");
3437 else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED)
3438 seq_puts(m, "\tVBT: DRRS_type: None");
3440 seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value");
3442 seq_puts(m, "\n\n");
3444 if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) {
3445 struct intel_panel *panel;
3447 mutex_lock(&drrs->mutex);
3448 /* DRRS Supported */
3449 seq_puts(m, "\tDRRS Supported: Yes\n");
3451 /* disable_drrs() will make drrs->dp NULL */
3453 seq_puts(m, "Idleness DRRS: Disabled");
3454 mutex_unlock(&drrs->mutex);
3458 panel = &drrs->dp->attached_connector->panel;
3459 seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X",
3460 drrs->busy_frontbuffer_bits);
3462 seq_puts(m, "\n\t\t");
3463 if (drrs->refresh_rate_type == DRRS_HIGH_RR) {
3464 seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n");
3465 vrefresh = panel->fixed_mode->vrefresh;
3466 } else if (drrs->refresh_rate_type == DRRS_LOW_RR) {
3467 seq_puts(m, "DRRS_State: DRRS_LOW_RR\n");
3468 vrefresh = panel->downclock_mode->vrefresh;
3470 seq_printf(m, "DRRS_State: Unknown(%d)\n",
3471 drrs->refresh_rate_type);
3472 mutex_unlock(&drrs->mutex);
3475 seq_printf(m, "\t\tVrefresh: %d", vrefresh);
3477 seq_puts(m, "\n\t\t");
3478 mutex_unlock(&drrs->mutex);
3480 /* DRRS not supported. Print the VBT parameter*/
3481 seq_puts(m, "\tDRRS Supported : No");
3486 static int i915_drrs_status(struct seq_file *m, void *unused)
3488 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3489 struct drm_device *dev = &dev_priv->drm;
3490 struct intel_crtc *intel_crtc;
3491 int active_crtc_cnt = 0;
3493 drm_modeset_lock_all(dev);
3494 for_each_intel_crtc(dev, intel_crtc) {
3495 if (intel_crtc->base.state->active) {
3497 seq_printf(m, "\nCRTC %d: ", active_crtc_cnt);
3499 drrs_status_per_crtc(m, dev, intel_crtc);
3502 drm_modeset_unlock_all(dev);
3504 if (!active_crtc_cnt)
3505 seq_puts(m, "No active crtc found\n");
3510 struct pipe_crc_info {
3512 struct drm_i915_private *dev_priv;
3516 static int i915_dp_mst_info(struct seq_file *m, void *unused)
3518 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3519 struct drm_device *dev = &dev_priv->drm;
3520 struct intel_encoder *intel_encoder;
3521 struct intel_digital_port *intel_dig_port;
3522 struct drm_connector *connector;
3524 drm_modeset_lock_all(dev);
3525 drm_for_each_connector(connector, dev) {
3526 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
3529 intel_encoder = intel_attached_encoder(connector);
3530 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
3533 intel_dig_port = enc_to_dig_port(&intel_encoder->base);
3534 if (!intel_dig_port->dp.can_mst)
3537 seq_printf(m, "MST Source Port %c\n",
3538 port_name(intel_dig_port->port));
3539 drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr);
3541 drm_modeset_unlock_all(dev);
3545 static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
3547 struct pipe_crc_info *info = inode->i_private;
3548 struct drm_i915_private *dev_priv = info->dev_priv;
3549 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
3551 if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
3554 spin_lock_irq(&pipe_crc->lock);
3556 if (pipe_crc->opened) {
3557 spin_unlock_irq(&pipe_crc->lock);
3558 return -EBUSY; /* already open */
3561 pipe_crc->opened = true;
3562 filep->private_data = inode->i_private;
3564 spin_unlock_irq(&pipe_crc->lock);
3569 static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
3571 struct pipe_crc_info *info = inode->i_private;
3572 struct drm_i915_private *dev_priv = info->dev_priv;
3573 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
3575 spin_lock_irq(&pipe_crc->lock);
3576 pipe_crc->opened = false;
3577 spin_unlock_irq(&pipe_crc->lock);
3582 /* (6 fields, 8 chars each, space separated (5) + '\n') */
3583 #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1)
3584 /* account for \'0' */
3585 #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1)
3587 static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
3589 assert_spin_locked(&pipe_crc->lock);
3590 return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
3591 INTEL_PIPE_CRC_ENTRIES_NR);
3595 i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
3598 struct pipe_crc_info *info = filep->private_data;
3599 struct drm_i915_private *dev_priv = info->dev_priv;
3600 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
3601 char buf[PIPE_CRC_BUFFER_LEN];
3606 * Don't allow user space to provide buffers not big enough to hold
3609 if (count < PIPE_CRC_LINE_LEN)
3612 if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
3615 /* nothing to read */
3616 spin_lock_irq(&pipe_crc->lock);
3617 while (pipe_crc_data_count(pipe_crc) == 0) {
3620 if (filep->f_flags & O_NONBLOCK) {
3621 spin_unlock_irq(&pipe_crc->lock);
3625 ret = wait_event_interruptible_lock_irq(pipe_crc->wq,
3626 pipe_crc_data_count(pipe_crc), pipe_crc->lock);
3628 spin_unlock_irq(&pipe_crc->lock);
3633 /* We now have one or more entries to read */
3634 n_entries = count / PIPE_CRC_LINE_LEN;
3637 while (n_entries > 0) {
3638 struct intel_pipe_crc_entry *entry =
3639 &pipe_crc->entries[pipe_crc->tail];
3641 if (CIRC_CNT(pipe_crc->head, pipe_crc->tail,
3642 INTEL_PIPE_CRC_ENTRIES_NR) < 1)
3645 BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR);
3646 pipe_crc->tail = (pipe_crc->tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
3648 bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN,
3649 "%8u %8x %8x %8x %8x %8x\n",
3650 entry->frame, entry->crc[0],
3651 entry->crc[1], entry->crc[2],
3652 entry->crc[3], entry->crc[4]);
3654 spin_unlock_irq(&pipe_crc->lock);
3656 if (copy_to_user(user_buf, buf, PIPE_CRC_LINE_LEN))
3659 user_buf += PIPE_CRC_LINE_LEN;
3662 spin_lock_irq(&pipe_crc->lock);
3665 spin_unlock_irq(&pipe_crc->lock);
3670 static const struct file_operations i915_pipe_crc_fops = {
3671 .owner = THIS_MODULE,
3672 .open = i915_pipe_crc_open,
3673 .read = i915_pipe_crc_read,
3674 .release = i915_pipe_crc_release,
3677 static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = {
3679 .name = "i915_pipe_A_crc",
3683 .name = "i915_pipe_B_crc",
3687 .name = "i915_pipe_C_crc",
3692 static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor,
3695 struct drm_i915_private *dev_priv = to_i915(minor->dev);
3697 struct pipe_crc_info *info = &i915_pipe_crc_data[pipe];
3699 info->dev_priv = dev_priv;
3700 ent = debugfs_create_file(info->name, S_IRUGO, root, info,
3701 &i915_pipe_crc_fops);
3705 return drm_add_fake_info_node(minor, ent, info);
3708 static const char * const pipe_crc_sources[] = {
3721 static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)
3723 BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX);
3724 return pipe_crc_sources[source];
3727 static int display_crc_ctl_show(struct seq_file *m, void *data)
3729 struct drm_i915_private *dev_priv = m->private;
3732 for (i = 0; i < I915_MAX_PIPES; i++)
3733 seq_printf(m, "%c %s\n", pipe_name(i),
3734 pipe_crc_source_name(dev_priv->pipe_crc[i].source));
3739 static int display_crc_ctl_open(struct inode *inode, struct file *file)
3741 return single_open(file, display_crc_ctl_show, inode->i_private);
3744 static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
3747 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
3748 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
3751 case INTEL_PIPE_CRC_SOURCE_PIPE:
3752 *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX;
3754 case INTEL_PIPE_CRC_SOURCE_NONE:
3764 static int i9xx_pipe_crc_auto_source(struct drm_i915_private *dev_priv,
3766 enum intel_pipe_crc_source *source)
3768 struct drm_device *dev = &dev_priv->drm;
3769 struct intel_encoder *encoder;
3770 struct intel_crtc *crtc;
3771 struct intel_digital_port *dig_port;
3774 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
3776 drm_modeset_lock_all(dev);
3777 for_each_intel_encoder(dev, encoder) {
3778 if (!encoder->base.crtc)
3781 crtc = to_intel_crtc(encoder->base.crtc);
3783 if (crtc->pipe != pipe)
3786 switch (encoder->type) {
3787 case INTEL_OUTPUT_TVOUT:
3788 *source = INTEL_PIPE_CRC_SOURCE_TV;
3790 case INTEL_OUTPUT_DP:
3791 case INTEL_OUTPUT_EDP:
3792 dig_port = enc_to_dig_port(&encoder->base);
3793 switch (dig_port->port) {
3795 *source = INTEL_PIPE_CRC_SOURCE_DP_B;
3798 *source = INTEL_PIPE_CRC_SOURCE_DP_C;
3801 *source = INTEL_PIPE_CRC_SOURCE_DP_D;
3804 WARN(1, "nonexisting DP port %c\n",
3805 port_name(dig_port->port));
3813 drm_modeset_unlock_all(dev);
3818 static int vlv_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,
3820 enum intel_pipe_crc_source *source,
3823 bool need_stable_symbols = false;
3825 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) {
3826 int ret = i9xx_pipe_crc_auto_source(dev_priv, pipe, source);
3832 case INTEL_PIPE_CRC_SOURCE_PIPE:
3833 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV;
3835 case INTEL_PIPE_CRC_SOURCE_DP_B:
3836 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV;
3837 need_stable_symbols = true;
3839 case INTEL_PIPE_CRC_SOURCE_DP_C:
3840 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV;
3841 need_stable_symbols = true;
3843 case INTEL_PIPE_CRC_SOURCE_DP_D:
3844 if (!IS_CHERRYVIEW(dev_priv))
3846 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_VLV;
3847 need_stable_symbols = true;
3849 case INTEL_PIPE_CRC_SOURCE_NONE:
3857 * When the pipe CRC tap point is after the transcoders we need
3858 * to tweak symbol-level features to produce a deterministic series of
3859 * symbols for a given frame. We need to reset those features only once
3860 * a frame (instead of every nth symbol):
3861 * - DC-balance: used to ensure a better clock recovery from the data
3863 * - DisplayPort scrambling: used for EMI reduction
3865 if (need_stable_symbols) {
3866 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
3868 tmp |= DC_BALANCE_RESET_VLV;
3871 tmp |= PIPE_A_SCRAMBLE_RESET;
3874 tmp |= PIPE_B_SCRAMBLE_RESET;
3877 tmp |= PIPE_C_SCRAMBLE_RESET;
3882 I915_WRITE(PORT_DFT2_G4X, tmp);
3888 static int i9xx_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,
3890 enum intel_pipe_crc_source *source,
3893 bool need_stable_symbols = false;
3895 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) {
3896 int ret = i9xx_pipe_crc_auto_source(dev_priv, pipe, source);
3902 case INTEL_PIPE_CRC_SOURCE_PIPE:
3903 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX;
3905 case INTEL_PIPE_CRC_SOURCE_TV:
3906 if (!SUPPORTS_TV(dev_priv))
3908 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE;
3910 case INTEL_PIPE_CRC_SOURCE_DP_B:
3911 if (!IS_G4X(dev_priv))
3913 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X;
3914 need_stable_symbols = true;
3916 case INTEL_PIPE_CRC_SOURCE_DP_C:
3917 if (!IS_G4X(dev_priv))
3919 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X;
3920 need_stable_symbols = true;
3922 case INTEL_PIPE_CRC_SOURCE_DP_D:
3923 if (!IS_G4X(dev_priv))
3925 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X;
3926 need_stable_symbols = true;
3928 case INTEL_PIPE_CRC_SOURCE_NONE:
3936 * When the pipe CRC tap point is after the transcoders we need
3937 * to tweak symbol-level features to produce a deterministic series of
3938 * symbols for a given frame. We need to reset those features only once
3939 * a frame (instead of every nth symbol):
3940 * - DC-balance: used to ensure a better clock recovery from the data
3942 * - DisplayPort scrambling: used for EMI reduction
3944 if (need_stable_symbols) {
3945 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
3947 WARN_ON(!IS_G4X(dev_priv));
3949 I915_WRITE(PORT_DFT_I9XX,
3950 I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET);
3953 tmp |= PIPE_A_SCRAMBLE_RESET;
3955 tmp |= PIPE_B_SCRAMBLE_RESET;
3957 I915_WRITE(PORT_DFT2_G4X, tmp);
3963 static void vlv_undo_pipe_scramble_reset(struct drm_i915_private *dev_priv,
3966 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
3970 tmp &= ~PIPE_A_SCRAMBLE_RESET;
3973 tmp &= ~PIPE_B_SCRAMBLE_RESET;
3976 tmp &= ~PIPE_C_SCRAMBLE_RESET;
3981 if (!(tmp & PIPE_SCRAMBLE_RESET_MASK))
3982 tmp &= ~DC_BALANCE_RESET_VLV;
3983 I915_WRITE(PORT_DFT2_G4X, tmp);
3987 static void g4x_undo_pipe_scramble_reset(struct drm_i915_private *dev_priv,
3990 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
3993 tmp &= ~PIPE_A_SCRAMBLE_RESET;
3995 tmp &= ~PIPE_B_SCRAMBLE_RESET;
3996 I915_WRITE(PORT_DFT2_G4X, tmp);
3998 if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) {
3999 I915_WRITE(PORT_DFT_I9XX,
4000 I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET);
4004 static int ilk_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
4007 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
4008 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
4011 case INTEL_PIPE_CRC_SOURCE_PLANE1:
4012 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK;
4014 case INTEL_PIPE_CRC_SOURCE_PLANE2:
4015 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK;
4017 case INTEL_PIPE_CRC_SOURCE_PIPE:
4018 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK;
4020 case INTEL_PIPE_CRC_SOURCE_NONE:
4030 static void hsw_trans_edp_pipe_A_crc_wa(struct drm_i915_private *dev_priv,
4033 struct drm_device *dev = &dev_priv->drm;
4034 struct intel_crtc *crtc =
4035 to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]);
4036 struct intel_crtc_state *pipe_config;
4037 struct drm_atomic_state *state;
4040 drm_modeset_lock_all(dev);
4041 state = drm_atomic_state_alloc(dev);
4047 state->acquire_ctx = drm_modeset_legacy_acquire_ctx(&crtc->base);
4048 pipe_config = intel_atomic_get_crtc_state(state, crtc);
4049 if (IS_ERR(pipe_config)) {
4050 ret = PTR_ERR(pipe_config);
4054 pipe_config->pch_pfit.force_thru = enable;
4055 if (pipe_config->cpu_transcoder == TRANSCODER_EDP &&
4056 pipe_config->pch_pfit.enabled != enable)
4057 pipe_config->base.connectors_changed = true;
4059 ret = drm_atomic_commit(state);
4061 drm_modeset_unlock_all(dev);
4062 WARN(ret, "Toggling workaround to %i returns %i\n", enable, ret);
4064 drm_atomic_state_free(state);
4067 static int ivb_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,
4069 enum intel_pipe_crc_source *source,
4072 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
4073 *source = INTEL_PIPE_CRC_SOURCE_PF;
4076 case INTEL_PIPE_CRC_SOURCE_PLANE1:
4077 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB;
4079 case INTEL_PIPE_CRC_SOURCE_PLANE2:
4080 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB;
4082 case INTEL_PIPE_CRC_SOURCE_PF:
4083 if (IS_HASWELL(dev_priv) && pipe == PIPE_A)
4084 hsw_trans_edp_pipe_A_crc_wa(dev_priv, true);
4086 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB;
4088 case INTEL_PIPE_CRC_SOURCE_NONE:
4098 static int pipe_crc_set_source(struct drm_i915_private *dev_priv,
4100 enum intel_pipe_crc_source source)
4102 struct drm_device *dev = &dev_priv->drm;
4103 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
4104 struct intel_crtc *crtc =
4105 to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
4106 enum intel_display_power_domain power_domain;
4107 u32 val = 0; /* shut up gcc */
4110 if (pipe_crc->source == source)
4113 /* forbid changing the source without going back to 'none' */
4114 if (pipe_crc->source && source)
4117 power_domain = POWER_DOMAIN_PIPE(pipe);
4118 if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) {
4119 DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n");
4123 if (IS_GEN2(dev_priv))
4124 ret = i8xx_pipe_crc_ctl_reg(&source, &val);
4125 else if (INTEL_GEN(dev_priv) < 5)
4126 ret = i9xx_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val);
4127 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
4128 ret = vlv_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val);
4129 else if (IS_GEN5(dev_priv) || IS_GEN6(dev_priv))
4130 ret = ilk_pipe_crc_ctl_reg(&source, &val);
4132 ret = ivb_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val);
4137 /* none -> real source transition */
4139 struct intel_pipe_crc_entry *entries;
4141 DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n",
4142 pipe_name(pipe), pipe_crc_source_name(source));
4144 entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR,
4145 sizeof(pipe_crc->entries[0]),
4153 * When IPS gets enabled, the pipe CRC changes. Since IPS gets
4154 * enabled and disabled dynamically based on package C states,
4155 * user space can't make reliable use of the CRCs, so let's just
4156 * completely disable it.
4158 hsw_disable_ips(crtc);
4160 spin_lock_irq(&pipe_crc->lock);
4161 kfree(pipe_crc->entries);
4162 pipe_crc->entries = entries;
4165 spin_unlock_irq(&pipe_crc->lock);
4168 pipe_crc->source = source;
4170 I915_WRITE(PIPE_CRC_CTL(pipe), val);
4171 POSTING_READ(PIPE_CRC_CTL(pipe));
4173 /* real source -> none transition */
4174 if (source == INTEL_PIPE_CRC_SOURCE_NONE) {
4175 struct intel_pipe_crc_entry *entries;
4176 struct intel_crtc *crtc =
4177 to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
4179 DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n",
4182 drm_modeset_lock(&crtc->base.mutex, NULL);
4183 if (crtc->base.state->active)
4184 intel_wait_for_vblank(dev, pipe);
4185 drm_modeset_unlock(&crtc->base.mutex);
4187 spin_lock_irq(&pipe_crc->lock);
4188 entries = pipe_crc->entries;
4189 pipe_crc->entries = NULL;
4192 spin_unlock_irq(&pipe_crc->lock);
4196 if (IS_G4X(dev_priv))
4197 g4x_undo_pipe_scramble_reset(dev_priv, pipe);
4198 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
4199 vlv_undo_pipe_scramble_reset(dev_priv, pipe);
4200 else if (IS_HASWELL(dev_priv) && pipe == PIPE_A)
4201 hsw_trans_edp_pipe_A_crc_wa(dev_priv, false);
4203 hsw_enable_ips(crtc);
4209 intel_display_power_put(dev_priv, power_domain);
4215 * Parse pipe CRC command strings:
4216 * command: wsp* object wsp+ name wsp+ source wsp*
4219 * source: (none | plane1 | plane2 | pf)
4220 * wsp: (#0x20 | #0x9 | #0xA)+
4223 * "pipe A plane1" -> Start CRC computations on plane1 of pipe A
4224 * "pipe A none" -> Stop CRC
4226 static int display_crc_ctl_tokenize(char *buf, char *words[], int max_words)
4233 /* skip leading white space */
4234 buf = skip_spaces(buf);
4236 break; /* end of buffer */
4238 /* find end of word */
4239 for (end = buf; *end && !isspace(*end); end++)
4242 if (n_words == max_words) {
4243 DRM_DEBUG_DRIVER("too many words, allowed <= %d\n",
4245 return -EINVAL; /* ran out of words[] before bytes */
4250 words[n_words++] = buf;
4257 enum intel_pipe_crc_object {
4258 PIPE_CRC_OBJECT_PIPE,
4261 static const char * const pipe_crc_objects[] = {
4266 display_crc_ctl_parse_object(const char *buf, enum intel_pipe_crc_object *o)
4270 for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++)
4271 if (!strcmp(buf, pipe_crc_objects[i])) {
4279 static int display_crc_ctl_parse_pipe(const char *buf, enum pipe *pipe)
4281 const char name = buf[0];
4283 if (name < 'A' || name >= pipe_name(I915_MAX_PIPES))
4292 display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s)
4296 for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++)
4297 if (!strcmp(buf, pipe_crc_sources[i])) {
4305 static int display_crc_ctl_parse(struct drm_i915_private *dev_priv,
4306 char *buf, size_t len)
4310 char *words[N_WORDS];
4312 enum intel_pipe_crc_object object;
4313 enum intel_pipe_crc_source source;
4315 n_words = display_crc_ctl_tokenize(buf, words, N_WORDS);
4316 if (n_words != N_WORDS) {
4317 DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n",
4322 if (display_crc_ctl_parse_object(words[0], &object) < 0) {
4323 DRM_DEBUG_DRIVER("unknown object %s\n", words[0]);
4327 if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) {
4328 DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]);
4332 if (display_crc_ctl_parse_source(words[2], &source) < 0) {
4333 DRM_DEBUG_DRIVER("unknown source %s\n", words[2]);
4337 return pipe_crc_set_source(dev_priv, pipe, source);
4340 static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf,
4341 size_t len, loff_t *offp)
4343 struct seq_file *m = file->private_data;
4344 struct drm_i915_private *dev_priv = m->private;
4351 if (len > PAGE_SIZE - 1) {
4352 DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n",
4357 tmpbuf = kmalloc(len + 1, GFP_KERNEL);
4361 if (copy_from_user(tmpbuf, ubuf, len)) {
4367 ret = display_crc_ctl_parse(dev_priv, tmpbuf, len);
4378 static const struct file_operations i915_display_crc_ctl_fops = {
4379 .owner = THIS_MODULE,
4380 .open = display_crc_ctl_open,
4382 .llseek = seq_lseek,
4383 .release = single_release,
4384 .write = display_crc_ctl_write
4387 static ssize_t i915_displayport_test_active_write(struct file *file,
4388 const char __user *ubuf,
4389 size_t len, loff_t *offp)
4393 struct drm_device *dev;
4394 struct drm_connector *connector;
4395 struct list_head *connector_list;
4396 struct intel_dp *intel_dp;
4399 dev = ((struct seq_file *)file->private_data)->private;
4401 connector_list = &dev->mode_config.connector_list;
4406 input_buffer = kmalloc(len + 1, GFP_KERNEL);
4410 if (copy_from_user(input_buffer, ubuf, len)) {
4415 input_buffer[len] = '\0';
4416 DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len);
4418 list_for_each_entry(connector, connector_list, head) {
4419 if (connector->connector_type !=
4420 DRM_MODE_CONNECTOR_DisplayPort)
4423 if (connector->status == connector_status_connected &&
4424 connector->encoder != NULL) {
4425 intel_dp = enc_to_intel_dp(connector->encoder);
4426 status = kstrtoint(input_buffer, 10, &val);
4429 DRM_DEBUG_DRIVER("Got %d for test active\n", val);
4430 /* To prevent erroneous activation of the compliance
4431 * testing code, only accept an actual value of 1 here
4434 intel_dp->compliance_test_active = 1;
4436 intel_dp->compliance_test_active = 0;
4440 kfree(input_buffer);
4448 static int i915_displayport_test_active_show(struct seq_file *m, void *data)
4450 struct drm_device *dev = m->private;
4451 struct drm_connector *connector;
4452 struct list_head *connector_list = &dev->mode_config.connector_list;
4453 struct intel_dp *intel_dp;
4455 list_for_each_entry(connector, connector_list, head) {
4456 if (connector->connector_type !=
4457 DRM_MODE_CONNECTOR_DisplayPort)
4460 if (connector->status == connector_status_connected &&
4461 connector->encoder != NULL) {
4462 intel_dp = enc_to_intel_dp(connector->encoder);
4463 if (intel_dp->compliance_test_active)
4474 static int i915_displayport_test_active_open(struct inode *inode,
4477 struct drm_i915_private *dev_priv = inode->i_private;
4479 return single_open(file, i915_displayport_test_active_show,
4483 static const struct file_operations i915_displayport_test_active_fops = {
4484 .owner = THIS_MODULE,
4485 .open = i915_displayport_test_active_open,
4487 .llseek = seq_lseek,
4488 .release = single_release,
4489 .write = i915_displayport_test_active_write
4492 static int i915_displayport_test_data_show(struct seq_file *m, void *data)
4494 struct drm_device *dev = m->private;
4495 struct drm_connector *connector;
4496 struct list_head *connector_list = &dev->mode_config.connector_list;
4497 struct intel_dp *intel_dp;
4499 list_for_each_entry(connector, connector_list, head) {
4500 if (connector->connector_type !=
4501 DRM_MODE_CONNECTOR_DisplayPort)
4504 if (connector->status == connector_status_connected &&
4505 connector->encoder != NULL) {
4506 intel_dp = enc_to_intel_dp(connector->encoder);
4507 seq_printf(m, "%lx", intel_dp->compliance_test_data);
4514 static int i915_displayport_test_data_open(struct inode *inode,
4517 struct drm_i915_private *dev_priv = inode->i_private;
4519 return single_open(file, i915_displayport_test_data_show,
4523 static const struct file_operations i915_displayport_test_data_fops = {
4524 .owner = THIS_MODULE,
4525 .open = i915_displayport_test_data_open,
4527 .llseek = seq_lseek,
4528 .release = single_release
4531 static int i915_displayport_test_type_show(struct seq_file *m, void *data)
4533 struct drm_device *dev = m->private;
4534 struct drm_connector *connector;
4535 struct list_head *connector_list = &dev->mode_config.connector_list;
4536 struct intel_dp *intel_dp;
4538 list_for_each_entry(connector, connector_list, head) {
4539 if (connector->connector_type !=
4540 DRM_MODE_CONNECTOR_DisplayPort)
4543 if (connector->status == connector_status_connected &&
4544 connector->encoder != NULL) {
4545 intel_dp = enc_to_intel_dp(connector->encoder);
4546 seq_printf(m, "%02lx", intel_dp->compliance_test_type);
4554 static int i915_displayport_test_type_open(struct inode *inode,
4557 struct drm_i915_private *dev_priv = inode->i_private;
4559 return single_open(file, i915_displayport_test_type_show,
4563 static const struct file_operations i915_displayport_test_type_fops = {
4564 .owner = THIS_MODULE,
4565 .open = i915_displayport_test_type_open,
4567 .llseek = seq_lseek,
4568 .release = single_release
4571 static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
4573 struct drm_i915_private *dev_priv = m->private;
4574 struct drm_device *dev = &dev_priv->drm;
4578 if (IS_CHERRYVIEW(dev_priv))
4580 else if (IS_VALLEYVIEW(dev_priv))
4583 num_levels = ilk_wm_max_level(dev_priv) + 1;
4585 drm_modeset_lock_all(dev);
4587 for (level = 0; level < num_levels; level++) {
4588 unsigned int latency = wm[level];
4591 * - WM1+ latency values in 0.5us units
4592 * - latencies are in us on gen9/vlv/chv
4594 if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) ||
4595 IS_CHERRYVIEW(dev_priv))
4600 seq_printf(m, "WM%d %u (%u.%u usec)\n",
4601 level, wm[level], latency / 10, latency % 10);
4604 drm_modeset_unlock_all(dev);
4607 static int pri_wm_latency_show(struct seq_file *m, void *data)
4609 struct drm_i915_private *dev_priv = m->private;
4610 const uint16_t *latencies;
4612 if (INTEL_GEN(dev_priv) >= 9)
4613 latencies = dev_priv->wm.skl_latency;
4615 latencies = dev_priv->wm.pri_latency;
4617 wm_latency_show(m, latencies);
4622 static int spr_wm_latency_show(struct seq_file *m, void *data)
4624 struct drm_i915_private *dev_priv = m->private;
4625 const uint16_t *latencies;
4627 if (INTEL_GEN(dev_priv) >= 9)
4628 latencies = dev_priv->wm.skl_latency;
4630 latencies = dev_priv->wm.spr_latency;
4632 wm_latency_show(m, latencies);
4637 static int cur_wm_latency_show(struct seq_file *m, void *data)
4639 struct drm_i915_private *dev_priv = m->private;
4640 const uint16_t *latencies;
4642 if (INTEL_GEN(dev_priv) >= 9)
4643 latencies = dev_priv->wm.skl_latency;
4645 latencies = dev_priv->wm.cur_latency;
4647 wm_latency_show(m, latencies);
4652 static int pri_wm_latency_open(struct inode *inode, struct file *file)
4654 struct drm_i915_private *dev_priv = inode->i_private;
4656 if (INTEL_GEN(dev_priv) < 5)
4659 return single_open(file, pri_wm_latency_show, dev_priv);
4662 static int spr_wm_latency_open(struct inode *inode, struct file *file)
4664 struct drm_i915_private *dev_priv = inode->i_private;
4666 if (HAS_GMCH_DISPLAY(dev_priv))
4669 return single_open(file, spr_wm_latency_show, dev_priv);
4672 static int cur_wm_latency_open(struct inode *inode, struct file *file)
4674 struct drm_i915_private *dev_priv = inode->i_private;
4676 if (HAS_GMCH_DISPLAY(dev_priv))
4679 return single_open(file, cur_wm_latency_show, dev_priv);
4682 static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
4683 size_t len, loff_t *offp, uint16_t wm[8])
4685 struct seq_file *m = file->private_data;
4686 struct drm_i915_private *dev_priv = m->private;
4687 struct drm_device *dev = &dev_priv->drm;
4688 uint16_t new[8] = { 0 };
4694 if (IS_CHERRYVIEW(dev_priv))
4696 else if (IS_VALLEYVIEW(dev_priv))
4699 num_levels = ilk_wm_max_level(dev_priv) + 1;
4701 if (len >= sizeof(tmp))
4704 if (copy_from_user(tmp, ubuf, len))
4709 ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
4710 &new[0], &new[1], &new[2], &new[3],
4711 &new[4], &new[5], &new[6], &new[7]);
4712 if (ret != num_levels)
4715 drm_modeset_lock_all(dev);
4717 for (level = 0; level < num_levels; level++)
4718 wm[level] = new[level];
4720 drm_modeset_unlock_all(dev);
4726 static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
4727 size_t len, loff_t *offp)
4729 struct seq_file *m = file->private_data;
4730 struct drm_i915_private *dev_priv = m->private;
4731 uint16_t *latencies;
4733 if (INTEL_GEN(dev_priv) >= 9)
4734 latencies = dev_priv->wm.skl_latency;
4736 latencies = dev_priv->wm.pri_latency;
4738 return wm_latency_write(file, ubuf, len, offp, latencies);
4741 static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
4742 size_t len, loff_t *offp)
4744 struct seq_file *m = file->private_data;
4745 struct drm_i915_private *dev_priv = m->private;
4746 uint16_t *latencies;
4748 if (INTEL_GEN(dev_priv) >= 9)
4749 latencies = dev_priv->wm.skl_latency;
4751 latencies = dev_priv->wm.spr_latency;
4753 return wm_latency_write(file, ubuf, len, offp, latencies);
4756 static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
4757 size_t len, loff_t *offp)
4759 struct seq_file *m = file->private_data;
4760 struct drm_i915_private *dev_priv = m->private;
4761 uint16_t *latencies;
4763 if (INTEL_GEN(dev_priv) >= 9)
4764 latencies = dev_priv->wm.skl_latency;
4766 latencies = dev_priv->wm.cur_latency;
4768 return wm_latency_write(file, ubuf, len, offp, latencies);
4771 static const struct file_operations i915_pri_wm_latency_fops = {
4772 .owner = THIS_MODULE,
4773 .open = pri_wm_latency_open,
4775 .llseek = seq_lseek,
4776 .release = single_release,
4777 .write = pri_wm_latency_write
4780 static const struct file_operations i915_spr_wm_latency_fops = {
4781 .owner = THIS_MODULE,
4782 .open = spr_wm_latency_open,
4784 .llseek = seq_lseek,
4785 .release = single_release,
4786 .write = spr_wm_latency_write
4789 static const struct file_operations i915_cur_wm_latency_fops = {
4790 .owner = THIS_MODULE,
4791 .open = cur_wm_latency_open,
4793 .llseek = seq_lseek,
4794 .release = single_release,
4795 .write = cur_wm_latency_write
4799 i915_wedged_get(void *data, u64 *val)
4801 struct drm_i915_private *dev_priv = data;
4803 *val = i915_terminally_wedged(&dev_priv->gpu_error);
4809 i915_wedged_set(void *data, u64 val)
4811 struct drm_i915_private *dev_priv = data;
4814 * There is no safeguard against this debugfs entry colliding
4815 * with the hangcheck calling same i915_handle_error() in
4816 * parallel, causing an explosion. For now we assume that the
4817 * test harness is responsible enough not to inject gpu hangs
4818 * while it is writing to 'i915_wedged'
4821 if (i915_reset_in_progress(&dev_priv->gpu_error))
4824 i915_handle_error(dev_priv, val,
4825 "Manually setting wedged to %llu", val);
4830 DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
4831 i915_wedged_get, i915_wedged_set,
4835 i915_ring_missed_irq_get(void *data, u64 *val)
4837 struct drm_i915_private *dev_priv = data;
4839 *val = dev_priv->gpu_error.missed_irq_rings;
4844 i915_ring_missed_irq_set(void *data, u64 val)
4846 struct drm_i915_private *dev_priv = data;
4847 struct drm_device *dev = &dev_priv->drm;
4850 /* Lock against concurrent debugfs callers */
4851 ret = mutex_lock_interruptible(&dev->struct_mutex);
4854 dev_priv->gpu_error.missed_irq_rings = val;
4855 mutex_unlock(&dev->struct_mutex);
4860 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops,
4861 i915_ring_missed_irq_get, i915_ring_missed_irq_set,
4865 i915_ring_test_irq_get(void *data, u64 *val)
4867 struct drm_i915_private *dev_priv = data;
4869 *val = dev_priv->gpu_error.test_irq_rings;
4875 i915_ring_test_irq_set(void *data, u64 val)
4877 struct drm_i915_private *dev_priv = data;
4879 val &= INTEL_INFO(dev_priv)->ring_mask;
4880 DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val);
4881 dev_priv->gpu_error.test_irq_rings = val;
4886 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops,
4887 i915_ring_test_irq_get, i915_ring_test_irq_set,
4890 #define DROP_UNBOUND 0x1
4891 #define DROP_BOUND 0x2
4892 #define DROP_RETIRE 0x4
4893 #define DROP_ACTIVE 0x8
4894 #define DROP_ALL (DROP_UNBOUND | \
4899 i915_drop_caches_get(void *data, u64 *val)
4907 i915_drop_caches_set(void *data, u64 val)
4909 struct drm_i915_private *dev_priv = data;
4910 struct drm_device *dev = &dev_priv->drm;
4913 DRM_DEBUG("Dropping caches: 0x%08llx\n", val);
4915 /* No need to check and wait for gpu resets, only libdrm auto-restarts
4916 * on ioctls on -EAGAIN. */
4917 ret = mutex_lock_interruptible(&dev->struct_mutex);
4921 if (val & DROP_ACTIVE) {
4922 ret = i915_gem_wait_for_idle(dev_priv,
4923 I915_WAIT_INTERRUPTIBLE |
4929 if (val & (DROP_RETIRE | DROP_ACTIVE))
4930 i915_gem_retire_requests(dev_priv);
4932 if (val & DROP_BOUND)
4933 i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND);
4935 if (val & DROP_UNBOUND)
4936 i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND);
4939 mutex_unlock(&dev->struct_mutex);
4944 DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
4945 i915_drop_caches_get, i915_drop_caches_set,
4949 i915_max_freq_get(void *data, u64 *val)
4951 struct drm_i915_private *dev_priv = data;
4953 if (INTEL_GEN(dev_priv) < 6)
4956 *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit);
4961 i915_max_freq_set(void *data, u64 val)
4963 struct drm_i915_private *dev_priv = data;
4967 if (INTEL_GEN(dev_priv) < 6)
4970 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val);
4972 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
4977 * Turbo will still be enabled, but won't go above the set value.
4979 val = intel_freq_opcode(dev_priv, val);
4981 hw_max = dev_priv->rps.max_freq;
4982 hw_min = dev_priv->rps.min_freq;
4984 if (val < hw_min || val > hw_max || val < dev_priv->rps.min_freq_softlimit) {
4985 mutex_unlock(&dev_priv->rps.hw_lock);
4989 dev_priv->rps.max_freq_softlimit = val;
4991 intel_set_rps(dev_priv, val);
4993 mutex_unlock(&dev_priv->rps.hw_lock);
4998 DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
4999 i915_max_freq_get, i915_max_freq_set,
5003 i915_min_freq_get(void *data, u64 *val)
5005 struct drm_i915_private *dev_priv = data;
5007 if (INTEL_GEN(dev_priv) < 6)
5010 *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit);
5015 i915_min_freq_set(void *data, u64 val)
5017 struct drm_i915_private *dev_priv = data;
5021 if (INTEL_GEN(dev_priv) < 6)
5024 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val);
5026 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
5031 * Turbo will still be enabled, but won't go below the set value.
5033 val = intel_freq_opcode(dev_priv, val);
5035 hw_max = dev_priv->rps.max_freq;
5036 hw_min = dev_priv->rps.min_freq;
5039 val > hw_max || val > dev_priv->rps.max_freq_softlimit) {
5040 mutex_unlock(&dev_priv->rps.hw_lock);
5044 dev_priv->rps.min_freq_softlimit = val;
5046 intel_set_rps(dev_priv, val);
5048 mutex_unlock(&dev_priv->rps.hw_lock);
5053 DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
5054 i915_min_freq_get, i915_min_freq_set,
5058 i915_cache_sharing_get(void *data, u64 *val)
5060 struct drm_i915_private *dev_priv = data;
5063 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
5066 intel_runtime_pm_get(dev_priv);
5068 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
5070 intel_runtime_pm_put(dev_priv);
5072 *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
5078 i915_cache_sharing_set(void *data, u64 val)
5080 struct drm_i915_private *dev_priv = data;
5083 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
5089 intel_runtime_pm_get(dev_priv);
5090 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
5092 /* Update the cache sharing policy here as well */
5093 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
5094 snpcr &= ~GEN6_MBC_SNPCR_MASK;
5095 snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
5096 I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
5098 intel_runtime_pm_put(dev_priv);
5102 DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops,
5103 i915_cache_sharing_get, i915_cache_sharing_set,
5106 static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv,
5107 struct sseu_dev_info *sseu)
5111 u32 sig1[ss_max], sig2[ss_max];
5113 sig1[0] = I915_READ(CHV_POWER_SS0_SIG1);
5114 sig1[1] = I915_READ(CHV_POWER_SS1_SIG1);
5115 sig2[0] = I915_READ(CHV_POWER_SS0_SIG2);
5116 sig2[1] = I915_READ(CHV_POWER_SS1_SIG2);
5118 for (ss = 0; ss < ss_max; ss++) {
5119 unsigned int eu_cnt;
5121 if (sig1[ss] & CHV_SS_PG_ENABLE)
5122 /* skip disabled subslice */
5125 sseu->slice_mask = BIT(0);
5126 sseu->subslice_mask |= BIT(ss);
5127 eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) +
5128 ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) +
5129 ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) +
5130 ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2);
5131 sseu->eu_total += eu_cnt;
5132 sseu->eu_per_subslice = max_t(unsigned int,
5133 sseu->eu_per_subslice, eu_cnt);
5137 static void gen9_sseu_device_status(struct drm_i915_private *dev_priv,
5138 struct sseu_dev_info *sseu)
5140 int s_max = 3, ss_max = 4;
5142 u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2];
5144 /* BXT has a single slice and at most 3 subslices. */
5145 if (IS_BROXTON(dev_priv)) {
5150 for (s = 0; s < s_max; s++) {
5151 s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s));
5152 eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s));
5153 eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s));
5156 eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK |
5157 GEN9_PGCTL_SSA_EU19_ACK |
5158 GEN9_PGCTL_SSA_EU210_ACK |
5159 GEN9_PGCTL_SSA_EU311_ACK;
5160 eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK |
5161 GEN9_PGCTL_SSB_EU19_ACK |
5162 GEN9_PGCTL_SSB_EU210_ACK |
5163 GEN9_PGCTL_SSB_EU311_ACK;
5165 for (s = 0; s < s_max; s++) {
5166 if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0)
5167 /* skip disabled slice */
5170 sseu->slice_mask |= BIT(s);
5172 if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
5173 sseu->subslice_mask =
5174 INTEL_INFO(dev_priv)->sseu.subslice_mask;
5176 for (ss = 0; ss < ss_max; ss++) {
5177 unsigned int eu_cnt;
5179 if (IS_BROXTON(dev_priv)) {
5180 if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss))))
5181 /* skip disabled subslice */
5184 sseu->subslice_mask |= BIT(ss);
5187 eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] &
5189 sseu->eu_total += eu_cnt;
5190 sseu->eu_per_subslice = max_t(unsigned int,
5191 sseu->eu_per_subslice,
5197 static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv,
5198 struct sseu_dev_info *sseu)
5200 u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
5203 sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK;
5205 if (sseu->slice_mask) {
5206 sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask;
5207 sseu->eu_per_subslice =
5208 INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
5209 sseu->eu_total = sseu->eu_per_subslice *
5210 sseu_subslice_total(sseu);
5212 /* subtract fused off EU(s) from enabled slice(s) */
5213 for (s = 0; s < fls(sseu->slice_mask); s++) {
5215 INTEL_INFO(dev_priv)->sseu.subslice_7eu[s];
5217 sseu->eu_total -= hweight8(subslice_7eu);
5222 static void i915_print_sseu_info(struct seq_file *m, bool is_available_info,
5223 const struct sseu_dev_info *sseu)
5225 struct drm_i915_private *dev_priv = node_to_i915(m->private);
5226 const char *type = is_available_info ? "Available" : "Enabled";
5228 seq_printf(m, " %s Slice Mask: %04x\n", type,
5230 seq_printf(m, " %s Slice Total: %u\n", type,
5231 hweight8(sseu->slice_mask));
5232 seq_printf(m, " %s Subslice Total: %u\n", type,
5233 sseu_subslice_total(sseu));
5234 seq_printf(m, " %s Subslice Mask: %04x\n", type,
5235 sseu->subslice_mask);
5236 seq_printf(m, " %s Subslice Per Slice: %u\n", type,
5237 hweight8(sseu->subslice_mask));
5238 seq_printf(m, " %s EU Total: %u\n", type,
5240 seq_printf(m, " %s EU Per Subslice: %u\n", type,
5241 sseu->eu_per_subslice);
5243 if (!is_available_info)
5246 seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv)));
5247 if (HAS_POOLED_EU(dev_priv))
5248 seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool);
5250 seq_printf(m, " Has Slice Power Gating: %s\n",
5251 yesno(sseu->has_slice_pg));
5252 seq_printf(m, " Has Subslice Power Gating: %s\n",
5253 yesno(sseu->has_subslice_pg));
5254 seq_printf(m, " Has EU Power Gating: %s\n",
5255 yesno(sseu->has_eu_pg));
5258 static int i915_sseu_status(struct seq_file *m, void *unused)
5260 struct drm_i915_private *dev_priv = node_to_i915(m->private);
5261 struct sseu_dev_info sseu;
5263 if (INTEL_GEN(dev_priv) < 8)
5266 seq_puts(m, "SSEU Device Info\n");
5267 i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu);
5269 seq_puts(m, "SSEU Device Status\n");
5270 memset(&sseu, 0, sizeof(sseu));
5272 intel_runtime_pm_get(dev_priv);
5274 if (IS_CHERRYVIEW(dev_priv)) {
5275 cherryview_sseu_device_status(dev_priv, &sseu);
5276 } else if (IS_BROADWELL(dev_priv)) {
5277 broadwell_sseu_device_status(dev_priv, &sseu);
5278 } else if (INTEL_GEN(dev_priv) >= 9) {
5279 gen9_sseu_device_status(dev_priv, &sseu);
5282 intel_runtime_pm_put(dev_priv);
5284 i915_print_sseu_info(m, false, &sseu);
5289 static int i915_forcewake_open(struct inode *inode, struct file *file)
5291 struct drm_i915_private *dev_priv = inode->i_private;
5293 if (INTEL_GEN(dev_priv) < 6)
5296 intel_runtime_pm_get(dev_priv);
5297 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
5302 static int i915_forcewake_release(struct inode *inode, struct file *file)
5304 struct drm_i915_private *dev_priv = inode->i_private;
5306 if (INTEL_GEN(dev_priv) < 6)
5309 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
5310 intel_runtime_pm_put(dev_priv);
5315 static const struct file_operations i915_forcewake_fops = {
5316 .owner = THIS_MODULE,
5317 .open = i915_forcewake_open,
5318 .release = i915_forcewake_release,
5321 static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
5325 ent = debugfs_create_file("i915_forcewake_user",
5327 root, to_i915(minor->dev),
5328 &i915_forcewake_fops);
5332 return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
5335 static int i915_debugfs_create(struct dentry *root,
5336 struct drm_minor *minor,
5338 const struct file_operations *fops)
5342 ent = debugfs_create_file(name,
5344 root, to_i915(minor->dev),
5349 return drm_add_fake_info_node(minor, ent, fops);
5352 static const struct drm_info_list i915_debugfs_list[] = {
5353 {"i915_capabilities", i915_capabilities, 0},
5354 {"i915_gem_objects", i915_gem_object_info, 0},
5355 {"i915_gem_gtt", i915_gem_gtt_info, 0},
5356 {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1},
5357 {"i915_gem_stolen", i915_gem_stolen_list_info },
5358 {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
5359 {"i915_gem_request", i915_gem_request_info, 0},
5360 {"i915_gem_seqno", i915_gem_seqno_info, 0},
5361 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
5362 {"i915_gem_interrupt", i915_interrupt_info, 0},
5363 {"i915_gem_hws", i915_hws_info, 0, (void *)RCS},
5364 {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS},
5365 {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS},
5366 {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS},
5367 {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0},
5368 {"i915_guc_info", i915_guc_info, 0},
5369 {"i915_guc_load_status", i915_guc_load_status_info, 0},
5370 {"i915_guc_log_dump", i915_guc_log_dump, 0},
5371 {"i915_frequency_info", i915_frequency_info, 0},
5372 {"i915_hangcheck_info", i915_hangcheck_info, 0},
5373 {"i915_drpc_info", i915_drpc_info, 0},
5374 {"i915_emon_status", i915_emon_status, 0},
5375 {"i915_ring_freq_table", i915_ring_freq_table, 0},
5376 {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0},
5377 {"i915_fbc_status", i915_fbc_status, 0},
5378 {"i915_ips_status", i915_ips_status, 0},
5379 {"i915_sr_status", i915_sr_status, 0},
5380 {"i915_opregion", i915_opregion, 0},
5381 {"i915_vbt", i915_vbt, 0},
5382 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
5383 {"i915_context_status", i915_context_status, 0},
5384 {"i915_dump_lrc", i915_dump_lrc, 0},
5385 {"i915_forcewake_domains", i915_forcewake_domains, 0},
5386 {"i915_swizzle_info", i915_swizzle_info, 0},
5387 {"i915_ppgtt_info", i915_ppgtt_info, 0},
5388 {"i915_llc", i915_llc, 0},
5389 {"i915_edp_psr_status", i915_edp_psr_status, 0},
5390 {"i915_sink_crc_eDP1", i915_sink_crc, 0},
5391 {"i915_energy_uJ", i915_energy_uJ, 0},
5392 {"i915_runtime_pm_status", i915_runtime_pm_status, 0},
5393 {"i915_power_domain_info", i915_power_domain_info, 0},
5394 {"i915_dmc_info", i915_dmc_info, 0},
5395 {"i915_display_info", i915_display_info, 0},
5396 {"i915_engine_info", i915_engine_info, 0},
5397 {"i915_semaphore_status", i915_semaphore_status, 0},
5398 {"i915_shared_dplls_info", i915_shared_dplls_info, 0},
5399 {"i915_dp_mst_info", i915_dp_mst_info, 0},
5400 {"i915_wa_registers", i915_wa_registers, 0},
5401 {"i915_ddb_info", i915_ddb_info, 0},
5402 {"i915_sseu_status", i915_sseu_status, 0},
5403 {"i915_drrs_status", i915_drrs_status, 0},
5404 {"i915_rps_boost_info", i915_rps_boost_info, 0},
5406 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
5408 static const struct i915_debugfs_files {
5410 const struct file_operations *fops;
5411 } i915_debugfs_files[] = {
5412 {"i915_wedged", &i915_wedged_fops},
5413 {"i915_max_freq", &i915_max_freq_fops},
5414 {"i915_min_freq", &i915_min_freq_fops},
5415 {"i915_cache_sharing", &i915_cache_sharing_fops},
5416 {"i915_ring_missed_irq", &i915_ring_missed_irq_fops},
5417 {"i915_ring_test_irq", &i915_ring_test_irq_fops},
5418 {"i915_gem_drop_caches", &i915_drop_caches_fops},
5419 #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
5420 {"i915_error_state", &i915_error_state_fops},
5422 {"i915_next_seqno", &i915_next_seqno_fops},
5423 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
5424 {"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
5425 {"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
5426 {"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
5427 {"i915_fbc_false_color", &i915_fbc_fc_fops},
5428 {"i915_dp_test_data", &i915_displayport_test_data_fops},
5429 {"i915_dp_test_type", &i915_displayport_test_type_fops},
5430 {"i915_dp_test_active", &i915_displayport_test_active_fops}
5433 void intel_display_crc_init(struct drm_i915_private *dev_priv)
5437 for_each_pipe(dev_priv, pipe) {
5438 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
5440 pipe_crc->opened = false;
5441 spin_lock_init(&pipe_crc->lock);
5442 init_waitqueue_head(&pipe_crc->wq);
5446 int i915_debugfs_register(struct drm_i915_private *dev_priv)
5448 struct drm_minor *minor = dev_priv->drm.primary;
5451 ret = i915_forcewake_create(minor->debugfs_root, minor);
5455 for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) {
5456 ret = i915_pipe_crc_create(minor->debugfs_root, minor, i);
5461 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
5462 ret = i915_debugfs_create(minor->debugfs_root, minor,
5463 i915_debugfs_files[i].name,
5464 i915_debugfs_files[i].fops);
5469 return drm_debugfs_create_files(i915_debugfs_list,
5470 I915_DEBUGFS_ENTRIES,
5471 minor->debugfs_root, minor);
5474 void i915_debugfs_unregister(struct drm_i915_private *dev_priv)
5476 struct drm_minor *minor = dev_priv->drm.primary;
5479 drm_debugfs_remove_files(i915_debugfs_list,
5480 I915_DEBUGFS_ENTRIES, minor);
5482 drm_debugfs_remove_files((struct drm_info_list *)&i915_forcewake_fops,
5485 for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) {
5486 struct drm_info_list *info_list =
5487 (struct drm_info_list *)&i915_pipe_crc_data[i];
5489 drm_debugfs_remove_files(info_list, 1, minor);
5492 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
5493 struct drm_info_list *info_list =
5494 (struct drm_info_list *)i915_debugfs_files[i].fops;
5496 drm_debugfs_remove_files(info_list, 1, minor);
5501 /* DPCD dump start address. */
5502 unsigned int offset;
5503 /* DPCD dump end address, inclusive. If unset, .size will be used. */
5505 /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */
5507 /* Only valid for eDP. */
5511 static const struct dpcd_block i915_dpcd_debug[] = {
5512 { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE },
5513 { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS },
5514 { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 },
5515 { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET },
5516 { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 },
5517 { .offset = DP_SET_POWER },
5518 { .offset = DP_EDP_DPCD_REV },
5519 { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 },
5520 { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB },
5521 { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET },
5524 static int i915_dpcd_show(struct seq_file *m, void *data)
5526 struct drm_connector *connector = m->private;
5527 struct intel_dp *intel_dp =
5528 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
5533 if (connector->status != connector_status_connected)
5536 for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) {
5537 const struct dpcd_block *b = &i915_dpcd_debug[i];
5538 size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1);
5541 connector->connector_type != DRM_MODE_CONNECTOR_eDP)
5544 /* low tech for now */
5545 if (WARN_ON(size > sizeof(buf)))
5548 err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size);
5550 DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n",
5551 size, b->offset, err);
5555 seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf);
5561 static int i915_dpcd_open(struct inode *inode, struct file *file)
5563 return single_open(file, i915_dpcd_show, inode->i_private);
5566 static const struct file_operations i915_dpcd_fops = {
5567 .owner = THIS_MODULE,
5568 .open = i915_dpcd_open,
5570 .llseek = seq_lseek,
5571 .release = single_release,
5574 static int i915_panel_show(struct seq_file *m, void *data)
5576 struct drm_connector *connector = m->private;
5577 struct intel_dp *intel_dp =
5578 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
5580 if (connector->status != connector_status_connected)
5583 seq_printf(m, "Panel power up delay: %d\n",
5584 intel_dp->panel_power_up_delay);
5585 seq_printf(m, "Panel power down delay: %d\n",
5586 intel_dp->panel_power_down_delay);
5587 seq_printf(m, "Backlight on delay: %d\n",
5588 intel_dp->backlight_on_delay);
5589 seq_printf(m, "Backlight off delay: %d\n",
5590 intel_dp->backlight_off_delay);
5595 static int i915_panel_open(struct inode *inode, struct file *file)
5597 return single_open(file, i915_panel_show, inode->i_private);
5600 static const struct file_operations i915_panel_fops = {
5601 .owner = THIS_MODULE,
5602 .open = i915_panel_open,
5604 .llseek = seq_lseek,
5605 .release = single_release,
5609 * i915_debugfs_connector_add - add i915 specific connector debugfs files
5610 * @connector: pointer to a registered drm_connector
5612 * Cleanup will be done by drm_connector_unregister() through a call to
5613 * drm_debugfs_connector_remove().
5615 * Returns 0 on success, negative error codes on error.
5617 int i915_debugfs_connector_add(struct drm_connector *connector)
5619 struct dentry *root = connector->debugfs_entry;
5621 /* The connector must have been registered beforehands. */
5625 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
5626 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
5627 debugfs_create_file("i915_dpcd", S_IRUGO, root,
5628 connector, &i915_dpcd_fops);
5630 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP)
5631 debugfs_create_file("i915_panel_timings", S_IRUGO, root,
5632 connector, &i915_panel_fops);