2 * Copyright © 2008 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eric Anholt <eric@anholt.net>
25 * Keith Packard <keithp@keithp.com>
29 #include <linux/seq_file.h>
30 #include <linux/circ_buf.h>
31 #include <linux/ctype.h>
32 #include <linux/debugfs.h>
33 #include <linux/slab.h>
34 #include <linux/export.h>
35 #include <linux/list_sort.h>
36 #include <asm/msr-index.h>
38 #include "intel_drv.h"
39 #include "intel_ringbuffer.h"
40 #include <drm/i915_drm.h>
49 /* As the drm_debugfs_init() routines are called before dev->dev_private is
50 * allocated we need to hook into the minor for release. */
52 drm_add_fake_info_node(struct drm_minor
*minor
,
56 struct drm_info_node
*node
;
58 node
= kmalloc(sizeof(*node
), GFP_KERNEL
);
66 node
->info_ent
= (void *) key
;
68 mutex_lock(&minor
->debugfs_lock
);
69 list_add(&node
->list
, &minor
->debugfs_list
);
70 mutex_unlock(&minor
->debugfs_lock
);
75 static int i915_capabilities(struct seq_file
*m
, void *data
)
77 struct drm_info_node
*node
= m
->private;
78 struct drm_device
*dev
= node
->minor
->dev
;
79 const struct intel_device_info
*info
= INTEL_INFO(dev
);
81 seq_printf(m
, "gen: %d\n", info
->gen
);
82 seq_printf(m
, "pch: %d\n", INTEL_PCH_TYPE(dev
));
83 #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
84 #define SEP_SEMICOLON ;
85 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG
, SEP_SEMICOLON
);
92 static const char *get_pin_flag(struct drm_i915_gem_object
*obj
)
100 static const char *get_tiling_flag(struct drm_i915_gem_object
*obj
)
102 switch (obj
->tiling_mode
) {
104 case I915_TILING_NONE
: return " ";
105 case I915_TILING_X
: return "X";
106 case I915_TILING_Y
: return "Y";
110 static inline const char *get_global_flag(struct drm_i915_gem_object
*obj
)
112 return i915_gem_obj_to_ggtt(obj
) ? "g" : " ";
115 static u64
i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object
*obj
)
118 struct i915_vma
*vma
;
120 list_for_each_entry(vma
, &obj
->vma_list
, vma_link
) {
121 if (i915_is_ggtt(vma
->vm
) &&
122 drm_mm_node_allocated(&vma
->node
))
123 size
+= vma
->node
.size
;
130 describe_obj(struct seq_file
*m
, struct drm_i915_gem_object
*obj
)
132 struct drm_i915_private
*dev_priv
= to_i915(obj
->base
.dev
);
133 struct intel_engine_cs
*ring
;
134 struct i915_vma
*vma
;
138 seq_printf(m
, "%pK: %s%s%s%s %8zdKiB %02x %02x [ ",
140 obj
->active
? "*" : " ",
142 get_tiling_flag(obj
),
143 get_global_flag(obj
),
144 obj
->base
.size
/ 1024,
145 obj
->base
.read_domains
,
146 obj
->base
.write_domain
);
147 for_each_ring(ring
, dev_priv
, i
)
149 i915_gem_request_get_seqno(obj
->last_read_req
[i
]));
150 seq_printf(m
, "] %x %x%s%s%s",
151 i915_gem_request_get_seqno(obj
->last_write_req
),
152 i915_gem_request_get_seqno(obj
->last_fenced_req
),
153 i915_cache_level_str(to_i915(obj
->base
.dev
), obj
->cache_level
),
154 obj
->dirty
? " dirty" : "",
155 obj
->madv
== I915_MADV_DONTNEED
? " purgeable" : "");
157 seq_printf(m
, " (name: %d)", obj
->base
.name
);
158 list_for_each_entry(vma
, &obj
->vma_list
, vma_link
) {
159 if (vma
->pin_count
> 0)
162 seq_printf(m
, " (pinned x %d)", pin_count
);
163 if (obj
->pin_display
)
164 seq_printf(m
, " (display)");
165 if (obj
->fence_reg
!= I915_FENCE_REG_NONE
)
166 seq_printf(m
, " (fence: %d)", obj
->fence_reg
);
167 list_for_each_entry(vma
, &obj
->vma_list
, vma_link
) {
168 seq_printf(m
, " (%sgtt offset: %08llx, size: %08llx",
169 i915_is_ggtt(vma
->vm
) ? "g" : "pp",
170 vma
->node
.start
, vma
->node
.size
);
171 if (i915_is_ggtt(vma
->vm
))
172 seq_printf(m
, ", type: %u)", vma
->ggtt_view
.type
);
177 seq_printf(m
, " (stolen: %08llx)", obj
->stolen
->start
);
178 if (obj
->pin_display
|| obj
->fault_mappable
) {
180 if (obj
->pin_display
)
182 if (obj
->fault_mappable
)
185 seq_printf(m
, " (%s mappable)", s
);
187 if (obj
->last_write_req
!= NULL
)
188 seq_printf(m
, " (%s)",
189 i915_gem_request_get_ring(obj
->last_write_req
)->name
);
190 if (obj
->frontbuffer_bits
)
191 seq_printf(m
, " (frontbuffer: 0x%03x)", obj
->frontbuffer_bits
);
194 static void describe_ctx(struct seq_file
*m
, struct intel_context
*ctx
)
196 seq_putc(m
, ctx
->legacy_hw_ctx
.initialized
? 'I' : 'i');
197 seq_putc(m
, ctx
->remap_slice
? 'R' : 'r');
201 static int i915_gem_object_list_info(struct seq_file
*m
, void *data
)
203 struct drm_info_node
*node
= m
->private;
204 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
205 struct list_head
*head
;
206 struct drm_device
*dev
= node
->minor
->dev
;
207 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
208 struct i915_address_space
*vm
= &dev_priv
->gtt
.base
;
209 struct i915_vma
*vma
;
210 u64 total_obj_size
, total_gtt_size
;
213 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
217 /* FIXME: the user of this interface might want more than just GGTT */
220 seq_puts(m
, "Active:\n");
221 head
= &vm
->active_list
;
224 seq_puts(m
, "Inactive:\n");
225 head
= &vm
->inactive_list
;
228 mutex_unlock(&dev
->struct_mutex
);
232 total_obj_size
= total_gtt_size
= count
= 0;
233 list_for_each_entry(vma
, head
, mm_list
) {
235 describe_obj(m
, vma
->obj
);
237 total_obj_size
+= vma
->obj
->base
.size
;
238 total_gtt_size
+= vma
->node
.size
;
241 mutex_unlock(&dev
->struct_mutex
);
243 seq_printf(m
, "Total %d objects, %llu bytes, %llu GTT size\n",
244 count
, total_obj_size
, total_gtt_size
);
248 static int obj_rank_by_stolen(void *priv
,
249 struct list_head
*A
, struct list_head
*B
)
251 struct drm_i915_gem_object
*a
=
252 container_of(A
, struct drm_i915_gem_object
, obj_exec_link
);
253 struct drm_i915_gem_object
*b
=
254 container_of(B
, struct drm_i915_gem_object
, obj_exec_link
);
256 if (a
->stolen
->start
< b
->stolen
->start
)
258 if (a
->stolen
->start
> b
->stolen
->start
)
263 static int i915_gem_stolen_list_info(struct seq_file
*m
, void *data
)
265 struct drm_info_node
*node
= m
->private;
266 struct drm_device
*dev
= node
->minor
->dev
;
267 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
268 struct drm_i915_gem_object
*obj
;
269 u64 total_obj_size
, total_gtt_size
;
273 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
277 total_obj_size
= total_gtt_size
= count
= 0;
278 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
279 if (obj
->stolen
== NULL
)
282 list_add(&obj
->obj_exec_link
, &stolen
);
284 total_obj_size
+= obj
->base
.size
;
285 total_gtt_size
+= i915_gem_obj_total_ggtt_size(obj
);
288 list_for_each_entry(obj
, &dev_priv
->mm
.unbound_list
, global_list
) {
289 if (obj
->stolen
== NULL
)
292 list_add(&obj
->obj_exec_link
, &stolen
);
294 total_obj_size
+= obj
->base
.size
;
297 list_sort(NULL
, &stolen
, obj_rank_by_stolen
);
298 seq_puts(m
, "Stolen:\n");
299 while (!list_empty(&stolen
)) {
300 obj
= list_first_entry(&stolen
, typeof(*obj
), obj_exec_link
);
302 describe_obj(m
, obj
);
304 list_del_init(&obj
->obj_exec_link
);
306 mutex_unlock(&dev
->struct_mutex
);
308 seq_printf(m
, "Total %d objects, %llu bytes, %llu GTT size\n",
309 count
, total_obj_size
, total_gtt_size
);
313 #define count_objects(list, member) do { \
314 list_for_each_entry(obj, list, member) { \
315 size += i915_gem_obj_total_ggtt_size(obj); \
317 if (obj->map_and_fenceable) { \
318 mappable_size += i915_gem_obj_ggtt_size(obj); \
325 struct drm_i915_file_private
*file_priv
;
329 u64 active
, inactive
;
332 static int per_file_stats(int id
, void *ptr
, void *data
)
334 struct drm_i915_gem_object
*obj
= ptr
;
335 struct file_stats
*stats
= data
;
336 struct i915_vma
*vma
;
339 stats
->total
+= obj
->base
.size
;
341 if (obj
->base
.name
|| obj
->base
.dma_buf
)
342 stats
->shared
+= obj
->base
.size
;
344 if (USES_FULL_PPGTT(obj
->base
.dev
)) {
345 list_for_each_entry(vma
, &obj
->vma_list
, vma_link
) {
346 struct i915_hw_ppgtt
*ppgtt
;
348 if (!drm_mm_node_allocated(&vma
->node
))
351 if (i915_is_ggtt(vma
->vm
)) {
352 stats
->global
+= obj
->base
.size
;
356 ppgtt
= container_of(vma
->vm
, struct i915_hw_ppgtt
, base
);
357 if (ppgtt
->file_priv
!= stats
->file_priv
)
360 if (obj
->active
) /* XXX per-vma statistic */
361 stats
->active
+= obj
->base
.size
;
363 stats
->inactive
+= obj
->base
.size
;
368 if (i915_gem_obj_ggtt_bound(obj
)) {
369 stats
->global
+= obj
->base
.size
;
371 stats
->active
+= obj
->base
.size
;
373 stats
->inactive
+= obj
->base
.size
;
378 if (!list_empty(&obj
->global_list
))
379 stats
->unbound
+= obj
->base
.size
;
384 #define print_file_stats(m, name, stats) do { \
386 seq_printf(m, "%s: %lu objects, %llu bytes (%llu active, %llu inactive, %llu global, %llu shared, %llu unbound)\n", \
397 static void print_batch_pool_stats(struct seq_file
*m
,
398 struct drm_i915_private
*dev_priv
)
400 struct drm_i915_gem_object
*obj
;
401 struct file_stats stats
;
402 struct intel_engine_cs
*ring
;
405 memset(&stats
, 0, sizeof(stats
));
407 for_each_ring(ring
, dev_priv
, i
) {
408 for (j
= 0; j
< ARRAY_SIZE(ring
->batch_pool
.cache_list
); j
++) {
409 list_for_each_entry(obj
,
410 &ring
->batch_pool
.cache_list
[j
],
412 per_file_stats(0, obj
, &stats
);
416 print_file_stats(m
, "[k]batch pool", stats
);
419 #define count_vmas(list, member) do { \
420 list_for_each_entry(vma, list, member) { \
421 size += i915_gem_obj_total_ggtt_size(vma->obj); \
423 if (vma->obj->map_and_fenceable) { \
424 mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
430 static int i915_gem_object_info(struct seq_file
*m
, void* data
)
432 struct drm_info_node
*node
= m
->private;
433 struct drm_device
*dev
= node
->minor
->dev
;
434 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
435 u32 count
, mappable_count
, purgeable_count
;
436 u64 size
, mappable_size
, purgeable_size
;
437 struct drm_i915_gem_object
*obj
;
438 struct i915_address_space
*vm
= &dev_priv
->gtt
.base
;
439 struct drm_file
*file
;
440 struct i915_vma
*vma
;
443 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
447 seq_printf(m
, "%u objects, %zu bytes\n",
448 dev_priv
->mm
.object_count
,
449 dev_priv
->mm
.object_memory
);
451 size
= count
= mappable_size
= mappable_count
= 0;
452 count_objects(&dev_priv
->mm
.bound_list
, global_list
);
453 seq_printf(m
, "%u [%u] objects, %llu [%llu] bytes in gtt\n",
454 count
, mappable_count
, size
, mappable_size
);
456 size
= count
= mappable_size
= mappable_count
= 0;
457 count_vmas(&vm
->active_list
, mm_list
);
458 seq_printf(m
, " %u [%u] active objects, %llu [%llu] bytes\n",
459 count
, mappable_count
, size
, mappable_size
);
461 size
= count
= mappable_size
= mappable_count
= 0;
462 count_vmas(&vm
->inactive_list
, mm_list
);
463 seq_printf(m
, " %u [%u] inactive objects, %llu [%llu] bytes\n",
464 count
, mappable_count
, size
, mappable_size
);
466 size
= count
= purgeable_size
= purgeable_count
= 0;
467 list_for_each_entry(obj
, &dev_priv
->mm
.unbound_list
, global_list
) {
468 size
+= obj
->base
.size
, ++count
;
469 if (obj
->madv
== I915_MADV_DONTNEED
)
470 purgeable_size
+= obj
->base
.size
, ++purgeable_count
;
472 seq_printf(m
, "%u unbound objects, %llu bytes\n", count
, size
);
474 size
= count
= mappable_size
= mappable_count
= 0;
475 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
476 if (obj
->fault_mappable
) {
477 size
+= i915_gem_obj_ggtt_size(obj
);
480 if (obj
->pin_display
) {
481 mappable_size
+= i915_gem_obj_ggtt_size(obj
);
484 if (obj
->madv
== I915_MADV_DONTNEED
) {
485 purgeable_size
+= obj
->base
.size
;
489 seq_printf(m
, "%u purgeable objects, %llu bytes\n",
490 purgeable_count
, purgeable_size
);
491 seq_printf(m
, "%u pinned mappable objects, %llu bytes\n",
492 mappable_count
, mappable_size
);
493 seq_printf(m
, "%u fault mappable objects, %llu bytes\n",
496 seq_printf(m
, "%llu [%llu] gtt total\n",
497 dev_priv
->gtt
.base
.total
,
498 (u64
)dev_priv
->gtt
.mappable_end
- dev_priv
->gtt
.base
.start
);
501 print_batch_pool_stats(m
, dev_priv
);
502 list_for_each_entry_reverse(file
, &dev
->filelist
, lhead
) {
503 struct file_stats stats
;
504 struct task_struct
*task
;
506 memset(&stats
, 0, sizeof(stats
));
507 stats
.file_priv
= file
->driver_priv
;
508 spin_lock(&file
->table_lock
);
509 idr_for_each(&file
->object_idr
, per_file_stats
, &stats
);
510 spin_unlock(&file
->table_lock
);
512 * Although we have a valid reference on file->pid, that does
513 * not guarantee that the task_struct who called get_pid() is
514 * still alive (e.g. get_pid(current) => fork() => exit()).
515 * Therefore, we need to protect this ->comm access using RCU.
518 task
= pid_task(file
->pid
, PIDTYPE_PID
);
519 print_file_stats(m
, task
? task
->comm
: "<unknown>", stats
);
523 mutex_unlock(&dev
->struct_mutex
);
528 static int i915_gem_gtt_info(struct seq_file
*m
, void *data
)
530 struct drm_info_node
*node
= m
->private;
531 struct drm_device
*dev
= node
->minor
->dev
;
532 uintptr_t list
= (uintptr_t) node
->info_ent
->data
;
533 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
534 struct drm_i915_gem_object
*obj
;
535 u64 total_obj_size
, total_gtt_size
;
538 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
542 total_obj_size
= total_gtt_size
= count
= 0;
543 list_for_each_entry(obj
, &dev_priv
->mm
.bound_list
, global_list
) {
544 if (list
== PINNED_LIST
&& !i915_gem_obj_is_pinned(obj
))
548 describe_obj(m
, obj
);
550 total_obj_size
+= obj
->base
.size
;
551 total_gtt_size
+= i915_gem_obj_total_ggtt_size(obj
);
555 mutex_unlock(&dev
->struct_mutex
);
557 seq_printf(m
, "Total %d objects, %llu bytes, %llu GTT size\n",
558 count
, total_obj_size
, total_gtt_size
);
563 static int i915_gem_pageflip_info(struct seq_file
*m
, void *data
)
565 struct drm_info_node
*node
= m
->private;
566 struct drm_device
*dev
= node
->minor
->dev
;
567 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
568 struct intel_crtc
*crtc
;
571 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
575 for_each_intel_crtc(dev
, crtc
) {
576 const char pipe
= pipe_name(crtc
->pipe
);
577 const char plane
= plane_name(crtc
->plane
);
578 struct intel_unpin_work
*work
;
580 spin_lock_irq(&dev
->event_lock
);
581 work
= crtc
->unpin_work
;
583 seq_printf(m
, "No flip due on pipe %c (plane %c)\n",
588 if (atomic_read(&work
->pending
) < INTEL_FLIP_COMPLETE
) {
589 seq_printf(m
, "Flip queued on pipe %c (plane %c)\n",
592 seq_printf(m
, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
595 if (work
->flip_queued_req
) {
596 struct intel_engine_cs
*ring
=
597 i915_gem_request_get_ring(work
->flip_queued_req
);
599 seq_printf(m
, "Flip queued on %s at seqno %x, next seqno %x [current breadcrumb %x], completed? %d\n",
601 i915_gem_request_get_seqno(work
->flip_queued_req
),
602 dev_priv
->next_seqno
,
603 ring
->get_seqno(ring
, true),
604 i915_gem_request_completed(work
->flip_queued_req
, true));
606 seq_printf(m
, "Flip not associated with any ring\n");
607 seq_printf(m
, "Flip queued on frame %d, (was ready on frame %d), now %d\n",
608 work
->flip_queued_vblank
,
609 work
->flip_ready_vblank
,
610 drm_crtc_vblank_count(&crtc
->base
));
611 if (work
->enable_stall_check
)
612 seq_puts(m
, "Stall check enabled, ");
614 seq_puts(m
, "Stall check waiting for page flip ioctl, ");
615 seq_printf(m
, "%d prepares\n", atomic_read(&work
->pending
));
617 if (INTEL_INFO(dev
)->gen
>= 4)
618 addr
= I915_HI_DISPBASE(I915_READ(DSPSURF(crtc
->plane
)));
620 addr
= I915_READ(DSPADDR(crtc
->plane
));
621 seq_printf(m
, "Current scanout address 0x%08x\n", addr
);
623 if (work
->pending_flip_obj
) {
624 seq_printf(m
, "New framebuffer address 0x%08lx\n", (long)work
->gtt_offset
);
625 seq_printf(m
, "MMIO update completed? %d\n", addr
== work
->gtt_offset
);
628 spin_unlock_irq(&dev
->event_lock
);
631 mutex_unlock(&dev
->struct_mutex
);
636 static int i915_gem_batch_pool_info(struct seq_file
*m
, void *data
)
638 struct drm_info_node
*node
= m
->private;
639 struct drm_device
*dev
= node
->minor
->dev
;
640 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
641 struct drm_i915_gem_object
*obj
;
642 struct intel_engine_cs
*ring
;
646 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
650 for_each_ring(ring
, dev_priv
, i
) {
651 for (j
= 0; j
< ARRAY_SIZE(ring
->batch_pool
.cache_list
); j
++) {
655 list_for_each_entry(obj
,
656 &ring
->batch_pool
.cache_list
[j
],
659 seq_printf(m
, "%s cache[%d]: %d objects\n",
660 ring
->name
, j
, count
);
662 list_for_each_entry(obj
,
663 &ring
->batch_pool
.cache_list
[j
],
666 describe_obj(m
, obj
);
674 seq_printf(m
, "total: %d\n", total
);
676 mutex_unlock(&dev
->struct_mutex
);
681 static int i915_gem_request_info(struct seq_file
*m
, void *data
)
683 struct drm_info_node
*node
= m
->private;
684 struct drm_device
*dev
= node
->minor
->dev
;
685 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
686 struct intel_engine_cs
*ring
;
687 struct drm_i915_gem_request
*req
;
690 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
695 for_each_ring(ring
, dev_priv
, i
) {
699 list_for_each_entry(req
, &ring
->request_list
, list
)
704 seq_printf(m
, "%s requests: %d\n", ring
->name
, count
);
705 list_for_each_entry(req
, &ring
->request_list
, list
) {
706 struct task_struct
*task
;
711 task
= pid_task(req
->pid
, PIDTYPE_PID
);
712 seq_printf(m
, " %x @ %d: %s [%d]\n",
714 (int) (jiffies
- req
->emitted_jiffies
),
715 task
? task
->comm
: "<unknown>",
716 task
? task
->pid
: -1);
722 mutex_unlock(&dev
->struct_mutex
);
725 seq_puts(m
, "No requests\n");
730 static void i915_ring_seqno_info(struct seq_file
*m
,
731 struct intel_engine_cs
*ring
)
733 if (ring
->get_seqno
) {
734 seq_printf(m
, "Current sequence (%s): %x\n",
735 ring
->name
, ring
->get_seqno(ring
, false));
739 static int i915_gem_seqno_info(struct seq_file
*m
, void *data
)
741 struct drm_info_node
*node
= m
->private;
742 struct drm_device
*dev
= node
->minor
->dev
;
743 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
744 struct intel_engine_cs
*ring
;
747 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
750 intel_runtime_pm_get(dev_priv
);
752 for_each_ring(ring
, dev_priv
, i
)
753 i915_ring_seqno_info(m
, ring
);
755 intel_runtime_pm_put(dev_priv
);
756 mutex_unlock(&dev
->struct_mutex
);
762 static int i915_interrupt_info(struct seq_file
*m
, void *data
)
764 struct drm_info_node
*node
= m
->private;
765 struct drm_device
*dev
= node
->minor
->dev
;
766 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
767 struct intel_engine_cs
*ring
;
770 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
773 intel_runtime_pm_get(dev_priv
);
775 if (IS_CHERRYVIEW(dev
)) {
776 seq_printf(m
, "Master Interrupt Control:\t%08x\n",
777 I915_READ(GEN8_MASTER_IRQ
));
779 seq_printf(m
, "Display IER:\t%08x\n",
781 seq_printf(m
, "Display IIR:\t%08x\n",
783 seq_printf(m
, "Display IIR_RW:\t%08x\n",
784 I915_READ(VLV_IIR_RW
));
785 seq_printf(m
, "Display IMR:\t%08x\n",
787 for_each_pipe(dev_priv
, pipe
)
788 seq_printf(m
, "Pipe %c stat:\t%08x\n",
790 I915_READ(PIPESTAT(pipe
)));
792 seq_printf(m
, "Port hotplug:\t%08x\n",
793 I915_READ(PORT_HOTPLUG_EN
));
794 seq_printf(m
, "DPFLIPSTAT:\t%08x\n",
795 I915_READ(VLV_DPFLIPSTAT
));
796 seq_printf(m
, "DPINVGTT:\t%08x\n",
797 I915_READ(DPINVGTT
));
799 for (i
= 0; i
< 4; i
++) {
800 seq_printf(m
, "GT Interrupt IMR %d:\t%08x\n",
801 i
, I915_READ(GEN8_GT_IMR(i
)));
802 seq_printf(m
, "GT Interrupt IIR %d:\t%08x\n",
803 i
, I915_READ(GEN8_GT_IIR(i
)));
804 seq_printf(m
, "GT Interrupt IER %d:\t%08x\n",
805 i
, I915_READ(GEN8_GT_IER(i
)));
808 seq_printf(m
, "PCU interrupt mask:\t%08x\n",
809 I915_READ(GEN8_PCU_IMR
));
810 seq_printf(m
, "PCU interrupt identity:\t%08x\n",
811 I915_READ(GEN8_PCU_IIR
));
812 seq_printf(m
, "PCU interrupt enable:\t%08x\n",
813 I915_READ(GEN8_PCU_IER
));
814 } else if (INTEL_INFO(dev
)->gen
>= 8) {
815 seq_printf(m
, "Master Interrupt Control:\t%08x\n",
816 I915_READ(GEN8_MASTER_IRQ
));
818 for (i
= 0; i
< 4; i
++) {
819 seq_printf(m
, "GT Interrupt IMR %d:\t%08x\n",
820 i
, I915_READ(GEN8_GT_IMR(i
)));
821 seq_printf(m
, "GT Interrupt IIR %d:\t%08x\n",
822 i
, I915_READ(GEN8_GT_IIR(i
)));
823 seq_printf(m
, "GT Interrupt IER %d:\t%08x\n",
824 i
, I915_READ(GEN8_GT_IER(i
)));
827 for_each_pipe(dev_priv
, pipe
) {
828 if (!intel_display_power_is_enabled(dev_priv
,
829 POWER_DOMAIN_PIPE(pipe
))) {
830 seq_printf(m
, "Pipe %c power disabled\n",
834 seq_printf(m
, "Pipe %c IMR:\t%08x\n",
836 I915_READ(GEN8_DE_PIPE_IMR(pipe
)));
837 seq_printf(m
, "Pipe %c IIR:\t%08x\n",
839 I915_READ(GEN8_DE_PIPE_IIR(pipe
)));
840 seq_printf(m
, "Pipe %c IER:\t%08x\n",
842 I915_READ(GEN8_DE_PIPE_IER(pipe
)));
845 seq_printf(m
, "Display Engine port interrupt mask:\t%08x\n",
846 I915_READ(GEN8_DE_PORT_IMR
));
847 seq_printf(m
, "Display Engine port interrupt identity:\t%08x\n",
848 I915_READ(GEN8_DE_PORT_IIR
));
849 seq_printf(m
, "Display Engine port interrupt enable:\t%08x\n",
850 I915_READ(GEN8_DE_PORT_IER
));
852 seq_printf(m
, "Display Engine misc interrupt mask:\t%08x\n",
853 I915_READ(GEN8_DE_MISC_IMR
));
854 seq_printf(m
, "Display Engine misc interrupt identity:\t%08x\n",
855 I915_READ(GEN8_DE_MISC_IIR
));
856 seq_printf(m
, "Display Engine misc interrupt enable:\t%08x\n",
857 I915_READ(GEN8_DE_MISC_IER
));
859 seq_printf(m
, "PCU interrupt mask:\t%08x\n",
860 I915_READ(GEN8_PCU_IMR
));
861 seq_printf(m
, "PCU interrupt identity:\t%08x\n",
862 I915_READ(GEN8_PCU_IIR
));
863 seq_printf(m
, "PCU interrupt enable:\t%08x\n",
864 I915_READ(GEN8_PCU_IER
));
865 } else if (IS_VALLEYVIEW(dev
)) {
866 seq_printf(m
, "Display IER:\t%08x\n",
868 seq_printf(m
, "Display IIR:\t%08x\n",
870 seq_printf(m
, "Display IIR_RW:\t%08x\n",
871 I915_READ(VLV_IIR_RW
));
872 seq_printf(m
, "Display IMR:\t%08x\n",
874 for_each_pipe(dev_priv
, pipe
)
875 seq_printf(m
, "Pipe %c stat:\t%08x\n",
877 I915_READ(PIPESTAT(pipe
)));
879 seq_printf(m
, "Master IER:\t%08x\n",
880 I915_READ(VLV_MASTER_IER
));
882 seq_printf(m
, "Render IER:\t%08x\n",
884 seq_printf(m
, "Render IIR:\t%08x\n",
886 seq_printf(m
, "Render IMR:\t%08x\n",
889 seq_printf(m
, "PM IER:\t\t%08x\n",
890 I915_READ(GEN6_PMIER
));
891 seq_printf(m
, "PM IIR:\t\t%08x\n",
892 I915_READ(GEN6_PMIIR
));
893 seq_printf(m
, "PM IMR:\t\t%08x\n",
894 I915_READ(GEN6_PMIMR
));
896 seq_printf(m
, "Port hotplug:\t%08x\n",
897 I915_READ(PORT_HOTPLUG_EN
));
898 seq_printf(m
, "DPFLIPSTAT:\t%08x\n",
899 I915_READ(VLV_DPFLIPSTAT
));
900 seq_printf(m
, "DPINVGTT:\t%08x\n",
901 I915_READ(DPINVGTT
));
903 } else if (!HAS_PCH_SPLIT(dev
)) {
904 seq_printf(m
, "Interrupt enable: %08x\n",
906 seq_printf(m
, "Interrupt identity: %08x\n",
908 seq_printf(m
, "Interrupt mask: %08x\n",
910 for_each_pipe(dev_priv
, pipe
)
911 seq_printf(m
, "Pipe %c stat: %08x\n",
913 I915_READ(PIPESTAT(pipe
)));
915 seq_printf(m
, "North Display Interrupt enable: %08x\n",
917 seq_printf(m
, "North Display Interrupt identity: %08x\n",
919 seq_printf(m
, "North Display Interrupt mask: %08x\n",
921 seq_printf(m
, "South Display Interrupt enable: %08x\n",
923 seq_printf(m
, "South Display Interrupt identity: %08x\n",
925 seq_printf(m
, "South Display Interrupt mask: %08x\n",
927 seq_printf(m
, "Graphics Interrupt enable: %08x\n",
929 seq_printf(m
, "Graphics Interrupt identity: %08x\n",
931 seq_printf(m
, "Graphics Interrupt mask: %08x\n",
934 for_each_ring(ring
, dev_priv
, i
) {
935 if (INTEL_INFO(dev
)->gen
>= 6) {
937 "Graphics Interrupt mask (%s): %08x\n",
938 ring
->name
, I915_READ_IMR(ring
));
940 i915_ring_seqno_info(m
, ring
);
942 intel_runtime_pm_put(dev_priv
);
943 mutex_unlock(&dev
->struct_mutex
);
948 static int i915_gem_fence_regs_info(struct seq_file
*m
, void *data
)
950 struct drm_info_node
*node
= m
->private;
951 struct drm_device
*dev
= node
->minor
->dev
;
952 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
955 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
959 seq_printf(m
, "Reserved fences = %d\n", dev_priv
->fence_reg_start
);
960 seq_printf(m
, "Total fences = %d\n", dev_priv
->num_fence_regs
);
961 for (i
= 0; i
< dev_priv
->num_fence_regs
; i
++) {
962 struct drm_i915_gem_object
*obj
= dev_priv
->fence_regs
[i
].obj
;
964 seq_printf(m
, "Fence %d, pin count = %d, object = ",
965 i
, dev_priv
->fence_regs
[i
].pin_count
);
967 seq_puts(m
, "unused");
969 describe_obj(m
, obj
);
973 mutex_unlock(&dev
->struct_mutex
);
977 static int i915_hws_info(struct seq_file
*m
, void *data
)
979 struct drm_info_node
*node
= m
->private;
980 struct drm_device
*dev
= node
->minor
->dev
;
981 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
982 struct intel_engine_cs
*ring
;
986 ring
= &dev_priv
->ring
[(uintptr_t)node
->info_ent
->data
];
987 hws
= ring
->status_page
.page_addr
;
991 for (i
= 0; i
< 4096 / sizeof(u32
) / 4; i
+= 4) {
992 seq_printf(m
, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
994 hws
[i
], hws
[i
+ 1], hws
[i
+ 2], hws
[i
+ 3]);
1000 i915_error_state_write(struct file
*filp
,
1001 const char __user
*ubuf
,
1005 struct i915_error_state_file_priv
*error_priv
= filp
->private_data
;
1006 struct drm_device
*dev
= error_priv
->dev
;
1009 DRM_DEBUG_DRIVER("Resetting error state\n");
1011 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1015 i915_destroy_error_state(dev
);
1016 mutex_unlock(&dev
->struct_mutex
);
1021 static int i915_error_state_open(struct inode
*inode
, struct file
*file
)
1023 struct drm_device
*dev
= inode
->i_private
;
1024 struct i915_error_state_file_priv
*error_priv
;
1026 error_priv
= kzalloc(sizeof(*error_priv
), GFP_KERNEL
);
1030 error_priv
->dev
= dev
;
1032 i915_error_state_get(dev
, error_priv
);
1034 file
->private_data
= error_priv
;
1039 static int i915_error_state_release(struct inode
*inode
, struct file
*file
)
1041 struct i915_error_state_file_priv
*error_priv
= file
->private_data
;
1043 i915_error_state_put(error_priv
);
1049 static ssize_t
i915_error_state_read(struct file
*file
, char __user
*userbuf
,
1050 size_t count
, loff_t
*pos
)
1052 struct i915_error_state_file_priv
*error_priv
= file
->private_data
;
1053 struct drm_i915_error_state_buf error_str
;
1055 ssize_t ret_count
= 0;
1058 ret
= i915_error_state_buf_init(&error_str
, to_i915(error_priv
->dev
), count
, *pos
);
1062 ret
= i915_error_state_to_str(&error_str
, error_priv
);
1066 ret_count
= simple_read_from_buffer(userbuf
, count
, &tmp_pos
,
1073 *pos
= error_str
.start
+ ret_count
;
1075 i915_error_state_buf_release(&error_str
);
1076 return ret
?: ret_count
;
1079 static const struct file_operations i915_error_state_fops
= {
1080 .owner
= THIS_MODULE
,
1081 .open
= i915_error_state_open
,
1082 .read
= i915_error_state_read
,
1083 .write
= i915_error_state_write
,
1084 .llseek
= default_llseek
,
1085 .release
= i915_error_state_release
,
1089 i915_next_seqno_get(void *data
, u64
*val
)
1091 struct drm_device
*dev
= data
;
1092 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1095 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1099 *val
= dev_priv
->next_seqno
;
1100 mutex_unlock(&dev
->struct_mutex
);
1106 i915_next_seqno_set(void *data
, u64 val
)
1108 struct drm_device
*dev
= data
;
1111 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1115 ret
= i915_gem_set_seqno(dev
, val
);
1116 mutex_unlock(&dev
->struct_mutex
);
1121 DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops
,
1122 i915_next_seqno_get
, i915_next_seqno_set
,
1125 static int i915_frequency_info(struct seq_file
*m
, void *unused
)
1127 struct drm_info_node
*node
= m
->private;
1128 struct drm_device
*dev
= node
->minor
->dev
;
1129 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1132 intel_runtime_pm_get(dev_priv
);
1134 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
1137 u16 rgvswctl
= I915_READ16(MEMSWCTL
);
1138 u16 rgvstat
= I915_READ16(MEMSTAT_ILK
);
1140 seq_printf(m
, "Requested P-state: %d\n", (rgvswctl
>> 8) & 0xf);
1141 seq_printf(m
, "Requested VID: %d\n", rgvswctl
& 0x3f);
1142 seq_printf(m
, "Current VID: %d\n", (rgvstat
& MEMSTAT_VID_MASK
) >>
1144 seq_printf(m
, "Current P-state: %d\n",
1145 (rgvstat
& MEMSTAT_PSTATE_MASK
) >> MEMSTAT_PSTATE_SHIFT
);
1146 } else if (IS_GEN6(dev
) || (IS_GEN7(dev
) && !IS_VALLEYVIEW(dev
)) ||
1147 IS_BROADWELL(dev
) || IS_GEN9(dev
)) {
1148 u32 rp_state_limits
;
1151 u32 rpmodectl
, rpinclimit
, rpdeclimit
;
1152 u32 rpstat
, cagf
, reqf
;
1153 u32 rpupei
, rpcurup
, rpprevup
;
1154 u32 rpdownei
, rpcurdown
, rpprevdown
;
1155 u32 pm_ier
, pm_imr
, pm_isr
, pm_iir
, pm_mask
;
1158 rp_state_limits
= I915_READ(GEN6_RP_STATE_LIMITS
);
1159 if (IS_BROXTON(dev
)) {
1160 rp_state_cap
= I915_READ(BXT_RP_STATE_CAP
);
1161 gt_perf_status
= I915_READ(BXT_GT_PERF_STATUS
);
1163 rp_state_cap
= I915_READ(GEN6_RP_STATE_CAP
);
1164 gt_perf_status
= I915_READ(GEN6_GT_PERF_STATUS
);
1167 /* RPSTAT1 is in the GT power well */
1168 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1172 intel_uncore_forcewake_get(dev_priv
, FORCEWAKE_ALL
);
1174 reqf
= I915_READ(GEN6_RPNSWREQ
);
1178 reqf
&= ~GEN6_TURBO_DISABLE
;
1179 if (IS_HASWELL(dev
) || IS_BROADWELL(dev
))
1184 reqf
= intel_gpu_freq(dev_priv
, reqf
);
1186 rpmodectl
= I915_READ(GEN6_RP_CONTROL
);
1187 rpinclimit
= I915_READ(GEN6_RP_UP_THRESHOLD
);
1188 rpdeclimit
= I915_READ(GEN6_RP_DOWN_THRESHOLD
);
1190 rpstat
= I915_READ(GEN6_RPSTAT1
);
1191 rpupei
= I915_READ(GEN6_RP_CUR_UP_EI
);
1192 rpcurup
= I915_READ(GEN6_RP_CUR_UP
);
1193 rpprevup
= I915_READ(GEN6_RP_PREV_UP
);
1194 rpdownei
= I915_READ(GEN6_RP_CUR_DOWN_EI
);
1195 rpcurdown
= I915_READ(GEN6_RP_CUR_DOWN
);
1196 rpprevdown
= I915_READ(GEN6_RP_PREV_DOWN
);
1198 cagf
= (rpstat
& GEN9_CAGF_MASK
) >> GEN9_CAGF_SHIFT
;
1199 else if (IS_HASWELL(dev
) || IS_BROADWELL(dev
))
1200 cagf
= (rpstat
& HSW_CAGF_MASK
) >> HSW_CAGF_SHIFT
;
1202 cagf
= (rpstat
& GEN6_CAGF_MASK
) >> GEN6_CAGF_SHIFT
;
1203 cagf
= intel_gpu_freq(dev_priv
, cagf
);
1205 intel_uncore_forcewake_put(dev_priv
, FORCEWAKE_ALL
);
1206 mutex_unlock(&dev
->struct_mutex
);
1208 if (IS_GEN6(dev
) || IS_GEN7(dev
)) {
1209 pm_ier
= I915_READ(GEN6_PMIER
);
1210 pm_imr
= I915_READ(GEN6_PMIMR
);
1211 pm_isr
= I915_READ(GEN6_PMISR
);
1212 pm_iir
= I915_READ(GEN6_PMIIR
);
1213 pm_mask
= I915_READ(GEN6_PMINTRMSK
);
1215 pm_ier
= I915_READ(GEN8_GT_IER(2));
1216 pm_imr
= I915_READ(GEN8_GT_IMR(2));
1217 pm_isr
= I915_READ(GEN8_GT_ISR(2));
1218 pm_iir
= I915_READ(GEN8_GT_IIR(2));
1219 pm_mask
= I915_READ(GEN6_PMINTRMSK
);
1221 seq_printf(m
, "PM IER=0x%08x IMR=0x%08x ISR=0x%08x IIR=0x%08x, MASK=0x%08x\n",
1222 pm_ier
, pm_imr
, pm_isr
, pm_iir
, pm_mask
);
1223 seq_printf(m
, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status
);
1224 seq_printf(m
, "Render p-state ratio: %d\n",
1225 (gt_perf_status
& (IS_GEN9(dev
) ? 0x1ff00 : 0xff00)) >> 8);
1226 seq_printf(m
, "Render p-state VID: %d\n",
1227 gt_perf_status
& 0xff);
1228 seq_printf(m
, "Render p-state limit: %d\n",
1229 rp_state_limits
& 0xff);
1230 seq_printf(m
, "RPSTAT1: 0x%08x\n", rpstat
);
1231 seq_printf(m
, "RPMODECTL: 0x%08x\n", rpmodectl
);
1232 seq_printf(m
, "RPINCLIMIT: 0x%08x\n", rpinclimit
);
1233 seq_printf(m
, "RPDECLIMIT: 0x%08x\n", rpdeclimit
);
1234 seq_printf(m
, "RPNSWREQ: %dMHz\n", reqf
);
1235 seq_printf(m
, "CAGF: %dMHz\n", cagf
);
1236 seq_printf(m
, "RP CUR UP EI: %dus\n", rpupei
&
1237 GEN6_CURICONT_MASK
);
1238 seq_printf(m
, "RP CUR UP: %dus\n", rpcurup
&
1239 GEN6_CURBSYTAVG_MASK
);
1240 seq_printf(m
, "RP PREV UP: %dus\n", rpprevup
&
1241 GEN6_CURBSYTAVG_MASK
);
1242 seq_printf(m
, "Up threshold: %d%%\n",
1243 dev_priv
->rps
.up_threshold
);
1245 seq_printf(m
, "RP CUR DOWN EI: %dus\n", rpdownei
&
1247 seq_printf(m
, "RP CUR DOWN: %dus\n", rpcurdown
&
1248 GEN6_CURBSYTAVG_MASK
);
1249 seq_printf(m
, "RP PREV DOWN: %dus\n", rpprevdown
&
1250 GEN6_CURBSYTAVG_MASK
);
1251 seq_printf(m
, "Down threshold: %d%%\n",
1252 dev_priv
->rps
.down_threshold
);
1254 max_freq
= (IS_BROXTON(dev
) ? rp_state_cap
>> 0 :
1255 rp_state_cap
>> 16) & 0xff;
1256 max_freq
*= (IS_SKYLAKE(dev
) || IS_KABYLAKE(dev
) ?
1257 GEN9_FREQ_SCALER
: 1);
1258 seq_printf(m
, "Lowest (RPN) frequency: %dMHz\n",
1259 intel_gpu_freq(dev_priv
, max_freq
));
1261 max_freq
= (rp_state_cap
& 0xff00) >> 8;
1262 max_freq
*= (IS_SKYLAKE(dev
) || IS_KABYLAKE(dev
) ?
1263 GEN9_FREQ_SCALER
: 1);
1264 seq_printf(m
, "Nominal (RP1) frequency: %dMHz\n",
1265 intel_gpu_freq(dev_priv
, max_freq
));
1267 max_freq
= (IS_BROXTON(dev
) ? rp_state_cap
>> 16 :
1268 rp_state_cap
>> 0) & 0xff;
1269 max_freq
*= (IS_SKYLAKE(dev
) || IS_KABYLAKE(dev
) ?
1270 GEN9_FREQ_SCALER
: 1);
1271 seq_printf(m
, "Max non-overclocked (RP0) frequency: %dMHz\n",
1272 intel_gpu_freq(dev_priv
, max_freq
));
1273 seq_printf(m
, "Max overclocked frequency: %dMHz\n",
1274 intel_gpu_freq(dev_priv
, dev_priv
->rps
.max_freq
));
1276 seq_printf(m
, "Current freq: %d MHz\n",
1277 intel_gpu_freq(dev_priv
, dev_priv
->rps
.cur_freq
));
1278 seq_printf(m
, "Actual freq: %d MHz\n", cagf
);
1279 seq_printf(m
, "Idle freq: %d MHz\n",
1280 intel_gpu_freq(dev_priv
, dev_priv
->rps
.idle_freq
));
1281 seq_printf(m
, "Min freq: %d MHz\n",
1282 intel_gpu_freq(dev_priv
, dev_priv
->rps
.min_freq
));
1283 seq_printf(m
, "Max freq: %d MHz\n",
1284 intel_gpu_freq(dev_priv
, dev_priv
->rps
.max_freq
));
1286 "efficient (RPe) frequency: %d MHz\n",
1287 intel_gpu_freq(dev_priv
, dev_priv
->rps
.efficient_freq
));
1288 } else if (IS_VALLEYVIEW(dev
)) {
1291 mutex_lock(&dev_priv
->rps
.hw_lock
);
1292 freq_sts
= vlv_punit_read(dev_priv
, PUNIT_REG_GPU_FREQ_STS
);
1293 seq_printf(m
, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts
);
1294 seq_printf(m
, "DDR freq: %d MHz\n", dev_priv
->mem_freq
);
1296 seq_printf(m
, "actual GPU freq: %d MHz\n",
1297 intel_gpu_freq(dev_priv
, (freq_sts
>> 8) & 0xff));
1299 seq_printf(m
, "current GPU freq: %d MHz\n",
1300 intel_gpu_freq(dev_priv
, dev_priv
->rps
.cur_freq
));
1302 seq_printf(m
, "max GPU freq: %d MHz\n",
1303 intel_gpu_freq(dev_priv
, dev_priv
->rps
.max_freq
));
1305 seq_printf(m
, "min GPU freq: %d MHz\n",
1306 intel_gpu_freq(dev_priv
, dev_priv
->rps
.min_freq
));
1308 seq_printf(m
, "idle GPU freq: %d MHz\n",
1309 intel_gpu_freq(dev_priv
, dev_priv
->rps
.idle_freq
));
1312 "efficient (RPe) frequency: %d MHz\n",
1313 intel_gpu_freq(dev_priv
, dev_priv
->rps
.efficient_freq
));
1314 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1316 seq_puts(m
, "no P-state info available\n");
1319 seq_printf(m
, "Current CD clock frequency: %d kHz\n", dev_priv
->cdclk_freq
);
1320 seq_printf(m
, "Max CD clock frequency: %d kHz\n", dev_priv
->max_cdclk_freq
);
1321 seq_printf(m
, "Max pixel clock frequency: %d kHz\n", dev_priv
->max_dotclk_freq
);
1324 intel_runtime_pm_put(dev_priv
);
1328 static int i915_hangcheck_info(struct seq_file
*m
, void *unused
)
1330 struct drm_info_node
*node
= m
->private;
1331 struct drm_device
*dev
= node
->minor
->dev
;
1332 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1333 struct intel_engine_cs
*ring
;
1334 u64 acthd
[I915_NUM_RINGS
];
1335 u32 seqno
[I915_NUM_RINGS
];
1338 if (!i915
.enable_hangcheck
) {
1339 seq_printf(m
, "Hangcheck disabled\n");
1343 intel_runtime_pm_get(dev_priv
);
1345 for_each_ring(ring
, dev_priv
, i
) {
1346 seqno
[i
] = ring
->get_seqno(ring
, false);
1347 acthd
[i
] = intel_ring_get_active_head(ring
);
1350 intel_runtime_pm_put(dev_priv
);
1352 if (delayed_work_pending(&dev_priv
->gpu_error
.hangcheck_work
)) {
1353 seq_printf(m
, "Hangcheck active, fires in %dms\n",
1354 jiffies_to_msecs(dev_priv
->gpu_error
.hangcheck_work
.timer
.expires
-
1357 seq_printf(m
, "Hangcheck inactive\n");
1359 for_each_ring(ring
, dev_priv
, i
) {
1360 seq_printf(m
, "%s:\n", ring
->name
);
1361 seq_printf(m
, "\tseqno = %x [current %x]\n",
1362 ring
->hangcheck
.seqno
, seqno
[i
]);
1363 seq_printf(m
, "\tACTHD = 0x%08llx [current 0x%08llx]\n",
1364 (long long)ring
->hangcheck
.acthd
,
1365 (long long)acthd
[i
]);
1366 seq_printf(m
, "\tmax ACTHD = 0x%08llx\n",
1367 (long long)ring
->hangcheck
.max_acthd
);
1368 seq_printf(m
, "\tscore = %d\n", ring
->hangcheck
.score
);
1369 seq_printf(m
, "\taction = %d\n", ring
->hangcheck
.action
);
1375 static int ironlake_drpc_info(struct seq_file
*m
)
1377 struct drm_info_node
*node
= m
->private;
1378 struct drm_device
*dev
= node
->minor
->dev
;
1379 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1380 u32 rgvmodectl
, rstdbyctl
;
1384 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1387 intel_runtime_pm_get(dev_priv
);
1389 rgvmodectl
= I915_READ(MEMMODECTL
);
1390 rstdbyctl
= I915_READ(RSTDBYCTL
);
1391 crstandvid
= I915_READ16(CRSTANDVID
);
1393 intel_runtime_pm_put(dev_priv
);
1394 mutex_unlock(&dev
->struct_mutex
);
1396 seq_printf(m
, "HD boost: %s\n", yesno(rgvmodectl
& MEMMODE_BOOST_EN
));
1397 seq_printf(m
, "Boost freq: %d\n",
1398 (rgvmodectl
& MEMMODE_BOOST_FREQ_MASK
) >>
1399 MEMMODE_BOOST_FREQ_SHIFT
);
1400 seq_printf(m
, "HW control enabled: %s\n",
1401 yesno(rgvmodectl
& MEMMODE_HWIDLE_EN
));
1402 seq_printf(m
, "SW control enabled: %s\n",
1403 yesno(rgvmodectl
& MEMMODE_SWMODE_EN
));
1404 seq_printf(m
, "Gated voltage change: %s\n",
1405 yesno(rgvmodectl
& MEMMODE_RCLK_GATE
));
1406 seq_printf(m
, "Starting frequency: P%d\n",
1407 (rgvmodectl
& MEMMODE_FSTART_MASK
) >> MEMMODE_FSTART_SHIFT
);
1408 seq_printf(m
, "Max P-state: P%d\n",
1409 (rgvmodectl
& MEMMODE_FMAX_MASK
) >> MEMMODE_FMAX_SHIFT
);
1410 seq_printf(m
, "Min P-state: P%d\n", (rgvmodectl
& MEMMODE_FMIN_MASK
));
1411 seq_printf(m
, "RS1 VID: %d\n", (crstandvid
& 0x3f));
1412 seq_printf(m
, "RS2 VID: %d\n", ((crstandvid
>> 8) & 0x3f));
1413 seq_printf(m
, "Render standby enabled: %s\n",
1414 yesno(!(rstdbyctl
& RCX_SW_EXIT
)));
1415 seq_puts(m
, "Current RS state: ");
1416 switch (rstdbyctl
& RSX_STATUS_MASK
) {
1418 seq_puts(m
, "on\n");
1420 case RSX_STATUS_RC1
:
1421 seq_puts(m
, "RC1\n");
1423 case RSX_STATUS_RC1E
:
1424 seq_puts(m
, "RC1E\n");
1426 case RSX_STATUS_RS1
:
1427 seq_puts(m
, "RS1\n");
1429 case RSX_STATUS_RS2
:
1430 seq_puts(m
, "RS2 (RC6)\n");
1432 case RSX_STATUS_RS3
:
1433 seq_puts(m
, "RC3 (RC6+)\n");
1436 seq_puts(m
, "unknown\n");
1443 static int i915_forcewake_domains(struct seq_file
*m
, void *data
)
1445 struct drm_info_node
*node
= m
->private;
1446 struct drm_device
*dev
= node
->minor
->dev
;
1447 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1448 struct intel_uncore_forcewake_domain
*fw_domain
;
1451 spin_lock_irq(&dev_priv
->uncore
.lock
);
1452 for_each_fw_domain(fw_domain
, dev_priv
, i
) {
1453 seq_printf(m
, "%s.wake_count = %u\n",
1454 intel_uncore_forcewake_domain_to_str(i
),
1455 fw_domain
->wake_count
);
1457 spin_unlock_irq(&dev_priv
->uncore
.lock
);
1462 static int vlv_drpc_info(struct seq_file
*m
)
1464 struct drm_info_node
*node
= m
->private;
1465 struct drm_device
*dev
= node
->minor
->dev
;
1466 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1467 u32 rpmodectl1
, rcctl1
, pw_status
;
1469 intel_runtime_pm_get(dev_priv
);
1471 pw_status
= I915_READ(VLV_GTLC_PW_STATUS
);
1472 rpmodectl1
= I915_READ(GEN6_RP_CONTROL
);
1473 rcctl1
= I915_READ(GEN6_RC_CONTROL
);
1475 intel_runtime_pm_put(dev_priv
);
1477 seq_printf(m
, "Video Turbo Mode: %s\n",
1478 yesno(rpmodectl1
& GEN6_RP_MEDIA_TURBO
));
1479 seq_printf(m
, "Turbo enabled: %s\n",
1480 yesno(rpmodectl1
& GEN6_RP_ENABLE
));
1481 seq_printf(m
, "HW control enabled: %s\n",
1482 yesno(rpmodectl1
& GEN6_RP_ENABLE
));
1483 seq_printf(m
, "SW control enabled: %s\n",
1484 yesno((rpmodectl1
& GEN6_RP_MEDIA_MODE_MASK
) ==
1485 GEN6_RP_MEDIA_SW_MODE
));
1486 seq_printf(m
, "RC6 Enabled: %s\n",
1487 yesno(rcctl1
& (GEN7_RC_CTL_TO_MODE
|
1488 GEN6_RC_CTL_EI_MODE(1))));
1489 seq_printf(m
, "Render Power Well: %s\n",
1490 (pw_status
& VLV_GTLC_PW_RENDER_STATUS_MASK
) ? "Up" : "Down");
1491 seq_printf(m
, "Media Power Well: %s\n",
1492 (pw_status
& VLV_GTLC_PW_MEDIA_STATUS_MASK
) ? "Up" : "Down");
1494 seq_printf(m
, "Render RC6 residency since boot: %u\n",
1495 I915_READ(VLV_GT_RENDER_RC6
));
1496 seq_printf(m
, "Media RC6 residency since boot: %u\n",
1497 I915_READ(VLV_GT_MEDIA_RC6
));
1499 return i915_forcewake_domains(m
, NULL
);
1502 static int gen6_drpc_info(struct seq_file
*m
)
1504 struct drm_info_node
*node
= m
->private;
1505 struct drm_device
*dev
= node
->minor
->dev
;
1506 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1507 u32 rpmodectl1
, gt_core_status
, rcctl1
, rc6vids
= 0;
1508 unsigned forcewake_count
;
1511 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1514 intel_runtime_pm_get(dev_priv
);
1516 spin_lock_irq(&dev_priv
->uncore
.lock
);
1517 forcewake_count
= dev_priv
->uncore
.fw_domain
[FW_DOMAIN_ID_RENDER
].wake_count
;
1518 spin_unlock_irq(&dev_priv
->uncore
.lock
);
1520 if (forcewake_count
) {
1521 seq_puts(m
, "RC information inaccurate because somebody "
1522 "holds a forcewake reference \n");
1524 /* NB: we cannot use forcewake, else we read the wrong values */
1525 while (count
++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK
) & 1))
1527 seq_printf(m
, "RC information accurate: %s\n", yesno(count
< 51));
1530 gt_core_status
= I915_READ_FW(GEN6_GT_CORE_STATUS
);
1531 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS
, gt_core_status
, 4, true);
1533 rpmodectl1
= I915_READ(GEN6_RP_CONTROL
);
1534 rcctl1
= I915_READ(GEN6_RC_CONTROL
);
1535 mutex_unlock(&dev
->struct_mutex
);
1536 mutex_lock(&dev_priv
->rps
.hw_lock
);
1537 sandybridge_pcode_read(dev_priv
, GEN6_PCODE_READ_RC6VIDS
, &rc6vids
);
1538 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1540 intel_runtime_pm_put(dev_priv
);
1542 seq_printf(m
, "Video Turbo Mode: %s\n",
1543 yesno(rpmodectl1
& GEN6_RP_MEDIA_TURBO
));
1544 seq_printf(m
, "HW control enabled: %s\n",
1545 yesno(rpmodectl1
& GEN6_RP_ENABLE
));
1546 seq_printf(m
, "SW control enabled: %s\n",
1547 yesno((rpmodectl1
& GEN6_RP_MEDIA_MODE_MASK
) ==
1548 GEN6_RP_MEDIA_SW_MODE
));
1549 seq_printf(m
, "RC1e Enabled: %s\n",
1550 yesno(rcctl1
& GEN6_RC_CTL_RC1e_ENABLE
));
1551 seq_printf(m
, "RC6 Enabled: %s\n",
1552 yesno(rcctl1
& GEN6_RC_CTL_RC6_ENABLE
));
1553 seq_printf(m
, "Deep RC6 Enabled: %s\n",
1554 yesno(rcctl1
& GEN6_RC_CTL_RC6p_ENABLE
));
1555 seq_printf(m
, "Deepest RC6 Enabled: %s\n",
1556 yesno(rcctl1
& GEN6_RC_CTL_RC6pp_ENABLE
));
1557 seq_puts(m
, "Current RC state: ");
1558 switch (gt_core_status
& GEN6_RCn_MASK
) {
1560 if (gt_core_status
& GEN6_CORE_CPD_STATE_MASK
)
1561 seq_puts(m
, "Core Power Down\n");
1563 seq_puts(m
, "on\n");
1566 seq_puts(m
, "RC3\n");
1569 seq_puts(m
, "RC6\n");
1572 seq_puts(m
, "RC7\n");
1575 seq_puts(m
, "Unknown\n");
1579 seq_printf(m
, "Core Power Down: %s\n",
1580 yesno(gt_core_status
& GEN6_CORE_CPD_STATE_MASK
));
1582 /* Not exactly sure what this is */
1583 seq_printf(m
, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1584 I915_READ(GEN6_GT_GFX_RC6_LOCKED
));
1585 seq_printf(m
, "RC6 residency since boot: %u\n",
1586 I915_READ(GEN6_GT_GFX_RC6
));
1587 seq_printf(m
, "RC6+ residency since boot: %u\n",
1588 I915_READ(GEN6_GT_GFX_RC6p
));
1589 seq_printf(m
, "RC6++ residency since boot: %u\n",
1590 I915_READ(GEN6_GT_GFX_RC6pp
));
1592 seq_printf(m
, "RC6 voltage: %dmV\n",
1593 GEN6_DECODE_RC6_VID(((rc6vids
>> 0) & 0xff)));
1594 seq_printf(m
, "RC6+ voltage: %dmV\n",
1595 GEN6_DECODE_RC6_VID(((rc6vids
>> 8) & 0xff)));
1596 seq_printf(m
, "RC6++ voltage: %dmV\n",
1597 GEN6_DECODE_RC6_VID(((rc6vids
>> 16) & 0xff)));
1601 static int i915_drpc_info(struct seq_file
*m
, void *unused
)
1603 struct drm_info_node
*node
= m
->private;
1604 struct drm_device
*dev
= node
->minor
->dev
;
1606 if (IS_VALLEYVIEW(dev
))
1607 return vlv_drpc_info(m
);
1608 else if (INTEL_INFO(dev
)->gen
>= 6)
1609 return gen6_drpc_info(m
);
1611 return ironlake_drpc_info(m
);
1614 static int i915_frontbuffer_tracking(struct seq_file
*m
, void *unused
)
1616 struct drm_info_node
*node
= m
->private;
1617 struct drm_device
*dev
= node
->minor
->dev
;
1618 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1620 seq_printf(m
, "FB tracking busy bits: 0x%08x\n",
1621 dev_priv
->fb_tracking
.busy_bits
);
1623 seq_printf(m
, "FB tracking flip bits: 0x%08x\n",
1624 dev_priv
->fb_tracking
.flip_bits
);
1629 static int i915_fbc_status(struct seq_file
*m
, void *unused
)
1631 struct drm_info_node
*node
= m
->private;
1632 struct drm_device
*dev
= node
->minor
->dev
;
1633 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1635 if (!HAS_FBC(dev
)) {
1636 seq_puts(m
, "FBC unsupported on this chipset\n");
1640 intel_runtime_pm_get(dev_priv
);
1641 mutex_lock(&dev_priv
->fbc
.lock
);
1643 if (intel_fbc_enabled(dev_priv
))
1644 seq_puts(m
, "FBC enabled\n");
1646 seq_printf(m
, "FBC disabled: %s\n",
1647 intel_no_fbc_reason_str(dev_priv
->fbc
.no_fbc_reason
));
1649 if (INTEL_INFO(dev_priv
)->gen
>= 7)
1650 seq_printf(m
, "Compressing: %s\n",
1651 yesno(I915_READ(FBC_STATUS2
) &
1652 FBC_COMPRESSION_MASK
));
1654 mutex_unlock(&dev_priv
->fbc
.lock
);
1655 intel_runtime_pm_put(dev_priv
);
1660 static int i915_fbc_fc_get(void *data
, u64
*val
)
1662 struct drm_device
*dev
= data
;
1663 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1665 if (INTEL_INFO(dev
)->gen
< 7 || !HAS_FBC(dev
))
1668 *val
= dev_priv
->fbc
.false_color
;
1673 static int i915_fbc_fc_set(void *data
, u64 val
)
1675 struct drm_device
*dev
= data
;
1676 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1679 if (INTEL_INFO(dev
)->gen
< 7 || !HAS_FBC(dev
))
1682 mutex_lock(&dev_priv
->fbc
.lock
);
1684 reg
= I915_READ(ILK_DPFC_CONTROL
);
1685 dev_priv
->fbc
.false_color
= val
;
1687 I915_WRITE(ILK_DPFC_CONTROL
, val
?
1688 (reg
| FBC_CTL_FALSE_COLOR
) :
1689 (reg
& ~FBC_CTL_FALSE_COLOR
));
1691 mutex_unlock(&dev_priv
->fbc
.lock
);
1695 DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops
,
1696 i915_fbc_fc_get
, i915_fbc_fc_set
,
1699 static int i915_ips_status(struct seq_file
*m
, void *unused
)
1701 struct drm_info_node
*node
= m
->private;
1702 struct drm_device
*dev
= node
->minor
->dev
;
1703 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1705 if (!HAS_IPS(dev
)) {
1706 seq_puts(m
, "not supported\n");
1710 intel_runtime_pm_get(dev_priv
);
1712 seq_printf(m
, "Enabled by kernel parameter: %s\n",
1713 yesno(i915
.enable_ips
));
1715 if (INTEL_INFO(dev
)->gen
>= 8) {
1716 seq_puts(m
, "Currently: unknown\n");
1718 if (I915_READ(IPS_CTL
) & IPS_ENABLE
)
1719 seq_puts(m
, "Currently: enabled\n");
1721 seq_puts(m
, "Currently: disabled\n");
1724 intel_runtime_pm_put(dev_priv
);
1729 static int i915_sr_status(struct seq_file
*m
, void *unused
)
1731 struct drm_info_node
*node
= m
->private;
1732 struct drm_device
*dev
= node
->minor
->dev
;
1733 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1734 bool sr_enabled
= false;
1736 intel_runtime_pm_get(dev_priv
);
1738 if (HAS_PCH_SPLIT(dev
))
1739 sr_enabled
= I915_READ(WM1_LP_ILK
) & WM1_LP_SR_EN
;
1740 else if (IS_CRESTLINE(dev
) || IS_G4X(dev
) ||
1741 IS_I945G(dev
) || IS_I945GM(dev
))
1742 sr_enabled
= I915_READ(FW_BLC_SELF
) & FW_BLC_SELF_EN
;
1743 else if (IS_I915GM(dev
))
1744 sr_enabled
= I915_READ(INSTPM
) & INSTPM_SELF_EN
;
1745 else if (IS_PINEVIEW(dev
))
1746 sr_enabled
= I915_READ(DSPFW3
) & PINEVIEW_SELF_REFRESH_EN
;
1747 else if (IS_VALLEYVIEW(dev
))
1748 sr_enabled
= I915_READ(FW_BLC_SELF_VLV
) & FW_CSPWRDWNEN
;
1750 intel_runtime_pm_put(dev_priv
);
1752 seq_printf(m
, "self-refresh: %s\n",
1753 sr_enabled
? "enabled" : "disabled");
1758 static int i915_emon_status(struct seq_file
*m
, void *unused
)
1760 struct drm_info_node
*node
= m
->private;
1761 struct drm_device
*dev
= node
->minor
->dev
;
1762 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1763 unsigned long temp
, chipset
, gfx
;
1769 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1773 temp
= i915_mch_val(dev_priv
);
1774 chipset
= i915_chipset_val(dev_priv
);
1775 gfx
= i915_gfx_val(dev_priv
);
1776 mutex_unlock(&dev
->struct_mutex
);
1778 seq_printf(m
, "GMCH temp: %ld\n", temp
);
1779 seq_printf(m
, "Chipset power: %ld\n", chipset
);
1780 seq_printf(m
, "GFX power: %ld\n", gfx
);
1781 seq_printf(m
, "Total power: %ld\n", chipset
+ gfx
);
1786 static int i915_ring_freq_table(struct seq_file
*m
, void *unused
)
1788 struct drm_info_node
*node
= m
->private;
1789 struct drm_device
*dev
= node
->minor
->dev
;
1790 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1792 int gpu_freq
, ia_freq
;
1793 unsigned int max_gpu_freq
, min_gpu_freq
;
1795 if (!HAS_CORE_RING_FREQ(dev
)) {
1796 seq_puts(m
, "unsupported on this chipset\n");
1800 intel_runtime_pm_get(dev_priv
);
1802 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
1804 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
1808 if (IS_SKYLAKE(dev
) || IS_KABYLAKE(dev
)) {
1809 /* Convert GT frequency to 50 HZ units */
1811 dev_priv
->rps
.min_freq_softlimit
/ GEN9_FREQ_SCALER
;
1813 dev_priv
->rps
.max_freq_softlimit
/ GEN9_FREQ_SCALER
;
1815 min_gpu_freq
= dev_priv
->rps
.min_freq_softlimit
;
1816 max_gpu_freq
= dev_priv
->rps
.max_freq_softlimit
;
1819 seq_puts(m
, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
1821 for (gpu_freq
= min_gpu_freq
; gpu_freq
<= max_gpu_freq
; gpu_freq
++) {
1823 sandybridge_pcode_read(dev_priv
,
1824 GEN6_PCODE_READ_MIN_FREQ_TABLE
,
1826 seq_printf(m
, "%d\t\t%d\t\t\t\t%d\n",
1827 intel_gpu_freq(dev_priv
, (gpu_freq
*
1828 (IS_SKYLAKE(dev
) || IS_KABYLAKE(dev
) ?
1829 GEN9_FREQ_SCALER
: 1))),
1830 ((ia_freq
>> 0) & 0xff) * 100,
1831 ((ia_freq
>> 8) & 0xff) * 100);
1834 mutex_unlock(&dev_priv
->rps
.hw_lock
);
1837 intel_runtime_pm_put(dev_priv
);
1841 static int i915_opregion(struct seq_file
*m
, void *unused
)
1843 struct drm_info_node
*node
= m
->private;
1844 struct drm_device
*dev
= node
->minor
->dev
;
1845 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1846 struct intel_opregion
*opregion
= &dev_priv
->opregion
;
1847 void *data
= kmalloc(OPREGION_SIZE
, GFP_KERNEL
);
1853 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1857 if (opregion
->header
) {
1858 memcpy(data
, opregion
->header
, OPREGION_SIZE
);
1859 seq_write(m
, data
, OPREGION_SIZE
);
1862 mutex_unlock(&dev
->struct_mutex
);
1869 static int i915_gem_framebuffer_info(struct seq_file
*m
, void *data
)
1871 struct drm_info_node
*node
= m
->private;
1872 struct drm_device
*dev
= node
->minor
->dev
;
1873 struct intel_fbdev
*ifbdev
= NULL
;
1874 struct intel_framebuffer
*fb
;
1875 struct drm_framebuffer
*drm_fb
;
1877 #ifdef CONFIG_DRM_FBDEV_EMULATION
1878 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1880 ifbdev
= dev_priv
->fbdev
;
1881 fb
= to_intel_framebuffer(ifbdev
->helper
.fb
);
1883 seq_printf(m
, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
1887 fb
->base
.bits_per_pixel
,
1888 fb
->base
.modifier
[0],
1889 atomic_read(&fb
->base
.refcount
.refcount
));
1890 describe_obj(m
, fb
->obj
);
1894 mutex_lock(&dev
->mode_config
.fb_lock
);
1895 drm_for_each_fb(drm_fb
, dev
) {
1896 fb
= to_intel_framebuffer(drm_fb
);
1897 if (ifbdev
&& &fb
->base
== ifbdev
->helper
.fb
)
1900 seq_printf(m
, "user size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
1904 fb
->base
.bits_per_pixel
,
1905 fb
->base
.modifier
[0],
1906 atomic_read(&fb
->base
.refcount
.refcount
));
1907 describe_obj(m
, fb
->obj
);
1910 mutex_unlock(&dev
->mode_config
.fb_lock
);
1915 static void describe_ctx_ringbuf(struct seq_file
*m
,
1916 struct intel_ringbuffer
*ringbuf
)
1918 seq_printf(m
, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)",
1919 ringbuf
->space
, ringbuf
->head
, ringbuf
->tail
,
1920 ringbuf
->last_retired_head
);
1923 static int i915_context_status(struct seq_file
*m
, void *unused
)
1925 struct drm_info_node
*node
= m
->private;
1926 struct drm_device
*dev
= node
->minor
->dev
;
1927 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1928 struct intel_engine_cs
*ring
;
1929 struct intel_context
*ctx
;
1932 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
1936 list_for_each_entry(ctx
, &dev_priv
->context_list
, link
) {
1937 if (!i915
.enable_execlists
&&
1938 ctx
->legacy_hw_ctx
.rcs_state
== NULL
)
1941 seq_puts(m
, "HW context ");
1942 describe_ctx(m
, ctx
);
1943 for_each_ring(ring
, dev_priv
, i
) {
1944 if (ring
->default_context
== ctx
)
1945 seq_printf(m
, "(default context %s) ",
1949 if (i915
.enable_execlists
) {
1951 for_each_ring(ring
, dev_priv
, i
) {
1952 struct drm_i915_gem_object
*ctx_obj
=
1953 ctx
->engine
[i
].state
;
1954 struct intel_ringbuffer
*ringbuf
=
1955 ctx
->engine
[i
].ringbuf
;
1957 seq_printf(m
, "%s: ", ring
->name
);
1959 describe_obj(m
, ctx_obj
);
1961 describe_ctx_ringbuf(m
, ringbuf
);
1965 describe_obj(m
, ctx
->legacy_hw_ctx
.rcs_state
);
1971 mutex_unlock(&dev
->struct_mutex
);
1976 static void i915_dump_lrc_obj(struct seq_file
*m
,
1977 struct intel_engine_cs
*ring
,
1978 struct drm_i915_gem_object
*ctx_obj
)
1981 uint32_t *reg_state
;
1983 unsigned long ggtt_offset
= 0;
1985 if (ctx_obj
== NULL
) {
1986 seq_printf(m
, "Context on %s with no gem object\n",
1991 seq_printf(m
, "CONTEXT: %s %u\n", ring
->name
,
1992 intel_execlists_ctx_id(ctx_obj
));
1994 if (!i915_gem_obj_ggtt_bound(ctx_obj
))
1995 seq_puts(m
, "\tNot bound in GGTT\n");
1997 ggtt_offset
= i915_gem_obj_ggtt_offset(ctx_obj
);
1999 if (i915_gem_object_get_pages(ctx_obj
)) {
2000 seq_puts(m
, "\tFailed to get pages for context object\n");
2004 page
= i915_gem_object_get_page(ctx_obj
, LRC_STATE_PN
);
2005 if (!WARN_ON(page
== NULL
)) {
2006 reg_state
= kmap_atomic(page
);
2008 for (j
= 0; j
< 0x600 / sizeof(u32
) / 4; j
+= 4) {
2009 seq_printf(m
, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
2010 ggtt_offset
+ 4096 + (j
* 4),
2011 reg_state
[j
], reg_state
[j
+ 1],
2012 reg_state
[j
+ 2], reg_state
[j
+ 3]);
2014 kunmap_atomic(reg_state
);
2020 static int i915_dump_lrc(struct seq_file
*m
, void *unused
)
2022 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
2023 struct drm_device
*dev
= node
->minor
->dev
;
2024 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2025 struct intel_engine_cs
*ring
;
2026 struct intel_context
*ctx
;
2029 if (!i915
.enable_execlists
) {
2030 seq_printf(m
, "Logical Ring Contexts are disabled\n");
2034 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
2038 list_for_each_entry(ctx
, &dev_priv
->context_list
, link
) {
2039 for_each_ring(ring
, dev_priv
, i
) {
2040 if (ring
->default_context
!= ctx
)
2041 i915_dump_lrc_obj(m
, ring
,
2042 ctx
->engine
[i
].state
);
2046 mutex_unlock(&dev
->struct_mutex
);
2051 static int i915_execlists(struct seq_file
*m
, void *data
)
2053 struct drm_info_node
*node
= (struct drm_info_node
*)m
->private;
2054 struct drm_device
*dev
= node
->minor
->dev
;
2055 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2056 struct intel_engine_cs
*ring
;
2062 struct list_head
*cursor
;
2066 if (!i915
.enable_execlists
) {
2067 seq_puts(m
, "Logical Ring Contexts are disabled\n");
2071 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
2075 intel_runtime_pm_get(dev_priv
);
2077 for_each_ring(ring
, dev_priv
, ring_id
) {
2078 struct drm_i915_gem_request
*head_req
= NULL
;
2080 unsigned long flags
;
2082 seq_printf(m
, "%s\n", ring
->name
);
2084 status
= I915_READ(RING_EXECLIST_STATUS_LO(ring
));
2085 ctx_id
= I915_READ(RING_EXECLIST_STATUS_HI(ring
));
2086 seq_printf(m
, "\tExeclist status: 0x%08X, context: %u\n",
2089 status_pointer
= I915_READ(RING_CONTEXT_STATUS_PTR(ring
));
2090 seq_printf(m
, "\tStatus pointer: 0x%08X\n", status_pointer
);
2092 read_pointer
= ring
->next_context_status_buffer
;
2093 write_pointer
= status_pointer
& 0x07;
2094 if (read_pointer
> write_pointer
)
2096 seq_printf(m
, "\tRead pointer: 0x%08X, write pointer 0x%08X\n",
2097 read_pointer
, write_pointer
);
2099 for (i
= 0; i
< 6; i
++) {
2100 status
= I915_READ(RING_CONTEXT_STATUS_BUF_LO(ring
, i
));
2101 ctx_id
= I915_READ(RING_CONTEXT_STATUS_BUF_HI(ring
, i
));
2103 seq_printf(m
, "\tStatus buffer %d: 0x%08X, context: %u\n",
2107 spin_lock_irqsave(&ring
->execlist_lock
, flags
);
2108 list_for_each(cursor
, &ring
->execlist_queue
)
2110 head_req
= list_first_entry_or_null(&ring
->execlist_queue
,
2111 struct drm_i915_gem_request
, execlist_link
);
2112 spin_unlock_irqrestore(&ring
->execlist_lock
, flags
);
2114 seq_printf(m
, "\t%d requests in queue\n", count
);
2116 struct drm_i915_gem_object
*ctx_obj
;
2118 ctx_obj
= head_req
->ctx
->engine
[ring_id
].state
;
2119 seq_printf(m
, "\tHead request id: %u\n",
2120 intel_execlists_ctx_id(ctx_obj
));
2121 seq_printf(m
, "\tHead request tail: %u\n",
2128 intel_runtime_pm_put(dev_priv
);
2129 mutex_unlock(&dev
->struct_mutex
);
2134 static const char *swizzle_string(unsigned swizzle
)
2137 case I915_BIT_6_SWIZZLE_NONE
:
2139 case I915_BIT_6_SWIZZLE_9
:
2141 case I915_BIT_6_SWIZZLE_9_10
:
2142 return "bit9/bit10";
2143 case I915_BIT_6_SWIZZLE_9_11
:
2144 return "bit9/bit11";
2145 case I915_BIT_6_SWIZZLE_9_10_11
:
2146 return "bit9/bit10/bit11";
2147 case I915_BIT_6_SWIZZLE_9_17
:
2148 return "bit9/bit17";
2149 case I915_BIT_6_SWIZZLE_9_10_17
:
2150 return "bit9/bit10/bit17";
2151 case I915_BIT_6_SWIZZLE_UNKNOWN
:
2158 static int i915_swizzle_info(struct seq_file
*m
, void *data
)
2160 struct drm_info_node
*node
= m
->private;
2161 struct drm_device
*dev
= node
->minor
->dev
;
2162 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2165 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
2168 intel_runtime_pm_get(dev_priv
);
2170 seq_printf(m
, "bit6 swizzle for X-tiling = %s\n",
2171 swizzle_string(dev_priv
->mm
.bit_6_swizzle_x
));
2172 seq_printf(m
, "bit6 swizzle for Y-tiling = %s\n",
2173 swizzle_string(dev_priv
->mm
.bit_6_swizzle_y
));
2175 if (IS_GEN3(dev
) || IS_GEN4(dev
)) {
2176 seq_printf(m
, "DDC = 0x%08x\n",
2178 seq_printf(m
, "DDC2 = 0x%08x\n",
2180 seq_printf(m
, "C0DRB3 = 0x%04x\n",
2181 I915_READ16(C0DRB3
));
2182 seq_printf(m
, "C1DRB3 = 0x%04x\n",
2183 I915_READ16(C1DRB3
));
2184 } else if (INTEL_INFO(dev
)->gen
>= 6) {
2185 seq_printf(m
, "MAD_DIMM_C0 = 0x%08x\n",
2186 I915_READ(MAD_DIMM_C0
));
2187 seq_printf(m
, "MAD_DIMM_C1 = 0x%08x\n",
2188 I915_READ(MAD_DIMM_C1
));
2189 seq_printf(m
, "MAD_DIMM_C2 = 0x%08x\n",
2190 I915_READ(MAD_DIMM_C2
));
2191 seq_printf(m
, "TILECTL = 0x%08x\n",
2192 I915_READ(TILECTL
));
2193 if (INTEL_INFO(dev
)->gen
>= 8)
2194 seq_printf(m
, "GAMTARBMODE = 0x%08x\n",
2195 I915_READ(GAMTARBMODE
));
2197 seq_printf(m
, "ARB_MODE = 0x%08x\n",
2198 I915_READ(ARB_MODE
));
2199 seq_printf(m
, "DISP_ARB_CTL = 0x%08x\n",
2200 I915_READ(DISP_ARB_CTL
));
2203 if (dev_priv
->quirks
& QUIRK_PIN_SWIZZLED_PAGES
)
2204 seq_puts(m
, "L-shaped memory detected\n");
2206 intel_runtime_pm_put(dev_priv
);
2207 mutex_unlock(&dev
->struct_mutex
);
2212 static int per_file_ctx(int id
, void *ptr
, void *data
)
2214 struct intel_context
*ctx
= ptr
;
2215 struct seq_file
*m
= data
;
2216 struct i915_hw_ppgtt
*ppgtt
= ctx
->ppgtt
;
2219 seq_printf(m
, " no ppgtt for context %d\n",
2224 if (i915_gem_context_is_default(ctx
))
2225 seq_puts(m
, " default context:\n");
2227 seq_printf(m
, " context %d:\n", ctx
->user_handle
);
2228 ppgtt
->debug_dump(ppgtt
, m
);
2233 static void gen8_ppgtt_info(struct seq_file
*m
, struct drm_device
*dev
)
2235 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2236 struct intel_engine_cs
*ring
;
2237 struct i915_hw_ppgtt
*ppgtt
= dev_priv
->mm
.aliasing_ppgtt
;
2243 for_each_ring(ring
, dev_priv
, unused
) {
2244 seq_printf(m
, "%s\n", ring
->name
);
2245 for (i
= 0; i
< 4; i
++) {
2246 u64 pdp
= I915_READ(GEN8_RING_PDP_UDW(ring
, i
));
2248 pdp
|= I915_READ(GEN8_RING_PDP_LDW(ring
, i
));
2249 seq_printf(m
, "\tPDP%d 0x%016llx\n", i
, pdp
);
2254 static void gen6_ppgtt_info(struct seq_file
*m
, struct drm_device
*dev
)
2256 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2257 struct intel_engine_cs
*ring
;
2260 if (INTEL_INFO(dev
)->gen
== 6)
2261 seq_printf(m
, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE
));
2263 for_each_ring(ring
, dev_priv
, i
) {
2264 seq_printf(m
, "%s\n", ring
->name
);
2265 if (INTEL_INFO(dev
)->gen
== 7)
2266 seq_printf(m
, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring
)));
2267 seq_printf(m
, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring
)));
2268 seq_printf(m
, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring
)));
2269 seq_printf(m
, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring
)));
2271 if (dev_priv
->mm
.aliasing_ppgtt
) {
2272 struct i915_hw_ppgtt
*ppgtt
= dev_priv
->mm
.aliasing_ppgtt
;
2274 seq_puts(m
, "aliasing PPGTT:\n");
2275 seq_printf(m
, "pd gtt offset: 0x%08x\n", ppgtt
->pd
.base
.ggtt_offset
);
2277 ppgtt
->debug_dump(ppgtt
, m
);
2280 seq_printf(m
, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK
));
2283 static int i915_ppgtt_info(struct seq_file
*m
, void *data
)
2285 struct drm_info_node
*node
= m
->private;
2286 struct drm_device
*dev
= node
->minor
->dev
;
2287 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2288 struct drm_file
*file
;
2290 int ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
2293 intel_runtime_pm_get(dev_priv
);
2295 if (INTEL_INFO(dev
)->gen
>= 8)
2296 gen8_ppgtt_info(m
, dev
);
2297 else if (INTEL_INFO(dev
)->gen
>= 6)
2298 gen6_ppgtt_info(m
, dev
);
2300 list_for_each_entry_reverse(file
, &dev
->filelist
, lhead
) {
2301 struct drm_i915_file_private
*file_priv
= file
->driver_priv
;
2302 struct task_struct
*task
;
2304 task
= get_pid_task(file
->pid
, PIDTYPE_PID
);
2309 seq_printf(m
, "\nproc: %s\n", task
->comm
);
2310 put_task_struct(task
);
2311 idr_for_each(&file_priv
->context_idr
, per_file_ctx
,
2312 (void *)(unsigned long)m
);
2316 intel_runtime_pm_put(dev_priv
);
2317 mutex_unlock(&dev
->struct_mutex
);
2322 static int count_irq_waiters(struct drm_i915_private
*i915
)
2324 struct intel_engine_cs
*ring
;
2328 for_each_ring(ring
, i915
, i
)
2329 count
+= ring
->irq_refcount
;
2334 static int i915_rps_boost_info(struct seq_file
*m
, void *data
)
2336 struct drm_info_node
*node
= m
->private;
2337 struct drm_device
*dev
= node
->minor
->dev
;
2338 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2339 struct drm_file
*file
;
2341 seq_printf(m
, "RPS enabled? %d\n", dev_priv
->rps
.enabled
);
2342 seq_printf(m
, "GPU busy? %d\n", dev_priv
->mm
.busy
);
2343 seq_printf(m
, "CPU waiting? %d\n", count_irq_waiters(dev_priv
));
2344 seq_printf(m
, "Frequency requested %d; min hard:%d, soft:%d; max soft:%d, hard:%d\n",
2345 intel_gpu_freq(dev_priv
, dev_priv
->rps
.cur_freq
),
2346 intel_gpu_freq(dev_priv
, dev_priv
->rps
.min_freq
),
2347 intel_gpu_freq(dev_priv
, dev_priv
->rps
.min_freq_softlimit
),
2348 intel_gpu_freq(dev_priv
, dev_priv
->rps
.max_freq_softlimit
),
2349 intel_gpu_freq(dev_priv
, dev_priv
->rps
.max_freq
));
2350 spin_lock(&dev_priv
->rps
.client_lock
);
2351 list_for_each_entry_reverse(file
, &dev
->filelist
, lhead
) {
2352 struct drm_i915_file_private
*file_priv
= file
->driver_priv
;
2353 struct task_struct
*task
;
2356 task
= pid_task(file
->pid
, PIDTYPE_PID
);
2357 seq_printf(m
, "%s [%d]: %d boosts%s\n",
2358 task
? task
->comm
: "<unknown>",
2359 task
? task
->pid
: -1,
2360 file_priv
->rps
.boosts
,
2361 list_empty(&file_priv
->rps
.link
) ? "" : ", active");
2364 seq_printf(m
, "Semaphore boosts: %d%s\n",
2365 dev_priv
->rps
.semaphores
.boosts
,
2366 list_empty(&dev_priv
->rps
.semaphores
.link
) ? "" : ", active");
2367 seq_printf(m
, "MMIO flip boosts: %d%s\n",
2368 dev_priv
->rps
.mmioflips
.boosts
,
2369 list_empty(&dev_priv
->rps
.mmioflips
.link
) ? "" : ", active");
2370 seq_printf(m
, "Kernel boosts: %d\n", dev_priv
->rps
.boosts
);
2371 spin_unlock(&dev_priv
->rps
.client_lock
);
2376 static int i915_llc(struct seq_file
*m
, void *data
)
2378 struct drm_info_node
*node
= m
->private;
2379 struct drm_device
*dev
= node
->minor
->dev
;
2380 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2382 /* Size calculation for LLC is a bit of a pain. Ignore for now. */
2383 seq_printf(m
, "LLC: %s\n", yesno(HAS_LLC(dev
)));
2384 seq_printf(m
, "eLLC: %zuMB\n", dev_priv
->ellc_size
);
2389 static int i915_guc_load_status_info(struct seq_file
*m
, void *data
)
2391 struct drm_info_node
*node
= m
->private;
2392 struct drm_i915_private
*dev_priv
= node
->minor
->dev
->dev_private
;
2393 struct intel_guc_fw
*guc_fw
= &dev_priv
->guc
.guc_fw
;
2396 if (!HAS_GUC_UCODE(dev_priv
->dev
))
2399 seq_printf(m
, "GuC firmware status:\n");
2400 seq_printf(m
, "\tpath: %s\n",
2401 guc_fw
->guc_fw_path
);
2402 seq_printf(m
, "\tfetch: %s\n",
2403 intel_guc_fw_status_repr(guc_fw
->guc_fw_fetch_status
));
2404 seq_printf(m
, "\tload: %s\n",
2405 intel_guc_fw_status_repr(guc_fw
->guc_fw_load_status
));
2406 seq_printf(m
, "\tversion wanted: %d.%d\n",
2407 guc_fw
->guc_fw_major_wanted
, guc_fw
->guc_fw_minor_wanted
);
2408 seq_printf(m
, "\tversion found: %d.%d\n",
2409 guc_fw
->guc_fw_major_found
, guc_fw
->guc_fw_minor_found
);
2410 seq_printf(m
, "\theader: offset is %d; size = %d\n",
2411 guc_fw
->header_offset
, guc_fw
->header_size
);
2412 seq_printf(m
, "\tuCode: offset is %d; size = %d\n",
2413 guc_fw
->ucode_offset
, guc_fw
->ucode_size
);
2414 seq_printf(m
, "\tRSA: offset is %d; size = %d\n",
2415 guc_fw
->rsa_offset
, guc_fw
->rsa_size
);
2417 tmp
= I915_READ(GUC_STATUS
);
2419 seq_printf(m
, "\nGuC status 0x%08x:\n", tmp
);
2420 seq_printf(m
, "\tBootrom status = 0x%x\n",
2421 (tmp
& GS_BOOTROM_MASK
) >> GS_BOOTROM_SHIFT
);
2422 seq_printf(m
, "\tuKernel status = 0x%x\n",
2423 (tmp
& GS_UKERNEL_MASK
) >> GS_UKERNEL_SHIFT
);
2424 seq_printf(m
, "\tMIA Core status = 0x%x\n",
2425 (tmp
& GS_MIA_MASK
) >> GS_MIA_SHIFT
);
2426 seq_puts(m
, "\nScratch registers:\n");
2427 for (i
= 0; i
< 16; i
++)
2428 seq_printf(m
, "\t%2d: \t0x%x\n", i
, I915_READ(SOFT_SCRATCH(i
)));
2433 static void i915_guc_client_info(struct seq_file
*m
,
2434 struct drm_i915_private
*dev_priv
,
2435 struct i915_guc_client
*client
)
2437 struct intel_engine_cs
*ring
;
2441 seq_printf(m
, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n",
2442 client
->priority
, client
->ctx_index
, client
->proc_desc_offset
);
2443 seq_printf(m
, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n",
2444 client
->doorbell_id
, client
->doorbell_offset
, client
->cookie
);
2445 seq_printf(m
, "\tWQ size %d, offset: 0x%x, tail %d\n",
2446 client
->wq_size
, client
->wq_offset
, client
->wq_tail
);
2448 seq_printf(m
, "\tFailed to queue: %u\n", client
->q_fail
);
2449 seq_printf(m
, "\tFailed doorbell: %u\n", client
->b_fail
);
2450 seq_printf(m
, "\tLast submission result: %d\n", client
->retcode
);
2452 for_each_ring(ring
, dev_priv
, i
) {
2453 seq_printf(m
, "\tSubmissions: %llu %s\n",
2454 client
->submissions
[i
],
2456 tot
+= client
->submissions
[i
];
2458 seq_printf(m
, "\tTotal: %llu\n", tot
);
2461 static int i915_guc_info(struct seq_file
*m
, void *data
)
2463 struct drm_info_node
*node
= m
->private;
2464 struct drm_device
*dev
= node
->minor
->dev
;
2465 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2466 struct intel_guc guc
;
2467 struct i915_guc_client client
= {};
2468 struct intel_engine_cs
*ring
;
2469 enum intel_ring_id i
;
2472 if (!HAS_GUC_SCHED(dev_priv
->dev
))
2475 /* Take a local copy of the GuC data, so we can dump it at leisure */
2476 spin_lock(&dev_priv
->guc
.host2guc_lock
);
2477 guc
= dev_priv
->guc
;
2478 if (guc
.execbuf_client
) {
2479 spin_lock(&guc
.execbuf_client
->wq_lock
);
2480 client
= *guc
.execbuf_client
;
2481 spin_unlock(&guc
.execbuf_client
->wq_lock
);
2483 spin_unlock(&dev_priv
->guc
.host2guc_lock
);
2485 seq_printf(m
, "GuC total action count: %llu\n", guc
.action_count
);
2486 seq_printf(m
, "GuC action failure count: %u\n", guc
.action_fail
);
2487 seq_printf(m
, "GuC last action command: 0x%x\n", guc
.action_cmd
);
2488 seq_printf(m
, "GuC last action status: 0x%x\n", guc
.action_status
);
2489 seq_printf(m
, "GuC last action error code: %d\n", guc
.action_err
);
2491 seq_printf(m
, "\nGuC submissions:\n");
2492 for_each_ring(ring
, dev_priv
, i
) {
2493 seq_printf(m
, "\t%-24s: %10llu, last seqno 0x%08x %9d\n",
2494 ring
->name
, guc
.submissions
[i
],
2495 guc
.last_seqno
[i
], guc
.last_seqno
[i
]);
2496 total
+= guc
.submissions
[i
];
2498 seq_printf(m
, "\t%s: %llu\n", "Total", total
);
2500 seq_printf(m
, "\nGuC execbuf client @ %p:\n", guc
.execbuf_client
);
2501 i915_guc_client_info(m
, dev_priv
, &client
);
2503 /* Add more as required ... */
2508 static int i915_guc_log_dump(struct seq_file
*m
, void *data
)
2510 struct drm_info_node
*node
= m
->private;
2511 struct drm_device
*dev
= node
->minor
->dev
;
2512 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2513 struct drm_i915_gem_object
*log_obj
= dev_priv
->guc
.log_obj
;
2520 for (pg
= 0; pg
< log_obj
->base
.size
/ PAGE_SIZE
; pg
++) {
2521 log
= kmap_atomic(i915_gem_object_get_page(log_obj
, pg
));
2523 for (i
= 0; i
< PAGE_SIZE
/ sizeof(u32
); i
+= 4)
2524 seq_printf(m
, "0x%08x 0x%08x 0x%08x 0x%08x\n",
2525 *(log
+ i
), *(log
+ i
+ 1),
2526 *(log
+ i
+ 2), *(log
+ i
+ 3));
2536 static int i915_edp_psr_status(struct seq_file
*m
, void *data
)
2538 struct drm_info_node
*node
= m
->private;
2539 struct drm_device
*dev
= node
->minor
->dev
;
2540 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2544 bool enabled
= false;
2546 if (!HAS_PSR(dev
)) {
2547 seq_puts(m
, "PSR not supported\n");
2551 intel_runtime_pm_get(dev_priv
);
2553 mutex_lock(&dev_priv
->psr
.lock
);
2554 seq_printf(m
, "Sink_Support: %s\n", yesno(dev_priv
->psr
.sink_support
));
2555 seq_printf(m
, "Source_OK: %s\n", yesno(dev_priv
->psr
.source_ok
));
2556 seq_printf(m
, "Enabled: %s\n", yesno((bool)dev_priv
->psr
.enabled
));
2557 seq_printf(m
, "Active: %s\n", yesno(dev_priv
->psr
.active
));
2558 seq_printf(m
, "Busy frontbuffer bits: 0x%03x\n",
2559 dev_priv
->psr
.busy_frontbuffer_bits
);
2560 seq_printf(m
, "Re-enable work scheduled: %s\n",
2561 yesno(work_busy(&dev_priv
->psr
.work
.work
)));
2564 enabled
= I915_READ(EDP_PSR_CTL(dev
)) & EDP_PSR_ENABLE
;
2566 for_each_pipe(dev_priv
, pipe
) {
2567 stat
[pipe
] = I915_READ(VLV_PSRSTAT(pipe
)) &
2568 VLV_EDP_PSR_CURR_STATE_MASK
;
2569 if ((stat
[pipe
] == VLV_EDP_PSR_ACTIVE_NORFB_UP
) ||
2570 (stat
[pipe
] == VLV_EDP_PSR_ACTIVE_SF_UPDATE
))
2574 seq_printf(m
, "HW Enabled & Active bit: %s", yesno(enabled
));
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
));
2584 /* CHV PSR has no kind of performance counter */
2586 psrperf
= I915_READ(EDP_PSR_PERF_CNT(dev
)) &
2587 EDP_PSR_PERF_CNT_MASK
;
2589 seq_printf(m
, "Performance_Counter: %u\n", psrperf
);
2591 mutex_unlock(&dev_priv
->psr
.lock
);
2593 intel_runtime_pm_put(dev_priv
);
2597 static int i915_sink_crc(struct seq_file
*m
, void *data
)
2599 struct drm_info_node
*node
= m
->private;
2600 struct drm_device
*dev
= node
->minor
->dev
;
2601 struct intel_encoder
*encoder
;
2602 struct intel_connector
*connector
;
2603 struct intel_dp
*intel_dp
= NULL
;
2607 drm_modeset_lock_all(dev
);
2608 for_each_intel_connector(dev
, connector
) {
2610 if (connector
->base
.dpms
!= DRM_MODE_DPMS_ON
)
2613 if (!connector
->base
.encoder
)
2616 encoder
= to_intel_encoder(connector
->base
.encoder
);
2617 if (encoder
->type
!= INTEL_OUTPUT_EDP
)
2620 intel_dp
= enc_to_intel_dp(&encoder
->base
);
2622 ret
= intel_dp_sink_crc(intel_dp
, crc
);
2626 seq_printf(m
, "%02x%02x%02x%02x%02x%02x\n",
2627 crc
[0], crc
[1], crc
[2],
2628 crc
[3], crc
[4], crc
[5]);
2633 drm_modeset_unlock_all(dev
);
2637 static int i915_energy_uJ(struct seq_file
*m
, void *data
)
2639 struct drm_info_node
*node
= m
->private;
2640 struct drm_device
*dev
= node
->minor
->dev
;
2641 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2645 if (INTEL_INFO(dev
)->gen
< 6)
2648 intel_runtime_pm_get(dev_priv
);
2650 rdmsrl(MSR_RAPL_POWER_UNIT
, power
);
2651 power
= (power
& 0x1f00) >> 8;
2652 units
= 1000000 / (1 << power
); /* convert to uJ */
2653 power
= I915_READ(MCH_SECP_NRG_STTS
);
2656 intel_runtime_pm_put(dev_priv
);
2658 seq_printf(m
, "%llu", (long long unsigned)power
);
2663 static int i915_runtime_pm_status(struct seq_file
*m
, void *unused
)
2665 struct drm_info_node
*node
= m
->private;
2666 struct drm_device
*dev
= node
->minor
->dev
;
2667 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2669 if (!HAS_RUNTIME_PM(dev
)) {
2670 seq_puts(m
, "not supported\n");
2674 seq_printf(m
, "GPU idle: %s\n", yesno(!dev_priv
->mm
.busy
));
2675 seq_printf(m
, "IRQs disabled: %s\n",
2676 yesno(!intel_irqs_enabled(dev_priv
)));
2678 seq_printf(m
, "Usage count: %d\n",
2679 atomic_read(&dev
->dev
->power
.usage_count
));
2681 seq_printf(m
, "Device Power Management (CONFIG_PM) disabled\n");
2687 static const char *power_domain_str(enum intel_display_power_domain domain
)
2690 case POWER_DOMAIN_PIPE_A
:
2692 case POWER_DOMAIN_PIPE_B
:
2694 case POWER_DOMAIN_PIPE_C
:
2696 case POWER_DOMAIN_PIPE_A_PANEL_FITTER
:
2697 return "PIPE_A_PANEL_FITTER";
2698 case POWER_DOMAIN_PIPE_B_PANEL_FITTER
:
2699 return "PIPE_B_PANEL_FITTER";
2700 case POWER_DOMAIN_PIPE_C_PANEL_FITTER
:
2701 return "PIPE_C_PANEL_FITTER";
2702 case POWER_DOMAIN_TRANSCODER_A
:
2703 return "TRANSCODER_A";
2704 case POWER_DOMAIN_TRANSCODER_B
:
2705 return "TRANSCODER_B";
2706 case POWER_DOMAIN_TRANSCODER_C
:
2707 return "TRANSCODER_C";
2708 case POWER_DOMAIN_TRANSCODER_EDP
:
2709 return "TRANSCODER_EDP";
2710 case POWER_DOMAIN_PORT_DDI_A_2_LANES
:
2711 return "PORT_DDI_A_2_LANES";
2712 case POWER_DOMAIN_PORT_DDI_A_4_LANES
:
2713 return "PORT_DDI_A_4_LANES";
2714 case POWER_DOMAIN_PORT_DDI_B_2_LANES
:
2715 return "PORT_DDI_B_2_LANES";
2716 case POWER_DOMAIN_PORT_DDI_B_4_LANES
:
2717 return "PORT_DDI_B_4_LANES";
2718 case POWER_DOMAIN_PORT_DDI_C_2_LANES
:
2719 return "PORT_DDI_C_2_LANES";
2720 case POWER_DOMAIN_PORT_DDI_C_4_LANES
:
2721 return "PORT_DDI_C_4_LANES";
2722 case POWER_DOMAIN_PORT_DDI_D_2_LANES
:
2723 return "PORT_DDI_D_2_LANES";
2724 case POWER_DOMAIN_PORT_DDI_D_4_LANES
:
2725 return "PORT_DDI_D_4_LANES";
2726 case POWER_DOMAIN_PORT_DDI_E_2_LANES
:
2727 return "PORT_DDI_E_2_LANES";
2728 case POWER_DOMAIN_PORT_DSI
:
2730 case POWER_DOMAIN_PORT_CRT
:
2732 case POWER_DOMAIN_PORT_OTHER
:
2733 return "PORT_OTHER";
2734 case POWER_DOMAIN_VGA
:
2736 case POWER_DOMAIN_AUDIO
:
2738 case POWER_DOMAIN_PLLS
:
2740 case POWER_DOMAIN_AUX_A
:
2742 case POWER_DOMAIN_AUX_B
:
2744 case POWER_DOMAIN_AUX_C
:
2746 case POWER_DOMAIN_AUX_D
:
2748 case POWER_DOMAIN_INIT
:
2751 MISSING_CASE(domain
);
2756 static int i915_power_domain_info(struct seq_file
*m
, void *unused
)
2758 struct drm_info_node
*node
= m
->private;
2759 struct drm_device
*dev
= node
->minor
->dev
;
2760 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2761 struct i915_power_domains
*power_domains
= &dev_priv
->power_domains
;
2764 mutex_lock(&power_domains
->lock
);
2766 seq_printf(m
, "%-25s %s\n", "Power well/domain", "Use count");
2767 for (i
= 0; i
< power_domains
->power_well_count
; i
++) {
2768 struct i915_power_well
*power_well
;
2769 enum intel_display_power_domain power_domain
;
2771 power_well
= &power_domains
->power_wells
[i
];
2772 seq_printf(m
, "%-25s %d\n", power_well
->name
,
2775 for (power_domain
= 0; power_domain
< POWER_DOMAIN_NUM
;
2777 if (!(BIT(power_domain
) & power_well
->domains
))
2780 seq_printf(m
, " %-23s %d\n",
2781 power_domain_str(power_domain
),
2782 power_domains
->domain_use_count
[power_domain
]);
2786 mutex_unlock(&power_domains
->lock
);
2791 static void intel_seq_print_mode(struct seq_file
*m
, int tabs
,
2792 struct drm_display_mode
*mode
)
2796 for (i
= 0; i
< tabs
; i
++)
2799 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",
2800 mode
->base
.id
, mode
->name
,
2801 mode
->vrefresh
, mode
->clock
,
2802 mode
->hdisplay
, mode
->hsync_start
,
2803 mode
->hsync_end
, mode
->htotal
,
2804 mode
->vdisplay
, mode
->vsync_start
,
2805 mode
->vsync_end
, mode
->vtotal
,
2806 mode
->type
, mode
->flags
);
2809 static void intel_encoder_info(struct seq_file
*m
,
2810 struct intel_crtc
*intel_crtc
,
2811 struct intel_encoder
*intel_encoder
)
2813 struct drm_info_node
*node
= m
->private;
2814 struct drm_device
*dev
= node
->minor
->dev
;
2815 struct drm_crtc
*crtc
= &intel_crtc
->base
;
2816 struct intel_connector
*intel_connector
;
2817 struct drm_encoder
*encoder
;
2819 encoder
= &intel_encoder
->base
;
2820 seq_printf(m
, "\tencoder %d: type: %s, connectors:\n",
2821 encoder
->base
.id
, encoder
->name
);
2822 for_each_connector_on_encoder(dev
, encoder
, intel_connector
) {
2823 struct drm_connector
*connector
= &intel_connector
->base
;
2824 seq_printf(m
, "\t\tconnector %d: type: %s, status: %s",
2827 drm_get_connector_status_name(connector
->status
));
2828 if (connector
->status
== connector_status_connected
) {
2829 struct drm_display_mode
*mode
= &crtc
->mode
;
2830 seq_printf(m
, ", mode:\n");
2831 intel_seq_print_mode(m
, 2, mode
);
2838 static void intel_crtc_info(struct seq_file
*m
, struct intel_crtc
*intel_crtc
)
2840 struct drm_info_node
*node
= m
->private;
2841 struct drm_device
*dev
= node
->minor
->dev
;
2842 struct drm_crtc
*crtc
= &intel_crtc
->base
;
2843 struct intel_encoder
*intel_encoder
;
2844 struct drm_plane_state
*plane_state
= crtc
->primary
->state
;
2845 struct drm_framebuffer
*fb
= plane_state
->fb
;
2848 seq_printf(m
, "\tfb: %d, pos: %dx%d, size: %dx%d\n",
2849 fb
->base
.id
, plane_state
->src_x
>> 16,
2850 plane_state
->src_y
>> 16, fb
->width
, fb
->height
);
2852 seq_puts(m
, "\tprimary plane disabled\n");
2853 for_each_encoder_on_crtc(dev
, crtc
, intel_encoder
)
2854 intel_encoder_info(m
, intel_crtc
, intel_encoder
);
2857 static void intel_panel_info(struct seq_file
*m
, struct intel_panel
*panel
)
2859 struct drm_display_mode
*mode
= panel
->fixed_mode
;
2861 seq_printf(m
, "\tfixed mode:\n");
2862 intel_seq_print_mode(m
, 2, mode
);
2865 static void intel_dp_info(struct seq_file
*m
,
2866 struct intel_connector
*intel_connector
)
2868 struct intel_encoder
*intel_encoder
= intel_connector
->encoder
;
2869 struct intel_dp
*intel_dp
= enc_to_intel_dp(&intel_encoder
->base
);
2871 seq_printf(m
, "\tDPCD rev: %x\n", intel_dp
->dpcd
[DP_DPCD_REV
]);
2872 seq_printf(m
, "\taudio support: %s\n", yesno(intel_dp
->has_audio
));
2873 if (intel_encoder
->type
== INTEL_OUTPUT_EDP
)
2874 intel_panel_info(m
, &intel_connector
->panel
);
2877 static void intel_hdmi_info(struct seq_file
*m
,
2878 struct intel_connector
*intel_connector
)
2880 struct intel_encoder
*intel_encoder
= intel_connector
->encoder
;
2881 struct intel_hdmi
*intel_hdmi
= enc_to_intel_hdmi(&intel_encoder
->base
);
2883 seq_printf(m
, "\taudio support: %s\n", yesno(intel_hdmi
->has_audio
));
2886 static void intel_lvds_info(struct seq_file
*m
,
2887 struct intel_connector
*intel_connector
)
2889 intel_panel_info(m
, &intel_connector
->panel
);
2892 static void intel_connector_info(struct seq_file
*m
,
2893 struct drm_connector
*connector
)
2895 struct intel_connector
*intel_connector
= to_intel_connector(connector
);
2896 struct intel_encoder
*intel_encoder
= intel_connector
->encoder
;
2897 struct drm_display_mode
*mode
;
2899 seq_printf(m
, "connector %d: type %s, status: %s\n",
2900 connector
->base
.id
, connector
->name
,
2901 drm_get_connector_status_name(connector
->status
));
2902 if (connector
->status
== connector_status_connected
) {
2903 seq_printf(m
, "\tname: %s\n", connector
->display_info
.name
);
2904 seq_printf(m
, "\tphysical dimensions: %dx%dmm\n",
2905 connector
->display_info
.width_mm
,
2906 connector
->display_info
.height_mm
);
2907 seq_printf(m
, "\tsubpixel order: %s\n",
2908 drm_get_subpixel_order_name(connector
->display_info
.subpixel_order
));
2909 seq_printf(m
, "\tCEA rev: %d\n",
2910 connector
->display_info
.cea_rev
);
2912 if (intel_encoder
) {
2913 if (intel_encoder
->type
== INTEL_OUTPUT_DISPLAYPORT
||
2914 intel_encoder
->type
== INTEL_OUTPUT_EDP
)
2915 intel_dp_info(m
, intel_connector
);
2916 else if (intel_encoder
->type
== INTEL_OUTPUT_HDMI
)
2917 intel_hdmi_info(m
, intel_connector
);
2918 else if (intel_encoder
->type
== INTEL_OUTPUT_LVDS
)
2919 intel_lvds_info(m
, intel_connector
);
2922 seq_printf(m
, "\tmodes:\n");
2923 list_for_each_entry(mode
, &connector
->modes
, head
)
2924 intel_seq_print_mode(m
, 2, mode
);
2927 static bool cursor_active(struct drm_device
*dev
, int pipe
)
2929 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2932 if (IS_845G(dev
) || IS_I865G(dev
))
2933 state
= I915_READ(CURCNTR(PIPE_A
)) & CURSOR_ENABLE
;
2935 state
= I915_READ(CURCNTR(pipe
)) & CURSOR_MODE
;
2940 static bool cursor_position(struct drm_device
*dev
, int pipe
, int *x
, int *y
)
2942 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2945 pos
= I915_READ(CURPOS(pipe
));
2947 *x
= (pos
>> CURSOR_X_SHIFT
) & CURSOR_POS_MASK
;
2948 if (pos
& (CURSOR_POS_SIGN
<< CURSOR_X_SHIFT
))
2951 *y
= (pos
>> CURSOR_Y_SHIFT
) & CURSOR_POS_MASK
;
2952 if (pos
& (CURSOR_POS_SIGN
<< CURSOR_Y_SHIFT
))
2955 return cursor_active(dev
, pipe
);
2958 static int i915_display_info(struct seq_file
*m
, void *unused
)
2960 struct drm_info_node
*node
= m
->private;
2961 struct drm_device
*dev
= node
->minor
->dev
;
2962 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2963 struct intel_crtc
*crtc
;
2964 struct drm_connector
*connector
;
2966 intel_runtime_pm_get(dev_priv
);
2967 drm_modeset_lock_all(dev
);
2968 seq_printf(m
, "CRTC info\n");
2969 seq_printf(m
, "---------\n");
2970 for_each_intel_crtc(dev
, crtc
) {
2972 struct intel_crtc_state
*pipe_config
;
2975 pipe_config
= to_intel_crtc_state(crtc
->base
.state
);
2977 seq_printf(m
, "CRTC %d: pipe: %c, active=%s (size=%dx%d)\n",
2978 crtc
->base
.base
.id
, pipe_name(crtc
->pipe
),
2979 yesno(pipe_config
->base
.active
),
2980 pipe_config
->pipe_src_w
, pipe_config
->pipe_src_h
);
2981 if (pipe_config
->base
.active
) {
2982 intel_crtc_info(m
, crtc
);
2984 active
= cursor_position(dev
, crtc
->pipe
, &x
, &y
);
2985 seq_printf(m
, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x, active? %s\n",
2986 yesno(crtc
->cursor_base
),
2987 x
, y
, crtc
->base
.cursor
->state
->crtc_w
,
2988 crtc
->base
.cursor
->state
->crtc_h
,
2989 crtc
->cursor_addr
, yesno(active
));
2992 seq_printf(m
, "\tunderrun reporting: cpu=%s pch=%s \n",
2993 yesno(!crtc
->cpu_fifo_underrun_disabled
),
2994 yesno(!crtc
->pch_fifo_underrun_disabled
));
2997 seq_printf(m
, "\n");
2998 seq_printf(m
, "Connector info\n");
2999 seq_printf(m
, "--------------\n");
3000 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
3001 intel_connector_info(m
, connector
);
3003 drm_modeset_unlock_all(dev
);
3004 intel_runtime_pm_put(dev_priv
);
3009 static int i915_semaphore_status(struct seq_file
*m
, void *unused
)
3011 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
3012 struct drm_device
*dev
= node
->minor
->dev
;
3013 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3014 struct intel_engine_cs
*ring
;
3015 int num_rings
= hweight32(INTEL_INFO(dev
)->ring_mask
);
3018 if (!i915_semaphore_is_enabled(dev
)) {
3019 seq_puts(m
, "Semaphores are disabled\n");
3023 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
3026 intel_runtime_pm_get(dev_priv
);
3028 if (IS_BROADWELL(dev
)) {
3032 page
= i915_gem_object_get_page(dev_priv
->semaphore_obj
, 0);
3034 seqno
= (uint64_t *)kmap_atomic(page
);
3035 for_each_ring(ring
, dev_priv
, i
) {
3038 seq_printf(m
, "%s\n", ring
->name
);
3040 seq_puts(m
, " Last signal:");
3041 for (j
= 0; j
< num_rings
; j
++) {
3042 offset
= i
* I915_NUM_RINGS
+ j
;
3043 seq_printf(m
, "0x%08llx (0x%02llx) ",
3044 seqno
[offset
], offset
* 8);
3048 seq_puts(m
, " Last wait: ");
3049 for (j
= 0; j
< num_rings
; j
++) {
3050 offset
= i
+ (j
* I915_NUM_RINGS
);
3051 seq_printf(m
, "0x%08llx (0x%02llx) ",
3052 seqno
[offset
], offset
* 8);
3057 kunmap_atomic(seqno
);
3059 seq_puts(m
, " Last signal:");
3060 for_each_ring(ring
, dev_priv
, i
)
3061 for (j
= 0; j
< num_rings
; j
++)
3062 seq_printf(m
, "0x%08x\n",
3063 I915_READ(ring
->semaphore
.mbox
.signal
[j
]));
3067 seq_puts(m
, "\nSync seqno:\n");
3068 for_each_ring(ring
, dev_priv
, i
) {
3069 for (j
= 0; j
< num_rings
; j
++) {
3070 seq_printf(m
, " 0x%08x ", ring
->semaphore
.sync_seqno
[j
]);
3076 intel_runtime_pm_put(dev_priv
);
3077 mutex_unlock(&dev
->struct_mutex
);
3081 static int i915_shared_dplls_info(struct seq_file
*m
, void *unused
)
3083 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
3084 struct drm_device
*dev
= node
->minor
->dev
;
3085 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3088 drm_modeset_lock_all(dev
);
3089 for (i
= 0; i
< dev_priv
->num_shared_dpll
; i
++) {
3090 struct intel_shared_dpll
*pll
= &dev_priv
->shared_dplls
[i
];
3092 seq_printf(m
, "DPLL%i: %s, id: %i\n", i
, pll
->name
, pll
->id
);
3093 seq_printf(m
, " crtc_mask: 0x%08x, active: %d, on: %s\n",
3094 pll
->config
.crtc_mask
, pll
->active
, yesno(pll
->on
));
3095 seq_printf(m
, " tracked hardware state:\n");
3096 seq_printf(m
, " dpll: 0x%08x\n", pll
->config
.hw_state
.dpll
);
3097 seq_printf(m
, " dpll_md: 0x%08x\n",
3098 pll
->config
.hw_state
.dpll_md
);
3099 seq_printf(m
, " fp0: 0x%08x\n", pll
->config
.hw_state
.fp0
);
3100 seq_printf(m
, " fp1: 0x%08x\n", pll
->config
.hw_state
.fp1
);
3101 seq_printf(m
, " wrpll: 0x%08x\n", pll
->config
.hw_state
.wrpll
);
3103 drm_modeset_unlock_all(dev
);
3108 static int i915_wa_registers(struct seq_file
*m
, void *unused
)
3112 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
3113 struct drm_device
*dev
= node
->minor
->dev
;
3114 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3116 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
3120 intel_runtime_pm_get(dev_priv
);
3122 seq_printf(m
, "Workarounds applied: %d\n", dev_priv
->workarounds
.count
);
3123 for (i
= 0; i
< dev_priv
->workarounds
.count
; ++i
) {
3124 u32 addr
, mask
, value
, read
;
3127 addr
= dev_priv
->workarounds
.reg
[i
].addr
;
3128 mask
= dev_priv
->workarounds
.reg
[i
].mask
;
3129 value
= dev_priv
->workarounds
.reg
[i
].value
;
3130 read
= I915_READ(addr
);
3131 ok
= (value
& mask
) == (read
& mask
);
3132 seq_printf(m
, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n",
3133 addr
, value
, mask
, read
, ok
? "OK" : "FAIL");
3136 intel_runtime_pm_put(dev_priv
);
3137 mutex_unlock(&dev
->struct_mutex
);
3142 static int i915_ddb_info(struct seq_file
*m
, void *unused
)
3144 struct drm_info_node
*node
= m
->private;
3145 struct drm_device
*dev
= node
->minor
->dev
;
3146 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3147 struct skl_ddb_allocation
*ddb
;
3148 struct skl_ddb_entry
*entry
;
3152 if (INTEL_INFO(dev
)->gen
< 9)
3155 drm_modeset_lock_all(dev
);
3157 ddb
= &dev_priv
->wm
.skl_hw
.ddb
;
3159 seq_printf(m
, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
3161 for_each_pipe(dev_priv
, pipe
) {
3162 seq_printf(m
, "Pipe %c\n", pipe_name(pipe
));
3164 for_each_plane(dev_priv
, pipe
, plane
) {
3165 entry
= &ddb
->plane
[pipe
][plane
];
3166 seq_printf(m
, " Plane%-8d%8u%8u%8u\n", plane
+ 1,
3167 entry
->start
, entry
->end
,
3168 skl_ddb_entry_size(entry
));
3171 entry
= &ddb
->plane
[pipe
][PLANE_CURSOR
];
3172 seq_printf(m
, " %-13s%8u%8u%8u\n", "Cursor", entry
->start
,
3173 entry
->end
, skl_ddb_entry_size(entry
));
3176 drm_modeset_unlock_all(dev
);
3181 static void drrs_status_per_crtc(struct seq_file
*m
,
3182 struct drm_device
*dev
, struct intel_crtc
*intel_crtc
)
3184 struct intel_encoder
*intel_encoder
;
3185 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3186 struct i915_drrs
*drrs
= &dev_priv
->drrs
;
3189 for_each_encoder_on_crtc(dev
, &intel_crtc
->base
, intel_encoder
) {
3190 /* Encoder connected on this CRTC */
3191 switch (intel_encoder
->type
) {
3192 case INTEL_OUTPUT_EDP
:
3193 seq_puts(m
, "eDP:\n");
3195 case INTEL_OUTPUT_DSI
:
3196 seq_puts(m
, "DSI:\n");
3198 case INTEL_OUTPUT_HDMI
:
3199 seq_puts(m
, "HDMI:\n");
3201 case INTEL_OUTPUT_DISPLAYPORT
:
3202 seq_puts(m
, "DP:\n");
3205 seq_printf(m
, "Other encoder (id=%d).\n",
3206 intel_encoder
->type
);
3211 if (dev_priv
->vbt
.drrs_type
== STATIC_DRRS_SUPPORT
)
3212 seq_puts(m
, "\tVBT: DRRS_type: Static");
3213 else if (dev_priv
->vbt
.drrs_type
== SEAMLESS_DRRS_SUPPORT
)
3214 seq_puts(m
, "\tVBT: DRRS_type: Seamless");
3215 else if (dev_priv
->vbt
.drrs_type
== DRRS_NOT_SUPPORTED
)
3216 seq_puts(m
, "\tVBT: DRRS_type: None");
3218 seq_puts(m
, "\tVBT: DRRS_type: FIXME: Unrecognized Value");
3220 seq_puts(m
, "\n\n");
3222 if (to_intel_crtc_state(intel_crtc
->base
.state
)->has_drrs
) {
3223 struct intel_panel
*panel
;
3225 mutex_lock(&drrs
->mutex
);
3226 /* DRRS Supported */
3227 seq_puts(m
, "\tDRRS Supported: Yes\n");
3229 /* disable_drrs() will make drrs->dp NULL */
3231 seq_puts(m
, "Idleness DRRS: Disabled");
3232 mutex_unlock(&drrs
->mutex
);
3236 panel
= &drrs
->dp
->attached_connector
->panel
;
3237 seq_printf(m
, "\t\tBusy_frontbuffer_bits: 0x%X",
3238 drrs
->busy_frontbuffer_bits
);
3240 seq_puts(m
, "\n\t\t");
3241 if (drrs
->refresh_rate_type
== DRRS_HIGH_RR
) {
3242 seq_puts(m
, "DRRS_State: DRRS_HIGH_RR\n");
3243 vrefresh
= panel
->fixed_mode
->vrefresh
;
3244 } else if (drrs
->refresh_rate_type
== DRRS_LOW_RR
) {
3245 seq_puts(m
, "DRRS_State: DRRS_LOW_RR\n");
3246 vrefresh
= panel
->downclock_mode
->vrefresh
;
3248 seq_printf(m
, "DRRS_State: Unknown(%d)\n",
3249 drrs
->refresh_rate_type
);
3250 mutex_unlock(&drrs
->mutex
);
3253 seq_printf(m
, "\t\tVrefresh: %d", vrefresh
);
3255 seq_puts(m
, "\n\t\t");
3256 mutex_unlock(&drrs
->mutex
);
3258 /* DRRS not supported. Print the VBT parameter*/
3259 seq_puts(m
, "\tDRRS Supported : No");
3264 static int i915_drrs_status(struct seq_file
*m
, void *unused
)
3266 struct drm_info_node
*node
= m
->private;
3267 struct drm_device
*dev
= node
->minor
->dev
;
3268 struct intel_crtc
*intel_crtc
;
3269 int active_crtc_cnt
= 0;
3271 for_each_intel_crtc(dev
, intel_crtc
) {
3272 drm_modeset_lock(&intel_crtc
->base
.mutex
, NULL
);
3274 if (intel_crtc
->base
.state
->active
) {
3276 seq_printf(m
, "\nCRTC %d: ", active_crtc_cnt
);
3278 drrs_status_per_crtc(m
, dev
, intel_crtc
);
3281 drm_modeset_unlock(&intel_crtc
->base
.mutex
);
3284 if (!active_crtc_cnt
)
3285 seq_puts(m
, "No active crtc found\n");
3290 struct pipe_crc_info
{
3292 struct drm_device
*dev
;
3296 static int i915_dp_mst_info(struct seq_file
*m
, void *unused
)
3298 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
3299 struct drm_device
*dev
= node
->minor
->dev
;
3300 struct drm_encoder
*encoder
;
3301 struct intel_encoder
*intel_encoder
;
3302 struct intel_digital_port
*intel_dig_port
;
3303 drm_modeset_lock_all(dev
);
3304 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
3305 intel_encoder
= to_intel_encoder(encoder
);
3306 if (intel_encoder
->type
!= INTEL_OUTPUT_DISPLAYPORT
)
3308 intel_dig_port
= enc_to_dig_port(encoder
);
3309 if (!intel_dig_port
->dp
.can_mst
)
3312 drm_dp_mst_dump_topology(m
, &intel_dig_port
->dp
.mst_mgr
);
3314 drm_modeset_unlock_all(dev
);
3318 static int i915_pipe_crc_open(struct inode
*inode
, struct file
*filep
)
3320 struct pipe_crc_info
*info
= inode
->i_private
;
3321 struct drm_i915_private
*dev_priv
= info
->dev
->dev_private
;
3322 struct intel_pipe_crc
*pipe_crc
= &dev_priv
->pipe_crc
[info
->pipe
];
3324 if (info
->pipe
>= INTEL_INFO(info
->dev
)->num_pipes
)
3327 spin_lock_irq(&pipe_crc
->lock
);
3329 if (pipe_crc
->opened
) {
3330 spin_unlock_irq(&pipe_crc
->lock
);
3331 return -EBUSY
; /* already open */
3334 pipe_crc
->opened
= true;
3335 filep
->private_data
= inode
->i_private
;
3337 spin_unlock_irq(&pipe_crc
->lock
);
3342 static int i915_pipe_crc_release(struct inode
*inode
, struct file
*filep
)
3344 struct pipe_crc_info
*info
= inode
->i_private
;
3345 struct drm_i915_private
*dev_priv
= info
->dev
->dev_private
;
3346 struct intel_pipe_crc
*pipe_crc
= &dev_priv
->pipe_crc
[info
->pipe
];
3348 spin_lock_irq(&pipe_crc
->lock
);
3349 pipe_crc
->opened
= false;
3350 spin_unlock_irq(&pipe_crc
->lock
);
3355 /* (6 fields, 8 chars each, space separated (5) + '\n') */
3356 #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1)
3357 /* account for \'0' */
3358 #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1)
3360 static int pipe_crc_data_count(struct intel_pipe_crc
*pipe_crc
)
3362 assert_spin_locked(&pipe_crc
->lock
);
3363 return CIRC_CNT(pipe_crc
->head
, pipe_crc
->tail
,
3364 INTEL_PIPE_CRC_ENTRIES_NR
);
3368 i915_pipe_crc_read(struct file
*filep
, char __user
*user_buf
, size_t count
,
3371 struct pipe_crc_info
*info
= filep
->private_data
;
3372 struct drm_device
*dev
= info
->dev
;
3373 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3374 struct intel_pipe_crc
*pipe_crc
= &dev_priv
->pipe_crc
[info
->pipe
];
3375 char buf
[PIPE_CRC_BUFFER_LEN
];
3380 * Don't allow user space to provide buffers not big enough to hold
3383 if (count
< PIPE_CRC_LINE_LEN
)
3386 if (pipe_crc
->source
== INTEL_PIPE_CRC_SOURCE_NONE
)
3389 /* nothing to read */
3390 spin_lock_irq(&pipe_crc
->lock
);
3391 while (pipe_crc_data_count(pipe_crc
) == 0) {
3394 if (filep
->f_flags
& O_NONBLOCK
) {
3395 spin_unlock_irq(&pipe_crc
->lock
);
3399 ret
= wait_event_interruptible_lock_irq(pipe_crc
->wq
,
3400 pipe_crc_data_count(pipe_crc
), pipe_crc
->lock
);
3402 spin_unlock_irq(&pipe_crc
->lock
);
3407 /* We now have one or more entries to read */
3408 n_entries
= count
/ PIPE_CRC_LINE_LEN
;
3411 while (n_entries
> 0) {
3412 struct intel_pipe_crc_entry
*entry
=
3413 &pipe_crc
->entries
[pipe_crc
->tail
];
3416 if (CIRC_CNT(pipe_crc
->head
, pipe_crc
->tail
,
3417 INTEL_PIPE_CRC_ENTRIES_NR
) < 1)
3420 BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR
);
3421 pipe_crc
->tail
= (pipe_crc
->tail
+ 1) & (INTEL_PIPE_CRC_ENTRIES_NR
- 1);
3423 bytes_read
+= snprintf(buf
, PIPE_CRC_BUFFER_LEN
,
3424 "%8u %8x %8x %8x %8x %8x\n",
3425 entry
->frame
, entry
->crc
[0],
3426 entry
->crc
[1], entry
->crc
[2],
3427 entry
->crc
[3], entry
->crc
[4]);
3429 spin_unlock_irq(&pipe_crc
->lock
);
3431 ret
= copy_to_user(user_buf
, buf
, PIPE_CRC_LINE_LEN
);
3432 if (ret
== PIPE_CRC_LINE_LEN
)
3435 user_buf
+= PIPE_CRC_LINE_LEN
;
3438 spin_lock_irq(&pipe_crc
->lock
);
3441 spin_unlock_irq(&pipe_crc
->lock
);
3446 static const struct file_operations i915_pipe_crc_fops
= {
3447 .owner
= THIS_MODULE
,
3448 .open
= i915_pipe_crc_open
,
3449 .read
= i915_pipe_crc_read
,
3450 .release
= i915_pipe_crc_release
,
3453 static struct pipe_crc_info i915_pipe_crc_data
[I915_MAX_PIPES
] = {
3455 .name
= "i915_pipe_A_crc",
3459 .name
= "i915_pipe_B_crc",
3463 .name
= "i915_pipe_C_crc",
3468 static int i915_pipe_crc_create(struct dentry
*root
, struct drm_minor
*minor
,
3471 struct drm_device
*dev
= minor
->dev
;
3473 struct pipe_crc_info
*info
= &i915_pipe_crc_data
[pipe
];
3476 ent
= debugfs_create_file(info
->name
, S_IRUGO
, root
, info
,
3477 &i915_pipe_crc_fops
);
3481 return drm_add_fake_info_node(minor
, ent
, info
);
3484 static const char * const pipe_crc_sources
[] = {
3497 static const char *pipe_crc_source_name(enum intel_pipe_crc_source source
)
3499 BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources
) != INTEL_PIPE_CRC_SOURCE_MAX
);
3500 return pipe_crc_sources
[source
];
3503 static int display_crc_ctl_show(struct seq_file
*m
, void *data
)
3505 struct drm_device
*dev
= m
->private;
3506 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3509 for (i
= 0; i
< I915_MAX_PIPES
; i
++)
3510 seq_printf(m
, "%c %s\n", pipe_name(i
),
3511 pipe_crc_source_name(dev_priv
->pipe_crc
[i
].source
));
3516 static int display_crc_ctl_open(struct inode
*inode
, struct file
*file
)
3518 struct drm_device
*dev
= inode
->i_private
;
3520 return single_open(file
, display_crc_ctl_show
, dev
);
3523 static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source
*source
,
3526 if (*source
== INTEL_PIPE_CRC_SOURCE_AUTO
)
3527 *source
= INTEL_PIPE_CRC_SOURCE_PIPE
;
3530 case INTEL_PIPE_CRC_SOURCE_PIPE
:
3531 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_INCLUDE_BORDER_I8XX
;
3533 case INTEL_PIPE_CRC_SOURCE_NONE
:
3543 static int i9xx_pipe_crc_auto_source(struct drm_device
*dev
, enum pipe pipe
,
3544 enum intel_pipe_crc_source
*source
)
3546 struct intel_encoder
*encoder
;
3547 struct intel_crtc
*crtc
;
3548 struct intel_digital_port
*dig_port
;
3551 *source
= INTEL_PIPE_CRC_SOURCE_PIPE
;
3553 drm_modeset_lock_all(dev
);
3554 for_each_intel_encoder(dev
, encoder
) {
3555 if (!encoder
->base
.crtc
)
3558 crtc
= to_intel_crtc(encoder
->base
.crtc
);
3560 if (crtc
->pipe
!= pipe
)
3563 switch (encoder
->type
) {
3564 case INTEL_OUTPUT_TVOUT
:
3565 *source
= INTEL_PIPE_CRC_SOURCE_TV
;
3567 case INTEL_OUTPUT_DISPLAYPORT
:
3568 case INTEL_OUTPUT_EDP
:
3569 dig_port
= enc_to_dig_port(&encoder
->base
);
3570 switch (dig_port
->port
) {
3572 *source
= INTEL_PIPE_CRC_SOURCE_DP_B
;
3575 *source
= INTEL_PIPE_CRC_SOURCE_DP_C
;
3578 *source
= INTEL_PIPE_CRC_SOURCE_DP_D
;
3581 WARN(1, "nonexisting DP port %c\n",
3582 port_name(dig_port
->port
));
3590 drm_modeset_unlock_all(dev
);
3595 static int vlv_pipe_crc_ctl_reg(struct drm_device
*dev
,
3597 enum intel_pipe_crc_source
*source
,
3600 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3601 bool need_stable_symbols
= false;
3603 if (*source
== INTEL_PIPE_CRC_SOURCE_AUTO
) {
3604 int ret
= i9xx_pipe_crc_auto_source(dev
, pipe
, source
);
3610 case INTEL_PIPE_CRC_SOURCE_PIPE
:
3611 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PIPE_VLV
;
3613 case INTEL_PIPE_CRC_SOURCE_DP_B
:
3614 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_B_VLV
;
3615 need_stable_symbols
= true;
3617 case INTEL_PIPE_CRC_SOURCE_DP_C
:
3618 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_C_VLV
;
3619 need_stable_symbols
= true;
3621 case INTEL_PIPE_CRC_SOURCE_DP_D
:
3622 if (!IS_CHERRYVIEW(dev
))
3624 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_D_VLV
;
3625 need_stable_symbols
= true;
3627 case INTEL_PIPE_CRC_SOURCE_NONE
:
3635 * When the pipe CRC tap point is after the transcoders we need
3636 * to tweak symbol-level features to produce a deterministic series of
3637 * symbols for a given frame. We need to reset those features only once
3638 * a frame (instead of every nth symbol):
3639 * - DC-balance: used to ensure a better clock recovery from the data
3641 * - DisplayPort scrambling: used for EMI reduction
3643 if (need_stable_symbols
) {
3644 uint32_t tmp
= I915_READ(PORT_DFT2_G4X
);
3646 tmp
|= DC_BALANCE_RESET_VLV
;
3649 tmp
|= PIPE_A_SCRAMBLE_RESET
;
3652 tmp
|= PIPE_B_SCRAMBLE_RESET
;
3655 tmp
|= PIPE_C_SCRAMBLE_RESET
;
3660 I915_WRITE(PORT_DFT2_G4X
, tmp
);
3666 static int i9xx_pipe_crc_ctl_reg(struct drm_device
*dev
,
3668 enum intel_pipe_crc_source
*source
,
3671 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3672 bool need_stable_symbols
= false;
3674 if (*source
== INTEL_PIPE_CRC_SOURCE_AUTO
) {
3675 int ret
= i9xx_pipe_crc_auto_source(dev
, pipe
, source
);
3681 case INTEL_PIPE_CRC_SOURCE_PIPE
:
3682 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PIPE_I9XX
;
3684 case INTEL_PIPE_CRC_SOURCE_TV
:
3685 if (!SUPPORTS_TV(dev
))
3687 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_TV_PRE
;
3689 case INTEL_PIPE_CRC_SOURCE_DP_B
:
3692 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_B_G4X
;
3693 need_stable_symbols
= true;
3695 case INTEL_PIPE_CRC_SOURCE_DP_C
:
3698 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_C_G4X
;
3699 need_stable_symbols
= true;
3701 case INTEL_PIPE_CRC_SOURCE_DP_D
:
3704 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_DP_D_G4X
;
3705 need_stable_symbols
= true;
3707 case INTEL_PIPE_CRC_SOURCE_NONE
:
3715 * When the pipe CRC tap point is after the transcoders we need
3716 * to tweak symbol-level features to produce a deterministic series of
3717 * symbols for a given frame. We need to reset those features only once
3718 * a frame (instead of every nth symbol):
3719 * - DC-balance: used to ensure a better clock recovery from the data
3721 * - DisplayPort scrambling: used for EMI reduction
3723 if (need_stable_symbols
) {
3724 uint32_t tmp
= I915_READ(PORT_DFT2_G4X
);
3726 WARN_ON(!IS_G4X(dev
));
3728 I915_WRITE(PORT_DFT_I9XX
,
3729 I915_READ(PORT_DFT_I9XX
) | DC_BALANCE_RESET
);
3732 tmp
|= PIPE_A_SCRAMBLE_RESET
;
3734 tmp
|= PIPE_B_SCRAMBLE_RESET
;
3736 I915_WRITE(PORT_DFT2_G4X
, tmp
);
3742 static void vlv_undo_pipe_scramble_reset(struct drm_device
*dev
,
3745 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3746 uint32_t tmp
= I915_READ(PORT_DFT2_G4X
);
3750 tmp
&= ~PIPE_A_SCRAMBLE_RESET
;
3753 tmp
&= ~PIPE_B_SCRAMBLE_RESET
;
3756 tmp
&= ~PIPE_C_SCRAMBLE_RESET
;
3761 if (!(tmp
& PIPE_SCRAMBLE_RESET_MASK
))
3762 tmp
&= ~DC_BALANCE_RESET_VLV
;
3763 I915_WRITE(PORT_DFT2_G4X
, tmp
);
3767 static void g4x_undo_pipe_scramble_reset(struct drm_device
*dev
,
3770 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3771 uint32_t tmp
= I915_READ(PORT_DFT2_G4X
);
3774 tmp
&= ~PIPE_A_SCRAMBLE_RESET
;
3776 tmp
&= ~PIPE_B_SCRAMBLE_RESET
;
3777 I915_WRITE(PORT_DFT2_G4X
, tmp
);
3779 if (!(tmp
& PIPE_SCRAMBLE_RESET_MASK
)) {
3780 I915_WRITE(PORT_DFT_I9XX
,
3781 I915_READ(PORT_DFT_I9XX
) & ~DC_BALANCE_RESET
);
3785 static int ilk_pipe_crc_ctl_reg(enum intel_pipe_crc_source
*source
,
3788 if (*source
== INTEL_PIPE_CRC_SOURCE_AUTO
)
3789 *source
= INTEL_PIPE_CRC_SOURCE_PIPE
;
3792 case INTEL_PIPE_CRC_SOURCE_PLANE1
:
3793 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PRIMARY_ILK
;
3795 case INTEL_PIPE_CRC_SOURCE_PLANE2
:
3796 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_SPRITE_ILK
;
3798 case INTEL_PIPE_CRC_SOURCE_PIPE
:
3799 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PIPE_ILK
;
3801 case INTEL_PIPE_CRC_SOURCE_NONE
:
3811 static void hsw_trans_edp_pipe_A_crc_wa(struct drm_device
*dev
, bool enable
)
3813 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3814 struct intel_crtc
*crtc
=
3815 to_intel_crtc(dev_priv
->pipe_to_crtc_mapping
[PIPE_A
]);
3816 struct intel_crtc_state
*pipe_config
;
3817 struct drm_atomic_state
*state
;
3820 drm_modeset_lock_all(dev
);
3821 state
= drm_atomic_state_alloc(dev
);
3827 state
->acquire_ctx
= drm_modeset_legacy_acquire_ctx(&crtc
->base
);
3828 pipe_config
= intel_atomic_get_crtc_state(state
, crtc
);
3829 if (IS_ERR(pipe_config
)) {
3830 ret
= PTR_ERR(pipe_config
);
3834 pipe_config
->pch_pfit
.force_thru
= enable
;
3835 if (pipe_config
->cpu_transcoder
== TRANSCODER_EDP
&&
3836 pipe_config
->pch_pfit
.enabled
!= enable
)
3837 pipe_config
->base
.connectors_changed
= true;
3839 ret
= drm_atomic_commit(state
);
3841 drm_modeset_unlock_all(dev
);
3842 WARN(ret
, "Toggling workaround to %i returns %i\n", enable
, ret
);
3844 drm_atomic_state_free(state
);
3847 static int ivb_pipe_crc_ctl_reg(struct drm_device
*dev
,
3849 enum intel_pipe_crc_source
*source
,
3852 if (*source
== INTEL_PIPE_CRC_SOURCE_AUTO
)
3853 *source
= INTEL_PIPE_CRC_SOURCE_PF
;
3856 case INTEL_PIPE_CRC_SOURCE_PLANE1
:
3857 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PRIMARY_IVB
;
3859 case INTEL_PIPE_CRC_SOURCE_PLANE2
:
3860 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_SPRITE_IVB
;
3862 case INTEL_PIPE_CRC_SOURCE_PF
:
3863 if (IS_HASWELL(dev
) && pipe
== PIPE_A
)
3864 hsw_trans_edp_pipe_A_crc_wa(dev
, true);
3866 *val
= PIPE_CRC_ENABLE
| PIPE_CRC_SOURCE_PF_IVB
;
3868 case INTEL_PIPE_CRC_SOURCE_NONE
:
3878 static int pipe_crc_set_source(struct drm_device
*dev
, enum pipe pipe
,
3879 enum intel_pipe_crc_source source
)
3881 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
3882 struct intel_pipe_crc
*pipe_crc
= &dev_priv
->pipe_crc
[pipe
];
3883 struct intel_crtc
*crtc
= to_intel_crtc(intel_get_crtc_for_pipe(dev
,
3885 u32 val
= 0; /* shut up gcc */
3888 if (pipe_crc
->source
== source
)
3891 /* forbid changing the source without going back to 'none' */
3892 if (pipe_crc
->source
&& source
)
3895 if (!intel_display_power_is_enabled(dev_priv
, POWER_DOMAIN_PIPE(pipe
))) {
3896 DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n");
3901 ret
= i8xx_pipe_crc_ctl_reg(&source
, &val
);
3902 else if (INTEL_INFO(dev
)->gen
< 5)
3903 ret
= i9xx_pipe_crc_ctl_reg(dev
, pipe
, &source
, &val
);
3904 else if (IS_VALLEYVIEW(dev
))
3905 ret
= vlv_pipe_crc_ctl_reg(dev
, pipe
, &source
, &val
);
3906 else if (IS_GEN5(dev
) || IS_GEN6(dev
))
3907 ret
= ilk_pipe_crc_ctl_reg(&source
, &val
);
3909 ret
= ivb_pipe_crc_ctl_reg(dev
, pipe
, &source
, &val
);
3914 /* none -> real source transition */
3916 struct intel_pipe_crc_entry
*entries
;
3918 DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n",
3919 pipe_name(pipe
), pipe_crc_source_name(source
));
3921 entries
= kcalloc(INTEL_PIPE_CRC_ENTRIES_NR
,
3922 sizeof(pipe_crc
->entries
[0]),
3928 * When IPS gets enabled, the pipe CRC changes. Since IPS gets
3929 * enabled and disabled dynamically based on package C states,
3930 * user space can't make reliable use of the CRCs, so let's just
3931 * completely disable it.
3933 hsw_disable_ips(crtc
);
3935 spin_lock_irq(&pipe_crc
->lock
);
3936 kfree(pipe_crc
->entries
);
3937 pipe_crc
->entries
= entries
;
3940 spin_unlock_irq(&pipe_crc
->lock
);
3943 pipe_crc
->source
= source
;
3945 I915_WRITE(PIPE_CRC_CTL(pipe
), val
);
3946 POSTING_READ(PIPE_CRC_CTL(pipe
));
3948 /* real source -> none transition */
3949 if (source
== INTEL_PIPE_CRC_SOURCE_NONE
) {
3950 struct intel_pipe_crc_entry
*entries
;
3951 struct intel_crtc
*crtc
=
3952 to_intel_crtc(dev_priv
->pipe_to_crtc_mapping
[pipe
]);
3954 DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n",
3957 drm_modeset_lock(&crtc
->base
.mutex
, NULL
);
3958 if (crtc
->base
.state
->active
)
3959 intel_wait_for_vblank(dev
, pipe
);
3960 drm_modeset_unlock(&crtc
->base
.mutex
);
3962 spin_lock_irq(&pipe_crc
->lock
);
3963 entries
= pipe_crc
->entries
;
3964 pipe_crc
->entries
= NULL
;
3967 spin_unlock_irq(&pipe_crc
->lock
);
3972 g4x_undo_pipe_scramble_reset(dev
, pipe
);
3973 else if (IS_VALLEYVIEW(dev
))
3974 vlv_undo_pipe_scramble_reset(dev
, pipe
);
3975 else if (IS_HASWELL(dev
) && pipe
== PIPE_A
)
3976 hsw_trans_edp_pipe_A_crc_wa(dev
, false);
3978 hsw_enable_ips(crtc
);
3985 * Parse pipe CRC command strings:
3986 * command: wsp* object wsp+ name wsp+ source wsp*
3989 * source: (none | plane1 | plane2 | pf)
3990 * wsp: (#0x20 | #0x9 | #0xA)+
3993 * "pipe A plane1" -> Start CRC computations on plane1 of pipe A
3994 * "pipe A none" -> Stop CRC
3996 static int display_crc_ctl_tokenize(char *buf
, char *words
[], int max_words
)
4003 /* skip leading white space */
4004 buf
= skip_spaces(buf
);
4006 break; /* end of buffer */
4008 /* find end of word */
4009 for (end
= buf
; *end
&& !isspace(*end
); end
++)
4012 if (n_words
== max_words
) {
4013 DRM_DEBUG_DRIVER("too many words, allowed <= %d\n",
4015 return -EINVAL
; /* ran out of words[] before bytes */
4020 words
[n_words
++] = buf
;
4027 enum intel_pipe_crc_object
{
4028 PIPE_CRC_OBJECT_PIPE
,
4031 static const char * const pipe_crc_objects
[] = {
4036 display_crc_ctl_parse_object(const char *buf
, enum intel_pipe_crc_object
*o
)
4040 for (i
= 0; i
< ARRAY_SIZE(pipe_crc_objects
); i
++)
4041 if (!strcmp(buf
, pipe_crc_objects
[i
])) {
4049 static int display_crc_ctl_parse_pipe(const char *buf
, enum pipe
*pipe
)
4051 const char name
= buf
[0];
4053 if (name
< 'A' || name
>= pipe_name(I915_MAX_PIPES
))
4062 display_crc_ctl_parse_source(const char *buf
, enum intel_pipe_crc_source
*s
)
4066 for (i
= 0; i
< ARRAY_SIZE(pipe_crc_sources
); i
++)
4067 if (!strcmp(buf
, pipe_crc_sources
[i
])) {
4075 static int display_crc_ctl_parse(struct drm_device
*dev
, char *buf
, size_t len
)
4079 char *words
[N_WORDS
];
4081 enum intel_pipe_crc_object object
;
4082 enum intel_pipe_crc_source source
;
4084 n_words
= display_crc_ctl_tokenize(buf
, words
, N_WORDS
);
4085 if (n_words
!= N_WORDS
) {
4086 DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n",
4091 if (display_crc_ctl_parse_object(words
[0], &object
) < 0) {
4092 DRM_DEBUG_DRIVER("unknown object %s\n", words
[0]);
4096 if (display_crc_ctl_parse_pipe(words
[1], &pipe
) < 0) {
4097 DRM_DEBUG_DRIVER("unknown pipe %s\n", words
[1]);
4101 if (display_crc_ctl_parse_source(words
[2], &source
) < 0) {
4102 DRM_DEBUG_DRIVER("unknown source %s\n", words
[2]);
4106 return pipe_crc_set_source(dev
, pipe
, source
);
4109 static ssize_t
display_crc_ctl_write(struct file
*file
, const char __user
*ubuf
,
4110 size_t len
, loff_t
*offp
)
4112 struct seq_file
*m
= file
->private_data
;
4113 struct drm_device
*dev
= m
->private;
4120 if (len
> PAGE_SIZE
- 1) {
4121 DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n",
4126 tmpbuf
= kmalloc(len
+ 1, GFP_KERNEL
);
4130 if (copy_from_user(tmpbuf
, ubuf
, len
)) {
4136 ret
= display_crc_ctl_parse(dev
, tmpbuf
, len
);
4147 static const struct file_operations i915_display_crc_ctl_fops
= {
4148 .owner
= THIS_MODULE
,
4149 .open
= display_crc_ctl_open
,
4151 .llseek
= seq_lseek
,
4152 .release
= single_release
,
4153 .write
= display_crc_ctl_write
4156 static ssize_t
i915_displayport_test_active_write(struct file
*file
,
4157 const char __user
*ubuf
,
4158 size_t len
, loff_t
*offp
)
4162 struct drm_device
*dev
;
4163 struct drm_connector
*connector
;
4164 struct list_head
*connector_list
;
4165 struct intel_dp
*intel_dp
;
4168 dev
= ((struct seq_file
*)file
->private_data
)->private;
4170 connector_list
= &dev
->mode_config
.connector_list
;
4175 input_buffer
= kmalloc(len
+ 1, GFP_KERNEL
);
4179 if (copy_from_user(input_buffer
, ubuf
, len
)) {
4184 input_buffer
[len
] = '\0';
4185 DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len
);
4187 list_for_each_entry(connector
, connector_list
, head
) {
4189 if (connector
->connector_type
!=
4190 DRM_MODE_CONNECTOR_DisplayPort
)
4193 if (connector
->status
== connector_status_connected
&&
4194 connector
->encoder
!= NULL
) {
4195 intel_dp
= enc_to_intel_dp(connector
->encoder
);
4196 status
= kstrtoint(input_buffer
, 10, &val
);
4199 DRM_DEBUG_DRIVER("Got %d for test active\n", val
);
4200 /* To prevent erroneous activation of the compliance
4201 * testing code, only accept an actual value of 1 here
4204 intel_dp
->compliance_test_active
= 1;
4206 intel_dp
->compliance_test_active
= 0;
4210 kfree(input_buffer
);
4218 static int i915_displayport_test_active_show(struct seq_file
*m
, void *data
)
4220 struct drm_device
*dev
= m
->private;
4221 struct drm_connector
*connector
;
4222 struct list_head
*connector_list
= &dev
->mode_config
.connector_list
;
4223 struct intel_dp
*intel_dp
;
4225 list_for_each_entry(connector
, connector_list
, head
) {
4227 if (connector
->connector_type
!=
4228 DRM_MODE_CONNECTOR_DisplayPort
)
4231 if (connector
->status
== connector_status_connected
&&
4232 connector
->encoder
!= NULL
) {
4233 intel_dp
= enc_to_intel_dp(connector
->encoder
);
4234 if (intel_dp
->compliance_test_active
)
4245 static int i915_displayport_test_active_open(struct inode
*inode
,
4248 struct drm_device
*dev
= inode
->i_private
;
4250 return single_open(file
, i915_displayport_test_active_show
, dev
);
4253 static const struct file_operations i915_displayport_test_active_fops
= {
4254 .owner
= THIS_MODULE
,
4255 .open
= i915_displayport_test_active_open
,
4257 .llseek
= seq_lseek
,
4258 .release
= single_release
,
4259 .write
= i915_displayport_test_active_write
4262 static int i915_displayport_test_data_show(struct seq_file
*m
, void *data
)
4264 struct drm_device
*dev
= m
->private;
4265 struct drm_connector
*connector
;
4266 struct list_head
*connector_list
= &dev
->mode_config
.connector_list
;
4267 struct intel_dp
*intel_dp
;
4269 list_for_each_entry(connector
, connector_list
, head
) {
4271 if (connector
->connector_type
!=
4272 DRM_MODE_CONNECTOR_DisplayPort
)
4275 if (connector
->status
== connector_status_connected
&&
4276 connector
->encoder
!= NULL
) {
4277 intel_dp
= enc_to_intel_dp(connector
->encoder
);
4278 seq_printf(m
, "%lx", intel_dp
->compliance_test_data
);
4285 static int i915_displayport_test_data_open(struct inode
*inode
,
4288 struct drm_device
*dev
= inode
->i_private
;
4290 return single_open(file
, i915_displayport_test_data_show
, dev
);
4293 static const struct file_operations i915_displayport_test_data_fops
= {
4294 .owner
= THIS_MODULE
,
4295 .open
= i915_displayport_test_data_open
,
4297 .llseek
= seq_lseek
,
4298 .release
= single_release
4301 static int i915_displayport_test_type_show(struct seq_file
*m
, void *data
)
4303 struct drm_device
*dev
= m
->private;
4304 struct drm_connector
*connector
;
4305 struct list_head
*connector_list
= &dev
->mode_config
.connector_list
;
4306 struct intel_dp
*intel_dp
;
4308 list_for_each_entry(connector
, connector_list
, head
) {
4310 if (connector
->connector_type
!=
4311 DRM_MODE_CONNECTOR_DisplayPort
)
4314 if (connector
->status
== connector_status_connected
&&
4315 connector
->encoder
!= NULL
) {
4316 intel_dp
= enc_to_intel_dp(connector
->encoder
);
4317 seq_printf(m
, "%02lx", intel_dp
->compliance_test_type
);
4325 static int i915_displayport_test_type_open(struct inode
*inode
,
4328 struct drm_device
*dev
= inode
->i_private
;
4330 return single_open(file
, i915_displayport_test_type_show
, dev
);
4333 static const struct file_operations i915_displayport_test_type_fops
= {
4334 .owner
= THIS_MODULE
,
4335 .open
= i915_displayport_test_type_open
,
4337 .llseek
= seq_lseek
,
4338 .release
= single_release
4341 static void wm_latency_show(struct seq_file
*m
, const uint16_t wm
[8])
4343 struct drm_device
*dev
= m
->private;
4347 if (IS_CHERRYVIEW(dev
))
4349 else if (IS_VALLEYVIEW(dev
))
4352 num_levels
= ilk_wm_max_level(dev
) + 1;
4354 drm_modeset_lock_all(dev
);
4356 for (level
= 0; level
< num_levels
; level
++) {
4357 unsigned int latency
= wm
[level
];
4360 * - WM1+ latency values in 0.5us units
4361 * - latencies are in us on gen9/vlv/chv
4363 if (INTEL_INFO(dev
)->gen
>= 9 || IS_VALLEYVIEW(dev
))
4368 seq_printf(m
, "WM%d %u (%u.%u usec)\n",
4369 level
, wm
[level
], latency
/ 10, latency
% 10);
4372 drm_modeset_unlock_all(dev
);
4375 static int pri_wm_latency_show(struct seq_file
*m
, void *data
)
4377 struct drm_device
*dev
= m
->private;
4378 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4379 const uint16_t *latencies
;
4381 if (INTEL_INFO(dev
)->gen
>= 9)
4382 latencies
= dev_priv
->wm
.skl_latency
;
4384 latencies
= to_i915(dev
)->wm
.pri_latency
;
4386 wm_latency_show(m
, latencies
);
4391 static int spr_wm_latency_show(struct seq_file
*m
, void *data
)
4393 struct drm_device
*dev
= m
->private;
4394 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4395 const uint16_t *latencies
;
4397 if (INTEL_INFO(dev
)->gen
>= 9)
4398 latencies
= dev_priv
->wm
.skl_latency
;
4400 latencies
= to_i915(dev
)->wm
.spr_latency
;
4402 wm_latency_show(m
, latencies
);
4407 static int cur_wm_latency_show(struct seq_file
*m
, void *data
)
4409 struct drm_device
*dev
= m
->private;
4410 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4411 const uint16_t *latencies
;
4413 if (INTEL_INFO(dev
)->gen
>= 9)
4414 latencies
= dev_priv
->wm
.skl_latency
;
4416 latencies
= to_i915(dev
)->wm
.cur_latency
;
4418 wm_latency_show(m
, latencies
);
4423 static int pri_wm_latency_open(struct inode
*inode
, struct file
*file
)
4425 struct drm_device
*dev
= inode
->i_private
;
4427 if (INTEL_INFO(dev
)->gen
< 5)
4430 return single_open(file
, pri_wm_latency_show
, dev
);
4433 static int spr_wm_latency_open(struct inode
*inode
, struct file
*file
)
4435 struct drm_device
*dev
= inode
->i_private
;
4437 if (HAS_GMCH_DISPLAY(dev
))
4440 return single_open(file
, spr_wm_latency_show
, dev
);
4443 static int cur_wm_latency_open(struct inode
*inode
, struct file
*file
)
4445 struct drm_device
*dev
= inode
->i_private
;
4447 if (HAS_GMCH_DISPLAY(dev
))
4450 return single_open(file
, cur_wm_latency_show
, dev
);
4453 static ssize_t
wm_latency_write(struct file
*file
, const char __user
*ubuf
,
4454 size_t len
, loff_t
*offp
, uint16_t wm
[8])
4456 struct seq_file
*m
= file
->private_data
;
4457 struct drm_device
*dev
= m
->private;
4458 uint16_t new[8] = { 0 };
4464 if (IS_CHERRYVIEW(dev
))
4466 else if (IS_VALLEYVIEW(dev
))
4469 num_levels
= ilk_wm_max_level(dev
) + 1;
4471 if (len
>= sizeof(tmp
))
4474 if (copy_from_user(tmp
, ubuf
, len
))
4479 ret
= sscanf(tmp
, "%hu %hu %hu %hu %hu %hu %hu %hu",
4480 &new[0], &new[1], &new[2], &new[3],
4481 &new[4], &new[5], &new[6], &new[7]);
4482 if (ret
!= num_levels
)
4485 drm_modeset_lock_all(dev
);
4487 for (level
= 0; level
< num_levels
; level
++)
4488 wm
[level
] = new[level
];
4490 drm_modeset_unlock_all(dev
);
4496 static ssize_t
pri_wm_latency_write(struct file
*file
, const char __user
*ubuf
,
4497 size_t len
, loff_t
*offp
)
4499 struct seq_file
*m
= file
->private_data
;
4500 struct drm_device
*dev
= m
->private;
4501 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4502 uint16_t *latencies
;
4504 if (INTEL_INFO(dev
)->gen
>= 9)
4505 latencies
= dev_priv
->wm
.skl_latency
;
4507 latencies
= to_i915(dev
)->wm
.pri_latency
;
4509 return wm_latency_write(file
, ubuf
, len
, offp
, latencies
);
4512 static ssize_t
spr_wm_latency_write(struct file
*file
, const char __user
*ubuf
,
4513 size_t len
, loff_t
*offp
)
4515 struct seq_file
*m
= file
->private_data
;
4516 struct drm_device
*dev
= m
->private;
4517 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4518 uint16_t *latencies
;
4520 if (INTEL_INFO(dev
)->gen
>= 9)
4521 latencies
= dev_priv
->wm
.skl_latency
;
4523 latencies
= to_i915(dev
)->wm
.spr_latency
;
4525 return wm_latency_write(file
, ubuf
, len
, offp
, latencies
);
4528 static ssize_t
cur_wm_latency_write(struct file
*file
, const char __user
*ubuf
,
4529 size_t len
, loff_t
*offp
)
4531 struct seq_file
*m
= file
->private_data
;
4532 struct drm_device
*dev
= m
->private;
4533 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4534 uint16_t *latencies
;
4536 if (INTEL_INFO(dev
)->gen
>= 9)
4537 latencies
= dev_priv
->wm
.skl_latency
;
4539 latencies
= to_i915(dev
)->wm
.cur_latency
;
4541 return wm_latency_write(file
, ubuf
, len
, offp
, latencies
);
4544 static const struct file_operations i915_pri_wm_latency_fops
= {
4545 .owner
= THIS_MODULE
,
4546 .open
= pri_wm_latency_open
,
4548 .llseek
= seq_lseek
,
4549 .release
= single_release
,
4550 .write
= pri_wm_latency_write
4553 static const struct file_operations i915_spr_wm_latency_fops
= {
4554 .owner
= THIS_MODULE
,
4555 .open
= spr_wm_latency_open
,
4557 .llseek
= seq_lseek
,
4558 .release
= single_release
,
4559 .write
= spr_wm_latency_write
4562 static const struct file_operations i915_cur_wm_latency_fops
= {
4563 .owner
= THIS_MODULE
,
4564 .open
= cur_wm_latency_open
,
4566 .llseek
= seq_lseek
,
4567 .release
= single_release
,
4568 .write
= cur_wm_latency_write
4572 i915_wedged_get(void *data
, u64
*val
)
4574 struct drm_device
*dev
= data
;
4575 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4577 *val
= atomic_read(&dev_priv
->gpu_error
.reset_counter
);
4583 i915_wedged_set(void *data
, u64 val
)
4585 struct drm_device
*dev
= data
;
4586 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4589 * There is no safeguard against this debugfs entry colliding
4590 * with the hangcheck calling same i915_handle_error() in
4591 * parallel, causing an explosion. For now we assume that the
4592 * test harness is responsible enough not to inject gpu hangs
4593 * while it is writing to 'i915_wedged'
4596 if (i915_reset_in_progress(&dev_priv
->gpu_error
))
4599 intel_runtime_pm_get(dev_priv
);
4601 i915_handle_error(dev
, val
,
4602 "Manually setting wedged to %llu", val
);
4604 intel_runtime_pm_put(dev_priv
);
4609 DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops
,
4610 i915_wedged_get
, i915_wedged_set
,
4614 i915_ring_stop_get(void *data
, u64
*val
)
4616 struct drm_device
*dev
= data
;
4617 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4619 *val
= dev_priv
->gpu_error
.stop_rings
;
4625 i915_ring_stop_set(void *data
, u64 val
)
4627 struct drm_device
*dev
= data
;
4628 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4631 DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val
);
4633 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
4637 dev_priv
->gpu_error
.stop_rings
= val
;
4638 mutex_unlock(&dev
->struct_mutex
);
4643 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops
,
4644 i915_ring_stop_get
, i915_ring_stop_set
,
4648 i915_ring_missed_irq_get(void *data
, u64
*val
)
4650 struct drm_device
*dev
= data
;
4651 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4653 *val
= dev_priv
->gpu_error
.missed_irq_rings
;
4658 i915_ring_missed_irq_set(void *data
, u64 val
)
4660 struct drm_device
*dev
= data
;
4661 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4664 /* Lock against concurrent debugfs callers */
4665 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
4668 dev_priv
->gpu_error
.missed_irq_rings
= val
;
4669 mutex_unlock(&dev
->struct_mutex
);
4674 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops
,
4675 i915_ring_missed_irq_get
, i915_ring_missed_irq_set
,
4679 i915_ring_test_irq_get(void *data
, u64
*val
)
4681 struct drm_device
*dev
= data
;
4682 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4684 *val
= dev_priv
->gpu_error
.test_irq_rings
;
4690 i915_ring_test_irq_set(void *data
, u64 val
)
4692 struct drm_device
*dev
= data
;
4693 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4696 DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val
);
4698 /* Lock against concurrent debugfs callers */
4699 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
4703 dev_priv
->gpu_error
.test_irq_rings
= val
;
4704 mutex_unlock(&dev
->struct_mutex
);
4709 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops
,
4710 i915_ring_test_irq_get
, i915_ring_test_irq_set
,
4713 #define DROP_UNBOUND 0x1
4714 #define DROP_BOUND 0x2
4715 #define DROP_RETIRE 0x4
4716 #define DROP_ACTIVE 0x8
4717 #define DROP_ALL (DROP_UNBOUND | \
4722 i915_drop_caches_get(void *data
, u64
*val
)
4730 i915_drop_caches_set(void *data
, u64 val
)
4732 struct drm_device
*dev
= data
;
4733 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4736 DRM_DEBUG("Dropping caches: 0x%08llx\n", val
);
4738 /* No need to check and wait for gpu resets, only libdrm auto-restarts
4739 * on ioctls on -EAGAIN. */
4740 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
4744 if (val
& DROP_ACTIVE
) {
4745 ret
= i915_gpu_idle(dev
);
4750 if (val
& (DROP_RETIRE
| DROP_ACTIVE
))
4751 i915_gem_retire_requests(dev
);
4753 if (val
& DROP_BOUND
)
4754 i915_gem_shrink(dev_priv
, LONG_MAX
, I915_SHRINK_BOUND
);
4756 if (val
& DROP_UNBOUND
)
4757 i915_gem_shrink(dev_priv
, LONG_MAX
, I915_SHRINK_UNBOUND
);
4760 mutex_unlock(&dev
->struct_mutex
);
4765 DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops
,
4766 i915_drop_caches_get
, i915_drop_caches_set
,
4770 i915_max_freq_get(void *data
, u64
*val
)
4772 struct drm_device
*dev
= data
;
4773 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4776 if (INTEL_INFO(dev
)->gen
< 6)
4779 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
4781 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
4785 *val
= intel_gpu_freq(dev_priv
, dev_priv
->rps
.max_freq_softlimit
);
4786 mutex_unlock(&dev_priv
->rps
.hw_lock
);
4792 i915_max_freq_set(void *data
, u64 val
)
4794 struct drm_device
*dev
= data
;
4795 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4799 if (INTEL_INFO(dev
)->gen
< 6)
4802 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
4804 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val
);
4806 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
4811 * Turbo will still be enabled, but won't go above the set value.
4813 val
= intel_freq_opcode(dev_priv
, val
);
4815 hw_max
= dev_priv
->rps
.max_freq
;
4816 hw_min
= dev_priv
->rps
.min_freq
;
4818 if (val
< hw_min
|| val
> hw_max
|| val
< dev_priv
->rps
.min_freq_softlimit
) {
4819 mutex_unlock(&dev_priv
->rps
.hw_lock
);
4823 dev_priv
->rps
.max_freq_softlimit
= val
;
4825 intel_set_rps(dev
, val
);
4827 mutex_unlock(&dev_priv
->rps
.hw_lock
);
4832 DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops
,
4833 i915_max_freq_get
, i915_max_freq_set
,
4837 i915_min_freq_get(void *data
, u64
*val
)
4839 struct drm_device
*dev
= data
;
4840 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4843 if (INTEL_INFO(dev
)->gen
< 6)
4846 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
4848 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
4852 *val
= intel_gpu_freq(dev_priv
, dev_priv
->rps
.min_freq_softlimit
);
4853 mutex_unlock(&dev_priv
->rps
.hw_lock
);
4859 i915_min_freq_set(void *data
, u64 val
)
4861 struct drm_device
*dev
= data
;
4862 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4866 if (INTEL_INFO(dev
)->gen
< 6)
4869 flush_delayed_work(&dev_priv
->rps
.delayed_resume_work
);
4871 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val
);
4873 ret
= mutex_lock_interruptible(&dev_priv
->rps
.hw_lock
);
4878 * Turbo will still be enabled, but won't go below the set value.
4880 val
= intel_freq_opcode(dev_priv
, val
);
4882 hw_max
= dev_priv
->rps
.max_freq
;
4883 hw_min
= dev_priv
->rps
.min_freq
;
4885 if (val
< hw_min
|| val
> hw_max
|| val
> dev_priv
->rps
.max_freq_softlimit
) {
4886 mutex_unlock(&dev_priv
->rps
.hw_lock
);
4890 dev_priv
->rps
.min_freq_softlimit
= val
;
4892 intel_set_rps(dev
, val
);
4894 mutex_unlock(&dev_priv
->rps
.hw_lock
);
4899 DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops
,
4900 i915_min_freq_get
, i915_min_freq_set
,
4904 i915_cache_sharing_get(void *data
, u64
*val
)
4906 struct drm_device
*dev
= data
;
4907 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4911 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
4914 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
4917 intel_runtime_pm_get(dev_priv
);
4919 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
4921 intel_runtime_pm_put(dev_priv
);
4922 mutex_unlock(&dev_priv
->dev
->struct_mutex
);
4924 *val
= (snpcr
& GEN6_MBC_SNPCR_MASK
) >> GEN6_MBC_SNPCR_SHIFT
;
4930 i915_cache_sharing_set(void *data
, u64 val
)
4932 struct drm_device
*dev
= data
;
4933 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4936 if (!(IS_GEN6(dev
) || IS_GEN7(dev
)))
4942 intel_runtime_pm_get(dev_priv
);
4943 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val
);
4945 /* Update the cache sharing policy here as well */
4946 snpcr
= I915_READ(GEN6_MBCUNIT_SNPCR
);
4947 snpcr
&= ~GEN6_MBC_SNPCR_MASK
;
4948 snpcr
|= (val
<< GEN6_MBC_SNPCR_SHIFT
);
4949 I915_WRITE(GEN6_MBCUNIT_SNPCR
, snpcr
);
4951 intel_runtime_pm_put(dev_priv
);
4955 DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops
,
4956 i915_cache_sharing_get
, i915_cache_sharing_set
,
4959 struct sseu_dev_status
{
4960 unsigned int slice_total
;
4961 unsigned int subslice_total
;
4962 unsigned int subslice_per_slice
;
4963 unsigned int eu_total
;
4964 unsigned int eu_per_subslice
;
4967 static void cherryview_sseu_device_status(struct drm_device
*dev
,
4968 struct sseu_dev_status
*stat
)
4970 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
4973 u32 sig1
[ss_max
], sig2
[ss_max
];
4975 sig1
[0] = I915_READ(CHV_POWER_SS0_SIG1
);
4976 sig1
[1] = I915_READ(CHV_POWER_SS1_SIG1
);
4977 sig2
[0] = I915_READ(CHV_POWER_SS0_SIG2
);
4978 sig2
[1] = I915_READ(CHV_POWER_SS1_SIG2
);
4980 for (ss
= 0; ss
< ss_max
; ss
++) {
4981 unsigned int eu_cnt
;
4983 if (sig1
[ss
] & CHV_SS_PG_ENABLE
)
4984 /* skip disabled subslice */
4987 stat
->slice_total
= 1;
4988 stat
->subslice_per_slice
++;
4989 eu_cnt
= ((sig1
[ss
] & CHV_EU08_PG_ENABLE
) ? 0 : 2) +
4990 ((sig1
[ss
] & CHV_EU19_PG_ENABLE
) ? 0 : 2) +
4991 ((sig1
[ss
] & CHV_EU210_PG_ENABLE
) ? 0 : 2) +
4992 ((sig2
[ss
] & CHV_EU311_PG_ENABLE
) ? 0 : 2);
4993 stat
->eu_total
+= eu_cnt
;
4994 stat
->eu_per_subslice
= max(stat
->eu_per_subslice
, eu_cnt
);
4996 stat
->subslice_total
= stat
->subslice_per_slice
;
4999 static void gen9_sseu_device_status(struct drm_device
*dev
,
5000 struct sseu_dev_status
*stat
)
5002 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
5003 int s_max
= 3, ss_max
= 4;
5005 u32 s_reg
[s_max
], eu_reg
[2*s_max
], eu_mask
[2];
5007 /* BXT has a single slice and at most 3 subslices. */
5008 if (IS_BROXTON(dev
)) {
5013 for (s
= 0; s
< s_max
; s
++) {
5014 s_reg
[s
] = I915_READ(GEN9_SLICE_PGCTL_ACK(s
));
5015 eu_reg
[2*s
] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s
));
5016 eu_reg
[2*s
+ 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s
));
5019 eu_mask
[0] = GEN9_PGCTL_SSA_EU08_ACK
|
5020 GEN9_PGCTL_SSA_EU19_ACK
|
5021 GEN9_PGCTL_SSA_EU210_ACK
|
5022 GEN9_PGCTL_SSA_EU311_ACK
;
5023 eu_mask
[1] = GEN9_PGCTL_SSB_EU08_ACK
|
5024 GEN9_PGCTL_SSB_EU19_ACK
|
5025 GEN9_PGCTL_SSB_EU210_ACK
|
5026 GEN9_PGCTL_SSB_EU311_ACK
;
5028 for (s
= 0; s
< s_max
; s
++) {
5029 unsigned int ss_cnt
= 0;
5031 if ((s_reg
[s
] & GEN9_PGCTL_SLICE_ACK
) == 0)
5032 /* skip disabled slice */
5035 stat
->slice_total
++;
5037 if (IS_SKYLAKE(dev
) || IS_KABYLAKE(dev
))
5038 ss_cnt
= INTEL_INFO(dev
)->subslice_per_slice
;
5040 for (ss
= 0; ss
< ss_max
; ss
++) {
5041 unsigned int eu_cnt
;
5043 if (IS_BROXTON(dev
) &&
5044 !(s_reg
[s
] & (GEN9_PGCTL_SS_ACK(ss
))))
5045 /* skip disabled subslice */
5048 if (IS_BROXTON(dev
))
5051 eu_cnt
= 2 * hweight32(eu_reg
[2*s
+ ss
/2] &
5053 stat
->eu_total
+= eu_cnt
;
5054 stat
->eu_per_subslice
= max(stat
->eu_per_subslice
,
5058 stat
->subslice_total
+= ss_cnt
;
5059 stat
->subslice_per_slice
= max(stat
->subslice_per_slice
,
5064 static void broadwell_sseu_device_status(struct drm_device
*dev
,
5065 struct sseu_dev_status
*stat
)
5067 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
5069 u32 slice_info
= I915_READ(GEN8_GT_SLICE_INFO
);
5071 stat
->slice_total
= hweight32(slice_info
& GEN8_LSLICESTAT_MASK
);
5073 if (stat
->slice_total
) {
5074 stat
->subslice_per_slice
= INTEL_INFO(dev
)->subslice_per_slice
;
5075 stat
->subslice_total
= stat
->slice_total
*
5076 stat
->subslice_per_slice
;
5077 stat
->eu_per_subslice
= INTEL_INFO(dev
)->eu_per_subslice
;
5078 stat
->eu_total
= stat
->eu_per_subslice
* stat
->subslice_total
;
5080 /* subtract fused off EU(s) from enabled slice(s) */
5081 for (s
= 0; s
< stat
->slice_total
; s
++) {
5082 u8 subslice_7eu
= INTEL_INFO(dev
)->subslice_7eu
[s
];
5084 stat
->eu_total
-= hweight8(subslice_7eu
);
5089 static int i915_sseu_status(struct seq_file
*m
, void *unused
)
5091 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
5092 struct drm_device
*dev
= node
->minor
->dev
;
5093 struct sseu_dev_status stat
;
5095 if (INTEL_INFO(dev
)->gen
< 8)
5098 seq_puts(m
, "SSEU Device Info\n");
5099 seq_printf(m
, " Available Slice Total: %u\n",
5100 INTEL_INFO(dev
)->slice_total
);
5101 seq_printf(m
, " Available Subslice Total: %u\n",
5102 INTEL_INFO(dev
)->subslice_total
);
5103 seq_printf(m
, " Available Subslice Per Slice: %u\n",
5104 INTEL_INFO(dev
)->subslice_per_slice
);
5105 seq_printf(m
, " Available EU Total: %u\n",
5106 INTEL_INFO(dev
)->eu_total
);
5107 seq_printf(m
, " Available EU Per Subslice: %u\n",
5108 INTEL_INFO(dev
)->eu_per_subslice
);
5109 seq_printf(m
, " Has Slice Power Gating: %s\n",
5110 yesno(INTEL_INFO(dev
)->has_slice_pg
));
5111 seq_printf(m
, " Has Subslice Power Gating: %s\n",
5112 yesno(INTEL_INFO(dev
)->has_subslice_pg
));
5113 seq_printf(m
, " Has EU Power Gating: %s\n",
5114 yesno(INTEL_INFO(dev
)->has_eu_pg
));
5116 seq_puts(m
, "SSEU Device Status\n");
5117 memset(&stat
, 0, sizeof(stat
));
5118 if (IS_CHERRYVIEW(dev
)) {
5119 cherryview_sseu_device_status(dev
, &stat
);
5120 } else if (IS_BROADWELL(dev
)) {
5121 broadwell_sseu_device_status(dev
, &stat
);
5122 } else if (INTEL_INFO(dev
)->gen
>= 9) {
5123 gen9_sseu_device_status(dev
, &stat
);
5125 seq_printf(m
, " Enabled Slice Total: %u\n",
5127 seq_printf(m
, " Enabled Subslice Total: %u\n",
5128 stat
.subslice_total
);
5129 seq_printf(m
, " Enabled Subslice Per Slice: %u\n",
5130 stat
.subslice_per_slice
);
5131 seq_printf(m
, " Enabled EU Total: %u\n",
5133 seq_printf(m
, " Enabled EU Per Subslice: %u\n",
5134 stat
.eu_per_subslice
);
5139 static int i915_forcewake_open(struct inode
*inode
, struct file
*file
)
5141 struct drm_device
*dev
= inode
->i_private
;
5142 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
5144 if (INTEL_INFO(dev
)->gen
< 6)
5147 intel_runtime_pm_get(dev_priv
);
5148 intel_uncore_forcewake_get(dev_priv
, FORCEWAKE_ALL
);
5153 static int i915_forcewake_release(struct inode
*inode
, struct file
*file
)
5155 struct drm_device
*dev
= inode
->i_private
;
5156 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
5158 if (INTEL_INFO(dev
)->gen
< 6)
5161 intel_uncore_forcewake_put(dev_priv
, FORCEWAKE_ALL
);
5162 intel_runtime_pm_put(dev_priv
);
5167 static const struct file_operations i915_forcewake_fops
= {
5168 .owner
= THIS_MODULE
,
5169 .open
= i915_forcewake_open
,
5170 .release
= i915_forcewake_release
,
5173 static int i915_forcewake_create(struct dentry
*root
, struct drm_minor
*minor
)
5175 struct drm_device
*dev
= minor
->dev
;
5178 ent
= debugfs_create_file("i915_forcewake_user",
5181 &i915_forcewake_fops
);
5185 return drm_add_fake_info_node(minor
, ent
, &i915_forcewake_fops
);
5188 static int i915_debugfs_create(struct dentry
*root
,
5189 struct drm_minor
*minor
,
5191 const struct file_operations
*fops
)
5193 struct drm_device
*dev
= minor
->dev
;
5196 ent
= debugfs_create_file(name
,
5203 return drm_add_fake_info_node(minor
, ent
, fops
);
5206 static const struct drm_info_list i915_debugfs_list
[] = {
5207 {"i915_capabilities", i915_capabilities
, 0},
5208 {"i915_gem_objects", i915_gem_object_info
, 0},
5209 {"i915_gem_gtt", i915_gem_gtt_info
, 0},
5210 {"i915_gem_pinned", i915_gem_gtt_info
, 0, (void *) PINNED_LIST
},
5211 {"i915_gem_active", i915_gem_object_list_info
, 0, (void *) ACTIVE_LIST
},
5212 {"i915_gem_inactive", i915_gem_object_list_info
, 0, (void *) INACTIVE_LIST
},
5213 {"i915_gem_stolen", i915_gem_stolen_list_info
},
5214 {"i915_gem_pageflip", i915_gem_pageflip_info
, 0},
5215 {"i915_gem_request", i915_gem_request_info
, 0},
5216 {"i915_gem_seqno", i915_gem_seqno_info
, 0},
5217 {"i915_gem_fence_regs", i915_gem_fence_regs_info
, 0},
5218 {"i915_gem_interrupt", i915_interrupt_info
, 0},
5219 {"i915_gem_hws", i915_hws_info
, 0, (void *)RCS
},
5220 {"i915_gem_hws_blt", i915_hws_info
, 0, (void *)BCS
},
5221 {"i915_gem_hws_bsd", i915_hws_info
, 0, (void *)VCS
},
5222 {"i915_gem_hws_vebox", i915_hws_info
, 0, (void *)VECS
},
5223 {"i915_gem_batch_pool", i915_gem_batch_pool_info
, 0},
5224 {"i915_guc_info", i915_guc_info
, 0},
5225 {"i915_guc_load_status", i915_guc_load_status_info
, 0},
5226 {"i915_guc_log_dump", i915_guc_log_dump
, 0},
5227 {"i915_frequency_info", i915_frequency_info
, 0},
5228 {"i915_hangcheck_info", i915_hangcheck_info
, 0},
5229 {"i915_drpc_info", i915_drpc_info
, 0},
5230 {"i915_emon_status", i915_emon_status
, 0},
5231 {"i915_ring_freq_table", i915_ring_freq_table
, 0},
5232 {"i915_frontbuffer_tracking", i915_frontbuffer_tracking
, 0},
5233 {"i915_fbc_status", i915_fbc_status
, 0},
5234 {"i915_ips_status", i915_ips_status
, 0},
5235 {"i915_sr_status", i915_sr_status
, 0},
5236 {"i915_opregion", i915_opregion
, 0},
5237 {"i915_gem_framebuffer", i915_gem_framebuffer_info
, 0},
5238 {"i915_context_status", i915_context_status
, 0},
5239 {"i915_dump_lrc", i915_dump_lrc
, 0},
5240 {"i915_execlists", i915_execlists
, 0},
5241 {"i915_forcewake_domains", i915_forcewake_domains
, 0},
5242 {"i915_swizzle_info", i915_swizzle_info
, 0},
5243 {"i915_ppgtt_info", i915_ppgtt_info
, 0},
5244 {"i915_llc", i915_llc
, 0},
5245 {"i915_edp_psr_status", i915_edp_psr_status
, 0},
5246 {"i915_sink_crc_eDP1", i915_sink_crc
, 0},
5247 {"i915_energy_uJ", i915_energy_uJ
, 0},
5248 {"i915_runtime_pm_status", i915_runtime_pm_status
, 0},
5249 {"i915_power_domain_info", i915_power_domain_info
, 0},
5250 {"i915_display_info", i915_display_info
, 0},
5251 {"i915_semaphore_status", i915_semaphore_status
, 0},
5252 {"i915_shared_dplls_info", i915_shared_dplls_info
, 0},
5253 {"i915_dp_mst_info", i915_dp_mst_info
, 0},
5254 {"i915_wa_registers", i915_wa_registers
, 0},
5255 {"i915_ddb_info", i915_ddb_info
, 0},
5256 {"i915_sseu_status", i915_sseu_status
, 0},
5257 {"i915_drrs_status", i915_drrs_status
, 0},
5258 {"i915_rps_boost_info", i915_rps_boost_info
, 0},
5260 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
5262 static const struct i915_debugfs_files
{
5264 const struct file_operations
*fops
;
5265 } i915_debugfs_files
[] = {
5266 {"i915_wedged", &i915_wedged_fops
},
5267 {"i915_max_freq", &i915_max_freq_fops
},
5268 {"i915_min_freq", &i915_min_freq_fops
},
5269 {"i915_cache_sharing", &i915_cache_sharing_fops
},
5270 {"i915_ring_stop", &i915_ring_stop_fops
},
5271 {"i915_ring_missed_irq", &i915_ring_missed_irq_fops
},
5272 {"i915_ring_test_irq", &i915_ring_test_irq_fops
},
5273 {"i915_gem_drop_caches", &i915_drop_caches_fops
},
5274 {"i915_error_state", &i915_error_state_fops
},
5275 {"i915_next_seqno", &i915_next_seqno_fops
},
5276 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops
},
5277 {"i915_pri_wm_latency", &i915_pri_wm_latency_fops
},
5278 {"i915_spr_wm_latency", &i915_spr_wm_latency_fops
},
5279 {"i915_cur_wm_latency", &i915_cur_wm_latency_fops
},
5280 {"i915_fbc_false_color", &i915_fbc_fc_fops
},
5281 {"i915_dp_test_data", &i915_displayport_test_data_fops
},
5282 {"i915_dp_test_type", &i915_displayport_test_type_fops
},
5283 {"i915_dp_test_active", &i915_displayport_test_active_fops
}
5286 void intel_display_crc_init(struct drm_device
*dev
)
5288 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
5291 for_each_pipe(dev_priv
, pipe
) {
5292 struct intel_pipe_crc
*pipe_crc
= &dev_priv
->pipe_crc
[pipe
];
5294 pipe_crc
->opened
= false;
5295 spin_lock_init(&pipe_crc
->lock
);
5296 init_waitqueue_head(&pipe_crc
->wq
);
5300 int i915_debugfs_init(struct drm_minor
*minor
)
5304 ret
= i915_forcewake_create(minor
->debugfs_root
, minor
);
5308 for (i
= 0; i
< ARRAY_SIZE(i915_pipe_crc_data
); i
++) {
5309 ret
= i915_pipe_crc_create(minor
->debugfs_root
, minor
, i
);
5314 for (i
= 0; i
< ARRAY_SIZE(i915_debugfs_files
); i
++) {
5315 ret
= i915_debugfs_create(minor
->debugfs_root
, minor
,
5316 i915_debugfs_files
[i
].name
,
5317 i915_debugfs_files
[i
].fops
);
5322 return drm_debugfs_create_files(i915_debugfs_list
,
5323 I915_DEBUGFS_ENTRIES
,
5324 minor
->debugfs_root
, minor
);
5327 void i915_debugfs_cleanup(struct drm_minor
*minor
)
5331 drm_debugfs_remove_files(i915_debugfs_list
,
5332 I915_DEBUGFS_ENTRIES
, minor
);
5334 drm_debugfs_remove_files((struct drm_info_list
*) &i915_forcewake_fops
,
5337 for (i
= 0; i
< ARRAY_SIZE(i915_pipe_crc_data
); i
++) {
5338 struct drm_info_list
*info_list
=
5339 (struct drm_info_list
*)&i915_pipe_crc_data
[i
];
5341 drm_debugfs_remove_files(info_list
, 1, minor
);
5344 for (i
= 0; i
< ARRAY_SIZE(i915_debugfs_files
); i
++) {
5345 struct drm_info_list
*info_list
=
5346 (struct drm_info_list
*) i915_debugfs_files
[i
].fops
;
5348 drm_debugfs_remove_files(info_list
, 1, minor
);
5353 /* DPCD dump start address. */
5354 unsigned int offset
;
5355 /* DPCD dump end address, inclusive. If unset, .size will be used. */
5357 /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */
5359 /* Only valid for eDP. */
5363 static const struct dpcd_block i915_dpcd_debug
[] = {
5364 { .offset
= DP_DPCD_REV
, .size
= DP_RECEIVER_CAP_SIZE
},
5365 { .offset
= DP_PSR_SUPPORT
, .end
= DP_PSR_CAPS
},
5366 { .offset
= DP_DOWNSTREAM_PORT_0
, .size
= 16 },
5367 { .offset
= DP_LINK_BW_SET
, .end
= DP_EDP_CONFIGURATION_SET
},
5368 { .offset
= DP_SINK_COUNT
, .end
= DP_ADJUST_REQUEST_LANE2_3
},
5369 { .offset
= DP_SET_POWER
},
5370 { .offset
= DP_EDP_DPCD_REV
},
5371 { .offset
= DP_EDP_GENERAL_CAP_1
, .end
= DP_EDP_GENERAL_CAP_3
},
5372 { .offset
= DP_EDP_DISPLAY_CONTROL_REGISTER
, .end
= DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB
},
5373 { .offset
= DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET
, .end
= DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET
},
5376 static int i915_dpcd_show(struct seq_file
*m
, void *data
)
5378 struct drm_connector
*connector
= m
->private;
5379 struct intel_dp
*intel_dp
=
5380 enc_to_intel_dp(&intel_attached_encoder(connector
)->base
);
5385 if (connector
->status
!= connector_status_connected
)
5388 for (i
= 0; i
< ARRAY_SIZE(i915_dpcd_debug
); i
++) {
5389 const struct dpcd_block
*b
= &i915_dpcd_debug
[i
];
5390 size_t size
= b
->end
? b
->end
- b
->offset
+ 1 : (b
->size
?: 1);
5393 connector
->connector_type
!= DRM_MODE_CONNECTOR_eDP
)
5396 /* low tech for now */
5397 if (WARN_ON(size
> sizeof(buf
)))
5400 err
= drm_dp_dpcd_read(&intel_dp
->aux
, b
->offset
, buf
, size
);
5402 DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n",
5403 size
, b
->offset
, err
);
5407 seq_printf(m
, "%04x: %*ph\n", b
->offset
, (int) size
, buf
);
5413 static int i915_dpcd_open(struct inode
*inode
, struct file
*file
)
5415 return single_open(file
, i915_dpcd_show
, inode
->i_private
);
5418 static const struct file_operations i915_dpcd_fops
= {
5419 .owner
= THIS_MODULE
,
5420 .open
= i915_dpcd_open
,
5422 .llseek
= seq_lseek
,
5423 .release
= single_release
,
5427 * i915_debugfs_connector_add - add i915 specific connector debugfs files
5428 * @connector: pointer to a registered drm_connector
5430 * Cleanup will be done by drm_connector_unregister() through a call to
5431 * drm_debugfs_connector_remove().
5433 * Returns 0 on success, negative error codes on error.
5435 int i915_debugfs_connector_add(struct drm_connector
*connector
)
5437 struct dentry
*root
= connector
->debugfs_entry
;
5439 /* The connector must have been registered beforehands. */
5443 if (connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
||
5444 connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
)
5445 debugfs_create_file("i915_dpcd", S_IRUGO
, root
, connector
,