blob: e2390df22e08799c2aa679d71e319ffe0a19b145 [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 Wilsone637d2c2017-03-16 13:19:57 +000030#include <linux/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
Chris Wilson418e3cd2017-02-06 21:36:08 +000038static __always_inline void seq_print_param(struct seq_file *m,
39 const char *name,
40 const char *type,
41 const void *x)
42{
43 if (!__builtin_strcmp(type, "bool"))
44 seq_printf(m, "i915.%s=%s\n", name, yesno(*(const bool *)x));
45 else if (!__builtin_strcmp(type, "int"))
46 seq_printf(m, "i915.%s=%d\n", name, *(const int *)x);
47 else if (!__builtin_strcmp(type, "unsigned int"))
48 seq_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x);
Chris Wilson1d6aa7a2017-02-21 16:26:19 +000049 else if (!__builtin_strcmp(type, "char *"))
50 seq_printf(m, "i915.%s=%s\n", name, *(const char **)x);
Chris Wilson418e3cd2017-02-06 21:36:08 +000051 else
52 BUILD_BUG();
53}
54
Chris Wilson70d39fe2010-08-25 16:03:34 +010055static int i915_capabilities(struct seq_file *m, void *data)
56{
David Weinehall36cdd012016-08-22 13:59:31 +030057 struct drm_i915_private *dev_priv = node_to_i915(m->private);
58 const struct intel_device_info *info = INTEL_INFO(dev_priv);
Chris Wilson70d39fe2010-08-25 16:03:34 +010059
David Weinehall36cdd012016-08-22 13:59:31 +030060 seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv));
Jani Nikula2e0d26f2016-12-01 14:49:55 +020061 seq_printf(m, "platform: %s\n", intel_platform_name(info->platform));
David Weinehall36cdd012016-08-22 13:59:31 +030062 seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv));
Chris Wilson418e3cd2017-02-06 21:36:08 +000063
Damien Lespiau79fc46d2013-04-23 16:37:17 +010064#define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
Joonas Lahtinen604db652016-10-05 13:50:16 +030065 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
Damien Lespiau79fc46d2013-04-23 16:37:17 +010066#undef PRINT_FLAG
Chris Wilson70d39fe2010-08-25 16:03:34 +010067
Chris Wilson418e3cd2017-02-06 21:36:08 +000068 kernel_param_lock(THIS_MODULE);
69#define PRINT_PARAM(T, x) seq_print_param(m, #x, #T, &i915.x);
70 I915_PARAMS_FOR_EACH(PRINT_PARAM);
71#undef PRINT_PARAM
72 kernel_param_unlock(THIS_MODULE);
73
Chris Wilson70d39fe2010-08-25 16:03:34 +010074 return 0;
75}
Ben Gamari433e12f2009-02-17 20:08:51 -050076
Imre Deaka7363de2016-05-12 16:18:52 +030077static char get_active_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000078{
Chris Wilson573adb32016-08-04 16:32:39 +010079 return i915_gem_object_is_active(obj) ? '*' : ' ';
Chris Wilsona6172a82009-02-11 14:26:38 +000080}
81
Imre Deaka7363de2016-05-12 16:18:52 +030082static char get_pin_flag(struct drm_i915_gem_object *obj)
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +010083{
84 return obj->pin_display ? 'p' : ' ';
85}
86
Imre Deaka7363de2016-05-12 16:18:52 +030087static char get_tiling_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000088{
Chris Wilson3e510a82016-08-05 10:14:23 +010089 switch (i915_gem_object_get_tiling(obj)) {
Akshay Joshi0206e352011-08-16 15:34:10 -040090 default:
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +010091 case I915_TILING_NONE: return ' ';
92 case I915_TILING_X: return 'X';
93 case I915_TILING_Y: return 'Y';
Akshay Joshi0206e352011-08-16 15:34:10 -040094 }
Chris Wilsona6172a82009-02-11 14:26:38 +000095}
96
Imre Deaka7363de2016-05-12 16:18:52 +030097static char get_global_flag(struct drm_i915_gem_object *obj)
Ben Widawsky1d693bc2013-07-31 17:00:00 -070098{
Chris Wilson275f0392016-10-24 13:42:14 +010099 return !list_empty(&obj->userfault_link) ? 'g' : ' ';
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100100}
101
Imre Deaka7363de2016-05-12 16:18:52 +0300102static char get_pin_mapped_flag(struct drm_i915_gem_object *obj)
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100103{
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100104 return obj->mm.mapping ? 'M' : ' ';
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700105}
106
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100107static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
108{
109 u64 size = 0;
110 struct i915_vma *vma;
111
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000112 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson3272db52016-08-04 16:32:32 +0100113 if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node))
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100114 size += vma->node.size;
115 }
116
117 return size;
118}
119
Chris Wilson37811fc2010-08-25 22:45:57 +0100120static void
121describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
122{
Chris Wilsonb4716182015-04-27 13:41:17 +0100123 struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000124 struct intel_engine_cs *engine;
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700125 struct i915_vma *vma;
Chris Wilsonfaf5bf02016-08-04 16:32:37 +0100126 unsigned int frontbuffer_bits;
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800127 int pin_count = 0;
128
Chris Wilson188c1ab2016-04-03 14:14:20 +0100129 lockdep_assert_held(&obj->base.dev->struct_mutex);
130
Chris Wilsond07f0e52016-10-28 13:58:44 +0100131 seq_printf(m, "%pK: %c%c%c%c%c %8zdKiB %02x %02x %s%s%s",
Chris Wilson37811fc2010-08-25 22:45:57 +0100132 &obj->base,
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100133 get_active_flag(obj),
Chris Wilson37811fc2010-08-25 22:45:57 +0100134 get_pin_flag(obj),
135 get_tiling_flag(obj),
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700136 get_global_flag(obj),
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100137 get_pin_mapped_flag(obj),
Eric Anholta05a5862011-12-20 08:54:15 -0800138 obj->base.size / 1024,
Chris Wilson37811fc2010-08-25 22:45:57 +0100139 obj->base.read_domains,
Chris Wilsond07f0e52016-10-28 13:58:44 +0100140 obj->base.write_domain,
David Weinehall36cdd012016-08-22 13:59:31 +0300141 i915_cache_level_str(dev_priv, obj->cache_level),
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100142 obj->mm.dirty ? " dirty" : "",
143 obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : "");
Chris Wilson37811fc2010-08-25 22:45:57 +0100144 if (obj->base.name)
145 seq_printf(m, " (name: %d)", obj->base.name);
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000146 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson20dfbde2016-08-04 16:32:30 +0100147 if (i915_vma_is_pinned(vma))
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800148 pin_count++;
Dan Carpenterba0635ff2015-02-25 16:17:48 +0300149 }
150 seq_printf(m, " (pinned x %d)", pin_count);
Chris Wilsoncc98b412013-08-09 12:25:09 +0100151 if (obj->pin_display)
152 seq_printf(m, " (display)");
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000153 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson15717de2016-08-04 07:52:26 +0100154 if (!drm_mm_node_allocated(&vma->node))
155 continue;
156
Tvrtko Ursulin8d2fdc32015-05-27 10:52:32 +0100157 seq_printf(m, " (%sgtt offset: %08llx, size: %08llx",
Chris Wilson3272db52016-08-04 16:32:32 +0100158 i915_vma_is_ggtt(vma) ? "g" : "pp",
Tvrtko Ursulin8d2fdc32015-05-27 10:52:32 +0100159 vma->node.start, vma->node.size);
Chris Wilson21976852017-01-12 11:21:08 +0000160 if (i915_vma_is_ggtt(vma)) {
161 switch (vma->ggtt_view.type) {
162 case I915_GGTT_VIEW_NORMAL:
163 seq_puts(m, ", normal");
164 break;
165
166 case I915_GGTT_VIEW_PARTIAL:
167 seq_printf(m, ", partial [%08llx+%x]",
Chris Wilson8bab11932017-01-14 00:28:25 +0000168 vma->ggtt_view.partial.offset << PAGE_SHIFT,
169 vma->ggtt_view.partial.size << PAGE_SHIFT);
Chris Wilson21976852017-01-12 11:21:08 +0000170 break;
171
172 case I915_GGTT_VIEW_ROTATED:
173 seq_printf(m, ", rotated [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]",
Chris Wilson8bab11932017-01-14 00:28:25 +0000174 vma->ggtt_view.rotated.plane[0].width,
175 vma->ggtt_view.rotated.plane[0].height,
176 vma->ggtt_view.rotated.plane[0].stride,
177 vma->ggtt_view.rotated.plane[0].offset,
178 vma->ggtt_view.rotated.plane[1].width,
179 vma->ggtt_view.rotated.plane[1].height,
180 vma->ggtt_view.rotated.plane[1].stride,
181 vma->ggtt_view.rotated.plane[1].offset);
Chris Wilson21976852017-01-12 11:21:08 +0000182 break;
183
184 default:
185 MISSING_CASE(vma->ggtt_view.type);
186 break;
187 }
188 }
Chris Wilson49ef5292016-08-18 17:17:00 +0100189 if (vma->fence)
190 seq_printf(m, " , fence: %d%s",
191 vma->fence->id,
192 i915_gem_active_isset(&vma->last_fence) ? "*" : "");
Chris Wilson596c5922016-02-26 11:03:20 +0000193 seq_puts(m, ")");
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700194 }
Chris Wilsonc1ad11f2012-11-15 11:32:21 +0000195 if (obj->stolen)
Thierry Reding440fd522015-01-23 09:05:06 +0100196 seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
Chris Wilson27c01aa2016-08-04 07:52:30 +0100197
Chris Wilsond07f0e52016-10-28 13:58:44 +0100198 engine = i915_gem_object_last_write_engine(obj);
Chris Wilson27c01aa2016-08-04 07:52:30 +0100199 if (engine)
200 seq_printf(m, " (%s)", engine->name);
201
Chris Wilsonfaf5bf02016-08-04 16:32:37 +0100202 frontbuffer_bits = atomic_read(&obj->frontbuffer_bits);
203 if (frontbuffer_bits)
204 seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits);
Chris Wilson37811fc2010-08-25 22:45:57 +0100205}
206
Chris Wilsone637d2c2017-03-16 13:19:57 +0000207static int obj_rank_by_stolen(const void *A, const void *B)
Chris Wilson6d2b88852013-08-07 18:30:54 +0100208{
Chris Wilsone637d2c2017-03-16 13:19:57 +0000209 const struct drm_i915_gem_object *a =
210 *(const struct drm_i915_gem_object **)A;
211 const struct drm_i915_gem_object *b =
212 *(const struct drm_i915_gem_object **)B;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100213
Rasmus Villemoes2d05fa12015-09-28 23:08:50 +0200214 if (a->stolen->start < b->stolen->start)
215 return -1;
216 if (a->stolen->start > b->stolen->start)
217 return 1;
218 return 0;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100219}
220
221static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
222{
David Weinehall36cdd012016-08-22 13:59:31 +0300223 struct drm_i915_private *dev_priv = node_to_i915(m->private);
224 struct drm_device *dev = &dev_priv->drm;
Chris Wilsone637d2c2017-03-16 13:19:57 +0000225 struct drm_i915_gem_object **objects;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100226 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300227 u64 total_obj_size, total_gtt_size;
Chris Wilsone637d2c2017-03-16 13:19:57 +0000228 unsigned long total, count, n;
229 int ret;
230
231 total = READ_ONCE(dev_priv->mm.object_count);
232 objects = drm_malloc_ab(total, sizeof(*objects));
233 if (!objects)
234 return -ENOMEM;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100235
236 ret = mutex_lock_interruptible(&dev->struct_mutex);
237 if (ret)
Chris Wilsone637d2c2017-03-16 13:19:57 +0000238 goto out;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100239
240 total_obj_size = total_gtt_size = count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200241 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilsone637d2c2017-03-16 13:19:57 +0000242 if (count == total)
243 break;
244
Chris Wilson6d2b88852013-08-07 18:30:54 +0100245 if (obj->stolen == NULL)
246 continue;
247
Chris Wilsone637d2c2017-03-16 13:19:57 +0000248 objects[count++] = obj;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100249 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100250 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilsone637d2c2017-03-16 13:19:57 +0000251
Chris Wilson6d2b88852013-08-07 18:30:54 +0100252 }
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200253 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) {
Chris Wilsone637d2c2017-03-16 13:19:57 +0000254 if (count == total)
255 break;
256
Chris Wilson6d2b88852013-08-07 18:30:54 +0100257 if (obj->stolen == NULL)
258 continue;
259
Chris Wilsone637d2c2017-03-16 13:19:57 +0000260 objects[count++] = obj;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100261 total_obj_size += obj->base.size;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100262 }
Chris Wilson6d2b88852013-08-07 18:30:54 +0100263
Chris Wilsone637d2c2017-03-16 13:19:57 +0000264 sort(objects, count, sizeof(*objects), obj_rank_by_stolen, NULL);
265
266 seq_puts(m, "Stolen:\n");
267 for (n = 0; n < count; n++) {
268 seq_puts(m, " ");
269 describe_obj(m, objects[n]);
270 seq_putc(m, '\n');
271 }
272 seq_printf(m, "Total %lu objects, %llu bytes, %llu GTT size\n",
Chris Wilson6d2b88852013-08-07 18:30:54 +0100273 count, total_obj_size, total_gtt_size);
Chris Wilsone637d2c2017-03-16 13:19:57 +0000274
275 mutex_unlock(&dev->struct_mutex);
276out:
277 drm_free_large(objects);
278 return ret;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100279}
280
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100281struct file_stats {
Chris Wilson6313c202014-03-19 13:45:45 +0000282 struct drm_i915_file_private *file_priv;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300283 unsigned long count;
284 u64 total, unbound;
285 u64 global, shared;
286 u64 active, inactive;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100287};
288
289static int per_file_stats(int id, void *ptr, void *data)
290{
291 struct drm_i915_gem_object *obj = ptr;
292 struct file_stats *stats = data;
Chris Wilson6313c202014-03-19 13:45:45 +0000293 struct i915_vma *vma;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100294
295 stats->count++;
296 stats->total += obj->base.size;
Chris Wilson15717de2016-08-04 07:52:26 +0100297 if (!obj->bind_count)
298 stats->unbound += obj->base.size;
Chris Wilsonc67a17e2014-03-19 13:45:46 +0000299 if (obj->base.name || obj->base.dma_buf)
300 stats->shared += obj->base.size;
301
Chris Wilson894eeec2016-08-04 07:52:20 +0100302 list_for_each_entry(vma, &obj->vma_list, obj_link) {
303 if (!drm_mm_node_allocated(&vma->node))
304 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000305
Chris Wilson3272db52016-08-04 16:32:32 +0100306 if (i915_vma_is_ggtt(vma)) {
Chris Wilson894eeec2016-08-04 07:52:20 +0100307 stats->global += vma->node.size;
308 } else {
309 struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm);
Chris Wilson6313c202014-03-19 13:45:45 +0000310
Chris Wilson2bfa9962016-08-04 07:52:25 +0100311 if (ppgtt->base.file != stats->file_priv)
Chris Wilson6313c202014-03-19 13:45:45 +0000312 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000313 }
Chris Wilson894eeec2016-08-04 07:52:20 +0100314
Chris Wilsonb0decaf2016-08-04 07:52:44 +0100315 if (i915_vma_is_active(vma))
Chris Wilson894eeec2016-08-04 07:52:20 +0100316 stats->active += vma->node.size;
317 else
318 stats->inactive += vma->node.size;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100319 }
320
321 return 0;
322}
323
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100324#define print_file_stats(m, name, stats) do { \
325 if (stats.count) \
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300326 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 +0100327 name, \
328 stats.count, \
329 stats.total, \
330 stats.active, \
331 stats.inactive, \
332 stats.global, \
333 stats.shared, \
334 stats.unbound); \
335} while (0)
Brad Volkin493018d2014-12-11 12:13:08 -0800336
337static void print_batch_pool_stats(struct seq_file *m,
338 struct drm_i915_private *dev_priv)
339{
340 struct drm_i915_gem_object *obj;
341 struct file_stats stats;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000342 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530343 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000344 int j;
Brad Volkin493018d2014-12-11 12:13:08 -0800345
346 memset(&stats, 0, sizeof(stats));
347
Akash Goel3b3f1652016-10-13 22:44:48 +0530348 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000349 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100350 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000351 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100352 batch_pool_link)
353 per_file_stats(0, obj, &stats);
354 }
Chris Wilson06fbca72015-04-07 16:20:36 +0100355 }
Brad Volkin493018d2014-12-11 12:13:08 -0800356
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100357 print_file_stats(m, "[k]batch pool", stats);
Brad Volkin493018d2014-12-11 12:13:08 -0800358}
359
Chris Wilson15da9562016-05-24 14:53:43 +0100360static int per_file_ctx_stats(int id, void *ptr, void *data)
361{
362 struct i915_gem_context *ctx = ptr;
363 int n;
364
365 for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) {
366 if (ctx->engine[n].state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +0100367 per_file_stats(0, ctx->engine[n].state->obj, data);
Chris Wilsondca33ec2016-08-02 22:50:20 +0100368 if (ctx->engine[n].ring)
Chris Wilson57e88532016-08-15 10:48:57 +0100369 per_file_stats(0, ctx->engine[n].ring->vma->obj, data);
Chris Wilson15da9562016-05-24 14:53:43 +0100370 }
371
372 return 0;
373}
374
375static void print_context_stats(struct seq_file *m,
376 struct drm_i915_private *dev_priv)
377{
David Weinehall36cdd012016-08-22 13:59:31 +0300378 struct drm_device *dev = &dev_priv->drm;
Chris Wilson15da9562016-05-24 14:53:43 +0100379 struct file_stats stats;
380 struct drm_file *file;
381
382 memset(&stats, 0, sizeof(stats));
383
David Weinehall36cdd012016-08-22 13:59:31 +0300384 mutex_lock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100385 if (dev_priv->kernel_context)
386 per_file_ctx_stats(0, dev_priv->kernel_context, &stats);
387
David Weinehall36cdd012016-08-22 13:59:31 +0300388 list_for_each_entry(file, &dev->filelist, lhead) {
Chris Wilson15da9562016-05-24 14:53:43 +0100389 struct drm_i915_file_private *fpriv = file->driver_priv;
390 idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats);
391 }
David Weinehall36cdd012016-08-22 13:59:31 +0300392 mutex_unlock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100393
394 print_file_stats(m, "[k]contexts", stats);
395}
396
David Weinehall36cdd012016-08-22 13:59:31 +0300397static int i915_gem_object_info(struct seq_file *m, void *data)
Chris Wilson73aa8082010-09-30 11:46:12 +0100398{
David Weinehall36cdd012016-08-22 13:59:31 +0300399 struct drm_i915_private *dev_priv = node_to_i915(m->private);
400 struct drm_device *dev = &dev_priv->drm;
Joonas Lahtinen72e96d62016-03-30 16:57:10 +0300401 struct i915_ggtt *ggtt = &dev_priv->ggtt;
Chris Wilson2bd160a2016-08-15 10:48:45 +0100402 u32 count, mapped_count, purgeable_count, dpy_count;
403 u64 size, mapped_size, purgeable_size, dpy_size;
Chris Wilson6299f992010-11-24 12:23:44 +0000404 struct drm_i915_gem_object *obj;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100405 struct drm_file *file;
Chris Wilson73aa8082010-09-30 11:46:12 +0100406 int ret;
407
408 ret = mutex_lock_interruptible(&dev->struct_mutex);
409 if (ret)
410 return ret;
411
Chris Wilson3ef7f222016-10-18 13:02:48 +0100412 seq_printf(m, "%u objects, %llu bytes\n",
Chris Wilson6299f992010-11-24 12:23:44 +0000413 dev_priv->mm.object_count,
414 dev_priv->mm.object_memory);
415
Chris Wilson1544c422016-08-15 13:18:16 +0100416 size = count = 0;
417 mapped_size = mapped_count = 0;
418 purgeable_size = purgeable_count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200419 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100420 size += obj->base.size;
421 ++count;
Chris Wilson6c085a72012-08-20 11:40:46 +0200422
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100423 if (obj->mm.madv == I915_MADV_DONTNEED) {
Chris Wilsonb7abb712012-08-20 11:33:30 +0200424 purgeable_size += obj->base.size;
425 ++purgeable_count;
426 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100427
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100428 if (obj->mm.mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100429 mapped_count++;
430 mapped_size += obj->base.size;
Tvrtko Ursulinbe19b102016-04-15 11:34:53 +0100431 }
Chris Wilson6299f992010-11-24 12:23:44 +0000432 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100433 seq_printf(m, "%u unbound objects, %llu bytes\n", count, size);
434
435 size = count = dpy_size = dpy_count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200436 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100437 size += obj->base.size;
438 ++count;
439
440 if (obj->pin_display) {
441 dpy_size += obj->base.size;
442 ++dpy_count;
443 }
444
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100445 if (obj->mm.madv == I915_MADV_DONTNEED) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100446 purgeable_size += obj->base.size;
447 ++purgeable_count;
448 }
449
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100450 if (obj->mm.mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100451 mapped_count++;
452 mapped_size += obj->base.size;
453 }
454 }
455 seq_printf(m, "%u bound objects, %llu bytes\n",
456 count, size);
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300457 seq_printf(m, "%u purgeable objects, %llu bytes\n",
Chris Wilsonb7abb712012-08-20 11:33:30 +0200458 purgeable_count, purgeable_size);
Chris Wilson2bd160a2016-08-15 10:48:45 +0100459 seq_printf(m, "%u mapped objects, %llu bytes\n",
460 mapped_count, mapped_size);
461 seq_printf(m, "%u display objects (pinned), %llu bytes\n",
462 dpy_count, dpy_size);
Chris Wilson6299f992010-11-24 12:23:44 +0000463
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300464 seq_printf(m, "%llu [%llu] gtt total\n",
Chris Wilson381b9432017-02-15 08:43:54 +0000465 ggtt->base.total, ggtt->mappable_end);
Chris Wilson73aa8082010-09-30 11:46:12 +0100466
Damien Lespiau267f0c92013-06-24 22:59:48 +0100467 seq_putc(m, '\n');
Brad Volkin493018d2014-12-11 12:13:08 -0800468 print_batch_pool_stats(m, dev_priv);
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200469 mutex_unlock(&dev->struct_mutex);
470
471 mutex_lock(&dev->filelist_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100472 print_context_stats(m, dev_priv);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100473 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
474 struct file_stats stats;
Chris Wilsonc84455b2016-08-15 10:49:08 +0100475 struct drm_i915_file_private *file_priv = file->driver_priv;
476 struct drm_i915_gem_request *request;
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900477 struct task_struct *task;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100478
479 memset(&stats, 0, sizeof(stats));
Chris Wilson6313c202014-03-19 13:45:45 +0000480 stats.file_priv = file->driver_priv;
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100481 spin_lock(&file->table_lock);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100482 idr_for_each(&file->object_idr, per_file_stats, &stats);
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100483 spin_unlock(&file->table_lock);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900484 /*
485 * Although we have a valid reference on file->pid, that does
486 * not guarantee that the task_struct who called get_pid() is
487 * still alive (e.g. get_pid(current) => fork() => exit()).
488 * Therefore, we need to protect this ->comm access using RCU.
489 */
Chris Wilsonc84455b2016-08-15 10:49:08 +0100490 mutex_lock(&dev->struct_mutex);
491 request = list_first_entry_or_null(&file_priv->mm.request_list,
492 struct drm_i915_gem_request,
Chris Wilsonc8659ef2017-03-02 12:25:25 +0000493 client_link);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900494 rcu_read_lock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100495 task = pid_task(request && request->ctx->pid ?
496 request->ctx->pid : file->pid,
497 PIDTYPE_PID);
Brad Volkin493018d2014-12-11 12:13:08 -0800498 print_file_stats(m, task ? task->comm : "<unknown>", stats);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900499 rcu_read_unlock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100500 mutex_unlock(&dev->struct_mutex);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100501 }
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200502 mutex_unlock(&dev->filelist_mutex);
Chris Wilson73aa8082010-09-30 11:46:12 +0100503
504 return 0;
505}
506
Damien Lespiauaee56cf2013-06-24 22:59:49 +0100507static int i915_gem_gtt_info(struct seq_file *m, void *data)
Chris Wilson08c18322011-01-10 00:00:24 +0000508{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100509 struct drm_info_node *node = m->private;
David Weinehall36cdd012016-08-22 13:59:31 +0300510 struct drm_i915_private *dev_priv = node_to_i915(node);
511 struct drm_device *dev = &dev_priv->drm;
Chris Wilson5f4b0912016-08-19 12:56:25 +0100512 bool show_pin_display_only = !!node->info_ent->data;
Chris Wilson08c18322011-01-10 00:00:24 +0000513 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300514 u64 total_obj_size, total_gtt_size;
Chris Wilson08c18322011-01-10 00:00:24 +0000515 int count, ret;
516
517 ret = mutex_lock_interruptible(&dev->struct_mutex);
518 if (ret)
519 return ret;
520
521 total_obj_size = total_gtt_size = count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200522 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilson6da84822016-08-15 10:48:44 +0100523 if (show_pin_display_only && !obj->pin_display)
Chris Wilson1b502472012-04-24 15:47:30 +0100524 continue;
525
Damien Lespiau267f0c92013-06-24 22:59:48 +0100526 seq_puts(m, " ");
Chris Wilson08c18322011-01-10 00:00:24 +0000527 describe_obj(m, obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100528 seq_putc(m, '\n');
Chris Wilson08c18322011-01-10 00:00:24 +0000529 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100530 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilson08c18322011-01-10 00:00:24 +0000531 count++;
532 }
533
534 mutex_unlock(&dev->struct_mutex);
535
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300536 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
Chris Wilson08c18322011-01-10 00:00:24 +0000537 count, total_obj_size, total_gtt_size);
538
539 return 0;
540}
541
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100542static int i915_gem_pageflip_info(struct seq_file *m, void *data)
543{
David Weinehall36cdd012016-08-22 13:59:31 +0300544 struct drm_i915_private *dev_priv = node_to_i915(m->private);
545 struct drm_device *dev = &dev_priv->drm;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100546 struct intel_crtc *crtc;
Daniel Vetter8a270eb2014-06-17 22:34:37 +0200547 int ret;
548
549 ret = mutex_lock_interruptible(&dev->struct_mutex);
550 if (ret)
551 return ret;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100552
Damien Lespiaud3fcc802014-05-13 23:32:22 +0100553 for_each_intel_crtc(dev, crtc) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800554 const char pipe = pipe_name(crtc->pipe);
555 const char plane = plane_name(crtc->plane);
Maarten Lankhorst51cbaf02016-05-17 15:07:49 +0200556 struct intel_flip_work *work;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100557
Daniel Vetter5e2d7af2014-09-15 14:55:22 +0200558 spin_lock_irq(&dev->event_lock);
Daniel Vetter5a21b662016-05-24 17:13:53 +0200559 work = crtc->flip_work;
560 if (work == NULL) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800561 seq_printf(m, "No flip due on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100562 pipe, plane);
563 } else {
Daniel Vetter5a21b662016-05-24 17:13:53 +0200564 u32 pending;
565 u32 addr;
566
567 pending = atomic_read(&work->pending);
568 if (pending) {
569 seq_printf(m, "Flip ioctl preparing on pipe %c (plane %c)\n",
570 pipe, plane);
571 } else {
572 seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
573 pipe, plane);
574 }
575 if (work->flip_queued_req) {
Joonas Lahtinen24327f82016-11-08 09:11:48 +0200576 struct intel_engine_cs *engine = work->flip_queued_req->engine;
Daniel Vetter5a21b662016-05-24 17:13:53 +0200577
Chris Wilson312c3c42016-11-24 14:47:50 +0000578 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 +0200579 engine->name,
Joonas Lahtinen24327f82016-11-08 09:11:48 +0200580 work->flip_queued_req->global_seqno,
Chris Wilson312c3c42016-11-24 14:47:50 +0000581 intel_engine_last_submit(engine),
Chris Wilson1b7744e2016-07-01 17:23:17 +0100582 intel_engine_get_seqno(engine),
Chris Wilsonf69a02c2016-07-01 17:23:16 +0100583 i915_gem_request_completed(work->flip_queued_req));
Daniel Vetter5a21b662016-05-24 17:13:53 +0200584 } else
585 seq_printf(m, "Flip not associated with any ring\n");
586 seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n",
587 work->flip_queued_vblank,
588 work->flip_ready_vblank,
589 intel_crtc_get_vblank_counter(crtc));
590 seq_printf(m, "%d prepares\n", atomic_read(&work->pending));
591
David Weinehall36cdd012016-08-22 13:59:31 +0300592 if (INTEL_GEN(dev_priv) >= 4)
Daniel Vetter5a21b662016-05-24 17:13:53 +0200593 addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane)));
594 else
595 addr = I915_READ(DSPADDR(crtc->plane));
596 seq_printf(m, "Current scanout address 0x%08x\n", addr);
597
598 if (work->pending_flip_obj) {
599 seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset);
600 seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100601 }
602 }
Daniel Vetter5e2d7af2014-09-15 14:55:22 +0200603 spin_unlock_irq(&dev->event_lock);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100604 }
605
Daniel Vetter8a270eb2014-06-17 22:34:37 +0200606 mutex_unlock(&dev->struct_mutex);
607
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100608 return 0;
609}
610
Brad Volkin493018d2014-12-11 12:13:08 -0800611static int i915_gem_batch_pool_info(struct seq_file *m, void *data)
612{
David Weinehall36cdd012016-08-22 13:59:31 +0300613 struct drm_i915_private *dev_priv = node_to_i915(m->private);
614 struct drm_device *dev = &dev_priv->drm;
Brad Volkin493018d2014-12-11 12:13:08 -0800615 struct drm_i915_gem_object *obj;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000616 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530617 enum intel_engine_id id;
Chris Wilson8d9d5742015-04-07 16:20:38 +0100618 int total = 0;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000619 int ret, j;
Brad Volkin493018d2014-12-11 12:13:08 -0800620
621 ret = mutex_lock_interruptible(&dev->struct_mutex);
622 if (ret)
623 return ret;
624
Akash Goel3b3f1652016-10-13 22:44:48 +0530625 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000626 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100627 int count;
628
629 count = 0;
630 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000631 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100632 batch_pool_link)
633 count++;
634 seq_printf(m, "%s cache[%d]: %d objects\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000635 engine->name, j, count);
Chris Wilson8d9d5742015-04-07 16:20:38 +0100636
637 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000638 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100639 batch_pool_link) {
640 seq_puts(m, " ");
641 describe_obj(m, obj);
642 seq_putc(m, '\n');
643 }
644
645 total += count;
Chris Wilson06fbca72015-04-07 16:20:36 +0100646 }
Brad Volkin493018d2014-12-11 12:13:08 -0800647 }
648
Chris Wilson8d9d5742015-04-07 16:20:38 +0100649 seq_printf(m, "total: %d\n", total);
Brad Volkin493018d2014-12-11 12:13:08 -0800650
651 mutex_unlock(&dev->struct_mutex);
652
653 return 0;
654}
655
Chris Wilson1b365952016-10-04 21:11:31 +0100656static void print_request(struct seq_file *m,
657 struct drm_i915_gem_request *rq,
658 const char *prefix)
659{
Chris Wilson20311bd2016-11-14 20:41:03 +0000660 seq_printf(m, "%s%x [%x:%x] prio=%d @ %dms: %s\n", prefix,
Chris Wilson65e47602016-10-28 13:58:49 +0100661 rq->global_seqno, rq->ctx->hw_id, rq->fence.seqno,
Chris Wilson20311bd2016-11-14 20:41:03 +0000662 rq->priotree.priority,
Chris Wilson1b365952016-10-04 21:11:31 +0100663 jiffies_to_msecs(jiffies - rq->emitted_jiffies),
Chris Wilson562f5d42016-10-28 13:58:54 +0100664 rq->timeline->common->name);
Chris Wilson1b365952016-10-04 21:11:31 +0100665}
666
Ben Gamari20172632009-02-17 20:08:50 -0500667static int i915_gem_request_info(struct seq_file *m, void *data)
668{
David Weinehall36cdd012016-08-22 13:59:31 +0300669 struct drm_i915_private *dev_priv = node_to_i915(m->private);
670 struct drm_device *dev = &dev_priv->drm;
Daniel Vettereed29a52015-05-21 14:21:25 +0200671 struct drm_i915_gem_request *req;
Akash Goel3b3f1652016-10-13 22:44:48 +0530672 struct intel_engine_cs *engine;
673 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000674 int ret, any;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100675
676 ret = mutex_lock_interruptible(&dev->struct_mutex);
677 if (ret)
678 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500679
Chris Wilson2d1070b2015-04-01 10:36:56 +0100680 any = 0;
Akash Goel3b3f1652016-10-13 22:44:48 +0530681 for_each_engine(engine, dev_priv, id) {
Chris Wilson2d1070b2015-04-01 10:36:56 +0100682 int count;
683
684 count = 0;
Chris Wilson73cb9702016-10-28 13:58:46 +0100685 list_for_each_entry(req, &engine->timeline->requests, link)
Chris Wilson2d1070b2015-04-01 10:36:56 +0100686 count++;
687 if (count == 0)
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100688 continue;
689
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000690 seq_printf(m, "%s requests: %d\n", engine->name, count);
Chris Wilson73cb9702016-10-28 13:58:46 +0100691 list_for_each_entry(req, &engine->timeline->requests, link)
Chris Wilson1b365952016-10-04 21:11:31 +0100692 print_request(m, req, " ");
Chris Wilson2d1070b2015-04-01 10:36:56 +0100693
694 any++;
Ben Gamari20172632009-02-17 20:08:50 -0500695 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100696 mutex_unlock(&dev->struct_mutex);
697
Chris Wilson2d1070b2015-04-01 10:36:56 +0100698 if (any == 0)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100699 seq_puts(m, "No requests\n");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100700
Ben Gamari20172632009-02-17 20:08:50 -0500701 return 0;
702}
703
Chris Wilsonb2223492010-10-27 15:27:33 +0100704static void i915_ring_seqno_info(struct seq_file *m,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +0000705 struct intel_engine_cs *engine)
Chris Wilsonb2223492010-10-27 15:27:33 +0100706{
Chris Wilson688e6c72016-07-01 17:23:15 +0100707 struct intel_breadcrumbs *b = &engine->breadcrumbs;
708 struct rb_node *rb;
709
Chris Wilson12471ba2016-04-09 10:57:55 +0100710 seq_printf(m, "Current sequence (%s): %x\n",
Chris Wilson1b7744e2016-07-01 17:23:17 +0100711 engine->name, intel_engine_get_seqno(engine));
Chris Wilson688e6c72016-07-01 17:23:15 +0100712
Chris Wilson61d3dc72017-03-03 19:08:24 +0000713 spin_lock_irq(&b->rb_lock);
Chris Wilson688e6c72016-07-01 17:23:15 +0100714 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +0800715 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson688e6c72016-07-01 17:23:15 +0100716
717 seq_printf(m, "Waiting (%s): %s [%d] on %x\n",
718 engine->name, w->tsk->comm, w->tsk->pid, w->seqno);
719 }
Chris Wilson61d3dc72017-03-03 19:08:24 +0000720 spin_unlock_irq(&b->rb_lock);
Chris Wilsonb2223492010-10-27 15:27:33 +0100721}
722
Ben Gamari20172632009-02-17 20:08:50 -0500723static int i915_gem_seqno_info(struct seq_file *m, void *data)
724{
David Weinehall36cdd012016-08-22 13:59:31 +0300725 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000726 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530727 enum intel_engine_id id;
Ben Gamari20172632009-02-17 20:08:50 -0500728
Akash Goel3b3f1652016-10-13 22:44:48 +0530729 for_each_engine(engine, dev_priv, id)
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000730 i915_ring_seqno_info(m, engine);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100731
Ben Gamari20172632009-02-17 20:08:50 -0500732 return 0;
733}
734
735
736static int i915_interrupt_info(struct seq_file *m, void *data)
737{
David Weinehall36cdd012016-08-22 13:59:31 +0300738 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000739 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530740 enum intel_engine_id id;
Chris Wilson4bb05042016-09-03 07:53:43 +0100741 int i, pipe;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100742
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200743 intel_runtime_pm_get(dev_priv);
Ben Gamari20172632009-02-17 20:08:50 -0500744
David Weinehall36cdd012016-08-22 13:59:31 +0300745 if (IS_CHERRYVIEW(dev_priv)) {
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300746 seq_printf(m, "Master Interrupt Control:\t%08x\n",
747 I915_READ(GEN8_MASTER_IRQ));
748
749 seq_printf(m, "Display IER:\t%08x\n",
750 I915_READ(VLV_IER));
751 seq_printf(m, "Display IIR:\t%08x\n",
752 I915_READ(VLV_IIR));
753 seq_printf(m, "Display IIR_RW:\t%08x\n",
754 I915_READ(VLV_IIR_RW));
755 seq_printf(m, "Display IMR:\t%08x\n",
756 I915_READ(VLV_IMR));
Chris Wilson9c870d02016-10-24 13:42:15 +0100757 for_each_pipe(dev_priv, pipe) {
758 enum intel_display_power_domain power_domain;
759
760 power_domain = POWER_DOMAIN_PIPE(pipe);
761 if (!intel_display_power_get_if_enabled(dev_priv,
762 power_domain)) {
763 seq_printf(m, "Pipe %c power disabled\n",
764 pipe_name(pipe));
765 continue;
766 }
767
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300768 seq_printf(m, "Pipe %c stat:\t%08x\n",
769 pipe_name(pipe),
770 I915_READ(PIPESTAT(pipe)));
771
Chris Wilson9c870d02016-10-24 13:42:15 +0100772 intel_display_power_put(dev_priv, power_domain);
773 }
774
775 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300776 seq_printf(m, "Port hotplug:\t%08x\n",
777 I915_READ(PORT_HOTPLUG_EN));
778 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
779 I915_READ(VLV_DPFLIPSTAT));
780 seq_printf(m, "DPINVGTT:\t%08x\n",
781 I915_READ(DPINVGTT));
Chris Wilson9c870d02016-10-24 13:42:15 +0100782 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300783
784 for (i = 0; i < 4; i++) {
785 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
786 i, I915_READ(GEN8_GT_IMR(i)));
787 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
788 i, I915_READ(GEN8_GT_IIR(i)));
789 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
790 i, I915_READ(GEN8_GT_IER(i)));
791 }
792
793 seq_printf(m, "PCU interrupt mask:\t%08x\n",
794 I915_READ(GEN8_PCU_IMR));
795 seq_printf(m, "PCU interrupt identity:\t%08x\n",
796 I915_READ(GEN8_PCU_IIR));
797 seq_printf(m, "PCU interrupt enable:\t%08x\n",
798 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300799 } else if (INTEL_GEN(dev_priv) >= 8) {
Ben Widawskya123f152013-11-02 21:07:10 -0700800 seq_printf(m, "Master Interrupt Control:\t%08x\n",
801 I915_READ(GEN8_MASTER_IRQ));
802
803 for (i = 0; i < 4; i++) {
804 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
805 i, I915_READ(GEN8_GT_IMR(i)));
806 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
807 i, I915_READ(GEN8_GT_IIR(i)));
808 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
809 i, I915_READ(GEN8_GT_IER(i)));
810 }
811
Damien Lespiau055e3932014-08-18 13:49:10 +0100812 for_each_pipe(dev_priv, pipe) {
Imre Deake1296492016-02-12 18:55:17 +0200813 enum intel_display_power_domain power_domain;
814
815 power_domain = POWER_DOMAIN_PIPE(pipe);
816 if (!intel_display_power_get_if_enabled(dev_priv,
817 power_domain)) {
Paulo Zanoni22c59962014-08-08 17:45:32 -0300818 seq_printf(m, "Pipe %c power disabled\n",
819 pipe_name(pipe));
820 continue;
821 }
Ben Widawskya123f152013-11-02 21:07:10 -0700822 seq_printf(m, "Pipe %c IMR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000823 pipe_name(pipe),
824 I915_READ(GEN8_DE_PIPE_IMR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700825 seq_printf(m, "Pipe %c IIR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000826 pipe_name(pipe),
827 I915_READ(GEN8_DE_PIPE_IIR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700828 seq_printf(m, "Pipe %c IER:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000829 pipe_name(pipe),
830 I915_READ(GEN8_DE_PIPE_IER(pipe)));
Imre Deake1296492016-02-12 18:55:17 +0200831
832 intel_display_power_put(dev_priv, power_domain);
Ben Widawskya123f152013-11-02 21:07:10 -0700833 }
834
835 seq_printf(m, "Display Engine port interrupt mask:\t%08x\n",
836 I915_READ(GEN8_DE_PORT_IMR));
837 seq_printf(m, "Display Engine port interrupt identity:\t%08x\n",
838 I915_READ(GEN8_DE_PORT_IIR));
839 seq_printf(m, "Display Engine port interrupt enable:\t%08x\n",
840 I915_READ(GEN8_DE_PORT_IER));
841
842 seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n",
843 I915_READ(GEN8_DE_MISC_IMR));
844 seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n",
845 I915_READ(GEN8_DE_MISC_IIR));
846 seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n",
847 I915_READ(GEN8_DE_MISC_IER));
848
849 seq_printf(m, "PCU interrupt mask:\t%08x\n",
850 I915_READ(GEN8_PCU_IMR));
851 seq_printf(m, "PCU interrupt identity:\t%08x\n",
852 I915_READ(GEN8_PCU_IIR));
853 seq_printf(m, "PCU interrupt enable:\t%08x\n",
854 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300855 } else if (IS_VALLEYVIEW(dev_priv)) {
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700856 seq_printf(m, "Display IER:\t%08x\n",
857 I915_READ(VLV_IER));
858 seq_printf(m, "Display IIR:\t%08x\n",
859 I915_READ(VLV_IIR));
860 seq_printf(m, "Display IIR_RW:\t%08x\n",
861 I915_READ(VLV_IIR_RW));
862 seq_printf(m, "Display IMR:\t%08x\n",
863 I915_READ(VLV_IMR));
Chris Wilson4f4631a2017-02-10 13:36:32 +0000864 for_each_pipe(dev_priv, pipe) {
865 enum intel_display_power_domain power_domain;
866
867 power_domain = POWER_DOMAIN_PIPE(pipe);
868 if (!intel_display_power_get_if_enabled(dev_priv,
869 power_domain)) {
870 seq_printf(m, "Pipe %c power disabled\n",
871 pipe_name(pipe));
872 continue;
873 }
874
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700875 seq_printf(m, "Pipe %c stat:\t%08x\n",
876 pipe_name(pipe),
877 I915_READ(PIPESTAT(pipe)));
Chris Wilson4f4631a2017-02-10 13:36:32 +0000878 intel_display_power_put(dev_priv, power_domain);
879 }
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700880
881 seq_printf(m, "Master IER:\t%08x\n",
882 I915_READ(VLV_MASTER_IER));
883
884 seq_printf(m, "Render IER:\t%08x\n",
885 I915_READ(GTIER));
886 seq_printf(m, "Render IIR:\t%08x\n",
887 I915_READ(GTIIR));
888 seq_printf(m, "Render IMR:\t%08x\n",
889 I915_READ(GTIMR));
890
891 seq_printf(m, "PM IER:\t\t%08x\n",
892 I915_READ(GEN6_PMIER));
893 seq_printf(m, "PM IIR:\t\t%08x\n",
894 I915_READ(GEN6_PMIIR));
895 seq_printf(m, "PM IMR:\t\t%08x\n",
896 I915_READ(GEN6_PMIMR));
897
898 seq_printf(m, "Port hotplug:\t%08x\n",
899 I915_READ(PORT_HOTPLUG_EN));
900 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
901 I915_READ(VLV_DPFLIPSTAT));
902 seq_printf(m, "DPINVGTT:\t%08x\n",
903 I915_READ(DPINVGTT));
904
David Weinehall36cdd012016-08-22 13:59:31 +0300905 } else if (!HAS_PCH_SPLIT(dev_priv)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800906 seq_printf(m, "Interrupt enable: %08x\n",
907 I915_READ(IER));
908 seq_printf(m, "Interrupt identity: %08x\n",
909 I915_READ(IIR));
910 seq_printf(m, "Interrupt mask: %08x\n",
911 I915_READ(IMR));
Damien Lespiau055e3932014-08-18 13:49:10 +0100912 for_each_pipe(dev_priv, pipe)
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800913 seq_printf(m, "Pipe %c stat: %08x\n",
914 pipe_name(pipe),
915 I915_READ(PIPESTAT(pipe)));
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800916 } else {
917 seq_printf(m, "North Display Interrupt enable: %08x\n",
918 I915_READ(DEIER));
919 seq_printf(m, "North Display Interrupt identity: %08x\n",
920 I915_READ(DEIIR));
921 seq_printf(m, "North Display Interrupt mask: %08x\n",
922 I915_READ(DEIMR));
923 seq_printf(m, "South Display Interrupt enable: %08x\n",
924 I915_READ(SDEIER));
925 seq_printf(m, "South Display Interrupt identity: %08x\n",
926 I915_READ(SDEIIR));
927 seq_printf(m, "South Display Interrupt mask: %08x\n",
928 I915_READ(SDEIMR));
929 seq_printf(m, "Graphics Interrupt enable: %08x\n",
930 I915_READ(GTIER));
931 seq_printf(m, "Graphics Interrupt identity: %08x\n",
932 I915_READ(GTIIR));
933 seq_printf(m, "Graphics Interrupt mask: %08x\n",
934 I915_READ(GTIMR));
935 }
Akash Goel3b3f1652016-10-13 22:44:48 +0530936 for_each_engine(engine, dev_priv, id) {
David Weinehall36cdd012016-08-22 13:59:31 +0300937 if (INTEL_GEN(dev_priv) >= 6) {
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100938 seq_printf(m,
939 "Graphics Interrupt mask (%s): %08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000940 engine->name, I915_READ_IMR(engine));
Chris Wilson9862e602011-01-04 22:22:17 +0000941 }
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000942 i915_ring_seqno_info(m, engine);
Chris Wilson9862e602011-01-04 22:22:17 +0000943 }
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200944 intel_runtime_pm_put(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100945
Ben Gamari20172632009-02-17 20:08:50 -0500946 return 0;
947}
948
Chris Wilsona6172a82009-02-11 14:26:38 +0000949static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
950{
David Weinehall36cdd012016-08-22 13:59:31 +0300951 struct drm_i915_private *dev_priv = node_to_i915(m->private);
952 struct drm_device *dev = &dev_priv->drm;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100953 int i, ret;
954
955 ret = mutex_lock_interruptible(&dev->struct_mutex);
956 if (ret)
957 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000958
Chris Wilsona6172a82009-02-11 14:26:38 +0000959 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
960 for (i = 0; i < dev_priv->num_fence_regs; i++) {
Chris Wilson49ef5292016-08-18 17:17:00 +0100961 struct i915_vma *vma = dev_priv->fence_regs[i].vma;
Chris Wilsona6172a82009-02-11 14:26:38 +0000962
Chris Wilson6c085a72012-08-20 11:40:46 +0200963 seq_printf(m, "Fence %d, pin count = %d, object = ",
964 i, dev_priv->fence_regs[i].pin_count);
Chris Wilson49ef5292016-08-18 17:17:00 +0100965 if (!vma)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100966 seq_puts(m, "unused");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100967 else
Chris Wilson49ef5292016-08-18 17:17:00 +0100968 describe_obj(m, vma->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100969 seq_putc(m, '\n');
Chris Wilsona6172a82009-02-11 14:26:38 +0000970 }
971
Chris Wilson05394f32010-11-08 19:18:58 +0000972 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000973 return 0;
974}
975
Chris Wilson98a2f412016-10-12 10:05:18 +0100976#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
Chris Wilson5a4c6f12017-02-14 16:46:11 +0000977static ssize_t gpu_state_read(struct file *file, char __user *ubuf,
978 size_t count, loff_t *pos)
979{
980 struct i915_gpu_state *error = file->private_data;
981 struct drm_i915_error_state_buf str;
982 ssize_t ret;
983 loff_t tmp;
984
985 if (!error)
986 return 0;
987
988 ret = i915_error_state_buf_init(&str, error->i915, count, *pos);
989 if (ret)
990 return ret;
991
992 ret = i915_error_state_to_str(&str, error);
993 if (ret)
994 goto out;
995
996 tmp = 0;
997 ret = simple_read_from_buffer(ubuf, count, &tmp, str.buf, str.bytes);
998 if (ret < 0)
999 goto out;
1000
1001 *pos = str.start + ret;
1002out:
1003 i915_error_state_buf_release(&str);
1004 return ret;
1005}
1006
1007static int gpu_state_release(struct inode *inode, struct file *file)
1008{
1009 i915_gpu_state_put(file->private_data);
1010 return 0;
1011}
1012
1013static int i915_gpu_info_open(struct inode *inode, struct file *file)
1014{
1015 struct i915_gpu_state *gpu;
1016
1017 gpu = i915_capture_gpu_state(inode->i_private);
1018 if (!gpu)
1019 return -ENOMEM;
1020
1021 file->private_data = gpu;
1022 return 0;
1023}
1024
1025static const struct file_operations i915_gpu_info_fops = {
1026 .owner = THIS_MODULE,
1027 .open = i915_gpu_info_open,
1028 .read = gpu_state_read,
1029 .llseek = default_llseek,
1030 .release = gpu_state_release,
1031};
Chris Wilson98a2f412016-10-12 10:05:18 +01001032
Daniel Vetterd5442302012-04-27 15:17:40 +02001033static ssize_t
1034i915_error_state_write(struct file *filp,
1035 const char __user *ubuf,
1036 size_t cnt,
1037 loff_t *ppos)
1038{
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001039 struct i915_gpu_state *error = filp->private_data;
1040
1041 if (!error)
1042 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +02001043
1044 DRM_DEBUG_DRIVER("Resetting error state\n");
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001045 i915_reset_error_state(error->i915);
Daniel Vetterd5442302012-04-27 15:17:40 +02001046
1047 return cnt;
1048}
1049
1050static int i915_error_state_open(struct inode *inode, struct file *file)
1051{
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001052 file->private_data = i915_first_error_state(inode->i_private);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001053 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +02001054}
1055
Daniel Vetterd5442302012-04-27 15:17:40 +02001056static const struct file_operations i915_error_state_fops = {
1057 .owner = THIS_MODULE,
1058 .open = i915_error_state_open,
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001059 .read = gpu_state_read,
Daniel Vetterd5442302012-04-27 15:17:40 +02001060 .write = i915_error_state_write,
1061 .llseek = default_llseek,
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001062 .release = gpu_state_release,
Daniel Vetterd5442302012-04-27 15:17:40 +02001063};
Chris Wilson98a2f412016-10-12 10:05:18 +01001064#endif
1065
Kees Cook647416f2013-03-10 14:10:06 -07001066static int
Kees Cook647416f2013-03-10 14:10:06 -07001067i915_next_seqno_set(void *data, u64 val)
Mika Kuoppala40633212012-12-04 15:12:00 +02001068{
David Weinehall36cdd012016-08-22 13:59:31 +03001069 struct drm_i915_private *dev_priv = data;
1070 struct drm_device *dev = &dev_priv->drm;
Mika Kuoppala40633212012-12-04 15:12:00 +02001071 int ret;
1072
Mika Kuoppala40633212012-12-04 15:12:00 +02001073 ret = mutex_lock_interruptible(&dev->struct_mutex);
1074 if (ret)
1075 return ret;
1076
Chris Wilson73cb9702016-10-28 13:58:46 +01001077 ret = i915_gem_set_global_seqno(dev, val);
Mika Kuoppala40633212012-12-04 15:12:00 +02001078 mutex_unlock(&dev->struct_mutex);
1079
Kees Cook647416f2013-03-10 14:10:06 -07001080 return ret;
Mika Kuoppala40633212012-12-04 15:12:00 +02001081}
1082
Kees Cook647416f2013-03-10 14:10:06 -07001083DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
Chris Wilson9b6586a2017-02-23 07:44:08 +00001084 NULL, i915_next_seqno_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03001085 "0x%llx\n");
Mika Kuoppala40633212012-12-04 15:12:00 +02001086
Deepak Sadb4bd12014-03-31 11:30:02 +05301087static int i915_frequency_info(struct seq_file *m, void *unused)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001088{
David Weinehall36cdd012016-08-22 13:59:31 +03001089 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001090 int ret = 0;
1091
1092 intel_runtime_pm_get(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001093
David Weinehall36cdd012016-08-22 13:59:31 +03001094 if (IS_GEN5(dev_priv)) {
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001095 u16 rgvswctl = I915_READ16(MEMSWCTL);
1096 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
1097
1098 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
1099 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
1100 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
1101 MEMSTAT_VID_SHIFT);
1102 seq_printf(m, "Current P-state: %d\n",
1103 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
David Weinehall36cdd012016-08-22 13:59:31 +03001104 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
Wayne Boyer666a4532015-12-09 12:29:35 -08001105 u32 freq_sts;
1106
1107 mutex_lock(&dev_priv->rps.hw_lock);
1108 freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
1109 seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts);
1110 seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq);
1111
1112 seq_printf(m, "actual GPU freq: %d MHz\n",
1113 intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff));
1114
1115 seq_printf(m, "current GPU freq: %d MHz\n",
1116 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1117
1118 seq_printf(m, "max GPU freq: %d MHz\n",
1119 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1120
1121 seq_printf(m, "min GPU freq: %d MHz\n",
1122 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
1123
1124 seq_printf(m, "idle GPU freq: %d MHz\n",
1125 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
1126
1127 seq_printf(m,
1128 "efficient (RPe) frequency: %d MHz\n",
1129 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
1130 mutex_unlock(&dev_priv->rps.hw_lock);
David Weinehall36cdd012016-08-22 13:59:31 +03001131 } else if (INTEL_GEN(dev_priv) >= 6) {
Bob Paauwe35040562015-06-25 14:54:07 -07001132 u32 rp_state_limits;
1133 u32 gt_perf_status;
1134 u32 rp_state_cap;
Chris Wilson0d8f9492014-03-27 09:06:14 +00001135 u32 rpmodectl, rpinclimit, rpdeclimit;
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001136 u32 rpstat, cagf, reqf;
Jesse Barnesccab5c82011-01-18 15:49:25 -08001137 u32 rpupei, rpcurup, rpprevup;
1138 u32 rpdownei, rpcurdown, rpprevdown;
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001139 u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask;
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001140 int max_freq;
1141
Bob Paauwe35040562015-06-25 14:54:07 -07001142 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001143 if (IS_GEN9_LP(dev_priv)) {
Bob Paauwe35040562015-06-25 14:54:07 -07001144 rp_state_cap = I915_READ(BXT_RP_STATE_CAP);
1145 gt_perf_status = I915_READ(BXT_GT_PERF_STATUS);
1146 } else {
1147 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
1148 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
1149 }
1150
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001151 /* RPSTAT1 is in the GT power well */
Mika Kuoppala59bad942015-01-16 11:34:40 +02001152 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001153
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001154 reqf = I915_READ(GEN6_RPNSWREQ);
David Weinehall36cdd012016-08-22 13:59:31 +03001155 if (IS_GEN9(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301156 reqf >>= 23;
1157 else {
1158 reqf &= ~GEN6_TURBO_DISABLE;
David Weinehall36cdd012016-08-22 13:59:31 +03001159 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301160 reqf >>= 24;
1161 else
1162 reqf >>= 25;
1163 }
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001164 reqf = intel_gpu_freq(dev_priv, reqf);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001165
Chris Wilson0d8f9492014-03-27 09:06:14 +00001166 rpmodectl = I915_READ(GEN6_RP_CONTROL);
1167 rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD);
1168 rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD);
1169
Jesse Barnesccab5c82011-01-18 15:49:25 -08001170 rpstat = I915_READ(GEN6_RPSTAT1);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301171 rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK;
1172 rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK;
1173 rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK;
1174 rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK;
1175 rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK;
1176 rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK;
David Weinehall36cdd012016-08-22 13:59:31 +03001177 if (IS_GEN9(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301178 cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT;
David Weinehall36cdd012016-08-22 13:59:31 +03001179 else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Ben Widawskyf82855d2013-01-29 12:00:15 -08001180 cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT;
1181 else
1182 cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT;
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001183 cagf = intel_gpu_freq(dev_priv, cagf);
Jesse Barnesccab5c82011-01-18 15:49:25 -08001184
Mika Kuoppala59bad942015-01-16 11:34:40 +02001185 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001186
David Weinehall36cdd012016-08-22 13:59:31 +03001187 if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) {
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001188 pm_ier = I915_READ(GEN6_PMIER);
1189 pm_imr = I915_READ(GEN6_PMIMR);
1190 pm_isr = I915_READ(GEN6_PMISR);
1191 pm_iir = I915_READ(GEN6_PMIIR);
1192 pm_mask = I915_READ(GEN6_PMINTRMSK);
1193 } else {
1194 pm_ier = I915_READ(GEN8_GT_IER(2));
1195 pm_imr = I915_READ(GEN8_GT_IMR(2));
1196 pm_isr = I915_READ(GEN8_GT_ISR(2));
1197 pm_iir = I915_READ(GEN8_GT_IIR(2));
1198 pm_mask = I915_READ(GEN6_PMINTRMSK);
1199 }
Chris Wilson0d8f9492014-03-27 09:06:14 +00001200 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 -03001201 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask);
Sagar Arun Kamble5dd04552017-03-11 08:07:00 +05301202 seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n",
1203 dev_priv->rps.pm_intrmsk_mbz);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001204 seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001205 seq_printf(m, "Render p-state ratio: %d\n",
David Weinehall36cdd012016-08-22 13:59:31 +03001206 (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001207 seq_printf(m, "Render p-state VID: %d\n",
1208 gt_perf_status & 0xff);
1209 seq_printf(m, "Render p-state limit: %d\n",
1210 rp_state_limits & 0xff);
Chris Wilson0d8f9492014-03-27 09:06:14 +00001211 seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
1212 seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl);
1213 seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit);
1214 seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001215 seq_printf(m, "RPNSWREQ: %dMHz\n", reqf);
Ben Widawskyf82855d2013-01-29 12:00:15 -08001216 seq_printf(m, "CAGF: %dMHz\n", cagf);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301217 seq_printf(m, "RP CUR UP EI: %d (%dus)\n",
1218 rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei));
1219 seq_printf(m, "RP CUR UP: %d (%dus)\n",
1220 rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup));
1221 seq_printf(m, "RP PREV UP: %d (%dus)\n",
1222 rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup));
Chris Wilsond86ed342015-04-27 13:41:19 +01001223 seq_printf(m, "Up threshold: %d%%\n",
1224 dev_priv->rps.up_threshold);
1225
Akash Goeld6cda9c2016-04-23 00:05:46 +05301226 seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n",
1227 rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei));
1228 seq_printf(m, "RP CUR DOWN: %d (%dus)\n",
1229 rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown));
1230 seq_printf(m, "RP PREV DOWN: %d (%dus)\n",
1231 rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown));
Chris Wilsond86ed342015-04-27 13:41:19 +01001232 seq_printf(m, "Down threshold: %d%%\n",
1233 dev_priv->rps.down_threshold);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001234
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001235 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 :
Bob Paauwe35040562015-06-25 14:54:07 -07001236 rp_state_cap >> 16) & 0xff;
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001237 max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001238 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001239 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001240
1241 max_freq = (rp_state_cap & 0xff00) >> 8;
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001242 max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001243 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001244 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001245
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001246 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 :
Bob Paauwe35040562015-06-25 14:54:07 -07001247 rp_state_cap >> 0) & 0xff;
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001248 max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001249 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001250 intel_gpu_freq(dev_priv, max_freq));
Ben Widawsky31c77382013-04-05 14:29:22 -07001251 seq_printf(m, "Max overclocked frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001252 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
Chris Wilsonaed242f2015-03-18 09:48:21 +00001253
Chris Wilsond86ed342015-04-27 13:41:19 +01001254 seq_printf(m, "Current freq: %d MHz\n",
1255 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1256 seq_printf(m, "Actual freq: %d MHz\n", cagf);
Chris Wilsonaed242f2015-03-18 09:48:21 +00001257 seq_printf(m, "Idle freq: %d MHz\n",
1258 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001259 seq_printf(m, "Min freq: %d MHz\n",
1260 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
Chris Wilson29ecd78d2016-07-13 09:10:35 +01001261 seq_printf(m, "Boost freq: %d MHz\n",
1262 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001263 seq_printf(m, "Max freq: %d MHz\n",
1264 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1265 seq_printf(m,
1266 "efficient (RPe) frequency: %d MHz\n",
1267 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001268 } else {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001269 seq_puts(m, "no P-state info available\n");
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001270 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001271
Ville Syrjälä49cd97a2017-02-07 20:33:45 +02001272 seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk.hw.cdclk);
Mika Kahola1170f282015-09-25 14:00:32 +03001273 seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq);
1274 seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq);
1275
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001276 intel_runtime_pm_put(dev_priv);
1277 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001278}
1279
Ben Widawskyd6369512016-09-20 16:54:32 +03001280static void i915_instdone_info(struct drm_i915_private *dev_priv,
1281 struct seq_file *m,
1282 struct intel_instdone *instdone)
1283{
Ben Widawskyf9e61372016-09-20 16:54:33 +03001284 int slice;
1285 int subslice;
1286
Ben Widawskyd6369512016-09-20 16:54:32 +03001287 seq_printf(m, "\t\tINSTDONE: 0x%08x\n",
1288 instdone->instdone);
1289
1290 if (INTEL_GEN(dev_priv) <= 3)
1291 return;
1292
1293 seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n",
1294 instdone->slice_common);
1295
1296 if (INTEL_GEN(dev_priv) <= 6)
1297 return;
1298
Ben Widawskyf9e61372016-09-20 16:54:33 +03001299 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1300 seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n",
1301 slice, subslice, instdone->sampler[slice][subslice]);
1302
1303 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1304 seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n",
1305 slice, subslice, instdone->row[slice][subslice]);
Ben Widawskyd6369512016-09-20 16:54:32 +03001306}
1307
Chris Wilsonf6544492015-01-26 18:03:04 +02001308static int i915_hangcheck_info(struct seq_file *m, void *unused)
1309{
David Weinehall36cdd012016-08-22 13:59:31 +03001310 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001311 struct intel_engine_cs *engine;
Tvrtko Ursulin666796d2016-03-16 11:00:39 +00001312 u64 acthd[I915_NUM_ENGINES];
1313 u32 seqno[I915_NUM_ENGINES];
Ben Widawskyd6369512016-09-20 16:54:32 +03001314 struct intel_instdone instdone;
Dave Gordonc3232b12016-03-23 18:19:53 +00001315 enum intel_engine_id id;
Chris Wilsonf6544492015-01-26 18:03:04 +02001316
Chris Wilson8af29b02016-09-09 14:11:47 +01001317 if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags))
Chris Wilson8c185ec2017-03-16 17:13:02 +00001318 seq_puts(m, "Wedged\n");
1319 if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags))
1320 seq_puts(m, "Reset in progress: struct_mutex backoff\n");
1321 if (test_bit(I915_RESET_HANDOFF, &dev_priv->gpu_error.flags))
1322 seq_puts(m, "Reset in progress: reset handoff to waiter\n");
Chris Wilson8af29b02016-09-09 14:11:47 +01001323 if (waitqueue_active(&dev_priv->gpu_error.wait_queue))
Chris Wilson8c185ec2017-03-16 17:13:02 +00001324 seq_puts(m, "Waiter holding struct mutex\n");
Chris Wilson8af29b02016-09-09 14:11:47 +01001325 if (waitqueue_active(&dev_priv->gpu_error.reset_queue))
Chris Wilson8c185ec2017-03-16 17:13:02 +00001326 seq_puts(m, "struct_mutex blocked for reset\n");
Chris Wilson8af29b02016-09-09 14:11:47 +01001327
Chris Wilsonf6544492015-01-26 18:03:04 +02001328 if (!i915.enable_hangcheck) {
Chris Wilson8c185ec2017-03-16 17:13:02 +00001329 seq_puts(m, "Hangcheck disabled\n");
Chris Wilsonf6544492015-01-26 18:03:04 +02001330 return 0;
1331 }
1332
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001333 intel_runtime_pm_get(dev_priv);
1334
Akash Goel3b3f1652016-10-13 22:44:48 +05301335 for_each_engine(engine, dev_priv, id) {
Chris Wilson7e37f882016-08-02 22:50:21 +01001336 acthd[id] = intel_engine_get_active_head(engine);
Chris Wilson1b7744e2016-07-01 17:23:17 +01001337 seqno[id] = intel_engine_get_seqno(engine);
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001338 }
1339
Akash Goel3b3f1652016-10-13 22:44:48 +05301340 intel_engine_get_instdone(dev_priv->engine[RCS], &instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001341
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001342 intel_runtime_pm_put(dev_priv);
1343
Chris Wilson8352aea2017-03-03 09:00:56 +00001344 if (timer_pending(&dev_priv->gpu_error.hangcheck_work.timer))
1345 seq_printf(m, "Hangcheck active, timer fires in %dms\n",
Chris Wilsonf6544492015-01-26 18:03:04 +02001346 jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires -
1347 jiffies));
Chris Wilson8352aea2017-03-03 09:00:56 +00001348 else if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work))
1349 seq_puts(m, "Hangcheck active, work pending\n");
1350 else
1351 seq_puts(m, "Hangcheck inactive\n");
Chris Wilsonf6544492015-01-26 18:03:04 +02001352
Chris Wilsonf73b5672017-03-02 15:03:56 +00001353 seq_printf(m, "GT active? %s\n", yesno(dev_priv->gt.awake));
1354
Akash Goel3b3f1652016-10-13 22:44:48 +05301355 for_each_engine(engine, dev_priv, id) {
Chris Wilson33f53712016-10-04 21:11:32 +01001356 struct intel_breadcrumbs *b = &engine->breadcrumbs;
1357 struct rb_node *rb;
1358
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001359 seq_printf(m, "%s:\n", engine->name);
Chris Wilsonf73b5672017-03-02 15:03:56 +00001360 seq_printf(m, "\tseqno = %x [current %x, last %x], inflight %d\n",
Chris Wilsoncb399ea2016-11-01 10:03:16 +00001361 engine->hangcheck.seqno, seqno[id],
Chris Wilsonf73b5672017-03-02 15:03:56 +00001362 intel_engine_last_submit(engine),
1363 engine->timeline->inflight_seqnos);
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001364 seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n",
Chris Wilson83348ba2016-08-09 17:47:51 +01001365 yesno(intel_engine_has_waiter(engine)),
1366 yesno(test_bit(engine->id,
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001367 &dev_priv->gpu_error.missed_irq_rings)),
1368 yesno(engine->hangcheck.stalled));
1369
Chris Wilson61d3dc72017-03-03 19:08:24 +00001370 spin_lock_irq(&b->rb_lock);
Chris Wilson33f53712016-10-04 21:11:32 +01001371 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +08001372 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson33f53712016-10-04 21:11:32 +01001373
1374 seq_printf(m, "\t%s [%d] waiting for %x\n",
1375 w->tsk->comm, w->tsk->pid, w->seqno);
1376 }
Chris Wilson61d3dc72017-03-03 19:08:24 +00001377 spin_unlock_irq(&b->rb_lock);
Chris Wilson33f53712016-10-04 21:11:32 +01001378
Chris Wilsonf6544492015-01-26 18:03:04 +02001379 seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001380 (long long)engine->hangcheck.acthd,
Dave Gordonc3232b12016-03-23 18:19:53 +00001381 (long long)acthd[id]);
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001382 seq_printf(m, "\taction = %s(%d) %d ms ago\n",
1383 hangcheck_action_to_str(engine->hangcheck.action),
1384 engine->hangcheck.action,
1385 jiffies_to_msecs(jiffies -
1386 engine->hangcheck.action_timestamp));
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001387
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001388 if (engine->id == RCS) {
Ben Widawskyd6369512016-09-20 16:54:32 +03001389 seq_puts(m, "\tinstdone read =\n");
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001390
Ben Widawskyd6369512016-09-20 16:54:32 +03001391 i915_instdone_info(dev_priv, m, &instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001392
Ben Widawskyd6369512016-09-20 16:54:32 +03001393 seq_puts(m, "\tinstdone accu =\n");
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001394
Ben Widawskyd6369512016-09-20 16:54:32 +03001395 i915_instdone_info(dev_priv, m,
1396 &engine->hangcheck.instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001397 }
Chris Wilsonf6544492015-01-26 18:03:04 +02001398 }
1399
1400 return 0;
1401}
1402
Ben Widawsky4d855292011-12-12 19:34:16 -08001403static int ironlake_drpc_info(struct seq_file *m)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001404{
David Weinehall36cdd012016-08-22 13:59:31 +03001405 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001406 u32 rgvmodectl, rstdbyctl;
1407 u16 crstandvid;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001408
Ben Widawsky616fdb52011-10-05 11:44:54 -07001409 rgvmodectl = I915_READ(MEMMODECTL);
1410 rstdbyctl = I915_READ(RSTDBYCTL);
1411 crstandvid = I915_READ16(CRSTANDVID);
1412
Jani Nikula742f4912015-09-03 11:16:09 +03001413 seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001414 seq_printf(m, "Boost freq: %d\n",
1415 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
1416 MEMMODE_BOOST_FREQ_SHIFT);
1417 seq_printf(m, "HW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001418 yesno(rgvmodectl & MEMMODE_HWIDLE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001419 seq_printf(m, "SW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001420 yesno(rgvmodectl & MEMMODE_SWMODE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001421 seq_printf(m, "Gated voltage change: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001422 yesno(rgvmodectl & MEMMODE_RCLK_GATE));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001423 seq_printf(m, "Starting frequency: P%d\n",
1424 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001425 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -08001426 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001427 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
1428 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
1429 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
1430 seq_printf(m, "Render standby enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001431 yesno(!(rstdbyctl & RCX_SW_EXIT)));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001432 seq_puts(m, "Current RS state: ");
Jesse Barnes88271da2011-01-05 12:01:24 -08001433 switch (rstdbyctl & RSX_STATUS_MASK) {
1434 case RSX_STATUS_ON:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001435 seq_puts(m, "on\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001436 break;
1437 case RSX_STATUS_RC1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001438 seq_puts(m, "RC1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001439 break;
1440 case RSX_STATUS_RC1E:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001441 seq_puts(m, "RC1E\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001442 break;
1443 case RSX_STATUS_RS1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001444 seq_puts(m, "RS1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001445 break;
1446 case RSX_STATUS_RS2:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001447 seq_puts(m, "RS2 (RC6)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001448 break;
1449 case RSX_STATUS_RS3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001450 seq_puts(m, "RC3 (RC6+)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001451 break;
1452 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001453 seq_puts(m, "unknown\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001454 break;
1455 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001456
1457 return 0;
1458}
1459
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001460static int i915_forcewake_domains(struct seq_file *m, void *data)
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001461{
Chris Wilson233ebf52017-03-23 10:19:44 +00001462 struct drm_i915_private *i915 = node_to_i915(m->private);
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001463 struct intel_uncore_forcewake_domain *fw_domain;
Chris Wilsond2dc94b2017-03-23 10:19:41 +00001464 unsigned int tmp;
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001465
Chris Wilson233ebf52017-03-23 10:19:44 +00001466 for_each_fw_domain(fw_domain, i915, tmp)
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001467 seq_printf(m, "%s.wake_count = %u\n",
Tvrtko Ursulin33c582c2016-04-07 17:04:33 +01001468 intel_uncore_forcewake_domain_to_str(fw_domain->id),
Chris Wilson233ebf52017-03-23 10:19:44 +00001469 READ_ONCE(fw_domain->wake_count));
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001470
1471 return 0;
1472}
1473
Mika Kuoppala13628772017-03-15 17:43:02 +02001474static void print_rc6_res(struct seq_file *m,
1475 const char *title,
1476 const i915_reg_t reg)
1477{
1478 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1479
1480 seq_printf(m, "%s %u (%llu us)\n",
1481 title, I915_READ(reg),
1482 intel_rc6_residency_us(dev_priv, reg));
1483}
1484
Deepak S669ab5a2014-01-10 15:18:26 +05301485static int vlv_drpc_info(struct seq_file *m)
1486{
David Weinehall36cdd012016-08-22 13:59:31 +03001487 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001488 u32 rpmodectl1, rcctl1, pw_status;
Deepak S669ab5a2014-01-10 15:18:26 +05301489
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001490 pw_status = I915_READ(VLV_GTLC_PW_STATUS);
Deepak S669ab5a2014-01-10 15:18:26 +05301491 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1492 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1493
1494 seq_printf(m, "Video Turbo Mode: %s\n",
1495 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1496 seq_printf(m, "Turbo enabled: %s\n",
1497 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1498 seq_printf(m, "HW control enabled: %s\n",
1499 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1500 seq_printf(m, "SW control enabled: %s\n",
1501 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1502 GEN6_RP_MEDIA_SW_MODE));
1503 seq_printf(m, "RC6 Enabled: %s\n",
1504 yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE |
1505 GEN6_RC_CTL_EI_MODE(1))));
1506 seq_printf(m, "Render Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001507 (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301508 seq_printf(m, "Media Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001509 (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301510
Mika Kuoppala13628772017-03-15 17:43:02 +02001511 print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6);
1512 print_rc6_res(m, "Media RC6 residency since boot:", VLV_GT_MEDIA_RC6);
Imre Deak9cc19be2014-04-14 20:24:24 +03001513
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001514 return i915_forcewake_domains(m, NULL);
Deepak S669ab5a2014-01-10 15:18:26 +05301515}
1516
Ben Widawsky4d855292011-12-12 19:34:16 -08001517static int gen6_drpc_info(struct seq_file *m)
1518{
David Weinehall36cdd012016-08-22 13:59:31 +03001519 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001520 u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0;
Akash Goelf2dd7572016-06-27 20:10:01 +05301521 u32 gen9_powergate_enable = 0, gen9_powergate_status = 0;
Daniel Vetter93b525d2012-01-25 13:52:43 +01001522 unsigned forcewake_count;
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001523 int count = 0;
Ben Widawsky4d855292011-12-12 19:34:16 -08001524
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001525 forcewake_count = READ_ONCE(dev_priv->uncore.fw_domain[FW_DOMAIN_ID_RENDER].wake_count);
Daniel Vetter93b525d2012-01-25 13:52:43 +01001526 if (forcewake_count) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001527 seq_puts(m, "RC information inaccurate because somebody "
1528 "holds a forcewake reference \n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001529 } else {
1530 /* NB: we cannot use forcewake, else we read the wrong values */
1531 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
1532 udelay(10);
1533 seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
1534 }
1535
Ville Syrjälä75aa3f62015-10-22 15:34:56 +03001536 gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS);
Chris Wilsoned71f1b2013-07-19 20:36:56 +01001537 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4, true);
Ben Widawsky4d855292011-12-12 19:34:16 -08001538
1539 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1540 rcctl1 = I915_READ(GEN6_RC_CONTROL);
David Weinehall36cdd012016-08-22 13:59:31 +03001541 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301542 gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE);
1543 gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS);
1544 }
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001545
Ben Widawsky44cbd332012-11-06 14:36:36 +00001546 mutex_lock(&dev_priv->rps.hw_lock);
1547 sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
1548 mutex_unlock(&dev_priv->rps.hw_lock);
Ben Widawsky4d855292011-12-12 19:34:16 -08001549
1550 seq_printf(m, "Video Turbo Mode: %s\n",
1551 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1552 seq_printf(m, "HW control enabled: %s\n",
1553 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1554 seq_printf(m, "SW control enabled: %s\n",
1555 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1556 GEN6_RP_MEDIA_SW_MODE));
Eric Anholtfff24e22012-01-23 16:14:05 -08001557 seq_printf(m, "RC1e Enabled: %s\n",
Ben Widawsky4d855292011-12-12 19:34:16 -08001558 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1559 seq_printf(m, "RC6 Enabled: %s\n",
1560 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
David Weinehall36cdd012016-08-22 13:59:31 +03001561 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301562 seq_printf(m, "Render Well Gating Enabled: %s\n",
1563 yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE));
1564 seq_printf(m, "Media Well Gating Enabled: %s\n",
1565 yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE));
1566 }
Ben Widawsky4d855292011-12-12 19:34:16 -08001567 seq_printf(m, "Deep RC6 Enabled: %s\n",
1568 yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
1569 seq_printf(m, "Deepest RC6 Enabled: %s\n",
1570 yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001571 seq_puts(m, "Current RC state: ");
Ben Widawsky4d855292011-12-12 19:34:16 -08001572 switch (gt_core_status & GEN6_RCn_MASK) {
1573 case GEN6_RC0:
1574 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
Damien Lespiau267f0c92013-06-24 22:59:48 +01001575 seq_puts(m, "Core Power Down\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001576 else
Damien Lespiau267f0c92013-06-24 22:59:48 +01001577 seq_puts(m, "on\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001578 break;
1579 case GEN6_RC3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001580 seq_puts(m, "RC3\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001581 break;
1582 case GEN6_RC6:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001583 seq_puts(m, "RC6\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001584 break;
1585 case GEN6_RC7:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001586 seq_puts(m, "RC7\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001587 break;
1588 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001589 seq_puts(m, "Unknown\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001590 break;
1591 }
1592
1593 seq_printf(m, "Core Power Down: %s\n",
1594 yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
David Weinehall36cdd012016-08-22 13:59:31 +03001595 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301596 seq_printf(m, "Render Power Well: %s\n",
1597 (gen9_powergate_status &
1598 GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down");
1599 seq_printf(m, "Media Power Well: %s\n",
1600 (gen9_powergate_status &
1601 GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down");
1602 }
Ben Widawskycce66a22012-03-27 18:59:38 -07001603
1604 /* Not exactly sure what this is */
Mika Kuoppala13628772017-03-15 17:43:02 +02001605 print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:",
1606 GEN6_GT_GFX_RC6_LOCKED);
1607 print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6);
1608 print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p);
1609 print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp);
Ben Widawskycce66a22012-03-27 18:59:38 -07001610
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001611 seq_printf(m, "RC6 voltage: %dmV\n",
1612 GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff)));
1613 seq_printf(m, "RC6+ voltage: %dmV\n",
1614 GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff)));
1615 seq_printf(m, "RC6++ voltage: %dmV\n",
1616 GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff)));
Akash Goelf2dd7572016-06-27 20:10:01 +05301617 return i915_forcewake_domains(m, NULL);
Ben Widawsky4d855292011-12-12 19:34:16 -08001618}
1619
1620static int i915_drpc_info(struct seq_file *m, void *unused)
1621{
David Weinehall36cdd012016-08-22 13:59:31 +03001622 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001623 int err;
1624
1625 intel_runtime_pm_get(dev_priv);
Ben Widawsky4d855292011-12-12 19:34:16 -08001626
David Weinehall36cdd012016-08-22 13:59:31 +03001627 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001628 err = vlv_drpc_info(m);
David Weinehall36cdd012016-08-22 13:59:31 +03001629 else if (INTEL_GEN(dev_priv) >= 6)
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001630 err = gen6_drpc_info(m);
Ben Widawsky4d855292011-12-12 19:34:16 -08001631 else
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001632 err = ironlake_drpc_info(m);
1633
1634 intel_runtime_pm_put(dev_priv);
1635
1636 return err;
Ben Widawsky4d855292011-12-12 19:34:16 -08001637}
1638
Daniel Vetter9a851782015-06-18 10:30:22 +02001639static int i915_frontbuffer_tracking(struct seq_file *m, void *unused)
1640{
David Weinehall36cdd012016-08-22 13:59:31 +03001641 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetter9a851782015-06-18 10:30:22 +02001642
1643 seq_printf(m, "FB tracking busy bits: 0x%08x\n",
1644 dev_priv->fb_tracking.busy_bits);
1645
1646 seq_printf(m, "FB tracking flip bits: 0x%08x\n",
1647 dev_priv->fb_tracking.flip_bits);
1648
1649 return 0;
1650}
1651
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001652static int i915_fbc_status(struct seq_file *m, void *unused)
1653{
David Weinehall36cdd012016-08-22 13:59:31 +03001654 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001655
David Weinehall36cdd012016-08-22 13:59:31 +03001656 if (!HAS_FBC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001657 seq_puts(m, "FBC unsupported on this chipset\n");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001658 return 0;
1659 }
1660
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001661 intel_runtime_pm_get(dev_priv);
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001662 mutex_lock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001663
Paulo Zanoni0e631ad2015-10-14 17:45:36 -03001664 if (intel_fbc_is_active(dev_priv))
Damien Lespiau267f0c92013-06-24 22:59:48 +01001665 seq_puts(m, "FBC enabled\n");
Paulo Zanoni2e8144a2015-06-12 14:36:20 -03001666 else
1667 seq_printf(m, "FBC disabled: %s\n",
Paulo Zanonibf6189c2015-10-27 14:50:03 -02001668 dev_priv->fbc.no_fbc_reason);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001669
Paulo Zanoni0fc6a9d2016-10-21 13:55:46 -02001670 if (intel_fbc_is_active(dev_priv) && INTEL_GEN(dev_priv) >= 7) {
1671 uint32_t mask = INTEL_GEN(dev_priv) >= 8 ?
1672 BDW_FBC_COMPRESSION_MASK :
1673 IVB_FBC_COMPRESSION_MASK;
Paulo Zanoni31b9df12015-06-12 14:36:18 -03001674 seq_printf(m, "Compressing: %s\n",
Paulo Zanoni0fc6a9d2016-10-21 13:55:46 -02001675 yesno(I915_READ(FBC_STATUS2) & mask));
1676 }
Paulo Zanoni31b9df12015-06-12 14:36:18 -03001677
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001678 mutex_unlock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001679 intel_runtime_pm_put(dev_priv);
1680
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001681 return 0;
1682}
1683
Rodrigo Vivida46f932014-08-01 02:04:45 -07001684static int i915_fbc_fc_get(void *data, u64 *val)
1685{
David Weinehall36cdd012016-08-22 13:59:31 +03001686 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001687
David Weinehall36cdd012016-08-22 13:59:31 +03001688 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001689 return -ENODEV;
1690
Rodrigo Vivida46f932014-08-01 02:04:45 -07001691 *val = dev_priv->fbc.false_color;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001692
1693 return 0;
1694}
1695
1696static int i915_fbc_fc_set(void *data, u64 val)
1697{
David Weinehall36cdd012016-08-22 13:59:31 +03001698 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001699 u32 reg;
1700
David Weinehall36cdd012016-08-22 13:59:31 +03001701 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001702 return -ENODEV;
1703
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001704 mutex_lock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001705
1706 reg = I915_READ(ILK_DPFC_CONTROL);
1707 dev_priv->fbc.false_color = val;
1708
1709 I915_WRITE(ILK_DPFC_CONTROL, val ?
1710 (reg | FBC_CTL_FALSE_COLOR) :
1711 (reg & ~FBC_CTL_FALSE_COLOR));
1712
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001713 mutex_unlock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001714 return 0;
1715}
1716
1717DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops,
1718 i915_fbc_fc_get, i915_fbc_fc_set,
1719 "%llu\n");
1720
Paulo Zanoni92d44622013-05-31 16:33:24 -03001721static int i915_ips_status(struct seq_file *m, void *unused)
1722{
David Weinehall36cdd012016-08-22 13:59:31 +03001723 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni92d44622013-05-31 16:33:24 -03001724
David Weinehall36cdd012016-08-22 13:59:31 +03001725 if (!HAS_IPS(dev_priv)) {
Paulo Zanoni92d44622013-05-31 16:33:24 -03001726 seq_puts(m, "not supported\n");
1727 return 0;
1728 }
1729
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001730 intel_runtime_pm_get(dev_priv);
1731
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001732 seq_printf(m, "Enabled by kernel parameter: %s\n",
1733 yesno(i915.enable_ips));
1734
David Weinehall36cdd012016-08-22 13:59:31 +03001735 if (INTEL_GEN(dev_priv) >= 8) {
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001736 seq_puts(m, "Currently: unknown\n");
1737 } else {
1738 if (I915_READ(IPS_CTL) & IPS_ENABLE)
1739 seq_puts(m, "Currently: enabled\n");
1740 else
1741 seq_puts(m, "Currently: disabled\n");
1742 }
Paulo Zanoni92d44622013-05-31 16:33:24 -03001743
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001744 intel_runtime_pm_put(dev_priv);
1745
Paulo Zanoni92d44622013-05-31 16:33:24 -03001746 return 0;
1747}
1748
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001749static int i915_sr_status(struct seq_file *m, void *unused)
1750{
David Weinehall36cdd012016-08-22 13:59:31 +03001751 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001752 bool sr_enabled = false;
1753
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001754 intel_runtime_pm_get(dev_priv);
Chris Wilson9c870d02016-10-24 13:42:15 +01001755 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001756
Chris Wilson7342a722017-03-09 14:20:49 +00001757 if (INTEL_GEN(dev_priv) >= 9)
1758 /* no global SR status; inspect per-plane WM */;
1759 else if (HAS_PCH_SPLIT(dev_priv))
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001760 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
Jani Nikulac0f86832016-12-07 12:13:04 +02001761 else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) ||
David Weinehall36cdd012016-08-22 13:59:31 +03001762 IS_I945G(dev_priv) || IS_I945GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001763 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001764 else if (IS_I915GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001765 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001766 else if (IS_PINEVIEW(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001767 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001768 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Ander Conselvan de Oliveira77b64552015-06-02 14:17:47 +03001769 sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001770
Chris Wilson9c870d02016-10-24 13:42:15 +01001771 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001772 intel_runtime_pm_put(dev_priv);
1773
Tvrtko Ursulin08c4d7f2016-11-17 12:30:14 +00001774 seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled));
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001775
1776 return 0;
1777}
1778
Jesse Barnes7648fa92010-05-20 14:28:11 -07001779static int i915_emon_status(struct seq_file *m, void *unused)
1780{
David Weinehall36cdd012016-08-22 13:59:31 +03001781 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1782 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001783 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +01001784 int ret;
1785
David Weinehall36cdd012016-08-22 13:59:31 +03001786 if (!IS_GEN5(dev_priv))
Chris Wilson582be6b2012-04-30 19:35:02 +01001787 return -ENODEV;
1788
Chris Wilsonde227ef2010-07-03 07:58:38 +01001789 ret = mutex_lock_interruptible(&dev->struct_mutex);
1790 if (ret)
1791 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001792
1793 temp = i915_mch_val(dev_priv);
1794 chipset = i915_chipset_val(dev_priv);
1795 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +01001796 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001797
1798 seq_printf(m, "GMCH temp: %ld\n", temp);
1799 seq_printf(m, "Chipset power: %ld\n", chipset);
1800 seq_printf(m, "GFX power: %ld\n", gfx);
1801 seq_printf(m, "Total power: %ld\n", chipset + gfx);
1802
1803 return 0;
1804}
1805
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001806static int i915_ring_freq_table(struct seq_file *m, void *unused)
1807{
David Weinehall36cdd012016-08-22 13:59:31 +03001808 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001809 int ret = 0;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001810 int gpu_freq, ia_freq;
Akash Goelf936ec32015-06-29 14:50:22 +05301811 unsigned int max_gpu_freq, min_gpu_freq;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001812
Carlos Santa26310342016-08-17 12:30:41 -07001813 if (!HAS_LLC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001814 seq_puts(m, "unsupported on this chipset\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001815 return 0;
1816 }
1817
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001818 intel_runtime_pm_get(dev_priv);
1819
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001820 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001821 if (ret)
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001822 goto out;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001823
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001824 if (IS_GEN9_BC(dev_priv)) {
Akash Goelf936ec32015-06-29 14:50:22 +05301825 /* Convert GT frequency to 50 HZ units */
1826 min_gpu_freq =
1827 dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER;
1828 max_gpu_freq =
1829 dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER;
1830 } else {
1831 min_gpu_freq = dev_priv->rps.min_freq_softlimit;
1832 max_gpu_freq = dev_priv->rps.max_freq_softlimit;
1833 }
1834
Damien Lespiau267f0c92013-06-24 22:59:48 +01001835 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001836
Akash Goelf936ec32015-06-29 14:50:22 +05301837 for (gpu_freq = min_gpu_freq; gpu_freq <= max_gpu_freq; gpu_freq++) {
Ben Widawsky42c05262012-09-26 10:34:00 -07001838 ia_freq = gpu_freq;
1839 sandybridge_pcode_read(dev_priv,
1840 GEN6_PCODE_READ_MIN_FREQ_TABLE,
1841 &ia_freq);
Chris Wilson3ebecd02013-04-12 19:10:13 +01001842 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n",
Akash Goelf936ec32015-06-29 14:50:22 +05301843 intel_gpu_freq(dev_priv, (gpu_freq *
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001844 (IS_GEN9_BC(dev_priv) ?
1845 GEN9_FREQ_SCALER : 1))),
Chris Wilson3ebecd02013-04-12 19:10:13 +01001846 ((ia_freq >> 0) & 0xff) * 100,
1847 ((ia_freq >> 8) & 0xff) * 100);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001848 }
1849
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001850 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001851
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001852out:
1853 intel_runtime_pm_put(dev_priv);
1854 return ret;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001855}
1856
Chris Wilson44834a62010-08-19 16:09:23 +01001857static int i915_opregion(struct seq_file *m, void *unused)
1858{
David Weinehall36cdd012016-08-22 13:59:31 +03001859 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1860 struct drm_device *dev = &dev_priv->drm;
Chris Wilson44834a62010-08-19 16:09:23 +01001861 struct intel_opregion *opregion = &dev_priv->opregion;
1862 int ret;
1863
1864 ret = mutex_lock_interruptible(&dev->struct_mutex);
1865 if (ret)
Daniel Vetter0d38f002012-04-21 22:49:10 +02001866 goto out;
Chris Wilson44834a62010-08-19 16:09:23 +01001867
Jani Nikula2455a8e2015-12-14 12:50:53 +02001868 if (opregion->header)
1869 seq_write(m, opregion->header, OPREGION_SIZE);
Chris Wilson44834a62010-08-19 16:09:23 +01001870
1871 mutex_unlock(&dev->struct_mutex);
1872
Daniel Vetter0d38f002012-04-21 22:49:10 +02001873out:
Chris Wilson44834a62010-08-19 16:09:23 +01001874 return 0;
1875}
1876
Jani Nikulaada8f952015-12-15 13:17:12 +02001877static int i915_vbt(struct seq_file *m, void *unused)
1878{
David Weinehall36cdd012016-08-22 13:59:31 +03001879 struct intel_opregion *opregion = &node_to_i915(m->private)->opregion;
Jani Nikulaada8f952015-12-15 13:17:12 +02001880
1881 if (opregion->vbt)
1882 seq_write(m, opregion->vbt, opregion->vbt_size);
1883
1884 return 0;
1885}
1886
Chris Wilson37811fc2010-08-25 22:45:57 +01001887static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
1888{
David Weinehall36cdd012016-08-22 13:59:31 +03001889 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1890 struct drm_device *dev = &dev_priv->drm;
Namrta Salonieb13b8402015-11-27 13:43:11 +05301891 struct intel_framebuffer *fbdev_fb = NULL;
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001892 struct drm_framebuffer *drm_fb;
Chris Wilson188c1ab2016-04-03 14:14:20 +01001893 int ret;
1894
1895 ret = mutex_lock_interruptible(&dev->struct_mutex);
1896 if (ret)
1897 return ret;
Chris Wilson37811fc2010-08-25 22:45:57 +01001898
Daniel Vetter06957262015-08-10 13:34:08 +02001899#ifdef CONFIG_DRM_FBDEV_EMULATION
David Weinehall36cdd012016-08-22 13:59:31 +03001900 if (dev_priv->fbdev) {
1901 fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb);
Chris Wilson37811fc2010-08-25 22:45:57 +01001902
Chris Wilson25bcce92016-07-02 15:36:00 +01001903 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
1904 fbdev_fb->base.width,
1905 fbdev_fb->base.height,
Ville Syrjäläb00c6002016-12-14 23:31:35 +02001906 fbdev_fb->base.format->depth,
Ville Syrjälä272725c2016-12-14 23:32:20 +02001907 fbdev_fb->base.format->cpp[0] * 8,
Ville Syrjäläbae781b2016-11-16 13:33:16 +02001908 fbdev_fb->base.modifier,
Chris Wilson25bcce92016-07-02 15:36:00 +01001909 drm_framebuffer_read_refcount(&fbdev_fb->base));
1910 describe_obj(m, fbdev_fb->obj);
1911 seq_putc(m, '\n');
1912 }
Daniel Vetter4520f532013-10-09 09:18:51 +02001913#endif
Chris Wilson37811fc2010-08-25 22:45:57 +01001914
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001915 mutex_lock(&dev->mode_config.fb_lock);
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001916 drm_for_each_fb(drm_fb, dev) {
Namrta Salonieb13b8402015-11-27 13:43:11 +05301917 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
1918 if (fb == fbdev_fb)
Chris Wilson37811fc2010-08-25 22:45:57 +01001919 continue;
1920
Tvrtko Ursulinc1ca506d2015-02-10 17:16:07 +00001921 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 +01001922 fb->base.width,
1923 fb->base.height,
Ville Syrjäläb00c6002016-12-14 23:31:35 +02001924 fb->base.format->depth,
Ville Syrjälä272725c2016-12-14 23:32:20 +02001925 fb->base.format->cpp[0] * 8,
Ville Syrjäläbae781b2016-11-16 13:33:16 +02001926 fb->base.modifier,
Dave Airlie747a5982016-04-15 15:10:35 +10001927 drm_framebuffer_read_refcount(&fb->base));
Chris Wilson05394f32010-11-08 19:18:58 +00001928 describe_obj(m, fb->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001929 seq_putc(m, '\n');
Chris Wilson37811fc2010-08-25 22:45:57 +01001930 }
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001931 mutex_unlock(&dev->mode_config.fb_lock);
Chris Wilson188c1ab2016-04-03 14:14:20 +01001932 mutex_unlock(&dev->struct_mutex);
Chris Wilson37811fc2010-08-25 22:45:57 +01001933
1934 return 0;
1935}
1936
Chris Wilson7e37f882016-08-02 22:50:21 +01001937static void describe_ctx_ring(struct seq_file *m, struct intel_ring *ring)
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001938{
Chris Wilsonfe085f12017-03-21 10:25:52 +00001939 seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u)",
1940 ring->space, ring->head, ring->tail);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001941}
1942
Ben Widawskye76d3632011-03-19 18:14:29 -07001943static int i915_context_status(struct seq_file *m, void *unused)
1944{
David Weinehall36cdd012016-08-22 13:59:31 +03001945 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1946 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001947 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01001948 struct i915_gem_context *ctx;
Akash Goel3b3f1652016-10-13 22:44:48 +05301949 enum intel_engine_id id;
Dave Gordonc3232b12016-03-23 18:19:53 +00001950 int ret;
Ben Widawskye76d3632011-03-19 18:14:29 -07001951
Daniel Vetterf3d28872014-05-29 23:23:08 +02001952 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07001953 if (ret)
1954 return ret;
1955
Ben Widawskya33afea2013-09-17 21:12:45 -07001956 list_for_each_entry(ctx, &dev_priv->context_list, link) {
Chris Wilson5d1808e2016-04-28 09:56:51 +01001957 seq_printf(m, "HW context %u ", ctx->hw_id);
Chris Wilsonc84455b2016-08-15 10:49:08 +01001958 if (ctx->pid) {
Chris Wilsond28b99a2016-05-24 14:53:39 +01001959 struct task_struct *task;
1960
Chris Wilsonc84455b2016-08-15 10:49:08 +01001961 task = get_pid_task(ctx->pid, PIDTYPE_PID);
Chris Wilsond28b99a2016-05-24 14:53:39 +01001962 if (task) {
1963 seq_printf(m, "(%s [%d]) ",
1964 task->comm, task->pid);
1965 put_task_struct(task);
1966 }
Chris Wilsonc84455b2016-08-15 10:49:08 +01001967 } else if (IS_ERR(ctx->file_priv)) {
1968 seq_puts(m, "(deleted) ");
Chris Wilsond28b99a2016-05-24 14:53:39 +01001969 } else {
1970 seq_puts(m, "(kernel) ");
1971 }
1972
Chris Wilsonbca44d82016-05-24 14:53:41 +01001973 seq_putc(m, ctx->remap_slice ? 'R' : 'r');
1974 seq_putc(m, '\n');
Ben Widawskya33afea2013-09-17 21:12:45 -07001975
Akash Goel3b3f1652016-10-13 22:44:48 +05301976 for_each_engine(engine, dev_priv, id) {
Chris Wilsonbca44d82016-05-24 14:53:41 +01001977 struct intel_context *ce = &ctx->engine[engine->id];
1978
1979 seq_printf(m, "%s: ", engine->name);
1980 seq_putc(m, ce->initialised ? 'I' : 'i');
1981 if (ce->state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001982 describe_obj(m, ce->state->obj);
Chris Wilsondca33ec2016-08-02 22:50:20 +01001983 if (ce->ring)
Chris Wilson7e37f882016-08-02 22:50:21 +01001984 describe_ctx_ring(m, ce->ring);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001985 seq_putc(m, '\n');
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001986 }
1987
Ben Widawskya33afea2013-09-17 21:12:45 -07001988 seq_putc(m, '\n');
Ben Widawskya168c292013-02-14 15:05:12 -08001989 }
1990
Daniel Vetterf3d28872014-05-29 23:23:08 +02001991 mutex_unlock(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07001992
1993 return 0;
1994}
1995
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001996static void i915_dump_lrc_obj(struct seq_file *m,
Chris Wilsone2efd132016-05-24 14:53:34 +01001997 struct i915_gem_context *ctx,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +00001998 struct intel_engine_cs *engine)
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001999{
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002000 struct i915_vma *vma = ctx->engine[engine->id].state;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002001 struct page *page;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002002 int j;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002003
Chris Wilson7069b142016-04-28 09:56:52 +01002004 seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id);
2005
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002006 if (!vma) {
2007 seq_puts(m, "\tFake context\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002008 return;
2009 }
2010
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002011 if (vma->flags & I915_VMA_GLOBAL_BIND)
2012 seq_printf(m, "\tBound in GGTT at 0x%08x\n",
Chris Wilsonbde13eb2016-08-15 10:49:07 +01002013 i915_ggtt_offset(vma));
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002014
Chris Wilsona4f5ea62016-10-28 13:58:35 +01002015 if (i915_gem_object_pin_pages(vma->obj)) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002016 seq_puts(m, "\tFailed to get pages for context object\n\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002017 return;
2018 }
2019
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002020 page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN);
2021 if (page) {
2022 u32 *reg_state = kmap_atomic(page);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002023
2024 for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002025 seq_printf(m,
2026 "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n",
2027 j * 4,
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002028 reg_state[j], reg_state[j + 1],
2029 reg_state[j + 2], reg_state[j + 3]);
2030 }
2031 kunmap_atomic(reg_state);
2032 }
2033
Chris Wilsona4f5ea62016-10-28 13:58:35 +01002034 i915_gem_object_unpin_pages(vma->obj);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002035 seq_putc(m, '\n');
2036}
2037
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002038static int i915_dump_lrc(struct seq_file *m, void *unused)
2039{
David Weinehall36cdd012016-08-22 13:59:31 +03002040 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2041 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002042 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01002043 struct i915_gem_context *ctx;
Akash Goel3b3f1652016-10-13 22:44:48 +05302044 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002045 int ret;
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002046
2047 if (!i915.enable_execlists) {
2048 seq_printf(m, "Logical Ring Contexts are disabled\n");
2049 return 0;
2050 }
2051
2052 ret = mutex_lock_interruptible(&dev->struct_mutex);
2053 if (ret)
2054 return ret;
2055
Dave Gordone28e4042016-01-19 19:02:55 +00002056 list_for_each_entry(ctx, &dev_priv->context_list, link)
Akash Goel3b3f1652016-10-13 22:44:48 +05302057 for_each_engine(engine, dev_priv, id)
Chris Wilson24f1d3c2016-04-28 09:56:53 +01002058 i915_dump_lrc_obj(m, ctx, engine);
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002059
2060 mutex_unlock(&dev->struct_mutex);
2061
2062 return 0;
2063}
2064
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002065static const char *swizzle_string(unsigned swizzle)
2066{
Damien Lespiauaee56cf2013-06-24 22:59:49 +01002067 switch (swizzle) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002068 case I915_BIT_6_SWIZZLE_NONE:
2069 return "none";
2070 case I915_BIT_6_SWIZZLE_9:
2071 return "bit9";
2072 case I915_BIT_6_SWIZZLE_9_10:
2073 return "bit9/bit10";
2074 case I915_BIT_6_SWIZZLE_9_11:
2075 return "bit9/bit11";
2076 case I915_BIT_6_SWIZZLE_9_10_11:
2077 return "bit9/bit10/bit11";
2078 case I915_BIT_6_SWIZZLE_9_17:
2079 return "bit9/bit17";
2080 case I915_BIT_6_SWIZZLE_9_10_17:
2081 return "bit9/bit10/bit17";
2082 case I915_BIT_6_SWIZZLE_UNKNOWN:
Masanari Iida8a168ca2012-12-29 02:00:09 +09002083 return "unknown";
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002084 }
2085
2086 return "bug";
2087}
2088
2089static int i915_swizzle_info(struct seq_file *m, void *data)
2090{
David Weinehall36cdd012016-08-22 13:59:31 +03002091 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002092
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002093 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02002094
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002095 seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
2096 swizzle_string(dev_priv->mm.bit_6_swizzle_x));
2097 seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
2098 swizzle_string(dev_priv->mm.bit_6_swizzle_y));
2099
David Weinehall36cdd012016-08-22 13:59:31 +03002100 if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002101 seq_printf(m, "DDC = 0x%08x\n",
2102 I915_READ(DCC));
Daniel Vetter656bfa32014-11-20 09:26:30 +01002103 seq_printf(m, "DDC2 = 0x%08x\n",
2104 I915_READ(DCC2));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002105 seq_printf(m, "C0DRB3 = 0x%04x\n",
2106 I915_READ16(C0DRB3));
2107 seq_printf(m, "C1DRB3 = 0x%04x\n",
2108 I915_READ16(C1DRB3));
David Weinehall36cdd012016-08-22 13:59:31 +03002109 } else if (INTEL_GEN(dev_priv) >= 6) {
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002110 seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
2111 I915_READ(MAD_DIMM_C0));
2112 seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
2113 I915_READ(MAD_DIMM_C1));
2114 seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
2115 I915_READ(MAD_DIMM_C2));
2116 seq_printf(m, "TILECTL = 0x%08x\n",
2117 I915_READ(TILECTL));
David Weinehall36cdd012016-08-22 13:59:31 +03002118 if (INTEL_GEN(dev_priv) >= 8)
Ben Widawsky9d3203e2013-11-02 21:07:14 -07002119 seq_printf(m, "GAMTARBMODE = 0x%08x\n",
2120 I915_READ(GAMTARBMODE));
2121 else
2122 seq_printf(m, "ARB_MODE = 0x%08x\n",
2123 I915_READ(ARB_MODE));
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002124 seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
2125 I915_READ(DISP_ARB_CTL));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002126 }
Daniel Vetter656bfa32014-11-20 09:26:30 +01002127
2128 if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES)
2129 seq_puts(m, "L-shaped memory detected\n");
2130
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002131 intel_runtime_pm_put(dev_priv);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002132
2133 return 0;
2134}
2135
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002136static int per_file_ctx(int id, void *ptr, void *data)
2137{
Chris Wilsone2efd132016-05-24 14:53:34 +01002138 struct i915_gem_context *ctx = ptr;
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002139 struct seq_file *m = data;
Daniel Vetterae6c4802014-08-06 15:04:53 +02002140 struct i915_hw_ppgtt *ppgtt = ctx->ppgtt;
2141
2142 if (!ppgtt) {
2143 seq_printf(m, " no ppgtt for context %d\n",
2144 ctx->user_handle);
2145 return 0;
2146 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002147
Oscar Mateof83d6512014-05-22 14:13:38 +01002148 if (i915_gem_context_is_default(ctx))
2149 seq_puts(m, " default context:\n");
2150 else
Oscar Mateo821d66d2014-07-03 16:28:00 +01002151 seq_printf(m, " context %d:\n", ctx->user_handle);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002152 ppgtt->debug_dump(ppgtt, m);
2153
2154 return 0;
2155}
2156
David Weinehall36cdd012016-08-22 13:59:31 +03002157static void gen8_ppgtt_info(struct seq_file *m,
2158 struct drm_i915_private *dev_priv)
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002159{
Ben Widawsky77df6772013-11-02 21:07:30 -07002160 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
Akash Goel3b3f1652016-10-13 22:44:48 +05302161 struct intel_engine_cs *engine;
2162 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002163 int i;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002164
Ben Widawsky77df6772013-11-02 21:07:30 -07002165 if (!ppgtt)
2166 return;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002167
Akash Goel3b3f1652016-10-13 22:44:48 +05302168 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002169 seq_printf(m, "%s\n", engine->name);
Ben Widawsky77df6772013-11-02 21:07:30 -07002170 for (i = 0; i < 4; i++) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002171 u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i));
Ben Widawsky77df6772013-11-02 21:07:30 -07002172 pdp <<= 32;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002173 pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i));
Ville Syrjäläa2a5b152014-03-31 18:17:16 +03002174 seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp);
Ben Widawsky77df6772013-11-02 21:07:30 -07002175 }
2176 }
2177}
2178
David Weinehall36cdd012016-08-22 13:59:31 +03002179static void gen6_ppgtt_info(struct seq_file *m,
2180 struct drm_i915_private *dev_priv)
Ben Widawsky77df6772013-11-02 21:07:30 -07002181{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002182 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05302183 enum intel_engine_id id;
Ben Widawsky77df6772013-11-02 21:07:30 -07002184
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002185 if (IS_GEN6(dev_priv))
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002186 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
2187
Akash Goel3b3f1652016-10-13 22:44:48 +05302188 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002189 seq_printf(m, "%s\n", engine->name);
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002190 if (IS_GEN7(dev_priv))
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002191 seq_printf(m, "GFX_MODE: 0x%08x\n",
2192 I915_READ(RING_MODE_GEN7(engine)));
2193 seq_printf(m, "PP_DIR_BASE: 0x%08x\n",
2194 I915_READ(RING_PP_DIR_BASE(engine)));
2195 seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n",
2196 I915_READ(RING_PP_DIR_BASE_READ(engine)));
2197 seq_printf(m, "PP_DIR_DCLV: 0x%08x\n",
2198 I915_READ(RING_PP_DIR_DCLV(engine)));
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002199 }
2200 if (dev_priv->mm.aliasing_ppgtt) {
2201 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
2202
Damien Lespiau267f0c92013-06-24 22:59:48 +01002203 seq_puts(m, "aliasing PPGTT:\n");
Mika Kuoppala44159dd2015-06-25 18:35:07 +03002204 seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd.base.ggtt_offset);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002205
Ben Widawsky87d60b62013-12-06 14:11:29 -08002206 ppgtt->debug_dump(ppgtt, m);
Daniel Vetterae6c4802014-08-06 15:04:53 +02002207 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002208
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002209 seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
Ben Widawsky77df6772013-11-02 21:07:30 -07002210}
2211
2212static int i915_ppgtt_info(struct seq_file *m, void *data)
2213{
David Weinehall36cdd012016-08-22 13:59:31 +03002214 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2215 struct drm_device *dev = &dev_priv->drm;
Michel Thierryea91e402015-07-29 17:23:57 +01002216 struct drm_file *file;
Chris Wilson637ee292016-08-22 14:28:20 +01002217 int ret;
Ben Widawsky77df6772013-11-02 21:07:30 -07002218
Chris Wilson637ee292016-08-22 14:28:20 +01002219 mutex_lock(&dev->filelist_mutex);
2220 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawsky77df6772013-11-02 21:07:30 -07002221 if (ret)
Chris Wilson637ee292016-08-22 14:28:20 +01002222 goto out_unlock;
2223
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002224 intel_runtime_pm_get(dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002225
David Weinehall36cdd012016-08-22 13:59:31 +03002226 if (INTEL_GEN(dev_priv) >= 8)
2227 gen8_ppgtt_info(m, dev_priv);
2228 else if (INTEL_GEN(dev_priv) >= 6)
2229 gen6_ppgtt_info(m, dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002230
Michel Thierryea91e402015-07-29 17:23:57 +01002231 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2232 struct drm_i915_file_private *file_priv = file->driver_priv;
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002233 struct task_struct *task;
Michel Thierryea91e402015-07-29 17:23:57 +01002234
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002235 task = get_pid_task(file->pid, PIDTYPE_PID);
Dan Carpenter06812762015-10-02 18:14:22 +03002236 if (!task) {
2237 ret = -ESRCH;
Chris Wilson637ee292016-08-22 14:28:20 +01002238 goto out_rpm;
Dan Carpenter06812762015-10-02 18:14:22 +03002239 }
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002240 seq_printf(m, "\nproc: %s\n", task->comm);
2241 put_task_struct(task);
Michel Thierryea91e402015-07-29 17:23:57 +01002242 idr_for_each(&file_priv->context_idr, per_file_ctx,
2243 (void *)(unsigned long)m);
2244 }
2245
Chris Wilson637ee292016-08-22 14:28:20 +01002246out_rpm:
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002247 intel_runtime_pm_put(dev_priv);
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002248 mutex_unlock(&dev->struct_mutex);
Chris Wilson637ee292016-08-22 14:28:20 +01002249out_unlock:
2250 mutex_unlock(&dev->filelist_mutex);
Dan Carpenter06812762015-10-02 18:14:22 +03002251 return ret;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002252}
2253
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002254static int count_irq_waiters(struct drm_i915_private *i915)
2255{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002256 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05302257 enum intel_engine_id id;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002258 int count = 0;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002259
Akash Goel3b3f1652016-10-13 22:44:48 +05302260 for_each_engine(engine, i915, id)
Chris Wilson688e6c72016-07-01 17:23:15 +01002261 count += intel_engine_has_waiter(engine);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002262
2263 return count;
2264}
2265
Chris Wilson7466c292016-08-15 09:49:33 +01002266static const char *rps_power_to_str(unsigned int power)
2267{
2268 static const char * const strings[] = {
2269 [LOW_POWER] = "low power",
2270 [BETWEEN] = "mixed",
2271 [HIGH_POWER] = "high power",
2272 };
2273
2274 if (power >= ARRAY_SIZE(strings) || !strings[power])
2275 return "unknown";
2276
2277 return strings[power];
2278}
2279
Chris Wilson1854d5c2015-04-07 16:20:32 +01002280static int i915_rps_boost_info(struct seq_file *m, void *data)
2281{
David Weinehall36cdd012016-08-22 13:59:31 +03002282 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2283 struct drm_device *dev = &dev_priv->drm;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002284 struct drm_file *file;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002285
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002286 seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled);
Chris Wilson28176ef2016-10-28 13:58:56 +01002287 seq_printf(m, "GPU busy? %s [%d requests]\n",
2288 yesno(dev_priv->gt.awake), dev_priv->gt.active_requests);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002289 seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv));
Chris Wilson7466c292016-08-15 09:49:33 +01002290 seq_printf(m, "Frequency requested %d\n",
2291 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
2292 seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n",
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002293 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq),
2294 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit),
2295 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit),
2296 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
Chris Wilson7466c292016-08-15 09:49:33 +01002297 seq_printf(m, " idle:%d, efficient:%d, boost:%d\n",
2298 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq),
2299 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq),
2300 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002301
2302 mutex_lock(&dev->filelist_mutex);
Chris Wilson8d3afd72015-05-21 21:01:47 +01002303 spin_lock(&dev_priv->rps.client_lock);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002304 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2305 struct drm_i915_file_private *file_priv = file->driver_priv;
2306 struct task_struct *task;
2307
2308 rcu_read_lock();
2309 task = pid_task(file->pid, PIDTYPE_PID);
2310 seq_printf(m, "%s [%d]: %d boosts%s\n",
2311 task ? task->comm : "<unknown>",
2312 task ? task->pid : -1,
Chris Wilson2e1b8732015-04-27 13:41:22 +01002313 file_priv->rps.boosts,
2314 list_empty(&file_priv->rps.link) ? "" : ", active");
Chris Wilson1854d5c2015-04-07 16:20:32 +01002315 rcu_read_unlock();
2316 }
Chris Wilson197be2a2016-07-20 09:21:13 +01002317 seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts);
Chris Wilson8d3afd72015-05-21 21:01:47 +01002318 spin_unlock(&dev_priv->rps.client_lock);
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002319 mutex_unlock(&dev->filelist_mutex);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002320
Chris Wilson7466c292016-08-15 09:49:33 +01002321 if (INTEL_GEN(dev_priv) >= 6 &&
2322 dev_priv->rps.enabled &&
Chris Wilson28176ef2016-10-28 13:58:56 +01002323 dev_priv->gt.active_requests) {
Chris Wilson7466c292016-08-15 09:49:33 +01002324 u32 rpup, rpupei;
2325 u32 rpdown, rpdownei;
2326
2327 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
2328 rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK;
2329 rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK;
2330 rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK;
2331 rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK;
2332 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
2333
2334 seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n",
2335 rps_power_to_str(dev_priv->rps.power));
2336 seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n",
Chris Wilson23f4a282017-02-18 11:27:08 +00002337 rpup && rpupei ? 100 * rpup / rpupei : 0,
Chris Wilson7466c292016-08-15 09:49:33 +01002338 dev_priv->rps.up_threshold);
2339 seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n",
Chris Wilson23f4a282017-02-18 11:27:08 +00002340 rpdown && rpdownei ? 100 * rpdown / rpdownei : 0,
Chris Wilson7466c292016-08-15 09:49:33 +01002341 dev_priv->rps.down_threshold);
2342 } else {
2343 seq_puts(m, "\nRPS Autotuning inactive\n");
2344 }
2345
Chris Wilson8d3afd72015-05-21 21:01:47 +01002346 return 0;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002347}
2348
Ben Widawsky63573eb2013-07-04 11:02:07 -07002349static int i915_llc(struct seq_file *m, void *data)
2350{
David Weinehall36cdd012016-08-22 13:59:31 +03002351 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002352 const bool edram = INTEL_GEN(dev_priv) > 8;
Ben Widawsky63573eb2013-07-04 11:02:07 -07002353
David Weinehall36cdd012016-08-22 13:59:31 +03002354 seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv)));
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002355 seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC",
2356 intel_uncore_edram_size(dev_priv)/1024/1024);
Ben Widawsky63573eb2013-07-04 11:02:07 -07002357
2358 return 0;
2359}
2360
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002361static int i915_huc_load_status_info(struct seq_file *m, void *data)
2362{
2363 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2364 struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
2365
2366 if (!HAS_HUC_UCODE(dev_priv))
2367 return 0;
2368
2369 seq_puts(m, "HuC firmware status:\n");
2370 seq_printf(m, "\tpath: %s\n", huc_fw->path);
2371 seq_printf(m, "\tfetch: %s\n",
2372 intel_uc_fw_status_repr(huc_fw->fetch_status));
2373 seq_printf(m, "\tload: %s\n",
2374 intel_uc_fw_status_repr(huc_fw->load_status));
2375 seq_printf(m, "\tversion wanted: %d.%d\n",
2376 huc_fw->major_ver_wanted, huc_fw->minor_ver_wanted);
2377 seq_printf(m, "\tversion found: %d.%d\n",
2378 huc_fw->major_ver_found, huc_fw->minor_ver_found);
2379 seq_printf(m, "\theader: offset is %d; size = %d\n",
2380 huc_fw->header_offset, huc_fw->header_size);
2381 seq_printf(m, "\tuCode: offset is %d; size = %d\n",
2382 huc_fw->ucode_offset, huc_fw->ucode_size);
2383 seq_printf(m, "\tRSA: offset is %d; size = %d\n",
2384 huc_fw->rsa_offset, huc_fw->rsa_size);
2385
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302386 intel_runtime_pm_get(dev_priv);
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002387 seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2));
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302388 intel_runtime_pm_put(dev_priv);
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002389
2390 return 0;
2391}
2392
Alex Daifdf5d352015-08-12 15:43:37 +01002393static int i915_guc_load_status_info(struct seq_file *m, void *data)
2394{
David Weinehall36cdd012016-08-22 13:59:31 +03002395 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002396 struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
Alex Daifdf5d352015-08-12 15:43:37 +01002397 u32 tmp, i;
2398
Joonas Lahtinen2d1fe072016-04-07 11:08:05 +03002399 if (!HAS_GUC_UCODE(dev_priv))
Alex Daifdf5d352015-08-12 15:43:37 +01002400 return 0;
2401
2402 seq_printf(m, "GuC firmware status:\n");
2403 seq_printf(m, "\tpath: %s\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002404 guc_fw->path);
Alex Daifdf5d352015-08-12 15:43:37 +01002405 seq_printf(m, "\tfetch: %s\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002406 intel_uc_fw_status_repr(guc_fw->fetch_status));
Alex Daifdf5d352015-08-12 15:43:37 +01002407 seq_printf(m, "\tload: %s\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002408 intel_uc_fw_status_repr(guc_fw->load_status));
Alex Daifdf5d352015-08-12 15:43:37 +01002409 seq_printf(m, "\tversion wanted: %d.%d\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002410 guc_fw->major_ver_wanted, guc_fw->minor_ver_wanted);
Alex Daifdf5d352015-08-12 15:43:37 +01002411 seq_printf(m, "\tversion found: %d.%d\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002412 guc_fw->major_ver_found, guc_fw->minor_ver_found);
Alex Daifeda33e2015-10-19 16:10:54 -07002413 seq_printf(m, "\theader: offset is %d; size = %d\n",
2414 guc_fw->header_offset, guc_fw->header_size);
2415 seq_printf(m, "\tuCode: offset is %d; size = %d\n",
2416 guc_fw->ucode_offset, guc_fw->ucode_size);
2417 seq_printf(m, "\tRSA: offset is %d; size = %d\n",
2418 guc_fw->rsa_offset, guc_fw->rsa_size);
Alex Daifdf5d352015-08-12 15:43:37 +01002419
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302420 intel_runtime_pm_get(dev_priv);
2421
Alex Daifdf5d352015-08-12 15:43:37 +01002422 tmp = I915_READ(GUC_STATUS);
2423
2424 seq_printf(m, "\nGuC status 0x%08x:\n", tmp);
2425 seq_printf(m, "\tBootrom status = 0x%x\n",
2426 (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT);
2427 seq_printf(m, "\tuKernel status = 0x%x\n",
2428 (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT);
2429 seq_printf(m, "\tMIA Core status = 0x%x\n",
2430 (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT);
2431 seq_puts(m, "\nScratch registers:\n");
2432 for (i = 0; i < 16; i++)
2433 seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i)));
2434
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302435 intel_runtime_pm_put(dev_priv);
2436
Alex Daifdf5d352015-08-12 15:43:37 +01002437 return 0;
2438}
2439
Akash Goel5aa1ee42016-10-12 21:54:36 +05302440static void i915_guc_log_info(struct seq_file *m,
2441 struct drm_i915_private *dev_priv)
2442{
2443 struct intel_guc *guc = &dev_priv->guc;
2444
2445 seq_puts(m, "\nGuC logging stats:\n");
2446
2447 seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n",
2448 guc->log.flush_count[GUC_ISR_LOG_BUFFER],
2449 guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]);
2450
2451 seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n",
2452 guc->log.flush_count[GUC_DPC_LOG_BUFFER],
2453 guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]);
2454
2455 seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n",
2456 guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER],
2457 guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]);
2458
2459 seq_printf(m, "\tTotal flush interrupt count: %u\n",
2460 guc->log.flush_interrupt_count);
2461
2462 seq_printf(m, "\tCapture miss count: %u\n",
2463 guc->log.capture_miss_count);
2464}
2465
Dave Gordon8b417c22015-08-12 15:43:44 +01002466static void i915_guc_client_info(struct seq_file *m,
2467 struct drm_i915_private *dev_priv,
2468 struct i915_guc_client *client)
2469{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002470 struct intel_engine_cs *engine;
Dave Gordonc18468c2016-08-09 15:19:22 +01002471 enum intel_engine_id id;
Dave Gordon8b417c22015-08-12 15:43:44 +01002472 uint64_t tot = 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002473
2474 seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n",
2475 client->priority, client->ctx_index, client->proc_desc_offset);
Joonas Lahtinenabddffd2017-03-22 10:39:44 -07002476 seq_printf(m, "\tDoorbell id %d, offset: 0x%lx, cookie 0x%x\n",
Chris Wilson357248b2016-11-29 12:10:21 +00002477 client->doorbell_id, client->doorbell_offset, client->doorbell_cookie);
Dave Gordon8b417c22015-08-12 15:43:44 +01002478 seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n",
2479 client->wq_size, client->wq_offset, client->wq_tail);
2480
Dave Gordon551aaec2016-05-13 15:36:33 +01002481 seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space);
Dave Gordon8b417c22015-08-12 15:43:44 +01002482 seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail);
2483 seq_printf(m, "\tLast submission result: %d\n", client->retcode);
2484
Akash Goel3b3f1652016-10-13 22:44:48 +05302485 for_each_engine(engine, dev_priv, id) {
Dave Gordonc18468c2016-08-09 15:19:22 +01002486 u64 submissions = client->submissions[id];
2487 tot += submissions;
Dave Gordon8b417c22015-08-12 15:43:44 +01002488 seq_printf(m, "\tSubmissions: %llu %s\n",
Dave Gordonc18468c2016-08-09 15:19:22 +01002489 submissions, engine->name);
Dave Gordon8b417c22015-08-12 15:43:44 +01002490 }
2491 seq_printf(m, "\tTotal: %llu\n", tot);
2492}
2493
2494static int i915_guc_info(struct seq_file *m, void *data)
2495{
David Weinehall36cdd012016-08-22 13:59:31 +03002496 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilson334636c2016-11-29 12:10:20 +00002497 const struct intel_guc *guc = &dev_priv->guc;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002498 struct intel_engine_cs *engine;
Dave Gordonc18468c2016-08-09 15:19:22 +01002499 enum intel_engine_id id;
Chris Wilson334636c2016-11-29 12:10:20 +00002500 u64 total;
Dave Gordon8b417c22015-08-12 15:43:44 +01002501
Chris Wilson334636c2016-11-29 12:10:20 +00002502 if (!guc->execbuf_client) {
2503 seq_printf(m, "GuC submission %s\n",
2504 HAS_GUC_SCHED(dev_priv) ?
2505 "disabled" :
2506 "not supported");
Dave Gordon8b417c22015-08-12 15:43:44 +01002507 return 0;
Chris Wilson334636c2016-11-29 12:10:20 +00002508 }
Dave Gordon8b417c22015-08-12 15:43:44 +01002509
Dave Gordon9636f6d2016-06-13 17:57:28 +01002510 seq_printf(m, "Doorbell map:\n");
Joonas Lahtinenabddffd2017-03-22 10:39:44 -07002511 seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap);
Chris Wilson334636c2016-11-29 12:10:20 +00002512 seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc->db_cacheline);
Dave Gordon9636f6d2016-06-13 17:57:28 +01002513
Chris Wilson334636c2016-11-29 12:10:20 +00002514 seq_printf(m, "GuC total action count: %llu\n", guc->action_count);
2515 seq_printf(m, "GuC action failure count: %u\n", guc->action_fail);
2516 seq_printf(m, "GuC last action command: 0x%x\n", guc->action_cmd);
2517 seq_printf(m, "GuC last action status: 0x%x\n", guc->action_status);
2518 seq_printf(m, "GuC last action error code: %d\n", guc->action_err);
Dave Gordon8b417c22015-08-12 15:43:44 +01002519
Chris Wilson334636c2016-11-29 12:10:20 +00002520 total = 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002521 seq_printf(m, "\nGuC submissions:\n");
Akash Goel3b3f1652016-10-13 22:44:48 +05302522 for_each_engine(engine, dev_priv, id) {
Chris Wilson334636c2016-11-29 12:10:20 +00002523 u64 submissions = guc->submissions[id];
Dave Gordonc18468c2016-08-09 15:19:22 +01002524 total += submissions;
Alex Dai397097b2016-01-23 11:58:14 -08002525 seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n",
Chris Wilson334636c2016-11-29 12:10:20 +00002526 engine->name, submissions, guc->last_seqno[id]);
Dave Gordon8b417c22015-08-12 15:43:44 +01002527 }
2528 seq_printf(m, "\t%s: %llu\n", "Total", total);
2529
Chris Wilson334636c2016-11-29 12:10:20 +00002530 seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client);
2531 i915_guc_client_info(m, dev_priv, guc->execbuf_client);
Dave Gordon8b417c22015-08-12 15:43:44 +01002532
Akash Goel5aa1ee42016-10-12 21:54:36 +05302533 i915_guc_log_info(m, dev_priv);
2534
Dave Gordon8b417c22015-08-12 15:43:44 +01002535 /* Add more as required ... */
2536
2537 return 0;
2538}
2539
Alex Dai4c7e77f2015-08-12 15:43:40 +01002540static int i915_guc_log_dump(struct seq_file *m, void *data)
2541{
David Weinehall36cdd012016-08-22 13:59:31 +03002542 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilson8b797af2016-08-15 10:48:51 +01002543 struct drm_i915_gem_object *obj;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002544 int i = 0, pg;
2545
Akash Goeld6b40b42016-10-12 21:54:29 +05302546 if (!dev_priv->guc.log.vma)
Alex Dai4c7e77f2015-08-12 15:43:40 +01002547 return 0;
2548
Akash Goeld6b40b42016-10-12 21:54:29 +05302549 obj = dev_priv->guc.log.vma->obj;
Chris Wilson8b797af2016-08-15 10:48:51 +01002550 for (pg = 0; pg < obj->base.size / PAGE_SIZE; pg++) {
2551 u32 *log = kmap_atomic(i915_gem_object_get_page(obj, pg));
Alex Dai4c7e77f2015-08-12 15:43:40 +01002552
2553 for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4)
2554 seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n",
2555 *(log + i), *(log + i + 1),
2556 *(log + i + 2), *(log + i + 3));
2557
2558 kunmap_atomic(log);
2559 }
2560
2561 seq_putc(m, '\n');
2562
2563 return 0;
2564}
2565
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302566static int i915_guc_log_control_get(void *data, u64 *val)
2567{
2568 struct drm_device *dev = data;
2569 struct drm_i915_private *dev_priv = to_i915(dev);
2570
2571 if (!dev_priv->guc.log.vma)
2572 return -EINVAL;
2573
2574 *val = i915.guc_log_level;
2575
2576 return 0;
2577}
2578
2579static int i915_guc_log_control_set(void *data, u64 val)
2580{
2581 struct drm_device *dev = data;
2582 struct drm_i915_private *dev_priv = to_i915(dev);
2583 int ret;
2584
2585 if (!dev_priv->guc.log.vma)
2586 return -EINVAL;
2587
2588 ret = mutex_lock_interruptible(&dev->struct_mutex);
2589 if (ret)
2590 return ret;
2591
2592 intel_runtime_pm_get(dev_priv);
2593 ret = i915_guc_log_control(dev_priv, val);
2594 intel_runtime_pm_put(dev_priv);
2595
2596 mutex_unlock(&dev->struct_mutex);
2597 return ret;
2598}
2599
2600DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops,
2601 i915_guc_log_control_get, i915_guc_log_control_set,
2602 "%lld\n");
2603
Chris Wilsonb86bef202017-01-16 13:06:21 +00002604static const char *psr2_live_status(u32 val)
2605{
2606 static const char * const live_status[] = {
2607 "IDLE",
2608 "CAPTURE",
2609 "CAPTURE_FS",
2610 "SLEEP",
2611 "BUFON_FW",
2612 "ML_UP",
2613 "SU_STANDBY",
2614 "FAST_SLEEP",
2615 "DEEP_SLEEP",
2616 "BUF_ON",
2617 "TG_ON"
2618 };
2619
2620 val = (val & EDP_PSR2_STATUS_STATE_MASK) >> EDP_PSR2_STATUS_STATE_SHIFT;
2621 if (val < ARRAY_SIZE(live_status))
2622 return live_status[val];
2623
2624 return "unknown";
2625}
2626
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002627static int i915_edp_psr_status(struct seq_file *m, void *data)
2628{
David Weinehall36cdd012016-08-22 13:59:31 +03002629 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002630 u32 psrperf = 0;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002631 u32 stat[3];
2632 enum pipe pipe;
Rodrigo Vivia031d702013-10-03 16:15:06 -03002633 bool enabled = false;
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002634
David Weinehall36cdd012016-08-22 13:59:31 +03002635 if (!HAS_PSR(dev_priv)) {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002636 seq_puts(m, "PSR not supported\n");
2637 return 0;
2638 }
2639
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002640 intel_runtime_pm_get(dev_priv);
2641
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002642 mutex_lock(&dev_priv->psr.lock);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002643 seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support));
2644 seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok));
Daniel Vetter2807cf62014-07-11 10:30:11 -07002645 seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled));
Rodrigo Vivi5755c782014-06-12 10:16:45 -07002646 seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002647 seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
2648 dev_priv->psr.busy_frontbuffer_bits);
2649 seq_printf(m, "Re-enable work scheduled: %s\n",
2650 yesno(work_busy(&dev_priv->psr.work.work)));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002651
Nagaraju, Vathsala7e3eb592016-12-09 23:42:09 +05302652 if (HAS_DDI(dev_priv)) {
2653 if (dev_priv->psr.psr2_support)
2654 enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE;
2655 else
2656 enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE;
2657 } else {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002658 for_each_pipe(dev_priv, pipe) {
Chris Wilson9c870d02016-10-24 13:42:15 +01002659 enum transcoder cpu_transcoder =
2660 intel_pipe_to_cpu_transcoder(dev_priv, pipe);
2661 enum intel_display_power_domain power_domain;
2662
2663 power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder);
2664 if (!intel_display_power_get_if_enabled(dev_priv,
2665 power_domain))
2666 continue;
2667
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002668 stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) &
2669 VLV_EDP_PSR_CURR_STATE_MASK;
2670 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2671 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2672 enabled = true;
Chris Wilson9c870d02016-10-24 13:42:15 +01002673
2674 intel_display_power_put(dev_priv, power_domain);
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002675 }
2676 }
Rodrigo Vivi60e5ffe2016-02-01 12:02:07 -08002677
2678 seq_printf(m, "Main link in standby mode: %s\n",
2679 yesno(dev_priv->psr.link_standby));
2680
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002681 seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002682
David Weinehall36cdd012016-08-22 13:59:31 +03002683 if (!HAS_DDI(dev_priv))
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002684 for_each_pipe(dev_priv, pipe) {
2685 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2686 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2687 seq_printf(m, " pipe %c", pipe_name(pipe));
2688 }
2689 seq_puts(m, "\n");
2690
Rodrigo Vivi05eec3c2015-11-23 14:16:40 -08002691 /*
2692 * VLV/CHV PSR has no kind of performance counter
2693 * SKL+ Perf counter is reset to 0 everytime DC state is entered
2694 */
David Weinehall36cdd012016-08-22 13:59:31 +03002695 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
Ville Syrjälä443a3892015-11-11 20:34:15 +02002696 psrperf = I915_READ(EDP_PSR_PERF_CNT) &
Rodrigo Vivia031d702013-10-03 16:15:06 -03002697 EDP_PSR_PERF_CNT_MASK;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002698
2699 seq_printf(m, "Performance_Counter: %u\n", psrperf);
2700 }
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302701 if (dev_priv->psr.psr2_support) {
Chris Wilsonb86bef202017-01-16 13:06:21 +00002702 u32 psr2 = I915_READ(EDP_PSR2_STATUS_CTL);
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302703
Chris Wilsonb86bef202017-01-16 13:06:21 +00002704 seq_printf(m, "EDP_PSR2_STATUS_CTL: %x [%s]\n",
2705 psr2, psr2_live_status(psr2));
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302706 }
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002707 mutex_unlock(&dev_priv->psr.lock);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002708
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002709 intel_runtime_pm_put(dev_priv);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002710 return 0;
2711}
2712
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002713static int i915_sink_crc(struct seq_file *m, void *data)
2714{
David Weinehall36cdd012016-08-22 13:59:31 +03002715 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2716 struct drm_device *dev = &dev_priv->drm;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002717 struct intel_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01002718 struct drm_connector_list_iter conn_iter;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002719 struct intel_dp *intel_dp = NULL;
2720 int ret;
2721 u8 crc[6];
2722
2723 drm_modeset_lock_all(dev);
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01002724 drm_connector_list_iter_begin(dev, &conn_iter);
2725 for_each_intel_connector_iter(connector, &conn_iter) {
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002726 struct drm_crtc *crtc;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002727
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002728 if (!connector->base.state->best_encoder)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002729 continue;
2730
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002731 crtc = connector->base.state->crtc;
2732 if (!crtc->state->active)
Paulo Zanonib6ae3c72014-02-13 17:51:33 -02002733 continue;
2734
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002735 if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002736 continue;
2737
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002738 intel_dp = enc_to_intel_dp(connector->base.state->best_encoder);
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002739
2740 ret = intel_dp_sink_crc(intel_dp, crc);
2741 if (ret)
2742 goto out;
2743
2744 seq_printf(m, "%02x%02x%02x%02x%02x%02x\n",
2745 crc[0], crc[1], crc[2],
2746 crc[3], crc[4], crc[5]);
2747 goto out;
2748 }
2749 ret = -ENODEV;
2750out:
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01002751 drm_connector_list_iter_end(&conn_iter);
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002752 drm_modeset_unlock_all(dev);
2753 return ret;
2754}
2755
Jesse Barnesec013e72013-08-20 10:29:23 +01002756static int i915_energy_uJ(struct seq_file *m, void *data)
2757{
David Weinehall36cdd012016-08-22 13:59:31 +03002758 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnesec013e72013-08-20 10:29:23 +01002759 u64 power;
2760 u32 units;
2761
David Weinehall36cdd012016-08-22 13:59:31 +03002762 if (INTEL_GEN(dev_priv) < 6)
Jesse Barnesec013e72013-08-20 10:29:23 +01002763 return -ENODEV;
2764
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002765 intel_runtime_pm_get(dev_priv);
2766
Jesse Barnesec013e72013-08-20 10:29:23 +01002767 rdmsrl(MSR_RAPL_POWER_UNIT, power);
2768 power = (power & 0x1f00) >> 8;
2769 units = 1000000 / (1 << power); /* convert to uJ */
2770 power = I915_READ(MCH_SECP_NRG_STTS);
2771 power *= units;
2772
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002773 intel_runtime_pm_put(dev_priv);
2774
Jesse Barnesec013e72013-08-20 10:29:23 +01002775 seq_printf(m, "%llu", (long long unsigned)power);
Paulo Zanoni371db662013-08-19 13:18:10 -03002776
2777 return 0;
2778}
2779
Damien Lespiau6455c872015-06-04 18:23:57 +01002780static int i915_runtime_pm_status(struct seq_file *m, void *unused)
Paulo Zanoni371db662013-08-19 13:18:10 -03002781{
David Weinehall36cdd012016-08-22 13:59:31 +03002782 struct drm_i915_private *dev_priv = node_to_i915(m->private);
David Weinehall52a05c32016-08-22 13:32:44 +03002783 struct pci_dev *pdev = dev_priv->drm.pdev;
Paulo Zanoni371db662013-08-19 13:18:10 -03002784
Chris Wilsona156e642016-04-03 14:14:21 +01002785 if (!HAS_RUNTIME_PM(dev_priv))
2786 seq_puts(m, "Runtime power management not supported\n");
Paulo Zanoni371db662013-08-19 13:18:10 -03002787
Chris Wilson67d97da2016-07-04 08:08:31 +01002788 seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake));
Paulo Zanoni371db662013-08-19 13:18:10 -03002789 seq_printf(m, "IRQs disabled: %s\n",
Jesse Barnes9df7575f2014-06-20 09:29:20 -07002790 yesno(!intel_irqs_enabled(dev_priv)));
Chris Wilson0d804182015-06-15 12:52:28 +01002791#ifdef CONFIG_PM
Damien Lespiaua6aaec82015-06-04 18:23:58 +01002792 seq_printf(m, "Usage count: %d\n",
David Weinehall36cdd012016-08-22 13:59:31 +03002793 atomic_read(&dev_priv->drm.dev->power.usage_count));
Chris Wilson0d804182015-06-15 12:52:28 +01002794#else
2795 seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n");
2796#endif
Chris Wilsona156e642016-04-03 14:14:21 +01002797 seq_printf(m, "PCI device power state: %s [%d]\n",
David Weinehall52a05c32016-08-22 13:32:44 +03002798 pci_power_name(pdev->current_state),
2799 pdev->current_state);
Paulo Zanoni371db662013-08-19 13:18:10 -03002800
Jesse Barnesec013e72013-08-20 10:29:23 +01002801 return 0;
2802}
2803
Imre Deak1da51582013-11-25 17:15:35 +02002804static int i915_power_domain_info(struct seq_file *m, void *unused)
2805{
David Weinehall36cdd012016-08-22 13:59:31 +03002806 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak1da51582013-11-25 17:15:35 +02002807 struct i915_power_domains *power_domains = &dev_priv->power_domains;
2808 int i;
2809
2810 mutex_lock(&power_domains->lock);
2811
2812 seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count");
2813 for (i = 0; i < power_domains->power_well_count; i++) {
2814 struct i915_power_well *power_well;
2815 enum intel_display_power_domain power_domain;
2816
2817 power_well = &power_domains->power_wells[i];
2818 seq_printf(m, "%-25s %d\n", power_well->name,
2819 power_well->count);
2820
Joonas Lahtinen8385c2e2017-02-08 15:12:10 +02002821 for_each_power_domain(power_domain, power_well->domains)
Imre Deak1da51582013-11-25 17:15:35 +02002822 seq_printf(m, " %-23s %d\n",
Daniel Stone9895ad02015-11-20 15:55:33 +00002823 intel_display_power_domain_str(power_domain),
Imre Deak1da51582013-11-25 17:15:35 +02002824 power_domains->domain_use_count[power_domain]);
Imre Deak1da51582013-11-25 17:15:35 +02002825 }
2826
2827 mutex_unlock(&power_domains->lock);
2828
2829 return 0;
2830}
2831
Damien Lespiaub7cec662015-10-27 14:47:01 +02002832static int i915_dmc_info(struct seq_file *m, void *unused)
2833{
David Weinehall36cdd012016-08-22 13:59:31 +03002834 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Damien Lespiaub7cec662015-10-27 14:47:01 +02002835 struct intel_csr *csr;
2836
David Weinehall36cdd012016-08-22 13:59:31 +03002837 if (!HAS_CSR(dev_priv)) {
Damien Lespiaub7cec662015-10-27 14:47:01 +02002838 seq_puts(m, "not supported\n");
2839 return 0;
2840 }
2841
2842 csr = &dev_priv->csr;
2843
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002844 intel_runtime_pm_get(dev_priv);
2845
Damien Lespiaub7cec662015-10-27 14:47:01 +02002846 seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL));
2847 seq_printf(m, "path: %s\n", csr->fw_path);
2848
2849 if (!csr->dmc_payload)
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002850 goto out;
Damien Lespiaub7cec662015-10-27 14:47:01 +02002851
2852 seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version),
2853 CSR_VERSION_MINOR(csr->version));
2854
David Weinehall36cdd012016-08-22 13:59:31 +03002855 if (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6)) {
Damien Lespiau83372062015-10-30 17:53:32 +02002856 seq_printf(m, "DC3 -> DC5 count: %d\n",
2857 I915_READ(SKL_CSR_DC3_DC5_COUNT));
2858 seq_printf(m, "DC5 -> DC6 count: %d\n",
2859 I915_READ(SKL_CSR_DC5_DC6_COUNT));
David Weinehall36cdd012016-08-22 13:59:31 +03002860 } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) {
Mika Kuoppala16e11b92015-10-27 14:47:03 +02002861 seq_printf(m, "DC3 -> DC5 count: %d\n",
2862 I915_READ(BXT_CSR_DC3_DC5_COUNT));
Damien Lespiau83372062015-10-30 17:53:32 +02002863 }
2864
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002865out:
2866 seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0)));
2867 seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE));
2868 seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL));
2869
Damien Lespiau83372062015-10-30 17:53:32 +02002870 intel_runtime_pm_put(dev_priv);
2871
Damien Lespiaub7cec662015-10-27 14:47:01 +02002872 return 0;
2873}
2874
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002875static void intel_seq_print_mode(struct seq_file *m, int tabs,
2876 struct drm_display_mode *mode)
2877{
2878 int i;
2879
2880 for (i = 0; i < tabs; i++)
2881 seq_putc(m, '\t');
2882
2883 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",
2884 mode->base.id, mode->name,
2885 mode->vrefresh, mode->clock,
2886 mode->hdisplay, mode->hsync_start,
2887 mode->hsync_end, mode->htotal,
2888 mode->vdisplay, mode->vsync_start,
2889 mode->vsync_end, mode->vtotal,
2890 mode->type, mode->flags);
2891}
2892
2893static void intel_encoder_info(struct seq_file *m,
2894 struct intel_crtc *intel_crtc,
2895 struct intel_encoder *intel_encoder)
2896{
David Weinehall36cdd012016-08-22 13:59:31 +03002897 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2898 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002899 struct drm_crtc *crtc = &intel_crtc->base;
2900 struct intel_connector *intel_connector;
2901 struct drm_encoder *encoder;
2902
2903 encoder = &intel_encoder->base;
2904 seq_printf(m, "\tencoder %d: type: %s, connectors:\n",
Jani Nikula8e329a032014-06-03 14:56:21 +03002905 encoder->base.id, encoder->name);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002906 for_each_connector_on_encoder(dev, encoder, intel_connector) {
2907 struct drm_connector *connector = &intel_connector->base;
2908 seq_printf(m, "\t\tconnector %d: type: %s, status: %s",
2909 connector->base.id,
Jani Nikulac23cc412014-06-03 14:56:17 +03002910 connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002911 drm_get_connector_status_name(connector->status));
2912 if (connector->status == connector_status_connected) {
2913 struct drm_display_mode *mode = &crtc->mode;
2914 seq_printf(m, ", mode:\n");
2915 intel_seq_print_mode(m, 2, mode);
2916 } else {
2917 seq_putc(m, '\n');
2918 }
2919 }
2920}
2921
2922static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc)
2923{
David Weinehall36cdd012016-08-22 13:59:31 +03002924 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2925 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002926 struct drm_crtc *crtc = &intel_crtc->base;
2927 struct intel_encoder *intel_encoder;
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002928 struct drm_plane_state *plane_state = crtc->primary->state;
2929 struct drm_framebuffer *fb = plane_state->fb;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002930
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002931 if (fb)
Matt Roper5aa8a932014-06-16 10:12:55 -07002932 seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n",
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002933 fb->base.id, plane_state->src_x >> 16,
2934 plane_state->src_y >> 16, fb->width, fb->height);
Matt Roper5aa8a932014-06-16 10:12:55 -07002935 else
2936 seq_puts(m, "\tprimary plane disabled\n");
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002937 for_each_encoder_on_crtc(dev, crtc, intel_encoder)
2938 intel_encoder_info(m, intel_crtc, intel_encoder);
2939}
2940
2941static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
2942{
2943 struct drm_display_mode *mode = panel->fixed_mode;
2944
2945 seq_printf(m, "\tfixed mode:\n");
2946 intel_seq_print_mode(m, 2, mode);
2947}
2948
2949static void intel_dp_info(struct seq_file *m,
2950 struct intel_connector *intel_connector)
2951{
2952 struct intel_encoder *intel_encoder = intel_connector->encoder;
2953 struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
2954
2955 seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]);
Jani Nikula742f4912015-09-03 11:16:09 +03002956 seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio));
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02002957 if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002958 intel_panel_info(m, &intel_connector->panel);
Mika Kahola80209e52016-09-09 14:10:57 +03002959
2960 drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports,
2961 &intel_dp->aux);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002962}
2963
Libin Yang9a148a92016-11-28 20:07:05 +08002964static void intel_dp_mst_info(struct seq_file *m,
2965 struct intel_connector *intel_connector)
2966{
2967 struct intel_encoder *intel_encoder = intel_connector->encoder;
2968 struct intel_dp_mst_encoder *intel_mst =
2969 enc_to_mst(&intel_encoder->base);
2970 struct intel_digital_port *intel_dig_port = intel_mst->primary;
2971 struct intel_dp *intel_dp = &intel_dig_port->dp;
2972 bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr,
2973 intel_connector->port);
2974
2975 seq_printf(m, "\taudio support: %s\n", yesno(has_audio));
2976}
2977
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002978static void intel_hdmi_info(struct seq_file *m,
2979 struct intel_connector *intel_connector)
2980{
2981 struct intel_encoder *intel_encoder = intel_connector->encoder;
2982 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
2983
Jani Nikula742f4912015-09-03 11:16:09 +03002984 seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio));
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002985}
2986
2987static void intel_lvds_info(struct seq_file *m,
2988 struct intel_connector *intel_connector)
2989{
2990 intel_panel_info(m, &intel_connector->panel);
2991}
2992
2993static void intel_connector_info(struct seq_file *m,
2994 struct drm_connector *connector)
2995{
2996 struct intel_connector *intel_connector = to_intel_connector(connector);
2997 struct intel_encoder *intel_encoder = intel_connector->encoder;
Jesse Barnesf103fc72014-02-20 12:39:57 -08002998 struct drm_display_mode *mode;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002999
3000 seq_printf(m, "connector %d: type %s, status: %s\n",
Jani Nikulac23cc412014-06-03 14:56:17 +03003001 connector->base.id, connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003002 drm_get_connector_status_name(connector->status));
3003 if (connector->status == connector_status_connected) {
3004 seq_printf(m, "\tname: %s\n", connector->display_info.name);
3005 seq_printf(m, "\tphysical dimensions: %dx%dmm\n",
3006 connector->display_info.width_mm,
3007 connector->display_info.height_mm);
3008 seq_printf(m, "\tsubpixel order: %s\n",
3009 drm_get_subpixel_order_name(connector->display_info.subpixel_order));
3010 seq_printf(m, "\tCEA rev: %d\n",
3011 connector->display_info.cea_rev);
3012 }
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003013
3014 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
3015 return;
3016
3017 switch (connector->connector_type) {
3018 case DRM_MODE_CONNECTOR_DisplayPort:
3019 case DRM_MODE_CONNECTOR_eDP:
Libin Yang9a148a92016-11-28 20:07:05 +08003020 if (intel_encoder->type == INTEL_OUTPUT_DP_MST)
3021 intel_dp_mst_info(m, intel_connector);
3022 else
3023 intel_dp_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003024 break;
3025 case DRM_MODE_CONNECTOR_LVDS:
3026 if (intel_encoder->type == INTEL_OUTPUT_LVDS)
Dave Airlie36cd7442014-05-02 13:44:18 +10003027 intel_lvds_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003028 break;
3029 case DRM_MODE_CONNECTOR_HDMIA:
3030 if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
3031 intel_encoder->type == INTEL_OUTPUT_UNKNOWN)
3032 intel_hdmi_info(m, intel_connector);
3033 break;
3034 default:
3035 break;
Dave Airlie36cd7442014-05-02 13:44:18 +10003036 }
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003037
Jesse Barnesf103fc72014-02-20 12:39:57 -08003038 seq_printf(m, "\tmodes:\n");
3039 list_for_each_entry(mode, &connector->modes, head)
3040 intel_seq_print_mode(m, 2, mode);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003041}
3042
David Weinehall36cdd012016-08-22 13:59:31 +03003043static bool cursor_active(struct drm_i915_private *dev_priv, int pipe)
Chris Wilson065f2ec2014-03-12 09:13:13 +00003044{
Chris Wilson065f2ec2014-03-12 09:13:13 +00003045 u32 state;
3046
Jani Nikula2a307c22016-11-30 17:43:04 +02003047 if (IS_I845G(dev_priv) || IS_I865G(dev_priv))
Ville Syrjälä0b87c242015-09-22 19:47:51 +03003048 state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003049 else
Ville Syrjälä5efb3e22014-04-09 13:28:53 +03003050 state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003051
3052 return state;
3053}
3054
David Weinehall36cdd012016-08-22 13:59:31 +03003055static bool cursor_position(struct drm_i915_private *dev_priv,
3056 int pipe, int *x, int *y)
Chris Wilson065f2ec2014-03-12 09:13:13 +00003057{
Chris Wilson065f2ec2014-03-12 09:13:13 +00003058 u32 pos;
3059
Ville Syrjälä5efb3e22014-04-09 13:28:53 +03003060 pos = I915_READ(CURPOS(pipe));
Chris Wilson065f2ec2014-03-12 09:13:13 +00003061
3062 *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK;
3063 if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT))
3064 *x = -*x;
3065
3066 *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK;
3067 if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT))
3068 *y = -*y;
3069
David Weinehall36cdd012016-08-22 13:59:31 +03003070 return cursor_active(dev_priv, pipe);
Chris Wilson065f2ec2014-03-12 09:13:13 +00003071}
3072
Robert Fekete3abc4e02015-10-27 16:58:32 +01003073static const char *plane_type(enum drm_plane_type type)
3074{
3075 switch (type) {
3076 case DRM_PLANE_TYPE_OVERLAY:
3077 return "OVL";
3078 case DRM_PLANE_TYPE_PRIMARY:
3079 return "PRI";
3080 case DRM_PLANE_TYPE_CURSOR:
3081 return "CUR";
3082 /*
3083 * Deliberately omitting default: to generate compiler warnings
3084 * when a new drm_plane_type gets added.
3085 */
3086 }
3087
3088 return "unknown";
3089}
3090
3091static const char *plane_rotation(unsigned int rotation)
3092{
3093 static char buf[48];
3094 /*
3095 * According to doc only one DRM_ROTATE_ is allowed but this
3096 * will print them all to visualize if the values are misused
3097 */
3098 snprintf(buf, sizeof(buf),
3099 "%s%s%s%s%s%s(0x%08x)",
Joonas Lahtinen31ad61e2016-07-29 08:50:05 +03003100 (rotation & DRM_ROTATE_0) ? "0 " : "",
3101 (rotation & DRM_ROTATE_90) ? "90 " : "",
3102 (rotation & DRM_ROTATE_180) ? "180 " : "",
3103 (rotation & DRM_ROTATE_270) ? "270 " : "",
3104 (rotation & DRM_REFLECT_X) ? "FLIPX " : "",
3105 (rotation & DRM_REFLECT_Y) ? "FLIPY " : "",
Robert Fekete3abc4e02015-10-27 16:58:32 +01003106 rotation);
3107
3108 return buf;
3109}
3110
3111static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3112{
David Weinehall36cdd012016-08-22 13:59:31 +03003113 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3114 struct drm_device *dev = &dev_priv->drm;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003115 struct intel_plane *intel_plane;
3116
3117 for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
3118 struct drm_plane_state *state;
3119 struct drm_plane *plane = &intel_plane->base;
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003120 struct drm_format_name_buf format_name;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003121
3122 if (!plane->state) {
3123 seq_puts(m, "plane->state is NULL!\n");
3124 continue;
3125 }
3126
3127 state = plane->state;
3128
Eric Engestrom90844f02016-08-15 01:02:38 +01003129 if (state->fb) {
Ville Syrjälä438b74a2016-12-14 23:32:55 +02003130 drm_get_format_name(state->fb->format->format,
3131 &format_name);
Eric Engestrom90844f02016-08-15 01:02:38 +01003132 } else {
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003133 sprintf(format_name.str, "N/A");
Eric Engestrom90844f02016-08-15 01:02:38 +01003134 }
3135
Robert Fekete3abc4e02015-10-27 16:58:32 +01003136 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",
3137 plane->base.id,
3138 plane_type(intel_plane->base.type),
3139 state->crtc_x, state->crtc_y,
3140 state->crtc_w, state->crtc_h,
3141 (state->src_x >> 16),
3142 ((state->src_x & 0xffff) * 15625) >> 10,
3143 (state->src_y >> 16),
3144 ((state->src_y & 0xffff) * 15625) >> 10,
3145 (state->src_w >> 16),
3146 ((state->src_w & 0xffff) * 15625) >> 10,
3147 (state->src_h >> 16),
3148 ((state->src_h & 0xffff) * 15625) >> 10,
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003149 format_name.str,
Robert Fekete3abc4e02015-10-27 16:58:32 +01003150 plane_rotation(state->rotation));
3151 }
3152}
3153
3154static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3155{
3156 struct intel_crtc_state *pipe_config;
3157 int num_scalers = intel_crtc->num_scalers;
3158 int i;
3159
3160 pipe_config = to_intel_crtc_state(intel_crtc->base.state);
3161
3162 /* Not all platformas have a scaler */
3163 if (num_scalers) {
3164 seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d",
3165 num_scalers,
3166 pipe_config->scaler_state.scaler_users,
3167 pipe_config->scaler_state.scaler_id);
3168
A.Sunil Kamath58415912016-11-20 23:20:26 +05303169 for (i = 0; i < num_scalers; i++) {
Robert Fekete3abc4e02015-10-27 16:58:32 +01003170 struct intel_scaler *sc =
3171 &pipe_config->scaler_state.scalers[i];
3172
3173 seq_printf(m, ", scalers[%d]: use=%s, mode=%x",
3174 i, yesno(sc->in_use), sc->mode);
3175 }
3176 seq_puts(m, "\n");
3177 } else {
3178 seq_puts(m, "\tNo scalers available on this platform\n");
3179 }
3180}
3181
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003182static int i915_display_info(struct seq_file *m, void *unused)
3183{
David Weinehall36cdd012016-08-22 13:59:31 +03003184 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3185 struct drm_device *dev = &dev_priv->drm;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003186 struct intel_crtc *crtc;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003187 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003188 struct drm_connector_list_iter conn_iter;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003189
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003190 intel_runtime_pm_get(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003191 seq_printf(m, "CRTC info\n");
3192 seq_printf(m, "---------\n");
Damien Lespiaud3fcc802014-05-13 23:32:22 +01003193 for_each_intel_crtc(dev, crtc) {
Chris Wilson065f2ec2014-03-12 09:13:13 +00003194 bool active;
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003195 struct intel_crtc_state *pipe_config;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003196 int x, y;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003197
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003198 drm_modeset_lock(&crtc->base.mutex, NULL);
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003199 pipe_config = to_intel_crtc_state(crtc->base.state);
3200
Robert Fekete3abc4e02015-10-27 16:58:32 +01003201 seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n",
Chris Wilson065f2ec2014-03-12 09:13:13 +00003202 crtc->base.base.id, pipe_name(crtc->pipe),
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003203 yesno(pipe_config->base.active),
Robert Fekete3abc4e02015-10-27 16:58:32 +01003204 pipe_config->pipe_src_w, pipe_config->pipe_src_h,
3205 yesno(pipe_config->dither), pipe_config->pipe_bpp);
3206
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003207 if (pipe_config->base.active) {
Chris Wilson065f2ec2014-03-12 09:13:13 +00003208 intel_crtc_info(m, crtc);
3209
David Weinehall36cdd012016-08-22 13:59:31 +03003210 active = cursor_position(dev_priv, crtc->pipe, &x, &y);
Chris Wilson57127ef2014-07-04 08:20:11 +01003211 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 +03003212 yesno(crtc->cursor_base),
Matt Roper3dd512f2015-02-27 10:12:00 -08003213 x, y, crtc->base.cursor->state->crtc_w,
3214 crtc->base.cursor->state->crtc_h,
Chris Wilson57127ef2014-07-04 08:20:11 +01003215 crtc->cursor_addr, yesno(active));
Robert Fekete3abc4e02015-10-27 16:58:32 +01003216 intel_scaler_info(m, crtc);
3217 intel_plane_info(m, crtc);
Paulo Zanonia23dc652014-04-01 14:55:11 -03003218 }
Daniel Vettercace8412014-05-22 17:56:31 +02003219
3220 seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n",
3221 yesno(!crtc->cpu_fifo_underrun_disabled),
3222 yesno(!crtc->pch_fifo_underrun_disabled));
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003223 drm_modeset_unlock(&crtc->base.mutex);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003224 }
3225
3226 seq_printf(m, "\n");
3227 seq_printf(m, "Connector info\n");
3228 seq_printf(m, "--------------\n");
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003229 mutex_lock(&dev->mode_config.mutex);
3230 drm_connector_list_iter_begin(dev, &conn_iter);
3231 drm_for_each_connector_iter(connector, &conn_iter)
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003232 intel_connector_info(m, connector);
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003233 drm_connector_list_iter_end(&conn_iter);
3234 mutex_unlock(&dev->mode_config.mutex);
3235
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003236 intel_runtime_pm_put(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003237
3238 return 0;
3239}
3240
Chris Wilson1b365952016-10-04 21:11:31 +01003241static int i915_engine_info(struct seq_file *m, void *unused)
3242{
3243 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3244 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05303245 enum intel_engine_id id;
Chris Wilson1b365952016-10-04 21:11:31 +01003246
Chris Wilson9c870d02016-10-24 13:42:15 +01003247 intel_runtime_pm_get(dev_priv);
3248
Chris Wilsonf73b5672017-03-02 15:03:56 +00003249 seq_printf(m, "GT awake? %s\n",
3250 yesno(dev_priv->gt.awake));
3251 seq_printf(m, "Global active requests: %d\n",
3252 dev_priv->gt.active_requests);
3253
Akash Goel3b3f1652016-10-13 22:44:48 +05303254 for_each_engine(engine, dev_priv, id) {
Chris Wilson1b365952016-10-04 21:11:31 +01003255 struct intel_breadcrumbs *b = &engine->breadcrumbs;
3256 struct drm_i915_gem_request *rq;
3257 struct rb_node *rb;
3258 u64 addr;
3259
3260 seq_printf(m, "%s\n", engine->name);
Chris Wilsonf73b5672017-03-02 15:03:56 +00003261 seq_printf(m, "\tcurrent seqno %x, last %x, hangcheck %x [%d ms], inflight %d\n",
Chris Wilson1b365952016-10-04 21:11:31 +01003262 intel_engine_get_seqno(engine),
Chris Wilsoncb399ea2016-11-01 10:03:16 +00003263 intel_engine_last_submit(engine),
Chris Wilson1b365952016-10-04 21:11:31 +01003264 engine->hangcheck.seqno,
Chris Wilsonf73b5672017-03-02 15:03:56 +00003265 jiffies_to_msecs(jiffies - engine->hangcheck.action_timestamp),
3266 engine->timeline->inflight_seqnos);
Chris Wilson1b365952016-10-04 21:11:31 +01003267
3268 rcu_read_lock();
3269
3270 seq_printf(m, "\tRequests:\n");
3271
Chris Wilson73cb9702016-10-28 13:58:46 +01003272 rq = list_first_entry(&engine->timeline->requests,
3273 struct drm_i915_gem_request, link);
3274 if (&rq->link != &engine->timeline->requests)
Chris Wilson1b365952016-10-04 21:11:31 +01003275 print_request(m, rq, "\t\tfirst ");
3276
Chris Wilson73cb9702016-10-28 13:58:46 +01003277 rq = list_last_entry(&engine->timeline->requests,
3278 struct drm_i915_gem_request, link);
3279 if (&rq->link != &engine->timeline->requests)
Chris Wilson1b365952016-10-04 21:11:31 +01003280 print_request(m, rq, "\t\tlast ");
3281
3282 rq = i915_gem_find_active_request(engine);
3283 if (rq) {
3284 print_request(m, rq, "\t\tactive ");
3285 seq_printf(m,
3286 "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n",
3287 rq->head, rq->postfix, rq->tail,
3288 rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u,
3289 rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u);
3290 }
3291
3292 seq_printf(m, "\tRING_START: 0x%08x [0x%08x]\n",
3293 I915_READ(RING_START(engine->mmio_base)),
3294 rq ? i915_ggtt_offset(rq->ring->vma) : 0);
3295 seq_printf(m, "\tRING_HEAD: 0x%08x [0x%08x]\n",
3296 I915_READ(RING_HEAD(engine->mmio_base)) & HEAD_ADDR,
3297 rq ? rq->ring->head : 0);
3298 seq_printf(m, "\tRING_TAIL: 0x%08x [0x%08x]\n",
3299 I915_READ(RING_TAIL(engine->mmio_base)) & TAIL_ADDR,
3300 rq ? rq->ring->tail : 0);
3301 seq_printf(m, "\tRING_CTL: 0x%08x [%s]\n",
3302 I915_READ(RING_CTL(engine->mmio_base)),
3303 I915_READ(RING_CTL(engine->mmio_base)) & (RING_WAIT | RING_WAIT_SEMAPHORE) ? "waiting" : "");
3304
3305 rcu_read_unlock();
3306
3307 addr = intel_engine_get_active_head(engine);
3308 seq_printf(m, "\tACTHD: 0x%08x_%08x\n",
3309 upper_32_bits(addr), lower_32_bits(addr));
3310 addr = intel_engine_get_last_batch_head(engine);
3311 seq_printf(m, "\tBBADDR: 0x%08x_%08x\n",
3312 upper_32_bits(addr), lower_32_bits(addr));
3313
3314 if (i915.enable_execlists) {
3315 u32 ptr, read, write;
Chris Wilson20311bd2016-11-14 20:41:03 +00003316 struct rb_node *rb;
Chris Wilson1b365952016-10-04 21:11:31 +01003317
3318 seq_printf(m, "\tExeclist status: 0x%08x %08x\n",
3319 I915_READ(RING_EXECLIST_STATUS_LO(engine)),
3320 I915_READ(RING_EXECLIST_STATUS_HI(engine)));
3321
3322 ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine));
3323 read = GEN8_CSB_READ_PTR(ptr);
3324 write = GEN8_CSB_WRITE_PTR(ptr);
3325 seq_printf(m, "\tExeclist CSB read %d, write %d\n",
3326 read, write);
3327 if (read >= GEN8_CSB_ENTRIES)
3328 read = 0;
3329 if (write >= GEN8_CSB_ENTRIES)
3330 write = 0;
3331 if (read > write)
3332 write += GEN8_CSB_ENTRIES;
3333 while (read < write) {
3334 unsigned int idx = ++read % GEN8_CSB_ENTRIES;
3335
3336 seq_printf(m, "\tExeclist CSB[%d]: 0x%08x, context: %d\n",
3337 idx,
3338 I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, idx)),
3339 I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, idx)));
3340 }
3341
3342 rcu_read_lock();
3343 rq = READ_ONCE(engine->execlist_port[0].request);
Chris Wilson816ee792017-01-24 11:00:03 +00003344 if (rq) {
3345 seq_printf(m, "\t\tELSP[0] count=%d, ",
3346 engine->execlist_port[0].count);
3347 print_request(m, rq, "rq: ");
3348 } else {
Chris Wilson1b365952016-10-04 21:11:31 +01003349 seq_printf(m, "\t\tELSP[0] idle\n");
Chris Wilson816ee792017-01-24 11:00:03 +00003350 }
Chris Wilson1b365952016-10-04 21:11:31 +01003351 rq = READ_ONCE(engine->execlist_port[1].request);
Chris Wilson816ee792017-01-24 11:00:03 +00003352 if (rq) {
3353 seq_printf(m, "\t\tELSP[1] count=%d, ",
3354 engine->execlist_port[1].count);
3355 print_request(m, rq, "rq: ");
3356 } else {
Chris Wilson1b365952016-10-04 21:11:31 +01003357 seq_printf(m, "\t\tELSP[1] idle\n");
Chris Wilson816ee792017-01-24 11:00:03 +00003358 }
Chris Wilson1b365952016-10-04 21:11:31 +01003359 rcu_read_unlock();
Chris Wilsonc8247c02016-10-27 01:03:43 +01003360
Chris Wilson663f71e2016-11-14 20:41:00 +00003361 spin_lock_irq(&engine->timeline->lock);
Chris Wilson20311bd2016-11-14 20:41:03 +00003362 for (rb = engine->execlist_first; rb; rb = rb_next(rb)) {
3363 rq = rb_entry(rb, typeof(*rq), priotree.node);
Chris Wilsonc8247c02016-10-27 01:03:43 +01003364 print_request(m, rq, "\t\tQ ");
3365 }
Chris Wilson663f71e2016-11-14 20:41:00 +00003366 spin_unlock_irq(&engine->timeline->lock);
Chris Wilson1b365952016-10-04 21:11:31 +01003367 } else if (INTEL_GEN(dev_priv) > 6) {
3368 seq_printf(m, "\tPP_DIR_BASE: 0x%08x\n",
3369 I915_READ(RING_PP_DIR_BASE(engine)));
3370 seq_printf(m, "\tPP_DIR_BASE_READ: 0x%08x\n",
3371 I915_READ(RING_PP_DIR_BASE_READ(engine)));
3372 seq_printf(m, "\tPP_DIR_DCLV: 0x%08x\n",
3373 I915_READ(RING_PP_DIR_DCLV(engine)));
3374 }
3375
Chris Wilson61d3dc72017-03-03 19:08:24 +00003376 spin_lock_irq(&b->rb_lock);
Chris Wilson1b365952016-10-04 21:11:31 +01003377 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +08003378 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson1b365952016-10-04 21:11:31 +01003379
3380 seq_printf(m, "\t%s [%d] waiting for %x\n",
3381 w->tsk->comm, w->tsk->pid, w->seqno);
3382 }
Chris Wilson61d3dc72017-03-03 19:08:24 +00003383 spin_unlock_irq(&b->rb_lock);
Chris Wilson1b365952016-10-04 21:11:31 +01003384
3385 seq_puts(m, "\n");
3386 }
3387
Chris Wilson9c870d02016-10-24 13:42:15 +01003388 intel_runtime_pm_put(dev_priv);
3389
Chris Wilson1b365952016-10-04 21:11:31 +01003390 return 0;
3391}
3392
Ben Widawskye04934c2014-06-30 09:53:42 -07003393static int i915_semaphore_status(struct seq_file *m, void *unused)
3394{
David Weinehall36cdd012016-08-22 13:59:31 +03003395 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3396 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003397 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003398 int num_rings = INTEL_INFO(dev_priv)->num_rings;
Dave Gordonc3232b12016-03-23 18:19:53 +00003399 enum intel_engine_id id;
3400 int j, ret;
Ben Widawskye04934c2014-06-30 09:53:42 -07003401
Chris Wilson39df9192016-07-20 13:31:57 +01003402 if (!i915.semaphores) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003403 seq_puts(m, "Semaphores are disabled\n");
3404 return 0;
3405 }
3406
3407 ret = mutex_lock_interruptible(&dev->struct_mutex);
3408 if (ret)
3409 return ret;
Paulo Zanoni03872062014-07-09 14:31:57 -03003410 intel_runtime_pm_get(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003411
David Weinehall36cdd012016-08-22 13:59:31 +03003412 if (IS_BROADWELL(dev_priv)) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003413 struct page *page;
3414 uint64_t *seqno;
3415
Chris Wilson51d545d2016-08-15 10:49:02 +01003416 page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0);
Ben Widawskye04934c2014-06-30 09:53:42 -07003417
3418 seqno = (uint64_t *)kmap_atomic(page);
Akash Goel3b3f1652016-10-13 22:44:48 +05303419 for_each_engine(engine, dev_priv, id) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003420 uint64_t offset;
3421
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003422 seq_printf(m, "%s\n", engine->name);
Ben Widawskye04934c2014-06-30 09:53:42 -07003423
3424 seq_puts(m, " Last signal:");
3425 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003426 offset = id * I915_NUM_ENGINES + j;
Ben Widawskye04934c2014-06-30 09:53:42 -07003427 seq_printf(m, "0x%08llx (0x%02llx) ",
3428 seqno[offset], offset * 8);
3429 }
3430 seq_putc(m, '\n');
3431
3432 seq_puts(m, " Last wait: ");
3433 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003434 offset = id + (j * I915_NUM_ENGINES);
Ben Widawskye04934c2014-06-30 09:53:42 -07003435 seq_printf(m, "0x%08llx (0x%02llx) ",
3436 seqno[offset], offset * 8);
3437 }
3438 seq_putc(m, '\n');
3439
3440 }
3441 kunmap_atomic(seqno);
3442 } else {
3443 seq_puts(m, " Last signal:");
Akash Goel3b3f1652016-10-13 22:44:48 +05303444 for_each_engine(engine, dev_priv, id)
Ben Widawskye04934c2014-06-30 09:53:42 -07003445 for (j = 0; j < num_rings; j++)
3446 seq_printf(m, "0x%08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003447 I915_READ(engine->semaphore.mbox.signal[j]));
Ben Widawskye04934c2014-06-30 09:53:42 -07003448 seq_putc(m, '\n');
3449 }
3450
Paulo Zanoni03872062014-07-09 14:31:57 -03003451 intel_runtime_pm_put(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003452 mutex_unlock(&dev->struct_mutex);
3453 return 0;
3454}
3455
Daniel Vetter728e29d2014-06-25 22:01:53 +03003456static int i915_shared_dplls_info(struct seq_file *m, void *unused)
3457{
David Weinehall36cdd012016-08-22 13:59:31 +03003458 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3459 struct drm_device *dev = &dev_priv->drm;
Daniel Vetter728e29d2014-06-25 22:01:53 +03003460 int i;
3461
3462 drm_modeset_lock_all(dev);
3463 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3464 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
3465
3466 seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id);
Maarten Lankhorst2dd66ebd2016-03-14 09:27:52 +01003467 seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n",
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003468 pll->state.crtc_mask, pll->active_mask, yesno(pll->on));
Daniel Vetter728e29d2014-06-25 22:01:53 +03003469 seq_printf(m, " tracked hardware state:\n");
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003470 seq_printf(m, " dpll: 0x%08x\n", pll->state.hw_state.dpll);
Ander Conselvan de Oliveira3e369b72014-10-29 11:32:32 +02003471 seq_printf(m, " dpll_md: 0x%08x\n",
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003472 pll->state.hw_state.dpll_md);
3473 seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0);
3474 seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1);
3475 seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll);
Daniel Vetter728e29d2014-06-25 22:01:53 +03003476 }
3477 drm_modeset_unlock_all(dev);
3478
3479 return 0;
3480}
3481
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01003482static int i915_wa_registers(struct seq_file *m, void *unused)
Arun Siluvery888b5992014-08-26 14:44:51 +01003483{
3484 int i;
3485 int ret;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003486 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003487 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3488 struct drm_device *dev = &dev_priv->drm;
Arun Siluvery33136b02016-01-21 21:43:47 +00003489 struct i915_workarounds *workarounds = &dev_priv->workarounds;
Dave Gordonc3232b12016-03-23 18:19:53 +00003490 enum intel_engine_id id;
Arun Siluvery888b5992014-08-26 14:44:51 +01003491
Arun Siluvery888b5992014-08-26 14:44:51 +01003492 ret = mutex_lock_interruptible(&dev->struct_mutex);
3493 if (ret)
3494 return ret;
3495
3496 intel_runtime_pm_get(dev_priv);
3497
Arun Siluvery33136b02016-01-21 21:43:47 +00003498 seq_printf(m, "Workarounds applied: %d\n", workarounds->count);
Akash Goel3b3f1652016-10-13 22:44:48 +05303499 for_each_engine(engine, dev_priv, id)
Arun Siluvery33136b02016-01-21 21:43:47 +00003500 seq_printf(m, "HW whitelist count for %s: %d\n",
Dave Gordonc3232b12016-03-23 18:19:53 +00003501 engine->name, workarounds->hw_whitelist_count[id]);
Arun Siluvery33136b02016-01-21 21:43:47 +00003502 for (i = 0; i < workarounds->count; ++i) {
Ville Syrjäläf0f59a02015-11-18 15:33:26 +02003503 i915_reg_t addr;
3504 u32 mask, value, read;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003505 bool ok;
Arun Siluvery888b5992014-08-26 14:44:51 +01003506
Arun Siluvery33136b02016-01-21 21:43:47 +00003507 addr = workarounds->reg[i].addr;
3508 mask = workarounds->reg[i].mask;
3509 value = workarounds->reg[i].value;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003510 read = I915_READ(addr);
3511 ok = (value & mask) == (read & mask);
3512 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 +02003513 i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL");
Arun Siluvery888b5992014-08-26 14:44:51 +01003514 }
3515
3516 intel_runtime_pm_put(dev_priv);
3517 mutex_unlock(&dev->struct_mutex);
3518
3519 return 0;
3520}
3521
Damien Lespiauc5511e42014-11-04 17:06:51 +00003522static int i915_ddb_info(struct seq_file *m, void *unused)
3523{
David Weinehall36cdd012016-08-22 13:59:31 +03003524 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3525 struct drm_device *dev = &dev_priv->drm;
Damien Lespiauc5511e42014-11-04 17:06:51 +00003526 struct skl_ddb_allocation *ddb;
3527 struct skl_ddb_entry *entry;
3528 enum pipe pipe;
3529 int plane;
3530
David Weinehall36cdd012016-08-22 13:59:31 +03003531 if (INTEL_GEN(dev_priv) < 9)
Damien Lespiau2fcffe12014-12-03 17:33:24 +00003532 return 0;
3533
Damien Lespiauc5511e42014-11-04 17:06:51 +00003534 drm_modeset_lock_all(dev);
3535
3536 ddb = &dev_priv->wm.skl_hw.ddb;
3537
3538 seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
3539
3540 for_each_pipe(dev_priv, pipe) {
3541 seq_printf(m, "Pipe %c\n", pipe_name(pipe));
3542
Matt Roper8b364b42016-10-26 15:51:28 -07003543 for_each_universal_plane(dev_priv, pipe, plane) {
Damien Lespiauc5511e42014-11-04 17:06:51 +00003544 entry = &ddb->plane[pipe][plane];
3545 seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1,
3546 entry->start, entry->end,
3547 skl_ddb_entry_size(entry));
3548 }
3549
Matt Roper4969d332015-09-24 15:53:10 -07003550 entry = &ddb->plane[pipe][PLANE_CURSOR];
Damien Lespiauc5511e42014-11-04 17:06:51 +00003551 seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start,
3552 entry->end, skl_ddb_entry_size(entry));
3553 }
3554
3555 drm_modeset_unlock_all(dev);
3556
3557 return 0;
3558}
3559
Vandana Kannana54746e2015-03-03 20:53:10 +05303560static void drrs_status_per_crtc(struct seq_file *m,
David Weinehall36cdd012016-08-22 13:59:31 +03003561 struct drm_device *dev,
3562 struct intel_crtc *intel_crtc)
Vandana Kannana54746e2015-03-03 20:53:10 +05303563{
Chris Wilsonfac5e232016-07-04 11:34:36 +01003564 struct drm_i915_private *dev_priv = to_i915(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303565 struct i915_drrs *drrs = &dev_priv->drrs;
3566 int vrefresh = 0;
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003567 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003568 struct drm_connector_list_iter conn_iter;
Vandana Kannana54746e2015-03-03 20:53:10 +05303569
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003570 drm_connector_list_iter_begin(dev, &conn_iter);
3571 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003572 if (connector->state->crtc != &intel_crtc->base)
3573 continue;
3574
3575 seq_printf(m, "%s:\n", connector->name);
Vandana Kannana54746e2015-03-03 20:53:10 +05303576 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003577 drm_connector_list_iter_end(&conn_iter);
Vandana Kannana54746e2015-03-03 20:53:10 +05303578
3579 if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT)
3580 seq_puts(m, "\tVBT: DRRS_type: Static");
3581 else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT)
3582 seq_puts(m, "\tVBT: DRRS_type: Seamless");
3583 else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED)
3584 seq_puts(m, "\tVBT: DRRS_type: None");
3585 else
3586 seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value");
3587
3588 seq_puts(m, "\n\n");
3589
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003590 if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303591 struct intel_panel *panel;
3592
3593 mutex_lock(&drrs->mutex);
3594 /* DRRS Supported */
3595 seq_puts(m, "\tDRRS Supported: Yes\n");
3596
3597 /* disable_drrs() will make drrs->dp NULL */
3598 if (!drrs->dp) {
3599 seq_puts(m, "Idleness DRRS: Disabled");
3600 mutex_unlock(&drrs->mutex);
3601 return;
3602 }
3603
3604 panel = &drrs->dp->attached_connector->panel;
3605 seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X",
3606 drrs->busy_frontbuffer_bits);
3607
3608 seq_puts(m, "\n\t\t");
3609 if (drrs->refresh_rate_type == DRRS_HIGH_RR) {
3610 seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n");
3611 vrefresh = panel->fixed_mode->vrefresh;
3612 } else if (drrs->refresh_rate_type == DRRS_LOW_RR) {
3613 seq_puts(m, "DRRS_State: DRRS_LOW_RR\n");
3614 vrefresh = panel->downclock_mode->vrefresh;
3615 } else {
3616 seq_printf(m, "DRRS_State: Unknown(%d)\n",
3617 drrs->refresh_rate_type);
3618 mutex_unlock(&drrs->mutex);
3619 return;
3620 }
3621 seq_printf(m, "\t\tVrefresh: %d", vrefresh);
3622
3623 seq_puts(m, "\n\t\t");
3624 mutex_unlock(&drrs->mutex);
3625 } else {
3626 /* DRRS not supported. Print the VBT parameter*/
3627 seq_puts(m, "\tDRRS Supported : No");
3628 }
3629 seq_puts(m, "\n");
3630}
3631
3632static int i915_drrs_status(struct seq_file *m, void *unused)
3633{
David Weinehall36cdd012016-08-22 13:59:31 +03003634 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3635 struct drm_device *dev = &dev_priv->drm;
Vandana Kannana54746e2015-03-03 20:53:10 +05303636 struct intel_crtc *intel_crtc;
3637 int active_crtc_cnt = 0;
3638
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003639 drm_modeset_lock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303640 for_each_intel_crtc(dev, intel_crtc) {
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003641 if (intel_crtc->base.state->active) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303642 active_crtc_cnt++;
3643 seq_printf(m, "\nCRTC %d: ", active_crtc_cnt);
3644
3645 drrs_status_per_crtc(m, dev, intel_crtc);
3646 }
Vandana Kannana54746e2015-03-03 20:53:10 +05303647 }
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003648 drm_modeset_unlock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303649
3650 if (!active_crtc_cnt)
3651 seq_puts(m, "No active crtc found\n");
3652
3653 return 0;
3654}
3655
Dave Airlie11bed952014-05-12 15:22:27 +10003656static int i915_dp_mst_info(struct seq_file *m, void *unused)
3657{
David Weinehall36cdd012016-08-22 13:59:31 +03003658 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3659 struct drm_device *dev = &dev_priv->drm;
Dave Airlie11bed952014-05-12 15:22:27 +10003660 struct intel_encoder *intel_encoder;
3661 struct intel_digital_port *intel_dig_port;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003662 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003663 struct drm_connector_list_iter conn_iter;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003664
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003665 drm_connector_list_iter_begin(dev, &conn_iter);
3666 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003667 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
Dave Airlie11bed952014-05-12 15:22:27 +10003668 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003669
3670 intel_encoder = intel_attached_encoder(connector);
3671 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
3672 continue;
3673
3674 intel_dig_port = enc_to_dig_port(&intel_encoder->base);
Dave Airlie11bed952014-05-12 15:22:27 +10003675 if (!intel_dig_port->dp.can_mst)
3676 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003677
Jim Bride40ae80c2016-04-14 10:18:37 -07003678 seq_printf(m, "MST Source Port %c\n",
3679 port_name(intel_dig_port->port));
Dave Airlie11bed952014-05-12 15:22:27 +10003680 drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr);
3681 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003682 drm_connector_list_iter_end(&conn_iter);
3683
Dave Airlie11bed952014-05-12 15:22:27 +10003684 return 0;
3685}
3686
Todd Previteeb3394fa2015-04-18 00:04:19 -07003687static ssize_t i915_displayport_test_active_write(struct file *file,
David Weinehall36cdd012016-08-22 13:59:31 +03003688 const char __user *ubuf,
3689 size_t len, loff_t *offp)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003690{
3691 char *input_buffer;
3692 int status = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003693 struct drm_device *dev;
3694 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003695 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003696 struct intel_dp *intel_dp;
3697 int val = 0;
3698
Sudip Mukherjee9aaffa32015-07-21 17:36:45 +05303699 dev = ((struct seq_file *)file->private_data)->private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003700
Todd Previteeb3394fa2015-04-18 00:04:19 -07003701 if (len == 0)
3702 return 0;
3703
3704 input_buffer = kmalloc(len + 1, GFP_KERNEL);
3705 if (!input_buffer)
3706 return -ENOMEM;
3707
3708 if (copy_from_user(input_buffer, ubuf, len)) {
3709 status = -EFAULT;
3710 goto out;
3711 }
3712
3713 input_buffer[len] = '\0';
3714 DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len);
3715
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003716 drm_connector_list_iter_begin(dev, &conn_iter);
3717 drm_for_each_connector_iter(connector, &conn_iter) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003718 if (connector->connector_type !=
3719 DRM_MODE_CONNECTOR_DisplayPort)
3720 continue;
3721
Sudip Mukherjeeb8bb08e2015-07-21 17:36:46 +05303722 if (connector->status == connector_status_connected &&
Todd Previteeb3394fa2015-04-18 00:04:19 -07003723 connector->encoder != NULL) {
3724 intel_dp = enc_to_intel_dp(connector->encoder);
3725 status = kstrtoint(input_buffer, 10, &val);
3726 if (status < 0)
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003727 break;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003728 DRM_DEBUG_DRIVER("Got %d for test active\n", val);
3729 /* To prevent erroneous activation of the compliance
3730 * testing code, only accept an actual value of 1 here
3731 */
3732 if (val == 1)
Manasi Navarec1617ab2016-12-09 16:22:50 -08003733 intel_dp->compliance.test_active = 1;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003734 else
Manasi Navarec1617ab2016-12-09 16:22:50 -08003735 intel_dp->compliance.test_active = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003736 }
3737 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003738 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003739out:
3740 kfree(input_buffer);
3741 if (status < 0)
3742 return status;
3743
3744 *offp += len;
3745 return len;
3746}
3747
3748static int i915_displayport_test_active_show(struct seq_file *m, void *data)
3749{
3750 struct drm_device *dev = m->private;
3751 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003752 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003753 struct intel_dp *intel_dp;
3754
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003755 drm_connector_list_iter_begin(dev, &conn_iter);
3756 drm_for_each_connector_iter(connector, &conn_iter) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003757 if (connector->connector_type !=
3758 DRM_MODE_CONNECTOR_DisplayPort)
3759 continue;
3760
3761 if (connector->status == connector_status_connected &&
3762 connector->encoder != NULL) {
3763 intel_dp = enc_to_intel_dp(connector->encoder);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003764 if (intel_dp->compliance.test_active)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003765 seq_puts(m, "1");
3766 else
3767 seq_puts(m, "0");
3768 } else
3769 seq_puts(m, "0");
3770 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003771 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003772
3773 return 0;
3774}
3775
3776static int i915_displayport_test_active_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03003777 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003778{
David Weinehall36cdd012016-08-22 13:59:31 +03003779 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003780
David Weinehall36cdd012016-08-22 13:59:31 +03003781 return single_open(file, i915_displayport_test_active_show,
3782 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003783}
3784
3785static const struct file_operations i915_displayport_test_active_fops = {
3786 .owner = THIS_MODULE,
3787 .open = i915_displayport_test_active_open,
3788 .read = seq_read,
3789 .llseek = seq_lseek,
3790 .release = single_release,
3791 .write = i915_displayport_test_active_write
3792};
3793
3794static int i915_displayport_test_data_show(struct seq_file *m, void *data)
3795{
3796 struct drm_device *dev = m->private;
3797 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003798 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003799 struct intel_dp *intel_dp;
3800
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003801 drm_connector_list_iter_begin(dev, &conn_iter);
3802 drm_for_each_connector_iter(connector, &conn_iter) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003803 if (connector->connector_type !=
3804 DRM_MODE_CONNECTOR_DisplayPort)
3805 continue;
3806
3807 if (connector->status == connector_status_connected &&
3808 connector->encoder != NULL) {
3809 intel_dp = enc_to_intel_dp(connector->encoder);
Manasi Navareb48a5ba2017-01-20 19:09:28 -08003810 if (intel_dp->compliance.test_type ==
3811 DP_TEST_LINK_EDID_READ)
3812 seq_printf(m, "%lx",
3813 intel_dp->compliance.test_data.edid);
Manasi Navare611032b2017-01-24 08:21:49 -08003814 else if (intel_dp->compliance.test_type ==
3815 DP_TEST_LINK_VIDEO_PATTERN) {
3816 seq_printf(m, "hdisplay: %d\n",
3817 intel_dp->compliance.test_data.hdisplay);
3818 seq_printf(m, "vdisplay: %d\n",
3819 intel_dp->compliance.test_data.vdisplay);
3820 seq_printf(m, "bpc: %u\n",
3821 intel_dp->compliance.test_data.bpc);
3822 }
Todd Previteeb3394fa2015-04-18 00:04:19 -07003823 } else
3824 seq_puts(m, "0");
3825 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003826 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003827
3828 return 0;
3829}
3830static int i915_displayport_test_data_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03003831 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003832{
David Weinehall36cdd012016-08-22 13:59:31 +03003833 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003834
David Weinehall36cdd012016-08-22 13:59:31 +03003835 return single_open(file, i915_displayport_test_data_show,
3836 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003837}
3838
3839static const struct file_operations i915_displayport_test_data_fops = {
3840 .owner = THIS_MODULE,
3841 .open = i915_displayport_test_data_open,
3842 .read = seq_read,
3843 .llseek = seq_lseek,
3844 .release = single_release
3845};
3846
3847static int i915_displayport_test_type_show(struct seq_file *m, void *data)
3848{
3849 struct drm_device *dev = m->private;
3850 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003851 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003852 struct intel_dp *intel_dp;
3853
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003854 drm_connector_list_iter_begin(dev, &conn_iter);
3855 drm_for_each_connector_iter(connector, &conn_iter) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003856 if (connector->connector_type !=
3857 DRM_MODE_CONNECTOR_DisplayPort)
3858 continue;
3859
3860 if (connector->status == connector_status_connected &&
3861 connector->encoder != NULL) {
3862 intel_dp = enc_to_intel_dp(connector->encoder);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003863 seq_printf(m, "%02lx", intel_dp->compliance.test_type);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003864 } else
3865 seq_puts(m, "0");
3866 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003867 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003868
3869 return 0;
3870}
3871
3872static int i915_displayport_test_type_open(struct inode *inode,
3873 struct file *file)
3874{
David Weinehall36cdd012016-08-22 13:59:31 +03003875 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003876
David Weinehall36cdd012016-08-22 13:59:31 +03003877 return single_open(file, i915_displayport_test_type_show,
3878 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003879}
3880
3881static const struct file_operations i915_displayport_test_type_fops = {
3882 .owner = THIS_MODULE,
3883 .open = i915_displayport_test_type_open,
3884 .read = seq_read,
3885 .llseek = seq_lseek,
3886 .release = single_release
3887};
3888
Damien Lespiau97e94b22014-11-04 17:06:50 +00003889static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02003890{
David Weinehall36cdd012016-08-22 13:59:31 +03003891 struct drm_i915_private *dev_priv = m->private;
3892 struct drm_device *dev = &dev_priv->drm;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003893 int level;
Ville Syrjäläde38b952015-06-24 22:00:09 +03003894 int num_levels;
3895
David Weinehall36cdd012016-08-22 13:59:31 +03003896 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003897 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03003898 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003899 num_levels = 1;
3900 else
Tvrtko Ursulin5db94012016-10-13 11:03:10 +01003901 num_levels = ilk_wm_max_level(dev_priv) + 1;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003902
3903 drm_modeset_lock_all(dev);
3904
3905 for (level = 0; level < num_levels; level++) {
3906 unsigned int latency = wm[level];
3907
Damien Lespiau97e94b22014-11-04 17:06:50 +00003908 /*
3909 * - WM1+ latency values in 0.5us units
Ville Syrjäläde38b952015-06-24 22:00:09 +03003910 * - latencies are in us on gen9/vlv/chv
Damien Lespiau97e94b22014-11-04 17:06:50 +00003911 */
David Weinehall36cdd012016-08-22 13:59:31 +03003912 if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) ||
3913 IS_CHERRYVIEW(dev_priv))
Damien Lespiau97e94b22014-11-04 17:06:50 +00003914 latency *= 10;
3915 else if (level > 0)
Ville Syrjälä369a1342014-01-22 14:36:08 +02003916 latency *= 5;
3917
3918 seq_printf(m, "WM%d %u (%u.%u usec)\n",
Damien Lespiau97e94b22014-11-04 17:06:50 +00003919 level, wm[level], latency / 10, latency % 10);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003920 }
3921
3922 drm_modeset_unlock_all(dev);
3923}
3924
3925static int pri_wm_latency_show(struct seq_file *m, void *data)
3926{
David Weinehall36cdd012016-08-22 13:59:31 +03003927 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003928 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003929
David Weinehall36cdd012016-08-22 13:59:31 +03003930 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003931 latencies = dev_priv->wm.skl_latency;
3932 else
David Weinehall36cdd012016-08-22 13:59:31 +03003933 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003934
3935 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003936
3937 return 0;
3938}
3939
3940static int spr_wm_latency_show(struct seq_file *m, void *data)
3941{
David Weinehall36cdd012016-08-22 13:59:31 +03003942 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003943 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003944
David Weinehall36cdd012016-08-22 13:59:31 +03003945 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003946 latencies = dev_priv->wm.skl_latency;
3947 else
David Weinehall36cdd012016-08-22 13:59:31 +03003948 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003949
3950 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003951
3952 return 0;
3953}
3954
3955static int cur_wm_latency_show(struct seq_file *m, void *data)
3956{
David Weinehall36cdd012016-08-22 13:59:31 +03003957 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003958 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003959
David Weinehall36cdd012016-08-22 13:59:31 +03003960 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003961 latencies = dev_priv->wm.skl_latency;
3962 else
David Weinehall36cdd012016-08-22 13:59:31 +03003963 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003964
3965 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003966
3967 return 0;
3968}
3969
3970static int pri_wm_latency_open(struct inode *inode, struct file *file)
3971{
David Weinehall36cdd012016-08-22 13:59:31 +03003972 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003973
David Weinehall36cdd012016-08-22 13:59:31 +03003974 if (INTEL_GEN(dev_priv) < 5)
Ville Syrjälä369a1342014-01-22 14:36:08 +02003975 return -ENODEV;
3976
David Weinehall36cdd012016-08-22 13:59:31 +03003977 return single_open(file, pri_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003978}
3979
3980static int spr_wm_latency_open(struct inode *inode, struct file *file)
3981{
David Weinehall36cdd012016-08-22 13:59:31 +03003982 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003983
David Weinehall36cdd012016-08-22 13:59:31 +03003984 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003985 return -ENODEV;
3986
David Weinehall36cdd012016-08-22 13:59:31 +03003987 return single_open(file, spr_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003988}
3989
3990static int cur_wm_latency_open(struct inode *inode, struct file *file)
3991{
David Weinehall36cdd012016-08-22 13:59:31 +03003992 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003993
David Weinehall36cdd012016-08-22 13:59:31 +03003994 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003995 return -ENODEV;
3996
David Weinehall36cdd012016-08-22 13:59:31 +03003997 return single_open(file, cur_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003998}
3999
4000static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
Damien Lespiau97e94b22014-11-04 17:06:50 +00004001 size_t len, loff_t *offp, uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02004002{
4003 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004004 struct drm_i915_private *dev_priv = m->private;
4005 struct drm_device *dev = &dev_priv->drm;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004006 uint16_t new[8] = { 0 };
Ville Syrjäläde38b952015-06-24 22:00:09 +03004007 int num_levels;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004008 int level;
4009 int ret;
4010 char tmp[32];
4011
David Weinehall36cdd012016-08-22 13:59:31 +03004012 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03004013 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03004014 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03004015 num_levels = 1;
4016 else
Tvrtko Ursulin5db94012016-10-13 11:03:10 +01004017 num_levels = ilk_wm_max_level(dev_priv) + 1;
Ville Syrjäläde38b952015-06-24 22:00:09 +03004018
Ville Syrjälä369a1342014-01-22 14:36:08 +02004019 if (len >= sizeof(tmp))
4020 return -EINVAL;
4021
4022 if (copy_from_user(tmp, ubuf, len))
4023 return -EFAULT;
4024
4025 tmp[len] = '\0';
4026
Damien Lespiau97e94b22014-11-04 17:06:50 +00004027 ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
4028 &new[0], &new[1], &new[2], &new[3],
4029 &new[4], &new[5], &new[6], &new[7]);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004030 if (ret != num_levels)
4031 return -EINVAL;
4032
4033 drm_modeset_lock_all(dev);
4034
4035 for (level = 0; level < num_levels; level++)
4036 wm[level] = new[level];
4037
4038 drm_modeset_unlock_all(dev);
4039
4040 return len;
4041}
4042
4043
4044static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
4045 size_t len, loff_t *offp)
4046{
4047 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004048 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004049 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004050
David Weinehall36cdd012016-08-22 13:59:31 +03004051 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004052 latencies = dev_priv->wm.skl_latency;
4053 else
David Weinehall36cdd012016-08-22 13:59:31 +03004054 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004055
4056 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004057}
4058
4059static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
4060 size_t len, loff_t *offp)
4061{
4062 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004063 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004064 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004065
David Weinehall36cdd012016-08-22 13:59:31 +03004066 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004067 latencies = dev_priv->wm.skl_latency;
4068 else
David Weinehall36cdd012016-08-22 13:59:31 +03004069 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004070
4071 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004072}
4073
4074static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
4075 size_t len, loff_t *offp)
4076{
4077 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004078 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004079 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004080
David Weinehall36cdd012016-08-22 13:59:31 +03004081 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004082 latencies = dev_priv->wm.skl_latency;
4083 else
David Weinehall36cdd012016-08-22 13:59:31 +03004084 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004085
4086 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004087}
4088
4089static const struct file_operations i915_pri_wm_latency_fops = {
4090 .owner = THIS_MODULE,
4091 .open = pri_wm_latency_open,
4092 .read = seq_read,
4093 .llseek = seq_lseek,
4094 .release = single_release,
4095 .write = pri_wm_latency_write
4096};
4097
4098static const struct file_operations i915_spr_wm_latency_fops = {
4099 .owner = THIS_MODULE,
4100 .open = spr_wm_latency_open,
4101 .read = seq_read,
4102 .llseek = seq_lseek,
4103 .release = single_release,
4104 .write = spr_wm_latency_write
4105};
4106
4107static const struct file_operations i915_cur_wm_latency_fops = {
4108 .owner = THIS_MODULE,
4109 .open = cur_wm_latency_open,
4110 .read = seq_read,
4111 .llseek = seq_lseek,
4112 .release = single_release,
4113 .write = cur_wm_latency_write
4114};
4115
Kees Cook647416f2013-03-10 14:10:06 -07004116static int
4117i915_wedged_get(void *data, u64 *val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004118{
David Weinehall36cdd012016-08-22 13:59:31 +03004119 struct drm_i915_private *dev_priv = data;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004120
Chris Wilsond98c52c2016-04-13 17:35:05 +01004121 *val = i915_terminally_wedged(&dev_priv->gpu_error);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004122
Kees Cook647416f2013-03-10 14:10:06 -07004123 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004124}
4125
Kees Cook647416f2013-03-10 14:10:06 -07004126static int
4127i915_wedged_set(void *data, u64 val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004128{
David Weinehall36cdd012016-08-22 13:59:31 +03004129 struct drm_i915_private *dev_priv = data;
Imre Deakd46c0512014-04-14 20:24:27 +03004130
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004131 /*
4132 * There is no safeguard against this debugfs entry colliding
4133 * with the hangcheck calling same i915_handle_error() in
4134 * parallel, causing an explosion. For now we assume that the
4135 * test harness is responsible enough not to inject gpu hangs
4136 * while it is writing to 'i915_wedged'
4137 */
4138
Chris Wilson8c185ec2017-03-16 17:13:02 +00004139 if (i915_reset_backoff(&dev_priv->gpu_error))
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004140 return -EAGAIN;
4141
Chris Wilsonc0336662016-05-06 15:40:21 +01004142 i915_handle_error(dev_priv, val,
Mika Kuoppala58174462014-02-25 17:11:26 +02004143 "Manually setting wedged to %llu", val);
Imre Deakd46c0512014-04-14 20:24:27 +03004144
Chris Wilsond3df42b2017-03-16 17:13:05 +00004145 wait_on_bit(&dev_priv->gpu_error.flags,
4146 I915_RESET_HANDOFF,
4147 TASK_UNINTERRUPTIBLE);
4148
Kees Cook647416f2013-03-10 14:10:06 -07004149 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004150}
4151
Kees Cook647416f2013-03-10 14:10:06 -07004152DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
4153 i915_wedged_get, i915_wedged_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004154 "%llu\n");
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004155
Kees Cook647416f2013-03-10 14:10:06 -07004156static int
Chris Wilson64486ae2017-03-07 15:59:08 +00004157fault_irq_set(struct drm_i915_private *i915,
4158 unsigned long *irq,
4159 unsigned long val)
4160{
4161 int err;
4162
4163 err = mutex_lock_interruptible(&i915->drm.struct_mutex);
4164 if (err)
4165 return err;
4166
4167 err = i915_gem_wait_for_idle(i915,
4168 I915_WAIT_LOCKED |
4169 I915_WAIT_INTERRUPTIBLE);
4170 if (err)
4171 goto err_unlock;
4172
4173 /* Retire to kick idle work */
4174 i915_gem_retire_requests(i915);
4175 GEM_BUG_ON(i915->gt.active_requests);
4176
4177 *irq = val;
4178 mutex_unlock(&i915->drm.struct_mutex);
4179
4180 /* Flush idle worker to disarm irq */
4181 while (flush_delayed_work(&i915->gt.idle_work))
4182 ;
4183
4184 return 0;
4185
4186err_unlock:
4187 mutex_unlock(&i915->drm.struct_mutex);
4188 return err;
4189}
4190
4191static int
Chris Wilson094f9a52013-09-25 17:34:55 +01004192i915_ring_missed_irq_get(void *data, u64 *val)
4193{
David Weinehall36cdd012016-08-22 13:59:31 +03004194 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004195
4196 *val = dev_priv->gpu_error.missed_irq_rings;
4197 return 0;
4198}
4199
4200static int
4201i915_ring_missed_irq_set(void *data, u64 val)
4202{
Chris Wilson64486ae2017-03-07 15:59:08 +00004203 struct drm_i915_private *i915 = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004204
Chris Wilson64486ae2017-03-07 15:59:08 +00004205 return fault_irq_set(i915, &i915->gpu_error.missed_irq_rings, val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004206}
4207
4208DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops,
4209 i915_ring_missed_irq_get, i915_ring_missed_irq_set,
4210 "0x%08llx\n");
4211
4212static int
4213i915_ring_test_irq_get(void *data, u64 *val)
4214{
David Weinehall36cdd012016-08-22 13:59:31 +03004215 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004216
4217 *val = dev_priv->gpu_error.test_irq_rings;
4218
4219 return 0;
4220}
4221
4222static int
4223i915_ring_test_irq_set(void *data, u64 val)
4224{
Chris Wilson64486ae2017-03-07 15:59:08 +00004225 struct drm_i915_private *i915 = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004226
Chris Wilson64486ae2017-03-07 15:59:08 +00004227 val &= INTEL_INFO(i915)->ring_mask;
Chris Wilson094f9a52013-09-25 17:34:55 +01004228 DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004229
Chris Wilson64486ae2017-03-07 15:59:08 +00004230 return fault_irq_set(i915, &i915->gpu_error.test_irq_rings, val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004231}
4232
4233DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops,
4234 i915_ring_test_irq_get, i915_ring_test_irq_set,
4235 "0x%08llx\n");
4236
Chris Wilsondd624af2013-01-15 12:39:35 +00004237#define DROP_UNBOUND 0x1
4238#define DROP_BOUND 0x2
4239#define DROP_RETIRE 0x4
4240#define DROP_ACTIVE 0x8
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004241#define DROP_FREED 0x10
Chris Wilson8eadc192017-03-08 14:46:22 +00004242#define DROP_SHRINK_ALL 0x20
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004243#define DROP_ALL (DROP_UNBOUND | \
4244 DROP_BOUND | \
4245 DROP_RETIRE | \
4246 DROP_ACTIVE | \
Chris Wilson8eadc192017-03-08 14:46:22 +00004247 DROP_FREED | \
4248 DROP_SHRINK_ALL)
Kees Cook647416f2013-03-10 14:10:06 -07004249static int
4250i915_drop_caches_get(void *data, u64 *val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004251{
Kees Cook647416f2013-03-10 14:10:06 -07004252 *val = DROP_ALL;
Chris Wilsondd624af2013-01-15 12:39:35 +00004253
Kees Cook647416f2013-03-10 14:10:06 -07004254 return 0;
Chris Wilsondd624af2013-01-15 12:39:35 +00004255}
4256
Kees Cook647416f2013-03-10 14:10:06 -07004257static int
4258i915_drop_caches_set(void *data, u64 val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004259{
David Weinehall36cdd012016-08-22 13:59:31 +03004260 struct drm_i915_private *dev_priv = data;
4261 struct drm_device *dev = &dev_priv->drm;
Kees Cook647416f2013-03-10 14:10:06 -07004262 int ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004263
Ben Widawsky2f9fe5f2013-11-25 09:54:37 -08004264 DRM_DEBUG("Dropping caches: 0x%08llx\n", val);
Chris Wilsondd624af2013-01-15 12:39:35 +00004265
4266 /* No need to check and wait for gpu resets, only libdrm auto-restarts
4267 * on ioctls on -EAGAIN. */
4268 ret = mutex_lock_interruptible(&dev->struct_mutex);
4269 if (ret)
4270 return ret;
4271
4272 if (val & DROP_ACTIVE) {
Chris Wilson22dd3bb2016-09-09 14:11:50 +01004273 ret = i915_gem_wait_for_idle(dev_priv,
4274 I915_WAIT_INTERRUPTIBLE |
4275 I915_WAIT_LOCKED);
Chris Wilsondd624af2013-01-15 12:39:35 +00004276 if (ret)
4277 goto unlock;
4278 }
4279
4280 if (val & (DROP_RETIRE | DROP_ACTIVE))
Chris Wilsonc0336662016-05-06 15:40:21 +01004281 i915_gem_retire_requests(dev_priv);
Chris Wilsondd624af2013-01-15 12:39:35 +00004282
Daniel Vetter05df49e2017-03-12 21:53:40 +01004283 lockdep_set_current_reclaim_state(GFP_KERNEL);
Chris Wilson21ab4e72014-09-09 11:16:08 +01004284 if (val & DROP_BOUND)
4285 i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND);
Chris Wilson4ad72b72014-09-03 19:23:37 +01004286
Chris Wilson21ab4e72014-09-09 11:16:08 +01004287 if (val & DROP_UNBOUND)
4288 i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND);
Chris Wilsondd624af2013-01-15 12:39:35 +00004289
Chris Wilson8eadc192017-03-08 14:46:22 +00004290 if (val & DROP_SHRINK_ALL)
4291 i915_gem_shrink_all(dev_priv);
Daniel Vetter05df49e2017-03-12 21:53:40 +01004292 lockdep_clear_current_reclaim_state();
Chris Wilson8eadc192017-03-08 14:46:22 +00004293
Chris Wilsondd624af2013-01-15 12:39:35 +00004294unlock:
4295 mutex_unlock(&dev->struct_mutex);
4296
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004297 if (val & DROP_FREED) {
4298 synchronize_rcu();
Chris Wilsonbdeb9782016-12-23 14:57:56 +00004299 i915_gem_drain_freed_objects(dev_priv);
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004300 }
4301
Kees Cook647416f2013-03-10 14:10:06 -07004302 return ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004303}
4304
Kees Cook647416f2013-03-10 14:10:06 -07004305DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
4306 i915_drop_caches_get, i915_drop_caches_set,
4307 "0x%08llx\n");
Chris Wilsondd624af2013-01-15 12:39:35 +00004308
Kees Cook647416f2013-03-10 14:10:06 -07004309static int
4310i915_max_freq_get(void *data, u64 *val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004311{
David Weinehall36cdd012016-08-22 13:59:31 +03004312 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004313
David Weinehall36cdd012016-08-22 13:59:31 +03004314 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004315 return -ENODEV;
4316
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02004317 *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004318 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004319}
4320
Kees Cook647416f2013-03-10 14:10:06 -07004321static int
4322i915_max_freq_set(void *data, u64 val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004323{
David Weinehall36cdd012016-08-22 13:59:31 +03004324 struct drm_i915_private *dev_priv = data;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304325 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004326 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004327
David Weinehall36cdd012016-08-22 13:59:31 +03004328 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004329 return -ENODEV;
Jesse Barnes358733e2011-07-27 11:53:01 -07004330
Kees Cook647416f2013-03-10 14:10:06 -07004331 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val);
Jesse Barnes358733e2011-07-27 11:53:01 -07004332
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004333 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004334 if (ret)
4335 return ret;
4336
Jesse Barnes358733e2011-07-27 11:53:01 -07004337 /*
4338 * Turbo will still be enabled, but won't go above the set value.
4339 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304340 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004341
Akash Goelbc4d91f2015-02-26 16:09:47 +05304342 hw_max = dev_priv->rps.max_freq;
4343 hw_min = dev_priv->rps.min_freq;
Jesse Barnes0a073b82013-04-17 15:54:58 -07004344
Ben Widawskyb39fb292014-03-19 18:31:11 -07004345 if (val < hw_min || val > hw_max || val < dev_priv->rps.min_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004346 mutex_unlock(&dev_priv->rps.hw_lock);
4347 return -EINVAL;
4348 }
4349
Ben Widawskyb39fb292014-03-19 18:31:11 -07004350 dev_priv->rps.max_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004351
Chris Wilson9fcee2f2017-01-26 10:19:19 +00004352 if (intel_set_rps(dev_priv, val))
4353 DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n");
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004354
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004355 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes358733e2011-07-27 11:53:01 -07004356
Kees Cook647416f2013-03-10 14:10:06 -07004357 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004358}
4359
Kees Cook647416f2013-03-10 14:10:06 -07004360DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
4361 i915_max_freq_get, i915_max_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004362 "%llu\n");
Jesse Barnes358733e2011-07-27 11:53:01 -07004363
Kees Cook647416f2013-03-10 14:10:06 -07004364static int
4365i915_min_freq_get(void *data, u64 *val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004366{
David Weinehall36cdd012016-08-22 13:59:31 +03004367 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004368
Chris Wilson62e1baa2016-07-13 09:10:36 +01004369 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004370 return -ENODEV;
4371
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02004372 *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004373 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004374}
4375
Kees Cook647416f2013-03-10 14:10:06 -07004376static int
4377i915_min_freq_set(void *data, u64 val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004378{
David Weinehall36cdd012016-08-22 13:59:31 +03004379 struct drm_i915_private *dev_priv = data;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304380 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004381 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004382
Chris Wilson62e1baa2016-07-13 09:10:36 +01004383 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004384 return -ENODEV;
Jesse Barnes1523c312012-05-25 12:34:54 -07004385
Kees Cook647416f2013-03-10 14:10:06 -07004386 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val);
Jesse Barnes1523c312012-05-25 12:34:54 -07004387
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004388 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004389 if (ret)
4390 return ret;
4391
Jesse Barnes1523c312012-05-25 12:34:54 -07004392 /*
4393 * Turbo will still be enabled, but won't go below the set value.
4394 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304395 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004396
Akash Goelbc4d91f2015-02-26 16:09:47 +05304397 hw_max = dev_priv->rps.max_freq;
4398 hw_min = dev_priv->rps.min_freq;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004399
David Weinehall36cdd012016-08-22 13:59:31 +03004400 if (val < hw_min ||
4401 val > hw_max || val > dev_priv->rps.max_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004402 mutex_unlock(&dev_priv->rps.hw_lock);
4403 return -EINVAL;
4404 }
4405
Ben Widawskyb39fb292014-03-19 18:31:11 -07004406 dev_priv->rps.min_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004407
Chris Wilson9fcee2f2017-01-26 10:19:19 +00004408 if (intel_set_rps(dev_priv, val))
4409 DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n");
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004410
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004411 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes1523c312012-05-25 12:34:54 -07004412
Kees Cook647416f2013-03-10 14:10:06 -07004413 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004414}
4415
Kees Cook647416f2013-03-10 14:10:06 -07004416DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
4417 i915_min_freq_get, i915_min_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004418 "%llu\n");
Jesse Barnes1523c312012-05-25 12:34:54 -07004419
Kees Cook647416f2013-03-10 14:10:06 -07004420static int
4421i915_cache_sharing_get(void *data, u64 *val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004422{
David Weinehall36cdd012016-08-22 13:59:31 +03004423 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004424 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004425
David Weinehall36cdd012016-08-22 13:59:31 +03004426 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004427 return -ENODEV;
4428
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004429 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02004430
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004431 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004432
4433 intel_runtime_pm_put(dev_priv);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004434
Kees Cook647416f2013-03-10 14:10:06 -07004435 *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004436
Kees Cook647416f2013-03-10 14:10:06 -07004437 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004438}
4439
Kees Cook647416f2013-03-10 14:10:06 -07004440static int
4441i915_cache_sharing_set(void *data, u64 val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004442{
David Weinehall36cdd012016-08-22 13:59:31 +03004443 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004444 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004445
David Weinehall36cdd012016-08-22 13:59:31 +03004446 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004447 return -ENODEV;
4448
Kees Cook647416f2013-03-10 14:10:06 -07004449 if (val > 3)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004450 return -EINVAL;
4451
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004452 intel_runtime_pm_get(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004453 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004454
4455 /* Update the cache sharing policy here as well */
4456 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
4457 snpcr &= ~GEN6_MBC_SNPCR_MASK;
4458 snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
4459 I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
4460
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004461 intel_runtime_pm_put(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004462 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004463}
4464
Kees Cook647416f2013-03-10 14:10:06 -07004465DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops,
4466 i915_cache_sharing_get, i915_cache_sharing_set,
4467 "%llu\n");
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004468
David Weinehall36cdd012016-08-22 13:59:31 +03004469static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004470 struct sseu_dev_info *sseu)
Jeff McGee5d395252015-04-03 18:13:17 -07004471{
Ville Syrjälä0a0b4572015-08-21 20:45:27 +03004472 int ss_max = 2;
Jeff McGee5d395252015-04-03 18:13:17 -07004473 int ss;
4474 u32 sig1[ss_max], sig2[ss_max];
4475
4476 sig1[0] = I915_READ(CHV_POWER_SS0_SIG1);
4477 sig1[1] = I915_READ(CHV_POWER_SS1_SIG1);
4478 sig2[0] = I915_READ(CHV_POWER_SS0_SIG2);
4479 sig2[1] = I915_READ(CHV_POWER_SS1_SIG2);
4480
4481 for (ss = 0; ss < ss_max; ss++) {
4482 unsigned int eu_cnt;
4483
4484 if (sig1[ss] & CHV_SS_PG_ENABLE)
4485 /* skip disabled subslice */
4486 continue;
4487
Imre Deakf08a0c92016-08-31 19:13:04 +03004488 sseu->slice_mask = BIT(0);
Imre Deak57ec1712016-08-31 19:13:05 +03004489 sseu->subslice_mask |= BIT(ss);
Jeff McGee5d395252015-04-03 18:13:17 -07004490 eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) +
4491 ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) +
4492 ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) +
4493 ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2);
Imre Deak915490d2016-08-31 19:13:01 +03004494 sseu->eu_total += eu_cnt;
4495 sseu->eu_per_subslice = max_t(unsigned int,
4496 sseu->eu_per_subslice, eu_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07004497 }
Jeff McGee5d395252015-04-03 18:13:17 -07004498}
4499
David Weinehall36cdd012016-08-22 13:59:31 +03004500static void gen9_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004501 struct sseu_dev_info *sseu)
Jeff McGee5d395252015-04-03 18:13:17 -07004502{
Jeff McGee1c046bc2015-04-03 18:13:18 -07004503 int s_max = 3, ss_max = 4;
Jeff McGee5d395252015-04-03 18:13:17 -07004504 int s, ss;
4505 u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2];
4506
Jeff McGee1c046bc2015-04-03 18:13:18 -07004507 /* BXT has a single slice and at most 3 subslices. */
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02004508 if (IS_GEN9_LP(dev_priv)) {
Jeff McGee1c046bc2015-04-03 18:13:18 -07004509 s_max = 1;
4510 ss_max = 3;
4511 }
4512
4513 for (s = 0; s < s_max; s++) {
4514 s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s));
4515 eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s));
4516 eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s));
4517 }
4518
Jeff McGee5d395252015-04-03 18:13:17 -07004519 eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK |
4520 GEN9_PGCTL_SSA_EU19_ACK |
4521 GEN9_PGCTL_SSA_EU210_ACK |
4522 GEN9_PGCTL_SSA_EU311_ACK;
4523 eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK |
4524 GEN9_PGCTL_SSB_EU19_ACK |
4525 GEN9_PGCTL_SSB_EU210_ACK |
4526 GEN9_PGCTL_SSB_EU311_ACK;
4527
4528 for (s = 0; s < s_max; s++) {
4529 if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0)
4530 /* skip disabled slice */
4531 continue;
4532
Imre Deakf08a0c92016-08-31 19:13:04 +03004533 sseu->slice_mask |= BIT(s);
Jeff McGee1c046bc2015-04-03 18:13:18 -07004534
Rodrigo Vivib976dc52017-01-23 10:32:37 -08004535 if (IS_GEN9_BC(dev_priv))
Imre Deak57ec1712016-08-31 19:13:05 +03004536 sseu->subslice_mask =
4537 INTEL_INFO(dev_priv)->sseu.subslice_mask;
Jeff McGee1c046bc2015-04-03 18:13:18 -07004538
Jeff McGee5d395252015-04-03 18:13:17 -07004539 for (ss = 0; ss < ss_max; ss++) {
4540 unsigned int eu_cnt;
4541
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02004542 if (IS_GEN9_LP(dev_priv)) {
Imre Deak57ec1712016-08-31 19:13:05 +03004543 if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss))))
4544 /* skip disabled subslice */
4545 continue;
Jeff McGee1c046bc2015-04-03 18:13:18 -07004546
Imre Deak57ec1712016-08-31 19:13:05 +03004547 sseu->subslice_mask |= BIT(ss);
4548 }
Jeff McGee1c046bc2015-04-03 18:13:18 -07004549
Jeff McGee5d395252015-04-03 18:13:17 -07004550 eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] &
4551 eu_mask[ss%2]);
Imre Deak915490d2016-08-31 19:13:01 +03004552 sseu->eu_total += eu_cnt;
4553 sseu->eu_per_subslice = max_t(unsigned int,
4554 sseu->eu_per_subslice,
4555 eu_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07004556 }
4557 }
4558}
4559
David Weinehall36cdd012016-08-22 13:59:31 +03004560static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004561 struct sseu_dev_info *sseu)
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004562{
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004563 u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
David Weinehall36cdd012016-08-22 13:59:31 +03004564 int s;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004565
Imre Deakf08a0c92016-08-31 19:13:04 +03004566 sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004567
Imre Deakf08a0c92016-08-31 19:13:04 +03004568 if (sseu->slice_mask) {
Imre Deak57ec1712016-08-31 19:13:05 +03004569 sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask;
Imre Deak43b67992016-08-31 19:13:02 +03004570 sseu->eu_per_subslice =
4571 INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
Imre Deak57ec1712016-08-31 19:13:05 +03004572 sseu->eu_total = sseu->eu_per_subslice *
4573 sseu_subslice_total(sseu);
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004574
4575 /* subtract fused off EU(s) from enabled slice(s) */
Imre Deak795b38b2016-08-31 19:13:07 +03004576 for (s = 0; s < fls(sseu->slice_mask); s++) {
Imre Deak43b67992016-08-31 19:13:02 +03004577 u8 subslice_7eu =
4578 INTEL_INFO(dev_priv)->sseu.subslice_7eu[s];
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004579
Imre Deak915490d2016-08-31 19:13:01 +03004580 sseu->eu_total -= hweight8(subslice_7eu);
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004581 }
4582 }
4583}
4584
Imre Deak615d8902016-08-31 19:13:03 +03004585static void i915_print_sseu_info(struct seq_file *m, bool is_available_info,
4586 const struct sseu_dev_info *sseu)
4587{
4588 struct drm_i915_private *dev_priv = node_to_i915(m->private);
4589 const char *type = is_available_info ? "Available" : "Enabled";
4590
Imre Deakc67ba532016-08-31 19:13:06 +03004591 seq_printf(m, " %s Slice Mask: %04x\n", type,
4592 sseu->slice_mask);
Imre Deak615d8902016-08-31 19:13:03 +03004593 seq_printf(m, " %s Slice Total: %u\n", type,
Imre Deakf08a0c92016-08-31 19:13:04 +03004594 hweight8(sseu->slice_mask));
Imre Deak615d8902016-08-31 19:13:03 +03004595 seq_printf(m, " %s Subslice Total: %u\n", type,
Imre Deak57ec1712016-08-31 19:13:05 +03004596 sseu_subslice_total(sseu));
Imre Deakc67ba532016-08-31 19:13:06 +03004597 seq_printf(m, " %s Subslice Mask: %04x\n", type,
4598 sseu->subslice_mask);
Imre Deak615d8902016-08-31 19:13:03 +03004599 seq_printf(m, " %s Subslice Per Slice: %u\n", type,
Imre Deak57ec1712016-08-31 19:13:05 +03004600 hweight8(sseu->subslice_mask));
Imre Deak615d8902016-08-31 19:13:03 +03004601 seq_printf(m, " %s EU Total: %u\n", type,
4602 sseu->eu_total);
4603 seq_printf(m, " %s EU Per Subslice: %u\n", type,
4604 sseu->eu_per_subslice);
4605
4606 if (!is_available_info)
4607 return;
4608
4609 seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv)));
4610 if (HAS_POOLED_EU(dev_priv))
4611 seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool);
4612
4613 seq_printf(m, " Has Slice Power Gating: %s\n",
4614 yesno(sseu->has_slice_pg));
4615 seq_printf(m, " Has Subslice Power Gating: %s\n",
4616 yesno(sseu->has_subslice_pg));
4617 seq_printf(m, " Has EU Power Gating: %s\n",
4618 yesno(sseu->has_eu_pg));
4619}
4620
Jeff McGee38732182015-02-13 10:27:54 -06004621static int i915_sseu_status(struct seq_file *m, void *unused)
4622{
David Weinehall36cdd012016-08-22 13:59:31 +03004623 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak915490d2016-08-31 19:13:01 +03004624 struct sseu_dev_info sseu;
Jeff McGee38732182015-02-13 10:27:54 -06004625
David Weinehall36cdd012016-08-22 13:59:31 +03004626 if (INTEL_GEN(dev_priv) < 8)
Jeff McGee38732182015-02-13 10:27:54 -06004627 return -ENODEV;
4628
4629 seq_puts(m, "SSEU Device Info\n");
Imre Deak615d8902016-08-31 19:13:03 +03004630 i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu);
Jeff McGee38732182015-02-13 10:27:54 -06004631
Jeff McGee7f992ab2015-02-13 10:27:55 -06004632 seq_puts(m, "SSEU Device Status\n");
Imre Deak915490d2016-08-31 19:13:01 +03004633 memset(&sseu, 0, sizeof(sseu));
David Weinehall238010e2016-08-01 17:33:27 +03004634
4635 intel_runtime_pm_get(dev_priv);
4636
David Weinehall36cdd012016-08-22 13:59:31 +03004637 if (IS_CHERRYVIEW(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004638 cherryview_sseu_device_status(dev_priv, &sseu);
David Weinehall36cdd012016-08-22 13:59:31 +03004639 } else if (IS_BROADWELL(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004640 broadwell_sseu_device_status(dev_priv, &sseu);
David Weinehall36cdd012016-08-22 13:59:31 +03004641 } else if (INTEL_GEN(dev_priv) >= 9) {
Imre Deak915490d2016-08-31 19:13:01 +03004642 gen9_sseu_device_status(dev_priv, &sseu);
Jeff McGee7f992ab2015-02-13 10:27:55 -06004643 }
David Weinehall238010e2016-08-01 17:33:27 +03004644
4645 intel_runtime_pm_put(dev_priv);
4646
Imre Deak615d8902016-08-31 19:13:03 +03004647 i915_print_sseu_info(m, false, &sseu);
Jeff McGee7f992ab2015-02-13 10:27:55 -06004648
Jeff McGee38732182015-02-13 10:27:54 -06004649 return 0;
4650}
4651
Ben Widawsky6d794d42011-04-25 11:25:56 -07004652static int i915_forcewake_open(struct inode *inode, struct file *file)
4653{
David Weinehall36cdd012016-08-22 13:59:31 +03004654 struct drm_i915_private *dev_priv = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004655
David Weinehall36cdd012016-08-22 13:59:31 +03004656 if (INTEL_GEN(dev_priv) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004657 return 0;
4658
Chris Wilson6daccb02015-01-16 11:34:35 +02004659 intel_runtime_pm_get(dev_priv);
Mika Kuoppala59bad942015-01-16 11:34:40 +02004660 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004661
4662 return 0;
4663}
4664
Ben Widawskyc43b5632012-04-16 14:07:40 -07004665static int i915_forcewake_release(struct inode *inode, struct file *file)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004666{
David Weinehall36cdd012016-08-22 13:59:31 +03004667 struct drm_i915_private *dev_priv = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004668
David Weinehall36cdd012016-08-22 13:59:31 +03004669 if (INTEL_GEN(dev_priv) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004670 return 0;
4671
Mika Kuoppala59bad942015-01-16 11:34:40 +02004672 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Chris Wilson6daccb02015-01-16 11:34:35 +02004673 intel_runtime_pm_put(dev_priv);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004674
4675 return 0;
4676}
4677
4678static const struct file_operations i915_forcewake_fops = {
4679 .owner = THIS_MODULE,
4680 .open = i915_forcewake_open,
4681 .release = i915_forcewake_release,
4682};
4683
Lyude317eaa92017-02-03 21:18:25 -05004684static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data)
4685{
4686 struct drm_i915_private *dev_priv = m->private;
4687 struct i915_hotplug *hotplug = &dev_priv->hotplug;
4688
4689 seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold);
4690 seq_printf(m, "Detected: %s\n",
4691 yesno(delayed_work_pending(&hotplug->reenable_work)));
4692
4693 return 0;
4694}
4695
4696static ssize_t i915_hpd_storm_ctl_write(struct file *file,
4697 const char __user *ubuf, size_t len,
4698 loff_t *offp)
4699{
4700 struct seq_file *m = file->private_data;
4701 struct drm_i915_private *dev_priv = m->private;
4702 struct i915_hotplug *hotplug = &dev_priv->hotplug;
4703 unsigned int new_threshold;
4704 int i;
4705 char *newline;
4706 char tmp[16];
4707
4708 if (len >= sizeof(tmp))
4709 return -EINVAL;
4710
4711 if (copy_from_user(tmp, ubuf, len))
4712 return -EFAULT;
4713
4714 tmp[len] = '\0';
4715
4716 /* Strip newline, if any */
4717 newline = strchr(tmp, '\n');
4718 if (newline)
4719 *newline = '\0';
4720
4721 if (strcmp(tmp, "reset") == 0)
4722 new_threshold = HPD_STORM_DEFAULT_THRESHOLD;
4723 else if (kstrtouint(tmp, 10, &new_threshold) != 0)
4724 return -EINVAL;
4725
4726 if (new_threshold > 0)
4727 DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n",
4728 new_threshold);
4729 else
4730 DRM_DEBUG_KMS("Disabling HPD storm detection\n");
4731
4732 spin_lock_irq(&dev_priv->irq_lock);
4733 hotplug->hpd_storm_threshold = new_threshold;
4734 /* Reset the HPD storm stats so we don't accidentally trigger a storm */
4735 for_each_hpd_pin(i)
4736 hotplug->stats[i].count = 0;
4737 spin_unlock_irq(&dev_priv->irq_lock);
4738
4739 /* Re-enable hpd immediately if we were in an irq storm */
4740 flush_delayed_work(&dev_priv->hotplug.reenable_work);
4741
4742 return len;
4743}
4744
4745static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file)
4746{
4747 return single_open(file, i915_hpd_storm_ctl_show, inode->i_private);
4748}
4749
4750static const struct file_operations i915_hpd_storm_ctl_fops = {
4751 .owner = THIS_MODULE,
4752 .open = i915_hpd_storm_ctl_open,
4753 .read = seq_read,
4754 .llseek = seq_lseek,
4755 .release = single_release,
4756 .write = i915_hpd_storm_ctl_write
4757};
4758
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01004759static const struct drm_info_list i915_debugfs_list[] = {
Chris Wilson311bd682011-01-13 19:06:50 +00004760 {"i915_capabilities", i915_capabilities, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01004761 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson08c18322011-01-10 00:00:24 +00004762 {"i915_gem_gtt", i915_gem_gtt_info, 0},
Chris Wilson6da84822016-08-15 10:48:44 +01004763 {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1},
Chris Wilson6d2b88852013-08-07 18:30:54 +01004764 {"i915_gem_stolen", i915_gem_stolen_list_info },
Simon Farnsworth4e5359c2010-09-01 17:47:52 +01004765 {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004766 {"i915_gem_request", i915_gem_request_info, 0},
4767 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00004768 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004769 {"i915_gem_interrupt", i915_interrupt_info, 0},
Brad Volkin493018d2014-12-11 12:13:08 -08004770 {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0},
Dave Gordon8b417c22015-08-12 15:43:44 +01004771 {"i915_guc_info", i915_guc_info, 0},
Alex Daifdf5d352015-08-12 15:43:37 +01004772 {"i915_guc_load_status", i915_guc_load_status_info, 0},
Alex Dai4c7e77f2015-08-12 15:43:40 +01004773 {"i915_guc_log_dump", i915_guc_log_dump, 0},
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08004774 {"i915_huc_load_status", i915_huc_load_status_info, 0},
Deepak Sadb4bd12014-03-31 11:30:02 +05304775 {"i915_frequency_info", i915_frequency_info, 0},
Chris Wilsonf6544492015-01-26 18:03:04 +02004776 {"i915_hangcheck_info", i915_hangcheck_info, 0},
Jesse Barnesf97108d2010-01-29 11:27:07 -08004777 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07004778 {"i915_emon_status", i915_emon_status, 0},
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07004779 {"i915_ring_freq_table", i915_ring_freq_table, 0},
Daniel Vetter9a851782015-06-18 10:30:22 +02004780 {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08004781 {"i915_fbc_status", i915_fbc_status, 0},
Paulo Zanoni92d44622013-05-31 16:33:24 -03004782 {"i915_ips_status", i915_ips_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08004783 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01004784 {"i915_opregion", i915_opregion, 0},
Jani Nikulaada8f952015-12-15 13:17:12 +02004785 {"i915_vbt", i915_vbt, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01004786 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Widawskye76d3632011-03-19 18:14:29 -07004787 {"i915_context_status", i915_context_status, 0},
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01004788 {"i915_dump_lrc", i915_dump_lrc, 0},
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02004789 {"i915_forcewake_domains", i915_forcewake_domains, 0},
Daniel Vetterea16a3c2011-12-14 13:57:16 +01004790 {"i915_swizzle_info", i915_swizzle_info, 0},
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01004791 {"i915_ppgtt_info", i915_ppgtt_info, 0},
Ben Widawsky63573eb2013-07-04 11:02:07 -07004792 {"i915_llc", i915_llc, 0},
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03004793 {"i915_edp_psr_status", i915_edp_psr_status, 0},
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02004794 {"i915_sink_crc_eDP1", i915_sink_crc, 0},
Jesse Barnesec013e72013-08-20 10:29:23 +01004795 {"i915_energy_uJ", i915_energy_uJ, 0},
Damien Lespiau6455c872015-06-04 18:23:57 +01004796 {"i915_runtime_pm_status", i915_runtime_pm_status, 0},
Imre Deak1da51582013-11-25 17:15:35 +02004797 {"i915_power_domain_info", i915_power_domain_info, 0},
Damien Lespiaub7cec662015-10-27 14:47:01 +02004798 {"i915_dmc_info", i915_dmc_info, 0},
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08004799 {"i915_display_info", i915_display_info, 0},
Chris Wilson1b365952016-10-04 21:11:31 +01004800 {"i915_engine_info", i915_engine_info, 0},
Ben Widawskye04934c2014-06-30 09:53:42 -07004801 {"i915_semaphore_status", i915_semaphore_status, 0},
Daniel Vetter728e29d2014-06-25 22:01:53 +03004802 {"i915_shared_dplls_info", i915_shared_dplls_info, 0},
Dave Airlie11bed952014-05-12 15:22:27 +10004803 {"i915_dp_mst_info", i915_dp_mst_info, 0},
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01004804 {"i915_wa_registers", i915_wa_registers, 0},
Damien Lespiauc5511e42014-11-04 17:06:51 +00004805 {"i915_ddb_info", i915_ddb_info, 0},
Jeff McGee38732182015-02-13 10:27:54 -06004806 {"i915_sseu_status", i915_sseu_status, 0},
Vandana Kannana54746e2015-03-03 20:53:10 +05304807 {"i915_drrs_status", i915_drrs_status, 0},
Chris Wilson1854d5c2015-04-07 16:20:32 +01004808 {"i915_rps_boost_info", i915_rps_boost_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004809};
Ben Gamari27c202a2009-07-01 22:26:52 -04004810#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05004811
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01004812static const struct i915_debugfs_files {
Daniel Vetter34b96742013-07-04 20:49:44 +02004813 const char *name;
4814 const struct file_operations *fops;
4815} i915_debugfs_files[] = {
4816 {"i915_wedged", &i915_wedged_fops},
4817 {"i915_max_freq", &i915_max_freq_fops},
4818 {"i915_min_freq", &i915_min_freq_fops},
4819 {"i915_cache_sharing", &i915_cache_sharing_fops},
Chris Wilson094f9a52013-09-25 17:34:55 +01004820 {"i915_ring_missed_irq", &i915_ring_missed_irq_fops},
4821 {"i915_ring_test_irq", &i915_ring_test_irq_fops},
Daniel Vetter34b96742013-07-04 20:49:44 +02004822 {"i915_gem_drop_caches", &i915_drop_caches_fops},
Chris Wilson98a2f412016-10-12 10:05:18 +01004823#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
Daniel Vetter34b96742013-07-04 20:49:44 +02004824 {"i915_error_state", &i915_error_state_fops},
Chris Wilson5a4c6f12017-02-14 16:46:11 +00004825 {"i915_gpu_info", &i915_gpu_info_fops},
Chris Wilson98a2f412016-10-12 10:05:18 +01004826#endif
Daniel Vetter34b96742013-07-04 20:49:44 +02004827 {"i915_next_seqno", &i915_next_seqno_fops},
Damien Lespiaubd9db022013-10-15 18:55:36 +01004828 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
Ville Syrjälä369a1342014-01-22 14:36:08 +02004829 {"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
4830 {"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
4831 {"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
Rodrigo Vivida46f932014-08-01 02:04:45 -07004832 {"i915_fbc_false_color", &i915_fbc_fc_fops},
Todd Previteeb3394fa2015-04-18 00:04:19 -07004833 {"i915_dp_test_data", &i915_displayport_test_data_fops},
4834 {"i915_dp_test_type", &i915_displayport_test_type_fops},
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05304835 {"i915_dp_test_active", &i915_displayport_test_active_fops},
Lyude317eaa92017-02-03 21:18:25 -05004836 {"i915_guc_log_control", &i915_guc_log_control_fops},
4837 {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops}
Daniel Vetter34b96742013-07-04 20:49:44 +02004838};
4839
Chris Wilson1dac8912016-06-24 14:00:17 +01004840int i915_debugfs_register(struct drm_i915_private *dev_priv)
Ben Gamari20172632009-02-17 20:08:50 -05004841{
Chris Wilson91c8a322016-07-05 10:40:23 +01004842 struct drm_minor *minor = dev_priv->drm.primary;
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004843 struct dentry *ent;
Daniel Vetter34b96742013-07-04 20:49:44 +02004844 int ret, i;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004845
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004846 ent = debugfs_create_file("i915_forcewake_user", S_IRUSR,
4847 minor->debugfs_root, to_i915(minor->dev),
4848 &i915_forcewake_fops);
4849 if (!ent)
4850 return -ENOMEM;
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004851
Tomeu Vizoso731035f2016-12-12 13:29:48 +01004852 ret = intel_pipe_crc_create(minor);
4853 if (ret)
4854 return ret;
Damien Lespiau07144422013-10-15 18:55:40 +01004855
Daniel Vetter34b96742013-07-04 20:49:44 +02004856 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004857 ent = debugfs_create_file(i915_debugfs_files[i].name,
4858 S_IRUGO | S_IWUSR,
4859 minor->debugfs_root,
4860 to_i915(minor->dev),
Daniel Vetter34b96742013-07-04 20:49:44 +02004861 i915_debugfs_files[i].fops);
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004862 if (!ent)
4863 return -ENOMEM;
Daniel Vetter34b96742013-07-04 20:49:44 +02004864 }
Mika Kuoppala40633212012-12-04 15:12:00 +02004865
Ben Gamari27c202a2009-07-01 22:26:52 -04004866 return drm_debugfs_create_files(i915_debugfs_list,
4867 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05004868 minor->debugfs_root, minor);
4869}
4870
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004871struct dpcd_block {
4872 /* DPCD dump start address. */
4873 unsigned int offset;
4874 /* DPCD dump end address, inclusive. If unset, .size will be used. */
4875 unsigned int end;
4876 /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */
4877 size_t size;
4878 /* Only valid for eDP. */
4879 bool edp;
4880};
4881
4882static const struct dpcd_block i915_dpcd_debug[] = {
4883 { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE },
4884 { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS },
4885 { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 },
4886 { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET },
4887 { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 },
4888 { .offset = DP_SET_POWER },
4889 { .offset = DP_EDP_DPCD_REV },
4890 { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 },
4891 { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB },
4892 { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET },
4893};
4894
4895static int i915_dpcd_show(struct seq_file *m, void *data)
4896{
4897 struct drm_connector *connector = m->private;
4898 struct intel_dp *intel_dp =
4899 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
4900 uint8_t buf[16];
4901 ssize_t err;
4902 int i;
4903
Mika Kuoppala5c1a8872015-05-15 13:09:21 +03004904 if (connector->status != connector_status_connected)
4905 return -ENODEV;
4906
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004907 for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) {
4908 const struct dpcd_block *b = &i915_dpcd_debug[i];
4909 size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1);
4910
4911 if (b->edp &&
4912 connector->connector_type != DRM_MODE_CONNECTOR_eDP)
4913 continue;
4914
4915 /* low tech for now */
4916 if (WARN_ON(size > sizeof(buf)))
4917 continue;
4918
4919 err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size);
4920 if (err <= 0) {
4921 DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n",
4922 size, b->offset, err);
4923 continue;
4924 }
4925
4926 seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf);
kbuild test robotb3f9d7d2015-04-16 18:34:06 +08004927 }
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004928
4929 return 0;
4930}
4931
4932static int i915_dpcd_open(struct inode *inode, struct file *file)
4933{
4934 return single_open(file, i915_dpcd_show, inode->i_private);
4935}
4936
4937static const struct file_operations i915_dpcd_fops = {
4938 .owner = THIS_MODULE,
4939 .open = i915_dpcd_open,
4940 .read = seq_read,
4941 .llseek = seq_lseek,
4942 .release = single_release,
4943};
4944
David Weinehallecbd6782016-08-23 12:23:56 +03004945static int i915_panel_show(struct seq_file *m, void *data)
4946{
4947 struct drm_connector *connector = m->private;
4948 struct intel_dp *intel_dp =
4949 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
4950
4951 if (connector->status != connector_status_connected)
4952 return -ENODEV;
4953
4954 seq_printf(m, "Panel power up delay: %d\n",
4955 intel_dp->panel_power_up_delay);
4956 seq_printf(m, "Panel power down delay: %d\n",
4957 intel_dp->panel_power_down_delay);
4958 seq_printf(m, "Backlight on delay: %d\n",
4959 intel_dp->backlight_on_delay);
4960 seq_printf(m, "Backlight off delay: %d\n",
4961 intel_dp->backlight_off_delay);
4962
4963 return 0;
4964}
4965
4966static int i915_panel_open(struct inode *inode, struct file *file)
4967{
4968 return single_open(file, i915_panel_show, inode->i_private);
4969}
4970
4971static const struct file_operations i915_panel_fops = {
4972 .owner = THIS_MODULE,
4973 .open = i915_panel_open,
4974 .read = seq_read,
4975 .llseek = seq_lseek,
4976 .release = single_release,
4977};
4978
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004979/**
4980 * i915_debugfs_connector_add - add i915 specific connector debugfs files
4981 * @connector: pointer to a registered drm_connector
4982 *
4983 * Cleanup will be done by drm_connector_unregister() through a call to
4984 * drm_debugfs_connector_remove().
4985 *
4986 * Returns 0 on success, negative error codes on error.
4987 */
4988int i915_debugfs_connector_add(struct drm_connector *connector)
4989{
4990 struct dentry *root = connector->debugfs_entry;
4991
4992 /* The connector must have been registered beforehands. */
4993 if (!root)
4994 return -ENODEV;
4995
4996 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
4997 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
David Weinehallecbd6782016-08-23 12:23:56 +03004998 debugfs_create_file("i915_dpcd", S_IRUGO, root,
4999 connector, &i915_dpcd_fops);
5000
5001 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP)
5002 debugfs_create_file("i915_panel_timings", S_IRUGO, root,
5003 connector, &i915_panel_fops);
Jani Nikulaaa7471d2015-04-01 11:15:21 +03005004
5005 return 0;
5006}