blob: 01fdbbf0fd43f34f79755b7a658381f824bc98ea [file] [log] [blame]
Ben Gamari20172632009-02-17 20:08:50 -05001/*
2 * Copyright © 2008 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
25 * Keith Packard <keithp@keithp.com>
26 *
27 */
28
Chris Wilsonf3cd4742009-10-13 22:20:20 +010029#include <linux/debugfs.h>
Chris Wilson6d2b88852013-08-07 18:30:54 +010030#include <linux/list_sort.h>
Simon Farnsworth4e5359c2010-09-01 17:47:52 +010031#include "intel_drv.h"
Ben Gamari20172632009-02-17 20:08:50 -050032
David Weinehall36cdd012016-08-22 13:59:31 +030033static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
34{
35 return to_i915(node->minor->dev);
36}
37
Damien Lespiau497666d2013-10-15 18:55:39 +010038/* As the drm_debugfs_init() routines are called before dev->dev_private is
39 * allocated we need to hook into the minor for release. */
40static int
41drm_add_fake_info_node(struct drm_minor *minor,
42 struct dentry *ent,
43 const void *key)
44{
45 struct drm_info_node *node;
46
47 node = kmalloc(sizeof(*node), GFP_KERNEL);
48 if (node == NULL) {
49 debugfs_remove(ent);
50 return -ENOMEM;
51 }
52
53 node->minor = minor;
54 node->dent = ent;
David Weinehall36cdd012016-08-22 13:59:31 +030055 node->info_ent = (void *)key;
Damien Lespiau497666d2013-10-15 18:55:39 +010056
57 mutex_lock(&minor->debugfs_lock);
58 list_add(&node->list, &minor->debugfs_list);
59 mutex_unlock(&minor->debugfs_lock);
60
61 return 0;
62}
63
Chris Wilson70d39fe2010-08-25 16:03:34 +010064static int i915_capabilities(struct seq_file *m, void *data)
65{
David Weinehall36cdd012016-08-22 13:59:31 +030066 struct drm_i915_private *dev_priv = node_to_i915(m->private);
67 const struct intel_device_info *info = INTEL_INFO(dev_priv);
Chris Wilson70d39fe2010-08-25 16:03:34 +010068
David Weinehall36cdd012016-08-22 13:59:31 +030069 seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv));
Jani Nikula2e0d26f2016-12-01 14:49:55 +020070 seq_printf(m, "platform: %s\n", intel_platform_name(info->platform));
David Weinehall36cdd012016-08-22 13:59:31 +030071 seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv));
Damien Lespiau79fc46d2013-04-23 16:37:17 +010072#define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
Joonas Lahtinen604db652016-10-05 13:50:16 +030073 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
Damien Lespiau79fc46d2013-04-23 16:37:17 +010074#undef PRINT_FLAG
Chris Wilson70d39fe2010-08-25 16:03:34 +010075
76 return 0;
77}
Ben Gamari433e12f2009-02-17 20:08:51 -050078
Imre Deaka7363de2016-05-12 16:18:52 +030079static char get_active_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000080{
Chris Wilson573adb32016-08-04 16:32:39 +010081 return i915_gem_object_is_active(obj) ? '*' : ' ';
Chris Wilsona6172a82009-02-11 14:26:38 +000082}
83
Imre Deaka7363de2016-05-12 16:18:52 +030084static char get_pin_flag(struct drm_i915_gem_object *obj)
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +010085{
86 return obj->pin_display ? 'p' : ' ';
87}
88
Imre Deaka7363de2016-05-12 16:18:52 +030089static char get_tiling_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000090{
Chris Wilson3e510a82016-08-05 10:14:23 +010091 switch (i915_gem_object_get_tiling(obj)) {
Akshay Joshi0206e352011-08-16 15:34:10 -040092 default:
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +010093 case I915_TILING_NONE: return ' ';
94 case I915_TILING_X: return 'X';
95 case I915_TILING_Y: return 'Y';
Akshay Joshi0206e352011-08-16 15:34:10 -040096 }
Chris Wilsona6172a82009-02-11 14:26:38 +000097}
98
Imre Deaka7363de2016-05-12 16:18:52 +030099static char get_global_flag(struct drm_i915_gem_object *obj)
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700100{
Chris Wilson275f0392016-10-24 13:42:14 +0100101 return !list_empty(&obj->userfault_link) ? 'g' : ' ';
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100102}
103
Imre Deaka7363de2016-05-12 16:18:52 +0300104static char get_pin_mapped_flag(struct drm_i915_gem_object *obj)
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100105{
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100106 return obj->mm.mapping ? 'M' : ' ';
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700107}
108
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100109static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
110{
111 u64 size = 0;
112 struct i915_vma *vma;
113
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000114 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson3272db52016-08-04 16:32:32 +0100115 if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node))
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100116 size += vma->node.size;
117 }
118
119 return size;
120}
121
Chris Wilson37811fc2010-08-25 22:45:57 +0100122static void
123describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
124{
Chris Wilsonb4716182015-04-27 13:41:17 +0100125 struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000126 struct intel_engine_cs *engine;
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700127 struct i915_vma *vma;
Chris Wilsonfaf5bf02016-08-04 16:32:37 +0100128 unsigned int frontbuffer_bits;
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800129 int pin_count = 0;
130
Chris Wilson188c1ab2016-04-03 14:14:20 +0100131 lockdep_assert_held(&obj->base.dev->struct_mutex);
132
Chris Wilsond07f0e52016-10-28 13:58:44 +0100133 seq_printf(m, "%pK: %c%c%c%c%c %8zdKiB %02x %02x %s%s%s",
Chris Wilson37811fc2010-08-25 22:45:57 +0100134 &obj->base,
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100135 get_active_flag(obj),
Chris Wilson37811fc2010-08-25 22:45:57 +0100136 get_pin_flag(obj),
137 get_tiling_flag(obj),
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700138 get_global_flag(obj),
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100139 get_pin_mapped_flag(obj),
Eric Anholta05a5862011-12-20 08:54:15 -0800140 obj->base.size / 1024,
Chris Wilson37811fc2010-08-25 22:45:57 +0100141 obj->base.read_domains,
Chris Wilsond07f0e52016-10-28 13:58:44 +0100142 obj->base.write_domain,
David Weinehall36cdd012016-08-22 13:59:31 +0300143 i915_cache_level_str(dev_priv, obj->cache_level),
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100144 obj->mm.dirty ? " dirty" : "",
145 obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : "");
Chris Wilson37811fc2010-08-25 22:45:57 +0100146 if (obj->base.name)
147 seq_printf(m, " (name: %d)", obj->base.name);
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000148 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson20dfbde2016-08-04 16:32:30 +0100149 if (i915_vma_is_pinned(vma))
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800150 pin_count++;
Dan Carpenterba0635ff2015-02-25 16:17:48 +0300151 }
152 seq_printf(m, " (pinned x %d)", pin_count);
Chris Wilsoncc98b412013-08-09 12:25:09 +0100153 if (obj->pin_display)
154 seq_printf(m, " (display)");
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000155 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson15717de2016-08-04 07:52:26 +0100156 if (!drm_mm_node_allocated(&vma->node))
157 continue;
158
Tvrtko Ursulin8d2fdc32015-05-27 10:52:32 +0100159 seq_printf(m, " (%sgtt offset: %08llx, size: %08llx",
Chris Wilson3272db52016-08-04 16:32:32 +0100160 i915_vma_is_ggtt(vma) ? "g" : "pp",
Tvrtko Ursulin8d2fdc32015-05-27 10:52:32 +0100161 vma->node.start, vma->node.size);
Chris Wilson21976852017-01-12 11:21:08 +0000162 if (i915_vma_is_ggtt(vma)) {
163 switch (vma->ggtt_view.type) {
164 case I915_GGTT_VIEW_NORMAL:
165 seq_puts(m, ", normal");
166 break;
167
168 case I915_GGTT_VIEW_PARTIAL:
169 seq_printf(m, ", partial [%08llx+%x]",
Chris Wilson8bab11932017-01-14 00:28:25 +0000170 vma->ggtt_view.partial.offset << PAGE_SHIFT,
171 vma->ggtt_view.partial.size << PAGE_SHIFT);
Chris Wilson21976852017-01-12 11:21:08 +0000172 break;
173
174 case I915_GGTT_VIEW_ROTATED:
175 seq_printf(m, ", rotated [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]",
Chris Wilson8bab11932017-01-14 00:28:25 +0000176 vma->ggtt_view.rotated.plane[0].width,
177 vma->ggtt_view.rotated.plane[0].height,
178 vma->ggtt_view.rotated.plane[0].stride,
179 vma->ggtt_view.rotated.plane[0].offset,
180 vma->ggtt_view.rotated.plane[1].width,
181 vma->ggtt_view.rotated.plane[1].height,
182 vma->ggtt_view.rotated.plane[1].stride,
183 vma->ggtt_view.rotated.plane[1].offset);
Chris Wilson21976852017-01-12 11:21:08 +0000184 break;
185
186 default:
187 MISSING_CASE(vma->ggtt_view.type);
188 break;
189 }
190 }
Chris Wilson49ef5292016-08-18 17:17:00 +0100191 if (vma->fence)
192 seq_printf(m, " , fence: %d%s",
193 vma->fence->id,
194 i915_gem_active_isset(&vma->last_fence) ? "*" : "");
Chris Wilson596c5922016-02-26 11:03:20 +0000195 seq_puts(m, ")");
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700196 }
Chris Wilsonc1ad11f2012-11-15 11:32:21 +0000197 if (obj->stolen)
Thierry Reding440fd522015-01-23 09:05:06 +0100198 seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
Chris Wilson27c01aa2016-08-04 07:52:30 +0100199
Chris Wilsond07f0e52016-10-28 13:58:44 +0100200 engine = i915_gem_object_last_write_engine(obj);
Chris Wilson27c01aa2016-08-04 07:52:30 +0100201 if (engine)
202 seq_printf(m, " (%s)", engine->name);
203
Chris Wilsonfaf5bf02016-08-04 16:32:37 +0100204 frontbuffer_bits = atomic_read(&obj->frontbuffer_bits);
205 if (frontbuffer_bits)
206 seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits);
Chris Wilson37811fc2010-08-25 22:45:57 +0100207}
208
Chris Wilson6d2b88852013-08-07 18:30:54 +0100209static int obj_rank_by_stolen(void *priv,
210 struct list_head *A, struct list_head *B)
211{
212 struct drm_i915_gem_object *a =
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200213 container_of(A, struct drm_i915_gem_object, obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100214 struct drm_i915_gem_object *b =
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200215 container_of(B, struct drm_i915_gem_object, obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100216
Rasmus Villemoes2d05fa12015-09-28 23:08:50 +0200217 if (a->stolen->start < b->stolen->start)
218 return -1;
219 if (a->stolen->start > b->stolen->start)
220 return 1;
221 return 0;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100222}
223
224static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
225{
David Weinehall36cdd012016-08-22 13:59:31 +0300226 struct drm_i915_private *dev_priv = node_to_i915(m->private);
227 struct drm_device *dev = &dev_priv->drm;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100228 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300229 u64 total_obj_size, total_gtt_size;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100230 LIST_HEAD(stolen);
231 int count, ret;
232
233 ret = mutex_lock_interruptible(&dev->struct_mutex);
234 if (ret)
235 return ret;
236
237 total_obj_size = total_gtt_size = count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200238 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilson6d2b88852013-08-07 18:30:54 +0100239 if (obj->stolen == NULL)
240 continue;
241
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200242 list_add(&obj->obj_exec_link, &stolen);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100243
244 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100245 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100246 count++;
247 }
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200248 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) {
Chris Wilson6d2b88852013-08-07 18:30:54 +0100249 if (obj->stolen == NULL)
250 continue;
251
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200252 list_add(&obj->obj_exec_link, &stolen);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100253
254 total_obj_size += obj->base.size;
255 count++;
256 }
257 list_sort(NULL, &stolen, obj_rank_by_stolen);
258 seq_puts(m, "Stolen:\n");
259 while (!list_empty(&stolen)) {
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200260 obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100261 seq_puts(m, " ");
262 describe_obj(m, obj);
263 seq_putc(m, '\n');
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200264 list_del_init(&obj->obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100265 }
266 mutex_unlock(&dev->struct_mutex);
267
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300268 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
Chris Wilson6d2b88852013-08-07 18:30:54 +0100269 count, total_obj_size, total_gtt_size);
270 return 0;
271}
272
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100273struct file_stats {
Chris Wilson6313c202014-03-19 13:45:45 +0000274 struct drm_i915_file_private *file_priv;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300275 unsigned long count;
276 u64 total, unbound;
277 u64 global, shared;
278 u64 active, inactive;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100279};
280
281static int per_file_stats(int id, void *ptr, void *data)
282{
283 struct drm_i915_gem_object *obj = ptr;
284 struct file_stats *stats = data;
Chris Wilson6313c202014-03-19 13:45:45 +0000285 struct i915_vma *vma;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100286
287 stats->count++;
288 stats->total += obj->base.size;
Chris Wilson15717de2016-08-04 07:52:26 +0100289 if (!obj->bind_count)
290 stats->unbound += obj->base.size;
Chris Wilsonc67a17e2014-03-19 13:45:46 +0000291 if (obj->base.name || obj->base.dma_buf)
292 stats->shared += obj->base.size;
293
Chris Wilson894eeec2016-08-04 07:52:20 +0100294 list_for_each_entry(vma, &obj->vma_list, obj_link) {
295 if (!drm_mm_node_allocated(&vma->node))
296 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000297
Chris Wilson3272db52016-08-04 16:32:32 +0100298 if (i915_vma_is_ggtt(vma)) {
Chris Wilson894eeec2016-08-04 07:52:20 +0100299 stats->global += vma->node.size;
300 } else {
301 struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm);
Chris Wilson6313c202014-03-19 13:45:45 +0000302
Chris Wilson2bfa9962016-08-04 07:52:25 +0100303 if (ppgtt->base.file != stats->file_priv)
Chris Wilson6313c202014-03-19 13:45:45 +0000304 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000305 }
Chris Wilson894eeec2016-08-04 07:52:20 +0100306
Chris Wilsonb0decaf2016-08-04 07:52:44 +0100307 if (i915_vma_is_active(vma))
Chris Wilson894eeec2016-08-04 07:52:20 +0100308 stats->active += vma->node.size;
309 else
310 stats->inactive += vma->node.size;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100311 }
312
313 return 0;
314}
315
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100316#define print_file_stats(m, name, stats) do { \
317 if (stats.count) \
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300318 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 +0100319 name, \
320 stats.count, \
321 stats.total, \
322 stats.active, \
323 stats.inactive, \
324 stats.global, \
325 stats.shared, \
326 stats.unbound); \
327} while (0)
Brad Volkin493018d2014-12-11 12:13:08 -0800328
329static void print_batch_pool_stats(struct seq_file *m,
330 struct drm_i915_private *dev_priv)
331{
332 struct drm_i915_gem_object *obj;
333 struct file_stats stats;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000334 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530335 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000336 int j;
Brad Volkin493018d2014-12-11 12:13:08 -0800337
338 memset(&stats, 0, sizeof(stats));
339
Akash Goel3b3f1652016-10-13 22:44:48 +0530340 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000341 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100342 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000343 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100344 batch_pool_link)
345 per_file_stats(0, obj, &stats);
346 }
Chris Wilson06fbca72015-04-07 16:20:36 +0100347 }
Brad Volkin493018d2014-12-11 12:13:08 -0800348
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100349 print_file_stats(m, "[k]batch pool", stats);
Brad Volkin493018d2014-12-11 12:13:08 -0800350}
351
Chris Wilson15da9562016-05-24 14:53:43 +0100352static int per_file_ctx_stats(int id, void *ptr, void *data)
353{
354 struct i915_gem_context *ctx = ptr;
355 int n;
356
357 for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) {
358 if (ctx->engine[n].state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +0100359 per_file_stats(0, ctx->engine[n].state->obj, data);
Chris Wilsondca33ec2016-08-02 22:50:20 +0100360 if (ctx->engine[n].ring)
Chris Wilson57e88532016-08-15 10:48:57 +0100361 per_file_stats(0, ctx->engine[n].ring->vma->obj, data);
Chris Wilson15da9562016-05-24 14:53:43 +0100362 }
363
364 return 0;
365}
366
367static void print_context_stats(struct seq_file *m,
368 struct drm_i915_private *dev_priv)
369{
David Weinehall36cdd012016-08-22 13:59:31 +0300370 struct drm_device *dev = &dev_priv->drm;
Chris Wilson15da9562016-05-24 14:53:43 +0100371 struct file_stats stats;
372 struct drm_file *file;
373
374 memset(&stats, 0, sizeof(stats));
375
David Weinehall36cdd012016-08-22 13:59:31 +0300376 mutex_lock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100377 if (dev_priv->kernel_context)
378 per_file_ctx_stats(0, dev_priv->kernel_context, &stats);
379
David Weinehall36cdd012016-08-22 13:59:31 +0300380 list_for_each_entry(file, &dev->filelist, lhead) {
Chris Wilson15da9562016-05-24 14:53:43 +0100381 struct drm_i915_file_private *fpriv = file->driver_priv;
382 idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats);
383 }
David Weinehall36cdd012016-08-22 13:59:31 +0300384 mutex_unlock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100385
386 print_file_stats(m, "[k]contexts", stats);
387}
388
David Weinehall36cdd012016-08-22 13:59:31 +0300389static int i915_gem_object_info(struct seq_file *m, void *data)
Chris Wilson73aa8082010-09-30 11:46:12 +0100390{
David Weinehall36cdd012016-08-22 13:59:31 +0300391 struct drm_i915_private *dev_priv = node_to_i915(m->private);
392 struct drm_device *dev = &dev_priv->drm;
Joonas Lahtinen72e96d62016-03-30 16:57:10 +0300393 struct i915_ggtt *ggtt = &dev_priv->ggtt;
Chris Wilson2bd160a2016-08-15 10:48:45 +0100394 u32 count, mapped_count, purgeable_count, dpy_count;
395 u64 size, mapped_size, purgeable_size, dpy_size;
Chris Wilson6299f992010-11-24 12:23:44 +0000396 struct drm_i915_gem_object *obj;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100397 struct drm_file *file;
Chris Wilson73aa8082010-09-30 11:46:12 +0100398 int ret;
399
400 ret = mutex_lock_interruptible(&dev->struct_mutex);
401 if (ret)
402 return ret;
403
Chris Wilson3ef7f222016-10-18 13:02:48 +0100404 seq_printf(m, "%u objects, %llu bytes\n",
Chris Wilson6299f992010-11-24 12:23:44 +0000405 dev_priv->mm.object_count,
406 dev_priv->mm.object_memory);
407
Chris Wilson1544c422016-08-15 13:18:16 +0100408 size = count = 0;
409 mapped_size = mapped_count = 0;
410 purgeable_size = purgeable_count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200411 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100412 size += obj->base.size;
413 ++count;
Chris Wilson6c085a72012-08-20 11:40:46 +0200414
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100415 if (obj->mm.madv == I915_MADV_DONTNEED) {
Chris Wilsonb7abb712012-08-20 11:33:30 +0200416 purgeable_size += obj->base.size;
417 ++purgeable_count;
418 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100419
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100420 if (obj->mm.mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100421 mapped_count++;
422 mapped_size += obj->base.size;
Tvrtko Ursulinbe19b102016-04-15 11:34:53 +0100423 }
Chris Wilson6299f992010-11-24 12:23:44 +0000424 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100425 seq_printf(m, "%u unbound objects, %llu bytes\n", count, size);
426
427 size = count = dpy_size = dpy_count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200428 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100429 size += obj->base.size;
430 ++count;
431
432 if (obj->pin_display) {
433 dpy_size += obj->base.size;
434 ++dpy_count;
435 }
436
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100437 if (obj->mm.madv == I915_MADV_DONTNEED) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100438 purgeable_size += obj->base.size;
439 ++purgeable_count;
440 }
441
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100442 if (obj->mm.mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100443 mapped_count++;
444 mapped_size += obj->base.size;
445 }
446 }
447 seq_printf(m, "%u bound objects, %llu bytes\n",
448 count, size);
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300449 seq_printf(m, "%u purgeable objects, %llu bytes\n",
Chris Wilsonb7abb712012-08-20 11:33:30 +0200450 purgeable_count, purgeable_size);
Chris Wilson2bd160a2016-08-15 10:48:45 +0100451 seq_printf(m, "%u mapped objects, %llu bytes\n",
452 mapped_count, mapped_size);
453 seq_printf(m, "%u display objects (pinned), %llu bytes\n",
454 dpy_count, dpy_size);
Chris Wilson6299f992010-11-24 12:23:44 +0000455
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300456 seq_printf(m, "%llu [%llu] gtt total\n",
Joonas Lahtinen72e96d62016-03-30 16:57:10 +0300457 ggtt->base.total, ggtt->mappable_end - ggtt->base.start);
Chris Wilson73aa8082010-09-30 11:46:12 +0100458
Damien Lespiau267f0c92013-06-24 22:59:48 +0100459 seq_putc(m, '\n');
Brad Volkin493018d2014-12-11 12:13:08 -0800460 print_batch_pool_stats(m, dev_priv);
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200461 mutex_unlock(&dev->struct_mutex);
462
463 mutex_lock(&dev->filelist_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100464 print_context_stats(m, dev_priv);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100465 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
466 struct file_stats stats;
Chris Wilsonc84455b2016-08-15 10:49:08 +0100467 struct drm_i915_file_private *file_priv = file->driver_priv;
468 struct drm_i915_gem_request *request;
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900469 struct task_struct *task;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100470
471 memset(&stats, 0, sizeof(stats));
Chris Wilson6313c202014-03-19 13:45:45 +0000472 stats.file_priv = file->driver_priv;
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100473 spin_lock(&file->table_lock);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100474 idr_for_each(&file->object_idr, per_file_stats, &stats);
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100475 spin_unlock(&file->table_lock);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900476 /*
477 * Although we have a valid reference on file->pid, that does
478 * not guarantee that the task_struct who called get_pid() is
479 * still alive (e.g. get_pid(current) => fork() => exit()).
480 * Therefore, we need to protect this ->comm access using RCU.
481 */
Chris Wilsonc84455b2016-08-15 10:49:08 +0100482 mutex_lock(&dev->struct_mutex);
483 request = list_first_entry_or_null(&file_priv->mm.request_list,
484 struct drm_i915_gem_request,
485 client_list);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900486 rcu_read_lock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100487 task = pid_task(request && request->ctx->pid ?
488 request->ctx->pid : file->pid,
489 PIDTYPE_PID);
Brad Volkin493018d2014-12-11 12:13:08 -0800490 print_file_stats(m, task ? task->comm : "<unknown>", stats);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900491 rcu_read_unlock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100492 mutex_unlock(&dev->struct_mutex);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100493 }
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200494 mutex_unlock(&dev->filelist_mutex);
Chris Wilson73aa8082010-09-30 11:46:12 +0100495
496 return 0;
497}
498
Damien Lespiauaee56cf2013-06-24 22:59:49 +0100499static int i915_gem_gtt_info(struct seq_file *m, void *data)
Chris Wilson08c18322011-01-10 00:00:24 +0000500{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100501 struct drm_info_node *node = m->private;
David Weinehall36cdd012016-08-22 13:59:31 +0300502 struct drm_i915_private *dev_priv = node_to_i915(node);
503 struct drm_device *dev = &dev_priv->drm;
Chris Wilson5f4b0912016-08-19 12:56:25 +0100504 bool show_pin_display_only = !!node->info_ent->data;
Chris Wilson08c18322011-01-10 00:00:24 +0000505 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300506 u64 total_obj_size, total_gtt_size;
Chris Wilson08c18322011-01-10 00:00:24 +0000507 int count, ret;
508
509 ret = mutex_lock_interruptible(&dev->struct_mutex);
510 if (ret)
511 return ret;
512
513 total_obj_size = total_gtt_size = count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200514 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilson6da84822016-08-15 10:48:44 +0100515 if (show_pin_display_only && !obj->pin_display)
Chris Wilson1b502472012-04-24 15:47:30 +0100516 continue;
517
Damien Lespiau267f0c92013-06-24 22:59:48 +0100518 seq_puts(m, " ");
Chris Wilson08c18322011-01-10 00:00:24 +0000519 describe_obj(m, obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100520 seq_putc(m, '\n');
Chris Wilson08c18322011-01-10 00:00:24 +0000521 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100522 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilson08c18322011-01-10 00:00:24 +0000523 count++;
524 }
525
526 mutex_unlock(&dev->struct_mutex);
527
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300528 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
Chris Wilson08c18322011-01-10 00:00:24 +0000529 count, total_obj_size, total_gtt_size);
530
531 return 0;
532}
533
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100534static int i915_gem_pageflip_info(struct seq_file *m, void *data)
535{
David Weinehall36cdd012016-08-22 13:59:31 +0300536 struct drm_i915_private *dev_priv = node_to_i915(m->private);
537 struct drm_device *dev = &dev_priv->drm;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100538 struct intel_crtc *crtc;
Daniel Vetter8a270eb2014-06-17 22:34:37 +0200539 int ret;
540
541 ret = mutex_lock_interruptible(&dev->struct_mutex);
542 if (ret)
543 return ret;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100544
Damien Lespiaud3fcc802014-05-13 23:32:22 +0100545 for_each_intel_crtc(dev, crtc) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800546 const char pipe = pipe_name(crtc->pipe);
547 const char plane = plane_name(crtc->plane);
Maarten Lankhorst51cbaf02016-05-17 15:07:49 +0200548 struct intel_flip_work *work;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100549
Daniel Vetter5e2d7af2014-09-15 14:55:22 +0200550 spin_lock_irq(&dev->event_lock);
Daniel Vetter5a21b662016-05-24 17:13:53 +0200551 work = crtc->flip_work;
552 if (work == NULL) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800553 seq_printf(m, "No flip due on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100554 pipe, plane);
555 } else {
Daniel Vetter5a21b662016-05-24 17:13:53 +0200556 u32 pending;
557 u32 addr;
558
559 pending = atomic_read(&work->pending);
560 if (pending) {
561 seq_printf(m, "Flip ioctl preparing on pipe %c (plane %c)\n",
562 pipe, plane);
563 } else {
564 seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
565 pipe, plane);
566 }
567 if (work->flip_queued_req) {
Joonas Lahtinen24327f82016-11-08 09:11:48 +0200568 struct intel_engine_cs *engine = work->flip_queued_req->engine;
Daniel Vetter5a21b662016-05-24 17:13:53 +0200569
Chris Wilson312c3c42016-11-24 14:47:50 +0000570 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 +0200571 engine->name,
Joonas Lahtinen24327f82016-11-08 09:11:48 +0200572 work->flip_queued_req->global_seqno,
Chris Wilson312c3c42016-11-24 14:47:50 +0000573 intel_engine_last_submit(engine),
Chris Wilson1b7744e2016-07-01 17:23:17 +0100574 intel_engine_get_seqno(engine),
Chris Wilsonf69a02c2016-07-01 17:23:16 +0100575 i915_gem_request_completed(work->flip_queued_req));
Daniel Vetter5a21b662016-05-24 17:13:53 +0200576 } else
577 seq_printf(m, "Flip not associated with any ring\n");
578 seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n",
579 work->flip_queued_vblank,
580 work->flip_ready_vblank,
581 intel_crtc_get_vblank_counter(crtc));
582 seq_printf(m, "%d prepares\n", atomic_read(&work->pending));
583
David Weinehall36cdd012016-08-22 13:59:31 +0300584 if (INTEL_GEN(dev_priv) >= 4)
Daniel Vetter5a21b662016-05-24 17:13:53 +0200585 addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane)));
586 else
587 addr = I915_READ(DSPADDR(crtc->plane));
588 seq_printf(m, "Current scanout address 0x%08x\n", addr);
589
590 if (work->pending_flip_obj) {
591 seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset);
592 seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100593 }
594 }
Daniel Vetter5e2d7af2014-09-15 14:55:22 +0200595 spin_unlock_irq(&dev->event_lock);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100596 }
597
Daniel Vetter8a270eb2014-06-17 22:34:37 +0200598 mutex_unlock(&dev->struct_mutex);
599
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100600 return 0;
601}
602
Brad Volkin493018d2014-12-11 12:13:08 -0800603static int i915_gem_batch_pool_info(struct seq_file *m, void *data)
604{
David Weinehall36cdd012016-08-22 13:59:31 +0300605 struct drm_i915_private *dev_priv = node_to_i915(m->private);
606 struct drm_device *dev = &dev_priv->drm;
Brad Volkin493018d2014-12-11 12:13:08 -0800607 struct drm_i915_gem_object *obj;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000608 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530609 enum intel_engine_id id;
Chris Wilson8d9d5742015-04-07 16:20:38 +0100610 int total = 0;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000611 int ret, j;
Brad Volkin493018d2014-12-11 12:13:08 -0800612
613 ret = mutex_lock_interruptible(&dev->struct_mutex);
614 if (ret)
615 return ret;
616
Akash Goel3b3f1652016-10-13 22:44:48 +0530617 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000618 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100619 int count;
620
621 count = 0;
622 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000623 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100624 batch_pool_link)
625 count++;
626 seq_printf(m, "%s cache[%d]: %d objects\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000627 engine->name, j, count);
Chris Wilson8d9d5742015-04-07 16:20:38 +0100628
629 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000630 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100631 batch_pool_link) {
632 seq_puts(m, " ");
633 describe_obj(m, obj);
634 seq_putc(m, '\n');
635 }
636
637 total += count;
Chris Wilson06fbca72015-04-07 16:20:36 +0100638 }
Brad Volkin493018d2014-12-11 12:13:08 -0800639 }
640
Chris Wilson8d9d5742015-04-07 16:20:38 +0100641 seq_printf(m, "total: %d\n", total);
Brad Volkin493018d2014-12-11 12:13:08 -0800642
643 mutex_unlock(&dev->struct_mutex);
644
645 return 0;
646}
647
Chris Wilson1b365952016-10-04 21:11:31 +0100648static void print_request(struct seq_file *m,
649 struct drm_i915_gem_request *rq,
650 const char *prefix)
651{
Chris Wilson20311bd2016-11-14 20:41:03 +0000652 seq_printf(m, "%s%x [%x:%x] prio=%d @ %dms: %s\n", prefix,
Chris Wilson65e47602016-10-28 13:58:49 +0100653 rq->global_seqno, rq->ctx->hw_id, rq->fence.seqno,
Chris Wilson20311bd2016-11-14 20:41:03 +0000654 rq->priotree.priority,
Chris Wilson1b365952016-10-04 21:11:31 +0100655 jiffies_to_msecs(jiffies - rq->emitted_jiffies),
Chris Wilson562f5d42016-10-28 13:58:54 +0100656 rq->timeline->common->name);
Chris Wilson1b365952016-10-04 21:11:31 +0100657}
658
Ben Gamari20172632009-02-17 20:08:50 -0500659static int i915_gem_request_info(struct seq_file *m, void *data)
660{
David Weinehall36cdd012016-08-22 13:59:31 +0300661 struct drm_i915_private *dev_priv = node_to_i915(m->private);
662 struct drm_device *dev = &dev_priv->drm;
Daniel Vettereed29a52015-05-21 14:21:25 +0200663 struct drm_i915_gem_request *req;
Akash Goel3b3f1652016-10-13 22:44:48 +0530664 struct intel_engine_cs *engine;
665 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000666 int ret, any;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100667
668 ret = mutex_lock_interruptible(&dev->struct_mutex);
669 if (ret)
670 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500671
Chris Wilson2d1070b2015-04-01 10:36:56 +0100672 any = 0;
Akash Goel3b3f1652016-10-13 22:44:48 +0530673 for_each_engine(engine, dev_priv, id) {
Chris Wilson2d1070b2015-04-01 10:36:56 +0100674 int count;
675
676 count = 0;
Chris Wilson73cb9702016-10-28 13:58:46 +0100677 list_for_each_entry(req, &engine->timeline->requests, link)
Chris Wilson2d1070b2015-04-01 10:36:56 +0100678 count++;
679 if (count == 0)
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100680 continue;
681
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000682 seq_printf(m, "%s requests: %d\n", engine->name, count);
Chris Wilson73cb9702016-10-28 13:58:46 +0100683 list_for_each_entry(req, &engine->timeline->requests, link)
Chris Wilson1b365952016-10-04 21:11:31 +0100684 print_request(m, req, " ");
Chris Wilson2d1070b2015-04-01 10:36:56 +0100685
686 any++;
Ben Gamari20172632009-02-17 20:08:50 -0500687 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100688 mutex_unlock(&dev->struct_mutex);
689
Chris Wilson2d1070b2015-04-01 10:36:56 +0100690 if (any == 0)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100691 seq_puts(m, "No requests\n");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100692
Ben Gamari20172632009-02-17 20:08:50 -0500693 return 0;
694}
695
Chris Wilsonb2223492010-10-27 15:27:33 +0100696static void i915_ring_seqno_info(struct seq_file *m,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +0000697 struct intel_engine_cs *engine)
Chris Wilsonb2223492010-10-27 15:27:33 +0100698{
Chris Wilson688e6c72016-07-01 17:23:15 +0100699 struct intel_breadcrumbs *b = &engine->breadcrumbs;
700 struct rb_node *rb;
701
Chris Wilson12471ba2016-04-09 10:57:55 +0100702 seq_printf(m, "Current sequence (%s): %x\n",
Chris Wilson1b7744e2016-07-01 17:23:17 +0100703 engine->name, intel_engine_get_seqno(engine));
Chris Wilson688e6c72016-07-01 17:23:15 +0100704
Chris Wilsonf6168e32016-10-28 13:58:55 +0100705 spin_lock_irq(&b->lock);
Chris Wilson688e6c72016-07-01 17:23:15 +0100706 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +0800707 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson688e6c72016-07-01 17:23:15 +0100708
709 seq_printf(m, "Waiting (%s): %s [%d] on %x\n",
710 engine->name, w->tsk->comm, w->tsk->pid, w->seqno);
711 }
Chris Wilsonf6168e32016-10-28 13:58:55 +0100712 spin_unlock_irq(&b->lock);
Chris Wilsonb2223492010-10-27 15:27:33 +0100713}
714
Ben Gamari20172632009-02-17 20:08:50 -0500715static int i915_gem_seqno_info(struct seq_file *m, void *data)
716{
David Weinehall36cdd012016-08-22 13:59:31 +0300717 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000718 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530719 enum intel_engine_id id;
Ben Gamari20172632009-02-17 20:08:50 -0500720
Akash Goel3b3f1652016-10-13 22:44:48 +0530721 for_each_engine(engine, dev_priv, id)
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000722 i915_ring_seqno_info(m, engine);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100723
Ben Gamari20172632009-02-17 20:08:50 -0500724 return 0;
725}
726
727
728static int i915_interrupt_info(struct seq_file *m, void *data)
729{
David Weinehall36cdd012016-08-22 13:59:31 +0300730 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000731 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530732 enum intel_engine_id id;
Chris Wilson4bb05042016-09-03 07:53:43 +0100733 int i, pipe;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100734
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200735 intel_runtime_pm_get(dev_priv);
Ben Gamari20172632009-02-17 20:08:50 -0500736
David Weinehall36cdd012016-08-22 13:59:31 +0300737 if (IS_CHERRYVIEW(dev_priv)) {
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300738 seq_printf(m, "Master Interrupt Control:\t%08x\n",
739 I915_READ(GEN8_MASTER_IRQ));
740
741 seq_printf(m, "Display IER:\t%08x\n",
742 I915_READ(VLV_IER));
743 seq_printf(m, "Display IIR:\t%08x\n",
744 I915_READ(VLV_IIR));
745 seq_printf(m, "Display IIR_RW:\t%08x\n",
746 I915_READ(VLV_IIR_RW));
747 seq_printf(m, "Display IMR:\t%08x\n",
748 I915_READ(VLV_IMR));
Chris Wilson9c870d02016-10-24 13:42:15 +0100749 for_each_pipe(dev_priv, pipe) {
750 enum intel_display_power_domain power_domain;
751
752 power_domain = POWER_DOMAIN_PIPE(pipe);
753 if (!intel_display_power_get_if_enabled(dev_priv,
754 power_domain)) {
755 seq_printf(m, "Pipe %c power disabled\n",
756 pipe_name(pipe));
757 continue;
758 }
759
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300760 seq_printf(m, "Pipe %c stat:\t%08x\n",
761 pipe_name(pipe),
762 I915_READ(PIPESTAT(pipe)));
763
Chris Wilson9c870d02016-10-24 13:42:15 +0100764 intel_display_power_put(dev_priv, power_domain);
765 }
766
767 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300768 seq_printf(m, "Port hotplug:\t%08x\n",
769 I915_READ(PORT_HOTPLUG_EN));
770 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
771 I915_READ(VLV_DPFLIPSTAT));
772 seq_printf(m, "DPINVGTT:\t%08x\n",
773 I915_READ(DPINVGTT));
Chris Wilson9c870d02016-10-24 13:42:15 +0100774 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300775
776 for (i = 0; i < 4; i++) {
777 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
778 i, I915_READ(GEN8_GT_IMR(i)));
779 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
780 i, I915_READ(GEN8_GT_IIR(i)));
781 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
782 i, I915_READ(GEN8_GT_IER(i)));
783 }
784
785 seq_printf(m, "PCU interrupt mask:\t%08x\n",
786 I915_READ(GEN8_PCU_IMR));
787 seq_printf(m, "PCU interrupt identity:\t%08x\n",
788 I915_READ(GEN8_PCU_IIR));
789 seq_printf(m, "PCU interrupt enable:\t%08x\n",
790 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300791 } else if (INTEL_GEN(dev_priv) >= 8) {
Ben Widawskya123f152013-11-02 21:07:10 -0700792 seq_printf(m, "Master Interrupt Control:\t%08x\n",
793 I915_READ(GEN8_MASTER_IRQ));
794
795 for (i = 0; i < 4; i++) {
796 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
797 i, I915_READ(GEN8_GT_IMR(i)));
798 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
799 i, I915_READ(GEN8_GT_IIR(i)));
800 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
801 i, I915_READ(GEN8_GT_IER(i)));
802 }
803
Damien Lespiau055e3932014-08-18 13:49:10 +0100804 for_each_pipe(dev_priv, pipe) {
Imre Deake1296492016-02-12 18:55:17 +0200805 enum intel_display_power_domain power_domain;
806
807 power_domain = POWER_DOMAIN_PIPE(pipe);
808 if (!intel_display_power_get_if_enabled(dev_priv,
809 power_domain)) {
Paulo Zanoni22c59962014-08-08 17:45:32 -0300810 seq_printf(m, "Pipe %c power disabled\n",
811 pipe_name(pipe));
812 continue;
813 }
Ben Widawskya123f152013-11-02 21:07:10 -0700814 seq_printf(m, "Pipe %c IMR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000815 pipe_name(pipe),
816 I915_READ(GEN8_DE_PIPE_IMR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700817 seq_printf(m, "Pipe %c IIR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000818 pipe_name(pipe),
819 I915_READ(GEN8_DE_PIPE_IIR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700820 seq_printf(m, "Pipe %c IER:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000821 pipe_name(pipe),
822 I915_READ(GEN8_DE_PIPE_IER(pipe)));
Imre Deake1296492016-02-12 18:55:17 +0200823
824 intel_display_power_put(dev_priv, power_domain);
Ben Widawskya123f152013-11-02 21:07:10 -0700825 }
826
827 seq_printf(m, "Display Engine port interrupt mask:\t%08x\n",
828 I915_READ(GEN8_DE_PORT_IMR));
829 seq_printf(m, "Display Engine port interrupt identity:\t%08x\n",
830 I915_READ(GEN8_DE_PORT_IIR));
831 seq_printf(m, "Display Engine port interrupt enable:\t%08x\n",
832 I915_READ(GEN8_DE_PORT_IER));
833
834 seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n",
835 I915_READ(GEN8_DE_MISC_IMR));
836 seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n",
837 I915_READ(GEN8_DE_MISC_IIR));
838 seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n",
839 I915_READ(GEN8_DE_MISC_IER));
840
841 seq_printf(m, "PCU interrupt mask:\t%08x\n",
842 I915_READ(GEN8_PCU_IMR));
843 seq_printf(m, "PCU interrupt identity:\t%08x\n",
844 I915_READ(GEN8_PCU_IIR));
845 seq_printf(m, "PCU interrupt enable:\t%08x\n",
846 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300847 } else if (IS_VALLEYVIEW(dev_priv)) {
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700848 seq_printf(m, "Display IER:\t%08x\n",
849 I915_READ(VLV_IER));
850 seq_printf(m, "Display IIR:\t%08x\n",
851 I915_READ(VLV_IIR));
852 seq_printf(m, "Display IIR_RW:\t%08x\n",
853 I915_READ(VLV_IIR_RW));
854 seq_printf(m, "Display IMR:\t%08x\n",
855 I915_READ(VLV_IMR));
Damien Lespiau055e3932014-08-18 13:49:10 +0100856 for_each_pipe(dev_priv, pipe)
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700857 seq_printf(m, "Pipe %c stat:\t%08x\n",
858 pipe_name(pipe),
859 I915_READ(PIPESTAT(pipe)));
860
861 seq_printf(m, "Master IER:\t%08x\n",
862 I915_READ(VLV_MASTER_IER));
863
864 seq_printf(m, "Render IER:\t%08x\n",
865 I915_READ(GTIER));
866 seq_printf(m, "Render IIR:\t%08x\n",
867 I915_READ(GTIIR));
868 seq_printf(m, "Render IMR:\t%08x\n",
869 I915_READ(GTIMR));
870
871 seq_printf(m, "PM IER:\t\t%08x\n",
872 I915_READ(GEN6_PMIER));
873 seq_printf(m, "PM IIR:\t\t%08x\n",
874 I915_READ(GEN6_PMIIR));
875 seq_printf(m, "PM IMR:\t\t%08x\n",
876 I915_READ(GEN6_PMIMR));
877
878 seq_printf(m, "Port hotplug:\t%08x\n",
879 I915_READ(PORT_HOTPLUG_EN));
880 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
881 I915_READ(VLV_DPFLIPSTAT));
882 seq_printf(m, "DPINVGTT:\t%08x\n",
883 I915_READ(DPINVGTT));
884
David Weinehall36cdd012016-08-22 13:59:31 +0300885 } else if (!HAS_PCH_SPLIT(dev_priv)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800886 seq_printf(m, "Interrupt enable: %08x\n",
887 I915_READ(IER));
888 seq_printf(m, "Interrupt identity: %08x\n",
889 I915_READ(IIR));
890 seq_printf(m, "Interrupt mask: %08x\n",
891 I915_READ(IMR));
Damien Lespiau055e3932014-08-18 13:49:10 +0100892 for_each_pipe(dev_priv, pipe)
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800893 seq_printf(m, "Pipe %c stat: %08x\n",
894 pipe_name(pipe),
895 I915_READ(PIPESTAT(pipe)));
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800896 } else {
897 seq_printf(m, "North Display Interrupt enable: %08x\n",
898 I915_READ(DEIER));
899 seq_printf(m, "North Display Interrupt identity: %08x\n",
900 I915_READ(DEIIR));
901 seq_printf(m, "North Display Interrupt mask: %08x\n",
902 I915_READ(DEIMR));
903 seq_printf(m, "South Display Interrupt enable: %08x\n",
904 I915_READ(SDEIER));
905 seq_printf(m, "South Display Interrupt identity: %08x\n",
906 I915_READ(SDEIIR));
907 seq_printf(m, "South Display Interrupt mask: %08x\n",
908 I915_READ(SDEIMR));
909 seq_printf(m, "Graphics Interrupt enable: %08x\n",
910 I915_READ(GTIER));
911 seq_printf(m, "Graphics Interrupt identity: %08x\n",
912 I915_READ(GTIIR));
913 seq_printf(m, "Graphics Interrupt mask: %08x\n",
914 I915_READ(GTIMR));
915 }
Akash Goel3b3f1652016-10-13 22:44:48 +0530916 for_each_engine(engine, dev_priv, id) {
David Weinehall36cdd012016-08-22 13:59:31 +0300917 if (INTEL_GEN(dev_priv) >= 6) {
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100918 seq_printf(m,
919 "Graphics Interrupt mask (%s): %08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000920 engine->name, I915_READ_IMR(engine));
Chris Wilson9862e602011-01-04 22:22:17 +0000921 }
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000922 i915_ring_seqno_info(m, engine);
Chris Wilson9862e602011-01-04 22:22:17 +0000923 }
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200924 intel_runtime_pm_put(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100925
Ben Gamari20172632009-02-17 20:08:50 -0500926 return 0;
927}
928
Chris Wilsona6172a82009-02-11 14:26:38 +0000929static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
930{
David Weinehall36cdd012016-08-22 13:59:31 +0300931 struct drm_i915_private *dev_priv = node_to_i915(m->private);
932 struct drm_device *dev = &dev_priv->drm;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100933 int i, ret;
934
935 ret = mutex_lock_interruptible(&dev->struct_mutex);
936 if (ret)
937 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000938
Chris Wilsona6172a82009-02-11 14:26:38 +0000939 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
940 for (i = 0; i < dev_priv->num_fence_regs; i++) {
Chris Wilson49ef5292016-08-18 17:17:00 +0100941 struct i915_vma *vma = dev_priv->fence_regs[i].vma;
Chris Wilsona6172a82009-02-11 14:26:38 +0000942
Chris Wilson6c085a72012-08-20 11:40:46 +0200943 seq_printf(m, "Fence %d, pin count = %d, object = ",
944 i, dev_priv->fence_regs[i].pin_count);
Chris Wilson49ef5292016-08-18 17:17:00 +0100945 if (!vma)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100946 seq_puts(m, "unused");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100947 else
Chris Wilson49ef5292016-08-18 17:17:00 +0100948 describe_obj(m, vma->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100949 seq_putc(m, '\n');
Chris Wilsona6172a82009-02-11 14:26:38 +0000950 }
951
Chris Wilson05394f32010-11-08 19:18:58 +0000952 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000953 return 0;
954}
955
Chris Wilson98a2f412016-10-12 10:05:18 +0100956#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
957
Daniel Vetterd5442302012-04-27 15:17:40 +0200958static ssize_t
959i915_error_state_write(struct file *filp,
960 const char __user *ubuf,
961 size_t cnt,
962 loff_t *ppos)
963{
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300964 struct i915_error_state_file_priv *error_priv = filp->private_data;
Daniel Vetterd5442302012-04-27 15:17:40 +0200965
966 DRM_DEBUG_DRIVER("Resetting error state\n");
Tvrtko Ursulin12ff05e2016-12-01 14:16:43 +0000967 i915_destroy_error_state(error_priv->i915);
Daniel Vetterd5442302012-04-27 15:17:40 +0200968
969 return cnt;
970}
971
972static int i915_error_state_open(struct inode *inode, struct file *file)
973{
David Weinehall36cdd012016-08-22 13:59:31 +0300974 struct drm_i915_private *dev_priv = inode->i_private;
Daniel Vetterd5442302012-04-27 15:17:40 +0200975 struct i915_error_state_file_priv *error_priv;
Daniel Vetterd5442302012-04-27 15:17:40 +0200976
977 error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL);
978 if (!error_priv)
979 return -ENOMEM;
980
Tvrtko Ursulin12ff05e2016-12-01 14:16:43 +0000981 error_priv->i915 = dev_priv;
Daniel Vetterd5442302012-04-27 15:17:40 +0200982
David Weinehall36cdd012016-08-22 13:59:31 +0300983 i915_error_state_get(&dev_priv->drm, error_priv);
Daniel Vetterd5442302012-04-27 15:17:40 +0200984
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300985 file->private_data = error_priv;
986
987 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +0200988}
989
990static int i915_error_state_release(struct inode *inode, struct file *file)
991{
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300992 struct i915_error_state_file_priv *error_priv = file->private_data;
Daniel Vetterd5442302012-04-27 15:17:40 +0200993
Mika Kuoppala95d5bfb2013-06-06 15:18:40 +0300994 i915_error_state_put(error_priv);
Daniel Vetterd5442302012-04-27 15:17:40 +0200995 kfree(error_priv);
996
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300997 return 0;
998}
999
1000static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
1001 size_t count, loff_t *pos)
1002{
1003 struct i915_error_state_file_priv *error_priv = file->private_data;
1004 struct drm_i915_error_state_buf error_str;
1005 loff_t tmp_pos = 0;
1006 ssize_t ret_count = 0;
Mika Kuoppala4dc955f2013-06-06 15:18:41 +03001007 int ret;
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001008
Tvrtko Ursulin12ff05e2016-12-01 14:16:43 +00001009 ret = i915_error_state_buf_init(&error_str, error_priv->i915,
1010 count, *pos);
Mika Kuoppala4dc955f2013-06-06 15:18:41 +03001011 if (ret)
1012 return ret;
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001013
Mika Kuoppalafc16b482013-06-06 15:18:39 +03001014 ret = i915_error_state_to_str(&error_str, error_priv);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001015 if (ret)
1016 goto out;
1017
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001018 ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos,
1019 error_str.buf,
1020 error_str.bytes);
1021
1022 if (ret_count < 0)
1023 ret = ret_count;
1024 else
1025 *pos = error_str.start + ret_count;
1026out:
Mika Kuoppala4dc955f2013-06-06 15:18:41 +03001027 i915_error_state_buf_release(&error_str);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001028 return ret ?: ret_count;
Daniel Vetterd5442302012-04-27 15:17:40 +02001029}
1030
1031static const struct file_operations i915_error_state_fops = {
1032 .owner = THIS_MODULE,
1033 .open = i915_error_state_open,
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001034 .read = i915_error_state_read,
Daniel Vetterd5442302012-04-27 15:17:40 +02001035 .write = i915_error_state_write,
1036 .llseek = default_llseek,
1037 .release = i915_error_state_release,
1038};
1039
Chris Wilson98a2f412016-10-12 10:05:18 +01001040#endif
1041
Kees Cook647416f2013-03-10 14:10:06 -07001042static int
1043i915_next_seqno_get(void *data, u64 *val)
Mika Kuoppala40633212012-12-04 15:12:00 +02001044{
David Weinehall36cdd012016-08-22 13:59:31 +03001045 struct drm_i915_private *dev_priv = data;
Mika Kuoppala40633212012-12-04 15:12:00 +02001046
Joonas Lahtinen4c266ed2016-11-24 14:47:49 +00001047 *val = 1 + atomic_read(&dev_priv->gt.global_timeline.seqno);
Kees Cook647416f2013-03-10 14:10:06 -07001048 return 0;
Mika Kuoppala40633212012-12-04 15:12:00 +02001049}
1050
Kees Cook647416f2013-03-10 14:10:06 -07001051static int
1052i915_next_seqno_set(void *data, u64 val)
Mika Kuoppala40633212012-12-04 15:12:00 +02001053{
David Weinehall36cdd012016-08-22 13:59:31 +03001054 struct drm_i915_private *dev_priv = data;
1055 struct drm_device *dev = &dev_priv->drm;
Mika Kuoppala40633212012-12-04 15:12:00 +02001056 int ret;
1057
Mika Kuoppala40633212012-12-04 15:12:00 +02001058 ret = mutex_lock_interruptible(&dev->struct_mutex);
1059 if (ret)
1060 return ret;
1061
Chris Wilson73cb9702016-10-28 13:58:46 +01001062 ret = i915_gem_set_global_seqno(dev, val);
Mika Kuoppala40633212012-12-04 15:12:00 +02001063 mutex_unlock(&dev->struct_mutex);
1064
Kees Cook647416f2013-03-10 14:10:06 -07001065 return ret;
Mika Kuoppala40633212012-12-04 15:12:00 +02001066}
1067
Kees Cook647416f2013-03-10 14:10:06 -07001068DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
1069 i915_next_seqno_get, i915_next_seqno_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03001070 "0x%llx\n");
Mika Kuoppala40633212012-12-04 15:12:00 +02001071
Deepak Sadb4bd12014-03-31 11:30:02 +05301072static int i915_frequency_info(struct seq_file *m, void *unused)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001073{
David Weinehall36cdd012016-08-22 13:59:31 +03001074 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1075 struct drm_device *dev = &dev_priv->drm;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001076 int ret = 0;
1077
1078 intel_runtime_pm_get(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001079
David Weinehall36cdd012016-08-22 13:59:31 +03001080 if (IS_GEN5(dev_priv)) {
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001081 u16 rgvswctl = I915_READ16(MEMSWCTL);
1082 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
1083
1084 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
1085 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
1086 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
1087 MEMSTAT_VID_SHIFT);
1088 seq_printf(m, "Current P-state: %d\n",
1089 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
David Weinehall36cdd012016-08-22 13:59:31 +03001090 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
Wayne Boyer666a4532015-12-09 12:29:35 -08001091 u32 freq_sts;
1092
1093 mutex_lock(&dev_priv->rps.hw_lock);
1094 freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
1095 seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts);
1096 seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq);
1097
1098 seq_printf(m, "actual GPU freq: %d MHz\n",
1099 intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff));
1100
1101 seq_printf(m, "current GPU freq: %d MHz\n",
1102 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1103
1104 seq_printf(m, "max GPU freq: %d MHz\n",
1105 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1106
1107 seq_printf(m, "min GPU freq: %d MHz\n",
1108 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
1109
1110 seq_printf(m, "idle GPU freq: %d MHz\n",
1111 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
1112
1113 seq_printf(m,
1114 "efficient (RPe) frequency: %d MHz\n",
1115 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
1116 mutex_unlock(&dev_priv->rps.hw_lock);
David Weinehall36cdd012016-08-22 13:59:31 +03001117 } else if (INTEL_GEN(dev_priv) >= 6) {
Bob Paauwe35040562015-06-25 14:54:07 -07001118 u32 rp_state_limits;
1119 u32 gt_perf_status;
1120 u32 rp_state_cap;
Chris Wilson0d8f9492014-03-27 09:06:14 +00001121 u32 rpmodectl, rpinclimit, rpdeclimit;
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001122 u32 rpstat, cagf, reqf;
Jesse Barnesccab5c82011-01-18 15:49:25 -08001123 u32 rpupei, rpcurup, rpprevup;
1124 u32 rpdownei, rpcurdown, rpprevdown;
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001125 u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask;
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001126 int max_freq;
1127
Bob Paauwe35040562015-06-25 14:54:07 -07001128 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001129 if (IS_GEN9_LP(dev_priv)) {
Bob Paauwe35040562015-06-25 14:54:07 -07001130 rp_state_cap = I915_READ(BXT_RP_STATE_CAP);
1131 gt_perf_status = I915_READ(BXT_GT_PERF_STATUS);
1132 } else {
1133 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
1134 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
1135 }
1136
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001137 /* RPSTAT1 is in the GT power well */
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001138 ret = mutex_lock_interruptible(&dev->struct_mutex);
1139 if (ret)
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001140 goto out;
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001141
Mika Kuoppala59bad942015-01-16 11:34:40 +02001142 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001143
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001144 reqf = I915_READ(GEN6_RPNSWREQ);
David Weinehall36cdd012016-08-22 13:59:31 +03001145 if (IS_GEN9(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301146 reqf >>= 23;
1147 else {
1148 reqf &= ~GEN6_TURBO_DISABLE;
David Weinehall36cdd012016-08-22 13:59:31 +03001149 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301150 reqf >>= 24;
1151 else
1152 reqf >>= 25;
1153 }
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001154 reqf = intel_gpu_freq(dev_priv, reqf);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001155
Chris Wilson0d8f9492014-03-27 09:06:14 +00001156 rpmodectl = I915_READ(GEN6_RP_CONTROL);
1157 rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD);
1158 rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD);
1159
Jesse Barnesccab5c82011-01-18 15:49:25 -08001160 rpstat = I915_READ(GEN6_RPSTAT1);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301161 rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK;
1162 rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK;
1163 rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK;
1164 rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK;
1165 rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK;
1166 rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK;
David Weinehall36cdd012016-08-22 13:59:31 +03001167 if (IS_GEN9(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301168 cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT;
David Weinehall36cdd012016-08-22 13:59:31 +03001169 else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Ben Widawskyf82855d2013-01-29 12:00:15 -08001170 cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT;
1171 else
1172 cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT;
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001173 cagf = intel_gpu_freq(dev_priv, cagf);
Jesse Barnesccab5c82011-01-18 15:49:25 -08001174
Mika Kuoppala59bad942015-01-16 11:34:40 +02001175 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001176 mutex_unlock(&dev->struct_mutex);
1177
David Weinehall36cdd012016-08-22 13:59:31 +03001178 if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) {
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001179 pm_ier = I915_READ(GEN6_PMIER);
1180 pm_imr = I915_READ(GEN6_PMIMR);
1181 pm_isr = I915_READ(GEN6_PMISR);
1182 pm_iir = I915_READ(GEN6_PMIIR);
1183 pm_mask = I915_READ(GEN6_PMINTRMSK);
1184 } else {
1185 pm_ier = I915_READ(GEN8_GT_IER(2));
1186 pm_imr = I915_READ(GEN8_GT_IMR(2));
1187 pm_isr = I915_READ(GEN8_GT_ISR(2));
1188 pm_iir = I915_READ(GEN8_GT_IIR(2));
1189 pm_mask = I915_READ(GEN6_PMINTRMSK);
1190 }
Chris Wilson0d8f9492014-03-27 09:06:14 +00001191 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 -03001192 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask);
Sagar Arun Kamble1800ad22016-05-31 13:58:27 +05301193 seq_printf(m, "pm_intr_keep: 0x%08x\n", dev_priv->rps.pm_intr_keep);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001194 seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001195 seq_printf(m, "Render p-state ratio: %d\n",
David Weinehall36cdd012016-08-22 13:59:31 +03001196 (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001197 seq_printf(m, "Render p-state VID: %d\n",
1198 gt_perf_status & 0xff);
1199 seq_printf(m, "Render p-state limit: %d\n",
1200 rp_state_limits & 0xff);
Chris Wilson0d8f9492014-03-27 09:06:14 +00001201 seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
1202 seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl);
1203 seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit);
1204 seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001205 seq_printf(m, "RPNSWREQ: %dMHz\n", reqf);
Ben Widawskyf82855d2013-01-29 12:00:15 -08001206 seq_printf(m, "CAGF: %dMHz\n", cagf);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301207 seq_printf(m, "RP CUR UP EI: %d (%dus)\n",
1208 rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei));
1209 seq_printf(m, "RP CUR UP: %d (%dus)\n",
1210 rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup));
1211 seq_printf(m, "RP PREV UP: %d (%dus)\n",
1212 rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup));
Chris Wilsond86ed342015-04-27 13:41:19 +01001213 seq_printf(m, "Up threshold: %d%%\n",
1214 dev_priv->rps.up_threshold);
1215
Akash Goeld6cda9c2016-04-23 00:05:46 +05301216 seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n",
1217 rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei));
1218 seq_printf(m, "RP CUR DOWN: %d (%dus)\n",
1219 rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown));
1220 seq_printf(m, "RP PREV DOWN: %d (%dus)\n",
1221 rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown));
Chris Wilsond86ed342015-04-27 13:41:19 +01001222 seq_printf(m, "Down threshold: %d%%\n",
1223 dev_priv->rps.down_threshold);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001224
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001225 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 :
Bob Paauwe35040562015-06-25 14:54:07 -07001226 rp_state_cap >> 16) & 0xff;
David Weinehall36cdd012016-08-22 13:59:31 +03001227 max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
Rodrigo Vivief11bdb2015-10-28 04:16:45 -07001228 GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001229 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001230 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001231
1232 max_freq = (rp_state_cap & 0xff00) >> 8;
David Weinehall36cdd012016-08-22 13:59:31 +03001233 max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
Rodrigo Vivief11bdb2015-10-28 04:16:45 -07001234 GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001235 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001236 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001237
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001238 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 :
Bob Paauwe35040562015-06-25 14:54:07 -07001239 rp_state_cap >> 0) & 0xff;
David Weinehall36cdd012016-08-22 13:59:31 +03001240 max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
Rodrigo Vivief11bdb2015-10-28 04:16:45 -07001241 GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001242 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001243 intel_gpu_freq(dev_priv, max_freq));
Ben Widawsky31c77382013-04-05 14:29:22 -07001244 seq_printf(m, "Max overclocked frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001245 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
Chris Wilsonaed242f2015-03-18 09:48:21 +00001246
Chris Wilsond86ed342015-04-27 13:41:19 +01001247 seq_printf(m, "Current freq: %d MHz\n",
1248 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1249 seq_printf(m, "Actual freq: %d MHz\n", cagf);
Chris Wilsonaed242f2015-03-18 09:48:21 +00001250 seq_printf(m, "Idle freq: %d MHz\n",
1251 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001252 seq_printf(m, "Min freq: %d MHz\n",
1253 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
Chris Wilson29ecd78d2016-07-13 09:10:35 +01001254 seq_printf(m, "Boost freq: %d MHz\n",
1255 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001256 seq_printf(m, "Max freq: %d MHz\n",
1257 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1258 seq_printf(m,
1259 "efficient (RPe) frequency: %d MHz\n",
1260 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001261 } else {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001262 seq_puts(m, "no P-state info available\n");
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001263 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001264
Mika Kahola1170f282015-09-25 14:00:32 +03001265 seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq);
1266 seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq);
1267 seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq);
1268
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001269out:
1270 intel_runtime_pm_put(dev_priv);
1271 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001272}
1273
Ben Widawskyd6369512016-09-20 16:54:32 +03001274static void i915_instdone_info(struct drm_i915_private *dev_priv,
1275 struct seq_file *m,
1276 struct intel_instdone *instdone)
1277{
Ben Widawskyf9e61372016-09-20 16:54:33 +03001278 int slice;
1279 int subslice;
1280
Ben Widawskyd6369512016-09-20 16:54:32 +03001281 seq_printf(m, "\t\tINSTDONE: 0x%08x\n",
1282 instdone->instdone);
1283
1284 if (INTEL_GEN(dev_priv) <= 3)
1285 return;
1286
1287 seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n",
1288 instdone->slice_common);
1289
1290 if (INTEL_GEN(dev_priv) <= 6)
1291 return;
1292
Ben Widawskyf9e61372016-09-20 16:54:33 +03001293 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1294 seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n",
1295 slice, subslice, instdone->sampler[slice][subslice]);
1296
1297 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1298 seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n",
1299 slice, subslice, instdone->row[slice][subslice]);
Ben Widawskyd6369512016-09-20 16:54:32 +03001300}
1301
Chris Wilsonf6544492015-01-26 18:03:04 +02001302static int i915_hangcheck_info(struct seq_file *m, void *unused)
1303{
David Weinehall36cdd012016-08-22 13:59:31 +03001304 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001305 struct intel_engine_cs *engine;
Tvrtko Ursulin666796d2016-03-16 11:00:39 +00001306 u64 acthd[I915_NUM_ENGINES];
1307 u32 seqno[I915_NUM_ENGINES];
Ben Widawskyd6369512016-09-20 16:54:32 +03001308 struct intel_instdone instdone;
Dave Gordonc3232b12016-03-23 18:19:53 +00001309 enum intel_engine_id id;
Chris Wilsonf6544492015-01-26 18:03:04 +02001310
Chris Wilson8af29b02016-09-09 14:11:47 +01001311 if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags))
1312 seq_printf(m, "Wedged\n");
1313 if (test_bit(I915_RESET_IN_PROGRESS, &dev_priv->gpu_error.flags))
1314 seq_printf(m, "Reset in progress\n");
1315 if (waitqueue_active(&dev_priv->gpu_error.wait_queue))
1316 seq_printf(m, "Waiter holding struct mutex\n");
1317 if (waitqueue_active(&dev_priv->gpu_error.reset_queue))
1318 seq_printf(m, "struct_mutex blocked for reset\n");
1319
Chris Wilsonf6544492015-01-26 18:03:04 +02001320 if (!i915.enable_hangcheck) {
1321 seq_printf(m, "Hangcheck disabled\n");
1322 return 0;
1323 }
1324
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001325 intel_runtime_pm_get(dev_priv);
1326
Akash Goel3b3f1652016-10-13 22:44:48 +05301327 for_each_engine(engine, dev_priv, id) {
Chris Wilson7e37f882016-08-02 22:50:21 +01001328 acthd[id] = intel_engine_get_active_head(engine);
Chris Wilson1b7744e2016-07-01 17:23:17 +01001329 seqno[id] = intel_engine_get_seqno(engine);
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001330 }
1331
Akash Goel3b3f1652016-10-13 22:44:48 +05301332 intel_engine_get_instdone(dev_priv->engine[RCS], &instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001333
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001334 intel_runtime_pm_put(dev_priv);
1335
Chris Wilsonf6544492015-01-26 18:03:04 +02001336 if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) {
1337 seq_printf(m, "Hangcheck active, fires in %dms\n",
1338 jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires -
1339 jiffies));
1340 } else
1341 seq_printf(m, "Hangcheck inactive\n");
1342
Akash Goel3b3f1652016-10-13 22:44:48 +05301343 for_each_engine(engine, dev_priv, id) {
Chris Wilson33f53712016-10-04 21:11:32 +01001344 struct intel_breadcrumbs *b = &engine->breadcrumbs;
1345 struct rb_node *rb;
1346
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001347 seq_printf(m, "%s:\n", engine->name);
Chris Wilson14fd0d62016-04-07 07:29:10 +01001348 seq_printf(m, "\tseqno = %x [current %x, last %x]\n",
Chris Wilsoncb399ea2016-11-01 10:03:16 +00001349 engine->hangcheck.seqno, seqno[id],
1350 intel_engine_last_submit(engine));
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001351 seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n",
Chris Wilson83348ba2016-08-09 17:47:51 +01001352 yesno(intel_engine_has_waiter(engine)),
1353 yesno(test_bit(engine->id,
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001354 &dev_priv->gpu_error.missed_irq_rings)),
1355 yesno(engine->hangcheck.stalled));
1356
Chris Wilsonf6168e32016-10-28 13:58:55 +01001357 spin_lock_irq(&b->lock);
Chris Wilson33f53712016-10-04 21:11:32 +01001358 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +08001359 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson33f53712016-10-04 21:11:32 +01001360
1361 seq_printf(m, "\t%s [%d] waiting for %x\n",
1362 w->tsk->comm, w->tsk->pid, w->seqno);
1363 }
Chris Wilsonf6168e32016-10-28 13:58:55 +01001364 spin_unlock_irq(&b->lock);
Chris Wilson33f53712016-10-04 21:11:32 +01001365
Chris Wilsonf6544492015-01-26 18:03:04 +02001366 seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001367 (long long)engine->hangcheck.acthd,
Dave Gordonc3232b12016-03-23 18:19:53 +00001368 (long long)acthd[id]);
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001369 seq_printf(m, "\taction = %s(%d) %d ms ago\n",
1370 hangcheck_action_to_str(engine->hangcheck.action),
1371 engine->hangcheck.action,
1372 jiffies_to_msecs(jiffies -
1373 engine->hangcheck.action_timestamp));
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001374
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001375 if (engine->id == RCS) {
Ben Widawskyd6369512016-09-20 16:54:32 +03001376 seq_puts(m, "\tinstdone read =\n");
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001377
Ben Widawskyd6369512016-09-20 16:54:32 +03001378 i915_instdone_info(dev_priv, m, &instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001379
Ben Widawskyd6369512016-09-20 16:54:32 +03001380 seq_puts(m, "\tinstdone accu =\n");
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001381
Ben Widawskyd6369512016-09-20 16:54:32 +03001382 i915_instdone_info(dev_priv, m,
1383 &engine->hangcheck.instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001384 }
Chris Wilsonf6544492015-01-26 18:03:04 +02001385 }
1386
1387 return 0;
1388}
1389
Ben Widawsky4d855292011-12-12 19:34:16 -08001390static int ironlake_drpc_info(struct seq_file *m)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001391{
David Weinehall36cdd012016-08-22 13:59:31 +03001392 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001393 u32 rgvmodectl, rstdbyctl;
1394 u16 crstandvid;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001395
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001396 intel_runtime_pm_get(dev_priv);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001397
1398 rgvmodectl = I915_READ(MEMMODECTL);
1399 rstdbyctl = I915_READ(RSTDBYCTL);
1400 crstandvid = I915_READ16(CRSTANDVID);
1401
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001402 intel_runtime_pm_put(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001403
Jani Nikula742f4912015-09-03 11:16:09 +03001404 seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001405 seq_printf(m, "Boost freq: %d\n",
1406 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
1407 MEMMODE_BOOST_FREQ_SHIFT);
1408 seq_printf(m, "HW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001409 yesno(rgvmodectl & MEMMODE_HWIDLE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001410 seq_printf(m, "SW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001411 yesno(rgvmodectl & MEMMODE_SWMODE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001412 seq_printf(m, "Gated voltage change: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001413 yesno(rgvmodectl & MEMMODE_RCLK_GATE));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001414 seq_printf(m, "Starting frequency: P%d\n",
1415 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001416 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -08001417 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001418 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
1419 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
1420 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
1421 seq_printf(m, "Render standby enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001422 yesno(!(rstdbyctl & RCX_SW_EXIT)));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001423 seq_puts(m, "Current RS state: ");
Jesse Barnes88271da2011-01-05 12:01:24 -08001424 switch (rstdbyctl & RSX_STATUS_MASK) {
1425 case RSX_STATUS_ON:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001426 seq_puts(m, "on\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001427 break;
1428 case RSX_STATUS_RC1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001429 seq_puts(m, "RC1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001430 break;
1431 case RSX_STATUS_RC1E:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001432 seq_puts(m, "RC1E\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001433 break;
1434 case RSX_STATUS_RS1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001435 seq_puts(m, "RS1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001436 break;
1437 case RSX_STATUS_RS2:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001438 seq_puts(m, "RS2 (RC6)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001439 break;
1440 case RSX_STATUS_RS3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001441 seq_puts(m, "RC3 (RC6+)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001442 break;
1443 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001444 seq_puts(m, "unknown\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001445 break;
1446 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001447
1448 return 0;
1449}
1450
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001451static int i915_forcewake_domains(struct seq_file *m, void *data)
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001452{
David Weinehall36cdd012016-08-22 13:59:31 +03001453 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001454 struct intel_uncore_forcewake_domain *fw_domain;
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001455
1456 spin_lock_irq(&dev_priv->uncore.lock);
Tvrtko Ursulin33c582c2016-04-07 17:04:33 +01001457 for_each_fw_domain(fw_domain, dev_priv) {
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001458 seq_printf(m, "%s.wake_count = %u\n",
Tvrtko Ursulin33c582c2016-04-07 17:04:33 +01001459 intel_uncore_forcewake_domain_to_str(fw_domain->id),
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001460 fw_domain->wake_count);
1461 }
1462 spin_unlock_irq(&dev_priv->uncore.lock);
1463
1464 return 0;
1465}
1466
Deepak S669ab5a2014-01-10 15:18:26 +05301467static int vlv_drpc_info(struct seq_file *m)
1468{
David Weinehall36cdd012016-08-22 13:59:31 +03001469 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001470 u32 rpmodectl1, rcctl1, pw_status;
Deepak S669ab5a2014-01-10 15:18:26 +05301471
Imre Deakd46c0512014-04-14 20:24:27 +03001472 intel_runtime_pm_get(dev_priv);
1473
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001474 pw_status = I915_READ(VLV_GTLC_PW_STATUS);
Deepak S669ab5a2014-01-10 15:18:26 +05301475 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1476 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1477
Imre Deakd46c0512014-04-14 20:24:27 +03001478 intel_runtime_pm_put(dev_priv);
1479
Deepak S669ab5a2014-01-10 15:18:26 +05301480 seq_printf(m, "Video Turbo Mode: %s\n",
1481 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1482 seq_printf(m, "Turbo enabled: %s\n",
1483 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1484 seq_printf(m, "HW control enabled: %s\n",
1485 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1486 seq_printf(m, "SW control enabled: %s\n",
1487 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1488 GEN6_RP_MEDIA_SW_MODE));
1489 seq_printf(m, "RC6 Enabled: %s\n",
1490 yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE |
1491 GEN6_RC_CTL_EI_MODE(1))));
1492 seq_printf(m, "Render Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001493 (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301494 seq_printf(m, "Media Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001495 (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301496
Imre Deak9cc19be2014-04-14 20:24:24 +03001497 seq_printf(m, "Render RC6 residency since boot: %u\n",
1498 I915_READ(VLV_GT_RENDER_RC6));
1499 seq_printf(m, "Media RC6 residency since boot: %u\n",
1500 I915_READ(VLV_GT_MEDIA_RC6));
1501
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001502 return i915_forcewake_domains(m, NULL);
Deepak S669ab5a2014-01-10 15:18:26 +05301503}
1504
Ben Widawsky4d855292011-12-12 19:34:16 -08001505static int gen6_drpc_info(struct seq_file *m)
1506{
David Weinehall36cdd012016-08-22 13:59:31 +03001507 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1508 struct drm_device *dev = &dev_priv->drm;
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001509 u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0;
Akash Goelf2dd7572016-06-27 20:10:01 +05301510 u32 gen9_powergate_enable = 0, gen9_powergate_status = 0;
Daniel Vetter93b525d2012-01-25 13:52:43 +01001511 unsigned forcewake_count;
Damien Lespiauaee56cf2013-06-24 22:59:49 +01001512 int count = 0, ret;
Ben Widawsky4d855292011-12-12 19:34:16 -08001513
1514 ret = mutex_lock_interruptible(&dev->struct_mutex);
1515 if (ret)
1516 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001517 intel_runtime_pm_get(dev_priv);
Ben Widawsky4d855292011-12-12 19:34:16 -08001518
Chris Wilson907b28c2013-07-19 20:36:52 +01001519 spin_lock_irq(&dev_priv->uncore.lock);
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001520 forcewake_count = dev_priv->uncore.fw_domain[FW_DOMAIN_ID_RENDER].wake_count;
Chris Wilson907b28c2013-07-19 20:36:52 +01001521 spin_unlock_irq(&dev_priv->uncore.lock);
Daniel Vetter93b525d2012-01-25 13:52:43 +01001522
1523 if (forcewake_count) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001524 seq_puts(m, "RC information inaccurate because somebody "
1525 "holds a forcewake reference \n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001526 } else {
1527 /* NB: we cannot use forcewake, else we read the wrong values */
1528 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
1529 udelay(10);
1530 seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
1531 }
1532
Ville Syrjälä75aa3f62015-10-22 15:34:56 +03001533 gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS);
Chris Wilsoned71f1b2013-07-19 20:36:56 +01001534 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4, true);
Ben Widawsky4d855292011-12-12 19:34:16 -08001535
1536 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1537 rcctl1 = I915_READ(GEN6_RC_CONTROL);
David Weinehall36cdd012016-08-22 13:59:31 +03001538 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301539 gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE);
1540 gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS);
1541 }
Ben Widawsky4d855292011-12-12 19:34:16 -08001542 mutex_unlock(&dev->struct_mutex);
Ben Widawsky44cbd332012-11-06 14:36:36 +00001543 mutex_lock(&dev_priv->rps.hw_lock);
1544 sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
1545 mutex_unlock(&dev_priv->rps.hw_lock);
Ben Widawsky4d855292011-12-12 19:34:16 -08001546
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001547 intel_runtime_pm_put(dev_priv);
1548
Ben Widawsky4d855292011-12-12 19:34:16 -08001549 seq_printf(m, "Video Turbo Mode: %s\n",
1550 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1551 seq_printf(m, "HW control enabled: %s\n",
1552 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1553 seq_printf(m, "SW control enabled: %s\n",
1554 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1555 GEN6_RP_MEDIA_SW_MODE));
Eric Anholtfff24e22012-01-23 16:14:05 -08001556 seq_printf(m, "RC1e Enabled: %s\n",
Ben Widawsky4d855292011-12-12 19:34:16 -08001557 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1558 seq_printf(m, "RC6 Enabled: %s\n",
1559 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
David Weinehall36cdd012016-08-22 13:59:31 +03001560 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301561 seq_printf(m, "Render Well Gating Enabled: %s\n",
1562 yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE));
1563 seq_printf(m, "Media Well Gating Enabled: %s\n",
1564 yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE));
1565 }
Ben Widawsky4d855292011-12-12 19:34:16 -08001566 seq_printf(m, "Deep RC6 Enabled: %s\n",
1567 yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
1568 seq_printf(m, "Deepest RC6 Enabled: %s\n",
1569 yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001570 seq_puts(m, "Current RC state: ");
Ben Widawsky4d855292011-12-12 19:34:16 -08001571 switch (gt_core_status & GEN6_RCn_MASK) {
1572 case GEN6_RC0:
1573 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
Damien Lespiau267f0c92013-06-24 22:59:48 +01001574 seq_puts(m, "Core Power Down\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001575 else
Damien Lespiau267f0c92013-06-24 22:59:48 +01001576 seq_puts(m, "on\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001577 break;
1578 case GEN6_RC3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001579 seq_puts(m, "RC3\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001580 break;
1581 case GEN6_RC6:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001582 seq_puts(m, "RC6\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001583 break;
1584 case GEN6_RC7:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001585 seq_puts(m, "RC7\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001586 break;
1587 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001588 seq_puts(m, "Unknown\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001589 break;
1590 }
1591
1592 seq_printf(m, "Core Power Down: %s\n",
1593 yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
David Weinehall36cdd012016-08-22 13:59:31 +03001594 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301595 seq_printf(m, "Render Power Well: %s\n",
1596 (gen9_powergate_status &
1597 GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down");
1598 seq_printf(m, "Media Power Well: %s\n",
1599 (gen9_powergate_status &
1600 GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down");
1601 }
Ben Widawskycce66a22012-03-27 18:59:38 -07001602
1603 /* Not exactly sure what this is */
1604 seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1605 I915_READ(GEN6_GT_GFX_RC6_LOCKED));
1606 seq_printf(m, "RC6 residency since boot: %u\n",
1607 I915_READ(GEN6_GT_GFX_RC6));
1608 seq_printf(m, "RC6+ residency since boot: %u\n",
1609 I915_READ(GEN6_GT_GFX_RC6p));
1610 seq_printf(m, "RC6++ residency since boot: %u\n",
1611 I915_READ(GEN6_GT_GFX_RC6pp));
1612
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001613 seq_printf(m, "RC6 voltage: %dmV\n",
1614 GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff)));
1615 seq_printf(m, "RC6+ voltage: %dmV\n",
1616 GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff)));
1617 seq_printf(m, "RC6++ voltage: %dmV\n",
1618 GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff)));
Akash Goelf2dd7572016-06-27 20:10:01 +05301619 return i915_forcewake_domains(m, NULL);
Ben Widawsky4d855292011-12-12 19:34:16 -08001620}
1621
1622static int i915_drpc_info(struct seq_file *m, void *unused)
1623{
David Weinehall36cdd012016-08-22 13:59:31 +03001624 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ben Widawsky4d855292011-12-12 19:34:16 -08001625
David Weinehall36cdd012016-08-22 13:59:31 +03001626 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Deepak S669ab5a2014-01-10 15:18:26 +05301627 return vlv_drpc_info(m);
David Weinehall36cdd012016-08-22 13:59:31 +03001628 else if (INTEL_GEN(dev_priv) >= 6)
Ben Widawsky4d855292011-12-12 19:34:16 -08001629 return gen6_drpc_info(m);
1630 else
1631 return ironlake_drpc_info(m);
1632}
1633
Daniel Vetter9a851782015-06-18 10:30:22 +02001634static int i915_frontbuffer_tracking(struct seq_file *m, void *unused)
1635{
David Weinehall36cdd012016-08-22 13:59:31 +03001636 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetter9a851782015-06-18 10:30:22 +02001637
1638 seq_printf(m, "FB tracking busy bits: 0x%08x\n",
1639 dev_priv->fb_tracking.busy_bits);
1640
1641 seq_printf(m, "FB tracking flip bits: 0x%08x\n",
1642 dev_priv->fb_tracking.flip_bits);
1643
1644 return 0;
1645}
1646
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001647static int i915_fbc_status(struct seq_file *m, void *unused)
1648{
David Weinehall36cdd012016-08-22 13:59:31 +03001649 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001650
David Weinehall36cdd012016-08-22 13:59:31 +03001651 if (!HAS_FBC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001652 seq_puts(m, "FBC unsupported on this chipset\n");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001653 return 0;
1654 }
1655
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001656 intel_runtime_pm_get(dev_priv);
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001657 mutex_lock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001658
Paulo Zanoni0e631ad2015-10-14 17:45:36 -03001659 if (intel_fbc_is_active(dev_priv))
Damien Lespiau267f0c92013-06-24 22:59:48 +01001660 seq_puts(m, "FBC enabled\n");
Paulo Zanoni2e8144a2015-06-12 14:36:20 -03001661 else
1662 seq_printf(m, "FBC disabled: %s\n",
Paulo Zanonibf6189c2015-10-27 14:50:03 -02001663 dev_priv->fbc.no_fbc_reason);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001664
Paulo Zanoni0fc6a9d2016-10-21 13:55:46 -02001665 if (intel_fbc_is_active(dev_priv) && INTEL_GEN(dev_priv) >= 7) {
1666 uint32_t mask = INTEL_GEN(dev_priv) >= 8 ?
1667 BDW_FBC_COMPRESSION_MASK :
1668 IVB_FBC_COMPRESSION_MASK;
Paulo Zanoni31b9df12015-06-12 14:36:18 -03001669 seq_printf(m, "Compressing: %s\n",
Paulo Zanoni0fc6a9d2016-10-21 13:55:46 -02001670 yesno(I915_READ(FBC_STATUS2) & mask));
1671 }
Paulo Zanoni31b9df12015-06-12 14:36:18 -03001672
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001673 mutex_unlock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001674 intel_runtime_pm_put(dev_priv);
1675
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001676 return 0;
1677}
1678
Rodrigo Vivida46f932014-08-01 02:04:45 -07001679static int i915_fbc_fc_get(void *data, u64 *val)
1680{
David Weinehall36cdd012016-08-22 13:59:31 +03001681 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001682
David Weinehall36cdd012016-08-22 13:59:31 +03001683 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001684 return -ENODEV;
1685
Rodrigo Vivida46f932014-08-01 02:04:45 -07001686 *val = dev_priv->fbc.false_color;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001687
1688 return 0;
1689}
1690
1691static int i915_fbc_fc_set(void *data, u64 val)
1692{
David Weinehall36cdd012016-08-22 13:59:31 +03001693 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001694 u32 reg;
1695
David Weinehall36cdd012016-08-22 13:59:31 +03001696 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001697 return -ENODEV;
1698
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001699 mutex_lock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001700
1701 reg = I915_READ(ILK_DPFC_CONTROL);
1702 dev_priv->fbc.false_color = val;
1703
1704 I915_WRITE(ILK_DPFC_CONTROL, val ?
1705 (reg | FBC_CTL_FALSE_COLOR) :
1706 (reg & ~FBC_CTL_FALSE_COLOR));
1707
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001708 mutex_unlock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001709 return 0;
1710}
1711
1712DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops,
1713 i915_fbc_fc_get, i915_fbc_fc_set,
1714 "%llu\n");
1715
Paulo Zanoni92d44622013-05-31 16:33:24 -03001716static int i915_ips_status(struct seq_file *m, void *unused)
1717{
David Weinehall36cdd012016-08-22 13:59:31 +03001718 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni92d44622013-05-31 16:33:24 -03001719
David Weinehall36cdd012016-08-22 13:59:31 +03001720 if (!HAS_IPS(dev_priv)) {
Paulo Zanoni92d44622013-05-31 16:33:24 -03001721 seq_puts(m, "not supported\n");
1722 return 0;
1723 }
1724
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001725 intel_runtime_pm_get(dev_priv);
1726
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001727 seq_printf(m, "Enabled by kernel parameter: %s\n",
1728 yesno(i915.enable_ips));
1729
David Weinehall36cdd012016-08-22 13:59:31 +03001730 if (INTEL_GEN(dev_priv) >= 8) {
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001731 seq_puts(m, "Currently: unknown\n");
1732 } else {
1733 if (I915_READ(IPS_CTL) & IPS_ENABLE)
1734 seq_puts(m, "Currently: enabled\n");
1735 else
1736 seq_puts(m, "Currently: disabled\n");
1737 }
Paulo Zanoni92d44622013-05-31 16:33:24 -03001738
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001739 intel_runtime_pm_put(dev_priv);
1740
Paulo Zanoni92d44622013-05-31 16:33:24 -03001741 return 0;
1742}
1743
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001744static int i915_sr_status(struct seq_file *m, void *unused)
1745{
David Weinehall36cdd012016-08-22 13:59:31 +03001746 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001747 bool sr_enabled = false;
1748
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001749 intel_runtime_pm_get(dev_priv);
Chris Wilson9c870d02016-10-24 13:42:15 +01001750 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001751
David Weinehall36cdd012016-08-22 13:59:31 +03001752 if (HAS_PCH_SPLIT(dev_priv))
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001753 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
Jani Nikulac0f86832016-12-07 12:13:04 +02001754 else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) ||
David Weinehall36cdd012016-08-22 13:59:31 +03001755 IS_I945G(dev_priv) || IS_I945GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001756 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001757 else if (IS_I915GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001758 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001759 else if (IS_PINEVIEW(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001760 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001761 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Ander Conselvan de Oliveira77b64552015-06-02 14:17:47 +03001762 sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001763
Chris Wilson9c870d02016-10-24 13:42:15 +01001764 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001765 intel_runtime_pm_put(dev_priv);
1766
Tvrtko Ursulin08c4d7f2016-11-17 12:30:14 +00001767 seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled));
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001768
1769 return 0;
1770}
1771
Jesse Barnes7648fa92010-05-20 14:28:11 -07001772static int i915_emon_status(struct seq_file *m, void *unused)
1773{
David Weinehall36cdd012016-08-22 13:59:31 +03001774 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1775 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001776 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +01001777 int ret;
1778
David Weinehall36cdd012016-08-22 13:59:31 +03001779 if (!IS_GEN5(dev_priv))
Chris Wilson582be6b2012-04-30 19:35:02 +01001780 return -ENODEV;
1781
Chris Wilsonde227ef2010-07-03 07:58:38 +01001782 ret = mutex_lock_interruptible(&dev->struct_mutex);
1783 if (ret)
1784 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001785
1786 temp = i915_mch_val(dev_priv);
1787 chipset = i915_chipset_val(dev_priv);
1788 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +01001789 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001790
1791 seq_printf(m, "GMCH temp: %ld\n", temp);
1792 seq_printf(m, "Chipset power: %ld\n", chipset);
1793 seq_printf(m, "GFX power: %ld\n", gfx);
1794 seq_printf(m, "Total power: %ld\n", chipset + gfx);
1795
1796 return 0;
1797}
1798
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001799static int i915_ring_freq_table(struct seq_file *m, void *unused)
1800{
David Weinehall36cdd012016-08-22 13:59:31 +03001801 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001802 int ret = 0;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001803 int gpu_freq, ia_freq;
Akash Goelf936ec32015-06-29 14:50:22 +05301804 unsigned int max_gpu_freq, min_gpu_freq;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001805
Carlos Santa26310342016-08-17 12:30:41 -07001806 if (!HAS_LLC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001807 seq_puts(m, "unsupported on this chipset\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001808 return 0;
1809 }
1810
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001811 intel_runtime_pm_get(dev_priv);
1812
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001813 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001814 if (ret)
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001815 goto out;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001816
David Weinehall36cdd012016-08-22 13:59:31 +03001817 if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
Akash Goelf936ec32015-06-29 14:50:22 +05301818 /* Convert GT frequency to 50 HZ units */
1819 min_gpu_freq =
1820 dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER;
1821 max_gpu_freq =
1822 dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER;
1823 } else {
1824 min_gpu_freq = dev_priv->rps.min_freq_softlimit;
1825 max_gpu_freq = dev_priv->rps.max_freq_softlimit;
1826 }
1827
Damien Lespiau267f0c92013-06-24 22:59:48 +01001828 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001829
Akash Goelf936ec32015-06-29 14:50:22 +05301830 for (gpu_freq = min_gpu_freq; gpu_freq <= max_gpu_freq; gpu_freq++) {
Ben Widawsky42c05262012-09-26 10:34:00 -07001831 ia_freq = gpu_freq;
1832 sandybridge_pcode_read(dev_priv,
1833 GEN6_PCODE_READ_MIN_FREQ_TABLE,
1834 &ia_freq);
Chris Wilson3ebecd02013-04-12 19:10:13 +01001835 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n",
Akash Goelf936ec32015-06-29 14:50:22 +05301836 intel_gpu_freq(dev_priv, (gpu_freq *
David Weinehall36cdd012016-08-22 13:59:31 +03001837 (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
Rodrigo Vivief11bdb2015-10-28 04:16:45 -07001838 GEN9_FREQ_SCALER : 1))),
Chris Wilson3ebecd02013-04-12 19:10:13 +01001839 ((ia_freq >> 0) & 0xff) * 100,
1840 ((ia_freq >> 8) & 0xff) * 100);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001841 }
1842
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001843 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001844
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001845out:
1846 intel_runtime_pm_put(dev_priv);
1847 return ret;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001848}
1849
Chris Wilson44834a62010-08-19 16:09:23 +01001850static int i915_opregion(struct seq_file *m, void *unused)
1851{
David Weinehall36cdd012016-08-22 13:59:31 +03001852 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1853 struct drm_device *dev = &dev_priv->drm;
Chris Wilson44834a62010-08-19 16:09:23 +01001854 struct intel_opregion *opregion = &dev_priv->opregion;
1855 int ret;
1856
1857 ret = mutex_lock_interruptible(&dev->struct_mutex);
1858 if (ret)
Daniel Vetter0d38f002012-04-21 22:49:10 +02001859 goto out;
Chris Wilson44834a62010-08-19 16:09:23 +01001860
Jani Nikula2455a8e2015-12-14 12:50:53 +02001861 if (opregion->header)
1862 seq_write(m, opregion->header, OPREGION_SIZE);
Chris Wilson44834a62010-08-19 16:09:23 +01001863
1864 mutex_unlock(&dev->struct_mutex);
1865
Daniel Vetter0d38f002012-04-21 22:49:10 +02001866out:
Chris Wilson44834a62010-08-19 16:09:23 +01001867 return 0;
1868}
1869
Jani Nikulaada8f952015-12-15 13:17:12 +02001870static int i915_vbt(struct seq_file *m, void *unused)
1871{
David Weinehall36cdd012016-08-22 13:59:31 +03001872 struct intel_opregion *opregion = &node_to_i915(m->private)->opregion;
Jani Nikulaada8f952015-12-15 13:17:12 +02001873
1874 if (opregion->vbt)
1875 seq_write(m, opregion->vbt, opregion->vbt_size);
1876
1877 return 0;
1878}
1879
Chris Wilson37811fc2010-08-25 22:45:57 +01001880static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
1881{
David Weinehall36cdd012016-08-22 13:59:31 +03001882 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1883 struct drm_device *dev = &dev_priv->drm;
Namrta Salonieb13b8402015-11-27 13:43:11 +05301884 struct intel_framebuffer *fbdev_fb = NULL;
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001885 struct drm_framebuffer *drm_fb;
Chris Wilson188c1ab2016-04-03 14:14:20 +01001886 int ret;
1887
1888 ret = mutex_lock_interruptible(&dev->struct_mutex);
1889 if (ret)
1890 return ret;
Chris Wilson37811fc2010-08-25 22:45:57 +01001891
Daniel Vetter06957262015-08-10 13:34:08 +02001892#ifdef CONFIG_DRM_FBDEV_EMULATION
David Weinehall36cdd012016-08-22 13:59:31 +03001893 if (dev_priv->fbdev) {
1894 fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb);
Chris Wilson37811fc2010-08-25 22:45:57 +01001895
Chris Wilson25bcce92016-07-02 15:36:00 +01001896 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
1897 fbdev_fb->base.width,
1898 fbdev_fb->base.height,
Ville Syrjäläb00c6002016-12-14 23:31:35 +02001899 fbdev_fb->base.format->depth,
Ville Syrjälä272725c2016-12-14 23:32:20 +02001900 fbdev_fb->base.format->cpp[0] * 8,
Ville Syrjäläbae781b2016-11-16 13:33:16 +02001901 fbdev_fb->base.modifier,
Chris Wilson25bcce92016-07-02 15:36:00 +01001902 drm_framebuffer_read_refcount(&fbdev_fb->base));
1903 describe_obj(m, fbdev_fb->obj);
1904 seq_putc(m, '\n');
1905 }
Daniel Vetter4520f532013-10-09 09:18:51 +02001906#endif
Chris Wilson37811fc2010-08-25 22:45:57 +01001907
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001908 mutex_lock(&dev->mode_config.fb_lock);
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001909 drm_for_each_fb(drm_fb, dev) {
Namrta Salonieb13b8402015-11-27 13:43:11 +05301910 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
1911 if (fb == fbdev_fb)
Chris Wilson37811fc2010-08-25 22:45:57 +01001912 continue;
1913
Tvrtko Ursulinc1ca506d2015-02-10 17:16:07 +00001914 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 +01001915 fb->base.width,
1916 fb->base.height,
Ville Syrjäläb00c6002016-12-14 23:31:35 +02001917 fb->base.format->depth,
Ville Syrjälä272725c2016-12-14 23:32:20 +02001918 fb->base.format->cpp[0] * 8,
Ville Syrjäläbae781b2016-11-16 13:33:16 +02001919 fb->base.modifier,
Dave Airlie747a5982016-04-15 15:10:35 +10001920 drm_framebuffer_read_refcount(&fb->base));
Chris Wilson05394f32010-11-08 19:18:58 +00001921 describe_obj(m, fb->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001922 seq_putc(m, '\n');
Chris Wilson37811fc2010-08-25 22:45:57 +01001923 }
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001924 mutex_unlock(&dev->mode_config.fb_lock);
Chris Wilson188c1ab2016-04-03 14:14:20 +01001925 mutex_unlock(&dev->struct_mutex);
Chris Wilson37811fc2010-08-25 22:45:57 +01001926
1927 return 0;
1928}
1929
Chris Wilson7e37f882016-08-02 22:50:21 +01001930static void describe_ctx_ring(struct seq_file *m, struct intel_ring *ring)
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001931{
1932 seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)",
Chris Wilson7e37f882016-08-02 22:50:21 +01001933 ring->space, ring->head, ring->tail,
1934 ring->last_retired_head);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001935}
1936
Ben Widawskye76d3632011-03-19 18:14:29 -07001937static int i915_context_status(struct seq_file *m, void *unused)
1938{
David Weinehall36cdd012016-08-22 13:59:31 +03001939 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1940 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001941 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01001942 struct i915_gem_context *ctx;
Akash Goel3b3f1652016-10-13 22:44:48 +05301943 enum intel_engine_id id;
Dave Gordonc3232b12016-03-23 18:19:53 +00001944 int ret;
Ben Widawskye76d3632011-03-19 18:14:29 -07001945
Daniel Vetterf3d28872014-05-29 23:23:08 +02001946 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07001947 if (ret)
1948 return ret;
1949
Ben Widawskya33afea2013-09-17 21:12:45 -07001950 list_for_each_entry(ctx, &dev_priv->context_list, link) {
Chris Wilson5d1808e2016-04-28 09:56:51 +01001951 seq_printf(m, "HW context %u ", ctx->hw_id);
Chris Wilsonc84455b2016-08-15 10:49:08 +01001952 if (ctx->pid) {
Chris Wilsond28b99a2016-05-24 14:53:39 +01001953 struct task_struct *task;
1954
Chris Wilsonc84455b2016-08-15 10:49:08 +01001955 task = get_pid_task(ctx->pid, PIDTYPE_PID);
Chris Wilsond28b99a2016-05-24 14:53:39 +01001956 if (task) {
1957 seq_printf(m, "(%s [%d]) ",
1958 task->comm, task->pid);
1959 put_task_struct(task);
1960 }
Chris Wilsonc84455b2016-08-15 10:49:08 +01001961 } else if (IS_ERR(ctx->file_priv)) {
1962 seq_puts(m, "(deleted) ");
Chris Wilsond28b99a2016-05-24 14:53:39 +01001963 } else {
1964 seq_puts(m, "(kernel) ");
1965 }
1966
Chris Wilsonbca44d82016-05-24 14:53:41 +01001967 seq_putc(m, ctx->remap_slice ? 'R' : 'r');
1968 seq_putc(m, '\n');
Ben Widawskya33afea2013-09-17 21:12:45 -07001969
Akash Goel3b3f1652016-10-13 22:44:48 +05301970 for_each_engine(engine, dev_priv, id) {
Chris Wilsonbca44d82016-05-24 14:53:41 +01001971 struct intel_context *ce = &ctx->engine[engine->id];
1972
1973 seq_printf(m, "%s: ", engine->name);
1974 seq_putc(m, ce->initialised ? 'I' : 'i');
1975 if (ce->state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001976 describe_obj(m, ce->state->obj);
Chris Wilsondca33ec2016-08-02 22:50:20 +01001977 if (ce->ring)
Chris Wilson7e37f882016-08-02 22:50:21 +01001978 describe_ctx_ring(m, ce->ring);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001979 seq_putc(m, '\n');
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001980 }
1981
Ben Widawskya33afea2013-09-17 21:12:45 -07001982 seq_putc(m, '\n');
Ben Widawskya168c292013-02-14 15:05:12 -08001983 }
1984
Daniel Vetterf3d28872014-05-29 23:23:08 +02001985 mutex_unlock(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07001986
1987 return 0;
1988}
1989
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001990static void i915_dump_lrc_obj(struct seq_file *m,
Chris Wilsone2efd132016-05-24 14:53:34 +01001991 struct i915_gem_context *ctx,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +00001992 struct intel_engine_cs *engine)
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001993{
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001994 struct i915_vma *vma = ctx->engine[engine->id].state;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001995 struct page *page;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001996 int j;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001997
Chris Wilson7069b142016-04-28 09:56:52 +01001998 seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id);
1999
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002000 if (!vma) {
2001 seq_puts(m, "\tFake context\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002002 return;
2003 }
2004
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002005 if (vma->flags & I915_VMA_GLOBAL_BIND)
2006 seq_printf(m, "\tBound in GGTT at 0x%08x\n",
Chris Wilsonbde13eb2016-08-15 10:49:07 +01002007 i915_ggtt_offset(vma));
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002008
Chris Wilsona4f5ea62016-10-28 13:58:35 +01002009 if (i915_gem_object_pin_pages(vma->obj)) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002010 seq_puts(m, "\tFailed to get pages for context object\n\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002011 return;
2012 }
2013
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002014 page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN);
2015 if (page) {
2016 u32 *reg_state = kmap_atomic(page);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002017
2018 for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002019 seq_printf(m,
2020 "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n",
2021 j * 4,
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002022 reg_state[j], reg_state[j + 1],
2023 reg_state[j + 2], reg_state[j + 3]);
2024 }
2025 kunmap_atomic(reg_state);
2026 }
2027
Chris Wilsona4f5ea62016-10-28 13:58:35 +01002028 i915_gem_object_unpin_pages(vma->obj);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002029 seq_putc(m, '\n');
2030}
2031
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01002032static int i915_dump_lrc(struct seq_file *m, void *unused)
2033{
David Weinehall36cdd012016-08-22 13:59:31 +03002034 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2035 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002036 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01002037 struct i915_gem_context *ctx;
Akash Goel3b3f1652016-10-13 22:44:48 +05302038 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002039 int ret;
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01002040
2041 if (!i915.enable_execlists) {
2042 seq_printf(m, "Logical Ring Contexts are disabled\n");
2043 return 0;
2044 }
2045
2046 ret = mutex_lock_interruptible(&dev->struct_mutex);
2047 if (ret)
2048 return ret;
2049
Dave Gordone28e4042016-01-19 19:02:55 +00002050 list_for_each_entry(ctx, &dev_priv->context_list, link)
Akash Goel3b3f1652016-10-13 22:44:48 +05302051 for_each_engine(engine, dev_priv, id)
Chris Wilson24f1d3c2016-04-28 09:56:53 +01002052 i915_dump_lrc_obj(m, ctx, engine);
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01002053
2054 mutex_unlock(&dev->struct_mutex);
2055
2056 return 0;
2057}
2058
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002059static const char *swizzle_string(unsigned swizzle)
2060{
Damien Lespiauaee56cf2013-06-24 22:59:49 +01002061 switch (swizzle) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002062 case I915_BIT_6_SWIZZLE_NONE:
2063 return "none";
2064 case I915_BIT_6_SWIZZLE_9:
2065 return "bit9";
2066 case I915_BIT_6_SWIZZLE_9_10:
2067 return "bit9/bit10";
2068 case I915_BIT_6_SWIZZLE_9_11:
2069 return "bit9/bit11";
2070 case I915_BIT_6_SWIZZLE_9_10_11:
2071 return "bit9/bit10/bit11";
2072 case I915_BIT_6_SWIZZLE_9_17:
2073 return "bit9/bit17";
2074 case I915_BIT_6_SWIZZLE_9_10_17:
2075 return "bit9/bit10/bit17";
2076 case I915_BIT_6_SWIZZLE_UNKNOWN:
Masanari Iida8a168ca2012-12-29 02:00:09 +09002077 return "unknown";
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002078 }
2079
2080 return "bug";
2081}
2082
2083static int i915_swizzle_info(struct seq_file *m, void *data)
2084{
David Weinehall36cdd012016-08-22 13:59:31 +03002085 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002086
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002087 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02002088
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002089 seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
2090 swizzle_string(dev_priv->mm.bit_6_swizzle_x));
2091 seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
2092 swizzle_string(dev_priv->mm.bit_6_swizzle_y));
2093
David Weinehall36cdd012016-08-22 13:59:31 +03002094 if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002095 seq_printf(m, "DDC = 0x%08x\n",
2096 I915_READ(DCC));
Daniel Vetter656bfa32014-11-20 09:26:30 +01002097 seq_printf(m, "DDC2 = 0x%08x\n",
2098 I915_READ(DCC2));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002099 seq_printf(m, "C0DRB3 = 0x%04x\n",
2100 I915_READ16(C0DRB3));
2101 seq_printf(m, "C1DRB3 = 0x%04x\n",
2102 I915_READ16(C1DRB3));
David Weinehall36cdd012016-08-22 13:59:31 +03002103 } else if (INTEL_GEN(dev_priv) >= 6) {
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002104 seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
2105 I915_READ(MAD_DIMM_C0));
2106 seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
2107 I915_READ(MAD_DIMM_C1));
2108 seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
2109 I915_READ(MAD_DIMM_C2));
2110 seq_printf(m, "TILECTL = 0x%08x\n",
2111 I915_READ(TILECTL));
David Weinehall36cdd012016-08-22 13:59:31 +03002112 if (INTEL_GEN(dev_priv) >= 8)
Ben Widawsky9d3203e2013-11-02 21:07:14 -07002113 seq_printf(m, "GAMTARBMODE = 0x%08x\n",
2114 I915_READ(GAMTARBMODE));
2115 else
2116 seq_printf(m, "ARB_MODE = 0x%08x\n",
2117 I915_READ(ARB_MODE));
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002118 seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
2119 I915_READ(DISP_ARB_CTL));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002120 }
Daniel Vetter656bfa32014-11-20 09:26:30 +01002121
2122 if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES)
2123 seq_puts(m, "L-shaped memory detected\n");
2124
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002125 intel_runtime_pm_put(dev_priv);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002126
2127 return 0;
2128}
2129
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002130static int per_file_ctx(int id, void *ptr, void *data)
2131{
Chris Wilsone2efd132016-05-24 14:53:34 +01002132 struct i915_gem_context *ctx = ptr;
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002133 struct seq_file *m = data;
Daniel Vetterae6c4802014-08-06 15:04:53 +02002134 struct i915_hw_ppgtt *ppgtt = ctx->ppgtt;
2135
2136 if (!ppgtt) {
2137 seq_printf(m, " no ppgtt for context %d\n",
2138 ctx->user_handle);
2139 return 0;
2140 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002141
Oscar Mateof83d6512014-05-22 14:13:38 +01002142 if (i915_gem_context_is_default(ctx))
2143 seq_puts(m, " default context:\n");
2144 else
Oscar Mateo821d66d2014-07-03 16:28:00 +01002145 seq_printf(m, " context %d:\n", ctx->user_handle);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002146 ppgtt->debug_dump(ppgtt, m);
2147
2148 return 0;
2149}
2150
David Weinehall36cdd012016-08-22 13:59:31 +03002151static void gen8_ppgtt_info(struct seq_file *m,
2152 struct drm_i915_private *dev_priv)
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002153{
Ben Widawsky77df6772013-11-02 21:07:30 -07002154 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
Akash Goel3b3f1652016-10-13 22:44:48 +05302155 struct intel_engine_cs *engine;
2156 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002157 int i;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002158
Ben Widawsky77df6772013-11-02 21:07:30 -07002159 if (!ppgtt)
2160 return;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002161
Akash Goel3b3f1652016-10-13 22:44:48 +05302162 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002163 seq_printf(m, "%s\n", engine->name);
Ben Widawsky77df6772013-11-02 21:07:30 -07002164 for (i = 0; i < 4; i++) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002165 u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i));
Ben Widawsky77df6772013-11-02 21:07:30 -07002166 pdp <<= 32;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002167 pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i));
Ville Syrjäläa2a5b152014-03-31 18:17:16 +03002168 seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp);
Ben Widawsky77df6772013-11-02 21:07:30 -07002169 }
2170 }
2171}
2172
David Weinehall36cdd012016-08-22 13:59:31 +03002173static void gen6_ppgtt_info(struct seq_file *m,
2174 struct drm_i915_private *dev_priv)
Ben Widawsky77df6772013-11-02 21:07:30 -07002175{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002176 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05302177 enum intel_engine_id id;
Ben Widawsky77df6772013-11-02 21:07:30 -07002178
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002179 if (IS_GEN6(dev_priv))
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002180 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
2181
Akash Goel3b3f1652016-10-13 22:44:48 +05302182 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002183 seq_printf(m, "%s\n", engine->name);
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002184 if (IS_GEN7(dev_priv))
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002185 seq_printf(m, "GFX_MODE: 0x%08x\n",
2186 I915_READ(RING_MODE_GEN7(engine)));
2187 seq_printf(m, "PP_DIR_BASE: 0x%08x\n",
2188 I915_READ(RING_PP_DIR_BASE(engine)));
2189 seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n",
2190 I915_READ(RING_PP_DIR_BASE_READ(engine)));
2191 seq_printf(m, "PP_DIR_DCLV: 0x%08x\n",
2192 I915_READ(RING_PP_DIR_DCLV(engine)));
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002193 }
2194 if (dev_priv->mm.aliasing_ppgtt) {
2195 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
2196
Damien Lespiau267f0c92013-06-24 22:59:48 +01002197 seq_puts(m, "aliasing PPGTT:\n");
Mika Kuoppala44159dd2015-06-25 18:35:07 +03002198 seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd.base.ggtt_offset);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002199
Ben Widawsky87d60b62013-12-06 14:11:29 -08002200 ppgtt->debug_dump(ppgtt, m);
Daniel Vetterae6c4802014-08-06 15:04:53 +02002201 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002202
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002203 seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
Ben Widawsky77df6772013-11-02 21:07:30 -07002204}
2205
2206static int i915_ppgtt_info(struct seq_file *m, void *data)
2207{
David Weinehall36cdd012016-08-22 13:59:31 +03002208 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2209 struct drm_device *dev = &dev_priv->drm;
Michel Thierryea91e402015-07-29 17:23:57 +01002210 struct drm_file *file;
Chris Wilson637ee292016-08-22 14:28:20 +01002211 int ret;
Ben Widawsky77df6772013-11-02 21:07:30 -07002212
Chris Wilson637ee292016-08-22 14:28:20 +01002213 mutex_lock(&dev->filelist_mutex);
2214 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawsky77df6772013-11-02 21:07:30 -07002215 if (ret)
Chris Wilson637ee292016-08-22 14:28:20 +01002216 goto out_unlock;
2217
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002218 intel_runtime_pm_get(dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002219
David Weinehall36cdd012016-08-22 13:59:31 +03002220 if (INTEL_GEN(dev_priv) >= 8)
2221 gen8_ppgtt_info(m, dev_priv);
2222 else if (INTEL_GEN(dev_priv) >= 6)
2223 gen6_ppgtt_info(m, dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002224
Michel Thierryea91e402015-07-29 17:23:57 +01002225 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2226 struct drm_i915_file_private *file_priv = file->driver_priv;
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002227 struct task_struct *task;
Michel Thierryea91e402015-07-29 17:23:57 +01002228
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002229 task = get_pid_task(file->pid, PIDTYPE_PID);
Dan Carpenter06812762015-10-02 18:14:22 +03002230 if (!task) {
2231 ret = -ESRCH;
Chris Wilson637ee292016-08-22 14:28:20 +01002232 goto out_rpm;
Dan Carpenter06812762015-10-02 18:14:22 +03002233 }
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002234 seq_printf(m, "\nproc: %s\n", task->comm);
2235 put_task_struct(task);
Michel Thierryea91e402015-07-29 17:23:57 +01002236 idr_for_each(&file_priv->context_idr, per_file_ctx,
2237 (void *)(unsigned long)m);
2238 }
2239
Chris Wilson637ee292016-08-22 14:28:20 +01002240out_rpm:
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002241 intel_runtime_pm_put(dev_priv);
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002242 mutex_unlock(&dev->struct_mutex);
Chris Wilson637ee292016-08-22 14:28:20 +01002243out_unlock:
2244 mutex_unlock(&dev->filelist_mutex);
Dan Carpenter06812762015-10-02 18:14:22 +03002245 return ret;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002246}
2247
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002248static int count_irq_waiters(struct drm_i915_private *i915)
2249{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002250 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05302251 enum intel_engine_id id;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002252 int count = 0;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002253
Akash Goel3b3f1652016-10-13 22:44:48 +05302254 for_each_engine(engine, i915, id)
Chris Wilson688e6c72016-07-01 17:23:15 +01002255 count += intel_engine_has_waiter(engine);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002256
2257 return count;
2258}
2259
Chris Wilson7466c292016-08-15 09:49:33 +01002260static const char *rps_power_to_str(unsigned int power)
2261{
2262 static const char * const strings[] = {
2263 [LOW_POWER] = "low power",
2264 [BETWEEN] = "mixed",
2265 [HIGH_POWER] = "high power",
2266 };
2267
2268 if (power >= ARRAY_SIZE(strings) || !strings[power])
2269 return "unknown";
2270
2271 return strings[power];
2272}
2273
Chris Wilson1854d5c2015-04-07 16:20:32 +01002274static int i915_rps_boost_info(struct seq_file *m, void *data)
2275{
David Weinehall36cdd012016-08-22 13:59:31 +03002276 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2277 struct drm_device *dev = &dev_priv->drm;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002278 struct drm_file *file;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002279
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002280 seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled);
Chris Wilson28176ef2016-10-28 13:58:56 +01002281 seq_printf(m, "GPU busy? %s [%d requests]\n",
2282 yesno(dev_priv->gt.awake), dev_priv->gt.active_requests);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002283 seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv));
Chris Wilson7466c292016-08-15 09:49:33 +01002284 seq_printf(m, "Frequency requested %d\n",
2285 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
2286 seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n",
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002287 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq),
2288 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit),
2289 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit),
2290 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
Chris Wilson7466c292016-08-15 09:49:33 +01002291 seq_printf(m, " idle:%d, efficient:%d, boost:%d\n",
2292 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq),
2293 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq),
2294 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002295
2296 mutex_lock(&dev->filelist_mutex);
Chris Wilson8d3afd72015-05-21 21:01:47 +01002297 spin_lock(&dev_priv->rps.client_lock);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002298 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2299 struct drm_i915_file_private *file_priv = file->driver_priv;
2300 struct task_struct *task;
2301
2302 rcu_read_lock();
2303 task = pid_task(file->pid, PIDTYPE_PID);
2304 seq_printf(m, "%s [%d]: %d boosts%s\n",
2305 task ? task->comm : "<unknown>",
2306 task ? task->pid : -1,
Chris Wilson2e1b8732015-04-27 13:41:22 +01002307 file_priv->rps.boosts,
2308 list_empty(&file_priv->rps.link) ? "" : ", active");
Chris Wilson1854d5c2015-04-07 16:20:32 +01002309 rcu_read_unlock();
2310 }
Chris Wilson197be2a2016-07-20 09:21:13 +01002311 seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts);
Chris Wilson8d3afd72015-05-21 21:01:47 +01002312 spin_unlock(&dev_priv->rps.client_lock);
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002313 mutex_unlock(&dev->filelist_mutex);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002314
Chris Wilson7466c292016-08-15 09:49:33 +01002315 if (INTEL_GEN(dev_priv) >= 6 &&
2316 dev_priv->rps.enabled &&
Chris Wilson28176ef2016-10-28 13:58:56 +01002317 dev_priv->gt.active_requests) {
Chris Wilson7466c292016-08-15 09:49:33 +01002318 u32 rpup, rpupei;
2319 u32 rpdown, rpdownei;
2320
2321 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
2322 rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK;
2323 rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK;
2324 rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK;
2325 rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK;
2326 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
2327
2328 seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n",
2329 rps_power_to_str(dev_priv->rps.power));
2330 seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n",
2331 100 * rpup / rpupei,
2332 dev_priv->rps.up_threshold);
2333 seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n",
2334 100 * rpdown / rpdownei,
2335 dev_priv->rps.down_threshold);
2336 } else {
2337 seq_puts(m, "\nRPS Autotuning inactive\n");
2338 }
2339
Chris Wilson8d3afd72015-05-21 21:01:47 +01002340 return 0;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002341}
2342
Ben Widawsky63573eb2013-07-04 11:02:07 -07002343static int i915_llc(struct seq_file *m, void *data)
2344{
David Weinehall36cdd012016-08-22 13:59:31 +03002345 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002346 const bool edram = INTEL_GEN(dev_priv) > 8;
Ben Widawsky63573eb2013-07-04 11:02:07 -07002347
David Weinehall36cdd012016-08-22 13:59:31 +03002348 seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv)));
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002349 seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC",
2350 intel_uncore_edram_size(dev_priv)/1024/1024);
Ben Widawsky63573eb2013-07-04 11:02:07 -07002351
2352 return 0;
2353}
2354
Alex Daifdf5d352015-08-12 15:43:37 +01002355static int i915_guc_load_status_info(struct seq_file *m, void *data)
2356{
David Weinehall36cdd012016-08-22 13:59:31 +03002357 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Alex Daifdf5d352015-08-12 15:43:37 +01002358 struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
2359 u32 tmp, i;
2360
Joonas Lahtinen2d1fe072016-04-07 11:08:05 +03002361 if (!HAS_GUC_UCODE(dev_priv))
Alex Daifdf5d352015-08-12 15:43:37 +01002362 return 0;
2363
2364 seq_printf(m, "GuC firmware status:\n");
2365 seq_printf(m, "\tpath: %s\n",
2366 guc_fw->guc_fw_path);
2367 seq_printf(m, "\tfetch: %s\n",
2368 intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status));
2369 seq_printf(m, "\tload: %s\n",
2370 intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
2371 seq_printf(m, "\tversion wanted: %d.%d\n",
2372 guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted);
2373 seq_printf(m, "\tversion found: %d.%d\n",
2374 guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found);
Alex Daifeda33e2015-10-19 16:10:54 -07002375 seq_printf(m, "\theader: offset is %d; size = %d\n",
2376 guc_fw->header_offset, guc_fw->header_size);
2377 seq_printf(m, "\tuCode: offset is %d; size = %d\n",
2378 guc_fw->ucode_offset, guc_fw->ucode_size);
2379 seq_printf(m, "\tRSA: offset is %d; size = %d\n",
2380 guc_fw->rsa_offset, guc_fw->rsa_size);
Alex Daifdf5d352015-08-12 15:43:37 +01002381
2382 tmp = I915_READ(GUC_STATUS);
2383
2384 seq_printf(m, "\nGuC status 0x%08x:\n", tmp);
2385 seq_printf(m, "\tBootrom status = 0x%x\n",
2386 (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT);
2387 seq_printf(m, "\tuKernel status = 0x%x\n",
2388 (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT);
2389 seq_printf(m, "\tMIA Core status = 0x%x\n",
2390 (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT);
2391 seq_puts(m, "\nScratch registers:\n");
2392 for (i = 0; i < 16; i++)
2393 seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i)));
2394
2395 return 0;
2396}
2397
Akash Goel5aa1ee42016-10-12 21:54:36 +05302398static void i915_guc_log_info(struct seq_file *m,
2399 struct drm_i915_private *dev_priv)
2400{
2401 struct intel_guc *guc = &dev_priv->guc;
2402
2403 seq_puts(m, "\nGuC logging stats:\n");
2404
2405 seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n",
2406 guc->log.flush_count[GUC_ISR_LOG_BUFFER],
2407 guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]);
2408
2409 seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n",
2410 guc->log.flush_count[GUC_DPC_LOG_BUFFER],
2411 guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]);
2412
2413 seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n",
2414 guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER],
2415 guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]);
2416
2417 seq_printf(m, "\tTotal flush interrupt count: %u\n",
2418 guc->log.flush_interrupt_count);
2419
2420 seq_printf(m, "\tCapture miss count: %u\n",
2421 guc->log.capture_miss_count);
2422}
2423
Dave Gordon8b417c22015-08-12 15:43:44 +01002424static void i915_guc_client_info(struct seq_file *m,
2425 struct drm_i915_private *dev_priv,
2426 struct i915_guc_client *client)
2427{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002428 struct intel_engine_cs *engine;
Dave Gordonc18468c2016-08-09 15:19:22 +01002429 enum intel_engine_id id;
Dave Gordon8b417c22015-08-12 15:43:44 +01002430 uint64_t tot = 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002431
2432 seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n",
2433 client->priority, client->ctx_index, client->proc_desc_offset);
2434 seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n",
Chris Wilson357248b2016-11-29 12:10:21 +00002435 client->doorbell_id, client->doorbell_offset, client->doorbell_cookie);
Dave Gordon8b417c22015-08-12 15:43:44 +01002436 seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n",
2437 client->wq_size, client->wq_offset, client->wq_tail);
2438
Dave Gordon551aaec2016-05-13 15:36:33 +01002439 seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space);
Dave Gordon8b417c22015-08-12 15:43:44 +01002440 seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail);
2441 seq_printf(m, "\tLast submission result: %d\n", client->retcode);
2442
Akash Goel3b3f1652016-10-13 22:44:48 +05302443 for_each_engine(engine, dev_priv, id) {
Dave Gordonc18468c2016-08-09 15:19:22 +01002444 u64 submissions = client->submissions[id];
2445 tot += submissions;
Dave Gordon8b417c22015-08-12 15:43:44 +01002446 seq_printf(m, "\tSubmissions: %llu %s\n",
Dave Gordonc18468c2016-08-09 15:19:22 +01002447 submissions, engine->name);
Dave Gordon8b417c22015-08-12 15:43:44 +01002448 }
2449 seq_printf(m, "\tTotal: %llu\n", tot);
2450}
2451
2452static int i915_guc_info(struct seq_file *m, void *data)
2453{
David Weinehall36cdd012016-08-22 13:59:31 +03002454 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilson334636c2016-11-29 12:10:20 +00002455 const struct intel_guc *guc = &dev_priv->guc;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002456 struct intel_engine_cs *engine;
Dave Gordonc18468c2016-08-09 15:19:22 +01002457 enum intel_engine_id id;
Chris Wilson334636c2016-11-29 12:10:20 +00002458 u64 total;
Dave Gordon8b417c22015-08-12 15:43:44 +01002459
Chris Wilson334636c2016-11-29 12:10:20 +00002460 if (!guc->execbuf_client) {
2461 seq_printf(m, "GuC submission %s\n",
2462 HAS_GUC_SCHED(dev_priv) ?
2463 "disabled" :
2464 "not supported");
Dave Gordon8b417c22015-08-12 15:43:44 +01002465 return 0;
Chris Wilson334636c2016-11-29 12:10:20 +00002466 }
Dave Gordon8b417c22015-08-12 15:43:44 +01002467
Dave Gordon9636f6d2016-06-13 17:57:28 +01002468 seq_printf(m, "Doorbell map:\n");
Chris Wilson334636c2016-11-29 12:10:20 +00002469 seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc->doorbell_bitmap);
2470 seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc->db_cacheline);
Dave Gordon9636f6d2016-06-13 17:57:28 +01002471
Chris Wilson334636c2016-11-29 12:10:20 +00002472 seq_printf(m, "GuC total action count: %llu\n", guc->action_count);
2473 seq_printf(m, "GuC action failure count: %u\n", guc->action_fail);
2474 seq_printf(m, "GuC last action command: 0x%x\n", guc->action_cmd);
2475 seq_printf(m, "GuC last action status: 0x%x\n", guc->action_status);
2476 seq_printf(m, "GuC last action error code: %d\n", guc->action_err);
Dave Gordon8b417c22015-08-12 15:43:44 +01002477
Chris Wilson334636c2016-11-29 12:10:20 +00002478 total = 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002479 seq_printf(m, "\nGuC submissions:\n");
Akash Goel3b3f1652016-10-13 22:44:48 +05302480 for_each_engine(engine, dev_priv, id) {
Chris Wilson334636c2016-11-29 12:10:20 +00002481 u64 submissions = guc->submissions[id];
Dave Gordonc18468c2016-08-09 15:19:22 +01002482 total += submissions;
Alex Dai397097b2016-01-23 11:58:14 -08002483 seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n",
Chris Wilson334636c2016-11-29 12:10:20 +00002484 engine->name, submissions, guc->last_seqno[id]);
Dave Gordon8b417c22015-08-12 15:43:44 +01002485 }
2486 seq_printf(m, "\t%s: %llu\n", "Total", total);
2487
Chris Wilson334636c2016-11-29 12:10:20 +00002488 seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client);
2489 i915_guc_client_info(m, dev_priv, guc->execbuf_client);
Dave Gordon8b417c22015-08-12 15:43:44 +01002490
Akash Goel5aa1ee42016-10-12 21:54:36 +05302491 i915_guc_log_info(m, dev_priv);
2492
Dave Gordon8b417c22015-08-12 15:43:44 +01002493 /* Add more as required ... */
2494
2495 return 0;
2496}
2497
Alex Dai4c7e77f2015-08-12 15:43:40 +01002498static int i915_guc_log_dump(struct seq_file *m, void *data)
2499{
David Weinehall36cdd012016-08-22 13:59:31 +03002500 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilson8b797af2016-08-15 10:48:51 +01002501 struct drm_i915_gem_object *obj;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002502 int i = 0, pg;
2503
Akash Goeld6b40b42016-10-12 21:54:29 +05302504 if (!dev_priv->guc.log.vma)
Alex Dai4c7e77f2015-08-12 15:43:40 +01002505 return 0;
2506
Akash Goeld6b40b42016-10-12 21:54:29 +05302507 obj = dev_priv->guc.log.vma->obj;
Chris Wilson8b797af2016-08-15 10:48:51 +01002508 for (pg = 0; pg < obj->base.size / PAGE_SIZE; pg++) {
2509 u32 *log = kmap_atomic(i915_gem_object_get_page(obj, pg));
Alex Dai4c7e77f2015-08-12 15:43:40 +01002510
2511 for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4)
2512 seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n",
2513 *(log + i), *(log + i + 1),
2514 *(log + i + 2), *(log + i + 3));
2515
2516 kunmap_atomic(log);
2517 }
2518
2519 seq_putc(m, '\n');
2520
2521 return 0;
2522}
2523
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302524static int i915_guc_log_control_get(void *data, u64 *val)
2525{
2526 struct drm_device *dev = data;
2527 struct drm_i915_private *dev_priv = to_i915(dev);
2528
2529 if (!dev_priv->guc.log.vma)
2530 return -EINVAL;
2531
2532 *val = i915.guc_log_level;
2533
2534 return 0;
2535}
2536
2537static int i915_guc_log_control_set(void *data, u64 val)
2538{
2539 struct drm_device *dev = data;
2540 struct drm_i915_private *dev_priv = to_i915(dev);
2541 int ret;
2542
2543 if (!dev_priv->guc.log.vma)
2544 return -EINVAL;
2545
2546 ret = mutex_lock_interruptible(&dev->struct_mutex);
2547 if (ret)
2548 return ret;
2549
2550 intel_runtime_pm_get(dev_priv);
2551 ret = i915_guc_log_control(dev_priv, val);
2552 intel_runtime_pm_put(dev_priv);
2553
2554 mutex_unlock(&dev->struct_mutex);
2555 return ret;
2556}
2557
2558DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops,
2559 i915_guc_log_control_get, i915_guc_log_control_set,
2560 "%lld\n");
2561
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002562static int i915_edp_psr_status(struct seq_file *m, void *data)
2563{
David Weinehall36cdd012016-08-22 13:59:31 +03002564 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002565 u32 psrperf = 0;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002566 u32 stat[3];
2567 enum pipe pipe;
Rodrigo Vivia031d702013-10-03 16:15:06 -03002568 bool enabled = false;
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002569
David Weinehall36cdd012016-08-22 13:59:31 +03002570 if (!HAS_PSR(dev_priv)) {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002571 seq_puts(m, "PSR not supported\n");
2572 return 0;
2573 }
2574
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002575 intel_runtime_pm_get(dev_priv);
2576
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002577 mutex_lock(&dev_priv->psr.lock);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002578 seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support));
2579 seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok));
Daniel Vetter2807cf62014-07-11 10:30:11 -07002580 seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled));
Rodrigo Vivi5755c782014-06-12 10:16:45 -07002581 seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002582 seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
2583 dev_priv->psr.busy_frontbuffer_bits);
2584 seq_printf(m, "Re-enable work scheduled: %s\n",
2585 yesno(work_busy(&dev_priv->psr.work.work)));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002586
Nagaraju, Vathsala7e3eb592016-12-09 23:42:09 +05302587 if (HAS_DDI(dev_priv)) {
2588 if (dev_priv->psr.psr2_support)
2589 enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE;
2590 else
2591 enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE;
2592 } else {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002593 for_each_pipe(dev_priv, pipe) {
Chris Wilson9c870d02016-10-24 13:42:15 +01002594 enum transcoder cpu_transcoder =
2595 intel_pipe_to_cpu_transcoder(dev_priv, pipe);
2596 enum intel_display_power_domain power_domain;
2597
2598 power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder);
2599 if (!intel_display_power_get_if_enabled(dev_priv,
2600 power_domain))
2601 continue;
2602
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002603 stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) &
2604 VLV_EDP_PSR_CURR_STATE_MASK;
2605 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2606 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2607 enabled = true;
Chris Wilson9c870d02016-10-24 13:42:15 +01002608
2609 intel_display_power_put(dev_priv, power_domain);
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002610 }
2611 }
Rodrigo Vivi60e5ffe2016-02-01 12:02:07 -08002612
2613 seq_printf(m, "Main link in standby mode: %s\n",
2614 yesno(dev_priv->psr.link_standby));
2615
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002616 seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002617
David Weinehall36cdd012016-08-22 13:59:31 +03002618 if (!HAS_DDI(dev_priv))
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002619 for_each_pipe(dev_priv, pipe) {
2620 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2621 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2622 seq_printf(m, " pipe %c", pipe_name(pipe));
2623 }
2624 seq_puts(m, "\n");
2625
Rodrigo Vivi05eec3c2015-11-23 14:16:40 -08002626 /*
2627 * VLV/CHV PSR has no kind of performance counter
2628 * SKL+ Perf counter is reset to 0 everytime DC state is entered
2629 */
David Weinehall36cdd012016-08-22 13:59:31 +03002630 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
Ville Syrjälä443a3892015-11-11 20:34:15 +02002631 psrperf = I915_READ(EDP_PSR_PERF_CNT) &
Rodrigo Vivia031d702013-10-03 16:15:06 -03002632 EDP_PSR_PERF_CNT_MASK;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002633
2634 seq_printf(m, "Performance_Counter: %u\n", psrperf);
2635 }
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302636 if (dev_priv->psr.psr2_support) {
2637 static const char * const live_status[] = {
2638 "IDLE",
2639 "CAPTURE",
2640 "CAPTURE_FS",
2641 "SLEEP",
2642 "BUFON_FW",
2643 "ML_UP",
2644 "SU_STANDBY",
2645 "FAST_SLEEP",
2646 "DEEP_SLEEP",
2647 "BUF_ON",
2648 "TG_ON" };
2649 u8 pos = (I915_READ(EDP_PSR2_STATUS_CTL) &
2650 EDP_PSR2_STATUS_STATE_MASK) >>
2651 EDP_PSR2_STATUS_STATE_SHIFT;
2652
2653 seq_printf(m, "PSR2_STATUS_EDP: %x\n",
2654 I915_READ(EDP_PSR2_STATUS_CTL));
2655
2656 if (pos < ARRAY_SIZE(live_status))
2657 seq_printf(m, "PSR2 live state %s\n",
2658 live_status[pos]);
2659 }
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002660 mutex_unlock(&dev_priv->psr.lock);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002661
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002662 intel_runtime_pm_put(dev_priv);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002663 return 0;
2664}
2665
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002666static int i915_sink_crc(struct seq_file *m, void *data)
2667{
David Weinehall36cdd012016-08-22 13:59:31 +03002668 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2669 struct drm_device *dev = &dev_priv->drm;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002670 struct intel_connector *connector;
2671 struct intel_dp *intel_dp = NULL;
2672 int ret;
2673 u8 crc[6];
2674
2675 drm_modeset_lock_all(dev);
Rodrigo Viviaca5e362015-03-13 16:13:59 -07002676 for_each_intel_connector(dev, connector) {
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002677 struct drm_crtc *crtc;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002678
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002679 if (!connector->base.state->best_encoder)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002680 continue;
2681
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002682 crtc = connector->base.state->crtc;
2683 if (!crtc->state->active)
Paulo Zanonib6ae3c72014-02-13 17:51:33 -02002684 continue;
2685
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002686 if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002687 continue;
2688
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002689 intel_dp = enc_to_intel_dp(connector->base.state->best_encoder);
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002690
2691 ret = intel_dp_sink_crc(intel_dp, crc);
2692 if (ret)
2693 goto out;
2694
2695 seq_printf(m, "%02x%02x%02x%02x%02x%02x\n",
2696 crc[0], crc[1], crc[2],
2697 crc[3], crc[4], crc[5]);
2698 goto out;
2699 }
2700 ret = -ENODEV;
2701out:
2702 drm_modeset_unlock_all(dev);
2703 return ret;
2704}
2705
Jesse Barnesec013e72013-08-20 10:29:23 +01002706static int i915_energy_uJ(struct seq_file *m, void *data)
2707{
David Weinehall36cdd012016-08-22 13:59:31 +03002708 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnesec013e72013-08-20 10:29:23 +01002709 u64 power;
2710 u32 units;
2711
David Weinehall36cdd012016-08-22 13:59:31 +03002712 if (INTEL_GEN(dev_priv) < 6)
Jesse Barnesec013e72013-08-20 10:29:23 +01002713 return -ENODEV;
2714
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002715 intel_runtime_pm_get(dev_priv);
2716
Jesse Barnesec013e72013-08-20 10:29:23 +01002717 rdmsrl(MSR_RAPL_POWER_UNIT, power);
2718 power = (power & 0x1f00) >> 8;
2719 units = 1000000 / (1 << power); /* convert to uJ */
2720 power = I915_READ(MCH_SECP_NRG_STTS);
2721 power *= units;
2722
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002723 intel_runtime_pm_put(dev_priv);
2724
Jesse Barnesec013e72013-08-20 10:29:23 +01002725 seq_printf(m, "%llu", (long long unsigned)power);
Paulo Zanoni371db662013-08-19 13:18:10 -03002726
2727 return 0;
2728}
2729
Damien Lespiau6455c872015-06-04 18:23:57 +01002730static int i915_runtime_pm_status(struct seq_file *m, void *unused)
Paulo Zanoni371db662013-08-19 13:18:10 -03002731{
David Weinehall36cdd012016-08-22 13:59:31 +03002732 struct drm_i915_private *dev_priv = node_to_i915(m->private);
David Weinehall52a05c32016-08-22 13:32:44 +03002733 struct pci_dev *pdev = dev_priv->drm.pdev;
Paulo Zanoni371db662013-08-19 13:18:10 -03002734
Chris Wilsona156e642016-04-03 14:14:21 +01002735 if (!HAS_RUNTIME_PM(dev_priv))
2736 seq_puts(m, "Runtime power management not supported\n");
Paulo Zanoni371db662013-08-19 13:18:10 -03002737
Chris Wilson67d97da2016-07-04 08:08:31 +01002738 seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake));
Paulo Zanoni371db662013-08-19 13:18:10 -03002739 seq_printf(m, "IRQs disabled: %s\n",
Jesse Barnes9df7575f2014-06-20 09:29:20 -07002740 yesno(!intel_irqs_enabled(dev_priv)));
Chris Wilson0d804182015-06-15 12:52:28 +01002741#ifdef CONFIG_PM
Damien Lespiaua6aaec82015-06-04 18:23:58 +01002742 seq_printf(m, "Usage count: %d\n",
David Weinehall36cdd012016-08-22 13:59:31 +03002743 atomic_read(&dev_priv->drm.dev->power.usage_count));
Chris Wilson0d804182015-06-15 12:52:28 +01002744#else
2745 seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n");
2746#endif
Chris Wilsona156e642016-04-03 14:14:21 +01002747 seq_printf(m, "PCI device power state: %s [%d]\n",
David Weinehall52a05c32016-08-22 13:32:44 +03002748 pci_power_name(pdev->current_state),
2749 pdev->current_state);
Paulo Zanoni371db662013-08-19 13:18:10 -03002750
Jesse Barnesec013e72013-08-20 10:29:23 +01002751 return 0;
2752}
2753
Imre Deak1da51582013-11-25 17:15:35 +02002754static int i915_power_domain_info(struct seq_file *m, void *unused)
2755{
David Weinehall36cdd012016-08-22 13:59:31 +03002756 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak1da51582013-11-25 17:15:35 +02002757 struct i915_power_domains *power_domains = &dev_priv->power_domains;
2758 int i;
2759
2760 mutex_lock(&power_domains->lock);
2761
2762 seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count");
2763 for (i = 0; i < power_domains->power_well_count; i++) {
2764 struct i915_power_well *power_well;
2765 enum intel_display_power_domain power_domain;
2766
2767 power_well = &power_domains->power_wells[i];
2768 seq_printf(m, "%-25s %d\n", power_well->name,
2769 power_well->count);
2770
2771 for (power_domain = 0; power_domain < POWER_DOMAIN_NUM;
2772 power_domain++) {
2773 if (!(BIT(power_domain) & power_well->domains))
2774 continue;
2775
2776 seq_printf(m, " %-23s %d\n",
Daniel Stone9895ad02015-11-20 15:55:33 +00002777 intel_display_power_domain_str(power_domain),
Imre Deak1da51582013-11-25 17:15:35 +02002778 power_domains->domain_use_count[power_domain]);
2779 }
2780 }
2781
2782 mutex_unlock(&power_domains->lock);
2783
2784 return 0;
2785}
2786
Damien Lespiaub7cec662015-10-27 14:47:01 +02002787static int i915_dmc_info(struct seq_file *m, void *unused)
2788{
David Weinehall36cdd012016-08-22 13:59:31 +03002789 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Damien Lespiaub7cec662015-10-27 14:47:01 +02002790 struct intel_csr *csr;
2791
David Weinehall36cdd012016-08-22 13:59:31 +03002792 if (!HAS_CSR(dev_priv)) {
Damien Lespiaub7cec662015-10-27 14:47:01 +02002793 seq_puts(m, "not supported\n");
2794 return 0;
2795 }
2796
2797 csr = &dev_priv->csr;
2798
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002799 intel_runtime_pm_get(dev_priv);
2800
Damien Lespiaub7cec662015-10-27 14:47:01 +02002801 seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL));
2802 seq_printf(m, "path: %s\n", csr->fw_path);
2803
2804 if (!csr->dmc_payload)
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002805 goto out;
Damien Lespiaub7cec662015-10-27 14:47:01 +02002806
2807 seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version),
2808 CSR_VERSION_MINOR(csr->version));
2809
David Weinehall36cdd012016-08-22 13:59:31 +03002810 if (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6)) {
Damien Lespiau83372062015-10-30 17:53:32 +02002811 seq_printf(m, "DC3 -> DC5 count: %d\n",
2812 I915_READ(SKL_CSR_DC3_DC5_COUNT));
2813 seq_printf(m, "DC5 -> DC6 count: %d\n",
2814 I915_READ(SKL_CSR_DC5_DC6_COUNT));
David Weinehall36cdd012016-08-22 13:59:31 +03002815 } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) {
Mika Kuoppala16e11b92015-10-27 14:47:03 +02002816 seq_printf(m, "DC3 -> DC5 count: %d\n",
2817 I915_READ(BXT_CSR_DC3_DC5_COUNT));
Damien Lespiau83372062015-10-30 17:53:32 +02002818 }
2819
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002820out:
2821 seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0)));
2822 seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE));
2823 seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL));
2824
Damien Lespiau83372062015-10-30 17:53:32 +02002825 intel_runtime_pm_put(dev_priv);
2826
Damien Lespiaub7cec662015-10-27 14:47:01 +02002827 return 0;
2828}
2829
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002830static void intel_seq_print_mode(struct seq_file *m, int tabs,
2831 struct drm_display_mode *mode)
2832{
2833 int i;
2834
2835 for (i = 0; i < tabs; i++)
2836 seq_putc(m, '\t');
2837
2838 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",
2839 mode->base.id, mode->name,
2840 mode->vrefresh, mode->clock,
2841 mode->hdisplay, mode->hsync_start,
2842 mode->hsync_end, mode->htotal,
2843 mode->vdisplay, mode->vsync_start,
2844 mode->vsync_end, mode->vtotal,
2845 mode->type, mode->flags);
2846}
2847
2848static void intel_encoder_info(struct seq_file *m,
2849 struct intel_crtc *intel_crtc,
2850 struct intel_encoder *intel_encoder)
2851{
David Weinehall36cdd012016-08-22 13:59:31 +03002852 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2853 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002854 struct drm_crtc *crtc = &intel_crtc->base;
2855 struct intel_connector *intel_connector;
2856 struct drm_encoder *encoder;
2857
2858 encoder = &intel_encoder->base;
2859 seq_printf(m, "\tencoder %d: type: %s, connectors:\n",
Jani Nikula8e329a032014-06-03 14:56:21 +03002860 encoder->base.id, encoder->name);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002861 for_each_connector_on_encoder(dev, encoder, intel_connector) {
2862 struct drm_connector *connector = &intel_connector->base;
2863 seq_printf(m, "\t\tconnector %d: type: %s, status: %s",
2864 connector->base.id,
Jani Nikulac23cc412014-06-03 14:56:17 +03002865 connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002866 drm_get_connector_status_name(connector->status));
2867 if (connector->status == connector_status_connected) {
2868 struct drm_display_mode *mode = &crtc->mode;
2869 seq_printf(m, ", mode:\n");
2870 intel_seq_print_mode(m, 2, mode);
2871 } else {
2872 seq_putc(m, '\n');
2873 }
2874 }
2875}
2876
2877static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc)
2878{
David Weinehall36cdd012016-08-22 13:59:31 +03002879 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2880 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002881 struct drm_crtc *crtc = &intel_crtc->base;
2882 struct intel_encoder *intel_encoder;
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002883 struct drm_plane_state *plane_state = crtc->primary->state;
2884 struct drm_framebuffer *fb = plane_state->fb;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002885
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002886 if (fb)
Matt Roper5aa8a932014-06-16 10:12:55 -07002887 seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n",
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002888 fb->base.id, plane_state->src_x >> 16,
2889 plane_state->src_y >> 16, fb->width, fb->height);
Matt Roper5aa8a932014-06-16 10:12:55 -07002890 else
2891 seq_puts(m, "\tprimary plane disabled\n");
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002892 for_each_encoder_on_crtc(dev, crtc, intel_encoder)
2893 intel_encoder_info(m, intel_crtc, intel_encoder);
2894}
2895
2896static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
2897{
2898 struct drm_display_mode *mode = panel->fixed_mode;
2899
2900 seq_printf(m, "\tfixed mode:\n");
2901 intel_seq_print_mode(m, 2, mode);
2902}
2903
2904static void intel_dp_info(struct seq_file *m,
2905 struct intel_connector *intel_connector)
2906{
2907 struct intel_encoder *intel_encoder = intel_connector->encoder;
2908 struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
2909
2910 seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]);
Jani Nikula742f4912015-09-03 11:16:09 +03002911 seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio));
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02002912 if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002913 intel_panel_info(m, &intel_connector->panel);
Mika Kahola80209e52016-09-09 14:10:57 +03002914
2915 drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports,
2916 &intel_dp->aux);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002917}
2918
Libin Yang9a148a92016-11-28 20:07:05 +08002919static void intel_dp_mst_info(struct seq_file *m,
2920 struct intel_connector *intel_connector)
2921{
2922 struct intel_encoder *intel_encoder = intel_connector->encoder;
2923 struct intel_dp_mst_encoder *intel_mst =
2924 enc_to_mst(&intel_encoder->base);
2925 struct intel_digital_port *intel_dig_port = intel_mst->primary;
2926 struct intel_dp *intel_dp = &intel_dig_port->dp;
2927 bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr,
2928 intel_connector->port);
2929
2930 seq_printf(m, "\taudio support: %s\n", yesno(has_audio));
2931}
2932
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002933static void intel_hdmi_info(struct seq_file *m,
2934 struct intel_connector *intel_connector)
2935{
2936 struct intel_encoder *intel_encoder = intel_connector->encoder;
2937 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
2938
Jani Nikula742f4912015-09-03 11:16:09 +03002939 seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio));
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002940}
2941
2942static void intel_lvds_info(struct seq_file *m,
2943 struct intel_connector *intel_connector)
2944{
2945 intel_panel_info(m, &intel_connector->panel);
2946}
2947
2948static void intel_connector_info(struct seq_file *m,
2949 struct drm_connector *connector)
2950{
2951 struct intel_connector *intel_connector = to_intel_connector(connector);
2952 struct intel_encoder *intel_encoder = intel_connector->encoder;
Jesse Barnesf103fc72014-02-20 12:39:57 -08002953 struct drm_display_mode *mode;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002954
2955 seq_printf(m, "connector %d: type %s, status: %s\n",
Jani Nikulac23cc412014-06-03 14:56:17 +03002956 connector->base.id, connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002957 drm_get_connector_status_name(connector->status));
2958 if (connector->status == connector_status_connected) {
2959 seq_printf(m, "\tname: %s\n", connector->display_info.name);
2960 seq_printf(m, "\tphysical dimensions: %dx%dmm\n",
2961 connector->display_info.width_mm,
2962 connector->display_info.height_mm);
2963 seq_printf(m, "\tsubpixel order: %s\n",
2964 drm_get_subpixel_order_name(connector->display_info.subpixel_order));
2965 seq_printf(m, "\tCEA rev: %d\n",
2966 connector->display_info.cea_rev);
2967 }
Maarten Lankhorstee648a72016-06-21 12:00:38 +02002968
2969 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
2970 return;
2971
2972 switch (connector->connector_type) {
2973 case DRM_MODE_CONNECTOR_DisplayPort:
2974 case DRM_MODE_CONNECTOR_eDP:
Libin Yang9a148a92016-11-28 20:07:05 +08002975 if (intel_encoder->type == INTEL_OUTPUT_DP_MST)
2976 intel_dp_mst_info(m, intel_connector);
2977 else
2978 intel_dp_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02002979 break;
2980 case DRM_MODE_CONNECTOR_LVDS:
2981 if (intel_encoder->type == INTEL_OUTPUT_LVDS)
Dave Airlie36cd7442014-05-02 13:44:18 +10002982 intel_lvds_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02002983 break;
2984 case DRM_MODE_CONNECTOR_HDMIA:
2985 if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
2986 intel_encoder->type == INTEL_OUTPUT_UNKNOWN)
2987 intel_hdmi_info(m, intel_connector);
2988 break;
2989 default:
2990 break;
Dave Airlie36cd7442014-05-02 13:44:18 +10002991 }
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002992
Jesse Barnesf103fc72014-02-20 12:39:57 -08002993 seq_printf(m, "\tmodes:\n");
2994 list_for_each_entry(mode, &connector->modes, head)
2995 intel_seq_print_mode(m, 2, mode);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002996}
2997
David Weinehall36cdd012016-08-22 13:59:31 +03002998static bool cursor_active(struct drm_i915_private *dev_priv, int pipe)
Chris Wilson065f2ec2014-03-12 09:13:13 +00002999{
Chris Wilson065f2ec2014-03-12 09:13:13 +00003000 u32 state;
3001
Jani Nikula2a307c22016-11-30 17:43:04 +02003002 if (IS_I845G(dev_priv) || IS_I865G(dev_priv))
Ville Syrjälä0b87c242015-09-22 19:47:51 +03003003 state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003004 else
Ville Syrjälä5efb3e22014-04-09 13:28:53 +03003005 state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003006
3007 return state;
3008}
3009
David Weinehall36cdd012016-08-22 13:59:31 +03003010static bool cursor_position(struct drm_i915_private *dev_priv,
3011 int pipe, int *x, int *y)
Chris Wilson065f2ec2014-03-12 09:13:13 +00003012{
Chris Wilson065f2ec2014-03-12 09:13:13 +00003013 u32 pos;
3014
Ville Syrjälä5efb3e22014-04-09 13:28:53 +03003015 pos = I915_READ(CURPOS(pipe));
Chris Wilson065f2ec2014-03-12 09:13:13 +00003016
3017 *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK;
3018 if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT))
3019 *x = -*x;
3020
3021 *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK;
3022 if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT))
3023 *y = -*y;
3024
David Weinehall36cdd012016-08-22 13:59:31 +03003025 return cursor_active(dev_priv, pipe);
Chris Wilson065f2ec2014-03-12 09:13:13 +00003026}
3027
Robert Fekete3abc4e02015-10-27 16:58:32 +01003028static const char *plane_type(enum drm_plane_type type)
3029{
3030 switch (type) {
3031 case DRM_PLANE_TYPE_OVERLAY:
3032 return "OVL";
3033 case DRM_PLANE_TYPE_PRIMARY:
3034 return "PRI";
3035 case DRM_PLANE_TYPE_CURSOR:
3036 return "CUR";
3037 /*
3038 * Deliberately omitting default: to generate compiler warnings
3039 * when a new drm_plane_type gets added.
3040 */
3041 }
3042
3043 return "unknown";
3044}
3045
3046static const char *plane_rotation(unsigned int rotation)
3047{
3048 static char buf[48];
3049 /*
3050 * According to doc only one DRM_ROTATE_ is allowed but this
3051 * will print them all to visualize if the values are misused
3052 */
3053 snprintf(buf, sizeof(buf),
3054 "%s%s%s%s%s%s(0x%08x)",
Joonas Lahtinen31ad61e2016-07-29 08:50:05 +03003055 (rotation & DRM_ROTATE_0) ? "0 " : "",
3056 (rotation & DRM_ROTATE_90) ? "90 " : "",
3057 (rotation & DRM_ROTATE_180) ? "180 " : "",
3058 (rotation & DRM_ROTATE_270) ? "270 " : "",
3059 (rotation & DRM_REFLECT_X) ? "FLIPX " : "",
3060 (rotation & DRM_REFLECT_Y) ? "FLIPY " : "",
Robert Fekete3abc4e02015-10-27 16:58:32 +01003061 rotation);
3062
3063 return buf;
3064}
3065
3066static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3067{
David Weinehall36cdd012016-08-22 13:59:31 +03003068 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3069 struct drm_device *dev = &dev_priv->drm;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003070 struct intel_plane *intel_plane;
3071
3072 for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
3073 struct drm_plane_state *state;
3074 struct drm_plane *plane = &intel_plane->base;
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003075 struct drm_format_name_buf format_name;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003076
3077 if (!plane->state) {
3078 seq_puts(m, "plane->state is NULL!\n");
3079 continue;
3080 }
3081
3082 state = plane->state;
3083
Eric Engestrom90844f02016-08-15 01:02:38 +01003084 if (state->fb) {
Ville Syrjälä438b74a2016-12-14 23:32:55 +02003085 drm_get_format_name(state->fb->format->format,
3086 &format_name);
Eric Engestrom90844f02016-08-15 01:02:38 +01003087 } else {
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003088 sprintf(format_name.str, "N/A");
Eric Engestrom90844f02016-08-15 01:02:38 +01003089 }
3090
Robert Fekete3abc4e02015-10-27 16:58:32 +01003091 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",
3092 plane->base.id,
3093 plane_type(intel_plane->base.type),
3094 state->crtc_x, state->crtc_y,
3095 state->crtc_w, state->crtc_h,
3096 (state->src_x >> 16),
3097 ((state->src_x & 0xffff) * 15625) >> 10,
3098 (state->src_y >> 16),
3099 ((state->src_y & 0xffff) * 15625) >> 10,
3100 (state->src_w >> 16),
3101 ((state->src_w & 0xffff) * 15625) >> 10,
3102 (state->src_h >> 16),
3103 ((state->src_h & 0xffff) * 15625) >> 10,
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003104 format_name.str,
Robert Fekete3abc4e02015-10-27 16:58:32 +01003105 plane_rotation(state->rotation));
3106 }
3107}
3108
3109static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3110{
3111 struct intel_crtc_state *pipe_config;
3112 int num_scalers = intel_crtc->num_scalers;
3113 int i;
3114
3115 pipe_config = to_intel_crtc_state(intel_crtc->base.state);
3116
3117 /* Not all platformas have a scaler */
3118 if (num_scalers) {
3119 seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d",
3120 num_scalers,
3121 pipe_config->scaler_state.scaler_users,
3122 pipe_config->scaler_state.scaler_id);
3123
A.Sunil Kamath58415912016-11-20 23:20:26 +05303124 for (i = 0; i < num_scalers; i++) {
Robert Fekete3abc4e02015-10-27 16:58:32 +01003125 struct intel_scaler *sc =
3126 &pipe_config->scaler_state.scalers[i];
3127
3128 seq_printf(m, ", scalers[%d]: use=%s, mode=%x",
3129 i, yesno(sc->in_use), sc->mode);
3130 }
3131 seq_puts(m, "\n");
3132 } else {
3133 seq_puts(m, "\tNo scalers available on this platform\n");
3134 }
3135}
3136
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003137static int i915_display_info(struct seq_file *m, void *unused)
3138{
David Weinehall36cdd012016-08-22 13:59:31 +03003139 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3140 struct drm_device *dev = &dev_priv->drm;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003141 struct intel_crtc *crtc;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003142 struct drm_connector *connector;
3143
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003144 intel_runtime_pm_get(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003145 drm_modeset_lock_all(dev);
3146 seq_printf(m, "CRTC info\n");
3147 seq_printf(m, "---------\n");
Damien Lespiaud3fcc802014-05-13 23:32:22 +01003148 for_each_intel_crtc(dev, crtc) {
Chris Wilson065f2ec2014-03-12 09:13:13 +00003149 bool active;
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003150 struct intel_crtc_state *pipe_config;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003151 int x, y;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003152
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003153 pipe_config = to_intel_crtc_state(crtc->base.state);
3154
Robert Fekete3abc4e02015-10-27 16:58:32 +01003155 seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n",
Chris Wilson065f2ec2014-03-12 09:13:13 +00003156 crtc->base.base.id, pipe_name(crtc->pipe),
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003157 yesno(pipe_config->base.active),
Robert Fekete3abc4e02015-10-27 16:58:32 +01003158 pipe_config->pipe_src_w, pipe_config->pipe_src_h,
3159 yesno(pipe_config->dither), pipe_config->pipe_bpp);
3160
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003161 if (pipe_config->base.active) {
Chris Wilson065f2ec2014-03-12 09:13:13 +00003162 intel_crtc_info(m, crtc);
3163
David Weinehall36cdd012016-08-22 13:59:31 +03003164 active = cursor_position(dev_priv, crtc->pipe, &x, &y);
Chris Wilson57127ef2014-07-04 08:20:11 +01003165 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 +03003166 yesno(crtc->cursor_base),
Matt Roper3dd512f2015-02-27 10:12:00 -08003167 x, y, crtc->base.cursor->state->crtc_w,
3168 crtc->base.cursor->state->crtc_h,
Chris Wilson57127ef2014-07-04 08:20:11 +01003169 crtc->cursor_addr, yesno(active));
Robert Fekete3abc4e02015-10-27 16:58:32 +01003170 intel_scaler_info(m, crtc);
3171 intel_plane_info(m, crtc);
Paulo Zanonia23dc652014-04-01 14:55:11 -03003172 }
Daniel Vettercace8412014-05-22 17:56:31 +02003173
3174 seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n",
3175 yesno(!crtc->cpu_fifo_underrun_disabled),
3176 yesno(!crtc->pch_fifo_underrun_disabled));
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003177 }
3178
3179 seq_printf(m, "\n");
3180 seq_printf(m, "Connector info\n");
3181 seq_printf(m, "--------------\n");
3182 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
3183 intel_connector_info(m, connector);
3184 }
3185 drm_modeset_unlock_all(dev);
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003186 intel_runtime_pm_put(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003187
3188 return 0;
3189}
3190
Chris Wilson1b365952016-10-04 21:11:31 +01003191static int i915_engine_info(struct seq_file *m, void *unused)
3192{
3193 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3194 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05303195 enum intel_engine_id id;
Chris Wilson1b365952016-10-04 21:11:31 +01003196
Chris Wilson9c870d02016-10-24 13:42:15 +01003197 intel_runtime_pm_get(dev_priv);
3198
Akash Goel3b3f1652016-10-13 22:44:48 +05303199 for_each_engine(engine, dev_priv, id) {
Chris Wilson1b365952016-10-04 21:11:31 +01003200 struct intel_breadcrumbs *b = &engine->breadcrumbs;
3201 struct drm_i915_gem_request *rq;
3202 struct rb_node *rb;
3203 u64 addr;
3204
3205 seq_printf(m, "%s\n", engine->name);
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02003206 seq_printf(m, "\tcurrent seqno %x, last %x, hangcheck %x [%d ms]\n",
Chris Wilson1b365952016-10-04 21:11:31 +01003207 intel_engine_get_seqno(engine),
Chris Wilsoncb399ea2016-11-01 10:03:16 +00003208 intel_engine_last_submit(engine),
Chris Wilson1b365952016-10-04 21:11:31 +01003209 engine->hangcheck.seqno,
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02003210 jiffies_to_msecs(jiffies - engine->hangcheck.action_timestamp));
Chris Wilson1b365952016-10-04 21:11:31 +01003211
3212 rcu_read_lock();
3213
3214 seq_printf(m, "\tRequests:\n");
3215
Chris Wilson73cb9702016-10-28 13:58:46 +01003216 rq = list_first_entry(&engine->timeline->requests,
3217 struct drm_i915_gem_request, link);
3218 if (&rq->link != &engine->timeline->requests)
Chris Wilson1b365952016-10-04 21:11:31 +01003219 print_request(m, rq, "\t\tfirst ");
3220
Chris Wilson73cb9702016-10-28 13:58:46 +01003221 rq = list_last_entry(&engine->timeline->requests,
3222 struct drm_i915_gem_request, link);
3223 if (&rq->link != &engine->timeline->requests)
Chris Wilson1b365952016-10-04 21:11:31 +01003224 print_request(m, rq, "\t\tlast ");
3225
3226 rq = i915_gem_find_active_request(engine);
3227 if (rq) {
3228 print_request(m, rq, "\t\tactive ");
3229 seq_printf(m,
3230 "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n",
3231 rq->head, rq->postfix, rq->tail,
3232 rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u,
3233 rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u);
3234 }
3235
3236 seq_printf(m, "\tRING_START: 0x%08x [0x%08x]\n",
3237 I915_READ(RING_START(engine->mmio_base)),
3238 rq ? i915_ggtt_offset(rq->ring->vma) : 0);
3239 seq_printf(m, "\tRING_HEAD: 0x%08x [0x%08x]\n",
3240 I915_READ(RING_HEAD(engine->mmio_base)) & HEAD_ADDR,
3241 rq ? rq->ring->head : 0);
3242 seq_printf(m, "\tRING_TAIL: 0x%08x [0x%08x]\n",
3243 I915_READ(RING_TAIL(engine->mmio_base)) & TAIL_ADDR,
3244 rq ? rq->ring->tail : 0);
3245 seq_printf(m, "\tRING_CTL: 0x%08x [%s]\n",
3246 I915_READ(RING_CTL(engine->mmio_base)),
3247 I915_READ(RING_CTL(engine->mmio_base)) & (RING_WAIT | RING_WAIT_SEMAPHORE) ? "waiting" : "");
3248
3249 rcu_read_unlock();
3250
3251 addr = intel_engine_get_active_head(engine);
3252 seq_printf(m, "\tACTHD: 0x%08x_%08x\n",
3253 upper_32_bits(addr), lower_32_bits(addr));
3254 addr = intel_engine_get_last_batch_head(engine);
3255 seq_printf(m, "\tBBADDR: 0x%08x_%08x\n",
3256 upper_32_bits(addr), lower_32_bits(addr));
3257
3258 if (i915.enable_execlists) {
3259 u32 ptr, read, write;
Chris Wilson20311bd2016-11-14 20:41:03 +00003260 struct rb_node *rb;
Chris Wilson1b365952016-10-04 21:11:31 +01003261
3262 seq_printf(m, "\tExeclist status: 0x%08x %08x\n",
3263 I915_READ(RING_EXECLIST_STATUS_LO(engine)),
3264 I915_READ(RING_EXECLIST_STATUS_HI(engine)));
3265
3266 ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine));
3267 read = GEN8_CSB_READ_PTR(ptr);
3268 write = GEN8_CSB_WRITE_PTR(ptr);
3269 seq_printf(m, "\tExeclist CSB read %d, write %d\n",
3270 read, write);
3271 if (read >= GEN8_CSB_ENTRIES)
3272 read = 0;
3273 if (write >= GEN8_CSB_ENTRIES)
3274 write = 0;
3275 if (read > write)
3276 write += GEN8_CSB_ENTRIES;
3277 while (read < write) {
3278 unsigned int idx = ++read % GEN8_CSB_ENTRIES;
3279
3280 seq_printf(m, "\tExeclist CSB[%d]: 0x%08x, context: %d\n",
3281 idx,
3282 I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, idx)),
3283 I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, idx)));
3284 }
3285
3286 rcu_read_lock();
3287 rq = READ_ONCE(engine->execlist_port[0].request);
3288 if (rq)
3289 print_request(m, rq, "\t\tELSP[0] ");
3290 else
3291 seq_printf(m, "\t\tELSP[0] idle\n");
3292 rq = READ_ONCE(engine->execlist_port[1].request);
3293 if (rq)
3294 print_request(m, rq, "\t\tELSP[1] ");
3295 else
3296 seq_printf(m, "\t\tELSP[1] idle\n");
3297 rcu_read_unlock();
Chris Wilsonc8247c02016-10-27 01:03:43 +01003298
Chris Wilson663f71e2016-11-14 20:41:00 +00003299 spin_lock_irq(&engine->timeline->lock);
Chris Wilson20311bd2016-11-14 20:41:03 +00003300 for (rb = engine->execlist_first; rb; rb = rb_next(rb)) {
3301 rq = rb_entry(rb, typeof(*rq), priotree.node);
Chris Wilsonc8247c02016-10-27 01:03:43 +01003302 print_request(m, rq, "\t\tQ ");
3303 }
Chris Wilson663f71e2016-11-14 20:41:00 +00003304 spin_unlock_irq(&engine->timeline->lock);
Chris Wilson1b365952016-10-04 21:11:31 +01003305 } else if (INTEL_GEN(dev_priv) > 6) {
3306 seq_printf(m, "\tPP_DIR_BASE: 0x%08x\n",
3307 I915_READ(RING_PP_DIR_BASE(engine)));
3308 seq_printf(m, "\tPP_DIR_BASE_READ: 0x%08x\n",
3309 I915_READ(RING_PP_DIR_BASE_READ(engine)));
3310 seq_printf(m, "\tPP_DIR_DCLV: 0x%08x\n",
3311 I915_READ(RING_PP_DIR_DCLV(engine)));
3312 }
3313
Chris Wilsonf6168e32016-10-28 13:58:55 +01003314 spin_lock_irq(&b->lock);
Chris Wilson1b365952016-10-04 21:11:31 +01003315 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +08003316 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson1b365952016-10-04 21:11:31 +01003317
3318 seq_printf(m, "\t%s [%d] waiting for %x\n",
3319 w->tsk->comm, w->tsk->pid, w->seqno);
3320 }
Chris Wilsonf6168e32016-10-28 13:58:55 +01003321 spin_unlock_irq(&b->lock);
Chris Wilson1b365952016-10-04 21:11:31 +01003322
3323 seq_puts(m, "\n");
3324 }
3325
Chris Wilson9c870d02016-10-24 13:42:15 +01003326 intel_runtime_pm_put(dev_priv);
3327
Chris Wilson1b365952016-10-04 21:11:31 +01003328 return 0;
3329}
3330
Ben Widawskye04934c2014-06-30 09:53:42 -07003331static int i915_semaphore_status(struct seq_file *m, void *unused)
3332{
David Weinehall36cdd012016-08-22 13:59:31 +03003333 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3334 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003335 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003336 int num_rings = INTEL_INFO(dev_priv)->num_rings;
Dave Gordonc3232b12016-03-23 18:19:53 +00003337 enum intel_engine_id id;
3338 int j, ret;
Ben Widawskye04934c2014-06-30 09:53:42 -07003339
Chris Wilson39df9192016-07-20 13:31:57 +01003340 if (!i915.semaphores) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003341 seq_puts(m, "Semaphores are disabled\n");
3342 return 0;
3343 }
3344
3345 ret = mutex_lock_interruptible(&dev->struct_mutex);
3346 if (ret)
3347 return ret;
Paulo Zanoni03872062014-07-09 14:31:57 -03003348 intel_runtime_pm_get(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003349
David Weinehall36cdd012016-08-22 13:59:31 +03003350 if (IS_BROADWELL(dev_priv)) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003351 struct page *page;
3352 uint64_t *seqno;
3353
Chris Wilson51d545d2016-08-15 10:49:02 +01003354 page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0);
Ben Widawskye04934c2014-06-30 09:53:42 -07003355
3356 seqno = (uint64_t *)kmap_atomic(page);
Akash Goel3b3f1652016-10-13 22:44:48 +05303357 for_each_engine(engine, dev_priv, id) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003358 uint64_t offset;
3359
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003360 seq_printf(m, "%s\n", engine->name);
Ben Widawskye04934c2014-06-30 09:53:42 -07003361
3362 seq_puts(m, " Last signal:");
3363 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003364 offset = id * I915_NUM_ENGINES + j;
Ben Widawskye04934c2014-06-30 09:53:42 -07003365 seq_printf(m, "0x%08llx (0x%02llx) ",
3366 seqno[offset], offset * 8);
3367 }
3368 seq_putc(m, '\n');
3369
3370 seq_puts(m, " Last wait: ");
3371 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003372 offset = id + (j * I915_NUM_ENGINES);
Ben Widawskye04934c2014-06-30 09:53:42 -07003373 seq_printf(m, "0x%08llx (0x%02llx) ",
3374 seqno[offset], offset * 8);
3375 }
3376 seq_putc(m, '\n');
3377
3378 }
3379 kunmap_atomic(seqno);
3380 } else {
3381 seq_puts(m, " Last signal:");
Akash Goel3b3f1652016-10-13 22:44:48 +05303382 for_each_engine(engine, dev_priv, id)
Ben Widawskye04934c2014-06-30 09:53:42 -07003383 for (j = 0; j < num_rings; j++)
3384 seq_printf(m, "0x%08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003385 I915_READ(engine->semaphore.mbox.signal[j]));
Ben Widawskye04934c2014-06-30 09:53:42 -07003386 seq_putc(m, '\n');
3387 }
3388
Paulo Zanoni03872062014-07-09 14:31:57 -03003389 intel_runtime_pm_put(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003390 mutex_unlock(&dev->struct_mutex);
3391 return 0;
3392}
3393
Daniel Vetter728e29d2014-06-25 22:01:53 +03003394static int i915_shared_dplls_info(struct seq_file *m, void *unused)
3395{
David Weinehall36cdd012016-08-22 13:59:31 +03003396 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3397 struct drm_device *dev = &dev_priv->drm;
Daniel Vetter728e29d2014-06-25 22:01:53 +03003398 int i;
3399
3400 drm_modeset_lock_all(dev);
3401 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3402 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
3403
3404 seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id);
Maarten Lankhorst2dd66ebd2016-03-14 09:27:52 +01003405 seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n",
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003406 pll->state.crtc_mask, pll->active_mask, yesno(pll->on));
Daniel Vetter728e29d2014-06-25 22:01:53 +03003407 seq_printf(m, " tracked hardware state:\n");
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003408 seq_printf(m, " dpll: 0x%08x\n", pll->state.hw_state.dpll);
Ander Conselvan de Oliveira3e369b72014-10-29 11:32:32 +02003409 seq_printf(m, " dpll_md: 0x%08x\n",
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003410 pll->state.hw_state.dpll_md);
3411 seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0);
3412 seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1);
3413 seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll);
Daniel Vetter728e29d2014-06-25 22:01:53 +03003414 }
3415 drm_modeset_unlock_all(dev);
3416
3417 return 0;
3418}
3419
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01003420static int i915_wa_registers(struct seq_file *m, void *unused)
Arun Siluvery888b5992014-08-26 14:44:51 +01003421{
3422 int i;
3423 int ret;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003424 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003425 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3426 struct drm_device *dev = &dev_priv->drm;
Arun Siluvery33136b02016-01-21 21:43:47 +00003427 struct i915_workarounds *workarounds = &dev_priv->workarounds;
Dave Gordonc3232b12016-03-23 18:19:53 +00003428 enum intel_engine_id id;
Arun Siluvery888b5992014-08-26 14:44:51 +01003429
Arun Siluvery888b5992014-08-26 14:44:51 +01003430 ret = mutex_lock_interruptible(&dev->struct_mutex);
3431 if (ret)
3432 return ret;
3433
3434 intel_runtime_pm_get(dev_priv);
3435
Arun Siluvery33136b02016-01-21 21:43:47 +00003436 seq_printf(m, "Workarounds applied: %d\n", workarounds->count);
Akash Goel3b3f1652016-10-13 22:44:48 +05303437 for_each_engine(engine, dev_priv, id)
Arun Siluvery33136b02016-01-21 21:43:47 +00003438 seq_printf(m, "HW whitelist count for %s: %d\n",
Dave Gordonc3232b12016-03-23 18:19:53 +00003439 engine->name, workarounds->hw_whitelist_count[id]);
Arun Siluvery33136b02016-01-21 21:43:47 +00003440 for (i = 0; i < workarounds->count; ++i) {
Ville Syrjäläf0f59a02015-11-18 15:33:26 +02003441 i915_reg_t addr;
3442 u32 mask, value, read;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003443 bool ok;
Arun Siluvery888b5992014-08-26 14:44:51 +01003444
Arun Siluvery33136b02016-01-21 21:43:47 +00003445 addr = workarounds->reg[i].addr;
3446 mask = workarounds->reg[i].mask;
3447 value = workarounds->reg[i].value;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003448 read = I915_READ(addr);
3449 ok = (value & mask) == (read & mask);
3450 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 +02003451 i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL");
Arun Siluvery888b5992014-08-26 14:44:51 +01003452 }
3453
3454 intel_runtime_pm_put(dev_priv);
3455 mutex_unlock(&dev->struct_mutex);
3456
3457 return 0;
3458}
3459
Damien Lespiauc5511e42014-11-04 17:06:51 +00003460static int i915_ddb_info(struct seq_file *m, void *unused)
3461{
David Weinehall36cdd012016-08-22 13:59:31 +03003462 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3463 struct drm_device *dev = &dev_priv->drm;
Damien Lespiauc5511e42014-11-04 17:06:51 +00003464 struct skl_ddb_allocation *ddb;
3465 struct skl_ddb_entry *entry;
3466 enum pipe pipe;
3467 int plane;
3468
David Weinehall36cdd012016-08-22 13:59:31 +03003469 if (INTEL_GEN(dev_priv) < 9)
Damien Lespiau2fcffe12014-12-03 17:33:24 +00003470 return 0;
3471
Damien Lespiauc5511e42014-11-04 17:06:51 +00003472 drm_modeset_lock_all(dev);
3473
3474 ddb = &dev_priv->wm.skl_hw.ddb;
3475
3476 seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
3477
3478 for_each_pipe(dev_priv, pipe) {
3479 seq_printf(m, "Pipe %c\n", pipe_name(pipe));
3480
Matt Roper8b364b42016-10-26 15:51:28 -07003481 for_each_universal_plane(dev_priv, pipe, plane) {
Damien Lespiauc5511e42014-11-04 17:06:51 +00003482 entry = &ddb->plane[pipe][plane];
3483 seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1,
3484 entry->start, entry->end,
3485 skl_ddb_entry_size(entry));
3486 }
3487
Matt Roper4969d332015-09-24 15:53:10 -07003488 entry = &ddb->plane[pipe][PLANE_CURSOR];
Damien Lespiauc5511e42014-11-04 17:06:51 +00003489 seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start,
3490 entry->end, skl_ddb_entry_size(entry));
3491 }
3492
3493 drm_modeset_unlock_all(dev);
3494
3495 return 0;
3496}
3497
Vandana Kannana54746e2015-03-03 20:53:10 +05303498static void drrs_status_per_crtc(struct seq_file *m,
David Weinehall36cdd012016-08-22 13:59:31 +03003499 struct drm_device *dev,
3500 struct intel_crtc *intel_crtc)
Vandana Kannana54746e2015-03-03 20:53:10 +05303501{
Chris Wilsonfac5e232016-07-04 11:34:36 +01003502 struct drm_i915_private *dev_priv = to_i915(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303503 struct i915_drrs *drrs = &dev_priv->drrs;
3504 int vrefresh = 0;
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003505 struct drm_connector *connector;
Vandana Kannana54746e2015-03-03 20:53:10 +05303506
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003507 drm_for_each_connector(connector, dev) {
3508 if (connector->state->crtc != &intel_crtc->base)
3509 continue;
3510
3511 seq_printf(m, "%s:\n", connector->name);
Vandana Kannana54746e2015-03-03 20:53:10 +05303512 }
3513
3514 if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT)
3515 seq_puts(m, "\tVBT: DRRS_type: Static");
3516 else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT)
3517 seq_puts(m, "\tVBT: DRRS_type: Seamless");
3518 else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED)
3519 seq_puts(m, "\tVBT: DRRS_type: None");
3520 else
3521 seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value");
3522
3523 seq_puts(m, "\n\n");
3524
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003525 if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303526 struct intel_panel *panel;
3527
3528 mutex_lock(&drrs->mutex);
3529 /* DRRS Supported */
3530 seq_puts(m, "\tDRRS Supported: Yes\n");
3531
3532 /* disable_drrs() will make drrs->dp NULL */
3533 if (!drrs->dp) {
3534 seq_puts(m, "Idleness DRRS: Disabled");
3535 mutex_unlock(&drrs->mutex);
3536 return;
3537 }
3538
3539 panel = &drrs->dp->attached_connector->panel;
3540 seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X",
3541 drrs->busy_frontbuffer_bits);
3542
3543 seq_puts(m, "\n\t\t");
3544 if (drrs->refresh_rate_type == DRRS_HIGH_RR) {
3545 seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n");
3546 vrefresh = panel->fixed_mode->vrefresh;
3547 } else if (drrs->refresh_rate_type == DRRS_LOW_RR) {
3548 seq_puts(m, "DRRS_State: DRRS_LOW_RR\n");
3549 vrefresh = panel->downclock_mode->vrefresh;
3550 } else {
3551 seq_printf(m, "DRRS_State: Unknown(%d)\n",
3552 drrs->refresh_rate_type);
3553 mutex_unlock(&drrs->mutex);
3554 return;
3555 }
3556 seq_printf(m, "\t\tVrefresh: %d", vrefresh);
3557
3558 seq_puts(m, "\n\t\t");
3559 mutex_unlock(&drrs->mutex);
3560 } else {
3561 /* DRRS not supported. Print the VBT parameter*/
3562 seq_puts(m, "\tDRRS Supported : No");
3563 }
3564 seq_puts(m, "\n");
3565}
3566
3567static int i915_drrs_status(struct seq_file *m, void *unused)
3568{
David Weinehall36cdd012016-08-22 13:59:31 +03003569 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3570 struct drm_device *dev = &dev_priv->drm;
Vandana Kannana54746e2015-03-03 20:53:10 +05303571 struct intel_crtc *intel_crtc;
3572 int active_crtc_cnt = 0;
3573
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003574 drm_modeset_lock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303575 for_each_intel_crtc(dev, intel_crtc) {
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003576 if (intel_crtc->base.state->active) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303577 active_crtc_cnt++;
3578 seq_printf(m, "\nCRTC %d: ", active_crtc_cnt);
3579
3580 drrs_status_per_crtc(m, dev, intel_crtc);
3581 }
Vandana Kannana54746e2015-03-03 20:53:10 +05303582 }
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003583 drm_modeset_unlock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303584
3585 if (!active_crtc_cnt)
3586 seq_puts(m, "No active crtc found\n");
3587
3588 return 0;
3589}
3590
Dave Airlie11bed952014-05-12 15:22:27 +10003591static int i915_dp_mst_info(struct seq_file *m, void *unused)
3592{
David Weinehall36cdd012016-08-22 13:59:31 +03003593 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3594 struct drm_device *dev = &dev_priv->drm;
Dave Airlie11bed952014-05-12 15:22:27 +10003595 struct intel_encoder *intel_encoder;
3596 struct intel_digital_port *intel_dig_port;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003597 struct drm_connector *connector;
3598
Dave Airlie11bed952014-05-12 15:22:27 +10003599 drm_modeset_lock_all(dev);
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003600 drm_for_each_connector(connector, dev) {
3601 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
Dave Airlie11bed952014-05-12 15:22:27 +10003602 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003603
3604 intel_encoder = intel_attached_encoder(connector);
3605 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
3606 continue;
3607
3608 intel_dig_port = enc_to_dig_port(&intel_encoder->base);
Dave Airlie11bed952014-05-12 15:22:27 +10003609 if (!intel_dig_port->dp.can_mst)
3610 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003611
Jim Bride40ae80c2016-04-14 10:18:37 -07003612 seq_printf(m, "MST Source Port %c\n",
3613 port_name(intel_dig_port->port));
Dave Airlie11bed952014-05-12 15:22:27 +10003614 drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr);
3615 }
3616 drm_modeset_unlock_all(dev);
3617 return 0;
3618}
3619
Todd Previteeb3394fa2015-04-18 00:04:19 -07003620static ssize_t i915_displayport_test_active_write(struct file *file,
David Weinehall36cdd012016-08-22 13:59:31 +03003621 const char __user *ubuf,
3622 size_t len, loff_t *offp)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003623{
3624 char *input_buffer;
3625 int status = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003626 struct drm_device *dev;
3627 struct drm_connector *connector;
3628 struct list_head *connector_list;
3629 struct intel_dp *intel_dp;
3630 int val = 0;
3631
Sudip Mukherjee9aaffa32015-07-21 17:36:45 +05303632 dev = ((struct seq_file *)file->private_data)->private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003633
Todd Previteeb3394fa2015-04-18 00:04:19 -07003634 connector_list = &dev->mode_config.connector_list;
3635
3636 if (len == 0)
3637 return 0;
3638
3639 input_buffer = kmalloc(len + 1, GFP_KERNEL);
3640 if (!input_buffer)
3641 return -ENOMEM;
3642
3643 if (copy_from_user(input_buffer, ubuf, len)) {
3644 status = -EFAULT;
3645 goto out;
3646 }
3647
3648 input_buffer[len] = '\0';
3649 DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len);
3650
3651 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003652 if (connector->connector_type !=
3653 DRM_MODE_CONNECTOR_DisplayPort)
3654 continue;
3655
Sudip Mukherjeeb8bb08e2015-07-21 17:36:46 +05303656 if (connector->status == connector_status_connected &&
Todd Previteeb3394fa2015-04-18 00:04:19 -07003657 connector->encoder != NULL) {
3658 intel_dp = enc_to_intel_dp(connector->encoder);
3659 status = kstrtoint(input_buffer, 10, &val);
3660 if (status < 0)
3661 goto out;
3662 DRM_DEBUG_DRIVER("Got %d for test active\n", val);
3663 /* To prevent erroneous activation of the compliance
3664 * testing code, only accept an actual value of 1 here
3665 */
3666 if (val == 1)
Manasi Navarec1617ab2016-12-09 16:22:50 -08003667 intel_dp->compliance.test_active = 1;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003668 else
Manasi Navarec1617ab2016-12-09 16:22:50 -08003669 intel_dp->compliance.test_active = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003670 }
3671 }
3672out:
3673 kfree(input_buffer);
3674 if (status < 0)
3675 return status;
3676
3677 *offp += len;
3678 return len;
3679}
3680
3681static int i915_displayport_test_active_show(struct seq_file *m, void *data)
3682{
3683 struct drm_device *dev = m->private;
3684 struct drm_connector *connector;
3685 struct list_head *connector_list = &dev->mode_config.connector_list;
3686 struct intel_dp *intel_dp;
3687
Todd Previteeb3394fa2015-04-18 00:04:19 -07003688 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003689 if (connector->connector_type !=
3690 DRM_MODE_CONNECTOR_DisplayPort)
3691 continue;
3692
3693 if (connector->status == connector_status_connected &&
3694 connector->encoder != NULL) {
3695 intel_dp = enc_to_intel_dp(connector->encoder);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003696 if (intel_dp->compliance.test_active)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003697 seq_puts(m, "1");
3698 else
3699 seq_puts(m, "0");
3700 } else
3701 seq_puts(m, "0");
3702 }
3703
3704 return 0;
3705}
3706
3707static int i915_displayport_test_active_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03003708 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003709{
David Weinehall36cdd012016-08-22 13:59:31 +03003710 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003711
David Weinehall36cdd012016-08-22 13:59:31 +03003712 return single_open(file, i915_displayport_test_active_show,
3713 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003714}
3715
3716static const struct file_operations i915_displayport_test_active_fops = {
3717 .owner = THIS_MODULE,
3718 .open = i915_displayport_test_active_open,
3719 .read = seq_read,
3720 .llseek = seq_lseek,
3721 .release = single_release,
3722 .write = i915_displayport_test_active_write
3723};
3724
3725static int i915_displayport_test_data_show(struct seq_file *m, void *data)
3726{
3727 struct drm_device *dev = m->private;
3728 struct drm_connector *connector;
3729 struct list_head *connector_list = &dev->mode_config.connector_list;
3730 struct intel_dp *intel_dp;
3731
Todd Previteeb3394fa2015-04-18 00:04:19 -07003732 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003733 if (connector->connector_type !=
3734 DRM_MODE_CONNECTOR_DisplayPort)
3735 continue;
3736
3737 if (connector->status == connector_status_connected &&
3738 connector->encoder != NULL) {
3739 intel_dp = enc_to_intel_dp(connector->encoder);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003740 seq_printf(m, "%lx", intel_dp->compliance.test_data.edid);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003741 } else
3742 seq_puts(m, "0");
3743 }
3744
3745 return 0;
3746}
3747static int i915_displayport_test_data_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03003748 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003749{
David Weinehall36cdd012016-08-22 13:59:31 +03003750 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003751
David Weinehall36cdd012016-08-22 13:59:31 +03003752 return single_open(file, i915_displayport_test_data_show,
3753 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003754}
3755
3756static const struct file_operations i915_displayport_test_data_fops = {
3757 .owner = THIS_MODULE,
3758 .open = i915_displayport_test_data_open,
3759 .read = seq_read,
3760 .llseek = seq_lseek,
3761 .release = single_release
3762};
3763
3764static int i915_displayport_test_type_show(struct seq_file *m, void *data)
3765{
3766 struct drm_device *dev = m->private;
3767 struct drm_connector *connector;
3768 struct list_head *connector_list = &dev->mode_config.connector_list;
3769 struct intel_dp *intel_dp;
3770
Todd Previteeb3394fa2015-04-18 00:04:19 -07003771 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07003772 if (connector->connector_type !=
3773 DRM_MODE_CONNECTOR_DisplayPort)
3774 continue;
3775
3776 if (connector->status == connector_status_connected &&
3777 connector->encoder != NULL) {
3778 intel_dp = enc_to_intel_dp(connector->encoder);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003779 seq_printf(m, "%02lx", intel_dp->compliance.test_type);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003780 } else
3781 seq_puts(m, "0");
3782 }
3783
3784 return 0;
3785}
3786
3787static int i915_displayport_test_type_open(struct inode *inode,
3788 struct file *file)
3789{
David Weinehall36cdd012016-08-22 13:59:31 +03003790 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003791
David Weinehall36cdd012016-08-22 13:59:31 +03003792 return single_open(file, i915_displayport_test_type_show,
3793 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003794}
3795
3796static const struct file_operations i915_displayport_test_type_fops = {
3797 .owner = THIS_MODULE,
3798 .open = i915_displayport_test_type_open,
3799 .read = seq_read,
3800 .llseek = seq_lseek,
3801 .release = single_release
3802};
3803
Damien Lespiau97e94b22014-11-04 17:06:50 +00003804static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02003805{
David Weinehall36cdd012016-08-22 13:59:31 +03003806 struct drm_i915_private *dev_priv = m->private;
3807 struct drm_device *dev = &dev_priv->drm;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003808 int level;
Ville Syrjäläde38b952015-06-24 22:00:09 +03003809 int num_levels;
3810
David Weinehall36cdd012016-08-22 13:59:31 +03003811 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003812 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03003813 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003814 num_levels = 1;
3815 else
Tvrtko Ursulin5db94012016-10-13 11:03:10 +01003816 num_levels = ilk_wm_max_level(dev_priv) + 1;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003817
3818 drm_modeset_lock_all(dev);
3819
3820 for (level = 0; level < num_levels; level++) {
3821 unsigned int latency = wm[level];
3822
Damien Lespiau97e94b22014-11-04 17:06:50 +00003823 /*
3824 * - WM1+ latency values in 0.5us units
Ville Syrjäläde38b952015-06-24 22:00:09 +03003825 * - latencies are in us on gen9/vlv/chv
Damien Lespiau97e94b22014-11-04 17:06:50 +00003826 */
David Weinehall36cdd012016-08-22 13:59:31 +03003827 if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) ||
3828 IS_CHERRYVIEW(dev_priv))
Damien Lespiau97e94b22014-11-04 17:06:50 +00003829 latency *= 10;
3830 else if (level > 0)
Ville Syrjälä369a1342014-01-22 14:36:08 +02003831 latency *= 5;
3832
3833 seq_printf(m, "WM%d %u (%u.%u usec)\n",
Damien Lespiau97e94b22014-11-04 17:06:50 +00003834 level, wm[level], latency / 10, latency % 10);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003835 }
3836
3837 drm_modeset_unlock_all(dev);
3838}
3839
3840static int pri_wm_latency_show(struct seq_file *m, void *data)
3841{
David Weinehall36cdd012016-08-22 13:59:31 +03003842 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003843 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003844
David Weinehall36cdd012016-08-22 13:59:31 +03003845 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003846 latencies = dev_priv->wm.skl_latency;
3847 else
David Weinehall36cdd012016-08-22 13:59:31 +03003848 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003849
3850 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003851
3852 return 0;
3853}
3854
3855static int spr_wm_latency_show(struct seq_file *m, void *data)
3856{
David Weinehall36cdd012016-08-22 13:59:31 +03003857 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003858 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003859
David Weinehall36cdd012016-08-22 13:59:31 +03003860 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003861 latencies = dev_priv->wm.skl_latency;
3862 else
David Weinehall36cdd012016-08-22 13:59:31 +03003863 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003864
3865 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003866
3867 return 0;
3868}
3869
3870static int cur_wm_latency_show(struct seq_file *m, void *data)
3871{
David Weinehall36cdd012016-08-22 13:59:31 +03003872 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003873 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003874
David Weinehall36cdd012016-08-22 13:59:31 +03003875 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003876 latencies = dev_priv->wm.skl_latency;
3877 else
David Weinehall36cdd012016-08-22 13:59:31 +03003878 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003879
3880 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003881
3882 return 0;
3883}
3884
3885static int pri_wm_latency_open(struct inode *inode, struct file *file)
3886{
David Weinehall36cdd012016-08-22 13:59:31 +03003887 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003888
David Weinehall36cdd012016-08-22 13:59:31 +03003889 if (INTEL_GEN(dev_priv) < 5)
Ville Syrjälä369a1342014-01-22 14:36:08 +02003890 return -ENODEV;
3891
David Weinehall36cdd012016-08-22 13:59:31 +03003892 return single_open(file, pri_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003893}
3894
3895static int spr_wm_latency_open(struct inode *inode, struct file *file)
3896{
David Weinehall36cdd012016-08-22 13:59:31 +03003897 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003898
David Weinehall36cdd012016-08-22 13:59:31 +03003899 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003900 return -ENODEV;
3901
David Weinehall36cdd012016-08-22 13:59:31 +03003902 return single_open(file, spr_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003903}
3904
3905static int cur_wm_latency_open(struct inode *inode, struct file *file)
3906{
David Weinehall36cdd012016-08-22 13:59:31 +03003907 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003908
David Weinehall36cdd012016-08-22 13:59:31 +03003909 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003910 return -ENODEV;
3911
David Weinehall36cdd012016-08-22 13:59:31 +03003912 return single_open(file, cur_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003913}
3914
3915static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
Damien Lespiau97e94b22014-11-04 17:06:50 +00003916 size_t len, loff_t *offp, uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02003917{
3918 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03003919 struct drm_i915_private *dev_priv = m->private;
3920 struct drm_device *dev = &dev_priv->drm;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003921 uint16_t new[8] = { 0 };
Ville Syrjäläde38b952015-06-24 22:00:09 +03003922 int num_levels;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003923 int level;
3924 int ret;
3925 char tmp[32];
3926
David Weinehall36cdd012016-08-22 13:59:31 +03003927 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003928 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03003929 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003930 num_levels = 1;
3931 else
Tvrtko Ursulin5db94012016-10-13 11:03:10 +01003932 num_levels = ilk_wm_max_level(dev_priv) + 1;
Ville Syrjäläde38b952015-06-24 22:00:09 +03003933
Ville Syrjälä369a1342014-01-22 14:36:08 +02003934 if (len >= sizeof(tmp))
3935 return -EINVAL;
3936
3937 if (copy_from_user(tmp, ubuf, len))
3938 return -EFAULT;
3939
3940 tmp[len] = '\0';
3941
Damien Lespiau97e94b22014-11-04 17:06:50 +00003942 ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
3943 &new[0], &new[1], &new[2], &new[3],
3944 &new[4], &new[5], &new[6], &new[7]);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003945 if (ret != num_levels)
3946 return -EINVAL;
3947
3948 drm_modeset_lock_all(dev);
3949
3950 for (level = 0; level < num_levels; level++)
3951 wm[level] = new[level];
3952
3953 drm_modeset_unlock_all(dev);
3954
3955 return len;
3956}
3957
3958
3959static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
3960 size_t len, loff_t *offp)
3961{
3962 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03003963 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003964 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003965
David Weinehall36cdd012016-08-22 13:59:31 +03003966 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003967 latencies = dev_priv->wm.skl_latency;
3968 else
David Weinehall36cdd012016-08-22 13:59:31 +03003969 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003970
3971 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003972}
3973
3974static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
3975 size_t len, loff_t *offp)
3976{
3977 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03003978 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003979 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003980
David Weinehall36cdd012016-08-22 13:59:31 +03003981 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003982 latencies = dev_priv->wm.skl_latency;
3983 else
David Weinehall36cdd012016-08-22 13:59:31 +03003984 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003985
3986 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003987}
3988
3989static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
3990 size_t len, loff_t *offp)
3991{
3992 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03003993 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003994 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003995
David Weinehall36cdd012016-08-22 13:59:31 +03003996 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003997 latencies = dev_priv->wm.skl_latency;
3998 else
David Weinehall36cdd012016-08-22 13:59:31 +03003999 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004000
4001 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004002}
4003
4004static const struct file_operations i915_pri_wm_latency_fops = {
4005 .owner = THIS_MODULE,
4006 .open = pri_wm_latency_open,
4007 .read = seq_read,
4008 .llseek = seq_lseek,
4009 .release = single_release,
4010 .write = pri_wm_latency_write
4011};
4012
4013static const struct file_operations i915_spr_wm_latency_fops = {
4014 .owner = THIS_MODULE,
4015 .open = spr_wm_latency_open,
4016 .read = seq_read,
4017 .llseek = seq_lseek,
4018 .release = single_release,
4019 .write = spr_wm_latency_write
4020};
4021
4022static const struct file_operations i915_cur_wm_latency_fops = {
4023 .owner = THIS_MODULE,
4024 .open = cur_wm_latency_open,
4025 .read = seq_read,
4026 .llseek = seq_lseek,
4027 .release = single_release,
4028 .write = cur_wm_latency_write
4029};
4030
Kees Cook647416f2013-03-10 14:10:06 -07004031static int
4032i915_wedged_get(void *data, u64 *val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004033{
David Weinehall36cdd012016-08-22 13:59:31 +03004034 struct drm_i915_private *dev_priv = data;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004035
Chris Wilsond98c52c2016-04-13 17:35:05 +01004036 *val = i915_terminally_wedged(&dev_priv->gpu_error);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004037
Kees Cook647416f2013-03-10 14:10:06 -07004038 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004039}
4040
Kees Cook647416f2013-03-10 14:10:06 -07004041static int
4042i915_wedged_set(void *data, u64 val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004043{
David Weinehall36cdd012016-08-22 13:59:31 +03004044 struct drm_i915_private *dev_priv = data;
Imre Deakd46c0512014-04-14 20:24:27 +03004045
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004046 /*
4047 * There is no safeguard against this debugfs entry colliding
4048 * with the hangcheck calling same i915_handle_error() in
4049 * parallel, causing an explosion. For now we assume that the
4050 * test harness is responsible enough not to inject gpu hangs
4051 * while it is writing to 'i915_wedged'
4052 */
4053
Chris Wilsond98c52c2016-04-13 17:35:05 +01004054 if (i915_reset_in_progress(&dev_priv->gpu_error))
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004055 return -EAGAIN;
4056
Chris Wilsonc0336662016-05-06 15:40:21 +01004057 i915_handle_error(dev_priv, val,
Mika Kuoppala58174462014-02-25 17:11:26 +02004058 "Manually setting wedged to %llu", val);
Imre Deakd46c0512014-04-14 20:24:27 +03004059
Kees Cook647416f2013-03-10 14:10:06 -07004060 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004061}
4062
Kees Cook647416f2013-03-10 14:10:06 -07004063DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
4064 i915_wedged_get, i915_wedged_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004065 "%llu\n");
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004066
Kees Cook647416f2013-03-10 14:10:06 -07004067static int
Chris Wilson094f9a52013-09-25 17:34:55 +01004068i915_ring_missed_irq_get(void *data, u64 *val)
4069{
David Weinehall36cdd012016-08-22 13:59:31 +03004070 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004071
4072 *val = dev_priv->gpu_error.missed_irq_rings;
4073 return 0;
4074}
4075
4076static int
4077i915_ring_missed_irq_set(void *data, u64 val)
4078{
David Weinehall36cdd012016-08-22 13:59:31 +03004079 struct drm_i915_private *dev_priv = data;
4080 struct drm_device *dev = &dev_priv->drm;
Chris Wilson094f9a52013-09-25 17:34:55 +01004081 int ret;
4082
4083 /* Lock against concurrent debugfs callers */
4084 ret = mutex_lock_interruptible(&dev->struct_mutex);
4085 if (ret)
4086 return ret;
4087 dev_priv->gpu_error.missed_irq_rings = val;
4088 mutex_unlock(&dev->struct_mutex);
4089
4090 return 0;
4091}
4092
4093DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops,
4094 i915_ring_missed_irq_get, i915_ring_missed_irq_set,
4095 "0x%08llx\n");
4096
4097static int
4098i915_ring_test_irq_get(void *data, u64 *val)
4099{
David Weinehall36cdd012016-08-22 13:59:31 +03004100 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004101
4102 *val = dev_priv->gpu_error.test_irq_rings;
4103
4104 return 0;
4105}
4106
4107static int
4108i915_ring_test_irq_set(void *data, u64 val)
4109{
David Weinehall36cdd012016-08-22 13:59:31 +03004110 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004111
Chris Wilson3a122c22016-06-17 14:35:05 +01004112 val &= INTEL_INFO(dev_priv)->ring_mask;
Chris Wilson094f9a52013-09-25 17:34:55 +01004113 DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004114 dev_priv->gpu_error.test_irq_rings = val;
Chris Wilson094f9a52013-09-25 17:34:55 +01004115
4116 return 0;
4117}
4118
4119DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops,
4120 i915_ring_test_irq_get, i915_ring_test_irq_set,
4121 "0x%08llx\n");
4122
Chris Wilsondd624af2013-01-15 12:39:35 +00004123#define DROP_UNBOUND 0x1
4124#define DROP_BOUND 0x2
4125#define DROP_RETIRE 0x4
4126#define DROP_ACTIVE 0x8
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004127#define DROP_FREED 0x10
4128#define DROP_ALL (DROP_UNBOUND | \
4129 DROP_BOUND | \
4130 DROP_RETIRE | \
4131 DROP_ACTIVE | \
4132 DROP_FREED)
Kees Cook647416f2013-03-10 14:10:06 -07004133static int
4134i915_drop_caches_get(void *data, u64 *val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004135{
Kees Cook647416f2013-03-10 14:10:06 -07004136 *val = DROP_ALL;
Chris Wilsondd624af2013-01-15 12:39:35 +00004137
Kees Cook647416f2013-03-10 14:10:06 -07004138 return 0;
Chris Wilsondd624af2013-01-15 12:39:35 +00004139}
4140
Kees Cook647416f2013-03-10 14:10:06 -07004141static int
4142i915_drop_caches_set(void *data, u64 val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004143{
David Weinehall36cdd012016-08-22 13:59:31 +03004144 struct drm_i915_private *dev_priv = data;
4145 struct drm_device *dev = &dev_priv->drm;
Kees Cook647416f2013-03-10 14:10:06 -07004146 int ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004147
Ben Widawsky2f9fe5f2013-11-25 09:54:37 -08004148 DRM_DEBUG("Dropping caches: 0x%08llx\n", val);
Chris Wilsondd624af2013-01-15 12:39:35 +00004149
4150 /* No need to check and wait for gpu resets, only libdrm auto-restarts
4151 * on ioctls on -EAGAIN. */
4152 ret = mutex_lock_interruptible(&dev->struct_mutex);
4153 if (ret)
4154 return ret;
4155
4156 if (val & DROP_ACTIVE) {
Chris Wilson22dd3bb2016-09-09 14:11:50 +01004157 ret = i915_gem_wait_for_idle(dev_priv,
4158 I915_WAIT_INTERRUPTIBLE |
4159 I915_WAIT_LOCKED);
Chris Wilsondd624af2013-01-15 12:39:35 +00004160 if (ret)
4161 goto unlock;
4162 }
4163
4164 if (val & (DROP_RETIRE | DROP_ACTIVE))
Chris Wilsonc0336662016-05-06 15:40:21 +01004165 i915_gem_retire_requests(dev_priv);
Chris Wilsondd624af2013-01-15 12:39:35 +00004166
Chris Wilson21ab4e72014-09-09 11:16:08 +01004167 if (val & DROP_BOUND)
4168 i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND);
Chris Wilson4ad72b72014-09-03 19:23:37 +01004169
Chris Wilson21ab4e72014-09-09 11:16:08 +01004170 if (val & DROP_UNBOUND)
4171 i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND);
Chris Wilsondd624af2013-01-15 12:39:35 +00004172
4173unlock:
4174 mutex_unlock(&dev->struct_mutex);
4175
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004176 if (val & DROP_FREED) {
4177 synchronize_rcu();
Chris Wilsonbdeb9782016-12-23 14:57:56 +00004178 i915_gem_drain_freed_objects(dev_priv);
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004179 }
4180
Kees Cook647416f2013-03-10 14:10:06 -07004181 return ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004182}
4183
Kees Cook647416f2013-03-10 14:10:06 -07004184DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
4185 i915_drop_caches_get, i915_drop_caches_set,
4186 "0x%08llx\n");
Chris Wilsondd624af2013-01-15 12:39:35 +00004187
Kees Cook647416f2013-03-10 14:10:06 -07004188static int
4189i915_max_freq_get(void *data, u64 *val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004190{
David Weinehall36cdd012016-08-22 13:59:31 +03004191 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004192
David Weinehall36cdd012016-08-22 13:59:31 +03004193 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004194 return -ENODEV;
4195
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02004196 *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004197 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004198}
4199
Kees Cook647416f2013-03-10 14:10:06 -07004200static int
4201i915_max_freq_set(void *data, u64 val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004202{
David Weinehall36cdd012016-08-22 13:59:31 +03004203 struct drm_i915_private *dev_priv = data;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304204 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004205 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004206
David Weinehall36cdd012016-08-22 13:59:31 +03004207 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004208 return -ENODEV;
Jesse Barnes358733e2011-07-27 11:53:01 -07004209
Kees Cook647416f2013-03-10 14:10:06 -07004210 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val);
Jesse Barnes358733e2011-07-27 11:53:01 -07004211
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004212 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004213 if (ret)
4214 return ret;
4215
Jesse Barnes358733e2011-07-27 11:53:01 -07004216 /*
4217 * Turbo will still be enabled, but won't go above the set value.
4218 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304219 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004220
Akash Goelbc4d91f2015-02-26 16:09:47 +05304221 hw_max = dev_priv->rps.max_freq;
4222 hw_min = dev_priv->rps.min_freq;
Jesse Barnes0a073b82013-04-17 15:54:58 -07004223
Ben Widawskyb39fb292014-03-19 18:31:11 -07004224 if (val < hw_min || val > hw_max || val < dev_priv->rps.min_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004225 mutex_unlock(&dev_priv->rps.hw_lock);
4226 return -EINVAL;
4227 }
4228
Ben Widawskyb39fb292014-03-19 18:31:11 -07004229 dev_priv->rps.max_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004230
Chris Wilsondc979972016-05-10 14:10:04 +01004231 intel_set_rps(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004232
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004233 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes358733e2011-07-27 11:53:01 -07004234
Kees Cook647416f2013-03-10 14:10:06 -07004235 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004236}
4237
Kees Cook647416f2013-03-10 14:10:06 -07004238DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
4239 i915_max_freq_get, i915_max_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004240 "%llu\n");
Jesse Barnes358733e2011-07-27 11:53:01 -07004241
Kees Cook647416f2013-03-10 14:10:06 -07004242static int
4243i915_min_freq_get(void *data, u64 *val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004244{
David Weinehall36cdd012016-08-22 13:59:31 +03004245 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004246
Chris Wilson62e1baa2016-07-13 09:10:36 +01004247 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004248 return -ENODEV;
4249
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02004250 *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004251 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004252}
4253
Kees Cook647416f2013-03-10 14:10:06 -07004254static int
4255i915_min_freq_set(void *data, u64 val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004256{
David Weinehall36cdd012016-08-22 13:59:31 +03004257 struct drm_i915_private *dev_priv = data;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304258 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004259 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004260
Chris Wilson62e1baa2016-07-13 09:10:36 +01004261 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004262 return -ENODEV;
Jesse Barnes1523c312012-05-25 12:34:54 -07004263
Kees Cook647416f2013-03-10 14:10:06 -07004264 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val);
Jesse Barnes1523c312012-05-25 12:34:54 -07004265
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004266 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004267 if (ret)
4268 return ret;
4269
Jesse Barnes1523c312012-05-25 12:34:54 -07004270 /*
4271 * Turbo will still be enabled, but won't go below the set value.
4272 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304273 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004274
Akash Goelbc4d91f2015-02-26 16:09:47 +05304275 hw_max = dev_priv->rps.max_freq;
4276 hw_min = dev_priv->rps.min_freq;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004277
David Weinehall36cdd012016-08-22 13:59:31 +03004278 if (val < hw_min ||
4279 val > hw_max || val > dev_priv->rps.max_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004280 mutex_unlock(&dev_priv->rps.hw_lock);
4281 return -EINVAL;
4282 }
4283
Ben Widawskyb39fb292014-03-19 18:31:11 -07004284 dev_priv->rps.min_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004285
Chris Wilsondc979972016-05-10 14:10:04 +01004286 intel_set_rps(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004287
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004288 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes1523c312012-05-25 12:34:54 -07004289
Kees Cook647416f2013-03-10 14:10:06 -07004290 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004291}
4292
Kees Cook647416f2013-03-10 14:10:06 -07004293DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
4294 i915_min_freq_get, i915_min_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004295 "%llu\n");
Jesse Barnes1523c312012-05-25 12:34:54 -07004296
Kees Cook647416f2013-03-10 14:10:06 -07004297static int
4298i915_cache_sharing_get(void *data, u64 *val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004299{
David Weinehall36cdd012016-08-22 13:59:31 +03004300 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004301 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004302
David Weinehall36cdd012016-08-22 13:59:31 +03004303 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004304 return -ENODEV;
4305
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004306 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02004307
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004308 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004309
4310 intel_runtime_pm_put(dev_priv);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004311
Kees Cook647416f2013-03-10 14:10:06 -07004312 *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004313
Kees Cook647416f2013-03-10 14:10:06 -07004314 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004315}
4316
Kees Cook647416f2013-03-10 14:10:06 -07004317static int
4318i915_cache_sharing_set(void *data, u64 val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004319{
David Weinehall36cdd012016-08-22 13:59:31 +03004320 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004321 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004322
David Weinehall36cdd012016-08-22 13:59:31 +03004323 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004324 return -ENODEV;
4325
Kees Cook647416f2013-03-10 14:10:06 -07004326 if (val > 3)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004327 return -EINVAL;
4328
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004329 intel_runtime_pm_get(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004330 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004331
4332 /* Update the cache sharing policy here as well */
4333 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
4334 snpcr &= ~GEN6_MBC_SNPCR_MASK;
4335 snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
4336 I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
4337
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004338 intel_runtime_pm_put(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004339 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004340}
4341
Kees Cook647416f2013-03-10 14:10:06 -07004342DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops,
4343 i915_cache_sharing_get, i915_cache_sharing_set,
4344 "%llu\n");
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004345
David Weinehall36cdd012016-08-22 13:59:31 +03004346static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004347 struct sseu_dev_info *sseu)
Jeff McGee5d395252015-04-03 18:13:17 -07004348{
Ville Syrjälä0a0b4572015-08-21 20:45:27 +03004349 int ss_max = 2;
Jeff McGee5d395252015-04-03 18:13:17 -07004350 int ss;
4351 u32 sig1[ss_max], sig2[ss_max];
4352
4353 sig1[0] = I915_READ(CHV_POWER_SS0_SIG1);
4354 sig1[1] = I915_READ(CHV_POWER_SS1_SIG1);
4355 sig2[0] = I915_READ(CHV_POWER_SS0_SIG2);
4356 sig2[1] = I915_READ(CHV_POWER_SS1_SIG2);
4357
4358 for (ss = 0; ss < ss_max; ss++) {
4359 unsigned int eu_cnt;
4360
4361 if (sig1[ss] & CHV_SS_PG_ENABLE)
4362 /* skip disabled subslice */
4363 continue;
4364
Imre Deakf08a0c92016-08-31 19:13:04 +03004365 sseu->slice_mask = BIT(0);
Imre Deak57ec1712016-08-31 19:13:05 +03004366 sseu->subslice_mask |= BIT(ss);
Jeff McGee5d395252015-04-03 18:13:17 -07004367 eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) +
4368 ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) +
4369 ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) +
4370 ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2);
Imre Deak915490d2016-08-31 19:13:01 +03004371 sseu->eu_total += eu_cnt;
4372 sseu->eu_per_subslice = max_t(unsigned int,
4373 sseu->eu_per_subslice, eu_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07004374 }
Jeff McGee5d395252015-04-03 18:13:17 -07004375}
4376
David Weinehall36cdd012016-08-22 13:59:31 +03004377static void gen9_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004378 struct sseu_dev_info *sseu)
Jeff McGee5d395252015-04-03 18:13:17 -07004379{
Jeff McGee1c046bc2015-04-03 18:13:18 -07004380 int s_max = 3, ss_max = 4;
Jeff McGee5d395252015-04-03 18:13:17 -07004381 int s, ss;
4382 u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2];
4383
Jeff McGee1c046bc2015-04-03 18:13:18 -07004384 /* BXT has a single slice and at most 3 subslices. */
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02004385 if (IS_GEN9_LP(dev_priv)) {
Jeff McGee1c046bc2015-04-03 18:13:18 -07004386 s_max = 1;
4387 ss_max = 3;
4388 }
4389
4390 for (s = 0; s < s_max; s++) {
4391 s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s));
4392 eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s));
4393 eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s));
4394 }
4395
Jeff McGee5d395252015-04-03 18:13:17 -07004396 eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK |
4397 GEN9_PGCTL_SSA_EU19_ACK |
4398 GEN9_PGCTL_SSA_EU210_ACK |
4399 GEN9_PGCTL_SSA_EU311_ACK;
4400 eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK |
4401 GEN9_PGCTL_SSB_EU19_ACK |
4402 GEN9_PGCTL_SSB_EU210_ACK |
4403 GEN9_PGCTL_SSB_EU311_ACK;
4404
4405 for (s = 0; s < s_max; s++) {
4406 if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0)
4407 /* skip disabled slice */
4408 continue;
4409
Imre Deakf08a0c92016-08-31 19:13:04 +03004410 sseu->slice_mask |= BIT(s);
Jeff McGee1c046bc2015-04-03 18:13:18 -07004411
David Weinehall36cdd012016-08-22 13:59:31 +03004412 if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
Imre Deak57ec1712016-08-31 19:13:05 +03004413 sseu->subslice_mask =
4414 INTEL_INFO(dev_priv)->sseu.subslice_mask;
Jeff McGee1c046bc2015-04-03 18:13:18 -07004415
Jeff McGee5d395252015-04-03 18:13:17 -07004416 for (ss = 0; ss < ss_max; ss++) {
4417 unsigned int eu_cnt;
4418
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02004419 if (IS_GEN9_LP(dev_priv)) {
Imre Deak57ec1712016-08-31 19:13:05 +03004420 if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss))))
4421 /* skip disabled subslice */
4422 continue;
Jeff McGee1c046bc2015-04-03 18:13:18 -07004423
Imre Deak57ec1712016-08-31 19:13:05 +03004424 sseu->subslice_mask |= BIT(ss);
4425 }
Jeff McGee1c046bc2015-04-03 18:13:18 -07004426
Jeff McGee5d395252015-04-03 18:13:17 -07004427 eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] &
4428 eu_mask[ss%2]);
Imre Deak915490d2016-08-31 19:13:01 +03004429 sseu->eu_total += eu_cnt;
4430 sseu->eu_per_subslice = max_t(unsigned int,
4431 sseu->eu_per_subslice,
4432 eu_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07004433 }
4434 }
4435}
4436
David Weinehall36cdd012016-08-22 13:59:31 +03004437static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004438 struct sseu_dev_info *sseu)
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004439{
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004440 u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
David Weinehall36cdd012016-08-22 13:59:31 +03004441 int s;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004442
Imre Deakf08a0c92016-08-31 19:13:04 +03004443 sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004444
Imre Deakf08a0c92016-08-31 19:13:04 +03004445 if (sseu->slice_mask) {
Imre Deak57ec1712016-08-31 19:13:05 +03004446 sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask;
Imre Deak43b67992016-08-31 19:13:02 +03004447 sseu->eu_per_subslice =
4448 INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
Imre Deak57ec1712016-08-31 19:13:05 +03004449 sseu->eu_total = sseu->eu_per_subslice *
4450 sseu_subslice_total(sseu);
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004451
4452 /* subtract fused off EU(s) from enabled slice(s) */
Imre Deak795b38b2016-08-31 19:13:07 +03004453 for (s = 0; s < fls(sseu->slice_mask); s++) {
Imre Deak43b67992016-08-31 19:13:02 +03004454 u8 subslice_7eu =
4455 INTEL_INFO(dev_priv)->sseu.subslice_7eu[s];
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004456
Imre Deak915490d2016-08-31 19:13:01 +03004457 sseu->eu_total -= hweight8(subslice_7eu);
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004458 }
4459 }
4460}
4461
Imre Deak615d8902016-08-31 19:13:03 +03004462static void i915_print_sseu_info(struct seq_file *m, bool is_available_info,
4463 const struct sseu_dev_info *sseu)
4464{
4465 struct drm_i915_private *dev_priv = node_to_i915(m->private);
4466 const char *type = is_available_info ? "Available" : "Enabled";
4467
Imre Deakc67ba532016-08-31 19:13:06 +03004468 seq_printf(m, " %s Slice Mask: %04x\n", type,
4469 sseu->slice_mask);
Imre Deak615d8902016-08-31 19:13:03 +03004470 seq_printf(m, " %s Slice Total: %u\n", type,
Imre Deakf08a0c92016-08-31 19:13:04 +03004471 hweight8(sseu->slice_mask));
Imre Deak615d8902016-08-31 19:13:03 +03004472 seq_printf(m, " %s Subslice Total: %u\n", type,
Imre Deak57ec1712016-08-31 19:13:05 +03004473 sseu_subslice_total(sseu));
Imre Deakc67ba532016-08-31 19:13:06 +03004474 seq_printf(m, " %s Subslice Mask: %04x\n", type,
4475 sseu->subslice_mask);
Imre Deak615d8902016-08-31 19:13:03 +03004476 seq_printf(m, " %s Subslice Per Slice: %u\n", type,
Imre Deak57ec1712016-08-31 19:13:05 +03004477 hweight8(sseu->subslice_mask));
Imre Deak615d8902016-08-31 19:13:03 +03004478 seq_printf(m, " %s EU Total: %u\n", type,
4479 sseu->eu_total);
4480 seq_printf(m, " %s EU Per Subslice: %u\n", type,
4481 sseu->eu_per_subslice);
4482
4483 if (!is_available_info)
4484 return;
4485
4486 seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv)));
4487 if (HAS_POOLED_EU(dev_priv))
4488 seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool);
4489
4490 seq_printf(m, " Has Slice Power Gating: %s\n",
4491 yesno(sseu->has_slice_pg));
4492 seq_printf(m, " Has Subslice Power Gating: %s\n",
4493 yesno(sseu->has_subslice_pg));
4494 seq_printf(m, " Has EU Power Gating: %s\n",
4495 yesno(sseu->has_eu_pg));
4496}
4497
Jeff McGee38732182015-02-13 10:27:54 -06004498static int i915_sseu_status(struct seq_file *m, void *unused)
4499{
David Weinehall36cdd012016-08-22 13:59:31 +03004500 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak915490d2016-08-31 19:13:01 +03004501 struct sseu_dev_info sseu;
Jeff McGee38732182015-02-13 10:27:54 -06004502
David Weinehall36cdd012016-08-22 13:59:31 +03004503 if (INTEL_GEN(dev_priv) < 8)
Jeff McGee38732182015-02-13 10:27:54 -06004504 return -ENODEV;
4505
4506 seq_puts(m, "SSEU Device Info\n");
Imre Deak615d8902016-08-31 19:13:03 +03004507 i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu);
Jeff McGee38732182015-02-13 10:27:54 -06004508
Jeff McGee7f992ab2015-02-13 10:27:55 -06004509 seq_puts(m, "SSEU Device Status\n");
Imre Deak915490d2016-08-31 19:13:01 +03004510 memset(&sseu, 0, sizeof(sseu));
David Weinehall238010e2016-08-01 17:33:27 +03004511
4512 intel_runtime_pm_get(dev_priv);
4513
David Weinehall36cdd012016-08-22 13:59:31 +03004514 if (IS_CHERRYVIEW(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004515 cherryview_sseu_device_status(dev_priv, &sseu);
David Weinehall36cdd012016-08-22 13:59:31 +03004516 } else if (IS_BROADWELL(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004517 broadwell_sseu_device_status(dev_priv, &sseu);
David Weinehall36cdd012016-08-22 13:59:31 +03004518 } else if (INTEL_GEN(dev_priv) >= 9) {
Imre Deak915490d2016-08-31 19:13:01 +03004519 gen9_sseu_device_status(dev_priv, &sseu);
Jeff McGee7f992ab2015-02-13 10:27:55 -06004520 }
David Weinehall238010e2016-08-01 17:33:27 +03004521
4522 intel_runtime_pm_put(dev_priv);
4523
Imre Deak615d8902016-08-31 19:13:03 +03004524 i915_print_sseu_info(m, false, &sseu);
Jeff McGee7f992ab2015-02-13 10:27:55 -06004525
Jeff McGee38732182015-02-13 10:27:54 -06004526 return 0;
4527}
4528
Ben Widawsky6d794d42011-04-25 11:25:56 -07004529static int i915_forcewake_open(struct inode *inode, struct file *file)
4530{
David Weinehall36cdd012016-08-22 13:59:31 +03004531 struct drm_i915_private *dev_priv = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004532
David Weinehall36cdd012016-08-22 13:59:31 +03004533 if (INTEL_GEN(dev_priv) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004534 return 0;
4535
Chris Wilson6daccb02015-01-16 11:34:35 +02004536 intel_runtime_pm_get(dev_priv);
Mika Kuoppala59bad942015-01-16 11:34:40 +02004537 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004538
4539 return 0;
4540}
4541
Ben Widawskyc43b5632012-04-16 14:07:40 -07004542static int i915_forcewake_release(struct inode *inode, struct file *file)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004543{
David Weinehall36cdd012016-08-22 13:59:31 +03004544 struct drm_i915_private *dev_priv = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004545
David Weinehall36cdd012016-08-22 13:59:31 +03004546 if (INTEL_GEN(dev_priv) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004547 return 0;
4548
Mika Kuoppala59bad942015-01-16 11:34:40 +02004549 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Chris Wilson6daccb02015-01-16 11:34:35 +02004550 intel_runtime_pm_put(dev_priv);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004551
4552 return 0;
4553}
4554
4555static const struct file_operations i915_forcewake_fops = {
4556 .owner = THIS_MODULE,
4557 .open = i915_forcewake_open,
4558 .release = i915_forcewake_release,
4559};
4560
4561static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
4562{
Ben Widawsky6d794d42011-04-25 11:25:56 -07004563 struct dentry *ent;
4564
4565 ent = debugfs_create_file("i915_forcewake_user",
Ben Widawsky8eb57292011-05-11 15:10:58 -07004566 S_IRUSR,
David Weinehall36cdd012016-08-22 13:59:31 +03004567 root, to_i915(minor->dev),
Ben Widawsky6d794d42011-04-25 11:25:56 -07004568 &i915_forcewake_fops);
Wei Yongjunf3c5fe92013-12-16 14:13:25 +08004569 if (!ent)
4570 return -ENOMEM;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004571
Ben Widawsky8eb57292011-05-11 15:10:58 -07004572 return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004573}
4574
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004575static int i915_debugfs_create(struct dentry *root,
4576 struct drm_minor *minor,
4577 const char *name,
4578 const struct file_operations *fops)
Jesse Barnes358733e2011-07-27 11:53:01 -07004579{
Jesse Barnes358733e2011-07-27 11:53:01 -07004580 struct dentry *ent;
4581
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004582 ent = debugfs_create_file(name,
Jesse Barnes358733e2011-07-27 11:53:01 -07004583 S_IRUGO | S_IWUSR,
David Weinehall36cdd012016-08-22 13:59:31 +03004584 root, to_i915(minor->dev),
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004585 fops);
Wei Yongjunf3c5fe92013-12-16 14:13:25 +08004586 if (!ent)
4587 return -ENOMEM;
Jesse Barnes358733e2011-07-27 11:53:01 -07004588
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004589 return drm_add_fake_info_node(minor, ent, fops);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004590}
4591
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01004592static const struct drm_info_list i915_debugfs_list[] = {
Chris Wilson311bd682011-01-13 19:06:50 +00004593 {"i915_capabilities", i915_capabilities, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01004594 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson08c18322011-01-10 00:00:24 +00004595 {"i915_gem_gtt", i915_gem_gtt_info, 0},
Chris Wilson6da84822016-08-15 10:48:44 +01004596 {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1},
Chris Wilson6d2b88852013-08-07 18:30:54 +01004597 {"i915_gem_stolen", i915_gem_stolen_list_info },
Simon Farnsworth4e5359c2010-09-01 17:47:52 +01004598 {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004599 {"i915_gem_request", i915_gem_request_info, 0},
4600 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00004601 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004602 {"i915_gem_interrupt", i915_interrupt_info, 0},
Brad Volkin493018d2014-12-11 12:13:08 -08004603 {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0},
Dave Gordon8b417c22015-08-12 15:43:44 +01004604 {"i915_guc_info", i915_guc_info, 0},
Alex Daifdf5d352015-08-12 15:43:37 +01004605 {"i915_guc_load_status", i915_guc_load_status_info, 0},
Alex Dai4c7e77f2015-08-12 15:43:40 +01004606 {"i915_guc_log_dump", i915_guc_log_dump, 0},
Deepak Sadb4bd12014-03-31 11:30:02 +05304607 {"i915_frequency_info", i915_frequency_info, 0},
Chris Wilsonf6544492015-01-26 18:03:04 +02004608 {"i915_hangcheck_info", i915_hangcheck_info, 0},
Jesse Barnesf97108d2010-01-29 11:27:07 -08004609 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07004610 {"i915_emon_status", i915_emon_status, 0},
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07004611 {"i915_ring_freq_table", i915_ring_freq_table, 0},
Daniel Vetter9a851782015-06-18 10:30:22 +02004612 {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08004613 {"i915_fbc_status", i915_fbc_status, 0},
Paulo Zanoni92d44622013-05-31 16:33:24 -03004614 {"i915_ips_status", i915_ips_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08004615 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01004616 {"i915_opregion", i915_opregion, 0},
Jani Nikulaada8f952015-12-15 13:17:12 +02004617 {"i915_vbt", i915_vbt, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01004618 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Widawskye76d3632011-03-19 18:14:29 -07004619 {"i915_context_status", i915_context_status, 0},
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01004620 {"i915_dump_lrc", i915_dump_lrc, 0},
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02004621 {"i915_forcewake_domains", i915_forcewake_domains, 0},
Daniel Vetterea16a3c2011-12-14 13:57:16 +01004622 {"i915_swizzle_info", i915_swizzle_info, 0},
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01004623 {"i915_ppgtt_info", i915_ppgtt_info, 0},
Ben Widawsky63573eb2013-07-04 11:02:07 -07004624 {"i915_llc", i915_llc, 0},
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03004625 {"i915_edp_psr_status", i915_edp_psr_status, 0},
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02004626 {"i915_sink_crc_eDP1", i915_sink_crc, 0},
Jesse Barnesec013e72013-08-20 10:29:23 +01004627 {"i915_energy_uJ", i915_energy_uJ, 0},
Damien Lespiau6455c872015-06-04 18:23:57 +01004628 {"i915_runtime_pm_status", i915_runtime_pm_status, 0},
Imre Deak1da51582013-11-25 17:15:35 +02004629 {"i915_power_domain_info", i915_power_domain_info, 0},
Damien Lespiaub7cec662015-10-27 14:47:01 +02004630 {"i915_dmc_info", i915_dmc_info, 0},
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08004631 {"i915_display_info", i915_display_info, 0},
Chris Wilson1b365952016-10-04 21:11:31 +01004632 {"i915_engine_info", i915_engine_info, 0},
Ben Widawskye04934c2014-06-30 09:53:42 -07004633 {"i915_semaphore_status", i915_semaphore_status, 0},
Daniel Vetter728e29d2014-06-25 22:01:53 +03004634 {"i915_shared_dplls_info", i915_shared_dplls_info, 0},
Dave Airlie11bed952014-05-12 15:22:27 +10004635 {"i915_dp_mst_info", i915_dp_mst_info, 0},
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01004636 {"i915_wa_registers", i915_wa_registers, 0},
Damien Lespiauc5511e42014-11-04 17:06:51 +00004637 {"i915_ddb_info", i915_ddb_info, 0},
Jeff McGee38732182015-02-13 10:27:54 -06004638 {"i915_sseu_status", i915_sseu_status, 0},
Vandana Kannana54746e2015-03-03 20:53:10 +05304639 {"i915_drrs_status", i915_drrs_status, 0},
Chris Wilson1854d5c2015-04-07 16:20:32 +01004640 {"i915_rps_boost_info", i915_rps_boost_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004641};
Ben Gamari27c202a2009-07-01 22:26:52 -04004642#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05004643
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01004644static const struct i915_debugfs_files {
Daniel Vetter34b96742013-07-04 20:49:44 +02004645 const char *name;
4646 const struct file_operations *fops;
4647} i915_debugfs_files[] = {
4648 {"i915_wedged", &i915_wedged_fops},
4649 {"i915_max_freq", &i915_max_freq_fops},
4650 {"i915_min_freq", &i915_min_freq_fops},
4651 {"i915_cache_sharing", &i915_cache_sharing_fops},
Chris Wilson094f9a52013-09-25 17:34:55 +01004652 {"i915_ring_missed_irq", &i915_ring_missed_irq_fops},
4653 {"i915_ring_test_irq", &i915_ring_test_irq_fops},
Daniel Vetter34b96742013-07-04 20:49:44 +02004654 {"i915_gem_drop_caches", &i915_drop_caches_fops},
Chris Wilson98a2f412016-10-12 10:05:18 +01004655#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
Daniel Vetter34b96742013-07-04 20:49:44 +02004656 {"i915_error_state", &i915_error_state_fops},
Chris Wilson98a2f412016-10-12 10:05:18 +01004657#endif
Daniel Vetter34b96742013-07-04 20:49:44 +02004658 {"i915_next_seqno", &i915_next_seqno_fops},
Damien Lespiaubd9db022013-10-15 18:55:36 +01004659 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
Ville Syrjälä369a1342014-01-22 14:36:08 +02004660 {"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
4661 {"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
4662 {"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
Rodrigo Vivida46f932014-08-01 02:04:45 -07004663 {"i915_fbc_false_color", &i915_fbc_fc_fops},
Todd Previteeb3394fa2015-04-18 00:04:19 -07004664 {"i915_dp_test_data", &i915_displayport_test_data_fops},
4665 {"i915_dp_test_type", &i915_displayport_test_type_fops},
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05304666 {"i915_dp_test_active", &i915_displayport_test_active_fops},
4667 {"i915_guc_log_control", &i915_guc_log_control_fops}
Daniel Vetter34b96742013-07-04 20:49:44 +02004668};
4669
Chris Wilson1dac8912016-06-24 14:00:17 +01004670int i915_debugfs_register(struct drm_i915_private *dev_priv)
Ben Gamari20172632009-02-17 20:08:50 -05004671{
Chris Wilson91c8a322016-07-05 10:40:23 +01004672 struct drm_minor *minor = dev_priv->drm.primary;
Daniel Vetter34b96742013-07-04 20:49:44 +02004673 int ret, i;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004674
Ben Widawsky6d794d42011-04-25 11:25:56 -07004675 ret = i915_forcewake_create(minor->debugfs_root, minor);
4676 if (ret)
4677 return ret;
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004678
Tomeu Vizoso731035f2016-12-12 13:29:48 +01004679 ret = intel_pipe_crc_create(minor);
4680 if (ret)
4681 return ret;
Damien Lespiau07144422013-10-15 18:55:40 +01004682
Daniel Vetter34b96742013-07-04 20:49:44 +02004683 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
4684 ret = i915_debugfs_create(minor->debugfs_root, minor,
4685 i915_debugfs_files[i].name,
4686 i915_debugfs_files[i].fops);
4687 if (ret)
4688 return ret;
4689 }
Mika Kuoppala40633212012-12-04 15:12:00 +02004690
Ben Gamari27c202a2009-07-01 22:26:52 -04004691 return drm_debugfs_create_files(i915_debugfs_list,
4692 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05004693 minor->debugfs_root, minor);
4694}
4695
Chris Wilson1dac8912016-06-24 14:00:17 +01004696void i915_debugfs_unregister(struct drm_i915_private *dev_priv)
Ben Gamari20172632009-02-17 20:08:50 -05004697{
Chris Wilson91c8a322016-07-05 10:40:23 +01004698 struct drm_minor *minor = dev_priv->drm.primary;
Daniel Vetter34b96742013-07-04 20:49:44 +02004699 int i;
4700
Ben Gamari27c202a2009-07-01 22:26:52 -04004701 drm_debugfs_remove_files(i915_debugfs_list,
4702 I915_DEBUGFS_ENTRIES, minor);
Damien Lespiau07144422013-10-15 18:55:40 +01004703
David Weinehall36cdd012016-08-22 13:59:31 +03004704 drm_debugfs_remove_files((struct drm_info_list *)&i915_forcewake_fops,
Ben Widawsky6d794d42011-04-25 11:25:56 -07004705 1, minor);
Damien Lespiau07144422013-10-15 18:55:40 +01004706
Tomeu Vizoso731035f2016-12-12 13:29:48 +01004707 intel_pipe_crc_cleanup(minor);
Damien Lespiau07144422013-10-15 18:55:40 +01004708
Daniel Vetter34b96742013-07-04 20:49:44 +02004709 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
4710 struct drm_info_list *info_list =
David Weinehall36cdd012016-08-22 13:59:31 +03004711 (struct drm_info_list *)i915_debugfs_files[i].fops;
Daniel Vetter34b96742013-07-04 20:49:44 +02004712
4713 drm_debugfs_remove_files(info_list, 1, minor);
4714 }
Ben Gamari20172632009-02-17 20:08:50 -05004715}
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004716
4717struct dpcd_block {
4718 /* DPCD dump start address. */
4719 unsigned int offset;
4720 /* DPCD dump end address, inclusive. If unset, .size will be used. */
4721 unsigned int end;
4722 /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */
4723 size_t size;
4724 /* Only valid for eDP. */
4725 bool edp;
4726};
4727
4728static const struct dpcd_block i915_dpcd_debug[] = {
4729 { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE },
4730 { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS },
4731 { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 },
4732 { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET },
4733 { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 },
4734 { .offset = DP_SET_POWER },
4735 { .offset = DP_EDP_DPCD_REV },
4736 { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 },
4737 { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB },
4738 { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET },
4739};
4740
4741static int i915_dpcd_show(struct seq_file *m, void *data)
4742{
4743 struct drm_connector *connector = m->private;
4744 struct intel_dp *intel_dp =
4745 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
4746 uint8_t buf[16];
4747 ssize_t err;
4748 int i;
4749
Mika Kuoppala5c1a8872015-05-15 13:09:21 +03004750 if (connector->status != connector_status_connected)
4751 return -ENODEV;
4752
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004753 for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) {
4754 const struct dpcd_block *b = &i915_dpcd_debug[i];
4755 size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1);
4756
4757 if (b->edp &&
4758 connector->connector_type != DRM_MODE_CONNECTOR_eDP)
4759 continue;
4760
4761 /* low tech for now */
4762 if (WARN_ON(size > sizeof(buf)))
4763 continue;
4764
4765 err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size);
4766 if (err <= 0) {
4767 DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n",
4768 size, b->offset, err);
4769 continue;
4770 }
4771
4772 seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf);
kbuild test robotb3f9d7d2015-04-16 18:34:06 +08004773 }
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004774
4775 return 0;
4776}
4777
4778static int i915_dpcd_open(struct inode *inode, struct file *file)
4779{
4780 return single_open(file, i915_dpcd_show, inode->i_private);
4781}
4782
4783static const struct file_operations i915_dpcd_fops = {
4784 .owner = THIS_MODULE,
4785 .open = i915_dpcd_open,
4786 .read = seq_read,
4787 .llseek = seq_lseek,
4788 .release = single_release,
4789};
4790
David Weinehallecbd6782016-08-23 12:23:56 +03004791static int i915_panel_show(struct seq_file *m, void *data)
4792{
4793 struct drm_connector *connector = m->private;
4794 struct intel_dp *intel_dp =
4795 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
4796
4797 if (connector->status != connector_status_connected)
4798 return -ENODEV;
4799
4800 seq_printf(m, "Panel power up delay: %d\n",
4801 intel_dp->panel_power_up_delay);
4802 seq_printf(m, "Panel power down delay: %d\n",
4803 intel_dp->panel_power_down_delay);
4804 seq_printf(m, "Backlight on delay: %d\n",
4805 intel_dp->backlight_on_delay);
4806 seq_printf(m, "Backlight off delay: %d\n",
4807 intel_dp->backlight_off_delay);
4808
4809 return 0;
4810}
4811
4812static int i915_panel_open(struct inode *inode, struct file *file)
4813{
4814 return single_open(file, i915_panel_show, inode->i_private);
4815}
4816
4817static const struct file_operations i915_panel_fops = {
4818 .owner = THIS_MODULE,
4819 .open = i915_panel_open,
4820 .read = seq_read,
4821 .llseek = seq_lseek,
4822 .release = single_release,
4823};
4824
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004825/**
4826 * i915_debugfs_connector_add - add i915 specific connector debugfs files
4827 * @connector: pointer to a registered drm_connector
4828 *
4829 * Cleanup will be done by drm_connector_unregister() through a call to
4830 * drm_debugfs_connector_remove().
4831 *
4832 * Returns 0 on success, negative error codes on error.
4833 */
4834int i915_debugfs_connector_add(struct drm_connector *connector)
4835{
4836 struct dentry *root = connector->debugfs_entry;
4837
4838 /* The connector must have been registered beforehands. */
4839 if (!root)
4840 return -ENODEV;
4841
4842 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
4843 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
David Weinehallecbd6782016-08-23 12:23:56 +03004844 debugfs_create_file("i915_dpcd", S_IRUGO, root,
4845 connector, &i915_dpcd_fops);
4846
4847 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP)
4848 debugfs_create_file("i915_panel_timings", S_IRUGO, root,
4849 connector, &i915_panel_fops);
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004850
4851 return 0;
4852}