blob: 6400f83d3ad1371afef99d2d4e5b989d7e5f74bc [file] [log] [blame]
Ben Gamari20172632009-02-17 20:08:50 -05001/*
2 * Copyright © 2008 Intel Corporation
3 *
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:
10 *
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
13 * Software.
14 *
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
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
25 * Keith Packard <keithp@keithp.com>
26 *
27 */
28
Chris Wilsonf3cd4742009-10-13 22:20:20 +010029#include <linux/debugfs.h>
Chris Wilson6d2b88852013-08-07 18:30:54 +010030#include <linux/list_sort.h>
Simon Farnsworth4e5359c2010-09-01 17:47:52 +010031#include "intel_drv.h"
Ben Gamari20172632009-02-17 20:08:50 -050032
David Weinehall36cdd012016-08-22 13:59:31 +030033static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
34{
35 return to_i915(node->minor->dev);
36}
37
Damien Lespiau497666d2013-10-15 18:55:39 +010038/* As the drm_debugfs_init() routines are called before dev->dev_private is
39 * allocated we need to hook into the minor for release. */
40static int
41drm_add_fake_info_node(struct drm_minor *minor,
42 struct dentry *ent,
43 const void *key)
44{
45 struct drm_info_node *node;
46
47 node = kmalloc(sizeof(*node), GFP_KERNEL);
48 if (node == NULL) {
49 debugfs_remove(ent);
50 return -ENOMEM;
51 }
52
53 node->minor = minor;
54 node->dent = ent;
David Weinehall36cdd012016-08-22 13:59:31 +030055 node->info_ent = (void *)key;
Damien Lespiau497666d2013-10-15 18:55:39 +010056
57 mutex_lock(&minor->debugfs_lock);
58 list_add(&node->list, &minor->debugfs_list);
59 mutex_unlock(&minor->debugfs_lock);
60
61 return 0;
62}
63
Chris Wilson418e3cd2017-02-06 21:36:08 +000064static __always_inline void seq_print_param(struct seq_file *m,
65 const char *name,
66 const char *type,
67 const void *x)
68{
69 if (!__builtin_strcmp(type, "bool"))
70 seq_printf(m, "i915.%s=%s\n", name, yesno(*(const bool *)x));
71 else if (!__builtin_strcmp(type, "int"))
72 seq_printf(m, "i915.%s=%d\n", name, *(const int *)x);
73 else if (!__builtin_strcmp(type, "unsigned int"))
74 seq_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x);
75 else
76 BUILD_BUG();
77}
78
Chris Wilson70d39fe2010-08-25 16:03:34 +010079static int i915_capabilities(struct seq_file *m, void *data)
80{
David Weinehall36cdd012016-08-22 13:59:31 +030081 struct drm_i915_private *dev_priv = node_to_i915(m->private);
82 const struct intel_device_info *info = INTEL_INFO(dev_priv);
Chris Wilson70d39fe2010-08-25 16:03:34 +010083
David Weinehall36cdd012016-08-22 13:59:31 +030084 seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv));
Jani Nikula2e0d26f2016-12-01 14:49:55 +020085 seq_printf(m, "platform: %s\n", intel_platform_name(info->platform));
David Weinehall36cdd012016-08-22 13:59:31 +030086 seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv));
Chris Wilson418e3cd2017-02-06 21:36:08 +000087
Damien Lespiau79fc46d2013-04-23 16:37:17 +010088#define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
Joonas Lahtinen604db652016-10-05 13:50:16 +030089 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
Damien Lespiau79fc46d2013-04-23 16:37:17 +010090#undef PRINT_FLAG
Chris Wilson70d39fe2010-08-25 16:03:34 +010091
Chris Wilson418e3cd2017-02-06 21:36:08 +000092 kernel_param_lock(THIS_MODULE);
93#define PRINT_PARAM(T, x) seq_print_param(m, #x, #T, &i915.x);
94 I915_PARAMS_FOR_EACH(PRINT_PARAM);
95#undef PRINT_PARAM
96 kernel_param_unlock(THIS_MODULE);
97
Chris Wilson70d39fe2010-08-25 16:03:34 +010098 return 0;
99}
Ben Gamari433e12f2009-02-17 20:08:51 -0500100
Imre Deaka7363de2016-05-12 16:18:52 +0300101static char get_active_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +0000102{
Chris Wilson573adb32016-08-04 16:32:39 +0100103 return i915_gem_object_is_active(obj) ? '*' : ' ';
Chris Wilsona6172a82009-02-11 14:26:38 +0000104}
105
Imre Deaka7363de2016-05-12 16:18:52 +0300106static char get_pin_flag(struct drm_i915_gem_object *obj)
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100107{
108 return obj->pin_display ? 'p' : ' ';
109}
110
Imre Deaka7363de2016-05-12 16:18:52 +0300111static char get_tiling_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +0000112{
Chris Wilson3e510a82016-08-05 10:14:23 +0100113 switch (i915_gem_object_get_tiling(obj)) {
Akshay Joshi0206e352011-08-16 15:34:10 -0400114 default:
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100115 case I915_TILING_NONE: return ' ';
116 case I915_TILING_X: return 'X';
117 case I915_TILING_Y: return 'Y';
Akshay Joshi0206e352011-08-16 15:34:10 -0400118 }
Chris Wilsona6172a82009-02-11 14:26:38 +0000119}
120
Imre Deaka7363de2016-05-12 16:18:52 +0300121static char get_global_flag(struct drm_i915_gem_object *obj)
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700122{
Chris Wilson275f0392016-10-24 13:42:14 +0100123 return !list_empty(&obj->userfault_link) ? 'g' : ' ';
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100124}
125
Imre Deaka7363de2016-05-12 16:18:52 +0300126static char get_pin_mapped_flag(struct drm_i915_gem_object *obj)
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100127{
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100128 return obj->mm.mapping ? 'M' : ' ';
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700129}
130
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100131static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
132{
133 u64 size = 0;
134 struct i915_vma *vma;
135
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000136 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson3272db52016-08-04 16:32:32 +0100137 if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node))
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100138 size += vma->node.size;
139 }
140
141 return size;
142}
143
Chris Wilson37811fc2010-08-25 22:45:57 +0100144static void
145describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
146{
Chris Wilsonb4716182015-04-27 13:41:17 +0100147 struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000148 struct intel_engine_cs *engine;
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700149 struct i915_vma *vma;
Chris Wilsonfaf5bf02016-08-04 16:32:37 +0100150 unsigned int frontbuffer_bits;
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800151 int pin_count = 0;
152
Chris Wilson188c1ab2016-04-03 14:14:20 +0100153 lockdep_assert_held(&obj->base.dev->struct_mutex);
154
Chris Wilsond07f0e52016-10-28 13:58:44 +0100155 seq_printf(m, "%pK: %c%c%c%c%c %8zdKiB %02x %02x %s%s%s",
Chris Wilson37811fc2010-08-25 22:45:57 +0100156 &obj->base,
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100157 get_active_flag(obj),
Chris Wilson37811fc2010-08-25 22:45:57 +0100158 get_pin_flag(obj),
159 get_tiling_flag(obj),
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700160 get_global_flag(obj),
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100161 get_pin_mapped_flag(obj),
Eric Anholta05a5862011-12-20 08:54:15 -0800162 obj->base.size / 1024,
Chris Wilson37811fc2010-08-25 22:45:57 +0100163 obj->base.read_domains,
Chris Wilsond07f0e52016-10-28 13:58:44 +0100164 obj->base.write_domain,
David Weinehall36cdd012016-08-22 13:59:31 +0300165 i915_cache_level_str(dev_priv, obj->cache_level),
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100166 obj->mm.dirty ? " dirty" : "",
167 obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : "");
Chris Wilson37811fc2010-08-25 22:45:57 +0100168 if (obj->base.name)
169 seq_printf(m, " (name: %d)", obj->base.name);
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000170 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson20dfbde2016-08-04 16:32:30 +0100171 if (i915_vma_is_pinned(vma))
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800172 pin_count++;
Dan Carpenterba0635ff2015-02-25 16:17:48 +0300173 }
174 seq_printf(m, " (pinned x %d)", pin_count);
Chris Wilsoncc98b412013-08-09 12:25:09 +0100175 if (obj->pin_display)
176 seq_printf(m, " (display)");
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000177 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson15717de2016-08-04 07:52:26 +0100178 if (!drm_mm_node_allocated(&vma->node))
179 continue;
180
Tvrtko Ursulin8d2fdc32015-05-27 10:52:32 +0100181 seq_printf(m, " (%sgtt offset: %08llx, size: %08llx",
Chris Wilson3272db52016-08-04 16:32:32 +0100182 i915_vma_is_ggtt(vma) ? "g" : "pp",
Tvrtko Ursulin8d2fdc32015-05-27 10:52:32 +0100183 vma->node.start, vma->node.size);
Chris Wilson21976852017-01-12 11:21:08 +0000184 if (i915_vma_is_ggtt(vma)) {
185 switch (vma->ggtt_view.type) {
186 case I915_GGTT_VIEW_NORMAL:
187 seq_puts(m, ", normal");
188 break;
189
190 case I915_GGTT_VIEW_PARTIAL:
191 seq_printf(m, ", partial [%08llx+%x]",
Chris Wilson8bab11932017-01-14 00:28:25 +0000192 vma->ggtt_view.partial.offset << PAGE_SHIFT,
193 vma->ggtt_view.partial.size << PAGE_SHIFT);
Chris Wilson21976852017-01-12 11:21:08 +0000194 break;
195
196 case I915_GGTT_VIEW_ROTATED:
197 seq_printf(m, ", rotated [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]",
Chris Wilson8bab11932017-01-14 00:28:25 +0000198 vma->ggtt_view.rotated.plane[0].width,
199 vma->ggtt_view.rotated.plane[0].height,
200 vma->ggtt_view.rotated.plane[0].stride,
201 vma->ggtt_view.rotated.plane[0].offset,
202 vma->ggtt_view.rotated.plane[1].width,
203 vma->ggtt_view.rotated.plane[1].height,
204 vma->ggtt_view.rotated.plane[1].stride,
205 vma->ggtt_view.rotated.plane[1].offset);
Chris Wilson21976852017-01-12 11:21:08 +0000206 break;
207
208 default:
209 MISSING_CASE(vma->ggtt_view.type);
210 break;
211 }
212 }
Chris Wilson49ef5292016-08-18 17:17:00 +0100213 if (vma->fence)
214 seq_printf(m, " , fence: %d%s",
215 vma->fence->id,
216 i915_gem_active_isset(&vma->last_fence) ? "*" : "");
Chris Wilson596c5922016-02-26 11:03:20 +0000217 seq_puts(m, ")");
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700218 }
Chris Wilsonc1ad11f2012-11-15 11:32:21 +0000219 if (obj->stolen)
Thierry Reding440fd522015-01-23 09:05:06 +0100220 seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
Chris Wilson27c01aa2016-08-04 07:52:30 +0100221
Chris Wilsond07f0e52016-10-28 13:58:44 +0100222 engine = i915_gem_object_last_write_engine(obj);
Chris Wilson27c01aa2016-08-04 07:52:30 +0100223 if (engine)
224 seq_printf(m, " (%s)", engine->name);
225
Chris Wilsonfaf5bf02016-08-04 16:32:37 +0100226 frontbuffer_bits = atomic_read(&obj->frontbuffer_bits);
227 if (frontbuffer_bits)
228 seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits);
Chris Wilson37811fc2010-08-25 22:45:57 +0100229}
230
Chris Wilson6d2b88852013-08-07 18:30:54 +0100231static int obj_rank_by_stolen(void *priv,
232 struct list_head *A, struct list_head *B)
233{
234 struct drm_i915_gem_object *a =
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200235 container_of(A, struct drm_i915_gem_object, obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100236 struct drm_i915_gem_object *b =
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200237 container_of(B, struct drm_i915_gem_object, obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100238
Rasmus Villemoes2d05fa12015-09-28 23:08:50 +0200239 if (a->stolen->start < b->stolen->start)
240 return -1;
241 if (a->stolen->start > b->stolen->start)
242 return 1;
243 return 0;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100244}
245
246static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
247{
David Weinehall36cdd012016-08-22 13:59:31 +0300248 struct drm_i915_private *dev_priv = node_to_i915(m->private);
249 struct drm_device *dev = &dev_priv->drm;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100250 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300251 u64 total_obj_size, total_gtt_size;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100252 LIST_HEAD(stolen);
253 int count, ret;
254
255 ret = mutex_lock_interruptible(&dev->struct_mutex);
256 if (ret)
257 return ret;
258
259 total_obj_size = total_gtt_size = count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200260 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilson6d2b88852013-08-07 18:30:54 +0100261 if (obj->stolen == NULL)
262 continue;
263
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200264 list_add(&obj->obj_exec_link, &stolen);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100265
266 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100267 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100268 count++;
269 }
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200270 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) {
Chris Wilson6d2b88852013-08-07 18:30:54 +0100271 if (obj->stolen == NULL)
272 continue;
273
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200274 list_add(&obj->obj_exec_link, &stolen);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100275
276 total_obj_size += obj->base.size;
277 count++;
278 }
279 list_sort(NULL, &stolen, obj_rank_by_stolen);
280 seq_puts(m, "Stolen:\n");
281 while (!list_empty(&stolen)) {
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200282 obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100283 seq_puts(m, " ");
284 describe_obj(m, obj);
285 seq_putc(m, '\n');
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200286 list_del_init(&obj->obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100287 }
288 mutex_unlock(&dev->struct_mutex);
289
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300290 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
Chris Wilson6d2b88852013-08-07 18:30:54 +0100291 count, total_obj_size, total_gtt_size);
292 return 0;
293}
294
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100295struct file_stats {
Chris Wilson6313c202014-03-19 13:45:45 +0000296 struct drm_i915_file_private *file_priv;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300297 unsigned long count;
298 u64 total, unbound;
299 u64 global, shared;
300 u64 active, inactive;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100301};
302
303static int per_file_stats(int id, void *ptr, void *data)
304{
305 struct drm_i915_gem_object *obj = ptr;
306 struct file_stats *stats = data;
Chris Wilson6313c202014-03-19 13:45:45 +0000307 struct i915_vma *vma;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100308
309 stats->count++;
310 stats->total += obj->base.size;
Chris Wilson15717de2016-08-04 07:52:26 +0100311 if (!obj->bind_count)
312 stats->unbound += obj->base.size;
Chris Wilsonc67a17e2014-03-19 13:45:46 +0000313 if (obj->base.name || obj->base.dma_buf)
314 stats->shared += obj->base.size;
315
Chris Wilson894eeec2016-08-04 07:52:20 +0100316 list_for_each_entry(vma, &obj->vma_list, obj_link) {
317 if (!drm_mm_node_allocated(&vma->node))
318 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000319
Chris Wilson3272db52016-08-04 16:32:32 +0100320 if (i915_vma_is_ggtt(vma)) {
Chris Wilson894eeec2016-08-04 07:52:20 +0100321 stats->global += vma->node.size;
322 } else {
323 struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm);
Chris Wilson6313c202014-03-19 13:45:45 +0000324
Chris Wilson2bfa9962016-08-04 07:52:25 +0100325 if (ppgtt->base.file != stats->file_priv)
Chris Wilson6313c202014-03-19 13:45:45 +0000326 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000327 }
Chris Wilson894eeec2016-08-04 07:52:20 +0100328
Chris Wilsonb0decaf2016-08-04 07:52:44 +0100329 if (i915_vma_is_active(vma))
Chris Wilson894eeec2016-08-04 07:52:20 +0100330 stats->active += vma->node.size;
331 else
332 stats->inactive += vma->node.size;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100333 }
334
335 return 0;
336}
337
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100338#define print_file_stats(m, name, stats) do { \
339 if (stats.count) \
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300340 seq_printf(m, "%s: %lu objects, %llu bytes (%llu active, %llu inactive, %llu global, %llu shared, %llu unbound)\n", \
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100341 name, \
342 stats.count, \
343 stats.total, \
344 stats.active, \
345 stats.inactive, \
346 stats.global, \
347 stats.shared, \
348 stats.unbound); \
349} while (0)
Brad Volkin493018d2014-12-11 12:13:08 -0800350
351static void print_batch_pool_stats(struct seq_file *m,
352 struct drm_i915_private *dev_priv)
353{
354 struct drm_i915_gem_object *obj;
355 struct file_stats stats;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000356 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530357 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000358 int j;
Brad Volkin493018d2014-12-11 12:13:08 -0800359
360 memset(&stats, 0, sizeof(stats));
361
Akash Goel3b3f1652016-10-13 22:44:48 +0530362 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000363 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100364 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000365 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100366 batch_pool_link)
367 per_file_stats(0, obj, &stats);
368 }
Chris Wilson06fbca72015-04-07 16:20:36 +0100369 }
Brad Volkin493018d2014-12-11 12:13:08 -0800370
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100371 print_file_stats(m, "[k]batch pool", stats);
Brad Volkin493018d2014-12-11 12:13:08 -0800372}
373
Chris Wilson15da9562016-05-24 14:53:43 +0100374static int per_file_ctx_stats(int id, void *ptr, void *data)
375{
376 struct i915_gem_context *ctx = ptr;
377 int n;
378
379 for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) {
380 if (ctx->engine[n].state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +0100381 per_file_stats(0, ctx->engine[n].state->obj, data);
Chris Wilsondca33ec2016-08-02 22:50:20 +0100382 if (ctx->engine[n].ring)
Chris Wilson57e88532016-08-15 10:48:57 +0100383 per_file_stats(0, ctx->engine[n].ring->vma->obj, data);
Chris Wilson15da9562016-05-24 14:53:43 +0100384 }
385
386 return 0;
387}
388
389static void print_context_stats(struct seq_file *m,
390 struct drm_i915_private *dev_priv)
391{
David Weinehall36cdd012016-08-22 13:59:31 +0300392 struct drm_device *dev = &dev_priv->drm;
Chris Wilson15da9562016-05-24 14:53:43 +0100393 struct file_stats stats;
394 struct drm_file *file;
395
396 memset(&stats, 0, sizeof(stats));
397
David Weinehall36cdd012016-08-22 13:59:31 +0300398 mutex_lock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100399 if (dev_priv->kernel_context)
400 per_file_ctx_stats(0, dev_priv->kernel_context, &stats);
401
David Weinehall36cdd012016-08-22 13:59:31 +0300402 list_for_each_entry(file, &dev->filelist, lhead) {
Chris Wilson15da9562016-05-24 14:53:43 +0100403 struct drm_i915_file_private *fpriv = file->driver_priv;
404 idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats);
405 }
David Weinehall36cdd012016-08-22 13:59:31 +0300406 mutex_unlock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100407
408 print_file_stats(m, "[k]contexts", stats);
409}
410
David Weinehall36cdd012016-08-22 13:59:31 +0300411static int i915_gem_object_info(struct seq_file *m, void *data)
Chris Wilson73aa8082010-09-30 11:46:12 +0100412{
David Weinehall36cdd012016-08-22 13:59:31 +0300413 struct drm_i915_private *dev_priv = node_to_i915(m->private);
414 struct drm_device *dev = &dev_priv->drm;
Joonas Lahtinen72e96d62016-03-30 16:57:10 +0300415 struct i915_ggtt *ggtt = &dev_priv->ggtt;
Chris Wilson2bd160a2016-08-15 10:48:45 +0100416 u32 count, mapped_count, purgeable_count, dpy_count;
417 u64 size, mapped_size, purgeable_size, dpy_size;
Chris Wilson6299f992010-11-24 12:23:44 +0000418 struct drm_i915_gem_object *obj;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100419 struct drm_file *file;
Chris Wilson73aa8082010-09-30 11:46:12 +0100420 int ret;
421
422 ret = mutex_lock_interruptible(&dev->struct_mutex);
423 if (ret)
424 return ret;
425
Chris Wilson3ef7f222016-10-18 13:02:48 +0100426 seq_printf(m, "%u objects, %llu bytes\n",
Chris Wilson6299f992010-11-24 12:23:44 +0000427 dev_priv->mm.object_count,
428 dev_priv->mm.object_memory);
429
Chris Wilson1544c422016-08-15 13:18:16 +0100430 size = count = 0;
431 mapped_size = mapped_count = 0;
432 purgeable_size = purgeable_count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200433 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100434 size += obj->base.size;
435 ++count;
Chris Wilson6c085a72012-08-20 11:40:46 +0200436
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100437 if (obj->mm.madv == I915_MADV_DONTNEED) {
Chris Wilsonb7abb712012-08-20 11:33:30 +0200438 purgeable_size += obj->base.size;
439 ++purgeable_count;
440 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100441
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100442 if (obj->mm.mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100443 mapped_count++;
444 mapped_size += obj->base.size;
Tvrtko Ursulinbe19b102016-04-15 11:34:53 +0100445 }
Chris Wilson6299f992010-11-24 12:23:44 +0000446 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100447 seq_printf(m, "%u unbound objects, %llu bytes\n", count, size);
448
449 size = count = dpy_size = dpy_count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200450 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100451 size += obj->base.size;
452 ++count;
453
454 if (obj->pin_display) {
455 dpy_size += obj->base.size;
456 ++dpy_count;
457 }
458
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100459 if (obj->mm.madv == I915_MADV_DONTNEED) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100460 purgeable_size += obj->base.size;
461 ++purgeable_count;
462 }
463
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100464 if (obj->mm.mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100465 mapped_count++;
466 mapped_size += obj->base.size;
467 }
468 }
469 seq_printf(m, "%u bound objects, %llu bytes\n",
470 count, size);
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300471 seq_printf(m, "%u purgeable objects, %llu bytes\n",
Chris Wilsonb7abb712012-08-20 11:33:30 +0200472 purgeable_count, purgeable_size);
Chris Wilson2bd160a2016-08-15 10:48:45 +0100473 seq_printf(m, "%u mapped objects, %llu bytes\n",
474 mapped_count, mapped_size);
475 seq_printf(m, "%u display objects (pinned), %llu bytes\n",
476 dpy_count, dpy_size);
Chris Wilson6299f992010-11-24 12:23:44 +0000477
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300478 seq_printf(m, "%llu [%llu] gtt total\n",
Joonas Lahtinen72e96d62016-03-30 16:57:10 +0300479 ggtt->base.total, ggtt->mappable_end - ggtt->base.start);
Chris Wilson73aa8082010-09-30 11:46:12 +0100480
Damien Lespiau267f0c92013-06-24 22:59:48 +0100481 seq_putc(m, '\n');
Brad Volkin493018d2014-12-11 12:13:08 -0800482 print_batch_pool_stats(m, dev_priv);
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200483 mutex_unlock(&dev->struct_mutex);
484
485 mutex_lock(&dev->filelist_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100486 print_context_stats(m, dev_priv);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100487 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
488 struct file_stats stats;
Chris Wilsonc84455b2016-08-15 10:49:08 +0100489 struct drm_i915_file_private *file_priv = file->driver_priv;
490 struct drm_i915_gem_request *request;
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900491 struct task_struct *task;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100492
493 memset(&stats, 0, sizeof(stats));
Chris Wilson6313c202014-03-19 13:45:45 +0000494 stats.file_priv = file->driver_priv;
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100495 spin_lock(&file->table_lock);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100496 idr_for_each(&file->object_idr, per_file_stats, &stats);
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100497 spin_unlock(&file->table_lock);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900498 /*
499 * Although we have a valid reference on file->pid, that does
500 * not guarantee that the task_struct who called get_pid() is
501 * still alive (e.g. get_pid(current) => fork() => exit()).
502 * Therefore, we need to protect this ->comm access using RCU.
503 */
Chris Wilsonc84455b2016-08-15 10:49:08 +0100504 mutex_lock(&dev->struct_mutex);
505 request = list_first_entry_or_null(&file_priv->mm.request_list,
506 struct drm_i915_gem_request,
507 client_list);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900508 rcu_read_lock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100509 task = pid_task(request && request->ctx->pid ?
510 request->ctx->pid : file->pid,
511 PIDTYPE_PID);
Brad Volkin493018d2014-12-11 12:13:08 -0800512 print_file_stats(m, task ? task->comm : "<unknown>", stats);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900513 rcu_read_unlock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100514 mutex_unlock(&dev->struct_mutex);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100515 }
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200516 mutex_unlock(&dev->filelist_mutex);
Chris Wilson73aa8082010-09-30 11:46:12 +0100517
518 return 0;
519}
520
Damien Lespiauaee56cf2013-06-24 22:59:49 +0100521static int i915_gem_gtt_info(struct seq_file *m, void *data)
Chris Wilson08c18322011-01-10 00:00:24 +0000522{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100523 struct drm_info_node *node = m->private;
David Weinehall36cdd012016-08-22 13:59:31 +0300524 struct drm_i915_private *dev_priv = node_to_i915(node);
525 struct drm_device *dev = &dev_priv->drm;
Chris Wilson5f4b0912016-08-19 12:56:25 +0100526 bool show_pin_display_only = !!node->info_ent->data;
Chris Wilson08c18322011-01-10 00:00:24 +0000527 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300528 u64 total_obj_size, total_gtt_size;
Chris Wilson08c18322011-01-10 00:00:24 +0000529 int count, ret;
530
531 ret = mutex_lock_interruptible(&dev->struct_mutex);
532 if (ret)
533 return ret;
534
535 total_obj_size = total_gtt_size = count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200536 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilson6da84822016-08-15 10:48:44 +0100537 if (show_pin_display_only && !obj->pin_display)
Chris Wilson1b502472012-04-24 15:47:30 +0100538 continue;
539
Damien Lespiau267f0c92013-06-24 22:59:48 +0100540 seq_puts(m, " ");
Chris Wilson08c18322011-01-10 00:00:24 +0000541 describe_obj(m, obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100542 seq_putc(m, '\n');
Chris Wilson08c18322011-01-10 00:00:24 +0000543 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100544 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilson08c18322011-01-10 00:00:24 +0000545 count++;
546 }
547
548 mutex_unlock(&dev->struct_mutex);
549
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300550 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
Chris Wilson08c18322011-01-10 00:00:24 +0000551 count, total_obj_size, total_gtt_size);
552
553 return 0;
554}
555
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100556static int i915_gem_pageflip_info(struct seq_file *m, void *data)
557{
David Weinehall36cdd012016-08-22 13:59:31 +0300558 struct drm_i915_private *dev_priv = node_to_i915(m->private);
559 struct drm_device *dev = &dev_priv->drm;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100560 struct intel_crtc *crtc;
Daniel Vetter8a270eb2014-06-17 22:34:37 +0200561 int ret;
562
563 ret = mutex_lock_interruptible(&dev->struct_mutex);
564 if (ret)
565 return ret;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100566
Damien Lespiaud3fcc802014-05-13 23:32:22 +0100567 for_each_intel_crtc(dev, crtc) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800568 const char pipe = pipe_name(crtc->pipe);
569 const char plane = plane_name(crtc->plane);
Maarten Lankhorst51cbaf02016-05-17 15:07:49 +0200570 struct intel_flip_work *work;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100571
Daniel Vetter5e2d7af2014-09-15 14:55:22 +0200572 spin_lock_irq(&dev->event_lock);
Daniel Vetter5a21b662016-05-24 17:13:53 +0200573 work = crtc->flip_work;
574 if (work == NULL) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800575 seq_printf(m, "No flip due on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100576 pipe, plane);
577 } else {
Daniel Vetter5a21b662016-05-24 17:13:53 +0200578 u32 pending;
579 u32 addr;
580
581 pending = atomic_read(&work->pending);
582 if (pending) {
583 seq_printf(m, "Flip ioctl preparing on pipe %c (plane %c)\n",
584 pipe, plane);
585 } else {
586 seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
587 pipe, plane);
588 }
589 if (work->flip_queued_req) {
Joonas Lahtinen24327f82016-11-08 09:11:48 +0200590 struct intel_engine_cs *engine = work->flip_queued_req->engine;
Daniel Vetter5a21b662016-05-24 17:13:53 +0200591
Chris Wilson312c3c42016-11-24 14:47:50 +0000592 seq_printf(m, "Flip queued on %s at seqno %x, last submitted seqno %x [current breadcrumb %x], completed? %d\n",
Daniel Vetter5a21b662016-05-24 17:13:53 +0200593 engine->name,
Joonas Lahtinen24327f82016-11-08 09:11:48 +0200594 work->flip_queued_req->global_seqno,
Chris Wilson312c3c42016-11-24 14:47:50 +0000595 intel_engine_last_submit(engine),
Chris Wilson1b7744e2016-07-01 17:23:17 +0100596 intel_engine_get_seqno(engine),
Chris Wilsonf69a02c2016-07-01 17:23:16 +0100597 i915_gem_request_completed(work->flip_queued_req));
Daniel Vetter5a21b662016-05-24 17:13:53 +0200598 } else
599 seq_printf(m, "Flip not associated with any ring\n");
600 seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n",
601 work->flip_queued_vblank,
602 work->flip_ready_vblank,
603 intel_crtc_get_vblank_counter(crtc));
604 seq_printf(m, "%d prepares\n", atomic_read(&work->pending));
605
David Weinehall36cdd012016-08-22 13:59:31 +0300606 if (INTEL_GEN(dev_priv) >= 4)
Daniel Vetter5a21b662016-05-24 17:13:53 +0200607 addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane)));
608 else
609 addr = I915_READ(DSPADDR(crtc->plane));
610 seq_printf(m, "Current scanout address 0x%08x\n", addr);
611
612 if (work->pending_flip_obj) {
613 seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset);
614 seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100615 }
616 }
Daniel Vetter5e2d7af2014-09-15 14:55:22 +0200617 spin_unlock_irq(&dev->event_lock);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100618 }
619
Daniel Vetter8a270eb2014-06-17 22:34:37 +0200620 mutex_unlock(&dev->struct_mutex);
621
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100622 return 0;
623}
624
Brad Volkin493018d2014-12-11 12:13:08 -0800625static int i915_gem_batch_pool_info(struct seq_file *m, void *data)
626{
David Weinehall36cdd012016-08-22 13:59:31 +0300627 struct drm_i915_private *dev_priv = node_to_i915(m->private);
628 struct drm_device *dev = &dev_priv->drm;
Brad Volkin493018d2014-12-11 12:13:08 -0800629 struct drm_i915_gem_object *obj;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000630 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530631 enum intel_engine_id id;
Chris Wilson8d9d5742015-04-07 16:20:38 +0100632 int total = 0;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000633 int ret, j;
Brad Volkin493018d2014-12-11 12:13:08 -0800634
635 ret = mutex_lock_interruptible(&dev->struct_mutex);
636 if (ret)
637 return ret;
638
Akash Goel3b3f1652016-10-13 22:44:48 +0530639 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000640 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100641 int count;
642
643 count = 0;
644 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000645 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100646 batch_pool_link)
647 count++;
648 seq_printf(m, "%s cache[%d]: %d objects\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000649 engine->name, j, count);
Chris Wilson8d9d5742015-04-07 16:20:38 +0100650
651 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000652 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100653 batch_pool_link) {
654 seq_puts(m, " ");
655 describe_obj(m, obj);
656 seq_putc(m, '\n');
657 }
658
659 total += count;
Chris Wilson06fbca72015-04-07 16:20:36 +0100660 }
Brad Volkin493018d2014-12-11 12:13:08 -0800661 }
662
Chris Wilson8d9d5742015-04-07 16:20:38 +0100663 seq_printf(m, "total: %d\n", total);
Brad Volkin493018d2014-12-11 12:13:08 -0800664
665 mutex_unlock(&dev->struct_mutex);
666
667 return 0;
668}
669
Chris Wilson1b365952016-10-04 21:11:31 +0100670static void print_request(struct seq_file *m,
671 struct drm_i915_gem_request *rq,
672 const char *prefix)
673{
Chris Wilson20311bd2016-11-14 20:41:03 +0000674 seq_printf(m, "%s%x [%x:%x] prio=%d @ %dms: %s\n", prefix,
Chris Wilson65e47602016-10-28 13:58:49 +0100675 rq->global_seqno, rq->ctx->hw_id, rq->fence.seqno,
Chris Wilson20311bd2016-11-14 20:41:03 +0000676 rq->priotree.priority,
Chris Wilson1b365952016-10-04 21:11:31 +0100677 jiffies_to_msecs(jiffies - rq->emitted_jiffies),
Chris Wilson562f5d42016-10-28 13:58:54 +0100678 rq->timeline->common->name);
Chris Wilson1b365952016-10-04 21:11:31 +0100679}
680
Ben Gamari20172632009-02-17 20:08:50 -0500681static int i915_gem_request_info(struct seq_file *m, void *data)
682{
David Weinehall36cdd012016-08-22 13:59:31 +0300683 struct drm_i915_private *dev_priv = node_to_i915(m->private);
684 struct drm_device *dev = &dev_priv->drm;
Daniel Vettereed29a52015-05-21 14:21:25 +0200685 struct drm_i915_gem_request *req;
Akash Goel3b3f1652016-10-13 22:44:48 +0530686 struct intel_engine_cs *engine;
687 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000688 int ret, any;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100689
690 ret = mutex_lock_interruptible(&dev->struct_mutex);
691 if (ret)
692 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500693
Chris Wilson2d1070b2015-04-01 10:36:56 +0100694 any = 0;
Akash Goel3b3f1652016-10-13 22:44:48 +0530695 for_each_engine(engine, dev_priv, id) {
Chris Wilson2d1070b2015-04-01 10:36:56 +0100696 int count;
697
698 count = 0;
Chris Wilson73cb9702016-10-28 13:58:46 +0100699 list_for_each_entry(req, &engine->timeline->requests, link)
Chris Wilson2d1070b2015-04-01 10:36:56 +0100700 count++;
701 if (count == 0)
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100702 continue;
703
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000704 seq_printf(m, "%s requests: %d\n", engine->name, count);
Chris Wilson73cb9702016-10-28 13:58:46 +0100705 list_for_each_entry(req, &engine->timeline->requests, link)
Chris Wilson1b365952016-10-04 21:11:31 +0100706 print_request(m, req, " ");
Chris Wilson2d1070b2015-04-01 10:36:56 +0100707
708 any++;
Ben Gamari20172632009-02-17 20:08:50 -0500709 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100710 mutex_unlock(&dev->struct_mutex);
711
Chris Wilson2d1070b2015-04-01 10:36:56 +0100712 if (any == 0)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100713 seq_puts(m, "No requests\n");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100714
Ben Gamari20172632009-02-17 20:08:50 -0500715 return 0;
716}
717
Chris Wilsonb2223492010-10-27 15:27:33 +0100718static void i915_ring_seqno_info(struct seq_file *m,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +0000719 struct intel_engine_cs *engine)
Chris Wilsonb2223492010-10-27 15:27:33 +0100720{
Chris Wilson688e6c72016-07-01 17:23:15 +0100721 struct intel_breadcrumbs *b = &engine->breadcrumbs;
722 struct rb_node *rb;
723
Chris Wilson12471ba2016-04-09 10:57:55 +0100724 seq_printf(m, "Current sequence (%s): %x\n",
Chris Wilson1b7744e2016-07-01 17:23:17 +0100725 engine->name, intel_engine_get_seqno(engine));
Chris Wilson688e6c72016-07-01 17:23:15 +0100726
Chris Wilsonf6168e32016-10-28 13:58:55 +0100727 spin_lock_irq(&b->lock);
Chris Wilson688e6c72016-07-01 17:23:15 +0100728 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +0800729 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson688e6c72016-07-01 17:23:15 +0100730
731 seq_printf(m, "Waiting (%s): %s [%d] on %x\n",
732 engine->name, w->tsk->comm, w->tsk->pid, w->seqno);
733 }
Chris Wilsonf6168e32016-10-28 13:58:55 +0100734 spin_unlock_irq(&b->lock);
Chris Wilsonb2223492010-10-27 15:27:33 +0100735}
736
Ben Gamari20172632009-02-17 20:08:50 -0500737static int i915_gem_seqno_info(struct seq_file *m, void *data)
738{
David Weinehall36cdd012016-08-22 13:59:31 +0300739 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000740 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530741 enum intel_engine_id id;
Ben Gamari20172632009-02-17 20:08:50 -0500742
Akash Goel3b3f1652016-10-13 22:44:48 +0530743 for_each_engine(engine, dev_priv, id)
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000744 i915_ring_seqno_info(m, engine);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100745
Ben Gamari20172632009-02-17 20:08:50 -0500746 return 0;
747}
748
749
750static int i915_interrupt_info(struct seq_file *m, void *data)
751{
David Weinehall36cdd012016-08-22 13:59:31 +0300752 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000753 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530754 enum intel_engine_id id;
Chris Wilson4bb05042016-09-03 07:53:43 +0100755 int i, pipe;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100756
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200757 intel_runtime_pm_get(dev_priv);
Ben Gamari20172632009-02-17 20:08:50 -0500758
David Weinehall36cdd012016-08-22 13:59:31 +0300759 if (IS_CHERRYVIEW(dev_priv)) {
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300760 seq_printf(m, "Master Interrupt Control:\t%08x\n",
761 I915_READ(GEN8_MASTER_IRQ));
762
763 seq_printf(m, "Display IER:\t%08x\n",
764 I915_READ(VLV_IER));
765 seq_printf(m, "Display IIR:\t%08x\n",
766 I915_READ(VLV_IIR));
767 seq_printf(m, "Display IIR_RW:\t%08x\n",
768 I915_READ(VLV_IIR_RW));
769 seq_printf(m, "Display IMR:\t%08x\n",
770 I915_READ(VLV_IMR));
Chris Wilson9c870d02016-10-24 13:42:15 +0100771 for_each_pipe(dev_priv, pipe) {
772 enum intel_display_power_domain power_domain;
773
774 power_domain = POWER_DOMAIN_PIPE(pipe);
775 if (!intel_display_power_get_if_enabled(dev_priv,
776 power_domain)) {
777 seq_printf(m, "Pipe %c power disabled\n",
778 pipe_name(pipe));
779 continue;
780 }
781
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300782 seq_printf(m, "Pipe %c stat:\t%08x\n",
783 pipe_name(pipe),
784 I915_READ(PIPESTAT(pipe)));
785
Chris Wilson9c870d02016-10-24 13:42:15 +0100786 intel_display_power_put(dev_priv, power_domain);
787 }
788
789 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300790 seq_printf(m, "Port hotplug:\t%08x\n",
791 I915_READ(PORT_HOTPLUG_EN));
792 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
793 I915_READ(VLV_DPFLIPSTAT));
794 seq_printf(m, "DPINVGTT:\t%08x\n",
795 I915_READ(DPINVGTT));
Chris Wilson9c870d02016-10-24 13:42:15 +0100796 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300797
798 for (i = 0; i < 4; i++) {
799 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
800 i, I915_READ(GEN8_GT_IMR(i)));
801 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
802 i, I915_READ(GEN8_GT_IIR(i)));
803 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
804 i, I915_READ(GEN8_GT_IER(i)));
805 }
806
807 seq_printf(m, "PCU interrupt mask:\t%08x\n",
808 I915_READ(GEN8_PCU_IMR));
809 seq_printf(m, "PCU interrupt identity:\t%08x\n",
810 I915_READ(GEN8_PCU_IIR));
811 seq_printf(m, "PCU interrupt enable:\t%08x\n",
812 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300813 } else if (INTEL_GEN(dev_priv) >= 8) {
Ben Widawskya123f152013-11-02 21:07:10 -0700814 seq_printf(m, "Master Interrupt Control:\t%08x\n",
815 I915_READ(GEN8_MASTER_IRQ));
816
817 for (i = 0; i < 4; i++) {
818 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
819 i, I915_READ(GEN8_GT_IMR(i)));
820 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
821 i, I915_READ(GEN8_GT_IIR(i)));
822 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
823 i, I915_READ(GEN8_GT_IER(i)));
824 }
825
Damien Lespiau055e3932014-08-18 13:49:10 +0100826 for_each_pipe(dev_priv, pipe) {
Imre Deake1296492016-02-12 18:55:17 +0200827 enum intel_display_power_domain power_domain;
828
829 power_domain = POWER_DOMAIN_PIPE(pipe);
830 if (!intel_display_power_get_if_enabled(dev_priv,
831 power_domain)) {
Paulo Zanoni22c59962014-08-08 17:45:32 -0300832 seq_printf(m, "Pipe %c power disabled\n",
833 pipe_name(pipe));
834 continue;
835 }
Ben Widawskya123f152013-11-02 21:07:10 -0700836 seq_printf(m, "Pipe %c IMR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000837 pipe_name(pipe),
838 I915_READ(GEN8_DE_PIPE_IMR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700839 seq_printf(m, "Pipe %c IIR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000840 pipe_name(pipe),
841 I915_READ(GEN8_DE_PIPE_IIR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700842 seq_printf(m, "Pipe %c IER:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000843 pipe_name(pipe),
844 I915_READ(GEN8_DE_PIPE_IER(pipe)));
Imre Deake1296492016-02-12 18:55:17 +0200845
846 intel_display_power_put(dev_priv, power_domain);
Ben Widawskya123f152013-11-02 21:07:10 -0700847 }
848
849 seq_printf(m, "Display Engine port interrupt mask:\t%08x\n",
850 I915_READ(GEN8_DE_PORT_IMR));
851 seq_printf(m, "Display Engine port interrupt identity:\t%08x\n",
852 I915_READ(GEN8_DE_PORT_IIR));
853 seq_printf(m, "Display Engine port interrupt enable:\t%08x\n",
854 I915_READ(GEN8_DE_PORT_IER));
855
856 seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n",
857 I915_READ(GEN8_DE_MISC_IMR));
858 seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n",
859 I915_READ(GEN8_DE_MISC_IIR));
860 seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n",
861 I915_READ(GEN8_DE_MISC_IER));
862
863 seq_printf(m, "PCU interrupt mask:\t%08x\n",
864 I915_READ(GEN8_PCU_IMR));
865 seq_printf(m, "PCU interrupt identity:\t%08x\n",
866 I915_READ(GEN8_PCU_IIR));
867 seq_printf(m, "PCU interrupt enable:\t%08x\n",
868 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300869 } else if (IS_VALLEYVIEW(dev_priv)) {
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700870 seq_printf(m, "Display IER:\t%08x\n",
871 I915_READ(VLV_IER));
872 seq_printf(m, "Display IIR:\t%08x\n",
873 I915_READ(VLV_IIR));
874 seq_printf(m, "Display IIR_RW:\t%08x\n",
875 I915_READ(VLV_IIR_RW));
876 seq_printf(m, "Display IMR:\t%08x\n",
877 I915_READ(VLV_IMR));
Damien Lespiau055e3932014-08-18 13:49:10 +0100878 for_each_pipe(dev_priv, pipe)
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700879 seq_printf(m, "Pipe %c stat:\t%08x\n",
880 pipe_name(pipe),
881 I915_READ(PIPESTAT(pipe)));
882
883 seq_printf(m, "Master IER:\t%08x\n",
884 I915_READ(VLV_MASTER_IER));
885
886 seq_printf(m, "Render IER:\t%08x\n",
887 I915_READ(GTIER));
888 seq_printf(m, "Render IIR:\t%08x\n",
889 I915_READ(GTIIR));
890 seq_printf(m, "Render IMR:\t%08x\n",
891 I915_READ(GTIMR));
892
893 seq_printf(m, "PM IER:\t\t%08x\n",
894 I915_READ(GEN6_PMIER));
895 seq_printf(m, "PM IIR:\t\t%08x\n",
896 I915_READ(GEN6_PMIIR));
897 seq_printf(m, "PM IMR:\t\t%08x\n",
898 I915_READ(GEN6_PMIMR));
899
900 seq_printf(m, "Port hotplug:\t%08x\n",
901 I915_READ(PORT_HOTPLUG_EN));
902 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
903 I915_READ(VLV_DPFLIPSTAT));
904 seq_printf(m, "DPINVGTT:\t%08x\n",
905 I915_READ(DPINVGTT));
906
David Weinehall36cdd012016-08-22 13:59:31 +0300907 } else if (!HAS_PCH_SPLIT(dev_priv)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800908 seq_printf(m, "Interrupt enable: %08x\n",
909 I915_READ(IER));
910 seq_printf(m, "Interrupt identity: %08x\n",
911 I915_READ(IIR));
912 seq_printf(m, "Interrupt mask: %08x\n",
913 I915_READ(IMR));
Damien Lespiau055e3932014-08-18 13:49:10 +0100914 for_each_pipe(dev_priv, pipe)
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800915 seq_printf(m, "Pipe %c stat: %08x\n",
916 pipe_name(pipe),
917 I915_READ(PIPESTAT(pipe)));
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800918 } else {
919 seq_printf(m, "North Display Interrupt enable: %08x\n",
920 I915_READ(DEIER));
921 seq_printf(m, "North Display Interrupt identity: %08x\n",
922 I915_READ(DEIIR));
923 seq_printf(m, "North Display Interrupt mask: %08x\n",
924 I915_READ(DEIMR));
925 seq_printf(m, "South Display Interrupt enable: %08x\n",
926 I915_READ(SDEIER));
927 seq_printf(m, "South Display Interrupt identity: %08x\n",
928 I915_READ(SDEIIR));
929 seq_printf(m, "South Display Interrupt mask: %08x\n",
930 I915_READ(SDEIMR));
931 seq_printf(m, "Graphics Interrupt enable: %08x\n",
932 I915_READ(GTIER));
933 seq_printf(m, "Graphics Interrupt identity: %08x\n",
934 I915_READ(GTIIR));
935 seq_printf(m, "Graphics Interrupt mask: %08x\n",
936 I915_READ(GTIMR));
937 }
Akash Goel3b3f1652016-10-13 22:44:48 +0530938 for_each_engine(engine, dev_priv, id) {
David Weinehall36cdd012016-08-22 13:59:31 +0300939 if (INTEL_GEN(dev_priv) >= 6) {
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100940 seq_printf(m,
941 "Graphics Interrupt mask (%s): %08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000942 engine->name, I915_READ_IMR(engine));
Chris Wilson9862e602011-01-04 22:22:17 +0000943 }
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000944 i915_ring_seqno_info(m, engine);
Chris Wilson9862e602011-01-04 22:22:17 +0000945 }
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200946 intel_runtime_pm_put(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100947
Ben Gamari20172632009-02-17 20:08:50 -0500948 return 0;
949}
950
Chris Wilsona6172a82009-02-11 14:26:38 +0000951static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
952{
David Weinehall36cdd012016-08-22 13:59:31 +0300953 struct drm_i915_private *dev_priv = node_to_i915(m->private);
954 struct drm_device *dev = &dev_priv->drm;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100955 int i, ret;
956
957 ret = mutex_lock_interruptible(&dev->struct_mutex);
958 if (ret)
959 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000960
Chris Wilsona6172a82009-02-11 14:26:38 +0000961 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
962 for (i = 0; i < dev_priv->num_fence_regs; i++) {
Chris Wilson49ef5292016-08-18 17:17:00 +0100963 struct i915_vma *vma = dev_priv->fence_regs[i].vma;
Chris Wilsona6172a82009-02-11 14:26:38 +0000964
Chris Wilson6c085a72012-08-20 11:40:46 +0200965 seq_printf(m, "Fence %d, pin count = %d, object = ",
966 i, dev_priv->fence_regs[i].pin_count);
Chris Wilson49ef5292016-08-18 17:17:00 +0100967 if (!vma)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100968 seq_puts(m, "unused");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100969 else
Chris Wilson49ef5292016-08-18 17:17:00 +0100970 describe_obj(m, vma->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100971 seq_putc(m, '\n');
Chris Wilsona6172a82009-02-11 14:26:38 +0000972 }
973
Chris Wilson05394f32010-11-08 19:18:58 +0000974 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000975 return 0;
976}
977
Chris Wilson98a2f412016-10-12 10:05:18 +0100978#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
979
Daniel Vetterd5442302012-04-27 15:17:40 +0200980static ssize_t
981i915_error_state_write(struct file *filp,
982 const char __user *ubuf,
983 size_t cnt,
984 loff_t *ppos)
985{
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300986 struct i915_error_state_file_priv *error_priv = filp->private_data;
Daniel Vetterd5442302012-04-27 15:17:40 +0200987
988 DRM_DEBUG_DRIVER("Resetting error state\n");
Tvrtko Ursulin12ff05e2016-12-01 14:16:43 +0000989 i915_destroy_error_state(error_priv->i915);
Daniel Vetterd5442302012-04-27 15:17:40 +0200990
991 return cnt;
992}
993
994static int i915_error_state_open(struct inode *inode, struct file *file)
995{
David Weinehall36cdd012016-08-22 13:59:31 +0300996 struct drm_i915_private *dev_priv = inode->i_private;
Daniel Vetterd5442302012-04-27 15:17:40 +0200997 struct i915_error_state_file_priv *error_priv;
Daniel Vetterd5442302012-04-27 15:17:40 +0200998
999 error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL);
1000 if (!error_priv)
1001 return -ENOMEM;
1002
Tvrtko Ursulin12ff05e2016-12-01 14:16:43 +00001003 error_priv->i915 = dev_priv;
Daniel Vetterd5442302012-04-27 15:17:40 +02001004
David Weinehall36cdd012016-08-22 13:59:31 +03001005 i915_error_state_get(&dev_priv->drm, error_priv);
Daniel Vetterd5442302012-04-27 15:17:40 +02001006
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001007 file->private_data = error_priv;
1008
1009 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +02001010}
1011
1012static int i915_error_state_release(struct inode *inode, struct file *file)
1013{
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001014 struct i915_error_state_file_priv *error_priv = file->private_data;
Daniel Vetterd5442302012-04-27 15:17:40 +02001015
Mika Kuoppala95d5bfb2013-06-06 15:18:40 +03001016 i915_error_state_put(error_priv);
Daniel Vetterd5442302012-04-27 15:17:40 +02001017 kfree(error_priv);
1018
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001019 return 0;
1020}
1021
1022static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
1023 size_t count, loff_t *pos)
1024{
1025 struct i915_error_state_file_priv *error_priv = file->private_data;
1026 struct drm_i915_error_state_buf error_str;
1027 loff_t tmp_pos = 0;
1028 ssize_t ret_count = 0;
Mika Kuoppala4dc955f2013-06-06 15:18:41 +03001029 int ret;
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001030
Tvrtko Ursulin12ff05e2016-12-01 14:16:43 +00001031 ret = i915_error_state_buf_init(&error_str, error_priv->i915,
1032 count, *pos);
Mika Kuoppala4dc955f2013-06-06 15:18:41 +03001033 if (ret)
1034 return ret;
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001035
Mika Kuoppalafc16b482013-06-06 15:18:39 +03001036 ret = i915_error_state_to_str(&error_str, error_priv);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001037 if (ret)
1038 goto out;
1039
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001040 ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos,
1041 error_str.buf,
1042 error_str.bytes);
1043
1044 if (ret_count < 0)
1045 ret = ret_count;
1046 else
1047 *pos = error_str.start + ret_count;
1048out:
Mika Kuoppala4dc955f2013-06-06 15:18:41 +03001049 i915_error_state_buf_release(&error_str);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001050 return ret ?: ret_count;
Daniel Vetterd5442302012-04-27 15:17:40 +02001051}
1052
1053static const struct file_operations i915_error_state_fops = {
1054 .owner = THIS_MODULE,
1055 .open = i915_error_state_open,
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001056 .read = i915_error_state_read,
Daniel Vetterd5442302012-04-27 15:17:40 +02001057 .write = i915_error_state_write,
1058 .llseek = default_llseek,
1059 .release = i915_error_state_release,
1060};
1061
Chris Wilson98a2f412016-10-12 10:05:18 +01001062#endif
1063
Kees Cook647416f2013-03-10 14:10:06 -07001064static int
1065i915_next_seqno_get(void *data, u64 *val)
Mika Kuoppala40633212012-12-04 15:12:00 +02001066{
David Weinehall36cdd012016-08-22 13:59:31 +03001067 struct drm_i915_private *dev_priv = data;
Mika Kuoppala40633212012-12-04 15:12:00 +02001068
Joonas Lahtinen4c266ed2016-11-24 14:47:49 +00001069 *val = 1 + atomic_read(&dev_priv->gt.global_timeline.seqno);
Kees Cook647416f2013-03-10 14:10:06 -07001070 return 0;
Mika Kuoppala40633212012-12-04 15:12:00 +02001071}
1072
Kees Cook647416f2013-03-10 14:10:06 -07001073static int
1074i915_next_seqno_set(void *data, u64 val)
Mika Kuoppala40633212012-12-04 15:12:00 +02001075{
David Weinehall36cdd012016-08-22 13:59:31 +03001076 struct drm_i915_private *dev_priv = data;
1077 struct drm_device *dev = &dev_priv->drm;
Mika Kuoppala40633212012-12-04 15:12:00 +02001078 int ret;
1079
Mika Kuoppala40633212012-12-04 15:12:00 +02001080 ret = mutex_lock_interruptible(&dev->struct_mutex);
1081 if (ret)
1082 return ret;
1083
Chris Wilson73cb9702016-10-28 13:58:46 +01001084 ret = i915_gem_set_global_seqno(dev, val);
Mika Kuoppala40633212012-12-04 15:12:00 +02001085 mutex_unlock(&dev->struct_mutex);
1086
Kees Cook647416f2013-03-10 14:10:06 -07001087 return ret;
Mika Kuoppala40633212012-12-04 15:12:00 +02001088}
1089
Kees Cook647416f2013-03-10 14:10:06 -07001090DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
1091 i915_next_seqno_get, i915_next_seqno_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03001092 "0x%llx\n");
Mika Kuoppala40633212012-12-04 15:12:00 +02001093
Deepak Sadb4bd12014-03-31 11:30:02 +05301094static int i915_frequency_info(struct seq_file *m, void *unused)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001095{
David Weinehall36cdd012016-08-22 13:59:31 +03001096 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1097 struct drm_device *dev = &dev_priv->drm;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001098 int ret = 0;
1099
1100 intel_runtime_pm_get(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001101
David Weinehall36cdd012016-08-22 13:59:31 +03001102 if (IS_GEN5(dev_priv)) {
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001103 u16 rgvswctl = I915_READ16(MEMSWCTL);
1104 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
1105
1106 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
1107 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
1108 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
1109 MEMSTAT_VID_SHIFT);
1110 seq_printf(m, "Current P-state: %d\n",
1111 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
David Weinehall36cdd012016-08-22 13:59:31 +03001112 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
Wayne Boyer666a4532015-12-09 12:29:35 -08001113 u32 freq_sts;
1114
1115 mutex_lock(&dev_priv->rps.hw_lock);
1116 freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
1117 seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts);
1118 seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq);
1119
1120 seq_printf(m, "actual GPU freq: %d MHz\n",
1121 intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff));
1122
1123 seq_printf(m, "current GPU freq: %d MHz\n",
1124 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1125
1126 seq_printf(m, "max GPU freq: %d MHz\n",
1127 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1128
1129 seq_printf(m, "min GPU freq: %d MHz\n",
1130 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
1131
1132 seq_printf(m, "idle GPU freq: %d MHz\n",
1133 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
1134
1135 seq_printf(m,
1136 "efficient (RPe) frequency: %d MHz\n",
1137 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
1138 mutex_unlock(&dev_priv->rps.hw_lock);
David Weinehall36cdd012016-08-22 13:59:31 +03001139 } else if (INTEL_GEN(dev_priv) >= 6) {
Bob Paauwe35040562015-06-25 14:54:07 -07001140 u32 rp_state_limits;
1141 u32 gt_perf_status;
1142 u32 rp_state_cap;
Chris Wilson0d8f9492014-03-27 09:06:14 +00001143 u32 rpmodectl, rpinclimit, rpdeclimit;
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001144 u32 rpstat, cagf, reqf;
Jesse Barnesccab5c82011-01-18 15:49:25 -08001145 u32 rpupei, rpcurup, rpprevup;
1146 u32 rpdownei, rpcurdown, rpprevdown;
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001147 u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask;
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001148 int max_freq;
1149
Bob Paauwe35040562015-06-25 14:54:07 -07001150 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001151 if (IS_GEN9_LP(dev_priv)) {
Bob Paauwe35040562015-06-25 14:54:07 -07001152 rp_state_cap = I915_READ(BXT_RP_STATE_CAP);
1153 gt_perf_status = I915_READ(BXT_GT_PERF_STATUS);
1154 } else {
1155 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
1156 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
1157 }
1158
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001159 /* RPSTAT1 is in the GT power well */
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001160 ret = mutex_lock_interruptible(&dev->struct_mutex);
1161 if (ret)
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001162 goto out;
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001163
Mika Kuoppala59bad942015-01-16 11:34:40 +02001164 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001165
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001166 reqf = I915_READ(GEN6_RPNSWREQ);
David Weinehall36cdd012016-08-22 13:59:31 +03001167 if (IS_GEN9(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301168 reqf >>= 23;
1169 else {
1170 reqf &= ~GEN6_TURBO_DISABLE;
David Weinehall36cdd012016-08-22 13:59:31 +03001171 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301172 reqf >>= 24;
1173 else
1174 reqf >>= 25;
1175 }
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001176 reqf = intel_gpu_freq(dev_priv, reqf);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001177
Chris Wilson0d8f9492014-03-27 09:06:14 +00001178 rpmodectl = I915_READ(GEN6_RP_CONTROL);
1179 rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD);
1180 rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD);
1181
Jesse Barnesccab5c82011-01-18 15:49:25 -08001182 rpstat = I915_READ(GEN6_RPSTAT1);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301183 rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK;
1184 rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK;
1185 rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK;
1186 rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK;
1187 rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK;
1188 rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK;
David Weinehall36cdd012016-08-22 13:59:31 +03001189 if (IS_GEN9(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301190 cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT;
David Weinehall36cdd012016-08-22 13:59:31 +03001191 else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Ben Widawskyf82855d2013-01-29 12:00:15 -08001192 cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT;
1193 else
1194 cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT;
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001195 cagf = intel_gpu_freq(dev_priv, cagf);
Jesse Barnesccab5c82011-01-18 15:49:25 -08001196
Mika Kuoppala59bad942015-01-16 11:34:40 +02001197 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001198 mutex_unlock(&dev->struct_mutex);
1199
David Weinehall36cdd012016-08-22 13:59:31 +03001200 if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) {
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001201 pm_ier = I915_READ(GEN6_PMIER);
1202 pm_imr = I915_READ(GEN6_PMIMR);
1203 pm_isr = I915_READ(GEN6_PMISR);
1204 pm_iir = I915_READ(GEN6_PMIIR);
1205 pm_mask = I915_READ(GEN6_PMINTRMSK);
1206 } else {
1207 pm_ier = I915_READ(GEN8_GT_IER(2));
1208 pm_imr = I915_READ(GEN8_GT_IMR(2));
1209 pm_isr = I915_READ(GEN8_GT_ISR(2));
1210 pm_iir = I915_READ(GEN8_GT_IIR(2));
1211 pm_mask = I915_READ(GEN6_PMINTRMSK);
1212 }
Chris Wilson0d8f9492014-03-27 09:06:14 +00001213 seq_printf(m, "PM IER=0x%08x IMR=0x%08x ISR=0x%08x IIR=0x%08x, MASK=0x%08x\n",
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001214 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask);
Sagar Arun Kamble1800ad22016-05-31 13:58:27 +05301215 seq_printf(m, "pm_intr_keep: 0x%08x\n", dev_priv->rps.pm_intr_keep);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001216 seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001217 seq_printf(m, "Render p-state ratio: %d\n",
David Weinehall36cdd012016-08-22 13:59:31 +03001218 (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001219 seq_printf(m, "Render p-state VID: %d\n",
1220 gt_perf_status & 0xff);
1221 seq_printf(m, "Render p-state limit: %d\n",
1222 rp_state_limits & 0xff);
Chris Wilson0d8f9492014-03-27 09:06:14 +00001223 seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
1224 seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl);
1225 seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit);
1226 seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001227 seq_printf(m, "RPNSWREQ: %dMHz\n", reqf);
Ben Widawskyf82855d2013-01-29 12:00:15 -08001228 seq_printf(m, "CAGF: %dMHz\n", cagf);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301229 seq_printf(m, "RP CUR UP EI: %d (%dus)\n",
1230 rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei));
1231 seq_printf(m, "RP CUR UP: %d (%dus)\n",
1232 rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup));
1233 seq_printf(m, "RP PREV UP: %d (%dus)\n",
1234 rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup));
Chris Wilsond86ed342015-04-27 13:41:19 +01001235 seq_printf(m, "Up threshold: %d%%\n",
1236 dev_priv->rps.up_threshold);
1237
Akash Goeld6cda9c2016-04-23 00:05:46 +05301238 seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n",
1239 rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei));
1240 seq_printf(m, "RP CUR DOWN: %d (%dus)\n",
1241 rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown));
1242 seq_printf(m, "RP PREV DOWN: %d (%dus)\n",
1243 rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown));
Chris Wilsond86ed342015-04-27 13:41:19 +01001244 seq_printf(m, "Down threshold: %d%%\n",
1245 dev_priv->rps.down_threshold);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001246
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001247 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 :
Bob Paauwe35040562015-06-25 14:54:07 -07001248 rp_state_cap >> 16) & 0xff;
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001249 max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001250 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001251 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001252
1253 max_freq = (rp_state_cap & 0xff00) >> 8;
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001254 max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001255 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001256 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001257
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001258 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 :
Bob Paauwe35040562015-06-25 14:54:07 -07001259 rp_state_cap >> 0) & 0xff;
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001260 max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001261 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001262 intel_gpu_freq(dev_priv, max_freq));
Ben Widawsky31c77382013-04-05 14:29:22 -07001263 seq_printf(m, "Max overclocked frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001264 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
Chris Wilsonaed242f2015-03-18 09:48:21 +00001265
Chris Wilsond86ed342015-04-27 13:41:19 +01001266 seq_printf(m, "Current freq: %d MHz\n",
1267 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1268 seq_printf(m, "Actual freq: %d MHz\n", cagf);
Chris Wilsonaed242f2015-03-18 09:48:21 +00001269 seq_printf(m, "Idle freq: %d MHz\n",
1270 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001271 seq_printf(m, "Min freq: %d MHz\n",
1272 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
Chris Wilson29ecd78d2016-07-13 09:10:35 +01001273 seq_printf(m, "Boost freq: %d MHz\n",
1274 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001275 seq_printf(m, "Max freq: %d MHz\n",
1276 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1277 seq_printf(m,
1278 "efficient (RPe) frequency: %d MHz\n",
1279 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001280 } else {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001281 seq_puts(m, "no P-state info available\n");
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001282 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001283
Mika Kahola1170f282015-09-25 14:00:32 +03001284 seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq);
1285 seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq);
1286 seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq);
1287
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001288out:
1289 intel_runtime_pm_put(dev_priv);
1290 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001291}
1292
Ben Widawskyd6369512016-09-20 16:54:32 +03001293static void i915_instdone_info(struct drm_i915_private *dev_priv,
1294 struct seq_file *m,
1295 struct intel_instdone *instdone)
1296{
Ben Widawskyf9e61372016-09-20 16:54:33 +03001297 int slice;
1298 int subslice;
1299
Ben Widawskyd6369512016-09-20 16:54:32 +03001300 seq_printf(m, "\t\tINSTDONE: 0x%08x\n",
1301 instdone->instdone);
1302
1303 if (INTEL_GEN(dev_priv) <= 3)
1304 return;
1305
1306 seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n",
1307 instdone->slice_common);
1308
1309 if (INTEL_GEN(dev_priv) <= 6)
1310 return;
1311
Ben Widawskyf9e61372016-09-20 16:54:33 +03001312 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1313 seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n",
1314 slice, subslice, instdone->sampler[slice][subslice]);
1315
1316 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1317 seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n",
1318 slice, subslice, instdone->row[slice][subslice]);
Ben Widawskyd6369512016-09-20 16:54:32 +03001319}
1320
Chris Wilsonf6544492015-01-26 18:03:04 +02001321static int i915_hangcheck_info(struct seq_file *m, void *unused)
1322{
David Weinehall36cdd012016-08-22 13:59:31 +03001323 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001324 struct intel_engine_cs *engine;
Tvrtko Ursulin666796d2016-03-16 11:00:39 +00001325 u64 acthd[I915_NUM_ENGINES];
1326 u32 seqno[I915_NUM_ENGINES];
Ben Widawskyd6369512016-09-20 16:54:32 +03001327 struct intel_instdone instdone;
Dave Gordonc3232b12016-03-23 18:19:53 +00001328 enum intel_engine_id id;
Chris Wilsonf6544492015-01-26 18:03:04 +02001329
Chris Wilson8af29b02016-09-09 14:11:47 +01001330 if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags))
1331 seq_printf(m, "Wedged\n");
1332 if (test_bit(I915_RESET_IN_PROGRESS, &dev_priv->gpu_error.flags))
1333 seq_printf(m, "Reset in progress\n");
1334 if (waitqueue_active(&dev_priv->gpu_error.wait_queue))
1335 seq_printf(m, "Waiter holding struct mutex\n");
1336 if (waitqueue_active(&dev_priv->gpu_error.reset_queue))
1337 seq_printf(m, "struct_mutex blocked for reset\n");
1338
Chris Wilsonf6544492015-01-26 18:03:04 +02001339 if (!i915.enable_hangcheck) {
1340 seq_printf(m, "Hangcheck disabled\n");
1341 return 0;
1342 }
1343
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001344 intel_runtime_pm_get(dev_priv);
1345
Akash Goel3b3f1652016-10-13 22:44:48 +05301346 for_each_engine(engine, dev_priv, id) {
Chris Wilson7e37f882016-08-02 22:50:21 +01001347 acthd[id] = intel_engine_get_active_head(engine);
Chris Wilson1b7744e2016-07-01 17:23:17 +01001348 seqno[id] = intel_engine_get_seqno(engine);
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001349 }
1350
Akash Goel3b3f1652016-10-13 22:44:48 +05301351 intel_engine_get_instdone(dev_priv->engine[RCS], &instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001352
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001353 intel_runtime_pm_put(dev_priv);
1354
Chris Wilsonf6544492015-01-26 18:03:04 +02001355 if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) {
1356 seq_printf(m, "Hangcheck active, fires in %dms\n",
1357 jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires -
1358 jiffies));
1359 } else
1360 seq_printf(m, "Hangcheck inactive\n");
1361
Akash Goel3b3f1652016-10-13 22:44:48 +05301362 for_each_engine(engine, dev_priv, id) {
Chris Wilson33f53712016-10-04 21:11:32 +01001363 struct intel_breadcrumbs *b = &engine->breadcrumbs;
1364 struct rb_node *rb;
1365
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001366 seq_printf(m, "%s:\n", engine->name);
Chris Wilson14fd0d62016-04-07 07:29:10 +01001367 seq_printf(m, "\tseqno = %x [current %x, last %x]\n",
Chris Wilsoncb399ea2016-11-01 10:03:16 +00001368 engine->hangcheck.seqno, seqno[id],
1369 intel_engine_last_submit(engine));
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001370 seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n",
Chris Wilson83348ba2016-08-09 17:47:51 +01001371 yesno(intel_engine_has_waiter(engine)),
1372 yesno(test_bit(engine->id,
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001373 &dev_priv->gpu_error.missed_irq_rings)),
1374 yesno(engine->hangcheck.stalled));
1375
Chris Wilsonf6168e32016-10-28 13:58:55 +01001376 spin_lock_irq(&b->lock);
Chris Wilson33f53712016-10-04 21:11:32 +01001377 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +08001378 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson33f53712016-10-04 21:11:32 +01001379
1380 seq_printf(m, "\t%s [%d] waiting for %x\n",
1381 w->tsk->comm, w->tsk->pid, w->seqno);
1382 }
Chris Wilsonf6168e32016-10-28 13:58:55 +01001383 spin_unlock_irq(&b->lock);
Chris Wilson33f53712016-10-04 21:11:32 +01001384
Chris Wilsonf6544492015-01-26 18:03:04 +02001385 seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001386 (long long)engine->hangcheck.acthd,
Dave Gordonc3232b12016-03-23 18:19:53 +00001387 (long long)acthd[id]);
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001388 seq_printf(m, "\taction = %s(%d) %d ms ago\n",
1389 hangcheck_action_to_str(engine->hangcheck.action),
1390 engine->hangcheck.action,
1391 jiffies_to_msecs(jiffies -
1392 engine->hangcheck.action_timestamp));
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001393
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001394 if (engine->id == RCS) {
Ben Widawskyd6369512016-09-20 16:54:32 +03001395 seq_puts(m, "\tinstdone read =\n");
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001396
Ben Widawskyd6369512016-09-20 16:54:32 +03001397 i915_instdone_info(dev_priv, m, &instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001398
Ben Widawskyd6369512016-09-20 16:54:32 +03001399 seq_puts(m, "\tinstdone accu =\n");
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001400
Ben Widawskyd6369512016-09-20 16:54:32 +03001401 i915_instdone_info(dev_priv, m,
1402 &engine->hangcheck.instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001403 }
Chris Wilsonf6544492015-01-26 18:03:04 +02001404 }
1405
1406 return 0;
1407}
1408
Ben Widawsky4d855292011-12-12 19:34:16 -08001409static int ironlake_drpc_info(struct seq_file *m)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001410{
David Weinehall36cdd012016-08-22 13:59:31 +03001411 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001412 u32 rgvmodectl, rstdbyctl;
1413 u16 crstandvid;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001414
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001415 intel_runtime_pm_get(dev_priv);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001416
1417 rgvmodectl = I915_READ(MEMMODECTL);
1418 rstdbyctl = I915_READ(RSTDBYCTL);
1419 crstandvid = I915_READ16(CRSTANDVID);
1420
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001421 intel_runtime_pm_put(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001422
Jani Nikula742f4912015-09-03 11:16:09 +03001423 seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001424 seq_printf(m, "Boost freq: %d\n",
1425 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
1426 MEMMODE_BOOST_FREQ_SHIFT);
1427 seq_printf(m, "HW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001428 yesno(rgvmodectl & MEMMODE_HWIDLE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001429 seq_printf(m, "SW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001430 yesno(rgvmodectl & MEMMODE_SWMODE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001431 seq_printf(m, "Gated voltage change: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001432 yesno(rgvmodectl & MEMMODE_RCLK_GATE));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001433 seq_printf(m, "Starting frequency: P%d\n",
1434 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001435 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -08001436 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001437 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
1438 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
1439 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
1440 seq_printf(m, "Render standby enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001441 yesno(!(rstdbyctl & RCX_SW_EXIT)));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001442 seq_puts(m, "Current RS state: ");
Jesse Barnes88271da2011-01-05 12:01:24 -08001443 switch (rstdbyctl & RSX_STATUS_MASK) {
1444 case RSX_STATUS_ON:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001445 seq_puts(m, "on\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001446 break;
1447 case RSX_STATUS_RC1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001448 seq_puts(m, "RC1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001449 break;
1450 case RSX_STATUS_RC1E:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001451 seq_puts(m, "RC1E\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001452 break;
1453 case RSX_STATUS_RS1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001454 seq_puts(m, "RS1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001455 break;
1456 case RSX_STATUS_RS2:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001457 seq_puts(m, "RS2 (RC6)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001458 break;
1459 case RSX_STATUS_RS3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001460 seq_puts(m, "RC3 (RC6+)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001461 break;
1462 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001463 seq_puts(m, "unknown\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001464 break;
1465 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001466
1467 return 0;
1468}
1469
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001470static int i915_forcewake_domains(struct seq_file *m, void *data)
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001471{
David Weinehall36cdd012016-08-22 13:59:31 +03001472 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001473 struct intel_uncore_forcewake_domain *fw_domain;
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001474
1475 spin_lock_irq(&dev_priv->uncore.lock);
Tvrtko Ursulin33c582c2016-04-07 17:04:33 +01001476 for_each_fw_domain(fw_domain, dev_priv) {
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001477 seq_printf(m, "%s.wake_count = %u\n",
Tvrtko Ursulin33c582c2016-04-07 17:04:33 +01001478 intel_uncore_forcewake_domain_to_str(fw_domain->id),
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001479 fw_domain->wake_count);
1480 }
1481 spin_unlock_irq(&dev_priv->uncore.lock);
1482
1483 return 0;
1484}
1485
Deepak S669ab5a2014-01-10 15:18:26 +05301486static int vlv_drpc_info(struct seq_file *m)
1487{
David Weinehall36cdd012016-08-22 13:59:31 +03001488 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001489 u32 rpmodectl1, rcctl1, pw_status;
Deepak S669ab5a2014-01-10 15:18:26 +05301490
Imre Deakd46c0512014-04-14 20:24:27 +03001491 intel_runtime_pm_get(dev_priv);
1492
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001493 pw_status = I915_READ(VLV_GTLC_PW_STATUS);
Deepak S669ab5a2014-01-10 15:18:26 +05301494 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1495 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1496
Imre Deakd46c0512014-04-14 20:24:27 +03001497 intel_runtime_pm_put(dev_priv);
1498
Deepak S669ab5a2014-01-10 15:18:26 +05301499 seq_printf(m, "Video Turbo Mode: %s\n",
1500 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1501 seq_printf(m, "Turbo enabled: %s\n",
1502 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1503 seq_printf(m, "HW control enabled: %s\n",
1504 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1505 seq_printf(m, "SW control enabled: %s\n",
1506 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1507 GEN6_RP_MEDIA_SW_MODE));
1508 seq_printf(m, "RC6 Enabled: %s\n",
1509 yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE |
1510 GEN6_RC_CTL_EI_MODE(1))));
1511 seq_printf(m, "Render Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001512 (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301513 seq_printf(m, "Media Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001514 (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301515
Imre Deak9cc19be2014-04-14 20:24:24 +03001516 seq_printf(m, "Render RC6 residency since boot: %u\n",
1517 I915_READ(VLV_GT_RENDER_RC6));
1518 seq_printf(m, "Media RC6 residency since boot: %u\n",
1519 I915_READ(VLV_GT_MEDIA_RC6));
1520
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001521 return i915_forcewake_domains(m, NULL);
Deepak S669ab5a2014-01-10 15:18:26 +05301522}
1523
Ben Widawsky4d855292011-12-12 19:34:16 -08001524static int gen6_drpc_info(struct seq_file *m)
1525{
David Weinehall36cdd012016-08-22 13:59:31 +03001526 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1527 struct drm_device *dev = &dev_priv->drm;
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001528 u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0;
Akash Goelf2dd7572016-06-27 20:10:01 +05301529 u32 gen9_powergate_enable = 0, gen9_powergate_status = 0;
Daniel Vetter93b525d2012-01-25 13:52:43 +01001530 unsigned forcewake_count;
Damien Lespiauaee56cf2013-06-24 22:59:49 +01001531 int count = 0, ret;
Ben Widawsky4d855292011-12-12 19:34:16 -08001532
1533 ret = mutex_lock_interruptible(&dev->struct_mutex);
1534 if (ret)
1535 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001536 intel_runtime_pm_get(dev_priv);
Ben Widawsky4d855292011-12-12 19:34:16 -08001537
Chris Wilson907b28c2013-07-19 20:36:52 +01001538 spin_lock_irq(&dev_priv->uncore.lock);
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001539 forcewake_count = dev_priv->uncore.fw_domain[FW_DOMAIN_ID_RENDER].wake_count;
Chris Wilson907b28c2013-07-19 20:36:52 +01001540 spin_unlock_irq(&dev_priv->uncore.lock);
Daniel Vetter93b525d2012-01-25 13:52:43 +01001541
1542 if (forcewake_count) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001543 seq_puts(m, "RC information inaccurate because somebody "
1544 "holds a forcewake reference \n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001545 } else {
1546 /* NB: we cannot use forcewake, else we read the wrong values */
1547 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
1548 udelay(10);
1549 seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
1550 }
1551
Ville Syrjälä75aa3f62015-10-22 15:34:56 +03001552 gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS);
Chris Wilsoned71f1b2013-07-19 20:36:56 +01001553 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4, true);
Ben Widawsky4d855292011-12-12 19:34:16 -08001554
1555 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1556 rcctl1 = I915_READ(GEN6_RC_CONTROL);
David Weinehall36cdd012016-08-22 13:59:31 +03001557 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301558 gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE);
1559 gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS);
1560 }
Ben Widawsky4d855292011-12-12 19:34:16 -08001561 mutex_unlock(&dev->struct_mutex);
Ben Widawsky44cbd332012-11-06 14:36:36 +00001562 mutex_lock(&dev_priv->rps.hw_lock);
1563 sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
1564 mutex_unlock(&dev_priv->rps.hw_lock);
Ben Widawsky4d855292011-12-12 19:34:16 -08001565
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001566 intel_runtime_pm_put(dev_priv);
1567
Ben Widawsky4d855292011-12-12 19:34:16 -08001568 seq_printf(m, "Video Turbo Mode: %s\n",
1569 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1570 seq_printf(m, "HW control enabled: %s\n",
1571 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1572 seq_printf(m, "SW control enabled: %s\n",
1573 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1574 GEN6_RP_MEDIA_SW_MODE));
Eric Anholtfff24e22012-01-23 16:14:05 -08001575 seq_printf(m, "RC1e Enabled: %s\n",
Ben Widawsky4d855292011-12-12 19:34:16 -08001576 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1577 seq_printf(m, "RC6 Enabled: %s\n",
1578 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
David Weinehall36cdd012016-08-22 13:59:31 +03001579 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301580 seq_printf(m, "Render Well Gating Enabled: %s\n",
1581 yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE));
1582 seq_printf(m, "Media Well Gating Enabled: %s\n",
1583 yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE));
1584 }
Ben Widawsky4d855292011-12-12 19:34:16 -08001585 seq_printf(m, "Deep RC6 Enabled: %s\n",
1586 yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
1587 seq_printf(m, "Deepest RC6 Enabled: %s\n",
1588 yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001589 seq_puts(m, "Current RC state: ");
Ben Widawsky4d855292011-12-12 19:34:16 -08001590 switch (gt_core_status & GEN6_RCn_MASK) {
1591 case GEN6_RC0:
1592 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
Damien Lespiau267f0c92013-06-24 22:59:48 +01001593 seq_puts(m, "Core Power Down\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001594 else
Damien Lespiau267f0c92013-06-24 22:59:48 +01001595 seq_puts(m, "on\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001596 break;
1597 case GEN6_RC3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001598 seq_puts(m, "RC3\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001599 break;
1600 case GEN6_RC6:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001601 seq_puts(m, "RC6\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001602 break;
1603 case GEN6_RC7:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001604 seq_puts(m, "RC7\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001605 break;
1606 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001607 seq_puts(m, "Unknown\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001608 break;
1609 }
1610
1611 seq_printf(m, "Core Power Down: %s\n",
1612 yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
David Weinehall36cdd012016-08-22 13:59:31 +03001613 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301614 seq_printf(m, "Render Power Well: %s\n",
1615 (gen9_powergate_status &
1616 GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down");
1617 seq_printf(m, "Media Power Well: %s\n",
1618 (gen9_powergate_status &
1619 GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down");
1620 }
Ben Widawskycce66a22012-03-27 18:59:38 -07001621
1622 /* Not exactly sure what this is */
1623 seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1624 I915_READ(GEN6_GT_GFX_RC6_LOCKED));
1625 seq_printf(m, "RC6 residency since boot: %u\n",
1626 I915_READ(GEN6_GT_GFX_RC6));
1627 seq_printf(m, "RC6+ residency since boot: %u\n",
1628 I915_READ(GEN6_GT_GFX_RC6p));
1629 seq_printf(m, "RC6++ residency since boot: %u\n",
1630 I915_READ(GEN6_GT_GFX_RC6pp));
1631
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001632 seq_printf(m, "RC6 voltage: %dmV\n",
1633 GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff)));
1634 seq_printf(m, "RC6+ voltage: %dmV\n",
1635 GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff)));
1636 seq_printf(m, "RC6++ voltage: %dmV\n",
1637 GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff)));
Akash Goelf2dd7572016-06-27 20:10:01 +05301638 return i915_forcewake_domains(m, NULL);
Ben Widawsky4d855292011-12-12 19:34:16 -08001639}
1640
1641static int i915_drpc_info(struct seq_file *m, void *unused)
1642{
David Weinehall36cdd012016-08-22 13:59:31 +03001643 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ben Widawsky4d855292011-12-12 19:34:16 -08001644
David Weinehall36cdd012016-08-22 13:59:31 +03001645 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Deepak S669ab5a2014-01-10 15:18:26 +05301646 return vlv_drpc_info(m);
David Weinehall36cdd012016-08-22 13:59:31 +03001647 else if (INTEL_GEN(dev_priv) >= 6)
Ben Widawsky4d855292011-12-12 19:34:16 -08001648 return gen6_drpc_info(m);
1649 else
1650 return ironlake_drpc_info(m);
1651}
1652
Daniel Vetter9a851782015-06-18 10:30:22 +02001653static int i915_frontbuffer_tracking(struct seq_file *m, void *unused)
1654{
David Weinehall36cdd012016-08-22 13:59:31 +03001655 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetter9a851782015-06-18 10:30:22 +02001656
1657 seq_printf(m, "FB tracking busy bits: 0x%08x\n",
1658 dev_priv->fb_tracking.busy_bits);
1659
1660 seq_printf(m, "FB tracking flip bits: 0x%08x\n",
1661 dev_priv->fb_tracking.flip_bits);
1662
1663 return 0;
1664}
1665
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001666static int i915_fbc_status(struct seq_file *m, void *unused)
1667{
David Weinehall36cdd012016-08-22 13:59:31 +03001668 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001669
David Weinehall36cdd012016-08-22 13:59:31 +03001670 if (!HAS_FBC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001671 seq_puts(m, "FBC unsupported on this chipset\n");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001672 return 0;
1673 }
1674
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001675 intel_runtime_pm_get(dev_priv);
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001676 mutex_lock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001677
Paulo Zanoni0e631ad2015-10-14 17:45:36 -03001678 if (intel_fbc_is_active(dev_priv))
Damien Lespiau267f0c92013-06-24 22:59:48 +01001679 seq_puts(m, "FBC enabled\n");
Paulo Zanoni2e8144a2015-06-12 14:36:20 -03001680 else
1681 seq_printf(m, "FBC disabled: %s\n",
Paulo Zanonibf6189c2015-10-27 14:50:03 -02001682 dev_priv->fbc.no_fbc_reason);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001683
Paulo Zanoni0fc6a9d2016-10-21 13:55:46 -02001684 if (intel_fbc_is_active(dev_priv) && INTEL_GEN(dev_priv) >= 7) {
1685 uint32_t mask = INTEL_GEN(dev_priv) >= 8 ?
1686 BDW_FBC_COMPRESSION_MASK :
1687 IVB_FBC_COMPRESSION_MASK;
Paulo Zanoni31b9df12015-06-12 14:36:18 -03001688 seq_printf(m, "Compressing: %s\n",
Paulo Zanoni0fc6a9d2016-10-21 13:55:46 -02001689 yesno(I915_READ(FBC_STATUS2) & mask));
1690 }
Paulo Zanoni31b9df12015-06-12 14:36:18 -03001691
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001692 mutex_unlock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001693 intel_runtime_pm_put(dev_priv);
1694
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001695 return 0;
1696}
1697
Rodrigo Vivida46f932014-08-01 02:04:45 -07001698static int i915_fbc_fc_get(void *data, u64 *val)
1699{
David Weinehall36cdd012016-08-22 13:59:31 +03001700 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001701
David Weinehall36cdd012016-08-22 13:59:31 +03001702 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001703 return -ENODEV;
1704
Rodrigo Vivida46f932014-08-01 02:04:45 -07001705 *val = dev_priv->fbc.false_color;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001706
1707 return 0;
1708}
1709
1710static int i915_fbc_fc_set(void *data, u64 val)
1711{
David Weinehall36cdd012016-08-22 13:59:31 +03001712 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001713 u32 reg;
1714
David Weinehall36cdd012016-08-22 13:59:31 +03001715 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001716 return -ENODEV;
1717
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001718 mutex_lock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001719
1720 reg = I915_READ(ILK_DPFC_CONTROL);
1721 dev_priv->fbc.false_color = val;
1722
1723 I915_WRITE(ILK_DPFC_CONTROL, val ?
1724 (reg | FBC_CTL_FALSE_COLOR) :
1725 (reg & ~FBC_CTL_FALSE_COLOR));
1726
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001727 mutex_unlock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001728 return 0;
1729}
1730
1731DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops,
1732 i915_fbc_fc_get, i915_fbc_fc_set,
1733 "%llu\n");
1734
Paulo Zanoni92d44622013-05-31 16:33:24 -03001735static int i915_ips_status(struct seq_file *m, void *unused)
1736{
David Weinehall36cdd012016-08-22 13:59:31 +03001737 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni92d44622013-05-31 16:33:24 -03001738
David Weinehall36cdd012016-08-22 13:59:31 +03001739 if (!HAS_IPS(dev_priv)) {
Paulo Zanoni92d44622013-05-31 16:33:24 -03001740 seq_puts(m, "not supported\n");
1741 return 0;
1742 }
1743
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001744 intel_runtime_pm_get(dev_priv);
1745
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001746 seq_printf(m, "Enabled by kernel parameter: %s\n",
1747 yesno(i915.enable_ips));
1748
David Weinehall36cdd012016-08-22 13:59:31 +03001749 if (INTEL_GEN(dev_priv) >= 8) {
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001750 seq_puts(m, "Currently: unknown\n");
1751 } else {
1752 if (I915_READ(IPS_CTL) & IPS_ENABLE)
1753 seq_puts(m, "Currently: enabled\n");
1754 else
1755 seq_puts(m, "Currently: disabled\n");
1756 }
Paulo Zanoni92d44622013-05-31 16:33:24 -03001757
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001758 intel_runtime_pm_put(dev_priv);
1759
Paulo Zanoni92d44622013-05-31 16:33:24 -03001760 return 0;
1761}
1762
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001763static int i915_sr_status(struct seq_file *m, void *unused)
1764{
David Weinehall36cdd012016-08-22 13:59:31 +03001765 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001766 bool sr_enabled = false;
1767
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001768 intel_runtime_pm_get(dev_priv);
Chris Wilson9c870d02016-10-24 13:42:15 +01001769 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001770
David Weinehall36cdd012016-08-22 13:59:31 +03001771 if (HAS_PCH_SPLIT(dev_priv))
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001772 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
Jani Nikulac0f86832016-12-07 12:13:04 +02001773 else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) ||
David Weinehall36cdd012016-08-22 13:59:31 +03001774 IS_I945G(dev_priv) || IS_I945GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001775 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001776 else if (IS_I915GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001777 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001778 else if (IS_PINEVIEW(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001779 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001780 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Ander Conselvan de Oliveira77b64552015-06-02 14:17:47 +03001781 sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001782
Chris Wilson9c870d02016-10-24 13:42:15 +01001783 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001784 intel_runtime_pm_put(dev_priv);
1785
Tvrtko Ursulin08c4d7f2016-11-17 12:30:14 +00001786 seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled));
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001787
1788 return 0;
1789}
1790
Jesse Barnes7648fa92010-05-20 14:28:11 -07001791static int i915_emon_status(struct seq_file *m, void *unused)
1792{
David Weinehall36cdd012016-08-22 13:59:31 +03001793 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1794 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001795 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +01001796 int ret;
1797
David Weinehall36cdd012016-08-22 13:59:31 +03001798 if (!IS_GEN5(dev_priv))
Chris Wilson582be6b2012-04-30 19:35:02 +01001799 return -ENODEV;
1800
Chris Wilsonde227ef2010-07-03 07:58:38 +01001801 ret = mutex_lock_interruptible(&dev->struct_mutex);
1802 if (ret)
1803 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001804
1805 temp = i915_mch_val(dev_priv);
1806 chipset = i915_chipset_val(dev_priv);
1807 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +01001808 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001809
1810 seq_printf(m, "GMCH temp: %ld\n", temp);
1811 seq_printf(m, "Chipset power: %ld\n", chipset);
1812 seq_printf(m, "GFX power: %ld\n", gfx);
1813 seq_printf(m, "Total power: %ld\n", chipset + gfx);
1814
1815 return 0;
1816}
1817
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001818static int i915_ring_freq_table(struct seq_file *m, void *unused)
1819{
David Weinehall36cdd012016-08-22 13:59:31 +03001820 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001821 int ret = 0;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001822 int gpu_freq, ia_freq;
Akash Goelf936ec32015-06-29 14:50:22 +05301823 unsigned int max_gpu_freq, min_gpu_freq;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001824
Carlos Santa26310342016-08-17 12:30:41 -07001825 if (!HAS_LLC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001826 seq_puts(m, "unsupported on this chipset\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001827 return 0;
1828 }
1829
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001830 intel_runtime_pm_get(dev_priv);
1831
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001832 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001833 if (ret)
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001834 goto out;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001835
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001836 if (IS_GEN9_BC(dev_priv)) {
Akash Goelf936ec32015-06-29 14:50:22 +05301837 /* Convert GT frequency to 50 HZ units */
1838 min_gpu_freq =
1839 dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER;
1840 max_gpu_freq =
1841 dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER;
1842 } else {
1843 min_gpu_freq = dev_priv->rps.min_freq_softlimit;
1844 max_gpu_freq = dev_priv->rps.max_freq_softlimit;
1845 }
1846
Damien Lespiau267f0c92013-06-24 22:59:48 +01001847 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001848
Akash Goelf936ec32015-06-29 14:50:22 +05301849 for (gpu_freq = min_gpu_freq; gpu_freq <= max_gpu_freq; gpu_freq++) {
Ben Widawsky42c05262012-09-26 10:34:00 -07001850 ia_freq = gpu_freq;
1851 sandybridge_pcode_read(dev_priv,
1852 GEN6_PCODE_READ_MIN_FREQ_TABLE,
1853 &ia_freq);
Chris Wilson3ebecd02013-04-12 19:10:13 +01001854 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n",
Akash Goelf936ec32015-06-29 14:50:22 +05301855 intel_gpu_freq(dev_priv, (gpu_freq *
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001856 (IS_GEN9_BC(dev_priv) ?
1857 GEN9_FREQ_SCALER : 1))),
Chris Wilson3ebecd02013-04-12 19:10:13 +01001858 ((ia_freq >> 0) & 0xff) * 100,
1859 ((ia_freq >> 8) & 0xff) * 100);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001860 }
1861
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001862 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001863
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001864out:
1865 intel_runtime_pm_put(dev_priv);
1866 return ret;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001867}
1868
Chris Wilson44834a62010-08-19 16:09:23 +01001869static int i915_opregion(struct seq_file *m, void *unused)
1870{
David Weinehall36cdd012016-08-22 13:59:31 +03001871 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1872 struct drm_device *dev = &dev_priv->drm;
Chris Wilson44834a62010-08-19 16:09:23 +01001873 struct intel_opregion *opregion = &dev_priv->opregion;
1874 int ret;
1875
1876 ret = mutex_lock_interruptible(&dev->struct_mutex);
1877 if (ret)
Daniel Vetter0d38f002012-04-21 22:49:10 +02001878 goto out;
Chris Wilson44834a62010-08-19 16:09:23 +01001879
Jani Nikula2455a8e2015-12-14 12:50:53 +02001880 if (opregion->header)
1881 seq_write(m, opregion->header, OPREGION_SIZE);
Chris Wilson44834a62010-08-19 16:09:23 +01001882
1883 mutex_unlock(&dev->struct_mutex);
1884
Daniel Vetter0d38f002012-04-21 22:49:10 +02001885out:
Chris Wilson44834a62010-08-19 16:09:23 +01001886 return 0;
1887}
1888
Jani Nikulaada8f952015-12-15 13:17:12 +02001889static int i915_vbt(struct seq_file *m, void *unused)
1890{
David Weinehall36cdd012016-08-22 13:59:31 +03001891 struct intel_opregion *opregion = &node_to_i915(m->private)->opregion;
Jani Nikulaada8f952015-12-15 13:17:12 +02001892
1893 if (opregion->vbt)
1894 seq_write(m, opregion->vbt, opregion->vbt_size);
1895
1896 return 0;
1897}
1898
Chris Wilson37811fc2010-08-25 22:45:57 +01001899static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
1900{
David Weinehall36cdd012016-08-22 13:59:31 +03001901 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1902 struct drm_device *dev = &dev_priv->drm;
Namrta Salonieb13b8402015-11-27 13:43:11 +05301903 struct intel_framebuffer *fbdev_fb = NULL;
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001904 struct drm_framebuffer *drm_fb;
Chris Wilson188c1ab2016-04-03 14:14:20 +01001905 int ret;
1906
1907 ret = mutex_lock_interruptible(&dev->struct_mutex);
1908 if (ret)
1909 return ret;
Chris Wilson37811fc2010-08-25 22:45:57 +01001910
Daniel Vetter06957262015-08-10 13:34:08 +02001911#ifdef CONFIG_DRM_FBDEV_EMULATION
David Weinehall36cdd012016-08-22 13:59:31 +03001912 if (dev_priv->fbdev) {
1913 fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb);
Chris Wilson37811fc2010-08-25 22:45:57 +01001914
Chris Wilson25bcce92016-07-02 15:36:00 +01001915 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
1916 fbdev_fb->base.width,
1917 fbdev_fb->base.height,
Ville Syrjäläb00c6002016-12-14 23:31:35 +02001918 fbdev_fb->base.format->depth,
Ville Syrjälä272725c2016-12-14 23:32:20 +02001919 fbdev_fb->base.format->cpp[0] * 8,
Ville Syrjäläbae781b2016-11-16 13:33:16 +02001920 fbdev_fb->base.modifier,
Chris Wilson25bcce92016-07-02 15:36:00 +01001921 drm_framebuffer_read_refcount(&fbdev_fb->base));
1922 describe_obj(m, fbdev_fb->obj);
1923 seq_putc(m, '\n');
1924 }
Daniel Vetter4520f532013-10-09 09:18:51 +02001925#endif
Chris Wilson37811fc2010-08-25 22:45:57 +01001926
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001927 mutex_lock(&dev->mode_config.fb_lock);
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001928 drm_for_each_fb(drm_fb, dev) {
Namrta Salonieb13b8402015-11-27 13:43:11 +05301929 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
1930 if (fb == fbdev_fb)
Chris Wilson37811fc2010-08-25 22:45:57 +01001931 continue;
1932
Tvrtko Ursulinc1ca506d2015-02-10 17:16:07 +00001933 seq_printf(m, "user size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
Chris Wilson37811fc2010-08-25 22:45:57 +01001934 fb->base.width,
1935 fb->base.height,
Ville Syrjäläb00c6002016-12-14 23:31:35 +02001936 fb->base.format->depth,
Ville Syrjälä272725c2016-12-14 23:32:20 +02001937 fb->base.format->cpp[0] * 8,
Ville Syrjäläbae781b2016-11-16 13:33:16 +02001938 fb->base.modifier,
Dave Airlie747a5982016-04-15 15:10:35 +10001939 drm_framebuffer_read_refcount(&fb->base));
Chris Wilson05394f32010-11-08 19:18:58 +00001940 describe_obj(m, fb->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001941 seq_putc(m, '\n');
Chris Wilson37811fc2010-08-25 22:45:57 +01001942 }
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001943 mutex_unlock(&dev->mode_config.fb_lock);
Chris Wilson188c1ab2016-04-03 14:14:20 +01001944 mutex_unlock(&dev->struct_mutex);
Chris Wilson37811fc2010-08-25 22:45:57 +01001945
1946 return 0;
1947}
1948
Chris Wilson7e37f882016-08-02 22:50:21 +01001949static void describe_ctx_ring(struct seq_file *m, struct intel_ring *ring)
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001950{
1951 seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)",
Chris Wilson7e37f882016-08-02 22:50:21 +01001952 ring->space, ring->head, ring->tail,
1953 ring->last_retired_head);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001954}
1955
Ben Widawskye76d3632011-03-19 18:14:29 -07001956static int i915_context_status(struct seq_file *m, void *unused)
1957{
David Weinehall36cdd012016-08-22 13:59:31 +03001958 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1959 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001960 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01001961 struct i915_gem_context *ctx;
Akash Goel3b3f1652016-10-13 22:44:48 +05301962 enum intel_engine_id id;
Dave Gordonc3232b12016-03-23 18:19:53 +00001963 int ret;
Ben Widawskye76d3632011-03-19 18:14:29 -07001964
Daniel Vetterf3d28872014-05-29 23:23:08 +02001965 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07001966 if (ret)
1967 return ret;
1968
Ben Widawskya33afea2013-09-17 21:12:45 -07001969 list_for_each_entry(ctx, &dev_priv->context_list, link) {
Chris Wilson5d1808e2016-04-28 09:56:51 +01001970 seq_printf(m, "HW context %u ", ctx->hw_id);
Chris Wilsonc84455b2016-08-15 10:49:08 +01001971 if (ctx->pid) {
Chris Wilsond28b99a2016-05-24 14:53:39 +01001972 struct task_struct *task;
1973
Chris Wilsonc84455b2016-08-15 10:49:08 +01001974 task = get_pid_task(ctx->pid, PIDTYPE_PID);
Chris Wilsond28b99a2016-05-24 14:53:39 +01001975 if (task) {
1976 seq_printf(m, "(%s [%d]) ",
1977 task->comm, task->pid);
1978 put_task_struct(task);
1979 }
Chris Wilsonc84455b2016-08-15 10:49:08 +01001980 } else if (IS_ERR(ctx->file_priv)) {
1981 seq_puts(m, "(deleted) ");
Chris Wilsond28b99a2016-05-24 14:53:39 +01001982 } else {
1983 seq_puts(m, "(kernel) ");
1984 }
1985
Chris Wilsonbca44d82016-05-24 14:53:41 +01001986 seq_putc(m, ctx->remap_slice ? 'R' : 'r');
1987 seq_putc(m, '\n');
Ben Widawskya33afea2013-09-17 21:12:45 -07001988
Akash Goel3b3f1652016-10-13 22:44:48 +05301989 for_each_engine(engine, dev_priv, id) {
Chris Wilsonbca44d82016-05-24 14:53:41 +01001990 struct intel_context *ce = &ctx->engine[engine->id];
1991
1992 seq_printf(m, "%s: ", engine->name);
1993 seq_putc(m, ce->initialised ? 'I' : 'i');
1994 if (ce->state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001995 describe_obj(m, ce->state->obj);
Chris Wilsondca33ec2016-08-02 22:50:20 +01001996 if (ce->ring)
Chris Wilson7e37f882016-08-02 22:50:21 +01001997 describe_ctx_ring(m, ce->ring);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001998 seq_putc(m, '\n');
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001999 }
2000
Ben Widawskya33afea2013-09-17 21:12:45 -07002001 seq_putc(m, '\n');
Ben Widawskya168c292013-02-14 15:05:12 -08002002 }
2003
Daniel Vetterf3d28872014-05-29 23:23:08 +02002004 mutex_unlock(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07002005
2006 return 0;
2007}
2008
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002009static void i915_dump_lrc_obj(struct seq_file *m,
Chris Wilsone2efd132016-05-24 14:53:34 +01002010 struct i915_gem_context *ctx,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +00002011 struct intel_engine_cs *engine)
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002012{
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002013 struct i915_vma *vma = ctx->engine[engine->id].state;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002014 struct page *page;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002015 int j;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002016
Chris Wilson7069b142016-04-28 09:56:52 +01002017 seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id);
2018
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002019 if (!vma) {
2020 seq_puts(m, "\tFake context\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002021 return;
2022 }
2023
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002024 if (vma->flags & I915_VMA_GLOBAL_BIND)
2025 seq_printf(m, "\tBound in GGTT at 0x%08x\n",
Chris Wilsonbde13eb2016-08-15 10:49:07 +01002026 i915_ggtt_offset(vma));
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002027
Chris Wilsona4f5ea62016-10-28 13:58:35 +01002028 if (i915_gem_object_pin_pages(vma->obj)) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002029 seq_puts(m, "\tFailed to get pages for context object\n\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002030 return;
2031 }
2032
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002033 page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN);
2034 if (page) {
2035 u32 *reg_state = kmap_atomic(page);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002036
2037 for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002038 seq_printf(m,
2039 "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n",
2040 j * 4,
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002041 reg_state[j], reg_state[j + 1],
2042 reg_state[j + 2], reg_state[j + 3]);
2043 }
2044 kunmap_atomic(reg_state);
2045 }
2046
Chris Wilsona4f5ea62016-10-28 13:58:35 +01002047 i915_gem_object_unpin_pages(vma->obj);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002048 seq_putc(m, '\n');
2049}
2050
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01002051static int i915_dump_lrc(struct seq_file *m, void *unused)
2052{
David Weinehall36cdd012016-08-22 13:59:31 +03002053 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2054 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002055 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01002056 struct i915_gem_context *ctx;
Akash Goel3b3f1652016-10-13 22:44:48 +05302057 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002058 int ret;
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01002059
2060 if (!i915.enable_execlists) {
2061 seq_printf(m, "Logical Ring Contexts are disabled\n");
2062 return 0;
2063 }
2064
2065 ret = mutex_lock_interruptible(&dev->struct_mutex);
2066 if (ret)
2067 return ret;
2068
Dave Gordone28e4042016-01-19 19:02:55 +00002069 list_for_each_entry(ctx, &dev_priv->context_list, link)
Akash Goel3b3f1652016-10-13 22:44:48 +05302070 for_each_engine(engine, dev_priv, id)
Chris Wilson24f1d3c2016-04-28 09:56:53 +01002071 i915_dump_lrc_obj(m, ctx, engine);
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01002072
2073 mutex_unlock(&dev->struct_mutex);
2074
2075 return 0;
2076}
2077
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002078static const char *swizzle_string(unsigned swizzle)
2079{
Damien Lespiauaee56cf2013-06-24 22:59:49 +01002080 switch (swizzle) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002081 case I915_BIT_6_SWIZZLE_NONE:
2082 return "none";
2083 case I915_BIT_6_SWIZZLE_9:
2084 return "bit9";
2085 case I915_BIT_6_SWIZZLE_9_10:
2086 return "bit9/bit10";
2087 case I915_BIT_6_SWIZZLE_9_11:
2088 return "bit9/bit11";
2089 case I915_BIT_6_SWIZZLE_9_10_11:
2090 return "bit9/bit10/bit11";
2091 case I915_BIT_6_SWIZZLE_9_17:
2092 return "bit9/bit17";
2093 case I915_BIT_6_SWIZZLE_9_10_17:
2094 return "bit9/bit10/bit17";
2095 case I915_BIT_6_SWIZZLE_UNKNOWN:
Masanari Iida8a168ca2012-12-29 02:00:09 +09002096 return "unknown";
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002097 }
2098
2099 return "bug";
2100}
2101
2102static int i915_swizzle_info(struct seq_file *m, void *data)
2103{
David Weinehall36cdd012016-08-22 13:59:31 +03002104 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002105
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002106 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02002107
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002108 seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
2109 swizzle_string(dev_priv->mm.bit_6_swizzle_x));
2110 seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
2111 swizzle_string(dev_priv->mm.bit_6_swizzle_y));
2112
David Weinehall36cdd012016-08-22 13:59:31 +03002113 if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002114 seq_printf(m, "DDC = 0x%08x\n",
2115 I915_READ(DCC));
Daniel Vetter656bfa32014-11-20 09:26:30 +01002116 seq_printf(m, "DDC2 = 0x%08x\n",
2117 I915_READ(DCC2));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002118 seq_printf(m, "C0DRB3 = 0x%04x\n",
2119 I915_READ16(C0DRB3));
2120 seq_printf(m, "C1DRB3 = 0x%04x\n",
2121 I915_READ16(C1DRB3));
David Weinehall36cdd012016-08-22 13:59:31 +03002122 } else if (INTEL_GEN(dev_priv) >= 6) {
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002123 seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
2124 I915_READ(MAD_DIMM_C0));
2125 seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
2126 I915_READ(MAD_DIMM_C1));
2127 seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
2128 I915_READ(MAD_DIMM_C2));
2129 seq_printf(m, "TILECTL = 0x%08x\n",
2130 I915_READ(TILECTL));
David Weinehall36cdd012016-08-22 13:59:31 +03002131 if (INTEL_GEN(dev_priv) >= 8)
Ben Widawsky9d3203e2013-11-02 21:07:14 -07002132 seq_printf(m, "GAMTARBMODE = 0x%08x\n",
2133 I915_READ(GAMTARBMODE));
2134 else
2135 seq_printf(m, "ARB_MODE = 0x%08x\n",
2136 I915_READ(ARB_MODE));
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002137 seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
2138 I915_READ(DISP_ARB_CTL));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002139 }
Daniel Vetter656bfa32014-11-20 09:26:30 +01002140
2141 if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES)
2142 seq_puts(m, "L-shaped memory detected\n");
2143
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002144 intel_runtime_pm_put(dev_priv);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002145
2146 return 0;
2147}
2148
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002149static int per_file_ctx(int id, void *ptr, void *data)
2150{
Chris Wilsone2efd132016-05-24 14:53:34 +01002151 struct i915_gem_context *ctx = ptr;
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002152 struct seq_file *m = data;
Daniel Vetterae6c4802014-08-06 15:04:53 +02002153 struct i915_hw_ppgtt *ppgtt = ctx->ppgtt;
2154
2155 if (!ppgtt) {
2156 seq_printf(m, " no ppgtt for context %d\n",
2157 ctx->user_handle);
2158 return 0;
2159 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002160
Oscar Mateof83d6512014-05-22 14:13:38 +01002161 if (i915_gem_context_is_default(ctx))
2162 seq_puts(m, " default context:\n");
2163 else
Oscar Mateo821d66d2014-07-03 16:28:00 +01002164 seq_printf(m, " context %d:\n", ctx->user_handle);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002165 ppgtt->debug_dump(ppgtt, m);
2166
2167 return 0;
2168}
2169
David Weinehall36cdd012016-08-22 13:59:31 +03002170static void gen8_ppgtt_info(struct seq_file *m,
2171 struct drm_i915_private *dev_priv)
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002172{
Ben Widawsky77df6772013-11-02 21:07:30 -07002173 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
Akash Goel3b3f1652016-10-13 22:44:48 +05302174 struct intel_engine_cs *engine;
2175 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002176 int i;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002177
Ben Widawsky77df6772013-11-02 21:07:30 -07002178 if (!ppgtt)
2179 return;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002180
Akash Goel3b3f1652016-10-13 22:44:48 +05302181 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002182 seq_printf(m, "%s\n", engine->name);
Ben Widawsky77df6772013-11-02 21:07:30 -07002183 for (i = 0; i < 4; i++) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002184 u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i));
Ben Widawsky77df6772013-11-02 21:07:30 -07002185 pdp <<= 32;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002186 pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i));
Ville Syrjäläa2a5b152014-03-31 18:17:16 +03002187 seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp);
Ben Widawsky77df6772013-11-02 21:07:30 -07002188 }
2189 }
2190}
2191
David Weinehall36cdd012016-08-22 13:59:31 +03002192static void gen6_ppgtt_info(struct seq_file *m,
2193 struct drm_i915_private *dev_priv)
Ben Widawsky77df6772013-11-02 21:07:30 -07002194{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002195 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05302196 enum intel_engine_id id;
Ben Widawsky77df6772013-11-02 21:07:30 -07002197
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002198 if (IS_GEN6(dev_priv))
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002199 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
2200
Akash Goel3b3f1652016-10-13 22:44:48 +05302201 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002202 seq_printf(m, "%s\n", engine->name);
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002203 if (IS_GEN7(dev_priv))
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002204 seq_printf(m, "GFX_MODE: 0x%08x\n",
2205 I915_READ(RING_MODE_GEN7(engine)));
2206 seq_printf(m, "PP_DIR_BASE: 0x%08x\n",
2207 I915_READ(RING_PP_DIR_BASE(engine)));
2208 seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n",
2209 I915_READ(RING_PP_DIR_BASE_READ(engine)));
2210 seq_printf(m, "PP_DIR_DCLV: 0x%08x\n",
2211 I915_READ(RING_PP_DIR_DCLV(engine)));
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002212 }
2213 if (dev_priv->mm.aliasing_ppgtt) {
2214 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
2215
Damien Lespiau267f0c92013-06-24 22:59:48 +01002216 seq_puts(m, "aliasing PPGTT:\n");
Mika Kuoppala44159dd2015-06-25 18:35:07 +03002217 seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd.base.ggtt_offset);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002218
Ben Widawsky87d60b62013-12-06 14:11:29 -08002219 ppgtt->debug_dump(ppgtt, m);
Daniel Vetterae6c4802014-08-06 15:04:53 +02002220 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002221
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002222 seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
Ben Widawsky77df6772013-11-02 21:07:30 -07002223}
2224
2225static int i915_ppgtt_info(struct seq_file *m, void *data)
2226{
David Weinehall36cdd012016-08-22 13:59:31 +03002227 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2228 struct drm_device *dev = &dev_priv->drm;
Michel Thierryea91e402015-07-29 17:23:57 +01002229 struct drm_file *file;
Chris Wilson637ee292016-08-22 14:28:20 +01002230 int ret;
Ben Widawsky77df6772013-11-02 21:07:30 -07002231
Chris Wilson637ee292016-08-22 14:28:20 +01002232 mutex_lock(&dev->filelist_mutex);
2233 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawsky77df6772013-11-02 21:07:30 -07002234 if (ret)
Chris Wilson637ee292016-08-22 14:28:20 +01002235 goto out_unlock;
2236
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002237 intel_runtime_pm_get(dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002238
David Weinehall36cdd012016-08-22 13:59:31 +03002239 if (INTEL_GEN(dev_priv) >= 8)
2240 gen8_ppgtt_info(m, dev_priv);
2241 else if (INTEL_GEN(dev_priv) >= 6)
2242 gen6_ppgtt_info(m, dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002243
Michel Thierryea91e402015-07-29 17:23:57 +01002244 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2245 struct drm_i915_file_private *file_priv = file->driver_priv;
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002246 struct task_struct *task;
Michel Thierryea91e402015-07-29 17:23:57 +01002247
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002248 task = get_pid_task(file->pid, PIDTYPE_PID);
Dan Carpenter06812762015-10-02 18:14:22 +03002249 if (!task) {
2250 ret = -ESRCH;
Chris Wilson637ee292016-08-22 14:28:20 +01002251 goto out_rpm;
Dan Carpenter06812762015-10-02 18:14:22 +03002252 }
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002253 seq_printf(m, "\nproc: %s\n", task->comm);
2254 put_task_struct(task);
Michel Thierryea91e402015-07-29 17:23:57 +01002255 idr_for_each(&file_priv->context_idr, per_file_ctx,
2256 (void *)(unsigned long)m);
2257 }
2258
Chris Wilson637ee292016-08-22 14:28:20 +01002259out_rpm:
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002260 intel_runtime_pm_put(dev_priv);
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002261 mutex_unlock(&dev->struct_mutex);
Chris Wilson637ee292016-08-22 14:28:20 +01002262out_unlock:
2263 mutex_unlock(&dev->filelist_mutex);
Dan Carpenter06812762015-10-02 18:14:22 +03002264 return ret;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002265}
2266
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002267static int count_irq_waiters(struct drm_i915_private *i915)
2268{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002269 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05302270 enum intel_engine_id id;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002271 int count = 0;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002272
Akash Goel3b3f1652016-10-13 22:44:48 +05302273 for_each_engine(engine, i915, id)
Chris Wilson688e6c72016-07-01 17:23:15 +01002274 count += intel_engine_has_waiter(engine);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002275
2276 return count;
2277}
2278
Chris Wilson7466c292016-08-15 09:49:33 +01002279static const char *rps_power_to_str(unsigned int power)
2280{
2281 static const char * const strings[] = {
2282 [LOW_POWER] = "low power",
2283 [BETWEEN] = "mixed",
2284 [HIGH_POWER] = "high power",
2285 };
2286
2287 if (power >= ARRAY_SIZE(strings) || !strings[power])
2288 return "unknown";
2289
2290 return strings[power];
2291}
2292
Chris Wilson1854d5c2015-04-07 16:20:32 +01002293static int i915_rps_boost_info(struct seq_file *m, void *data)
2294{
David Weinehall36cdd012016-08-22 13:59:31 +03002295 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2296 struct drm_device *dev = &dev_priv->drm;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002297 struct drm_file *file;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002298
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002299 seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled);
Chris Wilson28176ef2016-10-28 13:58:56 +01002300 seq_printf(m, "GPU busy? %s [%d requests]\n",
2301 yesno(dev_priv->gt.awake), dev_priv->gt.active_requests);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002302 seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv));
Chris Wilson7466c292016-08-15 09:49:33 +01002303 seq_printf(m, "Frequency requested %d\n",
2304 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
2305 seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n",
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002306 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq),
2307 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit),
2308 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit),
2309 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
Chris Wilson7466c292016-08-15 09:49:33 +01002310 seq_printf(m, " idle:%d, efficient:%d, boost:%d\n",
2311 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq),
2312 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq),
2313 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002314
2315 mutex_lock(&dev->filelist_mutex);
Chris Wilson8d3afd72015-05-21 21:01:47 +01002316 spin_lock(&dev_priv->rps.client_lock);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002317 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2318 struct drm_i915_file_private *file_priv = file->driver_priv;
2319 struct task_struct *task;
2320
2321 rcu_read_lock();
2322 task = pid_task(file->pid, PIDTYPE_PID);
2323 seq_printf(m, "%s [%d]: %d boosts%s\n",
2324 task ? task->comm : "<unknown>",
2325 task ? task->pid : -1,
Chris Wilson2e1b8732015-04-27 13:41:22 +01002326 file_priv->rps.boosts,
2327 list_empty(&file_priv->rps.link) ? "" : ", active");
Chris Wilson1854d5c2015-04-07 16:20:32 +01002328 rcu_read_unlock();
2329 }
Chris Wilson197be2a2016-07-20 09:21:13 +01002330 seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts);
Chris Wilson8d3afd72015-05-21 21:01:47 +01002331 spin_unlock(&dev_priv->rps.client_lock);
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002332 mutex_unlock(&dev->filelist_mutex);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002333
Chris Wilson7466c292016-08-15 09:49:33 +01002334 if (INTEL_GEN(dev_priv) >= 6 &&
2335 dev_priv->rps.enabled &&
Chris Wilson28176ef2016-10-28 13:58:56 +01002336 dev_priv->gt.active_requests) {
Chris Wilson7466c292016-08-15 09:49:33 +01002337 u32 rpup, rpupei;
2338 u32 rpdown, rpdownei;
2339
2340 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
2341 rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK;
2342 rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK;
2343 rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK;
2344 rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK;
2345 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
2346
2347 seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n",
2348 rps_power_to_str(dev_priv->rps.power));
2349 seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n",
2350 100 * rpup / rpupei,
2351 dev_priv->rps.up_threshold);
2352 seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n",
2353 100 * rpdown / rpdownei,
2354 dev_priv->rps.down_threshold);
2355 } else {
2356 seq_puts(m, "\nRPS Autotuning inactive\n");
2357 }
2358
Chris Wilson8d3afd72015-05-21 21:01:47 +01002359 return 0;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002360}
2361
Ben Widawsky63573eb2013-07-04 11:02:07 -07002362static int i915_llc(struct seq_file *m, void *data)
2363{
David Weinehall36cdd012016-08-22 13:59:31 +03002364 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002365 const bool edram = INTEL_GEN(dev_priv) > 8;
Ben Widawsky63573eb2013-07-04 11:02:07 -07002366
David Weinehall36cdd012016-08-22 13:59:31 +03002367 seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv)));
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002368 seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC",
2369 intel_uncore_edram_size(dev_priv)/1024/1024);
Ben Widawsky63573eb2013-07-04 11:02:07 -07002370
2371 return 0;
2372}
2373
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002374static int i915_huc_load_status_info(struct seq_file *m, void *data)
2375{
2376 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2377 struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
2378
2379 if (!HAS_HUC_UCODE(dev_priv))
2380 return 0;
2381
2382 seq_puts(m, "HuC firmware status:\n");
2383 seq_printf(m, "\tpath: %s\n", huc_fw->path);
2384 seq_printf(m, "\tfetch: %s\n",
2385 intel_uc_fw_status_repr(huc_fw->fetch_status));
2386 seq_printf(m, "\tload: %s\n",
2387 intel_uc_fw_status_repr(huc_fw->load_status));
2388 seq_printf(m, "\tversion wanted: %d.%d\n",
2389 huc_fw->major_ver_wanted, huc_fw->minor_ver_wanted);
2390 seq_printf(m, "\tversion found: %d.%d\n",
2391 huc_fw->major_ver_found, huc_fw->minor_ver_found);
2392 seq_printf(m, "\theader: offset is %d; size = %d\n",
2393 huc_fw->header_offset, huc_fw->header_size);
2394 seq_printf(m, "\tuCode: offset is %d; size = %d\n",
2395 huc_fw->ucode_offset, huc_fw->ucode_size);
2396 seq_printf(m, "\tRSA: offset is %d; size = %d\n",
2397 huc_fw->rsa_offset, huc_fw->rsa_size);
2398
2399 seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2));
2400
2401 return 0;
2402}
2403
Alex Daifdf5d352015-08-12 15:43:37 +01002404static int i915_guc_load_status_info(struct seq_file *m, void *data)
2405{
David Weinehall36cdd012016-08-22 13:59:31 +03002406 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002407 struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
Alex Daifdf5d352015-08-12 15:43:37 +01002408 u32 tmp, i;
2409
Joonas Lahtinen2d1fe072016-04-07 11:08:05 +03002410 if (!HAS_GUC_UCODE(dev_priv))
Alex Daifdf5d352015-08-12 15:43:37 +01002411 return 0;
2412
2413 seq_printf(m, "GuC firmware status:\n");
2414 seq_printf(m, "\tpath: %s\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002415 guc_fw->path);
Alex Daifdf5d352015-08-12 15:43:37 +01002416 seq_printf(m, "\tfetch: %s\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002417 intel_uc_fw_status_repr(guc_fw->fetch_status));
Alex Daifdf5d352015-08-12 15:43:37 +01002418 seq_printf(m, "\tload: %s\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002419 intel_uc_fw_status_repr(guc_fw->load_status));
Alex Daifdf5d352015-08-12 15:43:37 +01002420 seq_printf(m, "\tversion wanted: %d.%d\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002421 guc_fw->major_ver_wanted, guc_fw->minor_ver_wanted);
Alex Daifdf5d352015-08-12 15:43:37 +01002422 seq_printf(m, "\tversion found: %d.%d\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002423 guc_fw->major_ver_found, guc_fw->minor_ver_found);
Alex Daifeda33e2015-10-19 16:10:54 -07002424 seq_printf(m, "\theader: offset is %d; size = %d\n",
2425 guc_fw->header_offset, guc_fw->header_size);
2426 seq_printf(m, "\tuCode: offset is %d; size = %d\n",
2427 guc_fw->ucode_offset, guc_fw->ucode_size);
2428 seq_printf(m, "\tRSA: offset is %d; size = %d\n",
2429 guc_fw->rsa_offset, guc_fw->rsa_size);
Alex Daifdf5d352015-08-12 15:43:37 +01002430
2431 tmp = I915_READ(GUC_STATUS);
2432
2433 seq_printf(m, "\nGuC status 0x%08x:\n", tmp);
2434 seq_printf(m, "\tBootrom status = 0x%x\n",
2435 (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT);
2436 seq_printf(m, "\tuKernel status = 0x%x\n",
2437 (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT);
2438 seq_printf(m, "\tMIA Core status = 0x%x\n",
2439 (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT);
2440 seq_puts(m, "\nScratch registers:\n");
2441 for (i = 0; i < 16; i++)
2442 seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i)));
2443
2444 return 0;
2445}
2446
Akash Goel5aa1ee42016-10-12 21:54:36 +05302447static void i915_guc_log_info(struct seq_file *m,
2448 struct drm_i915_private *dev_priv)
2449{
2450 struct intel_guc *guc = &dev_priv->guc;
2451
2452 seq_puts(m, "\nGuC logging stats:\n");
2453
2454 seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n",
2455 guc->log.flush_count[GUC_ISR_LOG_BUFFER],
2456 guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]);
2457
2458 seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n",
2459 guc->log.flush_count[GUC_DPC_LOG_BUFFER],
2460 guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]);
2461
2462 seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n",
2463 guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER],
2464 guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]);
2465
2466 seq_printf(m, "\tTotal flush interrupt count: %u\n",
2467 guc->log.flush_interrupt_count);
2468
2469 seq_printf(m, "\tCapture miss count: %u\n",
2470 guc->log.capture_miss_count);
2471}
2472
Dave Gordon8b417c22015-08-12 15:43:44 +01002473static void i915_guc_client_info(struct seq_file *m,
2474 struct drm_i915_private *dev_priv,
2475 struct i915_guc_client *client)
2476{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002477 struct intel_engine_cs *engine;
Dave Gordonc18468c2016-08-09 15:19:22 +01002478 enum intel_engine_id id;
Dave Gordon8b417c22015-08-12 15:43:44 +01002479 uint64_t tot = 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002480
2481 seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n",
2482 client->priority, client->ctx_index, client->proc_desc_offset);
2483 seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n",
Chris Wilson357248b2016-11-29 12:10:21 +00002484 client->doorbell_id, client->doorbell_offset, client->doorbell_cookie);
Dave Gordon8b417c22015-08-12 15:43:44 +01002485 seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n",
2486 client->wq_size, client->wq_offset, client->wq_tail);
2487
Dave Gordon551aaec2016-05-13 15:36:33 +01002488 seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space);
Dave Gordon8b417c22015-08-12 15:43:44 +01002489 seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail);
2490 seq_printf(m, "\tLast submission result: %d\n", client->retcode);
2491
Akash Goel3b3f1652016-10-13 22:44:48 +05302492 for_each_engine(engine, dev_priv, id) {
Dave Gordonc18468c2016-08-09 15:19:22 +01002493 u64 submissions = client->submissions[id];
2494 tot += submissions;
Dave Gordon8b417c22015-08-12 15:43:44 +01002495 seq_printf(m, "\tSubmissions: %llu %s\n",
Dave Gordonc18468c2016-08-09 15:19:22 +01002496 submissions, engine->name);
Dave Gordon8b417c22015-08-12 15:43:44 +01002497 }
2498 seq_printf(m, "\tTotal: %llu\n", tot);
2499}
2500
2501static int i915_guc_info(struct seq_file *m, void *data)
2502{
David Weinehall36cdd012016-08-22 13:59:31 +03002503 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilson334636c2016-11-29 12:10:20 +00002504 const struct intel_guc *guc = &dev_priv->guc;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002505 struct intel_engine_cs *engine;
Dave Gordonc18468c2016-08-09 15:19:22 +01002506 enum intel_engine_id id;
Chris Wilson334636c2016-11-29 12:10:20 +00002507 u64 total;
Dave Gordon8b417c22015-08-12 15:43:44 +01002508
Chris Wilson334636c2016-11-29 12:10:20 +00002509 if (!guc->execbuf_client) {
2510 seq_printf(m, "GuC submission %s\n",
2511 HAS_GUC_SCHED(dev_priv) ?
2512 "disabled" :
2513 "not supported");
Dave Gordon8b417c22015-08-12 15:43:44 +01002514 return 0;
Chris Wilson334636c2016-11-29 12:10:20 +00002515 }
Dave Gordon8b417c22015-08-12 15:43:44 +01002516
Dave Gordon9636f6d2016-06-13 17:57:28 +01002517 seq_printf(m, "Doorbell map:\n");
Chris Wilson334636c2016-11-29 12:10:20 +00002518 seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc->doorbell_bitmap);
2519 seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc->db_cacheline);
Dave Gordon9636f6d2016-06-13 17:57:28 +01002520
Chris Wilson334636c2016-11-29 12:10:20 +00002521 seq_printf(m, "GuC total action count: %llu\n", guc->action_count);
2522 seq_printf(m, "GuC action failure count: %u\n", guc->action_fail);
2523 seq_printf(m, "GuC last action command: 0x%x\n", guc->action_cmd);
2524 seq_printf(m, "GuC last action status: 0x%x\n", guc->action_status);
2525 seq_printf(m, "GuC last action error code: %d\n", guc->action_err);
Dave Gordon8b417c22015-08-12 15:43:44 +01002526
Chris Wilson334636c2016-11-29 12:10:20 +00002527 total = 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002528 seq_printf(m, "\nGuC submissions:\n");
Akash Goel3b3f1652016-10-13 22:44:48 +05302529 for_each_engine(engine, dev_priv, id) {
Chris Wilson334636c2016-11-29 12:10:20 +00002530 u64 submissions = guc->submissions[id];
Dave Gordonc18468c2016-08-09 15:19:22 +01002531 total += submissions;
Alex Dai397097b2016-01-23 11:58:14 -08002532 seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n",
Chris Wilson334636c2016-11-29 12:10:20 +00002533 engine->name, submissions, guc->last_seqno[id]);
Dave Gordon8b417c22015-08-12 15:43:44 +01002534 }
2535 seq_printf(m, "\t%s: %llu\n", "Total", total);
2536
Chris Wilson334636c2016-11-29 12:10:20 +00002537 seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client);
2538 i915_guc_client_info(m, dev_priv, guc->execbuf_client);
Dave Gordon8b417c22015-08-12 15:43:44 +01002539
Akash Goel5aa1ee42016-10-12 21:54:36 +05302540 i915_guc_log_info(m, dev_priv);
2541
Dave Gordon8b417c22015-08-12 15:43:44 +01002542 /* Add more as required ... */
2543
2544 return 0;
2545}
2546
Alex Dai4c7e77f2015-08-12 15:43:40 +01002547static int i915_guc_log_dump(struct seq_file *m, void *data)
2548{
David Weinehall36cdd012016-08-22 13:59:31 +03002549 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilson8b797af2016-08-15 10:48:51 +01002550 struct drm_i915_gem_object *obj;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002551 int i = 0, pg;
2552
Akash Goeld6b40b42016-10-12 21:54:29 +05302553 if (!dev_priv->guc.log.vma)
Alex Dai4c7e77f2015-08-12 15:43:40 +01002554 return 0;
2555
Akash Goeld6b40b42016-10-12 21:54:29 +05302556 obj = dev_priv->guc.log.vma->obj;
Chris Wilson8b797af2016-08-15 10:48:51 +01002557 for (pg = 0; pg < obj->base.size / PAGE_SIZE; pg++) {
2558 u32 *log = kmap_atomic(i915_gem_object_get_page(obj, pg));
Alex Dai4c7e77f2015-08-12 15:43:40 +01002559
2560 for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4)
2561 seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n",
2562 *(log + i), *(log + i + 1),
2563 *(log + i + 2), *(log + i + 3));
2564
2565 kunmap_atomic(log);
2566 }
2567
2568 seq_putc(m, '\n');
2569
2570 return 0;
2571}
2572
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302573static int i915_guc_log_control_get(void *data, u64 *val)
2574{
2575 struct drm_device *dev = data;
2576 struct drm_i915_private *dev_priv = to_i915(dev);
2577
2578 if (!dev_priv->guc.log.vma)
2579 return -EINVAL;
2580
2581 *val = i915.guc_log_level;
2582
2583 return 0;
2584}
2585
2586static int i915_guc_log_control_set(void *data, u64 val)
2587{
2588 struct drm_device *dev = data;
2589 struct drm_i915_private *dev_priv = to_i915(dev);
2590 int ret;
2591
2592 if (!dev_priv->guc.log.vma)
2593 return -EINVAL;
2594
2595 ret = mutex_lock_interruptible(&dev->struct_mutex);
2596 if (ret)
2597 return ret;
2598
2599 intel_runtime_pm_get(dev_priv);
2600 ret = i915_guc_log_control(dev_priv, val);
2601 intel_runtime_pm_put(dev_priv);
2602
2603 mutex_unlock(&dev->struct_mutex);
2604 return ret;
2605}
2606
2607DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops,
2608 i915_guc_log_control_get, i915_guc_log_control_set,
2609 "%lld\n");
2610
Chris Wilsonb86bef202017-01-16 13:06:21 +00002611static const char *psr2_live_status(u32 val)
2612{
2613 static const char * const live_status[] = {
2614 "IDLE",
2615 "CAPTURE",
2616 "CAPTURE_FS",
2617 "SLEEP",
2618 "BUFON_FW",
2619 "ML_UP",
2620 "SU_STANDBY",
2621 "FAST_SLEEP",
2622 "DEEP_SLEEP",
2623 "BUF_ON",
2624 "TG_ON"
2625 };
2626
2627 val = (val & EDP_PSR2_STATUS_STATE_MASK) >> EDP_PSR2_STATUS_STATE_SHIFT;
2628 if (val < ARRAY_SIZE(live_status))
2629 return live_status[val];
2630
2631 return "unknown";
2632}
2633
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002634static int i915_edp_psr_status(struct seq_file *m, void *data)
2635{
David Weinehall36cdd012016-08-22 13:59:31 +03002636 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002637 u32 psrperf = 0;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002638 u32 stat[3];
2639 enum pipe pipe;
Rodrigo Vivia031d702013-10-03 16:15:06 -03002640 bool enabled = false;
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002641
David Weinehall36cdd012016-08-22 13:59:31 +03002642 if (!HAS_PSR(dev_priv)) {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002643 seq_puts(m, "PSR not supported\n");
2644 return 0;
2645 }
2646
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002647 intel_runtime_pm_get(dev_priv);
2648
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002649 mutex_lock(&dev_priv->psr.lock);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002650 seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support));
2651 seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok));
Daniel Vetter2807cf62014-07-11 10:30:11 -07002652 seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled));
Rodrigo Vivi5755c782014-06-12 10:16:45 -07002653 seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002654 seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
2655 dev_priv->psr.busy_frontbuffer_bits);
2656 seq_printf(m, "Re-enable work scheduled: %s\n",
2657 yesno(work_busy(&dev_priv->psr.work.work)));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002658
Nagaraju, Vathsala7e3eb592016-12-09 23:42:09 +05302659 if (HAS_DDI(dev_priv)) {
2660 if (dev_priv->psr.psr2_support)
2661 enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE;
2662 else
2663 enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE;
2664 } else {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002665 for_each_pipe(dev_priv, pipe) {
Chris Wilson9c870d02016-10-24 13:42:15 +01002666 enum transcoder cpu_transcoder =
2667 intel_pipe_to_cpu_transcoder(dev_priv, pipe);
2668 enum intel_display_power_domain power_domain;
2669
2670 power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder);
2671 if (!intel_display_power_get_if_enabled(dev_priv,
2672 power_domain))
2673 continue;
2674
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002675 stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) &
2676 VLV_EDP_PSR_CURR_STATE_MASK;
2677 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2678 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2679 enabled = true;
Chris Wilson9c870d02016-10-24 13:42:15 +01002680
2681 intel_display_power_put(dev_priv, power_domain);
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002682 }
2683 }
Rodrigo Vivi60e5ffe2016-02-01 12:02:07 -08002684
2685 seq_printf(m, "Main link in standby mode: %s\n",
2686 yesno(dev_priv->psr.link_standby));
2687
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002688 seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002689
David Weinehall36cdd012016-08-22 13:59:31 +03002690 if (!HAS_DDI(dev_priv))
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002691 for_each_pipe(dev_priv, pipe) {
2692 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2693 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2694 seq_printf(m, " pipe %c", pipe_name(pipe));
2695 }
2696 seq_puts(m, "\n");
2697
Rodrigo Vivi05eec3c2015-11-23 14:16:40 -08002698 /*
2699 * VLV/CHV PSR has no kind of performance counter
2700 * SKL+ Perf counter is reset to 0 everytime DC state is entered
2701 */
David Weinehall36cdd012016-08-22 13:59:31 +03002702 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
Ville Syrjälä443a3892015-11-11 20:34:15 +02002703 psrperf = I915_READ(EDP_PSR_PERF_CNT) &
Rodrigo Vivia031d702013-10-03 16:15:06 -03002704 EDP_PSR_PERF_CNT_MASK;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002705
2706 seq_printf(m, "Performance_Counter: %u\n", psrperf);
2707 }
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302708 if (dev_priv->psr.psr2_support) {
Chris Wilsonb86bef202017-01-16 13:06:21 +00002709 u32 psr2 = I915_READ(EDP_PSR2_STATUS_CTL);
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302710
Chris Wilsonb86bef202017-01-16 13:06:21 +00002711 seq_printf(m, "EDP_PSR2_STATUS_CTL: %x [%s]\n",
2712 psr2, psr2_live_status(psr2));
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302713 }
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002714 mutex_unlock(&dev_priv->psr.lock);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002715
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002716 intel_runtime_pm_put(dev_priv);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002717 return 0;
2718}
2719
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002720static int i915_sink_crc(struct seq_file *m, void *data)
2721{
David Weinehall36cdd012016-08-22 13:59:31 +03002722 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2723 struct drm_device *dev = &dev_priv->drm;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002724 struct intel_connector *connector;
2725 struct intel_dp *intel_dp = NULL;
2726 int ret;
2727 u8 crc[6];
2728
2729 drm_modeset_lock_all(dev);
Rodrigo Viviaca5e362015-03-13 16:13:59 -07002730 for_each_intel_connector(dev, connector) {
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002731 struct drm_crtc *crtc;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002732
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002733 if (!connector->base.state->best_encoder)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002734 continue;
2735
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002736 crtc = connector->base.state->crtc;
2737 if (!crtc->state->active)
Paulo Zanonib6ae3c72014-02-13 17:51:33 -02002738 continue;
2739
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002740 if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002741 continue;
2742
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002743 intel_dp = enc_to_intel_dp(connector->base.state->best_encoder);
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002744
2745 ret = intel_dp_sink_crc(intel_dp, crc);
2746 if (ret)
2747 goto out;
2748
2749 seq_printf(m, "%02x%02x%02x%02x%02x%02x\n",
2750 crc[0], crc[1], crc[2],
2751 crc[3], crc[4], crc[5]);
2752 goto out;
2753 }
2754 ret = -ENODEV;
2755out:
2756 drm_modeset_unlock_all(dev);
2757 return ret;
2758}
2759
Jesse Barnesec013e72013-08-20 10:29:23 +01002760static int i915_energy_uJ(struct seq_file *m, void *data)
2761{
David Weinehall36cdd012016-08-22 13:59:31 +03002762 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnesec013e72013-08-20 10:29:23 +01002763 u64 power;
2764 u32 units;
2765
David Weinehall36cdd012016-08-22 13:59:31 +03002766 if (INTEL_GEN(dev_priv) < 6)
Jesse Barnesec013e72013-08-20 10:29:23 +01002767 return -ENODEV;
2768
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002769 intel_runtime_pm_get(dev_priv);
2770
Jesse Barnesec013e72013-08-20 10:29:23 +01002771 rdmsrl(MSR_RAPL_POWER_UNIT, power);
2772 power = (power & 0x1f00) >> 8;
2773 units = 1000000 / (1 << power); /* convert to uJ */
2774 power = I915_READ(MCH_SECP_NRG_STTS);
2775 power *= units;
2776
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002777 intel_runtime_pm_put(dev_priv);
2778
Jesse Barnesec013e72013-08-20 10:29:23 +01002779 seq_printf(m, "%llu", (long long unsigned)power);
Paulo Zanoni371db662013-08-19 13:18:10 -03002780
2781 return 0;
2782}
2783
Damien Lespiau6455c872015-06-04 18:23:57 +01002784static int i915_runtime_pm_status(struct seq_file *m, void *unused)
Paulo Zanoni371db662013-08-19 13:18:10 -03002785{
David Weinehall36cdd012016-08-22 13:59:31 +03002786 struct drm_i915_private *dev_priv = node_to_i915(m->private);
David Weinehall52a05c32016-08-22 13:32:44 +03002787 struct pci_dev *pdev = dev_priv->drm.pdev;
Paulo Zanoni371db662013-08-19 13:18:10 -03002788
Chris Wilsona156e642016-04-03 14:14:21 +01002789 if (!HAS_RUNTIME_PM(dev_priv))
2790 seq_puts(m, "Runtime power management not supported\n");
Paulo Zanoni371db662013-08-19 13:18:10 -03002791
Chris Wilson67d97da2016-07-04 08:08:31 +01002792 seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake));
Paulo Zanoni371db662013-08-19 13:18:10 -03002793 seq_printf(m, "IRQs disabled: %s\n",
Jesse Barnes9df7575f2014-06-20 09:29:20 -07002794 yesno(!intel_irqs_enabled(dev_priv)));
Chris Wilson0d804182015-06-15 12:52:28 +01002795#ifdef CONFIG_PM
Damien Lespiaua6aaec82015-06-04 18:23:58 +01002796 seq_printf(m, "Usage count: %d\n",
David Weinehall36cdd012016-08-22 13:59:31 +03002797 atomic_read(&dev_priv->drm.dev->power.usage_count));
Chris Wilson0d804182015-06-15 12:52:28 +01002798#else
2799 seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n");
2800#endif
Chris Wilsona156e642016-04-03 14:14:21 +01002801 seq_printf(m, "PCI device power state: %s [%d]\n",
David Weinehall52a05c32016-08-22 13:32:44 +03002802 pci_power_name(pdev->current_state),
2803 pdev->current_state);
Paulo Zanoni371db662013-08-19 13:18:10 -03002804
Jesse Barnesec013e72013-08-20 10:29:23 +01002805 return 0;
2806}
2807
Imre Deak1da51582013-11-25 17:15:35 +02002808static int i915_power_domain_info(struct seq_file *m, void *unused)
2809{
David Weinehall36cdd012016-08-22 13:59:31 +03002810 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak1da51582013-11-25 17:15:35 +02002811 struct i915_power_domains *power_domains = &dev_priv->power_domains;
2812 int i;
2813
2814 mutex_lock(&power_domains->lock);
2815
2816 seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count");
2817 for (i = 0; i < power_domains->power_well_count; i++) {
2818 struct i915_power_well *power_well;
2819 enum intel_display_power_domain power_domain;
2820
2821 power_well = &power_domains->power_wells[i];
2822 seq_printf(m, "%-25s %d\n", power_well->name,
2823 power_well->count);
2824
Joonas Lahtinen8385c2e2017-02-08 15:12:10 +02002825 for_each_power_domain(power_domain, power_well->domains)
Imre Deak1da51582013-11-25 17:15:35 +02002826 seq_printf(m, " %-23s %d\n",
Daniel Stone9895ad02015-11-20 15:55:33 +00002827 intel_display_power_domain_str(power_domain),
Imre Deak1da51582013-11-25 17:15:35 +02002828 power_domains->domain_use_count[power_domain]);
Imre Deak1da51582013-11-25 17:15:35 +02002829 }
2830
2831 mutex_unlock(&power_domains->lock);
2832
2833 return 0;
2834}
2835
Damien Lespiaub7cec662015-10-27 14:47:01 +02002836static int i915_dmc_info(struct seq_file *m, void *unused)
2837{
David Weinehall36cdd012016-08-22 13:59:31 +03002838 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Damien Lespiaub7cec662015-10-27 14:47:01 +02002839 struct intel_csr *csr;
2840
David Weinehall36cdd012016-08-22 13:59:31 +03002841 if (!HAS_CSR(dev_priv)) {
Damien Lespiaub7cec662015-10-27 14:47:01 +02002842 seq_puts(m, "not supported\n");
2843 return 0;
2844 }
2845
2846 csr = &dev_priv->csr;
2847
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002848 intel_runtime_pm_get(dev_priv);
2849
Damien Lespiaub7cec662015-10-27 14:47:01 +02002850 seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL));
2851 seq_printf(m, "path: %s\n", csr->fw_path);
2852
2853 if (!csr->dmc_payload)
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002854 goto out;
Damien Lespiaub7cec662015-10-27 14:47:01 +02002855
2856 seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version),
2857 CSR_VERSION_MINOR(csr->version));
2858
David Weinehall36cdd012016-08-22 13:59:31 +03002859 if (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6)) {
Damien Lespiau83372062015-10-30 17:53:32 +02002860 seq_printf(m, "DC3 -> DC5 count: %d\n",
2861 I915_READ(SKL_CSR_DC3_DC5_COUNT));
2862 seq_printf(m, "DC5 -> DC6 count: %d\n",
2863 I915_READ(SKL_CSR_DC5_DC6_COUNT));
David Weinehall36cdd012016-08-22 13:59:31 +03002864 } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) {
Mika Kuoppala16e11b92015-10-27 14:47:03 +02002865 seq_printf(m, "DC3 -> DC5 count: %d\n",
2866 I915_READ(BXT_CSR_DC3_DC5_COUNT));
Damien Lespiau83372062015-10-30 17:53:32 +02002867 }
2868
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002869out:
2870 seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0)));
2871 seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE));
2872 seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL));
2873
Damien Lespiau83372062015-10-30 17:53:32 +02002874 intel_runtime_pm_put(dev_priv);
2875
Damien Lespiaub7cec662015-10-27 14:47:01 +02002876 return 0;
2877}
2878
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002879static void intel_seq_print_mode(struct seq_file *m, int tabs,
2880 struct drm_display_mode *mode)
2881{
2882 int i;
2883
2884 for (i = 0; i < tabs; i++)
2885 seq_putc(m, '\t');
2886
2887 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",
2888 mode->base.id, mode->name,
2889 mode->vrefresh, mode->clock,
2890 mode->hdisplay, mode->hsync_start,
2891 mode->hsync_end, mode->htotal,
2892 mode->vdisplay, mode->vsync_start,
2893 mode->vsync_end, mode->vtotal,
2894 mode->type, mode->flags);
2895}
2896
2897static void intel_encoder_info(struct seq_file *m,
2898 struct intel_crtc *intel_crtc,
2899 struct intel_encoder *intel_encoder)
2900{
David Weinehall36cdd012016-08-22 13:59:31 +03002901 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2902 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002903 struct drm_crtc *crtc = &intel_crtc->base;
2904 struct intel_connector *intel_connector;
2905 struct drm_encoder *encoder;
2906
2907 encoder = &intel_encoder->base;
2908 seq_printf(m, "\tencoder %d: type: %s, connectors:\n",
Jani Nikula8e329a032014-06-03 14:56:21 +03002909 encoder->base.id, encoder->name);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002910 for_each_connector_on_encoder(dev, encoder, intel_connector) {
2911 struct drm_connector *connector = &intel_connector->base;
2912 seq_printf(m, "\t\tconnector %d: type: %s, status: %s",
2913 connector->base.id,
Jani Nikulac23cc412014-06-03 14:56:17 +03002914 connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002915 drm_get_connector_status_name(connector->status));
2916 if (connector->status == connector_status_connected) {
2917 struct drm_display_mode *mode = &crtc->mode;
2918 seq_printf(m, ", mode:\n");
2919 intel_seq_print_mode(m, 2, mode);
2920 } else {
2921 seq_putc(m, '\n');
2922 }
2923 }
2924}
2925
2926static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc)
2927{
David Weinehall36cdd012016-08-22 13:59:31 +03002928 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2929 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002930 struct drm_crtc *crtc = &intel_crtc->base;
2931 struct intel_encoder *intel_encoder;
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002932 struct drm_plane_state *plane_state = crtc->primary->state;
2933 struct drm_framebuffer *fb = plane_state->fb;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002934
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002935 if (fb)
Matt Roper5aa8a932014-06-16 10:12:55 -07002936 seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n",
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002937 fb->base.id, plane_state->src_x >> 16,
2938 plane_state->src_y >> 16, fb->width, fb->height);
Matt Roper5aa8a932014-06-16 10:12:55 -07002939 else
2940 seq_puts(m, "\tprimary plane disabled\n");
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002941 for_each_encoder_on_crtc(dev, crtc, intel_encoder)
2942 intel_encoder_info(m, intel_crtc, intel_encoder);
2943}
2944
2945static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
2946{
2947 struct drm_display_mode *mode = panel->fixed_mode;
2948
2949 seq_printf(m, "\tfixed mode:\n");
2950 intel_seq_print_mode(m, 2, mode);
2951}
2952
2953static void intel_dp_info(struct seq_file *m,
2954 struct intel_connector *intel_connector)
2955{
2956 struct intel_encoder *intel_encoder = intel_connector->encoder;
2957 struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
2958
2959 seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]);
Jani Nikula742f4912015-09-03 11:16:09 +03002960 seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio));
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02002961 if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002962 intel_panel_info(m, &intel_connector->panel);
Mika Kahola80209e52016-09-09 14:10:57 +03002963
2964 drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports,
2965 &intel_dp->aux);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002966}
2967
Libin Yang9a148a92016-11-28 20:07:05 +08002968static void intel_dp_mst_info(struct seq_file *m,
2969 struct intel_connector *intel_connector)
2970{
2971 struct intel_encoder *intel_encoder = intel_connector->encoder;
2972 struct intel_dp_mst_encoder *intel_mst =
2973 enc_to_mst(&intel_encoder->base);
2974 struct intel_digital_port *intel_dig_port = intel_mst->primary;
2975 struct intel_dp *intel_dp = &intel_dig_port->dp;
2976 bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr,
2977 intel_connector->port);
2978
2979 seq_printf(m, "\taudio support: %s\n", yesno(has_audio));
2980}
2981
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002982static void intel_hdmi_info(struct seq_file *m,
2983 struct intel_connector *intel_connector)
2984{
2985 struct intel_encoder *intel_encoder = intel_connector->encoder;
2986 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
2987
Jani Nikula742f4912015-09-03 11:16:09 +03002988 seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio));
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002989}
2990
2991static void intel_lvds_info(struct seq_file *m,
2992 struct intel_connector *intel_connector)
2993{
2994 intel_panel_info(m, &intel_connector->panel);
2995}
2996
2997static void intel_connector_info(struct seq_file *m,
2998 struct drm_connector *connector)
2999{
3000 struct intel_connector *intel_connector = to_intel_connector(connector);
3001 struct intel_encoder *intel_encoder = intel_connector->encoder;
Jesse Barnesf103fc72014-02-20 12:39:57 -08003002 struct drm_display_mode *mode;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003003
3004 seq_printf(m, "connector %d: type %s, status: %s\n",
Jani Nikulac23cc412014-06-03 14:56:17 +03003005 connector->base.id, connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003006 drm_get_connector_status_name(connector->status));
3007 if (connector->status == connector_status_connected) {
3008 seq_printf(m, "\tname: %s\n", connector->display_info.name);
3009 seq_printf(m, "\tphysical dimensions: %dx%dmm\n",
3010 connector->display_info.width_mm,
3011 connector->display_info.height_mm);
3012 seq_printf(m, "\tsubpixel order: %s\n",
3013 drm_get_subpixel_order_name(connector->display_info.subpixel_order));
3014 seq_printf(m, "\tCEA rev: %d\n",
3015 connector->display_info.cea_rev);
3016 }
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003017
3018 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
3019 return;
3020
3021 switch (connector->connector_type) {
3022 case DRM_MODE_CONNECTOR_DisplayPort:
3023 case DRM_MODE_CONNECTOR_eDP:
Libin Yang9a148a92016-11-28 20:07:05 +08003024 if (intel_encoder->type == INTEL_OUTPUT_DP_MST)
3025 intel_dp_mst_info(m, intel_connector);
3026 else
3027 intel_dp_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003028 break;
3029 case DRM_MODE_CONNECTOR_LVDS:
3030 if (intel_encoder->type == INTEL_OUTPUT_LVDS)
Dave Airlie36cd7442014-05-02 13:44:18 +10003031 intel_lvds_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003032 break;
3033 case DRM_MODE_CONNECTOR_HDMIA:
3034 if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
3035 intel_encoder->type == INTEL_OUTPUT_UNKNOWN)
3036 intel_hdmi_info(m, intel_connector);
3037 break;
3038 default:
3039 break;
Dave Airlie36cd7442014-05-02 13:44:18 +10003040 }
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003041
Jesse Barnesf103fc72014-02-20 12:39:57 -08003042 seq_printf(m, "\tmodes:\n");
3043 list_for_each_entry(mode, &connector->modes, head)
3044 intel_seq_print_mode(m, 2, mode);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003045}
3046
David Weinehall36cdd012016-08-22 13:59:31 +03003047static bool cursor_active(struct drm_i915_private *dev_priv, int pipe)
Chris Wilson065f2ec2014-03-12 09:13:13 +00003048{
Chris Wilson065f2ec2014-03-12 09:13:13 +00003049 u32 state;
3050
Jani Nikula2a307c22016-11-30 17:43:04 +02003051 if (IS_I845G(dev_priv) || IS_I865G(dev_priv))
Ville Syrjälä0b87c242015-09-22 19:47:51 +03003052 state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003053 else
Ville Syrjälä5efb3e22014-04-09 13:28:53 +03003054 state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003055
3056 return state;
3057}
3058
David Weinehall36cdd012016-08-22 13:59:31 +03003059static bool cursor_position(struct drm_i915_private *dev_priv,
3060 int pipe, int *x, int *y)
Chris Wilson065f2ec2014-03-12 09:13:13 +00003061{
Chris Wilson065f2ec2014-03-12 09:13:13 +00003062 u32 pos;
3063
Ville Syrjälä5efb3e22014-04-09 13:28:53 +03003064 pos = I915_READ(CURPOS(pipe));
Chris Wilson065f2ec2014-03-12 09:13:13 +00003065
3066 *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK;
3067 if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT))
3068 *x = -*x;
3069
3070 *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK;
3071 if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT))
3072 *y = -*y;
3073
David Weinehall36cdd012016-08-22 13:59:31 +03003074 return cursor_active(dev_priv, pipe);
Chris Wilson065f2ec2014-03-12 09:13:13 +00003075}
3076
Robert Fekete3abc4e02015-10-27 16:58:32 +01003077static const char *plane_type(enum drm_plane_type type)
3078{
3079 switch (type) {
3080 case DRM_PLANE_TYPE_OVERLAY:
3081 return "OVL";
3082 case DRM_PLANE_TYPE_PRIMARY:
3083 return "PRI";
3084 case DRM_PLANE_TYPE_CURSOR:
3085 return "CUR";
3086 /*
3087 * Deliberately omitting default: to generate compiler warnings
3088 * when a new drm_plane_type gets added.
3089 */
3090 }
3091
3092 return "unknown";
3093}
3094
3095static const char *plane_rotation(unsigned int rotation)
3096{
3097 static char buf[48];
3098 /*
3099 * According to doc only one DRM_ROTATE_ is allowed but this
3100 * will print them all to visualize if the values are misused
3101 */
3102 snprintf(buf, sizeof(buf),
3103 "%s%s%s%s%s%s(0x%08x)",
Joonas Lahtinen31ad61e2016-07-29 08:50:05 +03003104 (rotation & DRM_ROTATE_0) ? "0 " : "",
3105 (rotation & DRM_ROTATE_90) ? "90 " : "",
3106 (rotation & DRM_ROTATE_180) ? "180 " : "",
3107 (rotation & DRM_ROTATE_270) ? "270 " : "",
3108 (rotation & DRM_REFLECT_X) ? "FLIPX " : "",
3109 (rotation & DRM_REFLECT_Y) ? "FLIPY " : "",
Robert Fekete3abc4e02015-10-27 16:58:32 +01003110 rotation);
3111
3112 return buf;
3113}
3114
3115static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3116{
David Weinehall36cdd012016-08-22 13:59:31 +03003117 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3118 struct drm_device *dev = &dev_priv->drm;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003119 struct intel_plane *intel_plane;
3120
3121 for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
3122 struct drm_plane_state *state;
3123 struct drm_plane *plane = &intel_plane->base;
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003124 struct drm_format_name_buf format_name;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003125
3126 if (!plane->state) {
3127 seq_puts(m, "plane->state is NULL!\n");
3128 continue;
3129 }
3130
3131 state = plane->state;
3132
Eric Engestrom90844f02016-08-15 01:02:38 +01003133 if (state->fb) {
Ville Syrjälä438b74a2016-12-14 23:32:55 +02003134 drm_get_format_name(state->fb->format->format,
3135 &format_name);
Eric Engestrom90844f02016-08-15 01:02:38 +01003136 } else {
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003137 sprintf(format_name.str, "N/A");
Eric Engestrom90844f02016-08-15 01:02:38 +01003138 }
3139
Robert Fekete3abc4e02015-10-27 16:58:32 +01003140 seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",
3141 plane->base.id,
3142 plane_type(intel_plane->base.type),
3143 state->crtc_x, state->crtc_y,
3144 state->crtc_w, state->crtc_h,
3145 (state->src_x >> 16),
3146 ((state->src_x & 0xffff) * 15625) >> 10,
3147 (state->src_y >> 16),
3148 ((state->src_y & 0xffff) * 15625) >> 10,
3149 (state->src_w >> 16),
3150 ((state->src_w & 0xffff) * 15625) >> 10,
3151 (state->src_h >> 16),
3152 ((state->src_h & 0xffff) * 15625) >> 10,
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003153 format_name.str,
Robert Fekete3abc4e02015-10-27 16:58:32 +01003154 plane_rotation(state->rotation));
3155 }
3156}
3157
3158static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3159{
3160 struct intel_crtc_state *pipe_config;
3161 int num_scalers = intel_crtc->num_scalers;
3162 int i;
3163
3164 pipe_config = to_intel_crtc_state(intel_crtc->base.state);
3165
3166 /* Not all platformas have a scaler */
3167 if (num_scalers) {
3168 seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d",
3169 num_scalers,
3170 pipe_config->scaler_state.scaler_users,
3171 pipe_config->scaler_state.scaler_id);
3172
A.Sunil Kamath58415912016-11-20 23:20:26 +05303173 for (i = 0; i < num_scalers; i++) {
Robert Fekete3abc4e02015-10-27 16:58:32 +01003174 struct intel_scaler *sc =
3175 &pipe_config->scaler_state.scalers[i];
3176
3177 seq_printf(m, ", scalers[%d]: use=%s, mode=%x",
3178 i, yesno(sc->in_use), sc->mode);
3179 }
3180 seq_puts(m, "\n");
3181 } else {
3182 seq_puts(m, "\tNo scalers available on this platform\n");
3183 }
3184}
3185
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003186static int i915_display_info(struct seq_file *m, void *unused)
3187{
David Weinehall36cdd012016-08-22 13:59:31 +03003188 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3189 struct drm_device *dev = &dev_priv->drm;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003190 struct intel_crtc *crtc;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003191 struct drm_connector *connector;
3192
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003193 intel_runtime_pm_get(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003194 drm_modeset_lock_all(dev);
3195 seq_printf(m, "CRTC info\n");
3196 seq_printf(m, "---------\n");
Damien Lespiaud3fcc802014-05-13 23:32:22 +01003197 for_each_intel_crtc(dev, crtc) {
Chris Wilson065f2ec2014-03-12 09:13:13 +00003198 bool active;
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003199 struct intel_crtc_state *pipe_config;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003200 int x, y;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003201
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003202 pipe_config = to_intel_crtc_state(crtc->base.state);
3203
Robert Fekete3abc4e02015-10-27 16:58:32 +01003204 seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n",
Chris Wilson065f2ec2014-03-12 09:13:13 +00003205 crtc->base.base.id, pipe_name(crtc->pipe),
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003206 yesno(pipe_config->base.active),
Robert Fekete3abc4e02015-10-27 16:58:32 +01003207 pipe_config->pipe_src_w, pipe_config->pipe_src_h,
3208 yesno(pipe_config->dither), pipe_config->pipe_bpp);
3209
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003210 if (pipe_config->base.active) {
Chris Wilson065f2ec2014-03-12 09:13:13 +00003211 intel_crtc_info(m, crtc);
3212
David Weinehall36cdd012016-08-22 13:59:31 +03003213 active = cursor_position(dev_priv, crtc->pipe, &x, &y);
Chris Wilson57127ef2014-07-04 08:20:11 +01003214 seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x, active? %s\n",
Chris Wilson4b0e3332014-05-30 16:35:26 +03003215 yesno(crtc->cursor_base),
Matt Roper3dd512f2015-02-27 10:12:00 -08003216 x, y, crtc->base.cursor->state->crtc_w,
3217 crtc->base.cursor->state->crtc_h,
Chris Wilson57127ef2014-07-04 08:20:11 +01003218 crtc->cursor_addr, yesno(active));
Robert Fekete3abc4e02015-10-27 16:58:32 +01003219 intel_scaler_info(m, crtc);
3220 intel_plane_info(m, crtc);
Paulo Zanonia23dc652014-04-01 14:55:11 -03003221 }
Daniel Vettercace8412014-05-22 17:56:31 +02003222
3223 seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n",
3224 yesno(!crtc->cpu_fifo_underrun_disabled),
3225 yesno(!crtc->pch_fifo_underrun_disabled));
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003226 }
3227
3228 seq_printf(m, "\n");
3229 seq_printf(m, "Connector info\n");
3230 seq_printf(m, "--------------\n");
3231 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
3232 intel_connector_info(m, connector);
3233 }
3234 drm_modeset_unlock_all(dev);
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003235 intel_runtime_pm_put(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003236
3237 return 0;
3238}
3239
Chris Wilson1b365952016-10-04 21:11:31 +01003240static int i915_engine_info(struct seq_file *m, void *unused)
3241{
3242 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3243 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05303244 enum intel_engine_id id;
Chris Wilson1b365952016-10-04 21:11:31 +01003245
Chris Wilson9c870d02016-10-24 13:42:15 +01003246 intel_runtime_pm_get(dev_priv);
3247
Akash Goel3b3f1652016-10-13 22:44:48 +05303248 for_each_engine(engine, dev_priv, id) {
Chris Wilson1b365952016-10-04 21:11:31 +01003249 struct intel_breadcrumbs *b = &engine->breadcrumbs;
3250 struct drm_i915_gem_request *rq;
3251 struct rb_node *rb;
3252 u64 addr;
3253
3254 seq_printf(m, "%s\n", engine->name);
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02003255 seq_printf(m, "\tcurrent seqno %x, last %x, hangcheck %x [%d ms]\n",
Chris Wilson1b365952016-10-04 21:11:31 +01003256 intel_engine_get_seqno(engine),
Chris Wilsoncb399ea2016-11-01 10:03:16 +00003257 intel_engine_last_submit(engine),
Chris Wilson1b365952016-10-04 21:11:31 +01003258 engine->hangcheck.seqno,
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02003259 jiffies_to_msecs(jiffies - engine->hangcheck.action_timestamp));
Chris Wilson1b365952016-10-04 21:11:31 +01003260
3261 rcu_read_lock();
3262
3263 seq_printf(m, "\tRequests:\n");
3264
Chris Wilson73cb9702016-10-28 13:58:46 +01003265 rq = list_first_entry(&engine->timeline->requests,
3266 struct drm_i915_gem_request, link);
3267 if (&rq->link != &engine->timeline->requests)
Chris Wilson1b365952016-10-04 21:11:31 +01003268 print_request(m, rq, "\t\tfirst ");
3269
Chris Wilson73cb9702016-10-28 13:58:46 +01003270 rq = list_last_entry(&engine->timeline->requests,
3271 struct drm_i915_gem_request, link);
3272 if (&rq->link != &engine->timeline->requests)
Chris Wilson1b365952016-10-04 21:11:31 +01003273 print_request(m, rq, "\t\tlast ");
3274
3275 rq = i915_gem_find_active_request(engine);
3276 if (rq) {
3277 print_request(m, rq, "\t\tactive ");
3278 seq_printf(m,
3279 "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n",
3280 rq->head, rq->postfix, rq->tail,
3281 rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u,
3282 rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u);
3283 }
3284
3285 seq_printf(m, "\tRING_START: 0x%08x [0x%08x]\n",
3286 I915_READ(RING_START(engine->mmio_base)),
3287 rq ? i915_ggtt_offset(rq->ring->vma) : 0);
3288 seq_printf(m, "\tRING_HEAD: 0x%08x [0x%08x]\n",
3289 I915_READ(RING_HEAD(engine->mmio_base)) & HEAD_ADDR,
3290 rq ? rq->ring->head : 0);
3291 seq_printf(m, "\tRING_TAIL: 0x%08x [0x%08x]\n",
3292 I915_READ(RING_TAIL(engine->mmio_base)) & TAIL_ADDR,
3293 rq ? rq->ring->tail : 0);
3294 seq_printf(m, "\tRING_CTL: 0x%08x [%s]\n",
3295 I915_READ(RING_CTL(engine->mmio_base)),
3296 I915_READ(RING_CTL(engine->mmio_base)) & (RING_WAIT | RING_WAIT_SEMAPHORE) ? "waiting" : "");
3297
3298 rcu_read_unlock();
3299
3300 addr = intel_engine_get_active_head(engine);
3301 seq_printf(m, "\tACTHD: 0x%08x_%08x\n",
3302 upper_32_bits(addr), lower_32_bits(addr));
3303 addr = intel_engine_get_last_batch_head(engine);
3304 seq_printf(m, "\tBBADDR: 0x%08x_%08x\n",
3305 upper_32_bits(addr), lower_32_bits(addr));
3306
3307 if (i915.enable_execlists) {
3308 u32 ptr, read, write;
Chris Wilson20311bd2016-11-14 20:41:03 +00003309 struct rb_node *rb;
Chris Wilson1b365952016-10-04 21:11:31 +01003310
3311 seq_printf(m, "\tExeclist status: 0x%08x %08x\n",
3312 I915_READ(RING_EXECLIST_STATUS_LO(engine)),
3313 I915_READ(RING_EXECLIST_STATUS_HI(engine)));
3314
3315 ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine));
3316 read = GEN8_CSB_READ_PTR(ptr);
3317 write = GEN8_CSB_WRITE_PTR(ptr);
3318 seq_printf(m, "\tExeclist CSB read %d, write %d\n",
3319 read, write);
3320 if (read >= GEN8_CSB_ENTRIES)
3321 read = 0;
3322 if (write >= GEN8_CSB_ENTRIES)
3323 write = 0;
3324 if (read > write)
3325 write += GEN8_CSB_ENTRIES;
3326 while (read < write) {
3327 unsigned int idx = ++read % GEN8_CSB_ENTRIES;
3328
3329 seq_printf(m, "\tExeclist CSB[%d]: 0x%08x, context: %d\n",
3330 idx,
3331 I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, idx)),
3332 I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, idx)));
3333 }
3334
3335 rcu_read_lock();
3336 rq = READ_ONCE(engine->execlist_port[0].request);
Chris Wilson816ee792017-01-24 11:00:03 +00003337 if (rq) {
3338 seq_printf(m, "\t\tELSP[0] count=%d, ",
3339 engine->execlist_port[0].count);
3340 print_request(m, rq, "rq: ");
3341 } else {
Chris Wilson1b365952016-10-04 21:11:31 +01003342 seq_printf(m, "\t\tELSP[0] idle\n");
Chris Wilson816ee792017-01-24 11:00:03 +00003343 }
Chris Wilson1b365952016-10-04 21:11:31 +01003344 rq = READ_ONCE(engine->execlist_port[1].request);
Chris Wilson816ee792017-01-24 11:00:03 +00003345 if (rq) {
3346 seq_printf(m, "\t\tELSP[1] count=%d, ",
3347 engine->execlist_port[1].count);
3348 print_request(m, rq, "rq: ");
3349 } else {
Chris Wilson1b365952016-10-04 21:11:31 +01003350 seq_printf(m, "\t\tELSP[1] idle\n");
Chris Wilson816ee792017-01-24 11:00:03 +00003351 }
Chris Wilson1b365952016-10-04 21:11:31 +01003352 rcu_read_unlock();
Chris Wilsonc8247c02016-10-27 01:03:43 +01003353
Chris Wilson663f71e2016-11-14 20:41:00 +00003354 spin_lock_irq(&engine->timeline->lock);
Chris Wilson20311bd2016-11-14 20:41:03 +00003355 for (rb = engine->execlist_first; rb; rb = rb_next(rb)) {
3356 rq = rb_entry(rb, typeof(*rq), priotree.node);
Chris Wilsonc8247c02016-10-27 01:03:43 +01003357 print_request(m, rq, "\t\tQ ");
3358 }
Chris Wilson663f71e2016-11-14 20:41:00 +00003359 spin_unlock_irq(&engine->timeline->lock);
Chris Wilson1b365952016-10-04 21:11:31 +01003360 } else if (INTEL_GEN(dev_priv) > 6) {
3361 seq_printf(m, "\tPP_DIR_BASE: 0x%08x\n",
3362 I915_READ(RING_PP_DIR_BASE(engine)));
3363 seq_printf(m, "\tPP_DIR_BASE_READ: 0x%08x\n",
3364 I915_READ(RING_PP_DIR_BASE_READ(engine)));
3365 seq_printf(m, "\tPP_DIR_DCLV: 0x%08x\n",
3366 I915_READ(RING_PP_DIR_DCLV(engine)));
3367 }
3368
Chris Wilsonf6168e32016-10-28 13:58:55 +01003369 spin_lock_irq(&b->lock);
Chris Wilson1b365952016-10-04 21:11:31 +01003370 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +08003371 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson1b365952016-10-04 21:11:31 +01003372
3373 seq_printf(m, "\t%s [%d] waiting for %x\n",
3374 w->tsk->comm, w->tsk->pid, w->seqno);
3375 }
Chris Wilsonf6168e32016-10-28 13:58:55 +01003376 spin_unlock_irq(&b->lock);
Chris Wilson1b365952016-10-04 21:11:31 +01003377
3378 seq_puts(m, "\n");
3379 }
3380
Chris Wilson9c870d02016-10-24 13:42:15 +01003381 intel_runtime_pm_put(dev_priv);
3382
Chris Wilson1b365952016-10-04 21:11:31 +01003383 return 0;
3384}
3385
Ben Widawskye04934c2014-06-30 09:53:42 -07003386static int i915_semaphore_status(struct seq_file *m, void *unused)
3387{
David Weinehall36cdd012016-08-22 13:59:31 +03003388 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3389 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003390 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003391 int num_rings = INTEL_INFO(dev_priv)->num_rings;
Dave Gordonc3232b12016-03-23 18:19:53 +00003392 enum intel_engine_id id;
3393 int j, ret;
Ben Widawskye04934c2014-06-30 09:53:42 -07003394
Chris Wilson39df9192016-07-20 13:31:57 +01003395 if (!i915.semaphores) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003396 seq_puts(m, "Semaphores are disabled\n");
3397 return 0;
3398 }
3399
3400 ret = mutex_lock_interruptible(&dev->struct_mutex);
3401 if (ret)
3402 return ret;
Paulo Zanoni03872062014-07-09 14:31:57 -03003403 intel_runtime_pm_get(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003404
David Weinehall36cdd012016-08-22 13:59:31 +03003405 if (IS_BROADWELL(dev_priv)) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003406 struct page *page;
3407 uint64_t *seqno;
3408
Chris Wilson51d545d2016-08-15 10:49:02 +01003409 page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0);
Ben Widawskye04934c2014-06-30 09:53:42 -07003410
3411 seqno = (uint64_t *)kmap_atomic(page);
Akash Goel3b3f1652016-10-13 22:44:48 +05303412 for_each_engine(engine, dev_priv, id) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003413 uint64_t offset;
3414
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003415 seq_printf(m, "%s\n", engine->name);
Ben Widawskye04934c2014-06-30 09:53:42 -07003416
3417 seq_puts(m, " Last signal:");
3418 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003419 offset = id * I915_NUM_ENGINES + j;
Ben Widawskye04934c2014-06-30 09:53:42 -07003420 seq_printf(m, "0x%08llx (0x%02llx) ",
3421 seqno[offset], offset * 8);
3422 }
3423 seq_putc(m, '\n');
3424
3425 seq_puts(m, " Last wait: ");
3426 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003427 offset = id + (j * I915_NUM_ENGINES);
Ben Widawskye04934c2014-06-30 09:53:42 -07003428 seq_printf(m, "0x%08llx (0x%02llx) ",
3429 seqno[offset], offset * 8);
3430 }
3431 seq_putc(m, '\n');
3432
3433 }
3434 kunmap_atomic(seqno);
3435 } else {
3436 seq_puts(m, " Last signal:");
Akash Goel3b3f1652016-10-13 22:44:48 +05303437 for_each_engine(engine, dev_priv, id)
Ben Widawskye04934c2014-06-30 09:53:42 -07003438 for (j = 0; j < num_rings; j++)
3439 seq_printf(m, "0x%08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003440 I915_READ(engine->semaphore.mbox.signal[j]));
Ben Widawskye04934c2014-06-30 09:53:42 -07003441 seq_putc(m, '\n');
3442 }
3443
Paulo Zanoni03872062014-07-09 14:31:57 -03003444 intel_runtime_pm_put(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003445 mutex_unlock(&dev->struct_mutex);
3446 return 0;
3447}
3448
Daniel Vetter728e29d2014-06-25 22:01:53 +03003449static int i915_shared_dplls_info(struct seq_file *m, void *unused)
3450{
David Weinehall36cdd012016-08-22 13:59:31 +03003451 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3452 struct drm_device *dev = &dev_priv->drm;
Daniel Vetter728e29d2014-06-25 22:01:53 +03003453 int i;
3454
3455 drm_modeset_lock_all(dev);
3456 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3457 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
3458
3459 seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id);
Maarten Lankhorst2dd66ebd2016-03-14 09:27:52 +01003460 seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n",
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003461 pll->state.crtc_mask, pll->active_mask, yesno(pll->on));
Daniel Vetter728e29d2014-06-25 22:01:53 +03003462 seq_printf(m, " tracked hardware state:\n");
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003463 seq_printf(m, " dpll: 0x%08x\n", pll->state.hw_state.dpll);
Ander Conselvan de Oliveira3e369b72014-10-29 11:32:32 +02003464 seq_printf(m, " dpll_md: 0x%08x\n",
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003465 pll->state.hw_state.dpll_md);
3466 seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0);
3467 seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1);
3468 seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll);
Daniel Vetter728e29d2014-06-25 22:01:53 +03003469 }
3470 drm_modeset_unlock_all(dev);
3471
3472 return 0;
3473}
3474
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01003475static int i915_wa_registers(struct seq_file *m, void *unused)
Arun Siluvery888b5992014-08-26 14:44:51 +01003476{
3477 int i;
3478 int ret;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003479 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003480 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3481 struct drm_device *dev = &dev_priv->drm;
Arun Siluvery33136b02016-01-21 21:43:47 +00003482 struct i915_workarounds *workarounds = &dev_priv->workarounds;
Dave Gordonc3232b12016-03-23 18:19:53 +00003483 enum intel_engine_id id;
Arun Siluvery888b5992014-08-26 14:44:51 +01003484
Arun Siluvery888b5992014-08-26 14:44:51 +01003485 ret = mutex_lock_interruptible(&dev->struct_mutex);
3486 if (ret)
3487 return ret;
3488
3489 intel_runtime_pm_get(dev_priv);
3490
Arun Siluvery33136b02016-01-21 21:43:47 +00003491 seq_printf(m, "Workarounds applied: %d\n", workarounds->count);
Akash Goel3b3f1652016-10-13 22:44:48 +05303492 for_each_engine(engine, dev_priv, id)
Arun Siluvery33136b02016-01-21 21:43:47 +00003493 seq_printf(m, "HW whitelist count for %s: %d\n",
Dave Gordonc3232b12016-03-23 18:19:53 +00003494 engine->name, workarounds->hw_whitelist_count[id]);
Arun Siluvery33136b02016-01-21 21:43:47 +00003495 for (i = 0; i < workarounds->count; ++i) {
Ville Syrjäläf0f59a02015-11-18 15:33:26 +02003496 i915_reg_t addr;
3497 u32 mask, value, read;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003498 bool ok;
Arun Siluvery888b5992014-08-26 14:44:51 +01003499
Arun Siluvery33136b02016-01-21 21:43:47 +00003500 addr = workarounds->reg[i].addr;
3501 mask = workarounds->reg[i].mask;
3502 value = workarounds->reg[i].value;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003503 read = I915_READ(addr);
3504 ok = (value & mask) == (read & mask);
3505 seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n",
Ville Syrjäläf0f59a02015-11-18 15:33:26 +02003506 i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL");
Arun Siluvery888b5992014-08-26 14:44:51 +01003507 }
3508
3509 intel_runtime_pm_put(dev_priv);
3510 mutex_unlock(&dev->struct_mutex);
3511
3512 return 0;
3513}
3514
Damien Lespiauc5511e42014-11-04 17:06:51 +00003515static int i915_ddb_info(struct seq_file *m, void *unused)
3516{
David Weinehall36cdd012016-08-22 13:59:31 +03003517 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3518 struct drm_device *dev = &dev_priv->drm;
Damien Lespiauc5511e42014-11-04 17:06:51 +00003519 struct skl_ddb_allocation *ddb;
3520 struct skl_ddb_entry *entry;
3521 enum pipe pipe;
3522 int plane;
3523
David Weinehall36cdd012016-08-22 13:59:31 +03003524 if (INTEL_GEN(dev_priv) < 9)
Damien Lespiau2fcffe12014-12-03 17:33:24 +00003525 return 0;
3526
Damien Lespiauc5511e42014-11-04 17:06:51 +00003527 drm_modeset_lock_all(dev);
3528
3529 ddb = &dev_priv->wm.skl_hw.ddb;
3530
3531 seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
3532
3533 for_each_pipe(dev_priv, pipe) {
3534 seq_printf(m, "Pipe %c\n", pipe_name(pipe));
3535
Matt Roper8b364b42016-10-26 15:51:28 -07003536 for_each_universal_plane(dev_priv, pipe, plane) {
Damien Lespiauc5511e42014-11-04 17:06:51 +00003537 entry = &ddb->plane[pipe][plane];
3538 seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1,
3539 entry->start, entry->end,
3540 skl_ddb_entry_size(entry));
3541 }
3542
Matt Roper4969d332015-09-24 15:53:10 -07003543 entry = &ddb->plane[pipe][PLANE_CURSOR];
Damien Lespiauc5511e42014-11-04 17:06:51 +00003544 seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start,
3545 entry->end, skl_ddb_entry_size(entry));
3546 }
3547
3548 drm_modeset_unlock_all(dev);
3549
3550 return 0;
3551}
3552
Vandana Kannana54746e2015-03-03 20:53:10 +05303553static void drrs_status_per_crtc(struct seq_file *m,
David Weinehall36cdd012016-08-22 13:59:31 +03003554 struct drm_device *dev,
3555 struct intel_crtc *intel_crtc)
Vandana Kannana54746e2015-03-03 20:53:10 +05303556{
Chris Wilsonfac5e232016-07-04 11:34:36 +01003557 struct drm_i915_private *dev_priv = to_i915(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303558 struct i915_drrs *drrs = &dev_priv->drrs;
3559 int vrefresh = 0;
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003560 struct drm_connector *connector;
Vandana Kannana54746e2015-03-03 20:53:10 +05303561
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003562 drm_for_each_connector(connector, dev) {
3563 if (connector->state->crtc != &intel_crtc->base)
3564 continue;
3565
3566 seq_printf(m, "%s:\n", connector->name);
Vandana Kannana54746e2015-03-03 20:53:10 +05303567 }
3568
3569 if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT)
3570 seq_puts(m, "\tVBT: DRRS_type: Static");
3571 else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT)
3572 seq_puts(m, "\tVBT: DRRS_type: Seamless");
3573 else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED)
3574 seq_puts(m, "\tVBT: DRRS_type: None");
3575 else
3576 seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value");
3577
3578 seq_puts(m, "\n\n");
3579
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003580 if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303581 struct intel_panel *panel;
3582
3583 mutex_lock(&drrs->mutex);
3584 /* DRRS Supported */
3585 seq_puts(m, "\tDRRS Supported: Yes\n");
3586
3587 /* disable_drrs() will make drrs->dp NULL */
3588 if (!drrs->dp) {
3589 seq_puts(m, "Idleness DRRS: Disabled");
3590 mutex_unlock(&drrs->mutex);
3591 return;
3592 }
3593
3594 panel = &drrs->dp->attached_connector->panel;
3595 seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X",
3596 drrs->busy_frontbuffer_bits);
3597
3598 seq_puts(m, "\n\t\t");
3599 if (drrs->refresh_rate_type == DRRS_HIGH_RR) {
3600 seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n");
3601 vrefresh = panel->fixed_mode->vrefresh;
3602 } else if (drrs->refresh_rate_type == DRRS_LOW_RR) {
3603 seq_puts(m, "DRRS_State: DRRS_LOW_RR\n");
3604 vrefresh = panel->downclock_mode->vrefresh;
3605 } else {
3606 seq_printf(m, "DRRS_State: Unknown(%d)\n",
3607 drrs->refresh_rate_type);
3608 mutex_unlock(&drrs->mutex);
3609 return;
3610 }
3611 seq_printf(m, "\t\tVrefresh: %d", vrefresh);
3612
3613 seq_puts(m, "\n\t\t");
3614 mutex_unlock(&drrs->mutex);
3615 } else {
3616 /* DRRS not supported. Print the VBT parameter*/
3617 seq_puts(m, "\tDRRS Supported : No");
3618 }
3619 seq_puts(m, "\n");
3620}
3621
3622static int i915_drrs_status(struct seq_file *m, void *unused)
3623{
David Weinehall36cdd012016-08-22 13:59:31 +03003624 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3625 struct drm_device *dev = &dev_priv->drm;
Vandana Kannana54746e2015-03-03 20:53:10 +05303626 struct intel_crtc *intel_crtc;
3627 int active_crtc_cnt = 0;
3628
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003629 drm_modeset_lock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303630 for_each_intel_crtc(dev, intel_crtc) {
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003631 if (intel_crtc->base.state->active) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303632 active_crtc_cnt++;
3633 seq_printf(m, "\nCRTC %d: ", active_crtc_cnt);
3634
3635 drrs_status_per_crtc(m, dev, intel_crtc);
3636 }
Vandana Kannana54746e2015-03-03 20:53:10 +05303637 }
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003638 drm_modeset_unlock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303639
3640 if (!active_crtc_cnt)
3641 seq_puts(m, "No active crtc found\n");
3642
3643 return 0;
3644}
3645
Dave Airlie11bed952014-05-12 15:22:27 +10003646static int i915_dp_mst_info(struct seq_file *m, void *unused)
3647{
David Weinehall36cdd012016-08-22 13:59:31 +03003648 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3649 struct drm_device *dev = &dev_priv->drm;
Dave Airlie11bed952014-05-12 15:22:27 +10003650 struct intel_encoder *intel_encoder;
3651 struct intel_digital_port *intel_dig_port;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003652 struct drm_connector *connector;
3653
Dave Airlie11bed952014-05-12 15:22:27 +10003654 drm_modeset_lock_all(dev);
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003655 drm_for_each_connector(connector, dev) {
3656 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
Dave Airlie11bed952014-05-12 15:22:27 +10003657 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003658
3659 intel_encoder = intel_attached_encoder(connector);
3660 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
3661 continue;
3662
3663 intel_dig_port = enc_to_dig_port(&intel_encoder->base);
Dave Airlie11bed952014-05-12 15:22:27 +10003664 if (!intel_dig_port->dp.can_mst)
3665 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003666
Jim Bride40ae80c2016-04-14 10:18:37 -07003667 seq_printf(m, "MST Source Port %c\n",
3668 port_name(intel_dig_port->port));
Dave Airlie11bed952014-05-12 15:22:27 +10003669 drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr);
3670 }
3671 drm_modeset_unlock_all(dev);
3672 return 0;
3673}
3674
Todd Previteeb3394fa2015-04-18 00:04:19 -07003675static ssize_t i915_displayport_test_active_write(struct file *file,
David Weinehall36cdd012016-08-22 13:59:31 +03003676 const char __user *ubuf,
3677 size_t len, loff_t *offp)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003678{
3679 char *input_buffer;
3680 int status = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003681 struct drm_device *dev;
3682 struct drm_connector *connector;
3683 struct list_head *connector_list;
3684 struct intel_dp *intel_dp;
3685 int val = 0;
3686
Sudip Mukherjee9aaffa32015-07-21 17:36:45 +05303687 dev = ((struct seq_file *)file->private_data)->private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003688
Todd Previteeb3394fa2015-04-18 00:04:19 -07003689 connector_list = &dev->mode_config.connector_list;
3690
3691 if (len == 0)
3692 return 0;
3693
3694 input_buffer = kmalloc(len + 1, GFP_KERNEL);
3695 if (!input_buffer)
3696 return -ENOMEM;
3697
3698 if (copy_from_user(input_buffer, ubuf, len)) {
3699 status = -EFAULT;
3700 goto out;
3701 }
3702
3703 input_buffer[len] = '\0';
3704 DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len);
3705
3706 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003707 if (connector->connector_type !=
3708 DRM_MODE_CONNECTOR_DisplayPort)
3709 continue;
3710
Sudip Mukherjeeb8bb08e2015-07-21 17:36:46 +05303711 if (connector->status == connector_status_connected &&
Todd Previteeb3394fa2015-04-18 00:04:19 -07003712 connector->encoder != NULL) {
3713 intel_dp = enc_to_intel_dp(connector->encoder);
3714 status = kstrtoint(input_buffer, 10, &val);
3715 if (status < 0)
3716 goto out;
3717 DRM_DEBUG_DRIVER("Got %d for test active\n", val);
3718 /* To prevent erroneous activation of the compliance
3719 * testing code, only accept an actual value of 1 here
3720 */
3721 if (val == 1)
Manasi Navarec1617ab2016-12-09 16:22:50 -08003722 intel_dp->compliance.test_active = 1;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003723 else
Manasi Navarec1617ab2016-12-09 16:22:50 -08003724 intel_dp->compliance.test_active = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003725 }
3726 }
3727out:
3728 kfree(input_buffer);
3729 if (status < 0)
3730 return status;
3731
3732 *offp += len;
3733 return len;
3734}
3735
3736static int i915_displayport_test_active_show(struct seq_file *m, void *data)
3737{
3738 struct drm_device *dev = m->private;
3739 struct drm_connector *connector;
3740 struct list_head *connector_list = &dev->mode_config.connector_list;
3741 struct intel_dp *intel_dp;
3742
Todd Previteeb3394fa2015-04-18 00:04:19 -07003743 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003744 if (connector->connector_type !=
3745 DRM_MODE_CONNECTOR_DisplayPort)
3746 continue;
3747
3748 if (connector->status == connector_status_connected &&
3749 connector->encoder != NULL) {
3750 intel_dp = enc_to_intel_dp(connector->encoder);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003751 if (intel_dp->compliance.test_active)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003752 seq_puts(m, "1");
3753 else
3754 seq_puts(m, "0");
3755 } else
3756 seq_puts(m, "0");
3757 }
3758
3759 return 0;
3760}
3761
3762static int i915_displayport_test_active_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03003763 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003764{
David Weinehall36cdd012016-08-22 13:59:31 +03003765 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003766
David Weinehall36cdd012016-08-22 13:59:31 +03003767 return single_open(file, i915_displayport_test_active_show,
3768 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003769}
3770
3771static const struct file_operations i915_displayport_test_active_fops = {
3772 .owner = THIS_MODULE,
3773 .open = i915_displayport_test_active_open,
3774 .read = seq_read,
3775 .llseek = seq_lseek,
3776 .release = single_release,
3777 .write = i915_displayport_test_active_write
3778};
3779
3780static int i915_displayport_test_data_show(struct seq_file *m, void *data)
3781{
3782 struct drm_device *dev = m->private;
3783 struct drm_connector *connector;
3784 struct list_head *connector_list = &dev->mode_config.connector_list;
3785 struct intel_dp *intel_dp;
3786
Todd Previteeb3394fa2015-04-18 00:04:19 -07003787 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003788 if (connector->connector_type !=
3789 DRM_MODE_CONNECTOR_DisplayPort)
3790 continue;
3791
3792 if (connector->status == connector_status_connected &&
3793 connector->encoder != NULL) {
3794 intel_dp = enc_to_intel_dp(connector->encoder);
Manasi Navareb48a5ba2017-01-20 19:09:28 -08003795 if (intel_dp->compliance.test_type ==
3796 DP_TEST_LINK_EDID_READ)
3797 seq_printf(m, "%lx",
3798 intel_dp->compliance.test_data.edid);
Manasi Navare611032b2017-01-24 08:21:49 -08003799 else if (intel_dp->compliance.test_type ==
3800 DP_TEST_LINK_VIDEO_PATTERN) {
3801 seq_printf(m, "hdisplay: %d\n",
3802 intel_dp->compliance.test_data.hdisplay);
3803 seq_printf(m, "vdisplay: %d\n",
3804 intel_dp->compliance.test_data.vdisplay);
3805 seq_printf(m, "bpc: %u\n",
3806 intel_dp->compliance.test_data.bpc);
3807 }
Todd Previteeb3394fa2015-04-18 00:04:19 -07003808 } else
3809 seq_puts(m, "0");
3810 }
3811
3812 return 0;
3813}
3814static int i915_displayport_test_data_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03003815 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003816{
David Weinehall36cdd012016-08-22 13:59:31 +03003817 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003818
David Weinehall36cdd012016-08-22 13:59:31 +03003819 return single_open(file, i915_displayport_test_data_show,
3820 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003821}
3822
3823static const struct file_operations i915_displayport_test_data_fops = {
3824 .owner = THIS_MODULE,
3825 .open = i915_displayport_test_data_open,
3826 .read = seq_read,
3827 .llseek = seq_lseek,
3828 .release = single_release
3829};
3830
3831static int i915_displayport_test_type_show(struct seq_file *m, void *data)
3832{
3833 struct drm_device *dev = m->private;
3834 struct drm_connector *connector;
3835 struct list_head *connector_list = &dev->mode_config.connector_list;
3836 struct intel_dp *intel_dp;
3837
Todd Previteeb3394fa2015-04-18 00:04:19 -07003838 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003839 if (connector->connector_type !=
3840 DRM_MODE_CONNECTOR_DisplayPort)
3841 continue;
3842
3843 if (connector->status == connector_status_connected &&
3844 connector->encoder != NULL) {
3845 intel_dp = enc_to_intel_dp(connector->encoder);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003846 seq_printf(m, "%02lx", intel_dp->compliance.test_type);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003847 } else
3848 seq_puts(m, "0");
3849 }
3850
3851 return 0;
3852}
3853
3854static int i915_displayport_test_type_open(struct inode *inode,
3855 struct file *file)
3856{
David Weinehall36cdd012016-08-22 13:59:31 +03003857 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003858
David Weinehall36cdd012016-08-22 13:59:31 +03003859 return single_open(file, i915_displayport_test_type_show,
3860 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003861}
3862
3863static const struct file_operations i915_displayport_test_type_fops = {
3864 .owner = THIS_MODULE,
3865 .open = i915_displayport_test_type_open,
3866 .read = seq_read,
3867 .llseek = seq_lseek,
3868 .release = single_release
3869};
3870
Damien Lespiau97e94b22014-11-04 17:06:50 +00003871static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02003872{
David Weinehall36cdd012016-08-22 13:59:31 +03003873 struct drm_i915_private *dev_priv = m->private;
3874 struct drm_device *dev = &dev_priv->drm;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003875 int level;
Ville Syrjäläde38b952015-06-24 22:00:09 +03003876 int num_levels;
3877
David Weinehall36cdd012016-08-22 13:59:31 +03003878 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003879 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03003880 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003881 num_levels = 1;
3882 else
Tvrtko Ursulin5db94012016-10-13 11:03:10 +01003883 num_levels = ilk_wm_max_level(dev_priv) + 1;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003884
3885 drm_modeset_lock_all(dev);
3886
3887 for (level = 0; level < num_levels; level++) {
3888 unsigned int latency = wm[level];
3889
Damien Lespiau97e94b22014-11-04 17:06:50 +00003890 /*
3891 * - WM1+ latency values in 0.5us units
Ville Syrjäläde38b952015-06-24 22:00:09 +03003892 * - latencies are in us on gen9/vlv/chv
Damien Lespiau97e94b22014-11-04 17:06:50 +00003893 */
David Weinehall36cdd012016-08-22 13:59:31 +03003894 if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) ||
3895 IS_CHERRYVIEW(dev_priv))
Damien Lespiau97e94b22014-11-04 17:06:50 +00003896 latency *= 10;
3897 else if (level > 0)
Ville Syrjälä369a1342014-01-22 14:36:08 +02003898 latency *= 5;
3899
3900 seq_printf(m, "WM%d %u (%u.%u usec)\n",
Damien Lespiau97e94b22014-11-04 17:06:50 +00003901 level, wm[level], latency / 10, latency % 10);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003902 }
3903
3904 drm_modeset_unlock_all(dev);
3905}
3906
3907static int pri_wm_latency_show(struct seq_file *m, void *data)
3908{
David Weinehall36cdd012016-08-22 13:59:31 +03003909 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003910 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003911
David Weinehall36cdd012016-08-22 13:59:31 +03003912 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003913 latencies = dev_priv->wm.skl_latency;
3914 else
David Weinehall36cdd012016-08-22 13:59:31 +03003915 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003916
3917 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003918
3919 return 0;
3920}
3921
3922static int spr_wm_latency_show(struct seq_file *m, void *data)
3923{
David Weinehall36cdd012016-08-22 13:59:31 +03003924 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003925 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003926
David Weinehall36cdd012016-08-22 13:59:31 +03003927 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003928 latencies = dev_priv->wm.skl_latency;
3929 else
David Weinehall36cdd012016-08-22 13:59:31 +03003930 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003931
3932 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003933
3934 return 0;
3935}
3936
3937static int cur_wm_latency_show(struct seq_file *m, void *data)
3938{
David Weinehall36cdd012016-08-22 13:59:31 +03003939 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003940 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003941
David Weinehall36cdd012016-08-22 13:59:31 +03003942 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003943 latencies = dev_priv->wm.skl_latency;
3944 else
David Weinehall36cdd012016-08-22 13:59:31 +03003945 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003946
3947 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003948
3949 return 0;
3950}
3951
3952static int pri_wm_latency_open(struct inode *inode, struct file *file)
3953{
David Weinehall36cdd012016-08-22 13:59:31 +03003954 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003955
David Weinehall36cdd012016-08-22 13:59:31 +03003956 if (INTEL_GEN(dev_priv) < 5)
Ville Syrjälä369a1342014-01-22 14:36:08 +02003957 return -ENODEV;
3958
David Weinehall36cdd012016-08-22 13:59:31 +03003959 return single_open(file, pri_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003960}
3961
3962static int spr_wm_latency_open(struct inode *inode, struct file *file)
3963{
David Weinehall36cdd012016-08-22 13:59:31 +03003964 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003965
David Weinehall36cdd012016-08-22 13:59:31 +03003966 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003967 return -ENODEV;
3968
David Weinehall36cdd012016-08-22 13:59:31 +03003969 return single_open(file, spr_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003970}
3971
3972static int cur_wm_latency_open(struct inode *inode, struct file *file)
3973{
David Weinehall36cdd012016-08-22 13:59:31 +03003974 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003975
David Weinehall36cdd012016-08-22 13:59:31 +03003976 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003977 return -ENODEV;
3978
David Weinehall36cdd012016-08-22 13:59:31 +03003979 return single_open(file, cur_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003980}
3981
3982static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
Damien Lespiau97e94b22014-11-04 17:06:50 +00003983 size_t len, loff_t *offp, uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02003984{
3985 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03003986 struct drm_i915_private *dev_priv = m->private;
3987 struct drm_device *dev = &dev_priv->drm;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003988 uint16_t new[8] = { 0 };
Ville Syrjäläde38b952015-06-24 22:00:09 +03003989 int num_levels;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003990 int level;
3991 int ret;
3992 char tmp[32];
3993
David Weinehall36cdd012016-08-22 13:59:31 +03003994 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003995 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03003996 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003997 num_levels = 1;
3998 else
Tvrtko Ursulin5db94012016-10-13 11:03:10 +01003999 num_levels = ilk_wm_max_level(dev_priv) + 1;
Ville Syrjäläde38b952015-06-24 22:00:09 +03004000
Ville Syrjälä369a1342014-01-22 14:36:08 +02004001 if (len >= sizeof(tmp))
4002 return -EINVAL;
4003
4004 if (copy_from_user(tmp, ubuf, len))
4005 return -EFAULT;
4006
4007 tmp[len] = '\0';
4008
Damien Lespiau97e94b22014-11-04 17:06:50 +00004009 ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
4010 &new[0], &new[1], &new[2], &new[3],
4011 &new[4], &new[5], &new[6], &new[7]);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004012 if (ret != num_levels)
4013 return -EINVAL;
4014
4015 drm_modeset_lock_all(dev);
4016
4017 for (level = 0; level < num_levels; level++)
4018 wm[level] = new[level];
4019
4020 drm_modeset_unlock_all(dev);
4021
4022 return len;
4023}
4024
4025
4026static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
4027 size_t len, loff_t *offp)
4028{
4029 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004030 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004031 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004032
David Weinehall36cdd012016-08-22 13:59:31 +03004033 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004034 latencies = dev_priv->wm.skl_latency;
4035 else
David Weinehall36cdd012016-08-22 13:59:31 +03004036 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004037
4038 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004039}
4040
4041static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
4042 size_t len, loff_t *offp)
4043{
4044 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004045 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004046 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004047
David Weinehall36cdd012016-08-22 13:59:31 +03004048 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004049 latencies = dev_priv->wm.skl_latency;
4050 else
David Weinehall36cdd012016-08-22 13:59:31 +03004051 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004052
4053 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004054}
4055
4056static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
4057 size_t len, loff_t *offp)
4058{
4059 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004060 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004061 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004062
David Weinehall36cdd012016-08-22 13:59:31 +03004063 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004064 latencies = dev_priv->wm.skl_latency;
4065 else
David Weinehall36cdd012016-08-22 13:59:31 +03004066 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004067
4068 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004069}
4070
4071static const struct file_operations i915_pri_wm_latency_fops = {
4072 .owner = THIS_MODULE,
4073 .open = pri_wm_latency_open,
4074 .read = seq_read,
4075 .llseek = seq_lseek,
4076 .release = single_release,
4077 .write = pri_wm_latency_write
4078};
4079
4080static const struct file_operations i915_spr_wm_latency_fops = {
4081 .owner = THIS_MODULE,
4082 .open = spr_wm_latency_open,
4083 .read = seq_read,
4084 .llseek = seq_lseek,
4085 .release = single_release,
4086 .write = spr_wm_latency_write
4087};
4088
4089static const struct file_operations i915_cur_wm_latency_fops = {
4090 .owner = THIS_MODULE,
4091 .open = cur_wm_latency_open,
4092 .read = seq_read,
4093 .llseek = seq_lseek,
4094 .release = single_release,
4095 .write = cur_wm_latency_write
4096};
4097
Kees Cook647416f2013-03-10 14:10:06 -07004098static int
4099i915_wedged_get(void *data, u64 *val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004100{
David Weinehall36cdd012016-08-22 13:59:31 +03004101 struct drm_i915_private *dev_priv = data;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004102
Chris Wilsond98c52c2016-04-13 17:35:05 +01004103 *val = i915_terminally_wedged(&dev_priv->gpu_error);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004104
Kees Cook647416f2013-03-10 14:10:06 -07004105 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004106}
4107
Kees Cook647416f2013-03-10 14:10:06 -07004108static int
4109i915_wedged_set(void *data, u64 val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004110{
David Weinehall36cdd012016-08-22 13:59:31 +03004111 struct drm_i915_private *dev_priv = data;
Imre Deakd46c0512014-04-14 20:24:27 +03004112
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004113 /*
4114 * There is no safeguard against this debugfs entry colliding
4115 * with the hangcheck calling same i915_handle_error() in
4116 * parallel, causing an explosion. For now we assume that the
4117 * test harness is responsible enough not to inject gpu hangs
4118 * while it is writing to 'i915_wedged'
4119 */
4120
Chris Wilsond98c52c2016-04-13 17:35:05 +01004121 if (i915_reset_in_progress(&dev_priv->gpu_error))
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004122 return -EAGAIN;
4123
Chris Wilsonc0336662016-05-06 15:40:21 +01004124 i915_handle_error(dev_priv, val,
Mika Kuoppala58174462014-02-25 17:11:26 +02004125 "Manually setting wedged to %llu", val);
Imre Deakd46c0512014-04-14 20:24:27 +03004126
Kees Cook647416f2013-03-10 14:10:06 -07004127 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004128}
4129
Kees Cook647416f2013-03-10 14:10:06 -07004130DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
4131 i915_wedged_get, i915_wedged_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004132 "%llu\n");
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004133
Kees Cook647416f2013-03-10 14:10:06 -07004134static int
Chris Wilson094f9a52013-09-25 17:34:55 +01004135i915_ring_missed_irq_get(void *data, u64 *val)
4136{
David Weinehall36cdd012016-08-22 13:59:31 +03004137 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004138
4139 *val = dev_priv->gpu_error.missed_irq_rings;
4140 return 0;
4141}
4142
4143static int
4144i915_ring_missed_irq_set(void *data, u64 val)
4145{
David Weinehall36cdd012016-08-22 13:59:31 +03004146 struct drm_i915_private *dev_priv = data;
4147 struct drm_device *dev = &dev_priv->drm;
Chris Wilson094f9a52013-09-25 17:34:55 +01004148 int ret;
4149
4150 /* Lock against concurrent debugfs callers */
4151 ret = mutex_lock_interruptible(&dev->struct_mutex);
4152 if (ret)
4153 return ret;
4154 dev_priv->gpu_error.missed_irq_rings = val;
4155 mutex_unlock(&dev->struct_mutex);
4156
4157 return 0;
4158}
4159
4160DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops,
4161 i915_ring_missed_irq_get, i915_ring_missed_irq_set,
4162 "0x%08llx\n");
4163
4164static int
4165i915_ring_test_irq_get(void *data, u64 *val)
4166{
David Weinehall36cdd012016-08-22 13:59:31 +03004167 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004168
4169 *val = dev_priv->gpu_error.test_irq_rings;
4170
4171 return 0;
4172}
4173
4174static int
4175i915_ring_test_irq_set(void *data, u64 val)
4176{
David Weinehall36cdd012016-08-22 13:59:31 +03004177 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004178
Chris Wilson3a122c22016-06-17 14:35:05 +01004179 val &= INTEL_INFO(dev_priv)->ring_mask;
Chris Wilson094f9a52013-09-25 17:34:55 +01004180 DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004181 dev_priv->gpu_error.test_irq_rings = val;
Chris Wilson094f9a52013-09-25 17:34:55 +01004182
4183 return 0;
4184}
4185
4186DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops,
4187 i915_ring_test_irq_get, i915_ring_test_irq_set,
4188 "0x%08llx\n");
4189
Chris Wilsondd624af2013-01-15 12:39:35 +00004190#define DROP_UNBOUND 0x1
4191#define DROP_BOUND 0x2
4192#define DROP_RETIRE 0x4
4193#define DROP_ACTIVE 0x8
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004194#define DROP_FREED 0x10
4195#define DROP_ALL (DROP_UNBOUND | \
4196 DROP_BOUND | \
4197 DROP_RETIRE | \
4198 DROP_ACTIVE | \
4199 DROP_FREED)
Kees Cook647416f2013-03-10 14:10:06 -07004200static int
4201i915_drop_caches_get(void *data, u64 *val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004202{
Kees Cook647416f2013-03-10 14:10:06 -07004203 *val = DROP_ALL;
Chris Wilsondd624af2013-01-15 12:39:35 +00004204
Kees Cook647416f2013-03-10 14:10:06 -07004205 return 0;
Chris Wilsondd624af2013-01-15 12:39:35 +00004206}
4207
Kees Cook647416f2013-03-10 14:10:06 -07004208static int
4209i915_drop_caches_set(void *data, u64 val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004210{
David Weinehall36cdd012016-08-22 13:59:31 +03004211 struct drm_i915_private *dev_priv = data;
4212 struct drm_device *dev = &dev_priv->drm;
Kees Cook647416f2013-03-10 14:10:06 -07004213 int ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004214
Ben Widawsky2f9fe5f2013-11-25 09:54:37 -08004215 DRM_DEBUG("Dropping caches: 0x%08llx\n", val);
Chris Wilsondd624af2013-01-15 12:39:35 +00004216
4217 /* No need to check and wait for gpu resets, only libdrm auto-restarts
4218 * on ioctls on -EAGAIN. */
4219 ret = mutex_lock_interruptible(&dev->struct_mutex);
4220 if (ret)
4221 return ret;
4222
4223 if (val & DROP_ACTIVE) {
Chris Wilson22dd3bb2016-09-09 14:11:50 +01004224 ret = i915_gem_wait_for_idle(dev_priv,
4225 I915_WAIT_INTERRUPTIBLE |
4226 I915_WAIT_LOCKED);
Chris Wilsondd624af2013-01-15 12:39:35 +00004227 if (ret)
4228 goto unlock;
4229 }
4230
4231 if (val & (DROP_RETIRE | DROP_ACTIVE))
Chris Wilsonc0336662016-05-06 15:40:21 +01004232 i915_gem_retire_requests(dev_priv);
Chris Wilsondd624af2013-01-15 12:39:35 +00004233
Chris Wilson21ab4e72014-09-09 11:16:08 +01004234 if (val & DROP_BOUND)
4235 i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND);
Chris Wilson4ad72b72014-09-03 19:23:37 +01004236
Chris Wilson21ab4e72014-09-09 11:16:08 +01004237 if (val & DROP_UNBOUND)
4238 i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND);
Chris Wilsondd624af2013-01-15 12:39:35 +00004239
4240unlock:
4241 mutex_unlock(&dev->struct_mutex);
4242
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004243 if (val & DROP_FREED) {
4244 synchronize_rcu();
Chris Wilsonbdeb9782016-12-23 14:57:56 +00004245 i915_gem_drain_freed_objects(dev_priv);
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004246 }
4247
Kees Cook647416f2013-03-10 14:10:06 -07004248 return ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004249}
4250
Kees Cook647416f2013-03-10 14:10:06 -07004251DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
4252 i915_drop_caches_get, i915_drop_caches_set,
4253 "0x%08llx\n");
Chris Wilsondd624af2013-01-15 12:39:35 +00004254
Kees Cook647416f2013-03-10 14:10:06 -07004255static int
4256i915_max_freq_get(void *data, u64 *val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004257{
David Weinehall36cdd012016-08-22 13:59:31 +03004258 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004259
David Weinehall36cdd012016-08-22 13:59:31 +03004260 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004261 return -ENODEV;
4262
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02004263 *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004264 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004265}
4266
Kees Cook647416f2013-03-10 14:10:06 -07004267static int
4268i915_max_freq_set(void *data, u64 val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004269{
David Weinehall36cdd012016-08-22 13:59:31 +03004270 struct drm_i915_private *dev_priv = data;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304271 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004272 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004273
David Weinehall36cdd012016-08-22 13:59:31 +03004274 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004275 return -ENODEV;
Jesse Barnes358733e2011-07-27 11:53:01 -07004276
Kees Cook647416f2013-03-10 14:10:06 -07004277 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val);
Jesse Barnes358733e2011-07-27 11:53:01 -07004278
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004279 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004280 if (ret)
4281 return ret;
4282
Jesse Barnes358733e2011-07-27 11:53:01 -07004283 /*
4284 * Turbo will still be enabled, but won't go above the set value.
4285 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304286 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004287
Akash Goelbc4d91f2015-02-26 16:09:47 +05304288 hw_max = dev_priv->rps.max_freq;
4289 hw_min = dev_priv->rps.min_freq;
Jesse Barnes0a073b82013-04-17 15:54:58 -07004290
Ben Widawskyb39fb292014-03-19 18:31:11 -07004291 if (val < hw_min || val > hw_max || val < dev_priv->rps.min_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004292 mutex_unlock(&dev_priv->rps.hw_lock);
4293 return -EINVAL;
4294 }
4295
Ben Widawskyb39fb292014-03-19 18:31:11 -07004296 dev_priv->rps.max_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004297
Chris Wilson9fcee2f2017-01-26 10:19:19 +00004298 if (intel_set_rps(dev_priv, val))
4299 DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n");
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004300
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004301 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes358733e2011-07-27 11:53:01 -07004302
Kees Cook647416f2013-03-10 14:10:06 -07004303 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004304}
4305
Kees Cook647416f2013-03-10 14:10:06 -07004306DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
4307 i915_max_freq_get, i915_max_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004308 "%llu\n");
Jesse Barnes358733e2011-07-27 11:53:01 -07004309
Kees Cook647416f2013-03-10 14:10:06 -07004310static int
4311i915_min_freq_get(void *data, u64 *val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004312{
David Weinehall36cdd012016-08-22 13:59:31 +03004313 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004314
Chris Wilson62e1baa2016-07-13 09:10:36 +01004315 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004316 return -ENODEV;
4317
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02004318 *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004319 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004320}
4321
Kees Cook647416f2013-03-10 14:10:06 -07004322static int
4323i915_min_freq_set(void *data, u64 val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004324{
David Weinehall36cdd012016-08-22 13:59:31 +03004325 struct drm_i915_private *dev_priv = data;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304326 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004327 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004328
Chris Wilson62e1baa2016-07-13 09:10:36 +01004329 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004330 return -ENODEV;
Jesse Barnes1523c312012-05-25 12:34:54 -07004331
Kees Cook647416f2013-03-10 14:10:06 -07004332 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val);
Jesse Barnes1523c312012-05-25 12:34:54 -07004333
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004334 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004335 if (ret)
4336 return ret;
4337
Jesse Barnes1523c312012-05-25 12:34:54 -07004338 /*
4339 * Turbo will still be enabled, but won't go below the set value.
4340 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304341 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004342
Akash Goelbc4d91f2015-02-26 16:09:47 +05304343 hw_max = dev_priv->rps.max_freq;
4344 hw_min = dev_priv->rps.min_freq;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004345
David Weinehall36cdd012016-08-22 13:59:31 +03004346 if (val < hw_min ||
4347 val > hw_max || val > dev_priv->rps.max_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004348 mutex_unlock(&dev_priv->rps.hw_lock);
4349 return -EINVAL;
4350 }
4351
Ben Widawskyb39fb292014-03-19 18:31:11 -07004352 dev_priv->rps.min_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004353
Chris Wilson9fcee2f2017-01-26 10:19:19 +00004354 if (intel_set_rps(dev_priv, val))
4355 DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n");
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004356
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004357 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes1523c312012-05-25 12:34:54 -07004358
Kees Cook647416f2013-03-10 14:10:06 -07004359 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004360}
4361
Kees Cook647416f2013-03-10 14:10:06 -07004362DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
4363 i915_min_freq_get, i915_min_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004364 "%llu\n");
Jesse Barnes1523c312012-05-25 12:34:54 -07004365
Kees Cook647416f2013-03-10 14:10:06 -07004366static int
4367i915_cache_sharing_get(void *data, u64 *val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004368{
David Weinehall36cdd012016-08-22 13:59:31 +03004369 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004370 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004371
David Weinehall36cdd012016-08-22 13:59:31 +03004372 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004373 return -ENODEV;
4374
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004375 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02004376
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004377 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004378
4379 intel_runtime_pm_put(dev_priv);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004380
Kees Cook647416f2013-03-10 14:10:06 -07004381 *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004382
Kees Cook647416f2013-03-10 14:10:06 -07004383 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004384}
4385
Kees Cook647416f2013-03-10 14:10:06 -07004386static int
4387i915_cache_sharing_set(void *data, u64 val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004388{
David Weinehall36cdd012016-08-22 13:59:31 +03004389 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004390 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004391
David Weinehall36cdd012016-08-22 13:59:31 +03004392 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004393 return -ENODEV;
4394
Kees Cook647416f2013-03-10 14:10:06 -07004395 if (val > 3)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004396 return -EINVAL;
4397
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004398 intel_runtime_pm_get(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004399 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004400
4401 /* Update the cache sharing policy here as well */
4402 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
4403 snpcr &= ~GEN6_MBC_SNPCR_MASK;
4404 snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
4405 I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
4406
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004407 intel_runtime_pm_put(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004408 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004409}
4410
Kees Cook647416f2013-03-10 14:10:06 -07004411DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops,
4412 i915_cache_sharing_get, i915_cache_sharing_set,
4413 "%llu\n");
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004414
David Weinehall36cdd012016-08-22 13:59:31 +03004415static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004416 struct sseu_dev_info *sseu)
Jeff McGee5d395252015-04-03 18:13:17 -07004417{
Ville Syrjälä0a0b4572015-08-21 20:45:27 +03004418 int ss_max = 2;
Jeff McGee5d395252015-04-03 18:13:17 -07004419 int ss;
4420 u32 sig1[ss_max], sig2[ss_max];
4421
4422 sig1[0] = I915_READ(CHV_POWER_SS0_SIG1);
4423 sig1[1] = I915_READ(CHV_POWER_SS1_SIG1);
4424 sig2[0] = I915_READ(CHV_POWER_SS0_SIG2);
4425 sig2[1] = I915_READ(CHV_POWER_SS1_SIG2);
4426
4427 for (ss = 0; ss < ss_max; ss++) {
4428 unsigned int eu_cnt;
4429
4430 if (sig1[ss] & CHV_SS_PG_ENABLE)
4431 /* skip disabled subslice */
4432 continue;
4433
Imre Deakf08a0c92016-08-31 19:13:04 +03004434 sseu->slice_mask = BIT(0);
Imre Deak57ec1712016-08-31 19:13:05 +03004435 sseu->subslice_mask |= BIT(ss);
Jeff McGee5d395252015-04-03 18:13:17 -07004436 eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) +
4437 ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) +
4438 ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) +
4439 ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2);
Imre Deak915490d2016-08-31 19:13:01 +03004440 sseu->eu_total += eu_cnt;
4441 sseu->eu_per_subslice = max_t(unsigned int,
4442 sseu->eu_per_subslice, eu_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07004443 }
Jeff McGee5d395252015-04-03 18:13:17 -07004444}
4445
David Weinehall36cdd012016-08-22 13:59:31 +03004446static void gen9_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004447 struct sseu_dev_info *sseu)
Jeff McGee5d395252015-04-03 18:13:17 -07004448{
Jeff McGee1c046bc2015-04-03 18:13:18 -07004449 int s_max = 3, ss_max = 4;
Jeff McGee5d395252015-04-03 18:13:17 -07004450 int s, ss;
4451 u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2];
4452
Jeff McGee1c046bc2015-04-03 18:13:18 -07004453 /* BXT has a single slice and at most 3 subslices. */
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02004454 if (IS_GEN9_LP(dev_priv)) {
Jeff McGee1c046bc2015-04-03 18:13:18 -07004455 s_max = 1;
4456 ss_max = 3;
4457 }
4458
4459 for (s = 0; s < s_max; s++) {
4460 s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s));
4461 eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s));
4462 eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s));
4463 }
4464
Jeff McGee5d395252015-04-03 18:13:17 -07004465 eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK |
4466 GEN9_PGCTL_SSA_EU19_ACK |
4467 GEN9_PGCTL_SSA_EU210_ACK |
4468 GEN9_PGCTL_SSA_EU311_ACK;
4469 eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK |
4470 GEN9_PGCTL_SSB_EU19_ACK |
4471 GEN9_PGCTL_SSB_EU210_ACK |
4472 GEN9_PGCTL_SSB_EU311_ACK;
4473
4474 for (s = 0; s < s_max; s++) {
4475 if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0)
4476 /* skip disabled slice */
4477 continue;
4478
Imre Deakf08a0c92016-08-31 19:13:04 +03004479 sseu->slice_mask |= BIT(s);
Jeff McGee1c046bc2015-04-03 18:13:18 -07004480
Rodrigo Vivib976dc52017-01-23 10:32:37 -08004481 if (IS_GEN9_BC(dev_priv))
Imre Deak57ec1712016-08-31 19:13:05 +03004482 sseu->subslice_mask =
4483 INTEL_INFO(dev_priv)->sseu.subslice_mask;
Jeff McGee1c046bc2015-04-03 18:13:18 -07004484
Jeff McGee5d395252015-04-03 18:13:17 -07004485 for (ss = 0; ss < ss_max; ss++) {
4486 unsigned int eu_cnt;
4487
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02004488 if (IS_GEN9_LP(dev_priv)) {
Imre Deak57ec1712016-08-31 19:13:05 +03004489 if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss))))
4490 /* skip disabled subslice */
4491 continue;
Jeff McGee1c046bc2015-04-03 18:13:18 -07004492
Imre Deak57ec1712016-08-31 19:13:05 +03004493 sseu->subslice_mask |= BIT(ss);
4494 }
Jeff McGee1c046bc2015-04-03 18:13:18 -07004495
Jeff McGee5d395252015-04-03 18:13:17 -07004496 eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] &
4497 eu_mask[ss%2]);
Imre Deak915490d2016-08-31 19:13:01 +03004498 sseu->eu_total += eu_cnt;
4499 sseu->eu_per_subslice = max_t(unsigned int,
4500 sseu->eu_per_subslice,
4501 eu_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07004502 }
4503 }
4504}
4505
David Weinehall36cdd012016-08-22 13:59:31 +03004506static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004507 struct sseu_dev_info *sseu)
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004508{
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004509 u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
David Weinehall36cdd012016-08-22 13:59:31 +03004510 int s;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004511
Imre Deakf08a0c92016-08-31 19:13:04 +03004512 sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004513
Imre Deakf08a0c92016-08-31 19:13:04 +03004514 if (sseu->slice_mask) {
Imre Deak57ec1712016-08-31 19:13:05 +03004515 sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask;
Imre Deak43b67992016-08-31 19:13:02 +03004516 sseu->eu_per_subslice =
4517 INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
Imre Deak57ec1712016-08-31 19:13:05 +03004518 sseu->eu_total = sseu->eu_per_subslice *
4519 sseu_subslice_total(sseu);
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004520
4521 /* subtract fused off EU(s) from enabled slice(s) */
Imre Deak795b38b2016-08-31 19:13:07 +03004522 for (s = 0; s < fls(sseu->slice_mask); s++) {
Imre Deak43b67992016-08-31 19:13:02 +03004523 u8 subslice_7eu =
4524 INTEL_INFO(dev_priv)->sseu.subslice_7eu[s];
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004525
Imre Deak915490d2016-08-31 19:13:01 +03004526 sseu->eu_total -= hweight8(subslice_7eu);
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004527 }
4528 }
4529}
4530
Imre Deak615d8902016-08-31 19:13:03 +03004531static void i915_print_sseu_info(struct seq_file *m, bool is_available_info,
4532 const struct sseu_dev_info *sseu)
4533{
4534 struct drm_i915_private *dev_priv = node_to_i915(m->private);
4535 const char *type = is_available_info ? "Available" : "Enabled";
4536
Imre Deakc67ba532016-08-31 19:13:06 +03004537 seq_printf(m, " %s Slice Mask: %04x\n", type,
4538 sseu->slice_mask);
Imre Deak615d8902016-08-31 19:13:03 +03004539 seq_printf(m, " %s Slice Total: %u\n", type,
Imre Deakf08a0c92016-08-31 19:13:04 +03004540 hweight8(sseu->slice_mask));
Imre Deak615d8902016-08-31 19:13:03 +03004541 seq_printf(m, " %s Subslice Total: %u\n", type,
Imre Deak57ec1712016-08-31 19:13:05 +03004542 sseu_subslice_total(sseu));
Imre Deakc67ba532016-08-31 19:13:06 +03004543 seq_printf(m, " %s Subslice Mask: %04x\n", type,
4544 sseu->subslice_mask);
Imre Deak615d8902016-08-31 19:13:03 +03004545 seq_printf(m, " %s Subslice Per Slice: %u\n", type,
Imre Deak57ec1712016-08-31 19:13:05 +03004546 hweight8(sseu->subslice_mask));
Imre Deak615d8902016-08-31 19:13:03 +03004547 seq_printf(m, " %s EU Total: %u\n", type,
4548 sseu->eu_total);
4549 seq_printf(m, " %s EU Per Subslice: %u\n", type,
4550 sseu->eu_per_subslice);
4551
4552 if (!is_available_info)
4553 return;
4554
4555 seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv)));
4556 if (HAS_POOLED_EU(dev_priv))
4557 seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool);
4558
4559 seq_printf(m, " Has Slice Power Gating: %s\n",
4560 yesno(sseu->has_slice_pg));
4561 seq_printf(m, " Has Subslice Power Gating: %s\n",
4562 yesno(sseu->has_subslice_pg));
4563 seq_printf(m, " Has EU Power Gating: %s\n",
4564 yesno(sseu->has_eu_pg));
4565}
4566
Jeff McGee38732182015-02-13 10:27:54 -06004567static int i915_sseu_status(struct seq_file *m, void *unused)
4568{
David Weinehall36cdd012016-08-22 13:59:31 +03004569 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak915490d2016-08-31 19:13:01 +03004570 struct sseu_dev_info sseu;
Jeff McGee38732182015-02-13 10:27:54 -06004571
David Weinehall36cdd012016-08-22 13:59:31 +03004572 if (INTEL_GEN(dev_priv) < 8)
Jeff McGee38732182015-02-13 10:27:54 -06004573 return -ENODEV;
4574
4575 seq_puts(m, "SSEU Device Info\n");
Imre Deak615d8902016-08-31 19:13:03 +03004576 i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu);
Jeff McGee38732182015-02-13 10:27:54 -06004577
Jeff McGee7f992ab2015-02-13 10:27:55 -06004578 seq_puts(m, "SSEU Device Status\n");
Imre Deak915490d2016-08-31 19:13:01 +03004579 memset(&sseu, 0, sizeof(sseu));
David Weinehall238010e2016-08-01 17:33:27 +03004580
4581 intel_runtime_pm_get(dev_priv);
4582
David Weinehall36cdd012016-08-22 13:59:31 +03004583 if (IS_CHERRYVIEW(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004584 cherryview_sseu_device_status(dev_priv, &sseu);
David Weinehall36cdd012016-08-22 13:59:31 +03004585 } else if (IS_BROADWELL(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004586 broadwell_sseu_device_status(dev_priv, &sseu);
David Weinehall36cdd012016-08-22 13:59:31 +03004587 } else if (INTEL_GEN(dev_priv) >= 9) {
Imre Deak915490d2016-08-31 19:13:01 +03004588 gen9_sseu_device_status(dev_priv, &sseu);
Jeff McGee7f992ab2015-02-13 10:27:55 -06004589 }
David Weinehall238010e2016-08-01 17:33:27 +03004590
4591 intel_runtime_pm_put(dev_priv);
4592
Imre Deak615d8902016-08-31 19:13:03 +03004593 i915_print_sseu_info(m, false, &sseu);
Jeff McGee7f992ab2015-02-13 10:27:55 -06004594
Jeff McGee38732182015-02-13 10:27:54 -06004595 return 0;
4596}
4597
Ben Widawsky6d794d42011-04-25 11:25:56 -07004598static int i915_forcewake_open(struct inode *inode, struct file *file)
4599{
David Weinehall36cdd012016-08-22 13:59:31 +03004600 struct drm_i915_private *dev_priv = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004601
David Weinehall36cdd012016-08-22 13:59:31 +03004602 if (INTEL_GEN(dev_priv) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004603 return 0;
4604
Chris Wilson6daccb02015-01-16 11:34:35 +02004605 intel_runtime_pm_get(dev_priv);
Mika Kuoppala59bad942015-01-16 11:34:40 +02004606 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004607
4608 return 0;
4609}
4610
Ben Widawskyc43b5632012-04-16 14:07:40 -07004611static int i915_forcewake_release(struct inode *inode, struct file *file)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004612{
David Weinehall36cdd012016-08-22 13:59:31 +03004613 struct drm_i915_private *dev_priv = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004614
David Weinehall36cdd012016-08-22 13:59:31 +03004615 if (INTEL_GEN(dev_priv) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004616 return 0;
4617
Mika Kuoppala59bad942015-01-16 11:34:40 +02004618 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Chris Wilson6daccb02015-01-16 11:34:35 +02004619 intel_runtime_pm_put(dev_priv);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004620
4621 return 0;
4622}
4623
4624static const struct file_operations i915_forcewake_fops = {
4625 .owner = THIS_MODULE,
4626 .open = i915_forcewake_open,
4627 .release = i915_forcewake_release,
4628};
4629
4630static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
4631{
Ben Widawsky6d794d42011-04-25 11:25:56 -07004632 struct dentry *ent;
4633
4634 ent = debugfs_create_file("i915_forcewake_user",
Ben Widawsky8eb57292011-05-11 15:10:58 -07004635 S_IRUSR,
David Weinehall36cdd012016-08-22 13:59:31 +03004636 root, to_i915(minor->dev),
Ben Widawsky6d794d42011-04-25 11:25:56 -07004637 &i915_forcewake_fops);
Wei Yongjunf3c5fe92013-12-16 14:13:25 +08004638 if (!ent)
4639 return -ENOMEM;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004640
Ben Widawsky8eb57292011-05-11 15:10:58 -07004641 return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004642}
4643
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004644static int i915_debugfs_create(struct dentry *root,
4645 struct drm_minor *minor,
4646 const char *name,
4647 const struct file_operations *fops)
Jesse Barnes358733e2011-07-27 11:53:01 -07004648{
Jesse Barnes358733e2011-07-27 11:53:01 -07004649 struct dentry *ent;
4650
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004651 ent = debugfs_create_file(name,
Jesse Barnes358733e2011-07-27 11:53:01 -07004652 S_IRUGO | S_IWUSR,
David Weinehall36cdd012016-08-22 13:59:31 +03004653 root, to_i915(minor->dev),
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004654 fops);
Wei Yongjunf3c5fe92013-12-16 14:13:25 +08004655 if (!ent)
4656 return -ENOMEM;
Jesse Barnes358733e2011-07-27 11:53:01 -07004657
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004658 return drm_add_fake_info_node(minor, ent, fops);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004659}
4660
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01004661static const struct drm_info_list i915_debugfs_list[] = {
Chris Wilson311bd682011-01-13 19:06:50 +00004662 {"i915_capabilities", i915_capabilities, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01004663 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson08c18322011-01-10 00:00:24 +00004664 {"i915_gem_gtt", i915_gem_gtt_info, 0},
Chris Wilson6da84822016-08-15 10:48:44 +01004665 {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1},
Chris Wilson6d2b88852013-08-07 18:30:54 +01004666 {"i915_gem_stolen", i915_gem_stolen_list_info },
Simon Farnsworth4e5359c2010-09-01 17:47:52 +01004667 {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004668 {"i915_gem_request", i915_gem_request_info, 0},
4669 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00004670 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004671 {"i915_gem_interrupt", i915_interrupt_info, 0},
Brad Volkin493018d2014-12-11 12:13:08 -08004672 {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0},
Dave Gordon8b417c22015-08-12 15:43:44 +01004673 {"i915_guc_info", i915_guc_info, 0},
Alex Daifdf5d352015-08-12 15:43:37 +01004674 {"i915_guc_load_status", i915_guc_load_status_info, 0},
Alex Dai4c7e77f2015-08-12 15:43:40 +01004675 {"i915_guc_log_dump", i915_guc_log_dump, 0},
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08004676 {"i915_huc_load_status", i915_huc_load_status_info, 0},
Deepak Sadb4bd12014-03-31 11:30:02 +05304677 {"i915_frequency_info", i915_frequency_info, 0},
Chris Wilsonf6544492015-01-26 18:03:04 +02004678 {"i915_hangcheck_info", i915_hangcheck_info, 0},
Jesse Barnesf97108d2010-01-29 11:27:07 -08004679 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07004680 {"i915_emon_status", i915_emon_status, 0},
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07004681 {"i915_ring_freq_table", i915_ring_freq_table, 0},
Daniel Vetter9a851782015-06-18 10:30:22 +02004682 {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08004683 {"i915_fbc_status", i915_fbc_status, 0},
Paulo Zanoni92d44622013-05-31 16:33:24 -03004684 {"i915_ips_status", i915_ips_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08004685 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01004686 {"i915_opregion", i915_opregion, 0},
Jani Nikulaada8f952015-12-15 13:17:12 +02004687 {"i915_vbt", i915_vbt, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01004688 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Widawskye76d3632011-03-19 18:14:29 -07004689 {"i915_context_status", i915_context_status, 0},
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01004690 {"i915_dump_lrc", i915_dump_lrc, 0},
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02004691 {"i915_forcewake_domains", i915_forcewake_domains, 0},
Daniel Vetterea16a3c2011-12-14 13:57:16 +01004692 {"i915_swizzle_info", i915_swizzle_info, 0},
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01004693 {"i915_ppgtt_info", i915_ppgtt_info, 0},
Ben Widawsky63573eb2013-07-04 11:02:07 -07004694 {"i915_llc", i915_llc, 0},
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03004695 {"i915_edp_psr_status", i915_edp_psr_status, 0},
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02004696 {"i915_sink_crc_eDP1", i915_sink_crc, 0},
Jesse Barnesec013e72013-08-20 10:29:23 +01004697 {"i915_energy_uJ", i915_energy_uJ, 0},
Damien Lespiau6455c872015-06-04 18:23:57 +01004698 {"i915_runtime_pm_status", i915_runtime_pm_status, 0},
Imre Deak1da51582013-11-25 17:15:35 +02004699 {"i915_power_domain_info", i915_power_domain_info, 0},
Damien Lespiaub7cec662015-10-27 14:47:01 +02004700 {"i915_dmc_info", i915_dmc_info, 0},
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08004701 {"i915_display_info", i915_display_info, 0},
Chris Wilson1b365952016-10-04 21:11:31 +01004702 {"i915_engine_info", i915_engine_info, 0},
Ben Widawskye04934c2014-06-30 09:53:42 -07004703 {"i915_semaphore_status", i915_semaphore_status, 0},
Daniel Vetter728e29d2014-06-25 22:01:53 +03004704 {"i915_shared_dplls_info", i915_shared_dplls_info, 0},
Dave Airlie11bed952014-05-12 15:22:27 +10004705 {"i915_dp_mst_info", i915_dp_mst_info, 0},
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01004706 {"i915_wa_registers", i915_wa_registers, 0},
Damien Lespiauc5511e42014-11-04 17:06:51 +00004707 {"i915_ddb_info", i915_ddb_info, 0},
Jeff McGee38732182015-02-13 10:27:54 -06004708 {"i915_sseu_status", i915_sseu_status, 0},
Vandana Kannana54746e2015-03-03 20:53:10 +05304709 {"i915_drrs_status", i915_drrs_status, 0},
Chris Wilson1854d5c2015-04-07 16:20:32 +01004710 {"i915_rps_boost_info", i915_rps_boost_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004711};
Ben Gamari27c202a2009-07-01 22:26:52 -04004712#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05004713
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01004714static const struct i915_debugfs_files {
Daniel Vetter34b96742013-07-04 20:49:44 +02004715 const char *name;
4716 const struct file_operations *fops;
4717} i915_debugfs_files[] = {
4718 {"i915_wedged", &i915_wedged_fops},
4719 {"i915_max_freq", &i915_max_freq_fops},
4720 {"i915_min_freq", &i915_min_freq_fops},
4721 {"i915_cache_sharing", &i915_cache_sharing_fops},
Chris Wilson094f9a52013-09-25 17:34:55 +01004722 {"i915_ring_missed_irq", &i915_ring_missed_irq_fops},
4723 {"i915_ring_test_irq", &i915_ring_test_irq_fops},
Daniel Vetter34b96742013-07-04 20:49:44 +02004724 {"i915_gem_drop_caches", &i915_drop_caches_fops},
Chris Wilson98a2f412016-10-12 10:05:18 +01004725#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
Daniel Vetter34b96742013-07-04 20:49:44 +02004726 {"i915_error_state", &i915_error_state_fops},
Chris Wilson98a2f412016-10-12 10:05:18 +01004727#endif
Daniel Vetter34b96742013-07-04 20:49:44 +02004728 {"i915_next_seqno", &i915_next_seqno_fops},
Damien Lespiaubd9db022013-10-15 18:55:36 +01004729 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
Ville Syrjälä369a1342014-01-22 14:36:08 +02004730 {"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
4731 {"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
4732 {"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
Rodrigo Vivida46f932014-08-01 02:04:45 -07004733 {"i915_fbc_false_color", &i915_fbc_fc_fops},
Todd Previteeb3394fa2015-04-18 00:04:19 -07004734 {"i915_dp_test_data", &i915_displayport_test_data_fops},
4735 {"i915_dp_test_type", &i915_displayport_test_type_fops},
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05304736 {"i915_dp_test_active", &i915_displayport_test_active_fops},
4737 {"i915_guc_log_control", &i915_guc_log_control_fops}
Daniel Vetter34b96742013-07-04 20:49:44 +02004738};
4739
Chris Wilson1dac8912016-06-24 14:00:17 +01004740int i915_debugfs_register(struct drm_i915_private *dev_priv)
Ben Gamari20172632009-02-17 20:08:50 -05004741{
Chris Wilson91c8a322016-07-05 10:40:23 +01004742 struct drm_minor *minor = dev_priv->drm.primary;
Daniel Vetter34b96742013-07-04 20:49:44 +02004743 int ret, i;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004744
Ben Widawsky6d794d42011-04-25 11:25:56 -07004745 ret = i915_forcewake_create(minor->debugfs_root, minor);
4746 if (ret)
4747 return ret;
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004748
Tomeu Vizoso731035f2016-12-12 13:29:48 +01004749 ret = intel_pipe_crc_create(minor);
4750 if (ret)
4751 return ret;
Damien Lespiau07144422013-10-15 18:55:40 +01004752
Daniel Vetter34b96742013-07-04 20:49:44 +02004753 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
4754 ret = i915_debugfs_create(minor->debugfs_root, minor,
4755 i915_debugfs_files[i].name,
4756 i915_debugfs_files[i].fops);
4757 if (ret)
4758 return ret;
4759 }
Mika Kuoppala40633212012-12-04 15:12:00 +02004760
Ben Gamari27c202a2009-07-01 22:26:52 -04004761 return drm_debugfs_create_files(i915_debugfs_list,
4762 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05004763 minor->debugfs_root, minor);
4764}
4765
Chris Wilson1dac8912016-06-24 14:00:17 +01004766void i915_debugfs_unregister(struct drm_i915_private *dev_priv)
Ben Gamari20172632009-02-17 20:08:50 -05004767{
Chris Wilson91c8a322016-07-05 10:40:23 +01004768 struct drm_minor *minor = dev_priv->drm.primary;
Daniel Vetter34b96742013-07-04 20:49:44 +02004769 int i;
4770
Ben Gamari27c202a2009-07-01 22:26:52 -04004771 drm_debugfs_remove_files(i915_debugfs_list,
4772 I915_DEBUGFS_ENTRIES, minor);
Damien Lespiau07144422013-10-15 18:55:40 +01004773
David Weinehall36cdd012016-08-22 13:59:31 +03004774 drm_debugfs_remove_files((struct drm_info_list *)&i915_forcewake_fops,
Ben Widawsky6d794d42011-04-25 11:25:56 -07004775 1, minor);
Damien Lespiau07144422013-10-15 18:55:40 +01004776
Tomeu Vizoso731035f2016-12-12 13:29:48 +01004777 intel_pipe_crc_cleanup(minor);
Damien Lespiau07144422013-10-15 18:55:40 +01004778
Daniel Vetter34b96742013-07-04 20:49:44 +02004779 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
4780 struct drm_info_list *info_list =
David Weinehall36cdd012016-08-22 13:59:31 +03004781 (struct drm_info_list *)i915_debugfs_files[i].fops;
Daniel Vetter34b96742013-07-04 20:49:44 +02004782
4783 drm_debugfs_remove_files(info_list, 1, minor);
4784 }
Ben Gamari20172632009-02-17 20:08:50 -05004785}
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004786
4787struct dpcd_block {
4788 /* DPCD dump start address. */
4789 unsigned int offset;
4790 /* DPCD dump end address, inclusive. If unset, .size will be used. */
4791 unsigned int end;
4792 /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */
4793 size_t size;
4794 /* Only valid for eDP. */
4795 bool edp;
4796};
4797
4798static const struct dpcd_block i915_dpcd_debug[] = {
4799 { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE },
4800 { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS },
4801 { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 },
4802 { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET },
4803 { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 },
4804 { .offset = DP_SET_POWER },
4805 { .offset = DP_EDP_DPCD_REV },
4806 { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 },
4807 { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB },
4808 { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET },
4809};
4810
4811static int i915_dpcd_show(struct seq_file *m, void *data)
4812{
4813 struct drm_connector *connector = m->private;
4814 struct intel_dp *intel_dp =
4815 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
4816 uint8_t buf[16];
4817 ssize_t err;
4818 int i;
4819
Mika Kuoppala5c1a8872015-05-15 13:09:21 +03004820 if (connector->status != connector_status_connected)
4821 return -ENODEV;
4822
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004823 for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) {
4824 const struct dpcd_block *b = &i915_dpcd_debug[i];
4825 size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1);
4826
4827 if (b->edp &&
4828 connector->connector_type != DRM_MODE_CONNECTOR_eDP)
4829 continue;
4830
4831 /* low tech for now */
4832 if (WARN_ON(size > sizeof(buf)))
4833 continue;
4834
4835 err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size);
4836 if (err <= 0) {
4837 DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n",
4838 size, b->offset, err);
4839 continue;
4840 }
4841
4842 seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf);
kbuild test robotb3f9d7d2015-04-16 18:34:06 +08004843 }
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004844
4845 return 0;
4846}
4847
4848static int i915_dpcd_open(struct inode *inode, struct file *file)
4849{
4850 return single_open(file, i915_dpcd_show, inode->i_private);
4851}
4852
4853static const struct file_operations i915_dpcd_fops = {
4854 .owner = THIS_MODULE,
4855 .open = i915_dpcd_open,
4856 .read = seq_read,
4857 .llseek = seq_lseek,
4858 .release = single_release,
4859};
4860
David Weinehallecbd6782016-08-23 12:23:56 +03004861static int i915_panel_show(struct seq_file *m, void *data)
4862{
4863 struct drm_connector *connector = m->private;
4864 struct intel_dp *intel_dp =
4865 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
4866
4867 if (connector->status != connector_status_connected)
4868 return -ENODEV;
4869
4870 seq_printf(m, "Panel power up delay: %d\n",
4871 intel_dp->panel_power_up_delay);
4872 seq_printf(m, "Panel power down delay: %d\n",
4873 intel_dp->panel_power_down_delay);
4874 seq_printf(m, "Backlight on delay: %d\n",
4875 intel_dp->backlight_on_delay);
4876 seq_printf(m, "Backlight off delay: %d\n",
4877 intel_dp->backlight_off_delay);
4878
4879 return 0;
4880}
4881
4882static int i915_panel_open(struct inode *inode, struct file *file)
4883{
4884 return single_open(file, i915_panel_show, inode->i_private);
4885}
4886
4887static const struct file_operations i915_panel_fops = {
4888 .owner = THIS_MODULE,
4889 .open = i915_panel_open,
4890 .read = seq_read,
4891 .llseek = seq_lseek,
4892 .release = single_release,
4893};
4894
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004895/**
4896 * i915_debugfs_connector_add - add i915 specific connector debugfs files
4897 * @connector: pointer to a registered drm_connector
4898 *
4899 * Cleanup will be done by drm_connector_unregister() through a call to
4900 * drm_debugfs_connector_remove().
4901 *
4902 * Returns 0 on success, negative error codes on error.
4903 */
4904int i915_debugfs_connector_add(struct drm_connector *connector)
4905{
4906 struct dentry *root = connector->debugfs_entry;
4907
4908 /* The connector must have been registered beforehands. */
4909 if (!root)
4910 return -ENODEV;
4911
4912 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
4913 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
David Weinehallecbd6782016-08-23 12:23:56 +03004914 debugfs_create_file("i915_dpcd", S_IRUGO, root,
4915 connector, &i915_dpcd_fops);
4916
4917 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP)
4918 debugfs_create_file("i915_panel_timings", S_IRUGO, root,
4919 connector, &i915_panel_fops);
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004920
4921 return 0;
4922}