blob: 0f6116fd91d81bd0b93b5e0b26307245d0b033d4 [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
29#include <linux/seq_file.h>
Damien Lespiaub2c88f52013-10-15 18:55:29 +010030#include <linux/circ_buf.h>
Daniel Vetter926321d2013-10-16 13:30:34 +020031#include <linux/ctype.h>
Chris Wilsonf3cd4742009-10-13 22:20:20 +010032#include <linux/debugfs.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090033#include <linux/slab.h>
Paul Gortmaker2d1a8a42011-08-30 18:16:33 -040034#include <linux/export.h>
Chris Wilson6d2b8882013-08-07 18:30:54 +010035#include <linux/list_sort.h>
Jesse Barnesec013e72013-08-20 10:29:23 +010036#include <asm/msr-index.h>
David Howells760285e2012-10-02 18:01:07 +010037#include <drm/drmP.h>
Simon Farnsworth4e5359c2010-09-01 17:47:52 +010038#include "intel_drv.h"
Chris Wilsone5c65262010-11-01 11:35:28 +000039#include "intel_ringbuffer.h"
David Howells760285e2012-10-02 18:01:07 +010040#include <drm/i915_drm.h>
Ben Gamari20172632009-02-17 20:08:50 -050041#include "i915_drv.h"
42
David Weinehall36cdd012016-08-22 13:59:31 +030043static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
44{
45 return to_i915(node->minor->dev);
46}
47
Damien Lespiau497666d2013-10-15 18:55:39 +010048/* As the drm_debugfs_init() routines are called before dev->dev_private is
49 * allocated we need to hook into the minor for release. */
50static int
51drm_add_fake_info_node(struct drm_minor *minor,
52 struct dentry *ent,
53 const void *key)
54{
55 struct drm_info_node *node;
56
57 node = kmalloc(sizeof(*node), GFP_KERNEL);
58 if (node == NULL) {
59 debugfs_remove(ent);
60 return -ENOMEM;
61 }
62
63 node->minor = minor;
64 node->dent = ent;
David Weinehall36cdd012016-08-22 13:59:31 +030065 node->info_ent = (void *)key;
Damien Lespiau497666d2013-10-15 18:55:39 +010066
67 mutex_lock(&minor->debugfs_lock);
68 list_add(&node->list, &minor->debugfs_list);
69 mutex_unlock(&minor->debugfs_lock);
70
71 return 0;
72}
73
Chris Wilson70d39fe2010-08-25 16:03:34 +010074static int i915_capabilities(struct seq_file *m, void *data)
75{
David Weinehall36cdd012016-08-22 13:59:31 +030076 struct drm_i915_private *dev_priv = node_to_i915(m->private);
77 const struct intel_device_info *info = INTEL_INFO(dev_priv);
Chris Wilson70d39fe2010-08-25 16:03:34 +010078
David Weinehall36cdd012016-08-22 13:59:31 +030079 seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv));
80 seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv));
Damien Lespiau79fc46d2013-04-23 16:37:17 +010081#define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
82#define SEP_SEMICOLON ;
83 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_SEMICOLON);
84#undef PRINT_FLAG
85#undef SEP_SEMICOLON
Chris Wilson70d39fe2010-08-25 16:03:34 +010086
87 return 0;
88}
Ben Gamari433e12f2009-02-17 20:08:51 -050089
Imre Deaka7363de2016-05-12 16:18:52 +030090static char get_active_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000091{
Chris Wilson573adb32016-08-04 16:32:39 +010092 return i915_gem_object_is_active(obj) ? '*' : ' ';
Chris Wilsona6172a82009-02-11 14:26:38 +000093}
94
Imre Deaka7363de2016-05-12 16:18:52 +030095static char get_pin_flag(struct drm_i915_gem_object *obj)
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +010096{
97 return obj->pin_display ? 'p' : ' ';
98}
99
Imre Deaka7363de2016-05-12 16:18:52 +0300100static char get_tiling_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +0000101{
Chris Wilson3e510a82016-08-05 10:14:23 +0100102 switch (i915_gem_object_get_tiling(obj)) {
Akshay Joshi0206e352011-08-16 15:34:10 -0400103 default:
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100104 case I915_TILING_NONE: return ' ';
105 case I915_TILING_X: return 'X';
106 case I915_TILING_Y: return 'Y';
Akshay Joshi0206e352011-08-16 15:34:10 -0400107 }
Chris Wilsona6172a82009-02-11 14:26:38 +0000108}
109
Imre Deaka7363de2016-05-12 16:18:52 +0300110static char get_global_flag(struct drm_i915_gem_object *obj)
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700111{
Chris Wilson058d88c2016-08-15 10:49:06 +0100112 return i915_gem_object_to_ggtt(obj, NULL) ? 'g' : ' ';
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100113}
114
Imre Deaka7363de2016-05-12 16:18:52 +0300115static char get_pin_mapped_flag(struct drm_i915_gem_object *obj)
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100116{
117 return obj->mapping ? 'M' : ' ';
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700118}
119
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100120static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
121{
122 u64 size = 0;
123 struct i915_vma *vma;
124
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000125 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson3272db52016-08-04 16:32:32 +0100126 if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node))
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100127 size += vma->node.size;
128 }
129
130 return size;
131}
132
Chris Wilson37811fc2010-08-25 22:45:57 +0100133static void
134describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
135{
Chris Wilsonb4716182015-04-27 13:41:17 +0100136 struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000137 struct intel_engine_cs *engine;
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700138 struct i915_vma *vma;
Chris Wilsonfaf5bf02016-08-04 16:32:37 +0100139 unsigned int frontbuffer_bits;
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800140 int pin_count = 0;
Dave Gordonc3232b12016-03-23 18:19:53 +0000141 enum intel_engine_id id;
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800142
Chris Wilson188c1ab2016-04-03 14:14:20 +0100143 lockdep_assert_held(&obj->base.dev->struct_mutex);
144
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100145 seq_printf(m, "%pK: %c%c%c%c%c %8zdKiB %02x %02x [ ",
Chris Wilson37811fc2010-08-25 22:45:57 +0100146 &obj->base,
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100147 get_active_flag(obj),
Chris Wilson37811fc2010-08-25 22:45:57 +0100148 get_pin_flag(obj),
149 get_tiling_flag(obj),
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700150 get_global_flag(obj),
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100151 get_pin_mapped_flag(obj),
Eric Anholta05a5862011-12-20 08:54:15 -0800152 obj->base.size / 1024,
Chris Wilson37811fc2010-08-25 22:45:57 +0100153 obj->base.read_domains,
Chris Wilsonb4716182015-04-27 13:41:17 +0100154 obj->base.write_domain);
Dave Gordonc3232b12016-03-23 18:19:53 +0000155 for_each_engine_id(engine, dev_priv, id)
Chris Wilsonb4716182015-04-27 13:41:17 +0100156 seq_printf(m, "%x ",
Chris Wilsond72d9082016-08-04 07:52:31 +0100157 i915_gem_active_get_seqno(&obj->last_read[id],
158 &obj->base.dev->struct_mutex));
Chris Wilson49ef5292016-08-18 17:17:00 +0100159 seq_printf(m, "] %x %s%s%s",
Chris Wilsond72d9082016-08-04 07:52:31 +0100160 i915_gem_active_get_seqno(&obj->last_write,
161 &obj->base.dev->struct_mutex),
David Weinehall36cdd012016-08-22 13:59:31 +0300162 i915_cache_level_str(dev_priv, obj->cache_level),
Chris Wilson37811fc2010-08-25 22:45:57 +0100163 obj->dirty ? " dirty" : "",
164 obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
165 if (obj->base.name)
166 seq_printf(m, " (name: %d)", obj->base.name);
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000167 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson20dfbde2016-08-04 16:32:30 +0100168 if (i915_vma_is_pinned(vma))
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800169 pin_count++;
Dan Carpenterba0635f2015-02-25 16:17:48 +0300170 }
171 seq_printf(m, " (pinned x %d)", pin_count);
Chris Wilsoncc98b412013-08-09 12:25:09 +0100172 if (obj->pin_display)
173 seq_printf(m, " (display)");
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000174 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson15717de2016-08-04 07:52:26 +0100175 if (!drm_mm_node_allocated(&vma->node))
176 continue;
177
Tvrtko Ursulin8d2fdc32015-05-27 10:52:32 +0100178 seq_printf(m, " (%sgtt offset: %08llx, size: %08llx",
Chris Wilson3272db52016-08-04 16:32:32 +0100179 i915_vma_is_ggtt(vma) ? "g" : "pp",
Tvrtko Ursulin8d2fdc32015-05-27 10:52:32 +0100180 vma->node.start, vma->node.size);
Chris Wilson3272db52016-08-04 16:32:32 +0100181 if (i915_vma_is_ggtt(vma))
Chris Wilson596c5922016-02-26 11:03:20 +0000182 seq_printf(m, ", type: %u", vma->ggtt_view.type);
Chris Wilson49ef5292016-08-18 17:17:00 +0100183 if (vma->fence)
184 seq_printf(m, " , fence: %d%s",
185 vma->fence->id,
186 i915_gem_active_isset(&vma->last_fence) ? "*" : "");
Chris Wilson596c5922016-02-26 11:03:20 +0000187 seq_puts(m, ")");
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700188 }
Chris Wilsonc1ad11f2012-11-15 11:32:21 +0000189 if (obj->stolen)
Thierry Reding440fd522015-01-23 09:05:06 +0100190 seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
Chris Wilson30154652015-04-07 17:28:24 +0100191 if (obj->pin_display || obj->fault_mappable) {
Chris Wilson6299f992010-11-24 12:23:44 +0000192 char s[3], *t = s;
Chris Wilson30154652015-04-07 17:28:24 +0100193 if (obj->pin_display)
Chris Wilson6299f992010-11-24 12:23:44 +0000194 *t++ = 'p';
195 if (obj->fault_mappable)
196 *t++ = 'f';
197 *t = '\0';
198 seq_printf(m, " (%s mappable)", s);
199 }
Chris Wilson27c01aa2016-08-04 07:52:30 +0100200
Chris Wilsond72d9082016-08-04 07:52:31 +0100201 engine = i915_gem_active_get_engine(&obj->last_write,
David Weinehall36cdd012016-08-22 13:59:31 +0300202 &dev_priv->drm.struct_mutex);
Chris Wilson27c01aa2016-08-04 07:52:30 +0100203 if (engine)
204 seq_printf(m, " (%s)", engine->name);
205
Chris Wilsonfaf5bf02016-08-04 16:32:37 +0100206 frontbuffer_bits = atomic_read(&obj->frontbuffer_bits);
207 if (frontbuffer_bits)
208 seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits);
Chris Wilson37811fc2010-08-25 22:45:57 +0100209}
210
Chris Wilson6d2b8882013-08-07 18:30:54 +0100211static int obj_rank_by_stolen(void *priv,
212 struct list_head *A, struct list_head *B)
213{
214 struct drm_i915_gem_object *a =
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200215 container_of(A, struct drm_i915_gem_object, obj_exec_link);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100216 struct drm_i915_gem_object *b =
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200217 container_of(B, struct drm_i915_gem_object, obj_exec_link);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100218
Rasmus Villemoes2d05fa12015-09-28 23:08:50 +0200219 if (a->stolen->start < b->stolen->start)
220 return -1;
221 if (a->stolen->start > b->stolen->start)
222 return 1;
223 return 0;
Chris Wilson6d2b8882013-08-07 18:30:54 +0100224}
225
226static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
227{
David Weinehall36cdd012016-08-22 13:59:31 +0300228 struct drm_i915_private *dev_priv = node_to_i915(m->private);
229 struct drm_device *dev = &dev_priv->drm;
Chris Wilson6d2b8882013-08-07 18:30:54 +0100230 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300231 u64 total_obj_size, total_gtt_size;
Chris Wilson6d2b8882013-08-07 18:30:54 +0100232 LIST_HEAD(stolen);
233 int count, ret;
234
235 ret = mutex_lock_interruptible(&dev->struct_mutex);
236 if (ret)
237 return ret;
238
239 total_obj_size = total_gtt_size = count = 0;
240 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
241 if (obj->stolen == NULL)
242 continue;
243
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200244 list_add(&obj->obj_exec_link, &stolen);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100245
246 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100247 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100248 count++;
249 }
250 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
251 if (obj->stolen == NULL)
252 continue;
253
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200254 list_add(&obj->obj_exec_link, &stolen);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100255
256 total_obj_size += obj->base.size;
257 count++;
258 }
259 list_sort(NULL, &stolen, obj_rank_by_stolen);
260 seq_puts(m, "Stolen:\n");
261 while (!list_empty(&stolen)) {
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200262 obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100263 seq_puts(m, " ");
264 describe_obj(m, obj);
265 seq_putc(m, '\n');
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200266 list_del_init(&obj->obj_exec_link);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100267 }
268 mutex_unlock(&dev->struct_mutex);
269
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300270 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
Chris Wilson6d2b8882013-08-07 18:30:54 +0100271 count, total_obj_size, total_gtt_size);
272 return 0;
273}
274
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100275struct file_stats {
Chris Wilson6313c202014-03-19 13:45:45 +0000276 struct drm_i915_file_private *file_priv;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300277 unsigned long count;
278 u64 total, unbound;
279 u64 global, shared;
280 u64 active, inactive;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100281};
282
283static int per_file_stats(int id, void *ptr, void *data)
284{
285 struct drm_i915_gem_object *obj = ptr;
286 struct file_stats *stats = data;
Chris Wilson6313c202014-03-19 13:45:45 +0000287 struct i915_vma *vma;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100288
289 stats->count++;
290 stats->total += obj->base.size;
Chris Wilson15717de2016-08-04 07:52:26 +0100291 if (!obj->bind_count)
292 stats->unbound += obj->base.size;
Chris Wilsonc67a17e2014-03-19 13:45:46 +0000293 if (obj->base.name || obj->base.dma_buf)
294 stats->shared += obj->base.size;
295
Chris Wilson894eeec2016-08-04 07:52:20 +0100296 list_for_each_entry(vma, &obj->vma_list, obj_link) {
297 if (!drm_mm_node_allocated(&vma->node))
298 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000299
Chris Wilson3272db52016-08-04 16:32:32 +0100300 if (i915_vma_is_ggtt(vma)) {
Chris Wilson894eeec2016-08-04 07:52:20 +0100301 stats->global += vma->node.size;
302 } else {
303 struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm);
Chris Wilson6313c202014-03-19 13:45:45 +0000304
Chris Wilson2bfa9962016-08-04 07:52:25 +0100305 if (ppgtt->base.file != stats->file_priv)
Chris Wilson6313c202014-03-19 13:45:45 +0000306 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000307 }
Chris Wilson894eeec2016-08-04 07:52:20 +0100308
Chris Wilsonb0decaf2016-08-04 07:52:44 +0100309 if (i915_vma_is_active(vma))
Chris Wilson894eeec2016-08-04 07:52:20 +0100310 stats->active += vma->node.size;
311 else
312 stats->inactive += vma->node.size;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100313 }
314
315 return 0;
316}
317
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100318#define print_file_stats(m, name, stats) do { \
319 if (stats.count) \
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300320 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 +0100321 name, \
322 stats.count, \
323 stats.total, \
324 stats.active, \
325 stats.inactive, \
326 stats.global, \
327 stats.shared, \
328 stats.unbound); \
329} while (0)
Brad Volkin493018d2014-12-11 12:13:08 -0800330
331static void print_batch_pool_stats(struct seq_file *m,
332 struct drm_i915_private *dev_priv)
333{
334 struct drm_i915_gem_object *obj;
335 struct file_stats stats;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000336 struct intel_engine_cs *engine;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000337 int j;
Brad Volkin493018d2014-12-11 12:13:08 -0800338
339 memset(&stats, 0, sizeof(stats));
340
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000341 for_each_engine(engine, dev_priv) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000342 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100343 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000344 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100345 batch_pool_link)
346 per_file_stats(0, obj, &stats);
347 }
Chris Wilson06fbca72015-04-07 16:20:36 +0100348 }
Brad Volkin493018d2014-12-11 12:13:08 -0800349
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100350 print_file_stats(m, "[k]batch pool", stats);
Brad Volkin493018d2014-12-11 12:13:08 -0800351}
352
Chris Wilson15da9562016-05-24 14:53:43 +0100353static int per_file_ctx_stats(int id, void *ptr, void *data)
354{
355 struct i915_gem_context *ctx = ptr;
356 int n;
357
358 for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) {
359 if (ctx->engine[n].state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +0100360 per_file_stats(0, ctx->engine[n].state->obj, data);
Chris Wilsondca33ec2016-08-02 22:50:20 +0100361 if (ctx->engine[n].ring)
Chris Wilson57e88532016-08-15 10:48:57 +0100362 per_file_stats(0, ctx->engine[n].ring->vma->obj, data);
Chris Wilson15da9562016-05-24 14:53:43 +0100363 }
364
365 return 0;
366}
367
368static void print_context_stats(struct seq_file *m,
369 struct drm_i915_private *dev_priv)
370{
David Weinehall36cdd012016-08-22 13:59:31 +0300371 struct drm_device *dev = &dev_priv->drm;
Chris Wilson15da9562016-05-24 14:53:43 +0100372 struct file_stats stats;
373 struct drm_file *file;
374
375 memset(&stats, 0, sizeof(stats));
376
David Weinehall36cdd012016-08-22 13:59:31 +0300377 mutex_lock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100378 if (dev_priv->kernel_context)
379 per_file_ctx_stats(0, dev_priv->kernel_context, &stats);
380
David Weinehall36cdd012016-08-22 13:59:31 +0300381 list_for_each_entry(file, &dev->filelist, lhead) {
Chris Wilson15da9562016-05-24 14:53:43 +0100382 struct drm_i915_file_private *fpriv = file->driver_priv;
383 idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats);
384 }
David Weinehall36cdd012016-08-22 13:59:31 +0300385 mutex_unlock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100386
387 print_file_stats(m, "[k]contexts", stats);
388}
389
David Weinehall36cdd012016-08-22 13:59:31 +0300390static int i915_gem_object_info(struct seq_file *m, void *data)
Chris Wilson73aa8082010-09-30 11:46:12 +0100391{
David Weinehall36cdd012016-08-22 13:59:31 +0300392 struct drm_i915_private *dev_priv = node_to_i915(m->private);
393 struct drm_device *dev = &dev_priv->drm;
Joonas Lahtinen72e96d62016-03-30 16:57:10 +0300394 struct i915_ggtt *ggtt = &dev_priv->ggtt;
Chris Wilson2bd160a2016-08-15 10:48:45 +0100395 u32 count, mapped_count, purgeable_count, dpy_count;
396 u64 size, mapped_size, purgeable_size, dpy_size;
Chris Wilson6299f992010-11-24 12:23:44 +0000397 struct drm_i915_gem_object *obj;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100398 struct drm_file *file;
Chris Wilson73aa8082010-09-30 11:46:12 +0100399 int ret;
400
401 ret = mutex_lock_interruptible(&dev->struct_mutex);
402 if (ret)
403 return ret;
404
Chris Wilson6299f992010-11-24 12:23:44 +0000405 seq_printf(m, "%u objects, %zu bytes\n",
406 dev_priv->mm.object_count,
407 dev_priv->mm.object_memory);
408
Chris Wilson1544c422016-08-15 13:18:16 +0100409 size = count = 0;
410 mapped_size = mapped_count = 0;
411 purgeable_size = purgeable_count = 0;
Ben Widawsky35c20a62013-05-31 11:28:48 -0700412 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100413 size += obj->base.size;
414 ++count;
Chris Wilson6c085a72012-08-20 11:40:46 +0200415
Chris Wilsonb7abb712012-08-20 11:33:30 +0200416 if (obj->madv == I915_MADV_DONTNEED) {
417 purgeable_size += obj->base.size;
418 ++purgeable_count;
419 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100420
Tvrtko Ursulinbe19b102016-04-15 11:34:53 +0100421 if (obj->mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100422 mapped_count++;
423 mapped_size += obj->base.size;
Tvrtko Ursulinbe19b102016-04-15 11:34:53 +0100424 }
Chris Wilson6299f992010-11-24 12:23:44 +0000425 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100426 seq_printf(m, "%u unbound objects, %llu bytes\n", count, size);
427
428 size = count = dpy_size = dpy_count = 0;
429 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
430 size += obj->base.size;
431 ++count;
432
433 if (obj->pin_display) {
434 dpy_size += obj->base.size;
435 ++dpy_count;
436 }
437
438 if (obj->madv == I915_MADV_DONTNEED) {
439 purgeable_size += obj->base.size;
440 ++purgeable_count;
441 }
442
443 if (obj->mapping) {
444 mapped_count++;
445 mapped_size += obj->base.size;
446 }
447 }
448 seq_printf(m, "%u bound objects, %llu bytes\n",
449 count, size);
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300450 seq_printf(m, "%u purgeable objects, %llu bytes\n",
Chris Wilsonb7abb712012-08-20 11:33:30 +0200451 purgeable_count, purgeable_size);
Chris Wilson2bd160a2016-08-15 10:48:45 +0100452 seq_printf(m, "%u mapped objects, %llu bytes\n",
453 mapped_count, mapped_size);
454 seq_printf(m, "%u display objects (pinned), %llu bytes\n",
455 dpy_count, dpy_size);
Chris Wilson6299f992010-11-24 12:23:44 +0000456
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300457 seq_printf(m, "%llu [%llu] gtt total\n",
Joonas Lahtinen72e96d62016-03-30 16:57:10 +0300458 ggtt->base.total, ggtt->mappable_end - ggtt->base.start);
Chris Wilson73aa8082010-09-30 11:46:12 +0100459
Damien Lespiau267f0c92013-06-24 22:59:48 +0100460 seq_putc(m, '\n');
Brad Volkin493018d2014-12-11 12:13:08 -0800461 print_batch_pool_stats(m, dev_priv);
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200462 mutex_unlock(&dev->struct_mutex);
463
464 mutex_lock(&dev->filelist_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100465 print_context_stats(m, dev_priv);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100466 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
467 struct file_stats stats;
Chris Wilsonc84455b2016-08-15 10:49:08 +0100468 struct drm_i915_file_private *file_priv = file->driver_priv;
469 struct drm_i915_gem_request *request;
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900470 struct task_struct *task;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100471
472 memset(&stats, 0, sizeof(stats));
Chris Wilson6313c202014-03-19 13:45:45 +0000473 stats.file_priv = file->driver_priv;
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100474 spin_lock(&file->table_lock);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100475 idr_for_each(&file->object_idr, per_file_stats, &stats);
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100476 spin_unlock(&file->table_lock);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900477 /*
478 * Although we have a valid reference on file->pid, that does
479 * not guarantee that the task_struct who called get_pid() is
480 * still alive (e.g. get_pid(current) => fork() => exit()).
481 * Therefore, we need to protect this ->comm access using RCU.
482 */
Chris Wilsonc84455b2016-08-15 10:49:08 +0100483 mutex_lock(&dev->struct_mutex);
484 request = list_first_entry_or_null(&file_priv->mm.request_list,
485 struct drm_i915_gem_request,
486 client_list);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900487 rcu_read_lock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100488 task = pid_task(request && request->ctx->pid ?
489 request->ctx->pid : file->pid,
490 PIDTYPE_PID);
Brad Volkin493018d2014-12-11 12:13:08 -0800491 print_file_stats(m, task ? task->comm : "<unknown>", stats);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900492 rcu_read_unlock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100493 mutex_unlock(&dev->struct_mutex);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100494 }
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200495 mutex_unlock(&dev->filelist_mutex);
Chris Wilson73aa8082010-09-30 11:46:12 +0100496
497 return 0;
498}
499
Damien Lespiauaee56cf2013-06-24 22:59:49 +0100500static int i915_gem_gtt_info(struct seq_file *m, void *data)
Chris Wilson08c18322011-01-10 00:00:24 +0000501{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100502 struct drm_info_node *node = m->private;
David Weinehall36cdd012016-08-22 13:59:31 +0300503 struct drm_i915_private *dev_priv = node_to_i915(node);
504 struct drm_device *dev = &dev_priv->drm;
Chris Wilson5f4b0912016-08-19 12:56:25 +0100505 bool show_pin_display_only = !!node->info_ent->data;
Chris Wilson08c18322011-01-10 00:00:24 +0000506 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300507 u64 total_obj_size, total_gtt_size;
Chris Wilson08c18322011-01-10 00:00:24 +0000508 int count, ret;
509
510 ret = mutex_lock_interruptible(&dev->struct_mutex);
511 if (ret)
512 return ret;
513
514 total_obj_size = total_gtt_size = count = 0;
Ben Widawsky35c20a62013-05-31 11:28:48 -0700515 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
Chris Wilson6da84822016-08-15 10:48:44 +0100516 if (show_pin_display_only && !obj->pin_display)
Chris Wilson1b502472012-04-24 15:47:30 +0100517 continue;
518
Damien Lespiau267f0c92013-06-24 22:59:48 +0100519 seq_puts(m, " ");
Chris Wilson08c18322011-01-10 00:00:24 +0000520 describe_obj(m, obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100521 seq_putc(m, '\n');
Chris Wilson08c18322011-01-10 00:00:24 +0000522 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100523 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilson08c18322011-01-10 00:00:24 +0000524 count++;
525 }
526
527 mutex_unlock(&dev->struct_mutex);
528
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300529 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
Chris Wilson08c18322011-01-10 00:00:24 +0000530 count, total_obj_size, total_gtt_size);
531
532 return 0;
533}
534
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100535static int i915_gem_pageflip_info(struct seq_file *m, void *data)
536{
David Weinehall36cdd012016-08-22 13:59:31 +0300537 struct drm_i915_private *dev_priv = node_to_i915(m->private);
538 struct drm_device *dev = &dev_priv->drm;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100539 struct intel_crtc *crtc;
Daniel Vetter8a270eb2014-06-17 22:34:37 +0200540 int ret;
541
542 ret = mutex_lock_interruptible(&dev->struct_mutex);
543 if (ret)
544 return ret;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100545
Damien Lespiaud3fcc802014-05-13 23:32:22 +0100546 for_each_intel_crtc(dev, crtc) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800547 const char pipe = pipe_name(crtc->pipe);
548 const char plane = plane_name(crtc->plane);
Maarten Lankhorst51cbaf02016-05-17 15:07:49 +0200549 struct intel_flip_work *work;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100550
Daniel Vetter5e2d7af2014-09-15 14:55:22 +0200551 spin_lock_irq(&dev->event_lock);
Daniel Vetter5a21b662016-05-24 17:13:53 +0200552 work = crtc->flip_work;
553 if (work == NULL) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800554 seq_printf(m, "No flip due on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100555 pipe, plane);
556 } else {
Daniel Vetter5a21b662016-05-24 17:13:53 +0200557 u32 pending;
558 u32 addr;
559
560 pending = atomic_read(&work->pending);
561 if (pending) {
562 seq_printf(m, "Flip ioctl preparing on pipe %c (plane %c)\n",
563 pipe, plane);
564 } else {
565 seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
566 pipe, plane);
567 }
568 if (work->flip_queued_req) {
569 struct intel_engine_cs *engine = i915_gem_request_get_engine(work->flip_queued_req);
570
571 seq_printf(m, "Flip queued on %s at seqno %x, next seqno %x [current breadcrumb %x], completed? %d\n",
572 engine->name,
573 i915_gem_request_get_seqno(work->flip_queued_req),
574 dev_priv->next_seqno,
Chris Wilson1b7744e2016-07-01 17:23:17 +0100575 intel_engine_get_seqno(engine),
Chris Wilsonf69a02c2016-07-01 17:23:16 +0100576 i915_gem_request_completed(work->flip_queued_req));
Daniel Vetter5a21b662016-05-24 17:13:53 +0200577 } else
578 seq_printf(m, "Flip not associated with any ring\n");
579 seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n",
580 work->flip_queued_vblank,
581 work->flip_ready_vblank,
582 intel_crtc_get_vblank_counter(crtc));
583 seq_printf(m, "%d prepares\n", atomic_read(&work->pending));
584
David Weinehall36cdd012016-08-22 13:59:31 +0300585 if (INTEL_GEN(dev_priv) >= 4)
Daniel Vetter5a21b662016-05-24 17:13:53 +0200586 addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane)));
587 else
588 addr = I915_READ(DSPADDR(crtc->plane));
589 seq_printf(m, "Current scanout address 0x%08x\n", addr);
590
591 if (work->pending_flip_obj) {
592 seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset);
593 seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100594 }
595 }
Daniel Vetter5e2d7af2014-09-15 14:55:22 +0200596 spin_unlock_irq(&dev->event_lock);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100597 }
598
Daniel Vetter8a270eb2014-06-17 22:34:37 +0200599 mutex_unlock(&dev->struct_mutex);
600
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100601 return 0;
602}
603
Brad Volkin493018d2014-12-11 12:13:08 -0800604static int i915_gem_batch_pool_info(struct seq_file *m, void *data)
605{
David Weinehall36cdd012016-08-22 13:59:31 +0300606 struct drm_i915_private *dev_priv = node_to_i915(m->private);
607 struct drm_device *dev = &dev_priv->drm;
Brad Volkin493018d2014-12-11 12:13:08 -0800608 struct drm_i915_gem_object *obj;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000609 struct intel_engine_cs *engine;
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
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000617 for_each_engine(engine, dev_priv) {
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
Ben Gamari20172632009-02-17 20:08:50 -0500648static int i915_gem_request_info(struct seq_file *m, void *data)
649{
David Weinehall36cdd012016-08-22 13:59:31 +0300650 struct drm_i915_private *dev_priv = node_to_i915(m->private);
651 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000652 struct intel_engine_cs *engine;
Daniel Vettereed29a52015-05-21 14:21:25 +0200653 struct drm_i915_gem_request *req;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000654 int ret, any;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100655
656 ret = mutex_lock_interruptible(&dev->struct_mutex);
657 if (ret)
658 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500659
Chris Wilson2d1070b2015-04-01 10:36:56 +0100660 any = 0;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000661 for_each_engine(engine, dev_priv) {
Chris Wilson2d1070b2015-04-01 10:36:56 +0100662 int count;
663
664 count = 0;
Chris Wilsonefdf7c02016-08-04 07:52:33 +0100665 list_for_each_entry(req, &engine->request_list, link)
Chris Wilson2d1070b2015-04-01 10:36:56 +0100666 count++;
667 if (count == 0)
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100668 continue;
669
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000670 seq_printf(m, "%s requests: %d\n", engine->name, count);
Chris Wilsonefdf7c02016-08-04 07:52:33 +0100671 list_for_each_entry(req, &engine->request_list, link) {
Chris Wilsonc84455b2016-08-15 10:49:08 +0100672 struct pid *pid = req->ctx->pid;
Chris Wilson2d1070b2015-04-01 10:36:56 +0100673 struct task_struct *task;
674
675 rcu_read_lock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100676 task = pid ? pid_task(pid, PIDTYPE_PID) : NULL;
Chris Wilson2d1070b2015-04-01 10:36:56 +0100677 seq_printf(m, " %x @ %d: %s [%d]\n",
Chris Wilson04769652016-07-20 09:21:11 +0100678 req->fence.seqno,
Daniel Vettereed29a52015-05-21 14:21:25 +0200679 (int) (jiffies - req->emitted_jiffies),
Chris Wilson2d1070b2015-04-01 10:36:56 +0100680 task ? task->comm : "<unknown>",
681 task ? task->pid : -1);
682 rcu_read_unlock();
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100683 }
Chris Wilson2d1070b2015-04-01 10:36:56 +0100684
685 any++;
Ben Gamari20172632009-02-17 20:08:50 -0500686 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100687 mutex_unlock(&dev->struct_mutex);
688
Chris Wilson2d1070b2015-04-01 10:36:56 +0100689 if (any == 0)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100690 seq_puts(m, "No requests\n");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100691
Ben Gamari20172632009-02-17 20:08:50 -0500692 return 0;
693}
694
Chris Wilsonb2223492010-10-27 15:27:33 +0100695static void i915_ring_seqno_info(struct seq_file *m,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +0000696 struct intel_engine_cs *engine)
Chris Wilsonb2223492010-10-27 15:27:33 +0100697{
Chris Wilson688e6c72016-07-01 17:23:15 +0100698 struct intel_breadcrumbs *b = &engine->breadcrumbs;
699 struct rb_node *rb;
700
Chris Wilson12471ba2016-04-09 10:57:55 +0100701 seq_printf(m, "Current sequence (%s): %x\n",
Chris Wilson1b7744e2016-07-01 17:23:17 +0100702 engine->name, intel_engine_get_seqno(engine));
Chris Wilson688e6c72016-07-01 17:23:15 +0100703
704 spin_lock(&b->lock);
705 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
706 struct intel_wait *w = container_of(rb, typeof(*w), node);
707
708 seq_printf(m, "Waiting (%s): %s [%d] on %x\n",
709 engine->name, w->tsk->comm, w->tsk->pid, w->seqno);
710 }
711 spin_unlock(&b->lock);
Chris Wilsonb2223492010-10-27 15:27:33 +0100712}
713
Ben Gamari20172632009-02-17 20:08:50 -0500714static int i915_gem_seqno_info(struct seq_file *m, void *data)
715{
David Weinehall36cdd012016-08-22 13:59:31 +0300716 struct drm_i915_private *dev_priv = node_to_i915(m->private);
717 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000718 struct intel_engine_cs *engine;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000719 int ret;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100720
721 ret = mutex_lock_interruptible(&dev->struct_mutex);
722 if (ret)
723 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200724 intel_runtime_pm_get(dev_priv);
Ben Gamari20172632009-02-17 20:08:50 -0500725
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000726 for_each_engine(engine, dev_priv)
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000727 i915_ring_seqno_info(m, engine);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100728
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200729 intel_runtime_pm_put(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100730 mutex_unlock(&dev->struct_mutex);
731
Ben Gamari20172632009-02-17 20:08:50 -0500732 return 0;
733}
734
735
736static int i915_interrupt_info(struct seq_file *m, void *data)
737{
David Weinehall36cdd012016-08-22 13:59:31 +0300738 struct drm_i915_private *dev_priv = node_to_i915(m->private);
739 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000740 struct intel_engine_cs *engine;
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800741 int ret, i, pipe;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100742
743 ret = mutex_lock_interruptible(&dev->struct_mutex);
744 if (ret)
745 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200746 intel_runtime_pm_get(dev_priv);
Ben Gamari20172632009-02-17 20:08:50 -0500747
David Weinehall36cdd012016-08-22 13:59:31 +0300748 if (IS_CHERRYVIEW(dev_priv)) {
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300749 seq_printf(m, "Master Interrupt Control:\t%08x\n",
750 I915_READ(GEN8_MASTER_IRQ));
751
752 seq_printf(m, "Display IER:\t%08x\n",
753 I915_READ(VLV_IER));
754 seq_printf(m, "Display IIR:\t%08x\n",
755 I915_READ(VLV_IIR));
756 seq_printf(m, "Display IIR_RW:\t%08x\n",
757 I915_READ(VLV_IIR_RW));
758 seq_printf(m, "Display IMR:\t%08x\n",
759 I915_READ(VLV_IMR));
Damien Lespiau055e3932014-08-18 13:49:10 +0100760 for_each_pipe(dev_priv, pipe)
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300761 seq_printf(m, "Pipe %c stat:\t%08x\n",
762 pipe_name(pipe),
763 I915_READ(PIPESTAT(pipe)));
764
765 seq_printf(m, "Port hotplug:\t%08x\n",
766 I915_READ(PORT_HOTPLUG_EN));
767 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
768 I915_READ(VLV_DPFLIPSTAT));
769 seq_printf(m, "DPINVGTT:\t%08x\n",
770 I915_READ(DPINVGTT));
771
772 for (i = 0; i < 4; i++) {
773 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
774 i, I915_READ(GEN8_GT_IMR(i)));
775 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
776 i, I915_READ(GEN8_GT_IIR(i)));
777 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
778 i, I915_READ(GEN8_GT_IER(i)));
779 }
780
781 seq_printf(m, "PCU interrupt mask:\t%08x\n",
782 I915_READ(GEN8_PCU_IMR));
783 seq_printf(m, "PCU interrupt identity:\t%08x\n",
784 I915_READ(GEN8_PCU_IIR));
785 seq_printf(m, "PCU interrupt enable:\t%08x\n",
786 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300787 } else if (INTEL_GEN(dev_priv) >= 8) {
Ben Widawskya123f152013-11-02 21:07:10 -0700788 seq_printf(m, "Master Interrupt Control:\t%08x\n",
789 I915_READ(GEN8_MASTER_IRQ));
790
791 for (i = 0; i < 4; i++) {
792 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
793 i, I915_READ(GEN8_GT_IMR(i)));
794 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
795 i, I915_READ(GEN8_GT_IIR(i)));
796 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
797 i, I915_READ(GEN8_GT_IER(i)));
798 }
799
Damien Lespiau055e3932014-08-18 13:49:10 +0100800 for_each_pipe(dev_priv, pipe) {
Imre Deake1296492016-02-12 18:55:17 +0200801 enum intel_display_power_domain power_domain;
802
803 power_domain = POWER_DOMAIN_PIPE(pipe);
804 if (!intel_display_power_get_if_enabled(dev_priv,
805 power_domain)) {
Paulo Zanoni22c59962014-08-08 17:45:32 -0300806 seq_printf(m, "Pipe %c power disabled\n",
807 pipe_name(pipe));
808 continue;
809 }
Ben Widawskya123f152013-11-02 21:07:10 -0700810 seq_printf(m, "Pipe %c IMR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000811 pipe_name(pipe),
812 I915_READ(GEN8_DE_PIPE_IMR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700813 seq_printf(m, "Pipe %c IIR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000814 pipe_name(pipe),
815 I915_READ(GEN8_DE_PIPE_IIR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700816 seq_printf(m, "Pipe %c IER:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000817 pipe_name(pipe),
818 I915_READ(GEN8_DE_PIPE_IER(pipe)));
Imre Deake1296492016-02-12 18:55:17 +0200819
820 intel_display_power_put(dev_priv, power_domain);
Ben Widawskya123f152013-11-02 21:07:10 -0700821 }
822
823 seq_printf(m, "Display Engine port interrupt mask:\t%08x\n",
824 I915_READ(GEN8_DE_PORT_IMR));
825 seq_printf(m, "Display Engine port interrupt identity:\t%08x\n",
826 I915_READ(GEN8_DE_PORT_IIR));
827 seq_printf(m, "Display Engine port interrupt enable:\t%08x\n",
828 I915_READ(GEN8_DE_PORT_IER));
829
830 seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n",
831 I915_READ(GEN8_DE_MISC_IMR));
832 seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n",
833 I915_READ(GEN8_DE_MISC_IIR));
834 seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n",
835 I915_READ(GEN8_DE_MISC_IER));
836
837 seq_printf(m, "PCU interrupt mask:\t%08x\n",
838 I915_READ(GEN8_PCU_IMR));
839 seq_printf(m, "PCU interrupt identity:\t%08x\n",
840 I915_READ(GEN8_PCU_IIR));
841 seq_printf(m, "PCU interrupt enable:\t%08x\n",
842 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300843 } else if (IS_VALLEYVIEW(dev_priv)) {
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700844 seq_printf(m, "Display IER:\t%08x\n",
845 I915_READ(VLV_IER));
846 seq_printf(m, "Display IIR:\t%08x\n",
847 I915_READ(VLV_IIR));
848 seq_printf(m, "Display IIR_RW:\t%08x\n",
849 I915_READ(VLV_IIR_RW));
850 seq_printf(m, "Display IMR:\t%08x\n",
851 I915_READ(VLV_IMR));
Damien Lespiau055e3932014-08-18 13:49:10 +0100852 for_each_pipe(dev_priv, pipe)
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700853 seq_printf(m, "Pipe %c stat:\t%08x\n",
854 pipe_name(pipe),
855 I915_READ(PIPESTAT(pipe)));
856
857 seq_printf(m, "Master IER:\t%08x\n",
858 I915_READ(VLV_MASTER_IER));
859
860 seq_printf(m, "Render IER:\t%08x\n",
861 I915_READ(GTIER));
862 seq_printf(m, "Render IIR:\t%08x\n",
863 I915_READ(GTIIR));
864 seq_printf(m, "Render IMR:\t%08x\n",
865 I915_READ(GTIMR));
866
867 seq_printf(m, "PM IER:\t\t%08x\n",
868 I915_READ(GEN6_PMIER));
869 seq_printf(m, "PM IIR:\t\t%08x\n",
870 I915_READ(GEN6_PMIIR));
871 seq_printf(m, "PM IMR:\t\t%08x\n",
872 I915_READ(GEN6_PMIMR));
873
874 seq_printf(m, "Port hotplug:\t%08x\n",
875 I915_READ(PORT_HOTPLUG_EN));
876 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
877 I915_READ(VLV_DPFLIPSTAT));
878 seq_printf(m, "DPINVGTT:\t%08x\n",
879 I915_READ(DPINVGTT));
880
David Weinehall36cdd012016-08-22 13:59:31 +0300881 } else if (!HAS_PCH_SPLIT(dev_priv)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800882 seq_printf(m, "Interrupt enable: %08x\n",
883 I915_READ(IER));
884 seq_printf(m, "Interrupt identity: %08x\n",
885 I915_READ(IIR));
886 seq_printf(m, "Interrupt mask: %08x\n",
887 I915_READ(IMR));
Damien Lespiau055e3932014-08-18 13:49:10 +0100888 for_each_pipe(dev_priv, pipe)
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800889 seq_printf(m, "Pipe %c stat: %08x\n",
890 pipe_name(pipe),
891 I915_READ(PIPESTAT(pipe)));
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800892 } else {
893 seq_printf(m, "North Display Interrupt enable: %08x\n",
894 I915_READ(DEIER));
895 seq_printf(m, "North Display Interrupt identity: %08x\n",
896 I915_READ(DEIIR));
897 seq_printf(m, "North Display Interrupt mask: %08x\n",
898 I915_READ(DEIMR));
899 seq_printf(m, "South Display Interrupt enable: %08x\n",
900 I915_READ(SDEIER));
901 seq_printf(m, "South Display Interrupt identity: %08x\n",
902 I915_READ(SDEIIR));
903 seq_printf(m, "South Display Interrupt mask: %08x\n",
904 I915_READ(SDEIMR));
905 seq_printf(m, "Graphics Interrupt enable: %08x\n",
906 I915_READ(GTIER));
907 seq_printf(m, "Graphics Interrupt identity: %08x\n",
908 I915_READ(GTIIR));
909 seq_printf(m, "Graphics Interrupt mask: %08x\n",
910 I915_READ(GTIMR));
911 }
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000912 for_each_engine(engine, dev_priv) {
David Weinehall36cdd012016-08-22 13:59:31 +0300913 if (INTEL_GEN(dev_priv) >= 6) {
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100914 seq_printf(m,
915 "Graphics Interrupt mask (%s): %08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000916 engine->name, I915_READ_IMR(engine));
Chris Wilson9862e602011-01-04 22:22:17 +0000917 }
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000918 i915_ring_seqno_info(m, engine);
Chris Wilson9862e602011-01-04 22:22:17 +0000919 }
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200920 intel_runtime_pm_put(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100921 mutex_unlock(&dev->struct_mutex);
922
Ben Gamari20172632009-02-17 20:08:50 -0500923 return 0;
924}
925
Chris Wilsona6172a82009-02-11 14:26:38 +0000926static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
927{
David Weinehall36cdd012016-08-22 13:59:31 +0300928 struct drm_i915_private *dev_priv = node_to_i915(m->private);
929 struct drm_device *dev = &dev_priv->drm;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100930 int i, ret;
931
932 ret = mutex_lock_interruptible(&dev->struct_mutex);
933 if (ret)
934 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000935
Chris Wilsona6172a82009-02-11 14:26:38 +0000936 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
937 for (i = 0; i < dev_priv->num_fence_regs; i++) {
Chris Wilson49ef5292016-08-18 17:17:00 +0100938 struct i915_vma *vma = dev_priv->fence_regs[i].vma;
Chris Wilsona6172a82009-02-11 14:26:38 +0000939
Chris Wilson6c085a72012-08-20 11:40:46 +0200940 seq_printf(m, "Fence %d, pin count = %d, object = ",
941 i, dev_priv->fence_regs[i].pin_count);
Chris Wilson49ef5292016-08-18 17:17:00 +0100942 if (!vma)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100943 seq_puts(m, "unused");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100944 else
Chris Wilson49ef5292016-08-18 17:17:00 +0100945 describe_obj(m, vma->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100946 seq_putc(m, '\n');
Chris Wilsona6172a82009-02-11 14:26:38 +0000947 }
948
Chris Wilson05394f32010-11-08 19:18:58 +0000949 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000950 return 0;
951}
952
Ben Gamari20172632009-02-17 20:08:50 -0500953static int i915_hws_info(struct seq_file *m, void *data)
954{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100955 struct drm_info_node *node = m->private;
David Weinehall36cdd012016-08-22 13:59:31 +0300956 struct drm_i915_private *dev_priv = node_to_i915(node);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000957 struct intel_engine_cs *engine;
Daniel Vetter1a240d42012-11-29 22:18:51 +0100958 const u32 *hws;
Chris Wilson4066c0a2010-10-29 21:00:54 +0100959 int i;
Ben Gamari20172632009-02-17 20:08:50 -0500960
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000961 engine = &dev_priv->engine[(uintptr_t)node->info_ent->data];
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000962 hws = engine->status_page.page_addr;
Ben Gamari20172632009-02-17 20:08:50 -0500963 if (hws == NULL)
964 return 0;
965
966 for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
967 seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
968 i * 4,
969 hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
970 }
971 return 0;
972}
973
Daniel Vetterd5442302012-04-27 15:17:40 +0200974static ssize_t
975i915_error_state_write(struct file *filp,
976 const char __user *ubuf,
977 size_t cnt,
978 loff_t *ppos)
979{
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300980 struct i915_error_state_file_priv *error_priv = filp->private_data;
Daniel Vetterd5442302012-04-27 15:17:40 +0200981 struct drm_device *dev = error_priv->dev;
Daniel Vetter22bcfc62012-08-09 15:07:02 +0200982 int ret;
Daniel Vetterd5442302012-04-27 15:17:40 +0200983
984 DRM_DEBUG_DRIVER("Resetting error state\n");
985
Daniel Vetter22bcfc62012-08-09 15:07:02 +0200986 ret = mutex_lock_interruptible(&dev->struct_mutex);
987 if (ret)
988 return ret;
989
Daniel Vetterd5442302012-04-27 15:17:40 +0200990 i915_destroy_error_state(dev);
991 mutex_unlock(&dev->struct_mutex);
992
993 return cnt;
994}
995
996static int i915_error_state_open(struct inode *inode, struct file *file)
997{
David Weinehall36cdd012016-08-22 13:59:31 +0300998 struct drm_i915_private *dev_priv = inode->i_private;
Daniel Vetterd5442302012-04-27 15:17:40 +0200999 struct i915_error_state_file_priv *error_priv;
Daniel Vetterd5442302012-04-27 15:17:40 +02001000
1001 error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL);
1002 if (!error_priv)
1003 return -ENOMEM;
1004
David Weinehall36cdd012016-08-22 13:59:31 +03001005 error_priv->dev = &dev_priv->drm;
Daniel Vetterd5442302012-04-27 15:17:40 +02001006
David Weinehall36cdd012016-08-22 13:59:31 +03001007 i915_error_state_get(&dev_priv->drm, error_priv);
Daniel Vetterd5442302012-04-27 15:17:40 +02001008
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001009 file->private_data = error_priv;
1010
1011 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +02001012}
1013
1014static int i915_error_state_release(struct inode *inode, struct file *file)
1015{
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001016 struct i915_error_state_file_priv *error_priv = file->private_data;
Daniel Vetterd5442302012-04-27 15:17:40 +02001017
Mika Kuoppala95d5bfb2013-06-06 15:18:40 +03001018 i915_error_state_put(error_priv);
Daniel Vetterd5442302012-04-27 15:17:40 +02001019 kfree(error_priv);
1020
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001021 return 0;
1022}
1023
1024static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
1025 size_t count, loff_t *pos)
1026{
1027 struct i915_error_state_file_priv *error_priv = file->private_data;
1028 struct drm_i915_error_state_buf error_str;
1029 loff_t tmp_pos = 0;
1030 ssize_t ret_count = 0;
Mika Kuoppala4dc955f2013-06-06 15:18:41 +03001031 int ret;
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001032
David Weinehall36cdd012016-08-22 13:59:31 +03001033 ret = i915_error_state_buf_init(&error_str,
1034 to_i915(error_priv->dev), count, *pos);
Mika Kuoppala4dc955f2013-06-06 15:18:41 +03001035 if (ret)
1036 return ret;
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001037
Mika Kuoppalafc16b482013-06-06 15:18:39 +03001038 ret = i915_error_state_to_str(&error_str, error_priv);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001039 if (ret)
1040 goto out;
1041
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001042 ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos,
1043 error_str.buf,
1044 error_str.bytes);
1045
1046 if (ret_count < 0)
1047 ret = ret_count;
1048 else
1049 *pos = error_str.start + ret_count;
1050out:
Mika Kuoppala4dc955f2013-06-06 15:18:41 +03001051 i915_error_state_buf_release(&error_str);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001052 return ret ?: ret_count;
Daniel Vetterd5442302012-04-27 15:17:40 +02001053}
1054
1055static const struct file_operations i915_error_state_fops = {
1056 .owner = THIS_MODULE,
1057 .open = i915_error_state_open,
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001058 .read = i915_error_state_read,
Daniel Vetterd5442302012-04-27 15:17:40 +02001059 .write = i915_error_state_write,
1060 .llseek = default_llseek,
1061 .release = i915_error_state_release,
1062};
1063
Kees Cook647416f2013-03-10 14:10:06 -07001064static int
1065i915_next_seqno_get(void *data, u64 *val)
Mika Kuoppala40633212012-12-04 15:12:00 +02001066{
David Weinehall36cdd012016-08-22 13:59:31 +03001067 struct drm_i915_private *dev_priv = data;
Mika Kuoppala40633212012-12-04 15:12:00 +02001068 int ret;
1069
David Weinehall36cdd012016-08-22 13:59:31 +03001070 ret = mutex_lock_interruptible(&dev_priv->drm.struct_mutex);
Mika Kuoppala40633212012-12-04 15:12:00 +02001071 if (ret)
1072 return ret;
1073
Kees Cook647416f2013-03-10 14:10:06 -07001074 *val = dev_priv->next_seqno;
David Weinehall36cdd012016-08-22 13:59:31 +03001075 mutex_unlock(&dev_priv->drm.struct_mutex);
Mika Kuoppala40633212012-12-04 15:12:00 +02001076
Kees Cook647416f2013-03-10 14:10:06 -07001077 return 0;
Mika Kuoppala40633212012-12-04 15:12:00 +02001078}
1079
Kees Cook647416f2013-03-10 14:10:06 -07001080static int
1081i915_next_seqno_set(void *data, u64 val)
Mika Kuoppala40633212012-12-04 15:12:00 +02001082{
David Weinehall36cdd012016-08-22 13:59:31 +03001083 struct drm_i915_private *dev_priv = data;
1084 struct drm_device *dev = &dev_priv->drm;
Mika Kuoppala40633212012-12-04 15:12:00 +02001085 int ret;
1086
Mika Kuoppala40633212012-12-04 15:12:00 +02001087 ret = mutex_lock_interruptible(&dev->struct_mutex);
1088 if (ret)
1089 return ret;
1090
Mika Kuoppalae94fbaa2012-12-19 11:13:09 +02001091 ret = i915_gem_set_seqno(dev, val);
Mika Kuoppala40633212012-12-04 15:12:00 +02001092 mutex_unlock(&dev->struct_mutex);
1093
Kees Cook647416f2013-03-10 14:10:06 -07001094 return ret;
Mika Kuoppala40633212012-12-04 15:12:00 +02001095}
1096
Kees Cook647416f2013-03-10 14:10:06 -07001097DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
1098 i915_next_seqno_get, i915_next_seqno_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03001099 "0x%llx\n");
Mika Kuoppala40633212012-12-04 15:12:00 +02001100
Deepak Sadb4bd12014-03-31 11:30:02 +05301101static int i915_frequency_info(struct seq_file *m, void *unused)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001102{
David Weinehall36cdd012016-08-22 13:59:31 +03001103 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1104 struct drm_device *dev = &dev_priv->drm;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001105 int ret = 0;
1106
1107 intel_runtime_pm_get(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001108
David Weinehall36cdd012016-08-22 13:59:31 +03001109 if (IS_GEN5(dev_priv)) {
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001110 u16 rgvswctl = I915_READ16(MEMSWCTL);
1111 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
1112
1113 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
1114 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
1115 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
1116 MEMSTAT_VID_SHIFT);
1117 seq_printf(m, "Current P-state: %d\n",
1118 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
David Weinehall36cdd012016-08-22 13:59:31 +03001119 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
Wayne Boyer666a4532015-12-09 12:29:35 -08001120 u32 freq_sts;
1121
1122 mutex_lock(&dev_priv->rps.hw_lock);
1123 freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
1124 seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts);
1125 seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq);
1126
1127 seq_printf(m, "actual GPU freq: %d MHz\n",
1128 intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff));
1129
1130 seq_printf(m, "current GPU freq: %d MHz\n",
1131 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1132
1133 seq_printf(m, "max GPU freq: %d MHz\n",
1134 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1135
1136 seq_printf(m, "min GPU freq: %d MHz\n",
1137 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
1138
1139 seq_printf(m, "idle GPU freq: %d MHz\n",
1140 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
1141
1142 seq_printf(m,
1143 "efficient (RPe) frequency: %d MHz\n",
1144 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
1145 mutex_unlock(&dev_priv->rps.hw_lock);
David Weinehall36cdd012016-08-22 13:59:31 +03001146 } else if (INTEL_GEN(dev_priv) >= 6) {
Bob Paauwe35040562015-06-25 14:54:07 -07001147 u32 rp_state_limits;
1148 u32 gt_perf_status;
1149 u32 rp_state_cap;
Chris Wilson0d8f9492014-03-27 09:06:14 +00001150 u32 rpmodectl, rpinclimit, rpdeclimit;
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001151 u32 rpstat, cagf, reqf;
Jesse Barnesccab5c82011-01-18 15:49:25 -08001152 u32 rpupei, rpcurup, rpprevup;
1153 u32 rpdownei, rpcurdown, rpprevdown;
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001154 u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask;
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001155 int max_freq;
1156
Bob Paauwe35040562015-06-25 14:54:07 -07001157 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
David Weinehall36cdd012016-08-22 13:59:31 +03001158 if (IS_BROXTON(dev_priv)) {
Bob Paauwe35040562015-06-25 14:54:07 -07001159 rp_state_cap = I915_READ(BXT_RP_STATE_CAP);
1160 gt_perf_status = I915_READ(BXT_GT_PERF_STATUS);
1161 } else {
1162 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
1163 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
1164 }
1165
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001166 /* RPSTAT1 is in the GT power well */
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001167 ret = mutex_lock_interruptible(&dev->struct_mutex);
1168 if (ret)
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001169 goto out;
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001170
Mika Kuoppala59bad942015-01-16 11:34:40 +02001171 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001172
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001173 reqf = I915_READ(GEN6_RPNSWREQ);
David Weinehall36cdd012016-08-22 13:59:31 +03001174 if (IS_GEN9(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301175 reqf >>= 23;
1176 else {
1177 reqf &= ~GEN6_TURBO_DISABLE;
David Weinehall36cdd012016-08-22 13:59:31 +03001178 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301179 reqf >>= 24;
1180 else
1181 reqf >>= 25;
1182 }
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001183 reqf = intel_gpu_freq(dev_priv, reqf);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001184
Chris Wilson0d8f9492014-03-27 09:06:14 +00001185 rpmodectl = I915_READ(GEN6_RP_CONTROL);
1186 rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD);
1187 rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD);
1188
Jesse Barnesccab5c82011-01-18 15:49:25 -08001189 rpstat = I915_READ(GEN6_RPSTAT1);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301190 rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK;
1191 rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK;
1192 rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK;
1193 rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK;
1194 rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK;
1195 rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK;
David Weinehall36cdd012016-08-22 13:59:31 +03001196 if (IS_GEN9(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301197 cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT;
David Weinehall36cdd012016-08-22 13:59:31 +03001198 else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Ben Widawskyf82855d2013-01-29 12:00:15 -08001199 cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT;
1200 else
1201 cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT;
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001202 cagf = intel_gpu_freq(dev_priv, cagf);
Jesse Barnesccab5c82011-01-18 15:49:25 -08001203
Mika Kuoppala59bad942015-01-16 11:34:40 +02001204 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001205 mutex_unlock(&dev->struct_mutex);
1206
David Weinehall36cdd012016-08-22 13:59:31 +03001207 if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) {
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001208 pm_ier = I915_READ(GEN6_PMIER);
1209 pm_imr = I915_READ(GEN6_PMIMR);
1210 pm_isr = I915_READ(GEN6_PMISR);
1211 pm_iir = I915_READ(GEN6_PMIIR);
1212 pm_mask = I915_READ(GEN6_PMINTRMSK);
1213 } else {
1214 pm_ier = I915_READ(GEN8_GT_IER(2));
1215 pm_imr = I915_READ(GEN8_GT_IMR(2));
1216 pm_isr = I915_READ(GEN8_GT_ISR(2));
1217 pm_iir = I915_READ(GEN8_GT_IIR(2));
1218 pm_mask = I915_READ(GEN6_PMINTRMSK);
1219 }
Chris Wilson0d8f9492014-03-27 09:06:14 +00001220 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 -03001221 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask);
Sagar Arun Kamble1800ad22016-05-31 13:58:27 +05301222 seq_printf(m, "pm_intr_keep: 0x%08x\n", dev_priv->rps.pm_intr_keep);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001223 seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001224 seq_printf(m, "Render p-state ratio: %d\n",
David Weinehall36cdd012016-08-22 13:59:31 +03001225 (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001226 seq_printf(m, "Render p-state VID: %d\n",
1227 gt_perf_status & 0xff);
1228 seq_printf(m, "Render p-state limit: %d\n",
1229 rp_state_limits & 0xff);
Chris Wilson0d8f9492014-03-27 09:06:14 +00001230 seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
1231 seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl);
1232 seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit);
1233 seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001234 seq_printf(m, "RPNSWREQ: %dMHz\n", reqf);
Ben Widawskyf82855d2013-01-29 12:00:15 -08001235 seq_printf(m, "CAGF: %dMHz\n", cagf);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301236 seq_printf(m, "RP CUR UP EI: %d (%dus)\n",
1237 rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei));
1238 seq_printf(m, "RP CUR UP: %d (%dus)\n",
1239 rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup));
1240 seq_printf(m, "RP PREV UP: %d (%dus)\n",
1241 rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup));
Chris Wilsond86ed342015-04-27 13:41:19 +01001242 seq_printf(m, "Up threshold: %d%%\n",
1243 dev_priv->rps.up_threshold);
1244
Akash Goeld6cda9c2016-04-23 00:05:46 +05301245 seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n",
1246 rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei));
1247 seq_printf(m, "RP CUR DOWN: %d (%dus)\n",
1248 rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown));
1249 seq_printf(m, "RP PREV DOWN: %d (%dus)\n",
1250 rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown));
Chris Wilsond86ed342015-04-27 13:41:19 +01001251 seq_printf(m, "Down threshold: %d%%\n",
1252 dev_priv->rps.down_threshold);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001253
David Weinehall36cdd012016-08-22 13:59:31 +03001254 max_freq = (IS_BROXTON(dev_priv) ? rp_state_cap >> 0 :
Bob Paauwe35040562015-06-25 14:54:07 -07001255 rp_state_cap >> 16) & 0xff;
David Weinehall36cdd012016-08-22 13:59:31 +03001256 max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
Rodrigo Vivief11bdb2015-10-28 04:16:45 -07001257 GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001258 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001259 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001260
1261 max_freq = (rp_state_cap & 0xff00) >> 8;
David Weinehall36cdd012016-08-22 13:59:31 +03001262 max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
Rodrigo Vivief11bdb2015-10-28 04:16:45 -07001263 GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001264 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001265 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001266
David Weinehall36cdd012016-08-22 13:59:31 +03001267 max_freq = (IS_BROXTON(dev_priv) ? rp_state_cap >> 16 :
Bob Paauwe35040562015-06-25 14:54:07 -07001268 rp_state_cap >> 0) & 0xff;
David Weinehall36cdd012016-08-22 13:59:31 +03001269 max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
Rodrigo Vivief11bdb2015-10-28 04:16:45 -07001270 GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001271 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001272 intel_gpu_freq(dev_priv, max_freq));
Ben Widawsky31c77382013-04-05 14:29:22 -07001273 seq_printf(m, "Max overclocked frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001274 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
Chris Wilsonaed242f2015-03-18 09:48:21 +00001275
Chris Wilsond86ed342015-04-27 13:41:19 +01001276 seq_printf(m, "Current freq: %d MHz\n",
1277 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1278 seq_printf(m, "Actual freq: %d MHz\n", cagf);
Chris Wilsonaed242f2015-03-18 09:48:21 +00001279 seq_printf(m, "Idle freq: %d MHz\n",
1280 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001281 seq_printf(m, "Min freq: %d MHz\n",
1282 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
Chris Wilson29ecd78d2016-07-13 09:10:35 +01001283 seq_printf(m, "Boost freq: %d MHz\n",
1284 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001285 seq_printf(m, "Max freq: %d MHz\n",
1286 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1287 seq_printf(m,
1288 "efficient (RPe) frequency: %d MHz\n",
1289 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001290 } else {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001291 seq_puts(m, "no P-state info available\n");
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001292 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001293
Mika Kahola1170f282015-09-25 14:00:32 +03001294 seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq);
1295 seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq);
1296 seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq);
1297
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001298out:
1299 intel_runtime_pm_put(dev_priv);
1300 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001301}
1302
Chris Wilsonf654449a2015-01-26 18:03:04 +02001303static int i915_hangcheck_info(struct seq_file *m, void *unused)
1304{
David Weinehall36cdd012016-08-22 13:59:31 +03001305 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001306 struct intel_engine_cs *engine;
Tvrtko Ursulin666796d2016-03-16 11:00:39 +00001307 u64 acthd[I915_NUM_ENGINES];
1308 u32 seqno[I915_NUM_ENGINES];
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001309 u32 instdone[I915_NUM_INSTDONE_REG];
Dave Gordonc3232b12016-03-23 18:19:53 +00001310 enum intel_engine_id id;
1311 int j;
Chris Wilsonf654449a2015-01-26 18:03:04 +02001312
1313 if (!i915.enable_hangcheck) {
1314 seq_printf(m, "Hangcheck disabled\n");
1315 return 0;
1316 }
1317
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001318 intel_runtime_pm_get(dev_priv);
1319
Dave Gordonc3232b12016-03-23 18:19:53 +00001320 for_each_engine_id(engine, dev_priv, id) {
Chris Wilson7e37f882016-08-02 22:50:21 +01001321 acthd[id] = intel_engine_get_active_head(engine);
Chris Wilson1b7744e2016-07-01 17:23:17 +01001322 seqno[id] = intel_engine_get_seqno(engine);
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001323 }
1324
Chris Wilsonc0336662016-05-06 15:40:21 +01001325 i915_get_extra_instdone(dev_priv, instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001326
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001327 intel_runtime_pm_put(dev_priv);
1328
Chris Wilsonf654449a2015-01-26 18:03:04 +02001329 if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) {
1330 seq_printf(m, "Hangcheck active, fires in %dms\n",
1331 jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires -
1332 jiffies));
1333 } else
1334 seq_printf(m, "Hangcheck inactive\n");
1335
Dave Gordonc3232b12016-03-23 18:19:53 +00001336 for_each_engine_id(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001337 seq_printf(m, "%s:\n", engine->name);
Chris Wilson14fd0d62016-04-07 07:29:10 +01001338 seq_printf(m, "\tseqno = %x [current %x, last %x]\n",
1339 engine->hangcheck.seqno,
1340 seqno[id],
1341 engine->last_submitted_seqno);
Chris Wilson83348ba2016-08-09 17:47:51 +01001342 seq_printf(m, "\twaiters? %s, fake irq active? %s\n",
1343 yesno(intel_engine_has_waiter(engine)),
1344 yesno(test_bit(engine->id,
1345 &dev_priv->gpu_error.missed_irq_rings)));
Chris Wilsonf654449a2015-01-26 18:03:04 +02001346 seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001347 (long long)engine->hangcheck.acthd,
Dave Gordonc3232b12016-03-23 18:19:53 +00001348 (long long)acthd[id]);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001349 seq_printf(m, "\tscore = %d\n", engine->hangcheck.score);
1350 seq_printf(m, "\taction = %d\n", engine->hangcheck.action);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001351
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001352 if (engine->id == RCS) {
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001353 seq_puts(m, "\tinstdone read =");
1354
1355 for (j = 0; j < I915_NUM_INSTDONE_REG; j++)
1356 seq_printf(m, " 0x%08x", instdone[j]);
1357
1358 seq_puts(m, "\n\tinstdone accu =");
1359
1360 for (j = 0; j < I915_NUM_INSTDONE_REG; j++)
1361 seq_printf(m, " 0x%08x",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001362 engine->hangcheck.instdone[j]);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001363
1364 seq_puts(m, "\n");
1365 }
Chris Wilsonf654449a2015-01-26 18:03:04 +02001366 }
1367
1368 return 0;
1369}
1370
Ben Widawsky4d855292011-12-12 19:34:16 -08001371static int ironlake_drpc_info(struct seq_file *m)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001372{
David Weinehall36cdd012016-08-22 13:59:31 +03001373 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1374 struct drm_device *dev = &dev_priv->drm;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001375 u32 rgvmodectl, rstdbyctl;
1376 u16 crstandvid;
1377 int ret;
1378
1379 ret = mutex_lock_interruptible(&dev->struct_mutex);
1380 if (ret)
1381 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001382 intel_runtime_pm_get(dev_priv);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001383
1384 rgvmodectl = I915_READ(MEMMODECTL);
1385 rstdbyctl = I915_READ(RSTDBYCTL);
1386 crstandvid = I915_READ16(CRSTANDVID);
1387
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001388 intel_runtime_pm_put(dev_priv);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001389 mutex_unlock(&dev->struct_mutex);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001390
Jani Nikula742f4912015-09-03 11:16:09 +03001391 seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001392 seq_printf(m, "Boost freq: %d\n",
1393 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
1394 MEMMODE_BOOST_FREQ_SHIFT);
1395 seq_printf(m, "HW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001396 yesno(rgvmodectl & MEMMODE_HWIDLE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001397 seq_printf(m, "SW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001398 yesno(rgvmodectl & MEMMODE_SWMODE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001399 seq_printf(m, "Gated voltage change: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001400 yesno(rgvmodectl & MEMMODE_RCLK_GATE));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001401 seq_printf(m, "Starting frequency: P%d\n",
1402 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001403 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -08001404 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001405 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
1406 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
1407 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
1408 seq_printf(m, "Render standby enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001409 yesno(!(rstdbyctl & RCX_SW_EXIT)));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001410 seq_puts(m, "Current RS state: ");
Jesse Barnes88271da2011-01-05 12:01:24 -08001411 switch (rstdbyctl & RSX_STATUS_MASK) {
1412 case RSX_STATUS_ON:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001413 seq_puts(m, "on\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001414 break;
1415 case RSX_STATUS_RC1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001416 seq_puts(m, "RC1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001417 break;
1418 case RSX_STATUS_RC1E:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001419 seq_puts(m, "RC1E\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001420 break;
1421 case RSX_STATUS_RS1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001422 seq_puts(m, "RS1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001423 break;
1424 case RSX_STATUS_RS2:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001425 seq_puts(m, "RS2 (RC6)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001426 break;
1427 case RSX_STATUS_RS3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001428 seq_puts(m, "RC3 (RC6+)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001429 break;
1430 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001431 seq_puts(m, "unknown\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001432 break;
1433 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001434
1435 return 0;
1436}
1437
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001438static int i915_forcewake_domains(struct seq_file *m, void *data)
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001439{
David Weinehall36cdd012016-08-22 13:59:31 +03001440 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001441 struct intel_uncore_forcewake_domain *fw_domain;
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001442
1443 spin_lock_irq(&dev_priv->uncore.lock);
Tvrtko Ursulin33c582c2016-04-07 17:04:33 +01001444 for_each_fw_domain(fw_domain, dev_priv) {
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001445 seq_printf(m, "%s.wake_count = %u\n",
Tvrtko Ursulin33c582c2016-04-07 17:04:33 +01001446 intel_uncore_forcewake_domain_to_str(fw_domain->id),
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001447 fw_domain->wake_count);
1448 }
1449 spin_unlock_irq(&dev_priv->uncore.lock);
1450
1451 return 0;
1452}
1453
Deepak S669ab5a2014-01-10 15:18:26 +05301454static int vlv_drpc_info(struct seq_file *m)
1455{
David Weinehall36cdd012016-08-22 13:59:31 +03001456 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001457 u32 rpmodectl1, rcctl1, pw_status;
Deepak S669ab5a2014-01-10 15:18:26 +05301458
Imre Deakd46c0512014-04-14 20:24:27 +03001459 intel_runtime_pm_get(dev_priv);
1460
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001461 pw_status = I915_READ(VLV_GTLC_PW_STATUS);
Deepak S669ab5a2014-01-10 15:18:26 +05301462 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1463 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1464
Imre Deakd46c0512014-04-14 20:24:27 +03001465 intel_runtime_pm_put(dev_priv);
1466
Deepak S669ab5a2014-01-10 15:18:26 +05301467 seq_printf(m, "Video Turbo Mode: %s\n",
1468 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1469 seq_printf(m, "Turbo enabled: %s\n",
1470 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1471 seq_printf(m, "HW control enabled: %s\n",
1472 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1473 seq_printf(m, "SW control enabled: %s\n",
1474 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1475 GEN6_RP_MEDIA_SW_MODE));
1476 seq_printf(m, "RC6 Enabled: %s\n",
1477 yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE |
1478 GEN6_RC_CTL_EI_MODE(1))));
1479 seq_printf(m, "Render Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001480 (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301481 seq_printf(m, "Media Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001482 (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301483
Imre Deak9cc19be2014-04-14 20:24:24 +03001484 seq_printf(m, "Render RC6 residency since boot: %u\n",
1485 I915_READ(VLV_GT_RENDER_RC6));
1486 seq_printf(m, "Media RC6 residency since boot: %u\n",
1487 I915_READ(VLV_GT_MEDIA_RC6));
1488
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001489 return i915_forcewake_domains(m, NULL);
Deepak S669ab5a2014-01-10 15:18:26 +05301490}
1491
Ben Widawsky4d855292011-12-12 19:34:16 -08001492static int gen6_drpc_info(struct seq_file *m)
1493{
David Weinehall36cdd012016-08-22 13:59:31 +03001494 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1495 struct drm_device *dev = &dev_priv->drm;
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001496 u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0;
Akash Goelf2dd7572016-06-27 20:10:01 +05301497 u32 gen9_powergate_enable = 0, gen9_powergate_status = 0;
Daniel Vetter93b525d2012-01-25 13:52:43 +01001498 unsigned forcewake_count;
Damien Lespiauaee56cf2013-06-24 22:59:49 +01001499 int count = 0, ret;
Ben Widawsky4d855292011-12-12 19:34:16 -08001500
1501 ret = mutex_lock_interruptible(&dev->struct_mutex);
1502 if (ret)
1503 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001504 intel_runtime_pm_get(dev_priv);
Ben Widawsky4d855292011-12-12 19:34:16 -08001505
Chris Wilson907b28c2013-07-19 20:36:52 +01001506 spin_lock_irq(&dev_priv->uncore.lock);
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001507 forcewake_count = dev_priv->uncore.fw_domain[FW_DOMAIN_ID_RENDER].wake_count;
Chris Wilson907b28c2013-07-19 20:36:52 +01001508 spin_unlock_irq(&dev_priv->uncore.lock);
Daniel Vetter93b525d2012-01-25 13:52:43 +01001509
1510 if (forcewake_count) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001511 seq_puts(m, "RC information inaccurate because somebody "
1512 "holds a forcewake reference \n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001513 } else {
1514 /* NB: we cannot use forcewake, else we read the wrong values */
1515 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
1516 udelay(10);
1517 seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
1518 }
1519
Ville Syrjälä75aa3f62015-10-22 15:34:56 +03001520 gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS);
Chris Wilsoned71f1b2013-07-19 20:36:56 +01001521 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4, true);
Ben Widawsky4d855292011-12-12 19:34:16 -08001522
1523 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1524 rcctl1 = I915_READ(GEN6_RC_CONTROL);
David Weinehall36cdd012016-08-22 13:59:31 +03001525 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301526 gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE);
1527 gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS);
1528 }
Ben Widawsky4d855292011-12-12 19:34:16 -08001529 mutex_unlock(&dev->struct_mutex);
Ben Widawsky44cbd332012-11-06 14:36:36 +00001530 mutex_lock(&dev_priv->rps.hw_lock);
1531 sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
1532 mutex_unlock(&dev_priv->rps.hw_lock);
Ben Widawsky4d855292011-12-12 19:34:16 -08001533
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001534 intel_runtime_pm_put(dev_priv);
1535
Ben Widawsky4d855292011-12-12 19:34:16 -08001536 seq_printf(m, "Video Turbo Mode: %s\n",
1537 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1538 seq_printf(m, "HW control enabled: %s\n",
1539 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1540 seq_printf(m, "SW control enabled: %s\n",
1541 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1542 GEN6_RP_MEDIA_SW_MODE));
Eric Anholtfff24e22012-01-23 16:14:05 -08001543 seq_printf(m, "RC1e Enabled: %s\n",
Ben Widawsky4d855292011-12-12 19:34:16 -08001544 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1545 seq_printf(m, "RC6 Enabled: %s\n",
1546 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
David Weinehall36cdd012016-08-22 13:59:31 +03001547 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301548 seq_printf(m, "Render Well Gating Enabled: %s\n",
1549 yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE));
1550 seq_printf(m, "Media Well Gating Enabled: %s\n",
1551 yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE));
1552 }
Ben Widawsky4d855292011-12-12 19:34:16 -08001553 seq_printf(m, "Deep RC6 Enabled: %s\n",
1554 yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
1555 seq_printf(m, "Deepest RC6 Enabled: %s\n",
1556 yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001557 seq_puts(m, "Current RC state: ");
Ben Widawsky4d855292011-12-12 19:34:16 -08001558 switch (gt_core_status & GEN6_RCn_MASK) {
1559 case GEN6_RC0:
1560 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
Damien Lespiau267f0c92013-06-24 22:59:48 +01001561 seq_puts(m, "Core Power Down\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001562 else
Damien Lespiau267f0c92013-06-24 22:59:48 +01001563 seq_puts(m, "on\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001564 break;
1565 case GEN6_RC3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001566 seq_puts(m, "RC3\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001567 break;
1568 case GEN6_RC6:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001569 seq_puts(m, "RC6\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001570 break;
1571 case GEN6_RC7:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001572 seq_puts(m, "RC7\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001573 break;
1574 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001575 seq_puts(m, "Unknown\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001576 break;
1577 }
1578
1579 seq_printf(m, "Core Power Down: %s\n",
1580 yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
David Weinehall36cdd012016-08-22 13:59:31 +03001581 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301582 seq_printf(m, "Render Power Well: %s\n",
1583 (gen9_powergate_status &
1584 GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down");
1585 seq_printf(m, "Media Power Well: %s\n",
1586 (gen9_powergate_status &
1587 GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down");
1588 }
Ben Widawskycce66a22012-03-27 18:59:38 -07001589
1590 /* Not exactly sure what this is */
1591 seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1592 I915_READ(GEN6_GT_GFX_RC6_LOCKED));
1593 seq_printf(m, "RC6 residency since boot: %u\n",
1594 I915_READ(GEN6_GT_GFX_RC6));
1595 seq_printf(m, "RC6+ residency since boot: %u\n",
1596 I915_READ(GEN6_GT_GFX_RC6p));
1597 seq_printf(m, "RC6++ residency since boot: %u\n",
1598 I915_READ(GEN6_GT_GFX_RC6pp));
1599
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001600 seq_printf(m, "RC6 voltage: %dmV\n",
1601 GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff)));
1602 seq_printf(m, "RC6+ voltage: %dmV\n",
1603 GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff)));
1604 seq_printf(m, "RC6++ voltage: %dmV\n",
1605 GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff)));
Akash Goelf2dd7572016-06-27 20:10:01 +05301606 return i915_forcewake_domains(m, NULL);
Ben Widawsky4d855292011-12-12 19:34:16 -08001607}
1608
1609static int i915_drpc_info(struct seq_file *m, void *unused)
1610{
David Weinehall36cdd012016-08-22 13:59:31 +03001611 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ben Widawsky4d855292011-12-12 19:34:16 -08001612
David Weinehall36cdd012016-08-22 13:59:31 +03001613 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Deepak S669ab5a2014-01-10 15:18:26 +05301614 return vlv_drpc_info(m);
David Weinehall36cdd012016-08-22 13:59:31 +03001615 else if (INTEL_GEN(dev_priv) >= 6)
Ben Widawsky4d855292011-12-12 19:34:16 -08001616 return gen6_drpc_info(m);
1617 else
1618 return ironlake_drpc_info(m);
1619}
1620
Daniel Vetter9a851782015-06-18 10:30:22 +02001621static int i915_frontbuffer_tracking(struct seq_file *m, void *unused)
1622{
David Weinehall36cdd012016-08-22 13:59:31 +03001623 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetter9a851782015-06-18 10:30:22 +02001624
1625 seq_printf(m, "FB tracking busy bits: 0x%08x\n",
1626 dev_priv->fb_tracking.busy_bits);
1627
1628 seq_printf(m, "FB tracking flip bits: 0x%08x\n",
1629 dev_priv->fb_tracking.flip_bits);
1630
1631 return 0;
1632}
1633
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001634static int i915_fbc_status(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);
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001637
David Weinehall36cdd012016-08-22 13:59:31 +03001638 if (!HAS_FBC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001639 seq_puts(m, "FBC unsupported on this chipset\n");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001640 return 0;
1641 }
1642
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001643 intel_runtime_pm_get(dev_priv);
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001644 mutex_lock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001645
Paulo Zanoni0e631ad2015-10-14 17:45:36 -03001646 if (intel_fbc_is_active(dev_priv))
Damien Lespiau267f0c92013-06-24 22:59:48 +01001647 seq_puts(m, "FBC enabled\n");
Paulo Zanoni2e8144a2015-06-12 14:36:20 -03001648 else
1649 seq_printf(m, "FBC disabled: %s\n",
Paulo Zanonibf6189c2015-10-27 14:50:03 -02001650 dev_priv->fbc.no_fbc_reason);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001651
David Weinehall36cdd012016-08-22 13:59:31 +03001652 if (INTEL_GEN(dev_priv) >= 7)
Paulo Zanoni31b9df12015-06-12 14:36:18 -03001653 seq_printf(m, "Compressing: %s\n",
1654 yesno(I915_READ(FBC_STATUS2) &
1655 FBC_COMPRESSION_MASK));
1656
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001657 mutex_unlock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001658 intel_runtime_pm_put(dev_priv);
1659
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001660 return 0;
1661}
1662
Rodrigo Vivida46f932014-08-01 02:04:45 -07001663static int i915_fbc_fc_get(void *data, u64 *val)
1664{
David Weinehall36cdd012016-08-22 13:59:31 +03001665 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001666
David Weinehall36cdd012016-08-22 13:59:31 +03001667 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001668 return -ENODEV;
1669
Rodrigo Vivida46f932014-08-01 02:04:45 -07001670 *val = dev_priv->fbc.false_color;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001671
1672 return 0;
1673}
1674
1675static int i915_fbc_fc_set(void *data, u64 val)
1676{
David Weinehall36cdd012016-08-22 13:59:31 +03001677 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001678 u32 reg;
1679
David Weinehall36cdd012016-08-22 13:59:31 +03001680 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001681 return -ENODEV;
1682
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001683 mutex_lock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001684
1685 reg = I915_READ(ILK_DPFC_CONTROL);
1686 dev_priv->fbc.false_color = val;
1687
1688 I915_WRITE(ILK_DPFC_CONTROL, val ?
1689 (reg | FBC_CTL_FALSE_COLOR) :
1690 (reg & ~FBC_CTL_FALSE_COLOR));
1691
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001692 mutex_unlock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001693 return 0;
1694}
1695
1696DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops,
1697 i915_fbc_fc_get, i915_fbc_fc_set,
1698 "%llu\n");
1699
Paulo Zanoni92d44622013-05-31 16:33:24 -03001700static int i915_ips_status(struct seq_file *m, void *unused)
1701{
David Weinehall36cdd012016-08-22 13:59:31 +03001702 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni92d44622013-05-31 16:33:24 -03001703
David Weinehall36cdd012016-08-22 13:59:31 +03001704 if (!HAS_IPS(dev_priv)) {
Paulo Zanoni92d44622013-05-31 16:33:24 -03001705 seq_puts(m, "not supported\n");
1706 return 0;
1707 }
1708
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001709 intel_runtime_pm_get(dev_priv);
1710
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001711 seq_printf(m, "Enabled by kernel parameter: %s\n",
1712 yesno(i915.enable_ips));
1713
David Weinehall36cdd012016-08-22 13:59:31 +03001714 if (INTEL_GEN(dev_priv) >= 8) {
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001715 seq_puts(m, "Currently: unknown\n");
1716 } else {
1717 if (I915_READ(IPS_CTL) & IPS_ENABLE)
1718 seq_puts(m, "Currently: enabled\n");
1719 else
1720 seq_puts(m, "Currently: disabled\n");
1721 }
Paulo Zanoni92d44622013-05-31 16:33:24 -03001722
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001723 intel_runtime_pm_put(dev_priv);
1724
Paulo Zanoni92d44622013-05-31 16:33:24 -03001725 return 0;
1726}
1727
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001728static int i915_sr_status(struct seq_file *m, void *unused)
1729{
David Weinehall36cdd012016-08-22 13:59:31 +03001730 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001731 bool sr_enabled = false;
1732
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001733 intel_runtime_pm_get(dev_priv);
1734
David Weinehall36cdd012016-08-22 13:59:31 +03001735 if (HAS_PCH_SPLIT(dev_priv))
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001736 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001737 else if (IS_CRESTLINE(dev_priv) || IS_G4X(dev_priv) ||
1738 IS_I945G(dev_priv) || IS_I945GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001739 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001740 else if (IS_I915GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001741 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001742 else if (IS_PINEVIEW(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001743 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001744 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Ander Conselvan de Oliveira77b64552015-06-02 14:17:47 +03001745 sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001746
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001747 intel_runtime_pm_put(dev_priv);
1748
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001749 seq_printf(m, "self-refresh: %s\n",
1750 sr_enabled ? "enabled" : "disabled");
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001751
1752 return 0;
1753}
1754
Jesse Barnes7648fa92010-05-20 14:28:11 -07001755static int i915_emon_status(struct seq_file *m, void *unused)
1756{
David Weinehall36cdd012016-08-22 13:59:31 +03001757 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1758 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001759 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +01001760 int ret;
1761
David Weinehall36cdd012016-08-22 13:59:31 +03001762 if (!IS_GEN5(dev_priv))
Chris Wilson582be6b2012-04-30 19:35:02 +01001763 return -ENODEV;
1764
Chris Wilsonde227ef2010-07-03 07:58:38 +01001765 ret = mutex_lock_interruptible(&dev->struct_mutex);
1766 if (ret)
1767 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001768
1769 temp = i915_mch_val(dev_priv);
1770 chipset = i915_chipset_val(dev_priv);
1771 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +01001772 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001773
1774 seq_printf(m, "GMCH temp: %ld\n", temp);
1775 seq_printf(m, "Chipset power: %ld\n", chipset);
1776 seq_printf(m, "GFX power: %ld\n", gfx);
1777 seq_printf(m, "Total power: %ld\n", chipset + gfx);
1778
1779 return 0;
1780}
1781
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001782static int i915_ring_freq_table(struct seq_file *m, void *unused)
1783{
David Weinehall36cdd012016-08-22 13:59:31 +03001784 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001785 int ret = 0;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001786 int gpu_freq, ia_freq;
Akash Goelf936ec32015-06-29 14:50:22 +05301787 unsigned int max_gpu_freq, min_gpu_freq;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001788
David Weinehall36cdd012016-08-22 13:59:31 +03001789 if (!HAS_CORE_RING_FREQ(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001790 seq_puts(m, "unsupported on this chipset\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001791 return 0;
1792 }
1793
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001794 intel_runtime_pm_get(dev_priv);
1795
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001796 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001797 if (ret)
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001798 goto out;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001799
David Weinehall36cdd012016-08-22 13:59:31 +03001800 if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
Akash Goelf936ec32015-06-29 14:50:22 +05301801 /* Convert GT frequency to 50 HZ units */
1802 min_gpu_freq =
1803 dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER;
1804 max_gpu_freq =
1805 dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER;
1806 } else {
1807 min_gpu_freq = dev_priv->rps.min_freq_softlimit;
1808 max_gpu_freq = dev_priv->rps.max_freq_softlimit;
1809 }
1810
Damien Lespiau267f0c92013-06-24 22:59:48 +01001811 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001812
Akash Goelf936ec32015-06-29 14:50:22 +05301813 for (gpu_freq = min_gpu_freq; gpu_freq <= max_gpu_freq; gpu_freq++) {
Ben Widawsky42c05262012-09-26 10:34:00 -07001814 ia_freq = gpu_freq;
1815 sandybridge_pcode_read(dev_priv,
1816 GEN6_PCODE_READ_MIN_FREQ_TABLE,
1817 &ia_freq);
Chris Wilson3ebecd02013-04-12 19:10:13 +01001818 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n",
Akash Goelf936ec32015-06-29 14:50:22 +05301819 intel_gpu_freq(dev_priv, (gpu_freq *
David Weinehall36cdd012016-08-22 13:59:31 +03001820 (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ?
Rodrigo Vivief11bdb2015-10-28 04:16:45 -07001821 GEN9_FREQ_SCALER : 1))),
Chris Wilson3ebecd02013-04-12 19:10:13 +01001822 ((ia_freq >> 0) & 0xff) * 100,
1823 ((ia_freq >> 8) & 0xff) * 100);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001824 }
1825
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001826 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001827
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001828out:
1829 intel_runtime_pm_put(dev_priv);
1830 return ret;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001831}
1832
Chris Wilson44834a62010-08-19 16:09:23 +01001833static int i915_opregion(struct seq_file *m, void *unused)
1834{
David Weinehall36cdd012016-08-22 13:59:31 +03001835 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1836 struct drm_device *dev = &dev_priv->drm;
Chris Wilson44834a62010-08-19 16:09:23 +01001837 struct intel_opregion *opregion = &dev_priv->opregion;
1838 int ret;
1839
1840 ret = mutex_lock_interruptible(&dev->struct_mutex);
1841 if (ret)
Daniel Vetter0d38f002012-04-21 22:49:10 +02001842 goto out;
Chris Wilson44834a62010-08-19 16:09:23 +01001843
Jani Nikula2455a8e2015-12-14 12:50:53 +02001844 if (opregion->header)
1845 seq_write(m, opregion->header, OPREGION_SIZE);
Chris Wilson44834a62010-08-19 16:09:23 +01001846
1847 mutex_unlock(&dev->struct_mutex);
1848
Daniel Vetter0d38f002012-04-21 22:49:10 +02001849out:
Chris Wilson44834a62010-08-19 16:09:23 +01001850 return 0;
1851}
1852
Jani Nikulaada8f952015-12-15 13:17:12 +02001853static int i915_vbt(struct seq_file *m, void *unused)
1854{
David Weinehall36cdd012016-08-22 13:59:31 +03001855 struct intel_opregion *opregion = &node_to_i915(m->private)->opregion;
Jani Nikulaada8f952015-12-15 13:17:12 +02001856
1857 if (opregion->vbt)
1858 seq_write(m, opregion->vbt, opregion->vbt_size);
1859
1860 return 0;
1861}
1862
Chris Wilson37811fc2010-08-25 22:45:57 +01001863static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
1864{
David Weinehall36cdd012016-08-22 13:59:31 +03001865 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1866 struct drm_device *dev = &dev_priv->drm;
Namrta Salonieb13b8402015-11-27 13:43:11 +05301867 struct intel_framebuffer *fbdev_fb = NULL;
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001868 struct drm_framebuffer *drm_fb;
Chris Wilson188c1ab2016-04-03 14:14:20 +01001869 int ret;
1870
1871 ret = mutex_lock_interruptible(&dev->struct_mutex);
1872 if (ret)
1873 return ret;
Chris Wilson37811fc2010-08-25 22:45:57 +01001874
Daniel Vetter06957262015-08-10 13:34:08 +02001875#ifdef CONFIG_DRM_FBDEV_EMULATION
David Weinehall36cdd012016-08-22 13:59:31 +03001876 if (dev_priv->fbdev) {
1877 fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb);
Chris Wilson37811fc2010-08-25 22:45:57 +01001878
Chris Wilson25bcce92016-07-02 15:36:00 +01001879 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
1880 fbdev_fb->base.width,
1881 fbdev_fb->base.height,
1882 fbdev_fb->base.depth,
1883 fbdev_fb->base.bits_per_pixel,
1884 fbdev_fb->base.modifier[0],
1885 drm_framebuffer_read_refcount(&fbdev_fb->base));
1886 describe_obj(m, fbdev_fb->obj);
1887 seq_putc(m, '\n');
1888 }
Daniel Vetter4520f532013-10-09 09:18:51 +02001889#endif
Chris Wilson37811fc2010-08-25 22:45:57 +01001890
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001891 mutex_lock(&dev->mode_config.fb_lock);
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001892 drm_for_each_fb(drm_fb, dev) {
Namrta Salonieb13b8402015-11-27 13:43:11 +05301893 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
1894 if (fb == fbdev_fb)
Chris Wilson37811fc2010-08-25 22:45:57 +01001895 continue;
1896
Tvrtko Ursulinc1ca5062015-02-10 17:16:07 +00001897 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 +01001898 fb->base.width,
1899 fb->base.height,
1900 fb->base.depth,
Daniel Vetter623f9782012-12-11 16:21:38 +01001901 fb->base.bits_per_pixel,
Tvrtko Ursulinc1ca5062015-02-10 17:16:07 +00001902 fb->base.modifier[0],
Dave Airlie747a5982016-04-15 15:10:35 +10001903 drm_framebuffer_read_refcount(&fb->base));
Chris Wilson05394f32010-11-08 19:18:58 +00001904 describe_obj(m, fb->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001905 seq_putc(m, '\n');
Chris Wilson37811fc2010-08-25 22:45:57 +01001906 }
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001907 mutex_unlock(&dev->mode_config.fb_lock);
Chris Wilson188c1ab2016-04-03 14:14:20 +01001908 mutex_unlock(&dev->struct_mutex);
Chris Wilson37811fc2010-08-25 22:45:57 +01001909
1910 return 0;
1911}
1912
Chris Wilson7e37f882016-08-02 22:50:21 +01001913static void describe_ctx_ring(struct seq_file *m, struct intel_ring *ring)
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001914{
1915 seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)",
Chris Wilson7e37f882016-08-02 22:50:21 +01001916 ring->space, ring->head, ring->tail,
1917 ring->last_retired_head);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001918}
1919
Ben Widawskye76d3632011-03-19 18:14:29 -07001920static int i915_context_status(struct seq_file *m, void *unused)
1921{
David Weinehall36cdd012016-08-22 13:59:31 +03001922 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1923 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001924 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01001925 struct i915_gem_context *ctx;
Dave Gordonc3232b12016-03-23 18:19:53 +00001926 int ret;
Ben Widawskye76d3632011-03-19 18:14:29 -07001927
Daniel Vetterf3d28872014-05-29 23:23:08 +02001928 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07001929 if (ret)
1930 return ret;
1931
Ben Widawskya33afea2013-09-17 21:12:45 -07001932 list_for_each_entry(ctx, &dev_priv->context_list, link) {
Chris Wilson5d1808e2016-04-28 09:56:51 +01001933 seq_printf(m, "HW context %u ", ctx->hw_id);
Chris Wilsonc84455b2016-08-15 10:49:08 +01001934 if (ctx->pid) {
Chris Wilsond28b99a2016-05-24 14:53:39 +01001935 struct task_struct *task;
1936
Chris Wilsonc84455b2016-08-15 10:49:08 +01001937 task = get_pid_task(ctx->pid, PIDTYPE_PID);
Chris Wilsond28b99a2016-05-24 14:53:39 +01001938 if (task) {
1939 seq_printf(m, "(%s [%d]) ",
1940 task->comm, task->pid);
1941 put_task_struct(task);
1942 }
Chris Wilsonc84455b2016-08-15 10:49:08 +01001943 } else if (IS_ERR(ctx->file_priv)) {
1944 seq_puts(m, "(deleted) ");
Chris Wilsond28b99a2016-05-24 14:53:39 +01001945 } else {
1946 seq_puts(m, "(kernel) ");
1947 }
1948
Chris Wilsonbca44d82016-05-24 14:53:41 +01001949 seq_putc(m, ctx->remap_slice ? 'R' : 'r');
1950 seq_putc(m, '\n');
Ben Widawskya33afea2013-09-17 21:12:45 -07001951
Chris Wilsonbca44d82016-05-24 14:53:41 +01001952 for_each_engine(engine, dev_priv) {
1953 struct intel_context *ce = &ctx->engine[engine->id];
1954
1955 seq_printf(m, "%s: ", engine->name);
1956 seq_putc(m, ce->initialised ? 'I' : 'i');
1957 if (ce->state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001958 describe_obj(m, ce->state->obj);
Chris Wilsondca33ec2016-08-02 22:50:20 +01001959 if (ce->ring)
Chris Wilson7e37f882016-08-02 22:50:21 +01001960 describe_ctx_ring(m, ce->ring);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001961 seq_putc(m, '\n');
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001962 }
1963
Ben Widawskya33afea2013-09-17 21:12:45 -07001964 seq_putc(m, '\n');
Ben Widawskya168c292013-02-14 15:05:12 -08001965 }
1966
Daniel Vetterf3d28872014-05-29 23:23:08 +02001967 mutex_unlock(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07001968
1969 return 0;
1970}
1971
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001972static void i915_dump_lrc_obj(struct seq_file *m,
Chris Wilsone2efd132016-05-24 14:53:34 +01001973 struct i915_gem_context *ctx,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +00001974 struct intel_engine_cs *engine)
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001975{
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001976 struct i915_vma *vma = ctx->engine[engine->id].state;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001977 struct page *page;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001978 int j;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001979
Chris Wilson7069b142016-04-28 09:56:52 +01001980 seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id);
1981
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001982 if (!vma) {
1983 seq_puts(m, "\tFake context\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001984 return;
1985 }
1986
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001987 if (vma->flags & I915_VMA_GLOBAL_BIND)
1988 seq_printf(m, "\tBound in GGTT at 0x%08x\n",
Chris Wilsonbde13eb2016-08-15 10:49:07 +01001989 i915_ggtt_offset(vma));
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001990
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001991 if (i915_gem_object_get_pages(vma->obj)) {
1992 seq_puts(m, "\tFailed to get pages for context object\n\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001993 return;
1994 }
1995
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001996 page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN);
1997 if (page) {
1998 u32 *reg_state = kmap_atomic(page);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001999
2000 for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002001 seq_printf(m,
2002 "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n",
2003 j * 4,
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002004 reg_state[j], reg_state[j + 1],
2005 reg_state[j + 2], reg_state[j + 3]);
2006 }
2007 kunmap_atomic(reg_state);
2008 }
2009
2010 seq_putc(m, '\n');
2011}
2012
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01002013static int i915_dump_lrc(struct seq_file *m, void *unused)
2014{
David Weinehall36cdd012016-08-22 13:59:31 +03002015 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2016 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002017 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01002018 struct i915_gem_context *ctx;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002019 int ret;
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01002020
2021 if (!i915.enable_execlists) {
2022 seq_printf(m, "Logical Ring Contexts are disabled\n");
2023 return 0;
2024 }
2025
2026 ret = mutex_lock_interruptible(&dev->struct_mutex);
2027 if (ret)
2028 return ret;
2029
Dave Gordone28e4042016-01-19 19:02:55 +00002030 list_for_each_entry(ctx, &dev_priv->context_list, link)
Chris Wilson24f1d3cc2016-04-28 09:56:53 +01002031 for_each_engine(engine, dev_priv)
2032 i915_dump_lrc_obj(m, ctx, engine);
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01002033
2034 mutex_unlock(&dev->struct_mutex);
2035
2036 return 0;
2037}
2038
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002039static int i915_execlists(struct seq_file *m, void *data)
2040{
David Weinehall36cdd012016-08-22 13:59:31 +03002041 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2042 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002043 struct intel_engine_cs *engine;
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002044 u32 status_pointer;
2045 u8 read_pointer;
2046 u8 write_pointer;
2047 u32 status;
2048 u32 ctx_id;
2049 struct list_head *cursor;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002050 int i, ret;
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002051
2052 if (!i915.enable_execlists) {
2053 seq_puts(m, "Logical Ring Contexts are disabled\n");
2054 return 0;
2055 }
2056
2057 ret = mutex_lock_interruptible(&dev->struct_mutex);
2058 if (ret)
2059 return ret;
2060
Michel Thierryfc0412e2014-10-16 16:13:38 +01002061 intel_runtime_pm_get(dev_priv);
2062
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002063 for_each_engine(engine, dev_priv) {
Nick Hoath6d3d8272015-01-15 13:10:39 +00002064 struct drm_i915_gem_request *head_req = NULL;
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002065 int count = 0;
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002066
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002067 seq_printf(m, "%s\n", engine->name);
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002068
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002069 status = I915_READ(RING_EXECLIST_STATUS_LO(engine));
2070 ctx_id = I915_READ(RING_EXECLIST_STATUS_HI(engine));
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002071 seq_printf(m, "\tExeclist status: 0x%08X, context: %u\n",
2072 status, ctx_id);
2073
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002074 status_pointer = I915_READ(RING_CONTEXT_STATUS_PTR(engine));
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002075 seq_printf(m, "\tStatus pointer: 0x%08X\n", status_pointer);
2076
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002077 read_pointer = engine->next_context_status_buffer;
Ben Widawsky5590a5f2016-01-05 10:30:05 -08002078 write_pointer = GEN8_CSB_WRITE_PTR(status_pointer);
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002079 if (read_pointer > write_pointer)
Ben Widawsky5590a5f2016-01-05 10:30:05 -08002080 write_pointer += GEN8_CSB_ENTRIES;
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002081 seq_printf(m, "\tRead pointer: 0x%08X, write pointer 0x%08X\n",
2082 read_pointer, write_pointer);
2083
Ben Widawsky5590a5f2016-01-05 10:30:05 -08002084 for (i = 0; i < GEN8_CSB_ENTRIES; i++) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002085 status = I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, i));
2086 ctx_id = I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, i));
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002087
2088 seq_printf(m, "\tStatus buffer %d: 0x%08X, context: %u\n",
2089 i, status, ctx_id);
2090 }
2091
Tvrtko Ursulin27af5ee2016-04-04 12:11:56 +01002092 spin_lock_bh(&engine->execlist_lock);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002093 list_for_each(cursor, &engine->execlist_queue)
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002094 count++;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002095 head_req = list_first_entry_or_null(&engine->execlist_queue,
2096 struct drm_i915_gem_request,
2097 execlist_link);
Tvrtko Ursulin27af5ee2016-04-04 12:11:56 +01002098 spin_unlock_bh(&engine->execlist_lock);
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002099
2100 seq_printf(m, "\t%d requests in queue\n", count);
2101 if (head_req) {
Chris Wilson7069b142016-04-28 09:56:52 +01002102 seq_printf(m, "\tHead request context: %u\n",
2103 head_req->ctx->hw_id);
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002104 seq_printf(m, "\tHead request tail: %u\n",
Nick Hoath6d3d8272015-01-15 13:10:39 +00002105 head_req->tail);
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002106 }
2107
2108 seq_putc(m, '\n');
2109 }
2110
Michel Thierryfc0412e2014-10-16 16:13:38 +01002111 intel_runtime_pm_put(dev_priv);
Oscar Mateo4ba70e42014-08-07 13:23:20 +01002112 mutex_unlock(&dev->struct_mutex);
2113
2114 return 0;
2115}
2116
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002117static const char *swizzle_string(unsigned swizzle)
2118{
Damien Lespiauaee56cf2013-06-24 22:59:49 +01002119 switch (swizzle) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002120 case I915_BIT_6_SWIZZLE_NONE:
2121 return "none";
2122 case I915_BIT_6_SWIZZLE_9:
2123 return "bit9";
2124 case I915_BIT_6_SWIZZLE_9_10:
2125 return "bit9/bit10";
2126 case I915_BIT_6_SWIZZLE_9_11:
2127 return "bit9/bit11";
2128 case I915_BIT_6_SWIZZLE_9_10_11:
2129 return "bit9/bit10/bit11";
2130 case I915_BIT_6_SWIZZLE_9_17:
2131 return "bit9/bit17";
2132 case I915_BIT_6_SWIZZLE_9_10_17:
2133 return "bit9/bit10/bit17";
2134 case I915_BIT_6_SWIZZLE_UNKNOWN:
Masanari Iida8a168ca2012-12-29 02:00:09 +09002135 return "unknown";
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002136 }
2137
2138 return "bug";
2139}
2140
2141static int i915_swizzle_info(struct seq_file *m, void *data)
2142{
David Weinehall36cdd012016-08-22 13:59:31 +03002143 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2144 struct drm_device *dev = &dev_priv->drm;
Daniel Vetter22bcfc62012-08-09 15:07:02 +02002145 int ret;
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002146
Daniel Vetter22bcfc62012-08-09 15:07:02 +02002147 ret = mutex_lock_interruptible(&dev->struct_mutex);
2148 if (ret)
2149 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002150 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02002151
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002152 seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
2153 swizzle_string(dev_priv->mm.bit_6_swizzle_x));
2154 seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
2155 swizzle_string(dev_priv->mm.bit_6_swizzle_y));
2156
David Weinehall36cdd012016-08-22 13:59:31 +03002157 if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002158 seq_printf(m, "DDC = 0x%08x\n",
2159 I915_READ(DCC));
Daniel Vetter656bfa32014-11-20 09:26:30 +01002160 seq_printf(m, "DDC2 = 0x%08x\n",
2161 I915_READ(DCC2));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002162 seq_printf(m, "C0DRB3 = 0x%04x\n",
2163 I915_READ16(C0DRB3));
2164 seq_printf(m, "C1DRB3 = 0x%04x\n",
2165 I915_READ16(C1DRB3));
David Weinehall36cdd012016-08-22 13:59:31 +03002166 } else if (INTEL_GEN(dev_priv) >= 6) {
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002167 seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
2168 I915_READ(MAD_DIMM_C0));
2169 seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
2170 I915_READ(MAD_DIMM_C1));
2171 seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
2172 I915_READ(MAD_DIMM_C2));
2173 seq_printf(m, "TILECTL = 0x%08x\n",
2174 I915_READ(TILECTL));
David Weinehall36cdd012016-08-22 13:59:31 +03002175 if (INTEL_GEN(dev_priv) >= 8)
Ben Widawsky9d3203e2013-11-02 21:07:14 -07002176 seq_printf(m, "GAMTARBMODE = 0x%08x\n",
2177 I915_READ(GAMTARBMODE));
2178 else
2179 seq_printf(m, "ARB_MODE = 0x%08x\n",
2180 I915_READ(ARB_MODE));
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002181 seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
2182 I915_READ(DISP_ARB_CTL));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002183 }
Daniel Vetter656bfa32014-11-20 09:26:30 +01002184
2185 if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES)
2186 seq_puts(m, "L-shaped memory detected\n");
2187
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002188 intel_runtime_pm_put(dev_priv);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002189 mutex_unlock(&dev->struct_mutex);
2190
2191 return 0;
2192}
2193
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002194static int per_file_ctx(int id, void *ptr, void *data)
2195{
Chris Wilsone2efd132016-05-24 14:53:34 +01002196 struct i915_gem_context *ctx = ptr;
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002197 struct seq_file *m = data;
Daniel Vetterae6c4802014-08-06 15:04:53 +02002198 struct i915_hw_ppgtt *ppgtt = ctx->ppgtt;
2199
2200 if (!ppgtt) {
2201 seq_printf(m, " no ppgtt for context %d\n",
2202 ctx->user_handle);
2203 return 0;
2204 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002205
Oscar Mateof83d6512014-05-22 14:13:38 +01002206 if (i915_gem_context_is_default(ctx))
2207 seq_puts(m, " default context:\n");
2208 else
Oscar Mateo821d66d2014-07-03 16:28:00 +01002209 seq_printf(m, " context %d:\n", ctx->user_handle);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002210 ppgtt->debug_dump(ppgtt, m);
2211
2212 return 0;
2213}
2214
David Weinehall36cdd012016-08-22 13:59:31 +03002215static void gen8_ppgtt_info(struct seq_file *m,
2216 struct drm_i915_private *dev_priv)
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002217{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002218 struct intel_engine_cs *engine;
Ben Widawsky77df6772013-11-02 21:07:30 -07002219 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002220 int i;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002221
Ben Widawsky77df6772013-11-02 21:07:30 -07002222 if (!ppgtt)
2223 return;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002224
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002225 for_each_engine(engine, dev_priv) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002226 seq_printf(m, "%s\n", engine->name);
Ben Widawsky77df6772013-11-02 21:07:30 -07002227 for (i = 0; i < 4; i++) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002228 u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i));
Ben Widawsky77df6772013-11-02 21:07:30 -07002229 pdp <<= 32;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002230 pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i));
Ville Syrjäläa2a5b152014-03-31 18:17:16 +03002231 seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp);
Ben Widawsky77df6772013-11-02 21:07:30 -07002232 }
2233 }
2234}
2235
David Weinehall36cdd012016-08-22 13:59:31 +03002236static void gen6_ppgtt_info(struct seq_file *m,
2237 struct drm_i915_private *dev_priv)
Ben Widawsky77df6772013-11-02 21:07:30 -07002238{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002239 struct intel_engine_cs *engine;
Ben Widawsky77df6772013-11-02 21:07:30 -07002240
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002241 if (IS_GEN6(dev_priv))
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002242 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
2243
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002244 for_each_engine(engine, dev_priv) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002245 seq_printf(m, "%s\n", engine->name);
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002246 if (IS_GEN7(dev_priv))
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002247 seq_printf(m, "GFX_MODE: 0x%08x\n",
2248 I915_READ(RING_MODE_GEN7(engine)));
2249 seq_printf(m, "PP_DIR_BASE: 0x%08x\n",
2250 I915_READ(RING_PP_DIR_BASE(engine)));
2251 seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n",
2252 I915_READ(RING_PP_DIR_BASE_READ(engine)));
2253 seq_printf(m, "PP_DIR_DCLV: 0x%08x\n",
2254 I915_READ(RING_PP_DIR_DCLV(engine)));
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002255 }
2256 if (dev_priv->mm.aliasing_ppgtt) {
2257 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
2258
Damien Lespiau267f0c92013-06-24 22:59:48 +01002259 seq_puts(m, "aliasing PPGTT:\n");
Mika Kuoppala44159dd2015-06-25 18:35:07 +03002260 seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd.base.ggtt_offset);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002261
Ben Widawsky87d60b62013-12-06 14:11:29 -08002262 ppgtt->debug_dump(ppgtt, m);
Daniel Vetterae6c4802014-08-06 15:04:53 +02002263 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002264
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002265 seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
Ben Widawsky77df6772013-11-02 21:07:30 -07002266}
2267
2268static int i915_ppgtt_info(struct seq_file *m, void *data)
2269{
David Weinehall36cdd012016-08-22 13:59:31 +03002270 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2271 struct drm_device *dev = &dev_priv->drm;
Michel Thierryea91e402015-07-29 17:23:57 +01002272 struct drm_file *file;
Chris Wilson637ee292016-08-22 14:28:20 +01002273 int ret;
Ben Widawsky77df6772013-11-02 21:07:30 -07002274
Chris Wilson637ee292016-08-22 14:28:20 +01002275 mutex_lock(&dev->filelist_mutex);
2276 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawsky77df6772013-11-02 21:07:30 -07002277 if (ret)
Chris Wilson637ee292016-08-22 14:28:20 +01002278 goto out_unlock;
2279
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002280 intel_runtime_pm_get(dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002281
David Weinehall36cdd012016-08-22 13:59:31 +03002282 if (INTEL_GEN(dev_priv) >= 8)
2283 gen8_ppgtt_info(m, dev_priv);
2284 else if (INTEL_GEN(dev_priv) >= 6)
2285 gen6_ppgtt_info(m, dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002286
Michel Thierryea91e402015-07-29 17:23:57 +01002287 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2288 struct drm_i915_file_private *file_priv = file->driver_priv;
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002289 struct task_struct *task;
Michel Thierryea91e402015-07-29 17:23:57 +01002290
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002291 task = get_pid_task(file->pid, PIDTYPE_PID);
Dan Carpenter06812762015-10-02 18:14:22 +03002292 if (!task) {
2293 ret = -ESRCH;
Chris Wilson637ee292016-08-22 14:28:20 +01002294 goto out_rpm;
Dan Carpenter06812762015-10-02 18:14:22 +03002295 }
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002296 seq_printf(m, "\nproc: %s\n", task->comm);
2297 put_task_struct(task);
Michel Thierryea91e402015-07-29 17:23:57 +01002298 idr_for_each(&file_priv->context_idr, per_file_ctx,
2299 (void *)(unsigned long)m);
2300 }
2301
Chris Wilson637ee292016-08-22 14:28:20 +01002302out_rpm:
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002303 intel_runtime_pm_put(dev_priv);
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002304 mutex_unlock(&dev->struct_mutex);
Chris Wilson637ee292016-08-22 14:28:20 +01002305out_unlock:
2306 mutex_unlock(&dev->filelist_mutex);
Dan Carpenter06812762015-10-02 18:14:22 +03002307 return ret;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002308}
2309
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002310static int count_irq_waiters(struct drm_i915_private *i915)
2311{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002312 struct intel_engine_cs *engine;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002313 int count = 0;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002314
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002315 for_each_engine(engine, i915)
Chris Wilson688e6c72016-07-01 17:23:15 +01002316 count += intel_engine_has_waiter(engine);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002317
2318 return count;
2319}
2320
Chris Wilson7466c292016-08-15 09:49:33 +01002321static const char *rps_power_to_str(unsigned int power)
2322{
2323 static const char * const strings[] = {
2324 [LOW_POWER] = "low power",
2325 [BETWEEN] = "mixed",
2326 [HIGH_POWER] = "high power",
2327 };
2328
2329 if (power >= ARRAY_SIZE(strings) || !strings[power])
2330 return "unknown";
2331
2332 return strings[power];
2333}
2334
Chris Wilson1854d5c2015-04-07 16:20:32 +01002335static int i915_rps_boost_info(struct seq_file *m, void *data)
2336{
David Weinehall36cdd012016-08-22 13:59:31 +03002337 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2338 struct drm_device *dev = &dev_priv->drm;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002339 struct drm_file *file;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002340
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002341 seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled);
Chris Wilson67d97da2016-07-04 08:08:31 +01002342 seq_printf(m, "GPU busy? %s [%x]\n",
2343 yesno(dev_priv->gt.awake), dev_priv->gt.active_engines);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002344 seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv));
Chris Wilson7466c292016-08-15 09:49:33 +01002345 seq_printf(m, "Frequency requested %d\n",
2346 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
2347 seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n",
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002348 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq),
2349 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit),
2350 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit),
2351 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
Chris Wilson7466c292016-08-15 09:49:33 +01002352 seq_printf(m, " idle:%d, efficient:%d, boost:%d\n",
2353 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq),
2354 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq),
2355 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002356
2357 mutex_lock(&dev->filelist_mutex);
Chris Wilson8d3afd72015-05-21 21:01:47 +01002358 spin_lock(&dev_priv->rps.client_lock);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002359 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2360 struct drm_i915_file_private *file_priv = file->driver_priv;
2361 struct task_struct *task;
2362
2363 rcu_read_lock();
2364 task = pid_task(file->pid, PIDTYPE_PID);
2365 seq_printf(m, "%s [%d]: %d boosts%s\n",
2366 task ? task->comm : "<unknown>",
2367 task ? task->pid : -1,
Chris Wilson2e1b8732015-04-27 13:41:22 +01002368 file_priv->rps.boosts,
2369 list_empty(&file_priv->rps.link) ? "" : ", active");
Chris Wilson1854d5c2015-04-07 16:20:32 +01002370 rcu_read_unlock();
2371 }
Chris Wilson197be2a2016-07-20 09:21:13 +01002372 seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts);
Chris Wilson8d3afd72015-05-21 21:01:47 +01002373 spin_unlock(&dev_priv->rps.client_lock);
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002374 mutex_unlock(&dev->filelist_mutex);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002375
Chris Wilson7466c292016-08-15 09:49:33 +01002376 if (INTEL_GEN(dev_priv) >= 6 &&
2377 dev_priv->rps.enabled &&
2378 dev_priv->gt.active_engines) {
2379 u32 rpup, rpupei;
2380 u32 rpdown, rpdownei;
2381
2382 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
2383 rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK;
2384 rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK;
2385 rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK;
2386 rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK;
2387 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
2388
2389 seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n",
2390 rps_power_to_str(dev_priv->rps.power));
2391 seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n",
2392 100 * rpup / rpupei,
2393 dev_priv->rps.up_threshold);
2394 seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n",
2395 100 * rpdown / rpdownei,
2396 dev_priv->rps.down_threshold);
2397 } else {
2398 seq_puts(m, "\nRPS Autotuning inactive\n");
2399 }
2400
Chris Wilson8d3afd72015-05-21 21:01:47 +01002401 return 0;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002402}
2403
Ben Widawsky63573eb2013-07-04 11:02:07 -07002404static int i915_llc(struct seq_file *m, void *data)
2405{
David Weinehall36cdd012016-08-22 13:59:31 +03002406 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002407 const bool edram = INTEL_GEN(dev_priv) > 8;
Ben Widawsky63573eb2013-07-04 11:02:07 -07002408
David Weinehall36cdd012016-08-22 13:59:31 +03002409 seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv)));
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002410 seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC",
2411 intel_uncore_edram_size(dev_priv)/1024/1024);
Ben Widawsky63573eb2013-07-04 11:02:07 -07002412
2413 return 0;
2414}
2415
Alex Daifdf5d352015-08-12 15:43:37 +01002416static int i915_guc_load_status_info(struct seq_file *m, void *data)
2417{
David Weinehall36cdd012016-08-22 13:59:31 +03002418 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Alex Daifdf5d352015-08-12 15:43:37 +01002419 struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
2420 u32 tmp, i;
2421
Joonas Lahtinen2d1fe072016-04-07 11:08:05 +03002422 if (!HAS_GUC_UCODE(dev_priv))
Alex Daifdf5d352015-08-12 15:43:37 +01002423 return 0;
2424
2425 seq_printf(m, "GuC firmware status:\n");
2426 seq_printf(m, "\tpath: %s\n",
2427 guc_fw->guc_fw_path);
2428 seq_printf(m, "\tfetch: %s\n",
2429 intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status));
2430 seq_printf(m, "\tload: %s\n",
2431 intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
2432 seq_printf(m, "\tversion wanted: %d.%d\n",
2433 guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted);
2434 seq_printf(m, "\tversion found: %d.%d\n",
2435 guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found);
Alex Daifeda33e2015-10-19 16:10:54 -07002436 seq_printf(m, "\theader: offset is %d; size = %d\n",
2437 guc_fw->header_offset, guc_fw->header_size);
2438 seq_printf(m, "\tuCode: offset is %d; size = %d\n",
2439 guc_fw->ucode_offset, guc_fw->ucode_size);
2440 seq_printf(m, "\tRSA: offset is %d; size = %d\n",
2441 guc_fw->rsa_offset, guc_fw->rsa_size);
Alex Daifdf5d352015-08-12 15:43:37 +01002442
2443 tmp = I915_READ(GUC_STATUS);
2444
2445 seq_printf(m, "\nGuC status 0x%08x:\n", tmp);
2446 seq_printf(m, "\tBootrom status = 0x%x\n",
2447 (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT);
2448 seq_printf(m, "\tuKernel status = 0x%x\n",
2449 (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT);
2450 seq_printf(m, "\tMIA Core status = 0x%x\n",
2451 (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT);
2452 seq_puts(m, "\nScratch registers:\n");
2453 for (i = 0; i < 16; i++)
2454 seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i)));
2455
2456 return 0;
2457}
2458
Dave Gordon8b417c22015-08-12 15:43:44 +01002459static void i915_guc_client_info(struct seq_file *m,
2460 struct drm_i915_private *dev_priv,
2461 struct i915_guc_client *client)
2462{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002463 struct intel_engine_cs *engine;
Dave Gordonc18468c2016-08-09 15:19:22 +01002464 enum intel_engine_id id;
Dave Gordon8b417c22015-08-12 15:43:44 +01002465 uint64_t tot = 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002466
2467 seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n",
2468 client->priority, client->ctx_index, client->proc_desc_offset);
2469 seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n",
2470 client->doorbell_id, client->doorbell_offset, client->cookie);
2471 seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n",
2472 client->wq_size, client->wq_offset, client->wq_tail);
2473
Dave Gordon551aaec2016-05-13 15:36:33 +01002474 seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space);
Dave Gordon8b417c22015-08-12 15:43:44 +01002475 seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail);
2476 seq_printf(m, "\tLast submission result: %d\n", client->retcode);
2477
Dave Gordonc18468c2016-08-09 15:19:22 +01002478 for_each_engine_id(engine, dev_priv, id) {
2479 u64 submissions = client->submissions[id];
2480 tot += submissions;
Dave Gordon8b417c22015-08-12 15:43:44 +01002481 seq_printf(m, "\tSubmissions: %llu %s\n",
Dave Gordonc18468c2016-08-09 15:19:22 +01002482 submissions, engine->name);
Dave Gordon8b417c22015-08-12 15:43:44 +01002483 }
2484 seq_printf(m, "\tTotal: %llu\n", tot);
2485}
2486
2487static int i915_guc_info(struct seq_file *m, void *data)
2488{
David Weinehall36cdd012016-08-22 13:59:31 +03002489 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2490 struct drm_device *dev = &dev_priv->drm;
Dave Gordon8b417c22015-08-12 15:43:44 +01002491 struct intel_guc guc;
Ville Syrjälä0a0b4572015-08-21 20:45:27 +03002492 struct i915_guc_client client = {};
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002493 struct intel_engine_cs *engine;
Dave Gordonc18468c2016-08-09 15:19:22 +01002494 enum intel_engine_id id;
Dave Gordon8b417c22015-08-12 15:43:44 +01002495 u64 total = 0;
2496
Joonas Lahtinen2d1fe072016-04-07 11:08:05 +03002497 if (!HAS_GUC_SCHED(dev_priv))
Dave Gordon8b417c22015-08-12 15:43:44 +01002498 return 0;
2499
Alex Dai5a843302015-12-02 16:56:29 -08002500 if (mutex_lock_interruptible(&dev->struct_mutex))
2501 return 0;
2502
Dave Gordon8b417c22015-08-12 15:43:44 +01002503 /* Take a local copy of the GuC data, so we can dump it at leisure */
Dave Gordon8b417c22015-08-12 15:43:44 +01002504 guc = dev_priv->guc;
Alex Dai5a843302015-12-02 16:56:29 -08002505 if (guc.execbuf_client)
Dave Gordon8b417c22015-08-12 15:43:44 +01002506 client = *guc.execbuf_client;
Alex Dai5a843302015-12-02 16:56:29 -08002507
2508 mutex_unlock(&dev->struct_mutex);
Dave Gordon8b417c22015-08-12 15:43:44 +01002509
Dave Gordon9636f6d2016-06-13 17:57:28 +01002510 seq_printf(m, "Doorbell map:\n");
2511 seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc.doorbell_bitmap);
2512 seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc.db_cacheline);
2513
Dave Gordon8b417c22015-08-12 15:43:44 +01002514 seq_printf(m, "GuC total action count: %llu\n", guc.action_count);
2515 seq_printf(m, "GuC action failure count: %u\n", guc.action_fail);
2516 seq_printf(m, "GuC last action command: 0x%x\n", guc.action_cmd);
2517 seq_printf(m, "GuC last action status: 0x%x\n", guc.action_status);
2518 seq_printf(m, "GuC last action error code: %d\n", guc.action_err);
2519
2520 seq_printf(m, "\nGuC submissions:\n");
Dave Gordonc18468c2016-08-09 15:19:22 +01002521 for_each_engine_id(engine, dev_priv, id) {
2522 u64 submissions = guc.submissions[id];
2523 total += submissions;
Alex Dai397097b2016-01-23 11:58:14 -08002524 seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n",
Dave Gordonc18468c2016-08-09 15:19:22 +01002525 engine->name, submissions, guc.last_seqno[id]);
Dave Gordon8b417c22015-08-12 15:43:44 +01002526 }
2527 seq_printf(m, "\t%s: %llu\n", "Total", total);
2528
2529 seq_printf(m, "\nGuC execbuf client @ %p:\n", guc.execbuf_client);
2530 i915_guc_client_info(m, dev_priv, &client);
2531
2532 /* Add more as required ... */
2533
2534 return 0;
2535}
2536
Alex Dai4c7e77f2015-08-12 15:43:40 +01002537static int i915_guc_log_dump(struct seq_file *m, void *data)
2538{
David Weinehall36cdd012016-08-22 13:59:31 +03002539 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilson8b797af2016-08-15 10:48:51 +01002540 struct drm_i915_gem_object *obj;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002541 int i = 0, pg;
2542
Chris Wilson8b797af2016-08-15 10:48:51 +01002543 if (!dev_priv->guc.log_vma)
Alex Dai4c7e77f2015-08-12 15:43:40 +01002544 return 0;
2545
Chris Wilson8b797af2016-08-15 10:48:51 +01002546 obj = dev_priv->guc.log_vma->obj;
2547 for (pg = 0; pg < obj->base.size / PAGE_SIZE; pg++) {
2548 u32 *log = kmap_atomic(i915_gem_object_get_page(obj, pg));
Alex Dai4c7e77f2015-08-12 15:43:40 +01002549
2550 for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4)
2551 seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n",
2552 *(log + i), *(log + i + 1),
2553 *(log + i + 2), *(log + i + 3));
2554
2555 kunmap_atomic(log);
2556 }
2557
2558 seq_putc(m, '\n');
2559
2560 return 0;
2561}
2562
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002563static int i915_edp_psr_status(struct seq_file *m, void *data)
2564{
David Weinehall36cdd012016-08-22 13:59:31 +03002565 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002566 u32 psrperf = 0;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002567 u32 stat[3];
2568 enum pipe pipe;
Rodrigo Vivia031d702013-10-03 16:15:06 -03002569 bool enabled = false;
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002570
David Weinehall36cdd012016-08-22 13:59:31 +03002571 if (!HAS_PSR(dev_priv)) {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002572 seq_puts(m, "PSR not supported\n");
2573 return 0;
2574 }
2575
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002576 intel_runtime_pm_get(dev_priv);
2577
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002578 mutex_lock(&dev_priv->psr.lock);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002579 seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support));
2580 seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok));
Daniel Vetter2807cf62014-07-11 10:30:11 -07002581 seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled));
Rodrigo Vivi5755c782014-06-12 10:16:45 -07002582 seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002583 seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
2584 dev_priv->psr.busy_frontbuffer_bits);
2585 seq_printf(m, "Re-enable work scheduled: %s\n",
2586 yesno(work_busy(&dev_priv->psr.work.work)));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002587
David Weinehall36cdd012016-08-22 13:59:31 +03002588 if (HAS_DDI(dev_priv))
Ville Syrjälä443a3892015-11-11 20:34:15 +02002589 enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE;
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002590 else {
2591 for_each_pipe(dev_priv, pipe) {
2592 stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) &
2593 VLV_EDP_PSR_CURR_STATE_MASK;
2594 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2595 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2596 enabled = true;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002597 }
2598 }
Rodrigo Vivi60e5ffe2016-02-01 12:02:07 -08002599
2600 seq_printf(m, "Main link in standby mode: %s\n",
2601 yesno(dev_priv->psr.link_standby));
2602
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002603 seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002604
David Weinehall36cdd012016-08-22 13:59:31 +03002605 if (!HAS_DDI(dev_priv))
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002606 for_each_pipe(dev_priv, pipe) {
2607 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2608 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2609 seq_printf(m, " pipe %c", pipe_name(pipe));
2610 }
2611 seq_puts(m, "\n");
2612
Rodrigo Vivi05eec3c2015-11-23 14:16:40 -08002613 /*
2614 * VLV/CHV PSR has no kind of performance counter
2615 * SKL+ Perf counter is reset to 0 everytime DC state is entered
2616 */
David Weinehall36cdd012016-08-22 13:59:31 +03002617 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
Ville Syrjälä443a3892015-11-11 20:34:15 +02002618 psrperf = I915_READ(EDP_PSR_PERF_CNT) &
Rodrigo Vivia031d702013-10-03 16:15:06 -03002619 EDP_PSR_PERF_CNT_MASK;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002620
2621 seq_printf(m, "Performance_Counter: %u\n", psrperf);
2622 }
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002623 mutex_unlock(&dev_priv->psr.lock);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002624
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002625 intel_runtime_pm_put(dev_priv);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002626 return 0;
2627}
2628
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002629static int i915_sink_crc(struct seq_file *m, void *data)
2630{
David Weinehall36cdd012016-08-22 13:59:31 +03002631 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2632 struct drm_device *dev = &dev_priv->drm;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002633 struct intel_connector *connector;
2634 struct intel_dp *intel_dp = NULL;
2635 int ret;
2636 u8 crc[6];
2637
2638 drm_modeset_lock_all(dev);
Rodrigo Viviaca5e362015-03-13 16:13:59 -07002639 for_each_intel_connector(dev, connector) {
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002640 struct drm_crtc *crtc;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002641
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002642 if (!connector->base.state->best_encoder)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002643 continue;
2644
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002645 crtc = connector->base.state->crtc;
2646 if (!crtc->state->active)
Paulo Zanonib6ae3c72014-02-13 17:51:33 -02002647 continue;
2648
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002649 if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002650 continue;
2651
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002652 intel_dp = enc_to_intel_dp(connector->base.state->best_encoder);
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002653
2654 ret = intel_dp_sink_crc(intel_dp, crc);
2655 if (ret)
2656 goto out;
2657
2658 seq_printf(m, "%02x%02x%02x%02x%02x%02x\n",
2659 crc[0], crc[1], crc[2],
2660 crc[3], crc[4], crc[5]);
2661 goto out;
2662 }
2663 ret = -ENODEV;
2664out:
2665 drm_modeset_unlock_all(dev);
2666 return ret;
2667}
2668
Jesse Barnesec013e72013-08-20 10:29:23 +01002669static int i915_energy_uJ(struct seq_file *m, void *data)
2670{
David Weinehall36cdd012016-08-22 13:59:31 +03002671 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnesec013e72013-08-20 10:29:23 +01002672 u64 power;
2673 u32 units;
2674
David Weinehall36cdd012016-08-22 13:59:31 +03002675 if (INTEL_GEN(dev_priv) < 6)
Jesse Barnesec013e72013-08-20 10:29:23 +01002676 return -ENODEV;
2677
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002678 intel_runtime_pm_get(dev_priv);
2679
Jesse Barnesec013e72013-08-20 10:29:23 +01002680 rdmsrl(MSR_RAPL_POWER_UNIT, power);
2681 power = (power & 0x1f00) >> 8;
2682 units = 1000000 / (1 << power); /* convert to uJ */
2683 power = I915_READ(MCH_SECP_NRG_STTS);
2684 power *= units;
2685
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002686 intel_runtime_pm_put(dev_priv);
2687
Jesse Barnesec013e72013-08-20 10:29:23 +01002688 seq_printf(m, "%llu", (long long unsigned)power);
Paulo Zanoni371db662013-08-19 13:18:10 -03002689
2690 return 0;
2691}
2692
Damien Lespiau6455c872015-06-04 18:23:57 +01002693static int i915_runtime_pm_status(struct seq_file *m, void *unused)
Paulo Zanoni371db662013-08-19 13:18:10 -03002694{
David Weinehall36cdd012016-08-22 13:59:31 +03002695 struct drm_i915_private *dev_priv = node_to_i915(m->private);
David Weinehall52a05c32016-08-22 13:32:44 +03002696 struct pci_dev *pdev = dev_priv->drm.pdev;
Paulo Zanoni371db662013-08-19 13:18:10 -03002697
Chris Wilsona156e642016-04-03 14:14:21 +01002698 if (!HAS_RUNTIME_PM(dev_priv))
2699 seq_puts(m, "Runtime power management not supported\n");
Paulo Zanoni371db662013-08-19 13:18:10 -03002700
Chris Wilson67d97da2016-07-04 08:08:31 +01002701 seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake));
Paulo Zanoni371db662013-08-19 13:18:10 -03002702 seq_printf(m, "IRQs disabled: %s\n",
Jesse Barnes9df7575f2014-06-20 09:29:20 -07002703 yesno(!intel_irqs_enabled(dev_priv)));
Chris Wilson0d804182015-06-15 12:52:28 +01002704#ifdef CONFIG_PM
Damien Lespiaua6aaec82015-06-04 18:23:58 +01002705 seq_printf(m, "Usage count: %d\n",
David Weinehall36cdd012016-08-22 13:59:31 +03002706 atomic_read(&dev_priv->drm.dev->power.usage_count));
Chris Wilson0d804182015-06-15 12:52:28 +01002707#else
2708 seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n");
2709#endif
Chris Wilsona156e642016-04-03 14:14:21 +01002710 seq_printf(m, "PCI device power state: %s [%d]\n",
David Weinehall52a05c32016-08-22 13:32:44 +03002711 pci_power_name(pdev->current_state),
2712 pdev->current_state);
Paulo Zanoni371db662013-08-19 13:18:10 -03002713
Jesse Barnesec013e72013-08-20 10:29:23 +01002714 return 0;
2715}
2716
Imre Deak1da51582013-11-25 17:15:35 +02002717static int i915_power_domain_info(struct seq_file *m, void *unused)
2718{
David Weinehall36cdd012016-08-22 13:59:31 +03002719 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak1da51582013-11-25 17:15:35 +02002720 struct i915_power_domains *power_domains = &dev_priv->power_domains;
2721 int i;
2722
2723 mutex_lock(&power_domains->lock);
2724
2725 seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count");
2726 for (i = 0; i < power_domains->power_well_count; i++) {
2727 struct i915_power_well *power_well;
2728 enum intel_display_power_domain power_domain;
2729
2730 power_well = &power_domains->power_wells[i];
2731 seq_printf(m, "%-25s %d\n", power_well->name,
2732 power_well->count);
2733
2734 for (power_domain = 0; power_domain < POWER_DOMAIN_NUM;
2735 power_domain++) {
2736 if (!(BIT(power_domain) & power_well->domains))
2737 continue;
2738
2739 seq_printf(m, " %-23s %d\n",
Daniel Stone9895ad02015-11-20 15:55:33 +00002740 intel_display_power_domain_str(power_domain),
Imre Deak1da51582013-11-25 17:15:35 +02002741 power_domains->domain_use_count[power_domain]);
2742 }
2743 }
2744
2745 mutex_unlock(&power_domains->lock);
2746
2747 return 0;
2748}
2749
Damien Lespiaub7cec662015-10-27 14:47:01 +02002750static int i915_dmc_info(struct seq_file *m, void *unused)
2751{
David Weinehall36cdd012016-08-22 13:59:31 +03002752 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Damien Lespiaub7cec662015-10-27 14:47:01 +02002753 struct intel_csr *csr;
2754
David Weinehall36cdd012016-08-22 13:59:31 +03002755 if (!HAS_CSR(dev_priv)) {
Damien Lespiaub7cec662015-10-27 14:47:01 +02002756 seq_puts(m, "not supported\n");
2757 return 0;
2758 }
2759
2760 csr = &dev_priv->csr;
2761
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002762 intel_runtime_pm_get(dev_priv);
2763
Damien Lespiaub7cec662015-10-27 14:47:01 +02002764 seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL));
2765 seq_printf(m, "path: %s\n", csr->fw_path);
2766
2767 if (!csr->dmc_payload)
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002768 goto out;
Damien Lespiaub7cec662015-10-27 14:47:01 +02002769
2770 seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version),
2771 CSR_VERSION_MINOR(csr->version));
2772
David Weinehall36cdd012016-08-22 13:59:31 +03002773 if (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6)) {
Damien Lespiau83372062015-10-30 17:53:32 +02002774 seq_printf(m, "DC3 -> DC5 count: %d\n",
2775 I915_READ(SKL_CSR_DC3_DC5_COUNT));
2776 seq_printf(m, "DC5 -> DC6 count: %d\n",
2777 I915_READ(SKL_CSR_DC5_DC6_COUNT));
David Weinehall36cdd012016-08-22 13:59:31 +03002778 } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) {
Mika Kuoppala16e11b92015-10-27 14:47:03 +02002779 seq_printf(m, "DC3 -> DC5 count: %d\n",
2780 I915_READ(BXT_CSR_DC3_DC5_COUNT));
Damien Lespiau83372062015-10-30 17:53:32 +02002781 }
2782
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002783out:
2784 seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0)));
2785 seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE));
2786 seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL));
2787
Damien Lespiau83372062015-10-30 17:53:32 +02002788 intel_runtime_pm_put(dev_priv);
2789
Damien Lespiaub7cec662015-10-27 14:47:01 +02002790 return 0;
2791}
2792
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002793static void intel_seq_print_mode(struct seq_file *m, int tabs,
2794 struct drm_display_mode *mode)
2795{
2796 int i;
2797
2798 for (i = 0; i < tabs; i++)
2799 seq_putc(m, '\t');
2800
2801 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",
2802 mode->base.id, mode->name,
2803 mode->vrefresh, mode->clock,
2804 mode->hdisplay, mode->hsync_start,
2805 mode->hsync_end, mode->htotal,
2806 mode->vdisplay, mode->vsync_start,
2807 mode->vsync_end, mode->vtotal,
2808 mode->type, mode->flags);
2809}
2810
2811static void intel_encoder_info(struct seq_file *m,
2812 struct intel_crtc *intel_crtc,
2813 struct intel_encoder *intel_encoder)
2814{
David Weinehall36cdd012016-08-22 13:59:31 +03002815 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2816 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002817 struct drm_crtc *crtc = &intel_crtc->base;
2818 struct intel_connector *intel_connector;
2819 struct drm_encoder *encoder;
2820
2821 encoder = &intel_encoder->base;
2822 seq_printf(m, "\tencoder %d: type: %s, connectors:\n",
Jani Nikula8e329a02014-06-03 14:56:21 +03002823 encoder->base.id, encoder->name);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002824 for_each_connector_on_encoder(dev, encoder, intel_connector) {
2825 struct drm_connector *connector = &intel_connector->base;
2826 seq_printf(m, "\t\tconnector %d: type: %s, status: %s",
2827 connector->base.id,
Jani Nikulac23cc412014-06-03 14:56:17 +03002828 connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002829 drm_get_connector_status_name(connector->status));
2830 if (connector->status == connector_status_connected) {
2831 struct drm_display_mode *mode = &crtc->mode;
2832 seq_printf(m, ", mode:\n");
2833 intel_seq_print_mode(m, 2, mode);
2834 } else {
2835 seq_putc(m, '\n');
2836 }
2837 }
2838}
2839
2840static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc)
2841{
David Weinehall36cdd012016-08-22 13:59:31 +03002842 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2843 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002844 struct drm_crtc *crtc = &intel_crtc->base;
2845 struct intel_encoder *intel_encoder;
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002846 struct drm_plane_state *plane_state = crtc->primary->state;
2847 struct drm_framebuffer *fb = plane_state->fb;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002848
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002849 if (fb)
Matt Roper5aa8a932014-06-16 10:12:55 -07002850 seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n",
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002851 fb->base.id, plane_state->src_x >> 16,
2852 plane_state->src_y >> 16, fb->width, fb->height);
Matt Roper5aa8a932014-06-16 10:12:55 -07002853 else
2854 seq_puts(m, "\tprimary plane disabled\n");
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002855 for_each_encoder_on_crtc(dev, crtc, intel_encoder)
2856 intel_encoder_info(m, intel_crtc, intel_encoder);
2857}
2858
2859static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
2860{
2861 struct drm_display_mode *mode = panel->fixed_mode;
2862
2863 seq_printf(m, "\tfixed mode:\n");
2864 intel_seq_print_mode(m, 2, mode);
2865}
2866
2867static void intel_dp_info(struct seq_file *m,
2868 struct intel_connector *intel_connector)
2869{
2870 struct intel_encoder *intel_encoder = intel_connector->encoder;
2871 struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
2872
2873 seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]);
Jani Nikula742f4912015-09-03 11:16:09 +03002874 seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio));
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02002875 if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002876 intel_panel_info(m, &intel_connector->panel);
2877}
2878
2879static void intel_hdmi_info(struct seq_file *m,
2880 struct intel_connector *intel_connector)
2881{
2882 struct intel_encoder *intel_encoder = intel_connector->encoder;
2883 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
2884
Jani Nikula742f4912015-09-03 11:16:09 +03002885 seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio));
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002886}
2887
2888static void intel_lvds_info(struct seq_file *m,
2889 struct intel_connector *intel_connector)
2890{
2891 intel_panel_info(m, &intel_connector->panel);
2892}
2893
2894static void intel_connector_info(struct seq_file *m,
2895 struct drm_connector *connector)
2896{
2897 struct intel_connector *intel_connector = to_intel_connector(connector);
2898 struct intel_encoder *intel_encoder = intel_connector->encoder;
Jesse Barnesf103fc72014-02-20 12:39:57 -08002899 struct drm_display_mode *mode;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002900
2901 seq_printf(m, "connector %d: type %s, status: %s\n",
Jani Nikulac23cc412014-06-03 14:56:17 +03002902 connector->base.id, connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002903 drm_get_connector_status_name(connector->status));
2904 if (connector->status == connector_status_connected) {
2905 seq_printf(m, "\tname: %s\n", connector->display_info.name);
2906 seq_printf(m, "\tphysical dimensions: %dx%dmm\n",
2907 connector->display_info.width_mm,
2908 connector->display_info.height_mm);
2909 seq_printf(m, "\tsubpixel order: %s\n",
2910 drm_get_subpixel_order_name(connector->display_info.subpixel_order));
2911 seq_printf(m, "\tCEA rev: %d\n",
2912 connector->display_info.cea_rev);
2913 }
Maarten Lankhorstee648a72016-06-21 12:00:38 +02002914
2915 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
2916 return;
2917
2918 switch (connector->connector_type) {
2919 case DRM_MODE_CONNECTOR_DisplayPort:
2920 case DRM_MODE_CONNECTOR_eDP:
2921 intel_dp_info(m, intel_connector);
2922 break;
2923 case DRM_MODE_CONNECTOR_LVDS:
2924 if (intel_encoder->type == INTEL_OUTPUT_LVDS)
Dave Airlie36cd7442014-05-02 13:44:18 +10002925 intel_lvds_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02002926 break;
2927 case DRM_MODE_CONNECTOR_HDMIA:
2928 if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
2929 intel_encoder->type == INTEL_OUTPUT_UNKNOWN)
2930 intel_hdmi_info(m, intel_connector);
2931 break;
2932 default:
2933 break;
Dave Airlie36cd7442014-05-02 13:44:18 +10002934 }
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002935
Jesse Barnesf103fc72014-02-20 12:39:57 -08002936 seq_printf(m, "\tmodes:\n");
2937 list_for_each_entry(mode, &connector->modes, head)
2938 intel_seq_print_mode(m, 2, mode);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002939}
2940
David Weinehall36cdd012016-08-22 13:59:31 +03002941static bool cursor_active(struct drm_i915_private *dev_priv, int pipe)
Chris Wilson065f2ec2014-03-12 09:13:13 +00002942{
Chris Wilson065f2ec2014-03-12 09:13:13 +00002943 u32 state;
2944
David Weinehall36cdd012016-08-22 13:59:31 +03002945 if (IS_845G(dev_priv) || IS_I865G(dev_priv))
Ville Syrjälä0b87c242015-09-22 19:47:51 +03002946 state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE;
Chris Wilson065f2ec2014-03-12 09:13:13 +00002947 else
Ville Syrjälä5efb3e22014-04-09 13:28:53 +03002948 state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE;
Chris Wilson065f2ec2014-03-12 09:13:13 +00002949
2950 return state;
2951}
2952
David Weinehall36cdd012016-08-22 13:59:31 +03002953static bool cursor_position(struct drm_i915_private *dev_priv,
2954 int pipe, int *x, int *y)
Chris Wilson065f2ec2014-03-12 09:13:13 +00002955{
Chris Wilson065f2ec2014-03-12 09:13:13 +00002956 u32 pos;
2957
Ville Syrjälä5efb3e22014-04-09 13:28:53 +03002958 pos = I915_READ(CURPOS(pipe));
Chris Wilson065f2ec2014-03-12 09:13:13 +00002959
2960 *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK;
2961 if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT))
2962 *x = -*x;
2963
2964 *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK;
2965 if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT))
2966 *y = -*y;
2967
David Weinehall36cdd012016-08-22 13:59:31 +03002968 return cursor_active(dev_priv, pipe);
Chris Wilson065f2ec2014-03-12 09:13:13 +00002969}
2970
Robert Fekete3abc4e02015-10-27 16:58:32 +01002971static const char *plane_type(enum drm_plane_type type)
2972{
2973 switch (type) {
2974 case DRM_PLANE_TYPE_OVERLAY:
2975 return "OVL";
2976 case DRM_PLANE_TYPE_PRIMARY:
2977 return "PRI";
2978 case DRM_PLANE_TYPE_CURSOR:
2979 return "CUR";
2980 /*
2981 * Deliberately omitting default: to generate compiler warnings
2982 * when a new drm_plane_type gets added.
2983 */
2984 }
2985
2986 return "unknown";
2987}
2988
2989static const char *plane_rotation(unsigned int rotation)
2990{
2991 static char buf[48];
2992 /*
2993 * According to doc only one DRM_ROTATE_ is allowed but this
2994 * will print them all to visualize if the values are misused
2995 */
2996 snprintf(buf, sizeof(buf),
2997 "%s%s%s%s%s%s(0x%08x)",
Joonas Lahtinen31ad61e2016-07-29 08:50:05 +03002998 (rotation & DRM_ROTATE_0) ? "0 " : "",
2999 (rotation & DRM_ROTATE_90) ? "90 " : "",
3000 (rotation & DRM_ROTATE_180) ? "180 " : "",
3001 (rotation & DRM_ROTATE_270) ? "270 " : "",
3002 (rotation & DRM_REFLECT_X) ? "FLIPX " : "",
3003 (rotation & DRM_REFLECT_Y) ? "FLIPY " : "",
Robert Fekete3abc4e02015-10-27 16:58:32 +01003004 rotation);
3005
3006 return buf;
3007}
3008
3009static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3010{
David Weinehall36cdd012016-08-22 13:59:31 +03003011 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3012 struct drm_device *dev = &dev_priv->drm;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003013 struct intel_plane *intel_plane;
3014
3015 for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
3016 struct drm_plane_state *state;
3017 struct drm_plane *plane = &intel_plane->base;
3018
3019 if (!plane->state) {
3020 seq_puts(m, "plane->state is NULL!\n");
3021 continue;
3022 }
3023
3024 state = plane->state;
3025
3026 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",
3027 plane->base.id,
3028 plane_type(intel_plane->base.type),
3029 state->crtc_x, state->crtc_y,
3030 state->crtc_w, state->crtc_h,
3031 (state->src_x >> 16),
3032 ((state->src_x & 0xffff) * 15625) >> 10,
3033 (state->src_y >> 16),
3034 ((state->src_y & 0xffff) * 15625) >> 10,
3035 (state->src_w >> 16),
3036 ((state->src_w & 0xffff) * 15625) >> 10,
3037 (state->src_h >> 16),
3038 ((state->src_h & 0xffff) * 15625) >> 10,
3039 state->fb ? drm_get_format_name(state->fb->pixel_format) : "N/A",
3040 plane_rotation(state->rotation));
3041 }
3042}
3043
3044static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3045{
3046 struct intel_crtc_state *pipe_config;
3047 int num_scalers = intel_crtc->num_scalers;
3048 int i;
3049
3050 pipe_config = to_intel_crtc_state(intel_crtc->base.state);
3051
3052 /* Not all platformas have a scaler */
3053 if (num_scalers) {
3054 seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d",
3055 num_scalers,
3056 pipe_config->scaler_state.scaler_users,
3057 pipe_config->scaler_state.scaler_id);
3058
3059 for (i = 0; i < SKL_NUM_SCALERS; i++) {
3060 struct intel_scaler *sc =
3061 &pipe_config->scaler_state.scalers[i];
3062
3063 seq_printf(m, ", scalers[%d]: use=%s, mode=%x",
3064 i, yesno(sc->in_use), sc->mode);
3065 }
3066 seq_puts(m, "\n");
3067 } else {
3068 seq_puts(m, "\tNo scalers available on this platform\n");
3069 }
3070}
3071
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003072static int i915_display_info(struct seq_file *m, void *unused)
3073{
David Weinehall36cdd012016-08-22 13:59:31 +03003074 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3075 struct drm_device *dev = &dev_priv->drm;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003076 struct intel_crtc *crtc;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003077 struct drm_connector *connector;
3078
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003079 intel_runtime_pm_get(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003080 drm_modeset_lock_all(dev);
3081 seq_printf(m, "CRTC info\n");
3082 seq_printf(m, "---------\n");
Damien Lespiaud3fcc802014-05-13 23:32:22 +01003083 for_each_intel_crtc(dev, crtc) {
Chris Wilson065f2ec2014-03-12 09:13:13 +00003084 bool active;
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003085 struct intel_crtc_state *pipe_config;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003086 int x, y;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003087
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003088 pipe_config = to_intel_crtc_state(crtc->base.state);
3089
Robert Fekete3abc4e02015-10-27 16:58:32 +01003090 seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n",
Chris Wilson065f2ec2014-03-12 09:13:13 +00003091 crtc->base.base.id, pipe_name(crtc->pipe),
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003092 yesno(pipe_config->base.active),
Robert Fekete3abc4e02015-10-27 16:58:32 +01003093 pipe_config->pipe_src_w, pipe_config->pipe_src_h,
3094 yesno(pipe_config->dither), pipe_config->pipe_bpp);
3095
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003096 if (pipe_config->base.active) {
Chris Wilson065f2ec2014-03-12 09:13:13 +00003097 intel_crtc_info(m, crtc);
3098
David Weinehall36cdd012016-08-22 13:59:31 +03003099 active = cursor_position(dev_priv, crtc->pipe, &x, &y);
Chris Wilson57127ef2014-07-04 08:20:11 +01003100 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 +03003101 yesno(crtc->cursor_base),
Matt Roper3dd512f2015-02-27 10:12:00 -08003102 x, y, crtc->base.cursor->state->crtc_w,
3103 crtc->base.cursor->state->crtc_h,
Chris Wilson57127ef2014-07-04 08:20:11 +01003104 crtc->cursor_addr, yesno(active));
Robert Fekete3abc4e02015-10-27 16:58:32 +01003105 intel_scaler_info(m, crtc);
3106 intel_plane_info(m, crtc);
Paulo Zanonia23dc652014-04-01 14:55:11 -03003107 }
Daniel Vettercace8412014-05-22 17:56:31 +02003108
3109 seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n",
3110 yesno(!crtc->cpu_fifo_underrun_disabled),
3111 yesno(!crtc->pch_fifo_underrun_disabled));
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003112 }
3113
3114 seq_printf(m, "\n");
3115 seq_printf(m, "Connector info\n");
3116 seq_printf(m, "--------------\n");
3117 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
3118 intel_connector_info(m, connector);
3119 }
3120 drm_modeset_unlock_all(dev);
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003121 intel_runtime_pm_put(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003122
3123 return 0;
3124}
3125
Ben Widawskye04934c2014-06-30 09:53:42 -07003126static int i915_semaphore_status(struct seq_file *m, void *unused)
3127{
David Weinehall36cdd012016-08-22 13:59:31 +03003128 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3129 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003130 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003131 int num_rings = INTEL_INFO(dev_priv)->num_rings;
Dave Gordonc3232b12016-03-23 18:19:53 +00003132 enum intel_engine_id id;
3133 int j, ret;
Ben Widawskye04934c2014-06-30 09:53:42 -07003134
Chris Wilson39df9192016-07-20 13:31:57 +01003135 if (!i915.semaphores) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003136 seq_puts(m, "Semaphores are disabled\n");
3137 return 0;
3138 }
3139
3140 ret = mutex_lock_interruptible(&dev->struct_mutex);
3141 if (ret)
3142 return ret;
Paulo Zanoni03872062014-07-09 14:31:57 -03003143 intel_runtime_pm_get(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003144
David Weinehall36cdd012016-08-22 13:59:31 +03003145 if (IS_BROADWELL(dev_priv)) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003146 struct page *page;
3147 uint64_t *seqno;
3148
Chris Wilson51d545d2016-08-15 10:49:02 +01003149 page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0);
Ben Widawskye04934c2014-06-30 09:53:42 -07003150
3151 seqno = (uint64_t *)kmap_atomic(page);
Dave Gordonc3232b12016-03-23 18:19:53 +00003152 for_each_engine_id(engine, dev_priv, id) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003153 uint64_t offset;
3154
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003155 seq_printf(m, "%s\n", engine->name);
Ben Widawskye04934c2014-06-30 09:53:42 -07003156
3157 seq_puts(m, " Last signal:");
3158 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003159 offset = id * I915_NUM_ENGINES + j;
Ben Widawskye04934c2014-06-30 09:53:42 -07003160 seq_printf(m, "0x%08llx (0x%02llx) ",
3161 seqno[offset], offset * 8);
3162 }
3163 seq_putc(m, '\n');
3164
3165 seq_puts(m, " Last wait: ");
3166 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003167 offset = id + (j * I915_NUM_ENGINES);
Ben Widawskye04934c2014-06-30 09:53:42 -07003168 seq_printf(m, "0x%08llx (0x%02llx) ",
3169 seqno[offset], offset * 8);
3170 }
3171 seq_putc(m, '\n');
3172
3173 }
3174 kunmap_atomic(seqno);
3175 } else {
3176 seq_puts(m, " Last signal:");
Dave Gordonb4ac5af2016-03-24 11:20:38 +00003177 for_each_engine(engine, dev_priv)
Ben Widawskye04934c2014-06-30 09:53:42 -07003178 for (j = 0; j < num_rings; j++)
3179 seq_printf(m, "0x%08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003180 I915_READ(engine->semaphore.mbox.signal[j]));
Ben Widawskye04934c2014-06-30 09:53:42 -07003181 seq_putc(m, '\n');
3182 }
3183
3184 seq_puts(m, "\nSync seqno:\n");
Dave Gordonb4ac5af2016-03-24 11:20:38 +00003185 for_each_engine(engine, dev_priv) {
3186 for (j = 0; j < num_rings; j++)
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003187 seq_printf(m, " 0x%08x ",
3188 engine->semaphore.sync_seqno[j]);
Ben Widawskye04934c2014-06-30 09:53:42 -07003189 seq_putc(m, '\n');
3190 }
3191 seq_putc(m, '\n');
3192
Paulo Zanoni03872062014-07-09 14:31:57 -03003193 intel_runtime_pm_put(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003194 mutex_unlock(&dev->struct_mutex);
3195 return 0;
3196}
3197
Daniel Vetter728e29d2014-06-25 22:01:53 +03003198static int i915_shared_dplls_info(struct seq_file *m, void *unused)
3199{
David Weinehall36cdd012016-08-22 13:59:31 +03003200 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3201 struct drm_device *dev = &dev_priv->drm;
Daniel Vetter728e29d2014-06-25 22:01:53 +03003202 int i;
3203
3204 drm_modeset_lock_all(dev);
3205 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3206 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
3207
3208 seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id);
Maarten Lankhorst2dd66ebd2016-03-14 09:27:52 +01003209 seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n",
3210 pll->config.crtc_mask, pll->active_mask, yesno(pll->on));
Daniel Vetter728e29d2014-06-25 22:01:53 +03003211 seq_printf(m, " tracked hardware state:\n");
Ander Conselvan de Oliveira3e369b72014-10-29 11:32:32 +02003212 seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll);
3213 seq_printf(m, " dpll_md: 0x%08x\n",
3214 pll->config.hw_state.dpll_md);
3215 seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0);
3216 seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1);
3217 seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll);
Daniel Vetter728e29d2014-06-25 22:01:53 +03003218 }
3219 drm_modeset_unlock_all(dev);
3220
3221 return 0;
3222}
3223
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01003224static int i915_wa_registers(struct seq_file *m, void *unused)
Arun Siluvery888b5992014-08-26 14:44:51 +01003225{
3226 int i;
3227 int ret;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003228 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003229 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3230 struct drm_device *dev = &dev_priv->drm;
Arun Siluvery33136b02016-01-21 21:43:47 +00003231 struct i915_workarounds *workarounds = &dev_priv->workarounds;
Dave Gordonc3232b12016-03-23 18:19:53 +00003232 enum intel_engine_id id;
Arun Siluvery888b5992014-08-26 14:44:51 +01003233
Arun Siluvery888b5992014-08-26 14:44:51 +01003234 ret = mutex_lock_interruptible(&dev->struct_mutex);
3235 if (ret)
3236 return ret;
3237
3238 intel_runtime_pm_get(dev_priv);
3239
Arun Siluvery33136b02016-01-21 21:43:47 +00003240 seq_printf(m, "Workarounds applied: %d\n", workarounds->count);
Dave Gordonc3232b12016-03-23 18:19:53 +00003241 for_each_engine_id(engine, dev_priv, id)
Arun Siluvery33136b02016-01-21 21:43:47 +00003242 seq_printf(m, "HW whitelist count for %s: %d\n",
Dave Gordonc3232b12016-03-23 18:19:53 +00003243 engine->name, workarounds->hw_whitelist_count[id]);
Arun Siluvery33136b02016-01-21 21:43:47 +00003244 for (i = 0; i < workarounds->count; ++i) {
Ville Syrjäläf0f59a02015-11-18 15:33:26 +02003245 i915_reg_t addr;
3246 u32 mask, value, read;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003247 bool ok;
Arun Siluvery888b5992014-08-26 14:44:51 +01003248
Arun Siluvery33136b02016-01-21 21:43:47 +00003249 addr = workarounds->reg[i].addr;
3250 mask = workarounds->reg[i].mask;
3251 value = workarounds->reg[i].value;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003252 read = I915_READ(addr);
3253 ok = (value & mask) == (read & mask);
3254 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 +02003255 i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL");
Arun Siluvery888b5992014-08-26 14:44:51 +01003256 }
3257
3258 intel_runtime_pm_put(dev_priv);
3259 mutex_unlock(&dev->struct_mutex);
3260
3261 return 0;
3262}
3263
Damien Lespiauc5511e42014-11-04 17:06:51 +00003264static int i915_ddb_info(struct seq_file *m, void *unused)
3265{
David Weinehall36cdd012016-08-22 13:59:31 +03003266 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3267 struct drm_device *dev = &dev_priv->drm;
Damien Lespiauc5511e42014-11-04 17:06:51 +00003268 struct skl_ddb_allocation *ddb;
3269 struct skl_ddb_entry *entry;
3270 enum pipe pipe;
3271 int plane;
3272
David Weinehall36cdd012016-08-22 13:59:31 +03003273 if (INTEL_GEN(dev_priv) < 9)
Damien Lespiau2fcffe12014-12-03 17:33:24 +00003274 return 0;
3275
Damien Lespiauc5511e42014-11-04 17:06:51 +00003276 drm_modeset_lock_all(dev);
3277
3278 ddb = &dev_priv->wm.skl_hw.ddb;
3279
3280 seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
3281
3282 for_each_pipe(dev_priv, pipe) {
3283 seq_printf(m, "Pipe %c\n", pipe_name(pipe));
3284
Damien Lespiaudd740782015-02-28 14:54:08 +00003285 for_each_plane(dev_priv, pipe, plane) {
Damien Lespiauc5511e42014-11-04 17:06:51 +00003286 entry = &ddb->plane[pipe][plane];
3287 seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1,
3288 entry->start, entry->end,
3289 skl_ddb_entry_size(entry));
3290 }
3291
Matt Roper4969d332015-09-24 15:53:10 -07003292 entry = &ddb->plane[pipe][PLANE_CURSOR];
Damien Lespiauc5511e42014-11-04 17:06:51 +00003293 seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start,
3294 entry->end, skl_ddb_entry_size(entry));
3295 }
3296
3297 drm_modeset_unlock_all(dev);
3298
3299 return 0;
3300}
3301
Vandana Kannana54746e2015-03-03 20:53:10 +05303302static void drrs_status_per_crtc(struct seq_file *m,
David Weinehall36cdd012016-08-22 13:59:31 +03003303 struct drm_device *dev,
3304 struct intel_crtc *intel_crtc)
Vandana Kannana54746e2015-03-03 20:53:10 +05303305{
Chris Wilsonfac5e232016-07-04 11:34:36 +01003306 struct drm_i915_private *dev_priv = to_i915(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303307 struct i915_drrs *drrs = &dev_priv->drrs;
3308 int vrefresh = 0;
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003309 struct drm_connector *connector;
Vandana Kannana54746e2015-03-03 20:53:10 +05303310
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003311 drm_for_each_connector(connector, dev) {
3312 if (connector->state->crtc != &intel_crtc->base)
3313 continue;
3314
3315 seq_printf(m, "%s:\n", connector->name);
Vandana Kannana54746e2015-03-03 20:53:10 +05303316 }
3317
3318 if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT)
3319 seq_puts(m, "\tVBT: DRRS_type: Static");
3320 else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT)
3321 seq_puts(m, "\tVBT: DRRS_type: Seamless");
3322 else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED)
3323 seq_puts(m, "\tVBT: DRRS_type: None");
3324 else
3325 seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value");
3326
3327 seq_puts(m, "\n\n");
3328
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003329 if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303330 struct intel_panel *panel;
3331
3332 mutex_lock(&drrs->mutex);
3333 /* DRRS Supported */
3334 seq_puts(m, "\tDRRS Supported: Yes\n");
3335
3336 /* disable_drrs() will make drrs->dp NULL */
3337 if (!drrs->dp) {
3338 seq_puts(m, "Idleness DRRS: Disabled");
3339 mutex_unlock(&drrs->mutex);
3340 return;
3341 }
3342
3343 panel = &drrs->dp->attached_connector->panel;
3344 seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X",
3345 drrs->busy_frontbuffer_bits);
3346
3347 seq_puts(m, "\n\t\t");
3348 if (drrs->refresh_rate_type == DRRS_HIGH_RR) {
3349 seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n");
3350 vrefresh = panel->fixed_mode->vrefresh;
3351 } else if (drrs->refresh_rate_type == DRRS_LOW_RR) {
3352 seq_puts(m, "DRRS_State: DRRS_LOW_RR\n");
3353 vrefresh = panel->downclock_mode->vrefresh;
3354 } else {
3355 seq_printf(m, "DRRS_State: Unknown(%d)\n",
3356 drrs->refresh_rate_type);
3357 mutex_unlock(&drrs->mutex);
3358 return;
3359 }
3360 seq_printf(m, "\t\tVrefresh: %d", vrefresh);
3361
3362 seq_puts(m, "\n\t\t");
3363 mutex_unlock(&drrs->mutex);
3364 } else {
3365 /* DRRS not supported. Print the VBT parameter*/
3366 seq_puts(m, "\tDRRS Supported : No");
3367 }
3368 seq_puts(m, "\n");
3369}
3370
3371static int i915_drrs_status(struct seq_file *m, void *unused)
3372{
David Weinehall36cdd012016-08-22 13:59:31 +03003373 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3374 struct drm_device *dev = &dev_priv->drm;
Vandana Kannana54746e2015-03-03 20:53:10 +05303375 struct intel_crtc *intel_crtc;
3376 int active_crtc_cnt = 0;
3377
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003378 drm_modeset_lock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303379 for_each_intel_crtc(dev, intel_crtc) {
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003380 if (intel_crtc->base.state->active) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303381 active_crtc_cnt++;
3382 seq_printf(m, "\nCRTC %d: ", active_crtc_cnt);
3383
3384 drrs_status_per_crtc(m, dev, intel_crtc);
3385 }
Vandana Kannana54746e2015-03-03 20:53:10 +05303386 }
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003387 drm_modeset_unlock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303388
3389 if (!active_crtc_cnt)
3390 seq_puts(m, "No active crtc found\n");
3391
3392 return 0;
3393}
3394
Damien Lespiau07144422013-10-15 18:55:40 +01003395struct pipe_crc_info {
3396 const char *name;
David Weinehall36cdd012016-08-22 13:59:31 +03003397 struct drm_i915_private *dev_priv;
Damien Lespiau07144422013-10-15 18:55:40 +01003398 enum pipe pipe;
3399};
3400
Dave Airlie11bed9582014-05-12 15:22:27 +10003401static int i915_dp_mst_info(struct seq_file *m, void *unused)
3402{
David Weinehall36cdd012016-08-22 13:59:31 +03003403 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3404 struct drm_device *dev = &dev_priv->drm;
Dave Airlie11bed9582014-05-12 15:22:27 +10003405 struct intel_encoder *intel_encoder;
3406 struct intel_digital_port *intel_dig_port;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003407 struct drm_connector *connector;
3408
Dave Airlie11bed9582014-05-12 15:22:27 +10003409 drm_modeset_lock_all(dev);
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003410 drm_for_each_connector(connector, dev) {
3411 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
Dave Airlie11bed9582014-05-12 15:22:27 +10003412 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003413
3414 intel_encoder = intel_attached_encoder(connector);
3415 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
3416 continue;
3417
3418 intel_dig_port = enc_to_dig_port(&intel_encoder->base);
Dave Airlie11bed9582014-05-12 15:22:27 +10003419 if (!intel_dig_port->dp.can_mst)
3420 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003421
Jim Bride40ae80c2016-04-14 10:18:37 -07003422 seq_printf(m, "MST Source Port %c\n",
3423 port_name(intel_dig_port->port));
Dave Airlie11bed9582014-05-12 15:22:27 +10003424 drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr);
3425 }
3426 drm_modeset_unlock_all(dev);
3427 return 0;
3428}
3429
Damien Lespiau07144422013-10-15 18:55:40 +01003430static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
Shuang He8bf1e9f2013-10-15 18:55:27 +01003431{
Damien Lespiaube5c7a92013-10-15 18:55:41 +01003432 struct pipe_crc_info *info = inode->i_private;
David Weinehall36cdd012016-08-22 13:59:31 +03003433 struct drm_i915_private *dev_priv = info->dev_priv;
Damien Lespiaube5c7a92013-10-15 18:55:41 +01003434 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
3435
David Weinehall36cdd012016-08-22 13:59:31 +03003436 if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
Daniel Vetter7eb1c492013-11-14 11:30:43 +01003437 return -ENODEV;
3438
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003439 spin_lock_irq(&pipe_crc->lock);
3440
3441 if (pipe_crc->opened) {
3442 spin_unlock_irq(&pipe_crc->lock);
Damien Lespiaube5c7a92013-10-15 18:55:41 +01003443 return -EBUSY; /* already open */
3444 }
3445
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003446 pipe_crc->opened = true;
Damien Lespiau07144422013-10-15 18:55:40 +01003447 filep->private_data = inode->i_private;
3448
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003449 spin_unlock_irq(&pipe_crc->lock);
3450
Damien Lespiau07144422013-10-15 18:55:40 +01003451 return 0;
3452}
3453
3454static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
3455{
Damien Lespiaube5c7a92013-10-15 18:55:41 +01003456 struct pipe_crc_info *info = inode->i_private;
David Weinehall36cdd012016-08-22 13:59:31 +03003457 struct drm_i915_private *dev_priv = info->dev_priv;
Damien Lespiaube5c7a92013-10-15 18:55:41 +01003458 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
3459
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003460 spin_lock_irq(&pipe_crc->lock);
3461 pipe_crc->opened = false;
3462 spin_unlock_irq(&pipe_crc->lock);
Damien Lespiaube5c7a92013-10-15 18:55:41 +01003463
Damien Lespiau07144422013-10-15 18:55:40 +01003464 return 0;
3465}
3466
3467/* (6 fields, 8 chars each, space separated (5) + '\n') */
3468#define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1)
3469/* account for \'0' */
3470#define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1)
3471
3472static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
3473{
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003474 assert_spin_locked(&pipe_crc->lock);
3475 return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
3476 INTEL_PIPE_CRC_ENTRIES_NR);
Damien Lespiau07144422013-10-15 18:55:40 +01003477}
Shuang He8bf1e9f2013-10-15 18:55:27 +01003478
Damien Lespiau07144422013-10-15 18:55:40 +01003479static ssize_t
3480i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
3481 loff_t *pos)
3482{
3483 struct pipe_crc_info *info = filep->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03003484 struct drm_i915_private *dev_priv = info->dev_priv;
Damien Lespiau07144422013-10-15 18:55:40 +01003485 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
3486 char buf[PIPE_CRC_BUFFER_LEN];
Ville Syrjälä9ad6d992014-12-09 21:28:32 +02003487 int n_entries;
Damien Lespiau07144422013-10-15 18:55:40 +01003488 ssize_t bytes_read;
3489
3490 /*
3491 * Don't allow user space to provide buffers not big enough to hold
3492 * a line of data.
3493 */
3494 if (count < PIPE_CRC_LINE_LEN)
3495 return -EINVAL;
3496
3497 if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
3498 return 0;
3499
3500 /* nothing to read */
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003501 spin_lock_irq(&pipe_crc->lock);
Damien Lespiau07144422013-10-15 18:55:40 +01003502 while (pipe_crc_data_count(pipe_crc) == 0) {
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003503 int ret;
Damien Lespiau07144422013-10-15 18:55:40 +01003504
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003505 if (filep->f_flags & O_NONBLOCK) {
3506 spin_unlock_irq(&pipe_crc->lock);
3507 return -EAGAIN;
3508 }
3509
3510 ret = wait_event_interruptible_lock_irq(pipe_crc->wq,
3511 pipe_crc_data_count(pipe_crc), pipe_crc->lock);
3512 if (ret) {
3513 spin_unlock_irq(&pipe_crc->lock);
3514 return ret;
3515 }
Damien Lespiau07144422013-10-15 18:55:40 +01003516 }
3517
3518 /* We now have one or more entries to read */
Ville Syrjälä9ad6d992014-12-09 21:28:32 +02003519 n_entries = count / PIPE_CRC_LINE_LEN;
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003520
Damien Lespiau07144422013-10-15 18:55:40 +01003521 bytes_read = 0;
Ville Syrjälä9ad6d992014-12-09 21:28:32 +02003522 while (n_entries > 0) {
3523 struct intel_pipe_crc_entry *entry =
3524 &pipe_crc->entries[pipe_crc->tail];
Damien Lespiau07144422013-10-15 18:55:40 +01003525
Ville Syrjälä9ad6d992014-12-09 21:28:32 +02003526 if (CIRC_CNT(pipe_crc->head, pipe_crc->tail,
3527 INTEL_PIPE_CRC_ENTRIES_NR) < 1)
3528 break;
3529
3530 BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR);
3531 pipe_crc->tail = (pipe_crc->tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
3532
Damien Lespiau07144422013-10-15 18:55:40 +01003533 bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN,
3534 "%8u %8x %8x %8x %8x %8x\n",
3535 entry->frame, entry->crc[0],
3536 entry->crc[1], entry->crc[2],
3537 entry->crc[3], entry->crc[4]);
3538
Ville Syrjälä9ad6d992014-12-09 21:28:32 +02003539 spin_unlock_irq(&pipe_crc->lock);
3540
Rodrigo Vivi4e9121e2016-08-03 08:22:57 -07003541 if (copy_to_user(user_buf, buf, PIPE_CRC_LINE_LEN))
Damien Lespiau07144422013-10-15 18:55:40 +01003542 return -EFAULT;
Damien Lespiaub2c88f52013-10-15 18:55:29 +01003543
Ville Syrjälä9ad6d992014-12-09 21:28:32 +02003544 user_buf += PIPE_CRC_LINE_LEN;
3545 n_entries--;
Shuang He8bf1e9f2013-10-15 18:55:27 +01003546
Ville Syrjälä9ad6d992014-12-09 21:28:32 +02003547 spin_lock_irq(&pipe_crc->lock);
3548 }
3549
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003550 spin_unlock_irq(&pipe_crc->lock);
3551
Damien Lespiau07144422013-10-15 18:55:40 +01003552 return bytes_read;
3553}
3554
3555static const struct file_operations i915_pipe_crc_fops = {
3556 .owner = THIS_MODULE,
3557 .open = i915_pipe_crc_open,
3558 .read = i915_pipe_crc_read,
3559 .release = i915_pipe_crc_release,
3560};
3561
3562static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = {
3563 {
3564 .name = "i915_pipe_A_crc",
3565 .pipe = PIPE_A,
3566 },
3567 {
3568 .name = "i915_pipe_B_crc",
3569 .pipe = PIPE_B,
3570 },
3571 {
3572 .name = "i915_pipe_C_crc",
3573 .pipe = PIPE_C,
3574 },
3575};
3576
3577static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor,
3578 enum pipe pipe)
3579{
David Weinehall36cdd012016-08-22 13:59:31 +03003580 struct drm_i915_private *dev_priv = to_i915(minor->dev);
Damien Lespiau07144422013-10-15 18:55:40 +01003581 struct dentry *ent;
3582 struct pipe_crc_info *info = &i915_pipe_crc_data[pipe];
3583
David Weinehall36cdd012016-08-22 13:59:31 +03003584 info->dev_priv = dev_priv;
Damien Lespiau07144422013-10-15 18:55:40 +01003585 ent = debugfs_create_file(info->name, S_IRUGO, root, info,
3586 &i915_pipe_crc_fops);
Wei Yongjunf3c5fe92013-12-16 14:13:25 +08003587 if (!ent)
3588 return -ENOMEM;
Damien Lespiau07144422013-10-15 18:55:40 +01003589
3590 return drm_add_fake_info_node(minor, ent, info);
Shuang He8bf1e9f2013-10-15 18:55:27 +01003591}
3592
Daniel Vettere8dfcf72013-10-16 11:51:54 +02003593static const char * const pipe_crc_sources[] = {
Daniel Vetter926321d2013-10-16 13:30:34 +02003594 "none",
3595 "plane1",
3596 "plane2",
3597 "pf",
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003598 "pipe",
Daniel Vetter3d099a02013-10-16 22:55:58 +02003599 "TV",
3600 "DP-B",
3601 "DP-C",
3602 "DP-D",
Daniel Vetter46a19182013-11-01 10:50:20 +01003603 "auto",
Daniel Vetter926321d2013-10-16 13:30:34 +02003604};
3605
3606static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)
3607{
3608 BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX);
3609 return pipe_crc_sources[source];
3610}
3611
Damien Lespiaubd9db022013-10-15 18:55:36 +01003612static int display_crc_ctl_show(struct seq_file *m, void *data)
Daniel Vetter926321d2013-10-16 13:30:34 +02003613{
David Weinehall36cdd012016-08-22 13:59:31 +03003614 struct drm_i915_private *dev_priv = m->private;
Daniel Vetter926321d2013-10-16 13:30:34 +02003615 int i;
3616
3617 for (i = 0; i < I915_MAX_PIPES; i++)
3618 seq_printf(m, "%c %s\n", pipe_name(i),
3619 pipe_crc_source_name(dev_priv->pipe_crc[i].source));
3620
3621 return 0;
3622}
3623
Damien Lespiaubd9db022013-10-15 18:55:36 +01003624static int display_crc_ctl_open(struct inode *inode, struct file *file)
Daniel Vetter926321d2013-10-16 13:30:34 +02003625{
David Weinehall36cdd012016-08-22 13:59:31 +03003626 return single_open(file, display_crc_ctl_show, inode->i_private);
Daniel Vetter926321d2013-10-16 13:30:34 +02003627}
3628
Daniel Vetter46a19182013-11-01 10:50:20 +01003629static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
Daniel Vetter52f843f2013-10-21 17:26:38 +02003630 uint32_t *val)
3631{
Daniel Vetter46a19182013-11-01 10:50:20 +01003632 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
3633 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
3634
3635 switch (*source) {
Daniel Vetter52f843f2013-10-21 17:26:38 +02003636 case INTEL_PIPE_CRC_SOURCE_PIPE:
3637 *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX;
3638 break;
3639 case INTEL_PIPE_CRC_SOURCE_NONE:
3640 *val = 0;
3641 break;
3642 default:
3643 return -EINVAL;
3644 }
3645
3646 return 0;
3647}
3648
David Weinehall36cdd012016-08-22 13:59:31 +03003649static int i9xx_pipe_crc_auto_source(struct drm_i915_private *dev_priv,
3650 enum pipe pipe,
Daniel Vetter46a19182013-11-01 10:50:20 +01003651 enum intel_pipe_crc_source *source)
3652{
David Weinehall36cdd012016-08-22 13:59:31 +03003653 struct drm_device *dev = &dev_priv->drm;
Daniel Vetter46a19182013-11-01 10:50:20 +01003654 struct intel_encoder *encoder;
3655 struct intel_crtc *crtc;
Daniel Vetter26756802013-11-01 10:50:23 +01003656 struct intel_digital_port *dig_port;
Daniel Vetter46a19182013-11-01 10:50:20 +01003657 int ret = 0;
3658
3659 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
3660
Daniel Vetter6e9f7982014-05-29 23:54:47 +02003661 drm_modeset_lock_all(dev);
Damien Lespiaub2784e12014-08-05 11:29:37 +01003662 for_each_intel_encoder(dev, encoder) {
Daniel Vetter46a19182013-11-01 10:50:20 +01003663 if (!encoder->base.crtc)
3664 continue;
3665
3666 crtc = to_intel_crtc(encoder->base.crtc);
3667
3668 if (crtc->pipe != pipe)
3669 continue;
3670
3671 switch (encoder->type) {
3672 case INTEL_OUTPUT_TVOUT:
3673 *source = INTEL_PIPE_CRC_SOURCE_TV;
3674 break;
Ville Syrjäläcca05022016-06-22 21:57:06 +03003675 case INTEL_OUTPUT_DP:
Daniel Vetter46a19182013-11-01 10:50:20 +01003676 case INTEL_OUTPUT_EDP:
Daniel Vetter26756802013-11-01 10:50:23 +01003677 dig_port = enc_to_dig_port(&encoder->base);
3678 switch (dig_port->port) {
3679 case PORT_B:
3680 *source = INTEL_PIPE_CRC_SOURCE_DP_B;
3681 break;
3682 case PORT_C:
3683 *source = INTEL_PIPE_CRC_SOURCE_DP_C;
3684 break;
3685 case PORT_D:
3686 *source = INTEL_PIPE_CRC_SOURCE_DP_D;
3687 break;
3688 default:
3689 WARN(1, "nonexisting DP port %c\n",
3690 port_name(dig_port->port));
3691 break;
3692 }
Daniel Vetter46a19182013-11-01 10:50:20 +01003693 break;
Paulo Zanoni6847d712014-10-27 17:47:52 -02003694 default:
3695 break;
Daniel Vetter46a19182013-11-01 10:50:20 +01003696 }
3697 }
Daniel Vetter6e9f7982014-05-29 23:54:47 +02003698 drm_modeset_unlock_all(dev);
Daniel Vetter46a19182013-11-01 10:50:20 +01003699
3700 return ret;
3701}
3702
David Weinehall36cdd012016-08-22 13:59:31 +03003703static int vlv_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,
Daniel Vetter46a19182013-11-01 10:50:20 +01003704 enum pipe pipe,
3705 enum intel_pipe_crc_source *source,
Daniel Vetter7ac01292013-10-18 16:37:06 +02003706 uint32_t *val)
3707{
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003708 bool need_stable_symbols = false;
3709
Daniel Vetter46a19182013-11-01 10:50:20 +01003710 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) {
David Weinehall36cdd012016-08-22 13:59:31 +03003711 int ret = i9xx_pipe_crc_auto_source(dev_priv, pipe, source);
Daniel Vetter46a19182013-11-01 10:50:20 +01003712 if (ret)
3713 return ret;
3714 }
3715
3716 switch (*source) {
Daniel Vetter7ac01292013-10-18 16:37:06 +02003717 case INTEL_PIPE_CRC_SOURCE_PIPE:
3718 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV;
3719 break;
3720 case INTEL_PIPE_CRC_SOURCE_DP_B:
3721 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV;
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003722 need_stable_symbols = true;
Daniel Vetter7ac01292013-10-18 16:37:06 +02003723 break;
3724 case INTEL_PIPE_CRC_SOURCE_DP_C:
3725 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV;
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003726 need_stable_symbols = true;
Daniel Vetter7ac01292013-10-18 16:37:06 +02003727 break;
Ville Syrjälä2be57922014-12-09 21:28:29 +02003728 case INTEL_PIPE_CRC_SOURCE_DP_D:
David Weinehall36cdd012016-08-22 13:59:31 +03003729 if (!IS_CHERRYVIEW(dev_priv))
Ville Syrjälä2be57922014-12-09 21:28:29 +02003730 return -EINVAL;
3731 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_VLV;
3732 need_stable_symbols = true;
3733 break;
Daniel Vetter7ac01292013-10-18 16:37:06 +02003734 case INTEL_PIPE_CRC_SOURCE_NONE:
3735 *val = 0;
3736 break;
3737 default:
3738 return -EINVAL;
3739 }
3740
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003741 /*
3742 * When the pipe CRC tap point is after the transcoders we need
3743 * to tweak symbol-level features to produce a deterministic series of
3744 * symbols for a given frame. We need to reset those features only once
3745 * a frame (instead of every nth symbol):
3746 * - DC-balance: used to ensure a better clock recovery from the data
3747 * link (SDVO)
3748 * - DisplayPort scrambling: used for EMI reduction
3749 */
3750 if (need_stable_symbols) {
3751 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
3752
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003753 tmp |= DC_BALANCE_RESET_VLV;
Ville Syrjäläeb736672014-12-09 21:28:28 +02003754 switch (pipe) {
3755 case PIPE_A:
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003756 tmp |= PIPE_A_SCRAMBLE_RESET;
Ville Syrjäläeb736672014-12-09 21:28:28 +02003757 break;
3758 case PIPE_B:
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003759 tmp |= PIPE_B_SCRAMBLE_RESET;
Ville Syrjäläeb736672014-12-09 21:28:28 +02003760 break;
3761 case PIPE_C:
3762 tmp |= PIPE_C_SCRAMBLE_RESET;
3763 break;
3764 default:
3765 return -EINVAL;
3766 }
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003767 I915_WRITE(PORT_DFT2_G4X, tmp);
3768 }
3769
Daniel Vetter7ac01292013-10-18 16:37:06 +02003770 return 0;
3771}
3772
David Weinehall36cdd012016-08-22 13:59:31 +03003773static int i9xx_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,
Daniel Vetter46a19182013-11-01 10:50:20 +01003774 enum pipe pipe,
3775 enum intel_pipe_crc_source *source,
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02003776 uint32_t *val)
3777{
Daniel Vetter84093602013-11-01 10:50:21 +01003778 bool need_stable_symbols = false;
3779
Daniel Vetter46a19182013-11-01 10:50:20 +01003780 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) {
David Weinehall36cdd012016-08-22 13:59:31 +03003781 int ret = i9xx_pipe_crc_auto_source(dev_priv, pipe, source);
Daniel Vetter46a19182013-11-01 10:50:20 +01003782 if (ret)
3783 return ret;
3784 }
3785
3786 switch (*source) {
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02003787 case INTEL_PIPE_CRC_SOURCE_PIPE:
3788 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX;
3789 break;
3790 case INTEL_PIPE_CRC_SOURCE_TV:
David Weinehall36cdd012016-08-22 13:59:31 +03003791 if (!SUPPORTS_TV(dev_priv))
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02003792 return -EINVAL;
3793 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE;
3794 break;
3795 case INTEL_PIPE_CRC_SOURCE_DP_B:
David Weinehall36cdd012016-08-22 13:59:31 +03003796 if (!IS_G4X(dev_priv))
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02003797 return -EINVAL;
3798 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X;
Daniel Vetter84093602013-11-01 10:50:21 +01003799 need_stable_symbols = true;
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02003800 break;
3801 case INTEL_PIPE_CRC_SOURCE_DP_C:
David Weinehall36cdd012016-08-22 13:59:31 +03003802 if (!IS_G4X(dev_priv))
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02003803 return -EINVAL;
3804 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X;
Daniel Vetter84093602013-11-01 10:50:21 +01003805 need_stable_symbols = true;
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02003806 break;
3807 case INTEL_PIPE_CRC_SOURCE_DP_D:
David Weinehall36cdd012016-08-22 13:59:31 +03003808 if (!IS_G4X(dev_priv))
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02003809 return -EINVAL;
3810 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X;
Daniel Vetter84093602013-11-01 10:50:21 +01003811 need_stable_symbols = true;
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02003812 break;
3813 case INTEL_PIPE_CRC_SOURCE_NONE:
3814 *val = 0;
3815 break;
3816 default:
3817 return -EINVAL;
3818 }
3819
Daniel Vetter84093602013-11-01 10:50:21 +01003820 /*
3821 * When the pipe CRC tap point is after the transcoders we need
3822 * to tweak symbol-level features to produce a deterministic series of
3823 * symbols for a given frame. We need to reset those features only once
3824 * a frame (instead of every nth symbol):
3825 * - DC-balance: used to ensure a better clock recovery from the data
3826 * link (SDVO)
3827 * - DisplayPort scrambling: used for EMI reduction
3828 */
3829 if (need_stable_symbols) {
3830 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
3831
David Weinehall36cdd012016-08-22 13:59:31 +03003832 WARN_ON(!IS_G4X(dev_priv));
Daniel Vetter84093602013-11-01 10:50:21 +01003833
3834 I915_WRITE(PORT_DFT_I9XX,
3835 I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET);
3836
3837 if (pipe == PIPE_A)
3838 tmp |= PIPE_A_SCRAMBLE_RESET;
3839 else
3840 tmp |= PIPE_B_SCRAMBLE_RESET;
3841
3842 I915_WRITE(PORT_DFT2_G4X, tmp);
3843 }
3844
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02003845 return 0;
3846}
3847
David Weinehall36cdd012016-08-22 13:59:31 +03003848static void vlv_undo_pipe_scramble_reset(struct drm_i915_private *dev_priv,
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003849 enum pipe pipe)
3850{
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003851 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
3852
Ville Syrjäläeb736672014-12-09 21:28:28 +02003853 switch (pipe) {
3854 case PIPE_A:
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003855 tmp &= ~PIPE_A_SCRAMBLE_RESET;
Ville Syrjäläeb736672014-12-09 21:28:28 +02003856 break;
3857 case PIPE_B:
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003858 tmp &= ~PIPE_B_SCRAMBLE_RESET;
Ville Syrjäläeb736672014-12-09 21:28:28 +02003859 break;
3860 case PIPE_C:
3861 tmp &= ~PIPE_C_SCRAMBLE_RESET;
3862 break;
3863 default:
3864 return;
3865 }
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01003866 if (!(tmp & PIPE_SCRAMBLE_RESET_MASK))
3867 tmp &= ~DC_BALANCE_RESET_VLV;
3868 I915_WRITE(PORT_DFT2_G4X, tmp);
3869
3870}
3871
David Weinehall36cdd012016-08-22 13:59:31 +03003872static void g4x_undo_pipe_scramble_reset(struct drm_i915_private *dev_priv,
Daniel Vetter84093602013-11-01 10:50:21 +01003873 enum pipe pipe)
3874{
Daniel Vetter84093602013-11-01 10:50:21 +01003875 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
3876
3877 if (pipe == PIPE_A)
3878 tmp &= ~PIPE_A_SCRAMBLE_RESET;
3879 else
3880 tmp &= ~PIPE_B_SCRAMBLE_RESET;
3881 I915_WRITE(PORT_DFT2_G4X, tmp);
3882
3883 if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) {
3884 I915_WRITE(PORT_DFT_I9XX,
3885 I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET);
3886 }
3887}
3888
Daniel Vetter46a19182013-11-01 10:50:20 +01003889static int ilk_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003890 uint32_t *val)
3891{
Daniel Vetter46a19182013-11-01 10:50:20 +01003892 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
3893 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
3894
3895 switch (*source) {
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003896 case INTEL_PIPE_CRC_SOURCE_PLANE1:
3897 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK;
3898 break;
3899 case INTEL_PIPE_CRC_SOURCE_PLANE2:
3900 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK;
3901 break;
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003902 case INTEL_PIPE_CRC_SOURCE_PIPE:
3903 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK;
3904 break;
Daniel Vetter3d099a02013-10-16 22:55:58 +02003905 case INTEL_PIPE_CRC_SOURCE_NONE:
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003906 *val = 0;
3907 break;
Daniel Vetter3d099a02013-10-16 22:55:58 +02003908 default:
3909 return -EINVAL;
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003910 }
3911
3912 return 0;
3913}
3914
David Weinehall36cdd012016-08-22 13:59:31 +03003915static void hsw_trans_edp_pipe_A_crc_wa(struct drm_i915_private *dev_priv,
3916 bool enable)
Daniel Vetterfabf6e52014-05-29 14:10:22 +02003917{
David Weinehall36cdd012016-08-22 13:59:31 +03003918 struct drm_device *dev = &dev_priv->drm;
Daniel Vetterfabf6e52014-05-29 14:10:22 +02003919 struct intel_crtc *crtc =
3920 to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]);
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003921 struct intel_crtc_state *pipe_config;
Maarten Lankhorstc4e2d042015-08-05 12:36:59 +02003922 struct drm_atomic_state *state;
3923 int ret = 0;
Daniel Vetterfabf6e52014-05-29 14:10:22 +02003924
3925 drm_modeset_lock_all(dev);
Maarten Lankhorstc4e2d042015-08-05 12:36:59 +02003926 state = drm_atomic_state_alloc(dev);
3927 if (!state) {
3928 ret = -ENOMEM;
3929 goto out;
3930 }
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003931
Maarten Lankhorstc4e2d042015-08-05 12:36:59 +02003932 state->acquire_ctx = drm_modeset_legacy_acquire_ctx(&crtc->base);
3933 pipe_config = intel_atomic_get_crtc_state(state, crtc);
3934 if (IS_ERR(pipe_config)) {
3935 ret = PTR_ERR(pipe_config);
3936 goto out;
3937 }
3938
3939 pipe_config->pch_pfit.force_thru = enable;
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003940 if (pipe_config->cpu_transcoder == TRANSCODER_EDP &&
Maarten Lankhorstc4e2d042015-08-05 12:36:59 +02003941 pipe_config->pch_pfit.enabled != enable)
3942 pipe_config->base.connectors_changed = true;
Maarten Lankhorst1b509252015-06-01 12:49:48 +02003943
Maarten Lankhorstc4e2d042015-08-05 12:36:59 +02003944 ret = drm_atomic_commit(state);
3945out:
Daniel Vetterfabf6e52014-05-29 14:10:22 +02003946 drm_modeset_unlock_all(dev);
Maarten Lankhorstc4e2d042015-08-05 12:36:59 +02003947 WARN(ret, "Toggling workaround to %i returns %i\n", enable, ret);
3948 if (ret)
3949 drm_atomic_state_free(state);
Daniel Vetterfabf6e52014-05-29 14:10:22 +02003950}
3951
David Weinehall36cdd012016-08-22 13:59:31 +03003952static int ivb_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,
Daniel Vetterfabf6e52014-05-29 14:10:22 +02003953 enum pipe pipe,
3954 enum intel_pipe_crc_source *source,
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003955 uint32_t *val)
3956{
Daniel Vetter46a19182013-11-01 10:50:20 +01003957 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
3958 *source = INTEL_PIPE_CRC_SOURCE_PF;
3959
3960 switch (*source) {
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003961 case INTEL_PIPE_CRC_SOURCE_PLANE1:
3962 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB;
3963 break;
3964 case INTEL_PIPE_CRC_SOURCE_PLANE2:
3965 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB;
3966 break;
3967 case INTEL_PIPE_CRC_SOURCE_PF:
David Weinehall36cdd012016-08-22 13:59:31 +03003968 if (IS_HASWELL(dev_priv) && pipe == PIPE_A)
3969 hsw_trans_edp_pipe_A_crc_wa(dev_priv, true);
Daniel Vetterfabf6e52014-05-29 14:10:22 +02003970
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003971 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB;
3972 break;
Daniel Vetter3d099a02013-10-16 22:55:58 +02003973 case INTEL_PIPE_CRC_SOURCE_NONE:
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003974 *val = 0;
3975 break;
Daniel Vetter3d099a02013-10-16 22:55:58 +02003976 default:
3977 return -EINVAL;
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003978 }
3979
3980 return 0;
3981}
3982
David Weinehall36cdd012016-08-22 13:59:31 +03003983static int pipe_crc_set_source(struct drm_i915_private *dev_priv,
3984 enum pipe pipe,
Daniel Vetter926321d2013-10-16 13:30:34 +02003985 enum intel_pipe_crc_source source)
3986{
David Weinehall36cdd012016-08-22 13:59:31 +03003987 struct drm_device *dev = &dev_priv->drm;
Damien Lespiaucc3da172013-10-15 18:55:31 +01003988 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
David Weinehall36cdd012016-08-22 13:59:31 +03003989 struct intel_crtc *crtc =
3990 to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
Imre Deake1296492016-02-12 18:55:17 +02003991 enum intel_display_power_domain power_domain;
Borislav Petkov432f3342013-11-21 16:49:46 +01003992 u32 val = 0; /* shut up gcc */
Daniel Vetter5b3a8562013-10-16 22:55:48 +02003993 int ret;
Daniel Vetter926321d2013-10-16 13:30:34 +02003994
Damien Lespiaucc3da172013-10-15 18:55:31 +01003995 if (pipe_crc->source == source)
3996 return 0;
3997
Damien Lespiauae676fc2013-10-15 18:55:32 +01003998 /* forbid changing the source without going back to 'none' */
3999 if (pipe_crc->source && source)
4000 return -EINVAL;
4001
Imre Deake1296492016-02-12 18:55:17 +02004002 power_domain = POWER_DOMAIN_PIPE(pipe);
4003 if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) {
Daniel Vetter9d8b0582014-11-25 14:00:40 +01004004 DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n");
4005 return -EIO;
4006 }
4007
David Weinehall36cdd012016-08-22 13:59:31 +03004008 if (IS_GEN2(dev_priv))
Daniel Vetter46a19182013-11-01 10:50:20 +01004009 ret = i8xx_pipe_crc_ctl_reg(&source, &val);
David Weinehall36cdd012016-08-22 13:59:31 +03004010 else if (INTEL_GEN(dev_priv) < 5)
4011 ret = i9xx_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val);
4012 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
4013 ret = vlv_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val);
4014 else if (IS_GEN5(dev_priv) || IS_GEN6(dev_priv))
Daniel Vetter46a19182013-11-01 10:50:20 +01004015 ret = ilk_pipe_crc_ctl_reg(&source, &val);
Daniel Vetter5b3a8562013-10-16 22:55:48 +02004016 else
David Weinehall36cdd012016-08-22 13:59:31 +03004017 ret = ivb_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val);
Daniel Vetter5b3a8562013-10-16 22:55:48 +02004018
4019 if (ret != 0)
Imre Deake1296492016-02-12 18:55:17 +02004020 goto out;
Daniel Vetter5b3a8562013-10-16 22:55:48 +02004021
Damien Lespiau4b584362013-10-15 18:55:33 +01004022 /* none -> real source transition */
4023 if (source) {
Ville Syrjälä4252fbc2014-12-09 21:28:30 +02004024 struct intel_pipe_crc_entry *entries;
4025
Damien Lespiau7cd6ccf2013-10-15 18:55:38 +01004026 DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n",
4027 pipe_name(pipe), pipe_crc_source_name(source));
4028
Ville Syrjälä3cf54b32014-12-09 21:28:31 +02004029 entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR,
4030 sizeof(pipe_crc->entries[0]),
Ville Syrjälä4252fbc2014-12-09 21:28:30 +02004031 GFP_KERNEL);
Imre Deake1296492016-02-12 18:55:17 +02004032 if (!entries) {
4033 ret = -ENOMEM;
4034 goto out;
4035 }
Damien Lespiaue5f75ac2013-10-15 18:55:34 +01004036
Paulo Zanoni8c740dc2014-10-17 18:42:03 -03004037 /*
4038 * When IPS gets enabled, the pipe CRC changes. Since IPS gets
4039 * enabled and disabled dynamically based on package C states,
4040 * user space can't make reliable use of the CRCs, so let's just
4041 * completely disable it.
4042 */
4043 hsw_disable_ips(crtc);
4044
Damien Lespiaud538bbd2013-10-21 14:29:30 +01004045 spin_lock_irq(&pipe_crc->lock);
Daniel Vetter64387b62014-12-10 11:00:29 +01004046 kfree(pipe_crc->entries);
Ville Syrjälä4252fbc2014-12-09 21:28:30 +02004047 pipe_crc->entries = entries;
Damien Lespiaud538bbd2013-10-21 14:29:30 +01004048 pipe_crc->head = 0;
4049 pipe_crc->tail = 0;
4050 spin_unlock_irq(&pipe_crc->lock);
Damien Lespiau4b584362013-10-15 18:55:33 +01004051 }
4052
Damien Lespiaucc3da172013-10-15 18:55:31 +01004053 pipe_crc->source = source;
Daniel Vetter926321d2013-10-16 13:30:34 +02004054
Daniel Vetter926321d2013-10-16 13:30:34 +02004055 I915_WRITE(PIPE_CRC_CTL(pipe), val);
4056 POSTING_READ(PIPE_CRC_CTL(pipe));
4057
Damien Lespiaue5f75ac2013-10-15 18:55:34 +01004058 /* real source -> none transition */
4059 if (source == INTEL_PIPE_CRC_SOURCE_NONE) {
Damien Lespiaud538bbd2013-10-21 14:29:30 +01004060 struct intel_pipe_crc_entry *entries;
Daniel Vettera33d7102014-06-06 08:22:08 +02004061 struct intel_crtc *crtc =
4062 to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
Damien Lespiaud538bbd2013-10-21 14:29:30 +01004063
Damien Lespiau7cd6ccf2013-10-15 18:55:38 +01004064 DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n",
4065 pipe_name(pipe));
4066
Daniel Vettera33d7102014-06-06 08:22:08 +02004067 drm_modeset_lock(&crtc->base.mutex, NULL);
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02004068 if (crtc->base.state->active)
Daniel Vettera33d7102014-06-06 08:22:08 +02004069 intel_wait_for_vblank(dev, pipe);
4070 drm_modeset_unlock(&crtc->base.mutex);
Daniel Vetterbcf17ab2013-10-16 22:55:50 +02004071
Damien Lespiaud538bbd2013-10-21 14:29:30 +01004072 spin_lock_irq(&pipe_crc->lock);
4073 entries = pipe_crc->entries;
Damien Lespiaue5f75ac2013-10-15 18:55:34 +01004074 pipe_crc->entries = NULL;
Ville Syrjälä9ad6d992014-12-09 21:28:32 +02004075 pipe_crc->head = 0;
4076 pipe_crc->tail = 0;
Damien Lespiaud538bbd2013-10-21 14:29:30 +01004077 spin_unlock_irq(&pipe_crc->lock);
4078
4079 kfree(entries);
Daniel Vetter84093602013-11-01 10:50:21 +01004080
David Weinehall36cdd012016-08-22 13:59:31 +03004081 if (IS_G4X(dev_priv))
4082 g4x_undo_pipe_scramble_reset(dev_priv, pipe);
4083 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
4084 vlv_undo_pipe_scramble_reset(dev_priv, pipe);
4085 else if (IS_HASWELL(dev_priv) && pipe == PIPE_A)
4086 hsw_trans_edp_pipe_A_crc_wa(dev_priv, false);
Paulo Zanoni8c740dc2014-10-17 18:42:03 -03004087
4088 hsw_enable_ips(crtc);
Damien Lespiaue5f75ac2013-10-15 18:55:34 +01004089 }
4090
Imre Deake1296492016-02-12 18:55:17 +02004091 ret = 0;
4092
4093out:
4094 intel_display_power_put(dev_priv, power_domain);
4095
4096 return ret;
Daniel Vetter926321d2013-10-16 13:30:34 +02004097}
4098
4099/*
4100 * Parse pipe CRC command strings:
Damien Lespiaub94dec82013-10-15 18:55:35 +01004101 * command: wsp* object wsp+ name wsp+ source wsp*
4102 * object: 'pipe'
4103 * name: (A | B | C)
Daniel Vetter926321d2013-10-16 13:30:34 +02004104 * source: (none | plane1 | plane2 | pf)
4105 * wsp: (#0x20 | #0x9 | #0xA)+
4106 *
4107 * eg.:
Damien Lespiaub94dec82013-10-15 18:55:35 +01004108 * "pipe A plane1" -> Start CRC computations on plane1 of pipe A
4109 * "pipe A none" -> Stop CRC
Daniel Vetter926321d2013-10-16 13:30:34 +02004110 */
Damien Lespiaubd9db022013-10-15 18:55:36 +01004111static int display_crc_ctl_tokenize(char *buf, char *words[], int max_words)
Daniel Vetter926321d2013-10-16 13:30:34 +02004112{
4113 int n_words = 0;
4114
4115 while (*buf) {
4116 char *end;
4117
4118 /* skip leading white space */
4119 buf = skip_spaces(buf);
4120 if (!*buf)
4121 break; /* end of buffer */
4122
4123 /* find end of word */
4124 for (end = buf; *end && !isspace(*end); end++)
4125 ;
4126
4127 if (n_words == max_words) {
4128 DRM_DEBUG_DRIVER("too many words, allowed <= %d\n",
4129 max_words);
4130 return -EINVAL; /* ran out of words[] before bytes */
4131 }
4132
4133 if (*end)
4134 *end++ = '\0';
4135 words[n_words++] = buf;
4136 buf = end;
4137 }
4138
4139 return n_words;
4140}
4141
Damien Lespiaub94dec82013-10-15 18:55:35 +01004142enum intel_pipe_crc_object {
4143 PIPE_CRC_OBJECT_PIPE,
4144};
4145
Daniel Vettere8dfcf72013-10-16 11:51:54 +02004146static const char * const pipe_crc_objects[] = {
Damien Lespiaub94dec82013-10-15 18:55:35 +01004147 "pipe",
4148};
4149
4150static int
Damien Lespiaubd9db022013-10-15 18:55:36 +01004151display_crc_ctl_parse_object(const char *buf, enum intel_pipe_crc_object *o)
Damien Lespiaub94dec82013-10-15 18:55:35 +01004152{
4153 int i;
4154
4155 for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++)
4156 if (!strcmp(buf, pipe_crc_objects[i])) {
Damien Lespiaubd9db022013-10-15 18:55:36 +01004157 *o = i;
Damien Lespiaub94dec82013-10-15 18:55:35 +01004158 return 0;
4159 }
4160
4161 return -EINVAL;
4162}
4163
Damien Lespiaubd9db022013-10-15 18:55:36 +01004164static int display_crc_ctl_parse_pipe(const char *buf, enum pipe *pipe)
Daniel Vetter926321d2013-10-16 13:30:34 +02004165{
4166 const char name = buf[0];
4167
4168 if (name < 'A' || name >= pipe_name(I915_MAX_PIPES))
4169 return -EINVAL;
4170
4171 *pipe = name - 'A';
4172
4173 return 0;
4174}
4175
4176static int
Damien Lespiaubd9db022013-10-15 18:55:36 +01004177display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s)
Daniel Vetter926321d2013-10-16 13:30:34 +02004178{
4179 int i;
4180
4181 for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++)
4182 if (!strcmp(buf, pipe_crc_sources[i])) {
Damien Lespiaubd9db022013-10-15 18:55:36 +01004183 *s = i;
Daniel Vetter926321d2013-10-16 13:30:34 +02004184 return 0;
4185 }
4186
4187 return -EINVAL;
4188}
4189
David Weinehall36cdd012016-08-22 13:59:31 +03004190static int display_crc_ctl_parse(struct drm_i915_private *dev_priv,
4191 char *buf, size_t len)
Daniel Vetter926321d2013-10-16 13:30:34 +02004192{
Damien Lespiaub94dec82013-10-15 18:55:35 +01004193#define N_WORDS 3
Daniel Vetter926321d2013-10-16 13:30:34 +02004194 int n_words;
Damien Lespiaub94dec82013-10-15 18:55:35 +01004195 char *words[N_WORDS];
Daniel Vetter926321d2013-10-16 13:30:34 +02004196 enum pipe pipe;
Damien Lespiaub94dec82013-10-15 18:55:35 +01004197 enum intel_pipe_crc_object object;
Daniel Vetter926321d2013-10-16 13:30:34 +02004198 enum intel_pipe_crc_source source;
4199
Damien Lespiaubd9db022013-10-15 18:55:36 +01004200 n_words = display_crc_ctl_tokenize(buf, words, N_WORDS);
Damien Lespiaub94dec82013-10-15 18:55:35 +01004201 if (n_words != N_WORDS) {
4202 DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n",
4203 N_WORDS);
Daniel Vetter926321d2013-10-16 13:30:34 +02004204 return -EINVAL;
4205 }
4206
Damien Lespiaubd9db022013-10-15 18:55:36 +01004207 if (display_crc_ctl_parse_object(words[0], &object) < 0) {
Damien Lespiaub94dec82013-10-15 18:55:35 +01004208 DRM_DEBUG_DRIVER("unknown object %s\n", words[0]);
Daniel Vetter926321d2013-10-16 13:30:34 +02004209 return -EINVAL;
4210 }
4211
Damien Lespiaubd9db022013-10-15 18:55:36 +01004212 if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) {
Damien Lespiaub94dec82013-10-15 18:55:35 +01004213 DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]);
4214 return -EINVAL;
4215 }
4216
Damien Lespiaubd9db022013-10-15 18:55:36 +01004217 if (display_crc_ctl_parse_source(words[2], &source) < 0) {
Damien Lespiaub94dec82013-10-15 18:55:35 +01004218 DRM_DEBUG_DRIVER("unknown source %s\n", words[2]);
Daniel Vetter926321d2013-10-16 13:30:34 +02004219 return -EINVAL;
4220 }
4221
David Weinehall36cdd012016-08-22 13:59:31 +03004222 return pipe_crc_set_source(dev_priv, pipe, source);
Daniel Vetter926321d2013-10-16 13:30:34 +02004223}
4224
Damien Lespiaubd9db022013-10-15 18:55:36 +01004225static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf,
4226 size_t len, loff_t *offp)
Daniel Vetter926321d2013-10-16 13:30:34 +02004227{
4228 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004229 struct drm_i915_private *dev_priv = m->private;
Daniel Vetter926321d2013-10-16 13:30:34 +02004230 char *tmpbuf;
4231 int ret;
4232
4233 if (len == 0)
4234 return 0;
4235
4236 if (len > PAGE_SIZE - 1) {
4237 DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n",
4238 PAGE_SIZE);
4239 return -E2BIG;
4240 }
4241
4242 tmpbuf = kmalloc(len + 1, GFP_KERNEL);
4243 if (!tmpbuf)
4244 return -ENOMEM;
4245
4246 if (copy_from_user(tmpbuf, ubuf, len)) {
4247 ret = -EFAULT;
4248 goto out;
4249 }
4250 tmpbuf[len] = '\0';
4251
David Weinehall36cdd012016-08-22 13:59:31 +03004252 ret = display_crc_ctl_parse(dev_priv, tmpbuf, len);
Daniel Vetter926321d2013-10-16 13:30:34 +02004253
4254out:
4255 kfree(tmpbuf);
4256 if (ret < 0)
4257 return ret;
4258
4259 *offp += len;
4260 return len;
4261}
4262
Damien Lespiaubd9db022013-10-15 18:55:36 +01004263static const struct file_operations i915_display_crc_ctl_fops = {
Daniel Vetter926321d2013-10-16 13:30:34 +02004264 .owner = THIS_MODULE,
Damien Lespiaubd9db022013-10-15 18:55:36 +01004265 .open = display_crc_ctl_open,
Daniel Vetter926321d2013-10-16 13:30:34 +02004266 .read = seq_read,
4267 .llseek = seq_lseek,
4268 .release = single_release,
Damien Lespiaubd9db022013-10-15 18:55:36 +01004269 .write = display_crc_ctl_write
Daniel Vetter926321d2013-10-16 13:30:34 +02004270};
4271
Todd Previteeb3394fa2015-04-18 00:04:19 -07004272static ssize_t i915_displayport_test_active_write(struct file *file,
David Weinehall36cdd012016-08-22 13:59:31 +03004273 const char __user *ubuf,
4274 size_t len, loff_t *offp)
Todd Previteeb3394fa2015-04-18 00:04:19 -07004275{
4276 char *input_buffer;
4277 int status = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07004278 struct drm_device *dev;
4279 struct drm_connector *connector;
4280 struct list_head *connector_list;
4281 struct intel_dp *intel_dp;
4282 int val = 0;
4283
Sudip Mukherjee9aaffa32015-07-21 17:36:45 +05304284 dev = ((struct seq_file *)file->private_data)->private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07004285
Todd Previteeb3394fa2015-04-18 00:04:19 -07004286 connector_list = &dev->mode_config.connector_list;
4287
4288 if (len == 0)
4289 return 0;
4290
4291 input_buffer = kmalloc(len + 1, GFP_KERNEL);
4292 if (!input_buffer)
4293 return -ENOMEM;
4294
4295 if (copy_from_user(input_buffer, ubuf, len)) {
4296 status = -EFAULT;
4297 goto out;
4298 }
4299
4300 input_buffer[len] = '\0';
4301 DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len);
4302
4303 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07004304 if (connector->connector_type !=
4305 DRM_MODE_CONNECTOR_DisplayPort)
4306 continue;
4307
Sudip Mukherjeeb8bb08e2015-07-21 17:36:46 +05304308 if (connector->status == connector_status_connected &&
Todd Previteeb3394fa2015-04-18 00:04:19 -07004309 connector->encoder != NULL) {
4310 intel_dp = enc_to_intel_dp(connector->encoder);
4311 status = kstrtoint(input_buffer, 10, &val);
4312 if (status < 0)
4313 goto out;
4314 DRM_DEBUG_DRIVER("Got %d for test active\n", val);
4315 /* To prevent erroneous activation of the compliance
4316 * testing code, only accept an actual value of 1 here
4317 */
4318 if (val == 1)
4319 intel_dp->compliance_test_active = 1;
4320 else
4321 intel_dp->compliance_test_active = 0;
4322 }
4323 }
4324out:
4325 kfree(input_buffer);
4326 if (status < 0)
4327 return status;
4328
4329 *offp += len;
4330 return len;
4331}
4332
4333static int i915_displayport_test_active_show(struct seq_file *m, void *data)
4334{
4335 struct drm_device *dev = m->private;
4336 struct drm_connector *connector;
4337 struct list_head *connector_list = &dev->mode_config.connector_list;
4338 struct intel_dp *intel_dp;
4339
Todd Previteeb3394fa2015-04-18 00:04:19 -07004340 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07004341 if (connector->connector_type !=
4342 DRM_MODE_CONNECTOR_DisplayPort)
4343 continue;
4344
4345 if (connector->status == connector_status_connected &&
4346 connector->encoder != NULL) {
4347 intel_dp = enc_to_intel_dp(connector->encoder);
4348 if (intel_dp->compliance_test_active)
4349 seq_puts(m, "1");
4350 else
4351 seq_puts(m, "0");
4352 } else
4353 seq_puts(m, "0");
4354 }
4355
4356 return 0;
4357}
4358
4359static int i915_displayport_test_active_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03004360 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07004361{
David Weinehall36cdd012016-08-22 13:59:31 +03004362 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07004363
David Weinehall36cdd012016-08-22 13:59:31 +03004364 return single_open(file, i915_displayport_test_active_show,
4365 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07004366}
4367
4368static const struct file_operations i915_displayport_test_active_fops = {
4369 .owner = THIS_MODULE,
4370 .open = i915_displayport_test_active_open,
4371 .read = seq_read,
4372 .llseek = seq_lseek,
4373 .release = single_release,
4374 .write = i915_displayport_test_active_write
4375};
4376
4377static int i915_displayport_test_data_show(struct seq_file *m, void *data)
4378{
4379 struct drm_device *dev = m->private;
4380 struct drm_connector *connector;
4381 struct list_head *connector_list = &dev->mode_config.connector_list;
4382 struct intel_dp *intel_dp;
4383
Todd Previteeb3394fa2015-04-18 00:04:19 -07004384 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07004385 if (connector->connector_type !=
4386 DRM_MODE_CONNECTOR_DisplayPort)
4387 continue;
4388
4389 if (connector->status == connector_status_connected &&
4390 connector->encoder != NULL) {
4391 intel_dp = enc_to_intel_dp(connector->encoder);
4392 seq_printf(m, "%lx", intel_dp->compliance_test_data);
4393 } else
4394 seq_puts(m, "0");
4395 }
4396
4397 return 0;
4398}
4399static int i915_displayport_test_data_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03004400 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07004401{
David Weinehall36cdd012016-08-22 13:59:31 +03004402 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07004403
David Weinehall36cdd012016-08-22 13:59:31 +03004404 return single_open(file, i915_displayport_test_data_show,
4405 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07004406}
4407
4408static const struct file_operations i915_displayport_test_data_fops = {
4409 .owner = THIS_MODULE,
4410 .open = i915_displayport_test_data_open,
4411 .read = seq_read,
4412 .llseek = seq_lseek,
4413 .release = single_release
4414};
4415
4416static int i915_displayport_test_type_show(struct seq_file *m, void *data)
4417{
4418 struct drm_device *dev = m->private;
4419 struct drm_connector *connector;
4420 struct list_head *connector_list = &dev->mode_config.connector_list;
4421 struct intel_dp *intel_dp;
4422
Todd Previteeb3394fa2015-04-18 00:04:19 -07004423 list_for_each_entry(connector, connector_list, head) {
Todd Previteeb3394fa2015-04-18 00:04:19 -07004424 if (connector->connector_type !=
4425 DRM_MODE_CONNECTOR_DisplayPort)
4426 continue;
4427
4428 if (connector->status == connector_status_connected &&
4429 connector->encoder != NULL) {
4430 intel_dp = enc_to_intel_dp(connector->encoder);
4431 seq_printf(m, "%02lx", intel_dp->compliance_test_type);
4432 } else
4433 seq_puts(m, "0");
4434 }
4435
4436 return 0;
4437}
4438
4439static int i915_displayport_test_type_open(struct inode *inode,
4440 struct file *file)
4441{
David Weinehall36cdd012016-08-22 13:59:31 +03004442 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07004443
David Weinehall36cdd012016-08-22 13:59:31 +03004444 return single_open(file, i915_displayport_test_type_show,
4445 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07004446}
4447
4448static const struct file_operations i915_displayport_test_type_fops = {
4449 .owner = THIS_MODULE,
4450 .open = i915_displayport_test_type_open,
4451 .read = seq_read,
4452 .llseek = seq_lseek,
4453 .release = single_release
4454};
4455
Damien Lespiau97e94b22014-11-04 17:06:50 +00004456static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02004457{
David Weinehall36cdd012016-08-22 13:59:31 +03004458 struct drm_i915_private *dev_priv = m->private;
4459 struct drm_device *dev = &dev_priv->drm;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004460 int level;
Ville Syrjäläde38b952015-06-24 22:00:09 +03004461 int num_levels;
4462
David Weinehall36cdd012016-08-22 13:59:31 +03004463 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03004464 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03004465 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03004466 num_levels = 1;
4467 else
4468 num_levels = ilk_wm_max_level(dev) + 1;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004469
4470 drm_modeset_lock_all(dev);
4471
4472 for (level = 0; level < num_levels; level++) {
4473 unsigned int latency = wm[level];
4474
Damien Lespiau97e94b22014-11-04 17:06:50 +00004475 /*
4476 * - WM1+ latency values in 0.5us units
Ville Syrjäläde38b952015-06-24 22:00:09 +03004477 * - latencies are in us on gen9/vlv/chv
Damien Lespiau97e94b22014-11-04 17:06:50 +00004478 */
David Weinehall36cdd012016-08-22 13:59:31 +03004479 if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) ||
4480 IS_CHERRYVIEW(dev_priv))
Damien Lespiau97e94b22014-11-04 17:06:50 +00004481 latency *= 10;
4482 else if (level > 0)
Ville Syrjälä369a1342014-01-22 14:36:08 +02004483 latency *= 5;
4484
4485 seq_printf(m, "WM%d %u (%u.%u usec)\n",
Damien Lespiau97e94b22014-11-04 17:06:50 +00004486 level, wm[level], latency / 10, latency % 10);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004487 }
4488
4489 drm_modeset_unlock_all(dev);
4490}
4491
4492static int pri_wm_latency_show(struct seq_file *m, void *data)
4493{
David Weinehall36cdd012016-08-22 13:59:31 +03004494 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004495 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004496
David Weinehall36cdd012016-08-22 13:59:31 +03004497 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004498 latencies = dev_priv->wm.skl_latency;
4499 else
David Weinehall36cdd012016-08-22 13:59:31 +03004500 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004501
4502 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004503
4504 return 0;
4505}
4506
4507static int spr_wm_latency_show(struct seq_file *m, void *data)
4508{
David Weinehall36cdd012016-08-22 13:59:31 +03004509 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004510 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004511
David Weinehall36cdd012016-08-22 13:59:31 +03004512 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004513 latencies = dev_priv->wm.skl_latency;
4514 else
David Weinehall36cdd012016-08-22 13:59:31 +03004515 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004516
4517 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004518
4519 return 0;
4520}
4521
4522static int cur_wm_latency_show(struct seq_file *m, void *data)
4523{
David Weinehall36cdd012016-08-22 13:59:31 +03004524 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004525 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004526
David Weinehall36cdd012016-08-22 13:59:31 +03004527 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004528 latencies = dev_priv->wm.skl_latency;
4529 else
David Weinehall36cdd012016-08-22 13:59:31 +03004530 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004531
4532 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004533
4534 return 0;
4535}
4536
4537static int pri_wm_latency_open(struct inode *inode, struct file *file)
4538{
David Weinehall36cdd012016-08-22 13:59:31 +03004539 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004540
David Weinehall36cdd012016-08-22 13:59:31 +03004541 if (INTEL_GEN(dev_priv) < 5)
Ville Syrjälä369a1342014-01-22 14:36:08 +02004542 return -ENODEV;
4543
David Weinehall36cdd012016-08-22 13:59:31 +03004544 return single_open(file, pri_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004545}
4546
4547static int spr_wm_latency_open(struct inode *inode, struct file *file)
4548{
David Weinehall36cdd012016-08-22 13:59:31 +03004549 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004550
David Weinehall36cdd012016-08-22 13:59:31 +03004551 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02004552 return -ENODEV;
4553
David Weinehall36cdd012016-08-22 13:59:31 +03004554 return single_open(file, spr_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004555}
4556
4557static int cur_wm_latency_open(struct inode *inode, struct file *file)
4558{
David Weinehall36cdd012016-08-22 13:59:31 +03004559 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004560
David Weinehall36cdd012016-08-22 13:59:31 +03004561 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02004562 return -ENODEV;
4563
David Weinehall36cdd012016-08-22 13:59:31 +03004564 return single_open(file, cur_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004565}
4566
4567static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
Damien Lespiau97e94b22014-11-04 17:06:50 +00004568 size_t len, loff_t *offp, uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02004569{
4570 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004571 struct drm_i915_private *dev_priv = m->private;
4572 struct drm_device *dev = &dev_priv->drm;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004573 uint16_t new[8] = { 0 };
Ville Syrjäläde38b952015-06-24 22:00:09 +03004574 int num_levels;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004575 int level;
4576 int ret;
4577 char tmp[32];
4578
David Weinehall36cdd012016-08-22 13:59:31 +03004579 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03004580 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03004581 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03004582 num_levels = 1;
4583 else
4584 num_levels = ilk_wm_max_level(dev) + 1;
4585
Ville Syrjälä369a1342014-01-22 14:36:08 +02004586 if (len >= sizeof(tmp))
4587 return -EINVAL;
4588
4589 if (copy_from_user(tmp, ubuf, len))
4590 return -EFAULT;
4591
4592 tmp[len] = '\0';
4593
Damien Lespiau97e94b22014-11-04 17:06:50 +00004594 ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
4595 &new[0], &new[1], &new[2], &new[3],
4596 &new[4], &new[5], &new[6], &new[7]);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004597 if (ret != num_levels)
4598 return -EINVAL;
4599
4600 drm_modeset_lock_all(dev);
4601
4602 for (level = 0; level < num_levels; level++)
4603 wm[level] = new[level];
4604
4605 drm_modeset_unlock_all(dev);
4606
4607 return len;
4608}
4609
4610
4611static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
4612 size_t len, loff_t *offp)
4613{
4614 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004615 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004616 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004617
David Weinehall36cdd012016-08-22 13:59:31 +03004618 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004619 latencies = dev_priv->wm.skl_latency;
4620 else
David Weinehall36cdd012016-08-22 13:59:31 +03004621 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004622
4623 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004624}
4625
4626static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
4627 size_t len, loff_t *offp)
4628{
4629 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004630 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004631 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004632
David Weinehall36cdd012016-08-22 13:59:31 +03004633 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004634 latencies = dev_priv->wm.skl_latency;
4635 else
David Weinehall36cdd012016-08-22 13:59:31 +03004636 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004637
4638 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004639}
4640
4641static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
4642 size_t len, loff_t *offp)
4643{
4644 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004645 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004646 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004647
David Weinehall36cdd012016-08-22 13:59:31 +03004648 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004649 latencies = dev_priv->wm.skl_latency;
4650 else
David Weinehall36cdd012016-08-22 13:59:31 +03004651 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004652
4653 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004654}
4655
4656static const struct file_operations i915_pri_wm_latency_fops = {
4657 .owner = THIS_MODULE,
4658 .open = pri_wm_latency_open,
4659 .read = seq_read,
4660 .llseek = seq_lseek,
4661 .release = single_release,
4662 .write = pri_wm_latency_write
4663};
4664
4665static const struct file_operations i915_spr_wm_latency_fops = {
4666 .owner = THIS_MODULE,
4667 .open = spr_wm_latency_open,
4668 .read = seq_read,
4669 .llseek = seq_lseek,
4670 .release = single_release,
4671 .write = spr_wm_latency_write
4672};
4673
4674static const struct file_operations i915_cur_wm_latency_fops = {
4675 .owner = THIS_MODULE,
4676 .open = cur_wm_latency_open,
4677 .read = seq_read,
4678 .llseek = seq_lseek,
4679 .release = single_release,
4680 .write = cur_wm_latency_write
4681};
4682
Kees Cook647416f2013-03-10 14:10:06 -07004683static int
4684i915_wedged_get(void *data, u64 *val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004685{
David Weinehall36cdd012016-08-22 13:59:31 +03004686 struct drm_i915_private *dev_priv = data;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004687
Chris Wilsond98c52c2016-04-13 17:35:05 +01004688 *val = i915_terminally_wedged(&dev_priv->gpu_error);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004689
Kees Cook647416f2013-03-10 14:10:06 -07004690 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004691}
4692
Kees Cook647416f2013-03-10 14:10:06 -07004693static int
4694i915_wedged_set(void *data, u64 val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004695{
David Weinehall36cdd012016-08-22 13:59:31 +03004696 struct drm_i915_private *dev_priv = data;
Imre Deakd46c0512014-04-14 20:24:27 +03004697
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004698 /*
4699 * There is no safeguard against this debugfs entry colliding
4700 * with the hangcheck calling same i915_handle_error() in
4701 * parallel, causing an explosion. For now we assume that the
4702 * test harness is responsible enough not to inject gpu hangs
4703 * while it is writing to 'i915_wedged'
4704 */
4705
Chris Wilsond98c52c2016-04-13 17:35:05 +01004706 if (i915_reset_in_progress(&dev_priv->gpu_error))
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004707 return -EAGAIN;
4708
Imre Deakd46c0512014-04-14 20:24:27 +03004709 intel_runtime_pm_get(dev_priv);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004710
Chris Wilsonc0336662016-05-06 15:40:21 +01004711 i915_handle_error(dev_priv, val,
Mika Kuoppala58174462014-02-25 17:11:26 +02004712 "Manually setting wedged to %llu", val);
Imre Deakd46c0512014-04-14 20:24:27 +03004713
4714 intel_runtime_pm_put(dev_priv);
4715
Kees Cook647416f2013-03-10 14:10:06 -07004716 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004717}
4718
Kees Cook647416f2013-03-10 14:10:06 -07004719DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
4720 i915_wedged_get, i915_wedged_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004721 "%llu\n");
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004722
Kees Cook647416f2013-03-10 14:10:06 -07004723static int
Chris Wilson094f9a52013-09-25 17:34:55 +01004724i915_ring_missed_irq_get(void *data, u64 *val)
4725{
David Weinehall36cdd012016-08-22 13:59:31 +03004726 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004727
4728 *val = dev_priv->gpu_error.missed_irq_rings;
4729 return 0;
4730}
4731
4732static int
4733i915_ring_missed_irq_set(void *data, u64 val)
4734{
David Weinehall36cdd012016-08-22 13:59:31 +03004735 struct drm_i915_private *dev_priv = data;
4736 struct drm_device *dev = &dev_priv->drm;
Chris Wilson094f9a52013-09-25 17:34:55 +01004737 int ret;
4738
4739 /* Lock against concurrent debugfs callers */
4740 ret = mutex_lock_interruptible(&dev->struct_mutex);
4741 if (ret)
4742 return ret;
4743 dev_priv->gpu_error.missed_irq_rings = val;
4744 mutex_unlock(&dev->struct_mutex);
4745
4746 return 0;
4747}
4748
4749DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops,
4750 i915_ring_missed_irq_get, i915_ring_missed_irq_set,
4751 "0x%08llx\n");
4752
4753static int
4754i915_ring_test_irq_get(void *data, u64 *val)
4755{
David Weinehall36cdd012016-08-22 13:59:31 +03004756 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004757
4758 *val = dev_priv->gpu_error.test_irq_rings;
4759
4760 return 0;
4761}
4762
4763static int
4764i915_ring_test_irq_set(void *data, u64 val)
4765{
David Weinehall36cdd012016-08-22 13:59:31 +03004766 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004767
Chris Wilson3a122c22016-06-17 14:35:05 +01004768 val &= INTEL_INFO(dev_priv)->ring_mask;
Chris Wilson094f9a52013-09-25 17:34:55 +01004769 DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004770 dev_priv->gpu_error.test_irq_rings = val;
Chris Wilson094f9a52013-09-25 17:34:55 +01004771
4772 return 0;
4773}
4774
4775DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops,
4776 i915_ring_test_irq_get, i915_ring_test_irq_set,
4777 "0x%08llx\n");
4778
Chris Wilsondd624af2013-01-15 12:39:35 +00004779#define DROP_UNBOUND 0x1
4780#define DROP_BOUND 0x2
4781#define DROP_RETIRE 0x4
4782#define DROP_ACTIVE 0x8
4783#define DROP_ALL (DROP_UNBOUND | \
4784 DROP_BOUND | \
4785 DROP_RETIRE | \
4786 DROP_ACTIVE)
Kees Cook647416f2013-03-10 14:10:06 -07004787static int
4788i915_drop_caches_get(void *data, u64 *val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004789{
Kees Cook647416f2013-03-10 14:10:06 -07004790 *val = DROP_ALL;
Chris Wilsondd624af2013-01-15 12:39:35 +00004791
Kees Cook647416f2013-03-10 14:10:06 -07004792 return 0;
Chris Wilsondd624af2013-01-15 12:39:35 +00004793}
4794
Kees Cook647416f2013-03-10 14:10:06 -07004795static int
4796i915_drop_caches_set(void *data, u64 val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004797{
David Weinehall36cdd012016-08-22 13:59:31 +03004798 struct drm_i915_private *dev_priv = data;
4799 struct drm_device *dev = &dev_priv->drm;
Kees Cook647416f2013-03-10 14:10:06 -07004800 int ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004801
Ben Widawsky2f9fe5f2013-11-25 09:54:37 -08004802 DRM_DEBUG("Dropping caches: 0x%08llx\n", val);
Chris Wilsondd624af2013-01-15 12:39:35 +00004803
4804 /* No need to check and wait for gpu resets, only libdrm auto-restarts
4805 * on ioctls on -EAGAIN. */
4806 ret = mutex_lock_interruptible(&dev->struct_mutex);
4807 if (ret)
4808 return ret;
4809
4810 if (val & DROP_ACTIVE) {
Chris Wilsondcff85c2016-08-05 10:14:11 +01004811 ret = i915_gem_wait_for_idle(dev_priv, true);
Chris Wilsondd624af2013-01-15 12:39:35 +00004812 if (ret)
4813 goto unlock;
4814 }
4815
4816 if (val & (DROP_RETIRE | DROP_ACTIVE))
Chris Wilsonc0336662016-05-06 15:40:21 +01004817 i915_gem_retire_requests(dev_priv);
Chris Wilsondd624af2013-01-15 12:39:35 +00004818
Chris Wilson21ab4e72014-09-09 11:16:08 +01004819 if (val & DROP_BOUND)
4820 i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND);
Chris Wilson4ad72b72014-09-03 19:23:37 +01004821
Chris Wilson21ab4e72014-09-09 11:16:08 +01004822 if (val & DROP_UNBOUND)
4823 i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND);
Chris Wilsondd624af2013-01-15 12:39:35 +00004824
4825unlock:
4826 mutex_unlock(&dev->struct_mutex);
4827
Kees Cook647416f2013-03-10 14:10:06 -07004828 return ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004829}
4830
Kees Cook647416f2013-03-10 14:10:06 -07004831DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
4832 i915_drop_caches_get, i915_drop_caches_set,
4833 "0x%08llx\n");
Chris Wilsondd624af2013-01-15 12:39:35 +00004834
Kees Cook647416f2013-03-10 14:10:06 -07004835static int
4836i915_max_freq_get(void *data, u64 *val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004837{
David Weinehall36cdd012016-08-22 13:59:31 +03004838 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004839
David Weinehall36cdd012016-08-22 13:59:31 +03004840 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004841 return -ENODEV;
4842
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02004843 *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004844 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004845}
4846
Kees Cook647416f2013-03-10 14:10:06 -07004847static int
4848i915_max_freq_set(void *data, u64 val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004849{
David Weinehall36cdd012016-08-22 13:59:31 +03004850 struct drm_i915_private *dev_priv = data;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304851 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004852 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004853
David Weinehall36cdd012016-08-22 13:59:31 +03004854 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004855 return -ENODEV;
Jesse Barnes358733e2011-07-27 11:53:01 -07004856
Kees Cook647416f2013-03-10 14:10:06 -07004857 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val);
Jesse Barnes358733e2011-07-27 11:53:01 -07004858
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004859 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004860 if (ret)
4861 return ret;
4862
Jesse Barnes358733e2011-07-27 11:53:01 -07004863 /*
4864 * Turbo will still be enabled, but won't go above the set value.
4865 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304866 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004867
Akash Goelbc4d91f2015-02-26 16:09:47 +05304868 hw_max = dev_priv->rps.max_freq;
4869 hw_min = dev_priv->rps.min_freq;
Jesse Barnes0a073b82013-04-17 15:54:58 -07004870
Ben Widawskyb39fb292014-03-19 18:31:11 -07004871 if (val < hw_min || val > hw_max || val < dev_priv->rps.min_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004872 mutex_unlock(&dev_priv->rps.hw_lock);
4873 return -EINVAL;
4874 }
4875
Ben Widawskyb39fb292014-03-19 18:31:11 -07004876 dev_priv->rps.max_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004877
Chris Wilsondc979972016-05-10 14:10:04 +01004878 intel_set_rps(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004879
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004880 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes358733e2011-07-27 11:53:01 -07004881
Kees Cook647416f2013-03-10 14:10:06 -07004882 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004883}
4884
Kees Cook647416f2013-03-10 14:10:06 -07004885DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
4886 i915_max_freq_get, i915_max_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004887 "%llu\n");
Jesse Barnes358733e2011-07-27 11:53:01 -07004888
Kees Cook647416f2013-03-10 14:10:06 -07004889static int
4890i915_min_freq_get(void *data, u64 *val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004891{
David Weinehall36cdd012016-08-22 13:59:31 +03004892 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004893
Chris Wilson62e1baa2016-07-13 09:10:36 +01004894 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004895 return -ENODEV;
4896
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02004897 *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004898 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004899}
4900
Kees Cook647416f2013-03-10 14:10:06 -07004901static int
4902i915_min_freq_set(void *data, u64 val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004903{
David Weinehall36cdd012016-08-22 13:59:31 +03004904 struct drm_i915_private *dev_priv = data;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304905 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004906 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004907
Chris Wilson62e1baa2016-07-13 09:10:36 +01004908 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004909 return -ENODEV;
Jesse Barnes1523c312012-05-25 12:34:54 -07004910
Kees Cook647416f2013-03-10 14:10:06 -07004911 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val);
Jesse Barnes1523c312012-05-25 12:34:54 -07004912
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004913 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004914 if (ret)
4915 return ret;
4916
Jesse Barnes1523c312012-05-25 12:34:54 -07004917 /*
4918 * Turbo will still be enabled, but won't go below the set value.
4919 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304920 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004921
Akash Goelbc4d91f2015-02-26 16:09:47 +05304922 hw_max = dev_priv->rps.max_freq;
4923 hw_min = dev_priv->rps.min_freq;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004924
David Weinehall36cdd012016-08-22 13:59:31 +03004925 if (val < hw_min ||
4926 val > hw_max || val > dev_priv->rps.max_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004927 mutex_unlock(&dev_priv->rps.hw_lock);
4928 return -EINVAL;
4929 }
4930
Ben Widawskyb39fb292014-03-19 18:31:11 -07004931 dev_priv->rps.min_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004932
Chris Wilsondc979972016-05-10 14:10:04 +01004933 intel_set_rps(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004934
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004935 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes1523c312012-05-25 12:34:54 -07004936
Kees Cook647416f2013-03-10 14:10:06 -07004937 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004938}
4939
Kees Cook647416f2013-03-10 14:10:06 -07004940DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
4941 i915_min_freq_get, i915_min_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004942 "%llu\n");
Jesse Barnes1523c312012-05-25 12:34:54 -07004943
Kees Cook647416f2013-03-10 14:10:06 -07004944static int
4945i915_cache_sharing_get(void *data, u64 *val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004946{
David Weinehall36cdd012016-08-22 13:59:31 +03004947 struct drm_i915_private *dev_priv = data;
4948 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004949 u32 snpcr;
Kees Cook647416f2013-03-10 14:10:06 -07004950 int ret;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004951
David Weinehall36cdd012016-08-22 13:59:31 +03004952 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004953 return -ENODEV;
4954
Daniel Vetter22bcfc62012-08-09 15:07:02 +02004955 ret = mutex_lock_interruptible(&dev->struct_mutex);
4956 if (ret)
4957 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004958 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02004959
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004960 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004961
4962 intel_runtime_pm_put(dev_priv);
David Weinehall36cdd012016-08-22 13:59:31 +03004963 mutex_unlock(&dev->struct_mutex);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004964
Kees Cook647416f2013-03-10 14:10:06 -07004965 *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004966
Kees Cook647416f2013-03-10 14:10:06 -07004967 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004968}
4969
Kees Cook647416f2013-03-10 14:10:06 -07004970static int
4971i915_cache_sharing_set(void *data, u64 val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004972{
David Weinehall36cdd012016-08-22 13:59:31 +03004973 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004974 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004975
David Weinehall36cdd012016-08-22 13:59:31 +03004976 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004977 return -ENODEV;
4978
Kees Cook647416f2013-03-10 14:10:06 -07004979 if (val > 3)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004980 return -EINVAL;
4981
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004982 intel_runtime_pm_get(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004983 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004984
4985 /* Update the cache sharing policy here as well */
4986 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
4987 snpcr &= ~GEN6_MBC_SNPCR_MASK;
4988 snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
4989 I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
4990
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004991 intel_runtime_pm_put(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004992 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004993}
4994
Kees Cook647416f2013-03-10 14:10:06 -07004995DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops,
4996 i915_cache_sharing_get, i915_cache_sharing_set,
4997 "%llu\n");
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004998
Jeff McGee5d395252015-04-03 18:13:17 -07004999struct sseu_dev_status {
5000 unsigned int slice_total;
5001 unsigned int subslice_total;
5002 unsigned int subslice_per_slice;
5003 unsigned int eu_total;
5004 unsigned int eu_per_subslice;
5005};
5006
David Weinehall36cdd012016-08-22 13:59:31 +03005007static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv,
Jeff McGee5d395252015-04-03 18:13:17 -07005008 struct sseu_dev_status *stat)
5009{
Ville Syrjälä0a0b4572015-08-21 20:45:27 +03005010 int ss_max = 2;
Jeff McGee5d395252015-04-03 18:13:17 -07005011 int ss;
5012 u32 sig1[ss_max], sig2[ss_max];
5013
5014 sig1[0] = I915_READ(CHV_POWER_SS0_SIG1);
5015 sig1[1] = I915_READ(CHV_POWER_SS1_SIG1);
5016 sig2[0] = I915_READ(CHV_POWER_SS0_SIG2);
5017 sig2[1] = I915_READ(CHV_POWER_SS1_SIG2);
5018
5019 for (ss = 0; ss < ss_max; ss++) {
5020 unsigned int eu_cnt;
5021
5022 if (sig1[ss] & CHV_SS_PG_ENABLE)
5023 /* skip disabled subslice */
5024 continue;
5025
5026 stat->slice_total = 1;
5027 stat->subslice_per_slice++;
5028 eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) +
5029 ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) +
5030 ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) +
5031 ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2);
5032 stat->eu_total += eu_cnt;
5033 stat->eu_per_subslice = max(stat->eu_per_subslice, eu_cnt);
5034 }
5035 stat->subslice_total = stat->subslice_per_slice;
5036}
5037
David Weinehall36cdd012016-08-22 13:59:31 +03005038static void gen9_sseu_device_status(struct drm_i915_private *dev_priv,
Jeff McGee5d395252015-04-03 18:13:17 -07005039 struct sseu_dev_status *stat)
5040{
Jeff McGee1c046bc2015-04-03 18:13:18 -07005041 int s_max = 3, ss_max = 4;
Jeff McGee5d395252015-04-03 18:13:17 -07005042 int s, ss;
5043 u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2];
5044
Jeff McGee1c046bc2015-04-03 18:13:18 -07005045 /* BXT has a single slice and at most 3 subslices. */
David Weinehall36cdd012016-08-22 13:59:31 +03005046 if (IS_BROXTON(dev_priv)) {
Jeff McGee1c046bc2015-04-03 18:13:18 -07005047 s_max = 1;
5048 ss_max = 3;
5049 }
5050
5051 for (s = 0; s < s_max; s++) {
5052 s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s));
5053 eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s));
5054 eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s));
5055 }
5056
Jeff McGee5d395252015-04-03 18:13:17 -07005057 eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK |
5058 GEN9_PGCTL_SSA_EU19_ACK |
5059 GEN9_PGCTL_SSA_EU210_ACK |
5060 GEN9_PGCTL_SSA_EU311_ACK;
5061 eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK |
5062 GEN9_PGCTL_SSB_EU19_ACK |
5063 GEN9_PGCTL_SSB_EU210_ACK |
5064 GEN9_PGCTL_SSB_EU311_ACK;
5065
5066 for (s = 0; s < s_max; s++) {
Jeff McGee1c046bc2015-04-03 18:13:18 -07005067 unsigned int ss_cnt = 0;
5068
Jeff McGee5d395252015-04-03 18:13:17 -07005069 if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0)
5070 /* skip disabled slice */
5071 continue;
5072
5073 stat->slice_total++;
Jeff McGee1c046bc2015-04-03 18:13:18 -07005074
David Weinehall36cdd012016-08-22 13:59:31 +03005075 if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
5076 ss_cnt = INTEL_INFO(dev_priv)->subslice_per_slice;
Jeff McGee1c046bc2015-04-03 18:13:18 -07005077
Jeff McGee5d395252015-04-03 18:13:17 -07005078 for (ss = 0; ss < ss_max; ss++) {
5079 unsigned int eu_cnt;
5080
David Weinehall36cdd012016-08-22 13:59:31 +03005081 if (IS_BROXTON(dev_priv) &&
Jeff McGee1c046bc2015-04-03 18:13:18 -07005082 !(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss))))
5083 /* skip disabled subslice */
5084 continue;
5085
David Weinehall36cdd012016-08-22 13:59:31 +03005086 if (IS_BROXTON(dev_priv))
Jeff McGee1c046bc2015-04-03 18:13:18 -07005087 ss_cnt++;
5088
Jeff McGee5d395252015-04-03 18:13:17 -07005089 eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] &
5090 eu_mask[ss%2]);
5091 stat->eu_total += eu_cnt;
5092 stat->eu_per_subslice = max(stat->eu_per_subslice,
5093 eu_cnt);
5094 }
Jeff McGee1c046bc2015-04-03 18:13:18 -07005095
5096 stat->subslice_total += ss_cnt;
5097 stat->subslice_per_slice = max(stat->subslice_per_slice,
5098 ss_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07005099 }
5100}
5101
David Weinehall36cdd012016-08-22 13:59:31 +03005102static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv,
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02005103 struct sseu_dev_status *stat)
5104{
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02005105 u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
David Weinehall36cdd012016-08-22 13:59:31 +03005106 int s;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02005107
5108 stat->slice_total = hweight32(slice_info & GEN8_LSLICESTAT_MASK);
5109
5110 if (stat->slice_total) {
David Weinehall36cdd012016-08-22 13:59:31 +03005111 stat->subslice_per_slice = INTEL_INFO(dev_priv)->subslice_per_slice;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02005112 stat->subslice_total = stat->slice_total *
5113 stat->subslice_per_slice;
David Weinehall36cdd012016-08-22 13:59:31 +03005114 stat->eu_per_subslice = INTEL_INFO(dev_priv)->eu_per_subslice;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02005115 stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
5116
5117 /* subtract fused off EU(s) from enabled slice(s) */
5118 for (s = 0; s < stat->slice_total; s++) {
David Weinehall36cdd012016-08-22 13:59:31 +03005119 u8 subslice_7eu = INTEL_INFO(dev_priv)->subslice_7eu[s];
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02005120
5121 stat->eu_total -= hweight8(subslice_7eu);
5122 }
5123 }
5124}
5125
Jeff McGee38732182015-02-13 10:27:54 -06005126static int i915_sseu_status(struct seq_file *m, void *unused)
5127{
David Weinehall36cdd012016-08-22 13:59:31 +03005128 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jeff McGee5d395252015-04-03 18:13:17 -07005129 struct sseu_dev_status stat;
Jeff McGee38732182015-02-13 10:27:54 -06005130
David Weinehall36cdd012016-08-22 13:59:31 +03005131 if (INTEL_GEN(dev_priv) < 8)
Jeff McGee38732182015-02-13 10:27:54 -06005132 return -ENODEV;
5133
5134 seq_puts(m, "SSEU Device Info\n");
5135 seq_printf(m, " Available Slice Total: %u\n",
David Weinehall36cdd012016-08-22 13:59:31 +03005136 INTEL_INFO(dev_priv)->slice_total);
Jeff McGee38732182015-02-13 10:27:54 -06005137 seq_printf(m, " Available Subslice Total: %u\n",
David Weinehall36cdd012016-08-22 13:59:31 +03005138 INTEL_INFO(dev_priv)->subslice_total);
Jeff McGee38732182015-02-13 10:27:54 -06005139 seq_printf(m, " Available Subslice Per Slice: %u\n",
David Weinehall36cdd012016-08-22 13:59:31 +03005140 INTEL_INFO(dev_priv)->subslice_per_slice);
Jeff McGee38732182015-02-13 10:27:54 -06005141 seq_printf(m, " Available EU Total: %u\n",
David Weinehall36cdd012016-08-22 13:59:31 +03005142 INTEL_INFO(dev_priv)->eu_total);
Jeff McGee38732182015-02-13 10:27:54 -06005143 seq_printf(m, " Available EU Per Subslice: %u\n",
David Weinehall36cdd012016-08-22 13:59:31 +03005144 INTEL_INFO(dev_priv)->eu_per_subslice);
5145 seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv)));
5146 if (HAS_POOLED_EU(dev_priv))
arun.siluvery@linux.intel.com33e141e2016-06-03 06:34:33 +01005147 seq_printf(m, " Min EU in pool: %u\n",
David Weinehall36cdd012016-08-22 13:59:31 +03005148 INTEL_INFO(dev_priv)->min_eu_in_pool);
Jeff McGee38732182015-02-13 10:27:54 -06005149 seq_printf(m, " Has Slice Power Gating: %s\n",
David Weinehall36cdd012016-08-22 13:59:31 +03005150 yesno(INTEL_INFO(dev_priv)->has_slice_pg));
Jeff McGee38732182015-02-13 10:27:54 -06005151 seq_printf(m, " Has Subslice Power Gating: %s\n",
David Weinehall36cdd012016-08-22 13:59:31 +03005152 yesno(INTEL_INFO(dev_priv)->has_subslice_pg));
Jeff McGee38732182015-02-13 10:27:54 -06005153 seq_printf(m, " Has EU Power Gating: %s\n",
David Weinehall36cdd012016-08-22 13:59:31 +03005154 yesno(INTEL_INFO(dev_priv)->has_eu_pg));
Jeff McGee38732182015-02-13 10:27:54 -06005155
Jeff McGee7f992ab2015-02-13 10:27:55 -06005156 seq_puts(m, "SSEU Device Status\n");
Jeff McGee5d395252015-04-03 18:13:17 -07005157 memset(&stat, 0, sizeof(stat));
David Weinehall238010e2016-08-01 17:33:27 +03005158
5159 intel_runtime_pm_get(dev_priv);
5160
David Weinehall36cdd012016-08-22 13:59:31 +03005161 if (IS_CHERRYVIEW(dev_priv)) {
5162 cherryview_sseu_device_status(dev_priv, &stat);
5163 } else if (IS_BROADWELL(dev_priv)) {
5164 broadwell_sseu_device_status(dev_priv, &stat);
5165 } else if (INTEL_GEN(dev_priv) >= 9) {
5166 gen9_sseu_device_status(dev_priv, &stat);
Jeff McGee7f992ab2015-02-13 10:27:55 -06005167 }
David Weinehall238010e2016-08-01 17:33:27 +03005168
5169 intel_runtime_pm_put(dev_priv);
5170
Jeff McGee5d395252015-04-03 18:13:17 -07005171 seq_printf(m, " Enabled Slice Total: %u\n",
5172 stat.slice_total);
5173 seq_printf(m, " Enabled Subslice Total: %u\n",
5174 stat.subslice_total);
5175 seq_printf(m, " Enabled Subslice Per Slice: %u\n",
5176 stat.subslice_per_slice);
5177 seq_printf(m, " Enabled EU Total: %u\n",
5178 stat.eu_total);
5179 seq_printf(m, " Enabled EU Per Subslice: %u\n",
5180 stat.eu_per_subslice);
Jeff McGee7f992ab2015-02-13 10:27:55 -06005181
Jeff McGee38732182015-02-13 10:27:54 -06005182 return 0;
5183}
5184
Ben Widawsky6d794d42011-04-25 11:25:56 -07005185static int i915_forcewake_open(struct inode *inode, struct file *file)
5186{
David Weinehall36cdd012016-08-22 13:59:31 +03005187 struct drm_i915_private *dev_priv = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07005188
David Weinehall36cdd012016-08-22 13:59:31 +03005189 if (INTEL_GEN(dev_priv) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07005190 return 0;
5191
Chris Wilson6daccb02015-01-16 11:34:35 +02005192 intel_runtime_pm_get(dev_priv);
Mika Kuoppala59bad942015-01-16 11:34:40 +02005193 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
Ben Widawsky6d794d42011-04-25 11:25:56 -07005194
5195 return 0;
5196}
5197
Ben Widawskyc43b5632012-04-16 14:07:40 -07005198static int i915_forcewake_release(struct inode *inode, struct file *file)
Ben Widawsky6d794d42011-04-25 11:25:56 -07005199{
David Weinehall36cdd012016-08-22 13:59:31 +03005200 struct drm_i915_private *dev_priv = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07005201
David Weinehall36cdd012016-08-22 13:59:31 +03005202 if (INTEL_GEN(dev_priv) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07005203 return 0;
5204
Mika Kuoppala59bad942015-01-16 11:34:40 +02005205 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Chris Wilson6daccb02015-01-16 11:34:35 +02005206 intel_runtime_pm_put(dev_priv);
Ben Widawsky6d794d42011-04-25 11:25:56 -07005207
5208 return 0;
5209}
5210
5211static const struct file_operations i915_forcewake_fops = {
5212 .owner = THIS_MODULE,
5213 .open = i915_forcewake_open,
5214 .release = i915_forcewake_release,
5215};
5216
5217static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
5218{
Ben Widawsky6d794d42011-04-25 11:25:56 -07005219 struct dentry *ent;
5220
5221 ent = debugfs_create_file("i915_forcewake_user",
Ben Widawsky8eb57292011-05-11 15:10:58 -07005222 S_IRUSR,
David Weinehall36cdd012016-08-22 13:59:31 +03005223 root, to_i915(minor->dev),
Ben Widawsky6d794d42011-04-25 11:25:56 -07005224 &i915_forcewake_fops);
Wei Yongjunf3c5fe92013-12-16 14:13:25 +08005225 if (!ent)
5226 return -ENOMEM;
Ben Widawsky6d794d42011-04-25 11:25:56 -07005227
Ben Widawsky8eb57292011-05-11 15:10:58 -07005228 return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
Ben Widawsky6d794d42011-04-25 11:25:56 -07005229}
5230
Daniel Vetter6a9c3082011-12-14 13:57:11 +01005231static int i915_debugfs_create(struct dentry *root,
5232 struct drm_minor *minor,
5233 const char *name,
5234 const struct file_operations *fops)
Jesse Barnes358733e2011-07-27 11:53:01 -07005235{
Jesse Barnes358733e2011-07-27 11:53:01 -07005236 struct dentry *ent;
5237
Daniel Vetter6a9c3082011-12-14 13:57:11 +01005238 ent = debugfs_create_file(name,
Jesse Barnes358733e2011-07-27 11:53:01 -07005239 S_IRUGO | S_IWUSR,
David Weinehall36cdd012016-08-22 13:59:31 +03005240 root, to_i915(minor->dev),
Daniel Vetter6a9c3082011-12-14 13:57:11 +01005241 fops);
Wei Yongjunf3c5fe92013-12-16 14:13:25 +08005242 if (!ent)
5243 return -ENOMEM;
Jesse Barnes358733e2011-07-27 11:53:01 -07005244
Daniel Vetter6a9c3082011-12-14 13:57:11 +01005245 return drm_add_fake_info_node(minor, ent, fops);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07005246}
5247
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01005248static const struct drm_info_list i915_debugfs_list[] = {
Chris Wilson311bd682011-01-13 19:06:50 +00005249 {"i915_capabilities", i915_capabilities, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01005250 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson08c18322011-01-10 00:00:24 +00005251 {"i915_gem_gtt", i915_gem_gtt_info, 0},
Chris Wilson6da84822016-08-15 10:48:44 +01005252 {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1},
Chris Wilson6d2b8882013-08-07 18:30:54 +01005253 {"i915_gem_stolen", i915_gem_stolen_list_info },
Simon Farnsworth4e5359c2010-09-01 17:47:52 +01005254 {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05005255 {"i915_gem_request", i915_gem_request_info, 0},
5256 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00005257 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05005258 {"i915_gem_interrupt", i915_interrupt_info, 0},
Chris Wilson1ec14ad2010-12-04 11:30:53 +00005259 {"i915_gem_hws", i915_hws_info, 0, (void *)RCS},
5260 {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS},
5261 {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS},
Xiang, Haihao9010ebf2013-05-29 09:22:36 -07005262 {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS},
Brad Volkin493018d2014-12-11 12:13:08 -08005263 {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0},
Dave Gordon8b417c22015-08-12 15:43:44 +01005264 {"i915_guc_info", i915_guc_info, 0},
Alex Daifdf5d352015-08-12 15:43:37 +01005265 {"i915_guc_load_status", i915_guc_load_status_info, 0},
Alex Dai4c7e77f2015-08-12 15:43:40 +01005266 {"i915_guc_log_dump", i915_guc_log_dump, 0},
Deepak Sadb4bd12014-03-31 11:30:02 +05305267 {"i915_frequency_info", i915_frequency_info, 0},
Chris Wilsonf654449a2015-01-26 18:03:04 +02005268 {"i915_hangcheck_info", i915_hangcheck_info, 0},
Jesse Barnesf97108d2010-01-29 11:27:07 -08005269 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07005270 {"i915_emon_status", i915_emon_status, 0},
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07005271 {"i915_ring_freq_table", i915_ring_freq_table, 0},
Daniel Vetter9a851782015-06-18 10:30:22 +02005272 {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08005273 {"i915_fbc_status", i915_fbc_status, 0},
Paulo Zanoni92d44622013-05-31 16:33:24 -03005274 {"i915_ips_status", i915_ips_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08005275 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01005276 {"i915_opregion", i915_opregion, 0},
Jani Nikulaada8f952015-12-15 13:17:12 +02005277 {"i915_vbt", i915_vbt, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01005278 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Widawskye76d3632011-03-19 18:14:29 -07005279 {"i915_context_status", i915_context_status, 0},
Ben Widawskyc0ab1ae2014-08-07 13:24:26 +01005280 {"i915_dump_lrc", i915_dump_lrc, 0},
Oscar Mateo4ba70e42014-08-07 13:23:20 +01005281 {"i915_execlists", i915_execlists, 0},
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02005282 {"i915_forcewake_domains", i915_forcewake_domains, 0},
Daniel Vetterea16a3c2011-12-14 13:57:16 +01005283 {"i915_swizzle_info", i915_swizzle_info, 0},
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01005284 {"i915_ppgtt_info", i915_ppgtt_info, 0},
Ben Widawsky63573eb2013-07-04 11:02:07 -07005285 {"i915_llc", i915_llc, 0},
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03005286 {"i915_edp_psr_status", i915_edp_psr_status, 0},
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02005287 {"i915_sink_crc_eDP1", i915_sink_crc, 0},
Jesse Barnesec013e72013-08-20 10:29:23 +01005288 {"i915_energy_uJ", i915_energy_uJ, 0},
Damien Lespiau6455c872015-06-04 18:23:57 +01005289 {"i915_runtime_pm_status", i915_runtime_pm_status, 0},
Imre Deak1da51582013-11-25 17:15:35 +02005290 {"i915_power_domain_info", i915_power_domain_info, 0},
Damien Lespiaub7cec662015-10-27 14:47:01 +02005291 {"i915_dmc_info", i915_dmc_info, 0},
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08005292 {"i915_display_info", i915_display_info, 0},
Ben Widawskye04934c2014-06-30 09:53:42 -07005293 {"i915_semaphore_status", i915_semaphore_status, 0},
Daniel Vetter728e29d2014-06-25 22:01:53 +03005294 {"i915_shared_dplls_info", i915_shared_dplls_info, 0},
Dave Airlie11bed9582014-05-12 15:22:27 +10005295 {"i915_dp_mst_info", i915_dp_mst_info, 0},
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01005296 {"i915_wa_registers", i915_wa_registers, 0},
Damien Lespiauc5511e42014-11-04 17:06:51 +00005297 {"i915_ddb_info", i915_ddb_info, 0},
Jeff McGee38732182015-02-13 10:27:54 -06005298 {"i915_sseu_status", i915_sseu_status, 0},
Vandana Kannana54746e2015-03-03 20:53:10 +05305299 {"i915_drrs_status", i915_drrs_status, 0},
Chris Wilson1854d5c2015-04-07 16:20:32 +01005300 {"i915_rps_boost_info", i915_rps_boost_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05005301};
Ben Gamari27c202a2009-07-01 22:26:52 -04005302#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05005303
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01005304static const struct i915_debugfs_files {
Daniel Vetter34b96742013-07-04 20:49:44 +02005305 const char *name;
5306 const struct file_operations *fops;
5307} i915_debugfs_files[] = {
5308 {"i915_wedged", &i915_wedged_fops},
5309 {"i915_max_freq", &i915_max_freq_fops},
5310 {"i915_min_freq", &i915_min_freq_fops},
5311 {"i915_cache_sharing", &i915_cache_sharing_fops},
Chris Wilson094f9a52013-09-25 17:34:55 +01005312 {"i915_ring_missed_irq", &i915_ring_missed_irq_fops},
5313 {"i915_ring_test_irq", &i915_ring_test_irq_fops},
Daniel Vetter34b96742013-07-04 20:49:44 +02005314 {"i915_gem_drop_caches", &i915_drop_caches_fops},
5315 {"i915_error_state", &i915_error_state_fops},
5316 {"i915_next_seqno", &i915_next_seqno_fops},
Damien Lespiaubd9db022013-10-15 18:55:36 +01005317 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
Ville Syrjälä369a1342014-01-22 14:36:08 +02005318 {"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
5319 {"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
5320 {"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
Rodrigo Vivida46f932014-08-01 02:04:45 -07005321 {"i915_fbc_false_color", &i915_fbc_fc_fops},
Todd Previteeb3394fa2015-04-18 00:04:19 -07005322 {"i915_dp_test_data", &i915_displayport_test_data_fops},
5323 {"i915_dp_test_type", &i915_displayport_test_type_fops},
5324 {"i915_dp_test_active", &i915_displayport_test_active_fops}
Daniel Vetter34b96742013-07-04 20:49:44 +02005325};
5326
David Weinehall36cdd012016-08-22 13:59:31 +03005327void intel_display_crc_init(struct drm_i915_private *dev_priv)
Damien Lespiau07144422013-10-15 18:55:40 +01005328{
Daniel Vetterb3783602013-11-14 11:30:42 +01005329 enum pipe pipe;
Damien Lespiau07144422013-10-15 18:55:40 +01005330
Damien Lespiau055e3932014-08-18 13:49:10 +01005331 for_each_pipe(dev_priv, pipe) {
Daniel Vetterb3783602013-11-14 11:30:42 +01005332 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
Damien Lespiau07144422013-10-15 18:55:40 +01005333
Damien Lespiaud538bbd2013-10-21 14:29:30 +01005334 pipe_crc->opened = false;
5335 spin_lock_init(&pipe_crc->lock);
Damien Lespiau07144422013-10-15 18:55:40 +01005336 init_waitqueue_head(&pipe_crc->wq);
5337 }
5338}
5339
Chris Wilson1dac8912016-06-24 14:00:17 +01005340int i915_debugfs_register(struct drm_i915_private *dev_priv)
Ben Gamari20172632009-02-17 20:08:50 -05005341{
Chris Wilson91c8a322016-07-05 10:40:23 +01005342 struct drm_minor *minor = dev_priv->drm.primary;
Daniel Vetter34b96742013-07-04 20:49:44 +02005343 int ret, i;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01005344
Ben Widawsky6d794d42011-04-25 11:25:56 -07005345 ret = i915_forcewake_create(minor->debugfs_root, minor);
5346 if (ret)
5347 return ret;
Daniel Vetter6a9c3082011-12-14 13:57:11 +01005348
Damien Lespiau07144422013-10-15 18:55:40 +01005349 for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) {
5350 ret = i915_pipe_crc_create(minor->debugfs_root, minor, i);
5351 if (ret)
5352 return ret;
5353 }
5354
Daniel Vetter34b96742013-07-04 20:49:44 +02005355 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
5356 ret = i915_debugfs_create(minor->debugfs_root, minor,
5357 i915_debugfs_files[i].name,
5358 i915_debugfs_files[i].fops);
5359 if (ret)
5360 return ret;
5361 }
Mika Kuoppala40633212012-12-04 15:12:00 +02005362
Ben Gamari27c202a2009-07-01 22:26:52 -04005363 return drm_debugfs_create_files(i915_debugfs_list,
5364 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05005365 minor->debugfs_root, minor);
5366}
5367
Chris Wilson1dac8912016-06-24 14:00:17 +01005368void i915_debugfs_unregister(struct drm_i915_private *dev_priv)
Ben Gamari20172632009-02-17 20:08:50 -05005369{
Chris Wilson91c8a322016-07-05 10:40:23 +01005370 struct drm_minor *minor = dev_priv->drm.primary;
Daniel Vetter34b96742013-07-04 20:49:44 +02005371 int i;
5372
Ben Gamari27c202a2009-07-01 22:26:52 -04005373 drm_debugfs_remove_files(i915_debugfs_list,
5374 I915_DEBUGFS_ENTRIES, minor);
Damien Lespiau07144422013-10-15 18:55:40 +01005375
David Weinehall36cdd012016-08-22 13:59:31 +03005376 drm_debugfs_remove_files((struct drm_info_list *)&i915_forcewake_fops,
Ben Widawsky6d794d42011-04-25 11:25:56 -07005377 1, minor);
Damien Lespiau07144422013-10-15 18:55:40 +01005378
Daniel Vettere309a992013-10-16 22:55:51 +02005379 for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) {
Damien Lespiau07144422013-10-15 18:55:40 +01005380 struct drm_info_list *info_list =
5381 (struct drm_info_list *)&i915_pipe_crc_data[i];
5382
5383 drm_debugfs_remove_files(info_list, 1, minor);
5384 }
5385
Daniel Vetter34b96742013-07-04 20:49:44 +02005386 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
5387 struct drm_info_list *info_list =
David Weinehall36cdd012016-08-22 13:59:31 +03005388 (struct drm_info_list *)i915_debugfs_files[i].fops;
Daniel Vetter34b96742013-07-04 20:49:44 +02005389
5390 drm_debugfs_remove_files(info_list, 1, minor);
5391 }
Ben Gamari20172632009-02-17 20:08:50 -05005392}
Jani Nikulaaa7471d2015-04-01 11:15:21 +03005393
5394struct dpcd_block {
5395 /* DPCD dump start address. */
5396 unsigned int offset;
5397 /* DPCD dump end address, inclusive. If unset, .size will be used. */
5398 unsigned int end;
5399 /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */
5400 size_t size;
5401 /* Only valid for eDP. */
5402 bool edp;
5403};
5404
5405static const struct dpcd_block i915_dpcd_debug[] = {
5406 { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE },
5407 { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS },
5408 { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 },
5409 { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET },
5410 { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 },
5411 { .offset = DP_SET_POWER },
5412 { .offset = DP_EDP_DPCD_REV },
5413 { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 },
5414 { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB },
5415 { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET },
5416};
5417
5418static int i915_dpcd_show(struct seq_file *m, void *data)
5419{
5420 struct drm_connector *connector = m->private;
5421 struct intel_dp *intel_dp =
5422 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
5423 uint8_t buf[16];
5424 ssize_t err;
5425 int i;
5426
Mika Kuoppala5c1a8872015-05-15 13:09:21 +03005427 if (connector->status != connector_status_connected)
5428 return -ENODEV;
5429
Jani Nikulaaa7471d2015-04-01 11:15:21 +03005430 for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) {
5431 const struct dpcd_block *b = &i915_dpcd_debug[i];
5432 size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1);
5433
5434 if (b->edp &&
5435 connector->connector_type != DRM_MODE_CONNECTOR_eDP)
5436 continue;
5437
5438 /* low tech for now */
5439 if (WARN_ON(size > sizeof(buf)))
5440 continue;
5441
5442 err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size);
5443 if (err <= 0) {
5444 DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n",
5445 size, b->offset, err);
5446 continue;
5447 }
5448
5449 seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf);
kbuild test robotb3f9d7d2015-04-16 18:34:06 +08005450 }
Jani Nikulaaa7471d2015-04-01 11:15:21 +03005451
5452 return 0;
5453}
5454
5455static int i915_dpcd_open(struct inode *inode, struct file *file)
5456{
5457 return single_open(file, i915_dpcd_show, inode->i_private);
5458}
5459
5460static const struct file_operations i915_dpcd_fops = {
5461 .owner = THIS_MODULE,
5462 .open = i915_dpcd_open,
5463 .read = seq_read,
5464 .llseek = seq_lseek,
5465 .release = single_release,
5466};
5467
5468/**
5469 * i915_debugfs_connector_add - add i915 specific connector debugfs files
5470 * @connector: pointer to a registered drm_connector
5471 *
5472 * Cleanup will be done by drm_connector_unregister() through a call to
5473 * drm_debugfs_connector_remove().
5474 *
5475 * Returns 0 on success, negative error codes on error.
5476 */
5477int i915_debugfs_connector_add(struct drm_connector *connector)
5478{
5479 struct dentry *root = connector->debugfs_entry;
5480
5481 /* The connector must have been registered beforehands. */
5482 if (!root)
5483 return -ENODEV;
5484
5485 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
5486 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
5487 debugfs_create_file("i915_dpcd", S_IRUGO, root, connector,
5488 &i915_dpcd_fops);
5489
5490 return 0;
5491}